 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Emanuele
Joined: 21 Oct 2009 Posts: 78 Location: Bologna (Italy)
|
Posted: Thu Nov 08, 2012 11:07 pm Post subject: Type Initialization Exception for .NET |
|
|
Hi!
I'am trying to recompile an existing program, written in fixed format, for the .NET platform. This program compiles and works fine for the Win32 platform, while it immediatly crashes if compiled for the NET, returning a Type Initialization Exception.
This is the minimum portion of the program generating the exception:
Code: | program test
implicit real(kind=2) (a-h,o-z)
character(len=120):: path_mod,pmodl,name_mod,nmodl
character(len=120):: name_hgt,nhght,name_cnv,nconv
character(len=120):: path_pnt,ppnts,name_pnt,npnts
character(len=120):: path_out,pout,name_out,nout
parameter(path_mod = ' ',
& path_pnt = ' ',
& name_pnt = 'INPUT.DAT',
& path_out = ' ',
& name_out = 'OUTPUT.DAT')
parameter(iumi = 11,
& lmin = 2,
& lmax = 2190,
& name_mod = 'EGM2008_to2190_TideFree',
& aegm = 6378136.3d0,
& gmegm = 0.3986004415d20,
& isub = 1,
& igrid = 0,
& isw = 82,
& exclud = 9999.0d0)
parameter(iuci = 13,
& jmin = 0,
& jmax = 2160,
& name_cnv = 'Zeta-to-N_to2160_egm2008')
stop
end |
I cannot understand what's wrong. I'm working with FTN95 6 and Visual Studio 2008 on windows 7 x64. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Fri Nov 09, 2012 10:18 am Post subject: |
|
|
I have tried using your code from Plato and from the command line and there are no problems.
Try these two routes on your machine first so that we can identify if it is a problem with Visual Studio. |
|
Back to top |
|
 |
Emanuele
Joined: 21 Oct 2009 Posts: 78 Location: Bologna (Italy)
|
Posted: Fri Nov 09, 2012 12:48 pm Post subject: |
|
|
Dear Paul,
thank you for the reply. I can confirm that there are no problems with Plato, so the issue seems limited to the VS environment.
Furthermore, I found that the exception raises only with CheckMate mode (on NET of course).
Any ideas?
Thanks again for your help.
Emanuele |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Fri Nov 09, 2012 2:05 pm Post subject: |
|
|
The next thing to do is to look at the build log from Visual Studio. In the Output window, hold down the Ctrl key and click on the link for the build log.
In the build log, find the command line options for FTN95 and DBK_LINKx.
Now issue the same commands from a Command Prompt window (DOS box). If the same problem occurs then you can remove options selectively to see which one is causing the problem (besides /CHECKMATE which you know is OK). |
|
Back to top |
|
 |
Emanuele
Joined: 21 Oct 2009 Posts: 78 Location: Bologna (Italy)
|
Posted: Fri Nov 09, 2012 2:50 pm Post subject: |
|
|
Thanks again.
I did some tests and the problem seems to be in the combined use of /checkmate and /full_debug. In fact, by omitting one of the two, the program runs properly.
And I read on the help that the /full_debug option implies something related to the parameter statements... |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Fri Nov 09, 2012 7:40 pm Post subject: |
|
|
I think that you can safely omit /full_debug. /full_debug implies /debug but you already have /debug in /check and /checkmate.
I am not sure what /full_debug does above /debug (as you say, something to do with parameters) but I will log this for investigation. |
|
Back to top |
|
 |
Emanuele
Joined: 21 Oct 2009 Posts: 78 Location: Bologna (Italy)
|
Posted: Sat Nov 10, 2012 2:53 pm Post subject: |
|
|
Thanks for your help. |
|
Back to top |
|
 |
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Sun Nov 11, 2012 6:10 pm Post subject: Re: |
|
|
PaulLaidler wrote: | I am not sure what /full_debug does above /debug (as you say, something to do with parameters) but I will log this for investigation. |
/full_debug makes the values of parameters visible in the debugger. _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
 |
Emanuele
Joined: 21 Oct 2009 Posts: 78 Location: Bologna (Italy)
|
Posted: Mon Nov 12, 2012 2:52 pm Post subject: |
|
|
Dear Paul,
I made other tests and I reproduced the exception also on Plato, wih the following code, which is the same as before but with some more declaration statements.
Code: | program test
implicit real(kind=2) (a-h,o-z)
character(len=120):: path_mod,pmodl,name_mod,nmodl
character(len=120):: name_hgt,nhght,name_cnv,nconv
character(len=120):: path_pnt,ppnts,name_pnt,npnts
character(len=120):: path_out,pout,name_out,nout
parameter(path_mod = ' ',
& path_pnt = ' ',
& name_pnt = 'INPUT.DAT',
& path_out = ' ',
& name_out = 'OUTPUT.DAT')
parameter(iumi = 11,
& lmin = 2,
& lmax = 2190,
& name_mod = 'EGM2008_to2190_TideFree',
& aegm = 6378136.3d0,
& gmegm = 0.3986004415d20,
& isub = 1,
& igrid = 0,
& isw = 82,
& exclud = 9999.0d0)
parameter(iuci = 13,
& jmin = 0,
& jmax = 2160,
& name_cnv = 'Zeta-to-N_to2160_egm2008')
parameter(iusc = 12,
& maxpt = 1000000)
parameter(maxr=100)
parameter(ncols = 1,
& nrows = 1,
& nmax0 = max(lmax,jmax),
& nmax01 = nmax0+1,
& nmax02 = nmax0+2,
& jcol = 1,
& jfft = 1)
parameter(zeta0 = -41.d0/100.d0)
parameter(ae = 6378137.d0,
& gm = 0.3986004418d20,
& omega = 7292115.d-11,
& c20 = -0.484166774985d-03,
& rf = 0.d0)
real(kind=2) zonals(10),cz(20),da(5)
real(kind=2) batch(ncols*maxr),grsv(15)
real(kind=2) cnm(nmax01,nmax01),snm(nmax01,nmax01)
real(kind=2) scrd(ncols,2),statd(22),ddlon(ncols)
real(kind=2) flat(maxr),flon(maxr),dist(maxr),pt(maxr)
real(kind=2) pt_a(maxpt),ga(maxpt),zeta(maxpt),corr(maxpt)
real(kind=2) flat_a(maxpt),flon_a(maxpt),dist_a(maxpt),
& horth_a(maxpt)
real(kind=2) uc(maxr),tc(maxr),uic(maxr),uic2(maxr)
real(kind=2) cotc(maxr),thet2(maxr),thet1(maxr),thetc(maxr)
real(kind=2) pmm_a(nmax01,maxr+1),pmm_b(nmax01,maxr),f_n(maxr),
& f_s(maxr)
real(kind=2) p(nmax02,maxr),p1(nmax02,maxr),p2(nmax02,maxr)
real(kind=2) c_ev(nmax01,maxr),s_ev(nmax01,maxr),kk(nmax01,maxr)
real(kind=2) c_od(nmax01,maxr),s_od(nmax01,maxr)
real(kind=2) cr1(jfft),sr1(jfft),cr2(jfft),sr2(jfft)
real(kind=2) aux(2*jcol),wrkfft(2*jcol),factn(nmax01),k(nmax01)
real(kind=2) cml(nmax01),sml(nmax01)
real(kind=1) data(ncols,nrows)
integer(kind=3) it(maxr),it_a(maxpt),iex(maxr),zero(maxr+1)
stop
end |
Running with Checkmate NET option, I get the following error message in the prompt (sorry for the italian!):
Last edited by Emanuele on Mon Nov 12, 2012 5:17 pm; edited 1 time in total |
|
Back to top |
|
 |
Emanuele
Joined: 21 Oct 2009 Posts: 78 Location: Bologna (Italy)
|
Posted: Mon Nov 12, 2012 2:55 pm Post subject: |
|
|
Quote: | System.TypeInitializationException: L'inizializzatore di tipo di 'Test' ha generato un'eccezione. ---> System.TypeInitializationException
: L'inizializzatore di tipo di 'Salford.Fortran.RTLibrary' ha generato un'eccezione. ---> System.BadImageFormatException: Tentativo di caricare un programma con un formato non corretto. (Eccezione da HRESULT: 0x8007000B)
in Salford.Fortran.RTLibrary.__com_plus_initialise(Int32 hin)
in Salford.Fortran.RTLibrary.InitLibrary()
--- Fine dell'analisi dello stack dell'eccezione interna ---
in Salford.Fortran.RTLibrary.InitLibrary()
in Test..cctor()
--- Fine dell'analisi dello stack dell'eccezione interna ---
in Test.TEST() |
It is exactly the same exception I got in VS environment. Are you able to reproduce this behaviour?
Thanks in advance!
Last edited by Emanuele on Mon Nov 12, 2012 5:17 pm; edited 1 time in total |
|
Back to top |
|
 |
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Mon Nov 12, 2012 4:06 pm Post subject: Re: Type Initialization Exception for .NET |
|
|
Emanuele wrote: |
I cannot understand what's wrong. I'm working with FTN95 6 and Visual Studio 2008 on windows 7 x64.
|
As you are running x64 version of Windows 7, are you sure that you are using 32 bit CLR?
I have set it as default on my computer, it goes something like:
Code: | C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Ldr64.exe SetWow |
To revert back to 64-bit CLR:
Code: | C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Ldr64.exe Set64 |
|
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Mon Nov 12, 2012 4:15 pm Post subject: |
|
|
Your code compiles and links in Plato for me both with and without /full_debug. |
|
Back to top |
|
 |
Emanuele
Joined: 21 Oct 2009 Posts: 78 Location: Bologna (Italy)
|
Posted: Mon Nov 12, 2012 5:14 pm Post subject: |
|
|
Thank everybody!
I tried by setting "Ldr64.exe SetWow", as jalih suggested, and in fact the behaviour changes. I get no more initialization exception, but the program now crashes without any message! (only with /checkmate).
Regarding the CLR, I believed that the 32 bit version, was automatically chosen, considering that the /REF options of the compiler refer to the 32 bit versions of the NET dlls; but if it is not so, what are the consequences on redistribution? |
|
Back to top |
|
 |
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Mon Nov 12, 2012 5:39 pm Post subject: Re: |
|
|
Emanuele wrote: | I get no more initialization exception, but the program now crashes without any message! (only with /checkmate).
|
Just tested this myself and got the same symptom...
However, there was infact a StackOverFlowException in the process. Try increasing the stack size on linker options, it worked for me! |
|
Back to top |
|
 |
Emanuele
Joined: 21 Oct 2009 Posts: 78 Location: Bologna (Italy)
|
Posted: Mon Nov 12, 2012 5:50 pm Post subject: |
|
|
You are right, thanks!
Now the remaining question is what happens if I distribute an application to an end-user who has not set the CLR version to 32 bit by default? |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|