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

Calling a Fortran DLL in a Fortran poject

Dave12
Novice
4,890 Views

Hello everyone,

I am writing a Fortran program using Visual Studio and the ifort compiler. I would now like to use a DLL that has been made available to me. This was also written in Fortran. I already had a similar problem with a DLL written in C++, which was solved here (https://community.intel.com/t5/Intel-Fortran-Compiler/Integrate-C-DLL-in-Fortran-Code/m-p/1410919#M162620). Of course, this solution no longer works if it is not a C++ DLL.
Unfortunately, I only find suggestions on how Fortran DLLs can be used in other programming languages. What I have found are approaches like:

      !DEC$ ATTRIBUTES DLLIMPORT :: libdiscon
      !DEC$ ATTRIBUTES C, ALIAS:'DISCON' :: DISCON
    
      call DISCON(SWAP, Fail, infile, outname, msg )

The DLL I want to use is called libdiscon.dll. It contains the subroutine DISCON(), which I would like to access. I have placed libdiscon.dll in the debug folder of Visual Studio.

I would be very grateful if someone could help me.

Best regards

 

 

 

 

 

0 Kudos
44 Replies
JohnNichols
Valued Contributor III
402 Views

If this crashes, then this points bask to an argument error or code between the load dll and call corrupted the dll.

 

Jim:

I have been following along, I wish I was this good, but anyway, what was the word you meant above at bask, is it back?  

 

John

0 Kudos
jimdempseyatthecove
Honored Contributor III
400 Views

Yes, back. A typographical error on my part. Euphemistically a bug in the instructions.

Spellchecker didn't catch this, perhaps a grammar checker would have caught this.

 

Thanks for pointing this out.

 

Jim Dempsey

0 Kudos
Dave12
Novice
399 Views

Hello together,

to ensure the error was not caused by a damaged DLL, as you also supposed, I replaced it with another one that I furtunately found. Now I finally receive messages from the controller code. Nevertheless, the proposed debugging options will certainly also be helpful in the future.  Many thanks for your patient help and best regards!

 

0 Kudos
Reply