- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I have Intel Fortran Compiler 8.1 running on a 64-bit Itanium under Windows XP-64 version 2003.
I'm trying to link a Fortran DLL to a Fortran program. I have included the following lines in the DLL source code:
INTERFACE
SUBROUTINE RIPNET_SUB(id,fit,ncolp,nobsp,outfile,varname,w,xz,y)
!DEC$ ATTRIBUTES DLLIMPORT :: RIPNET_SUB
character outfile*1024,varname(2+ncolp)*40
integer id(nobsp),ncolp,nobsp
real*8 fit(nobsp),w(nobsp),xz(nobsp,ncolp),y(nobsp)
real*8, allocatable :: x(:,:)
END SUBROUTINE RIPNET_SUB
END INTERFACE
and it compiles fine with the following command:
ifort /dll ripnet.for /O3 /G2 /map:ripnet.map /link /out:ripnlib.dll
Next, I have included the following line in the main program:
!DEC$ ATTRIBUTES DLLEXPORT :: RIPNET_SUB
to compile and link all the code together I use:
ifort detailopt.for /O3 /G2 /map:detailopt.map /link ripnet.lib /out:detailopt.exe
It all links fine and I can run the program until just after it returns from the DLL the second time. I can write a statement to the screen at that point('back in detailopt 2'), but when I try to set a valid variable to zero I get:
Sample Run:
leaving detailopt 1
in ripnet
out ripnet
back in detailopt 1
leaving detailopt 2
in ripnet
out ripnet
back in detailopt 2
forrtl: severe (157): Program Exception - access violation
Image PC Routine Line Source
detailopt.exe 000000000040C134 Unknown Unknown Unknown
detailopt.exe 0000000000404510 Unknown Unknown Unknown
detailopt.exe 0000000000581CF0 Unknown Unknown Unknown
detailopt.exe 000000000056B1E0 Unknown Unknown Unknown
kernel32.dll 0000000077D24510 Unknown Unknown Unknown
32-bit versions of the same code work fine. I'm not sure if I'm compiling/linking these up correctly. I notice that the size of the 64-bit DLL is very small when compare with every other piece of Fortran code I've converted from 32-bit to 64-bit.
For example:
32-bit DetailOpt.exe = 72 kb(compiled with Compac Visual Fortran 6.6A)
32-bit Ripnlib.dll = 200 kb (compiled with Compac Visual Fortran 6.6A)
64-bit DetailOpt.exe = 1718 kb
64-bit Ripnlib.dll = 377 kb
Anyway, if anyone can gove me some pointers on how to code, compile, link and/or debug this, that would be great.
Thankx,
Mark
Message Edited by yood on 02-08-2006 02:20 PM
OK, so after grasping at various straws for the past day, I was able to come up come up with the following solution / even more perplexing situation.
The allegedly valid variable which I referenced upon return from the DLL was an element of a dynamically allocated array (real*8). It caused th e crash. I traced back thru the program and discovered that even referencing it immediately after its allocation was fatal. However,If i put a simple write statement like:
write(6,'(/a)') ' here is the stat array '
immediately after allocation, then the allocatable array is fine and the program runs to completion. Without the write statement - crash/burn as soon as the allocatable array is referenced in any way.
I'm thinking its some kind of boundary problem or some such thing. Is there any way to get around this and/or ensure this won't happen or should I just have a nice display and call it a feature?
Any thoughts would be interesting.
Thankx to all who viewed my query,
Mark
Message Edited by yood on 02-09-2006 02:28 PM
Link Copied
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page