Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

calling BIG FORTRAN dll from c++

dannyt
Beginner
381 Views
I have a large library (around 1000 files) of legacy (f77) FORTRAN code that I have been using for several years. I use to compile the code with CFV 6.0 and it has been serving me well, calling it from vc++, for many years. I declared the prototypes for the functions using syntax like...

extern "C" void _stdcall D2ADF(char *, int, int *, double *, char *, int, int *, int *, int *);

And I pass everything by pointer (except for the hidden string length values).

I changed jobs a few month ago and took the library with me to use in my new position. I recently needed to make changes to one of the routines. My new company has purchased the Intel FORTRAN compiler for me. I have been having an extremely difficult time getting it to work correctly with the Intel compiler.

-I created a dll project with the FORTRAN files and put the following lines in the routines I needed to "expose"...

!DEC$ IF DEFINED (_DLL)
!DEC$ ATTRIBUTES DLLEXPORT :: D2ADF
!DEC$ END IF

I placed these line before any executable code. (They we at the top of the file for the CVF compiler)

If I compile the library with /Gz I will not begin to get a clean compile. I get errors like...

d0acs.f: Error 531 : The variable CMEM cannot be a value dummy argument use CHARACTER(*) instead.

I don't get this error if I compile with /Gm, but if I compile with /Gm I get bad return values when I call the FORTRAN dll routines from vc++ and things don't work right. I think because things are being passed by value and not being updated in the c++ code.

I think my problem has something to do with IF using pass-by value in _stdcall by default (per the Intel FORTRAN user's guide: Appendix A), where (accourding to post) CVF defaults to pass-by-reference.

Is there any way to get my dll working again? I use pass-by-pointer/reference through out my vc++ code as well as within all the FORTRAN code.


Do I have to edit the approximatly 1000 files to add !DEC$ATTRIBUTES STDCALL?

Or worse yet edit each file and declare all passed variables as !DEC$ATTRIBUTES REFERENCE.


Also - another problem: In my FORTRAN dll project - if I press F7 to build the project I get the following error:

Cannot start tool.
The parameter is incorrect.
Error spawning 'vcspawn.exe'. The build could not be performed.
Linking...
LINK : fatal error LNK1104: cannot open file ".Debugd0acs.obj"
Error executing link.exe.

dtni.dll - 2 error(s), 0 warning(s)


Though I can right click each file (x1000) and build them individually and then press F7 to link. I ended up exporting a makefile and doing all my building from the command line using nmake.

Does anyone know what is wrong here?

Thanks for you help
Dan

Message Edited by intel.software.network.support on 12-09-2005 02:31 PM

0 Kudos
0 Replies
Reply