Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.

How DLL is called in FORTRAN 77?

Ahmad_Falahatpisheh
977 Views
I am trying to create a DLL with MATLAB. I am wondering if it is possible to open a DLL created by MATLAB in FORTRAN 77. Thank you.
0 Kudos
5 Replies
Steven_L_Intel1
Employee
977 Views

Are you using Intel Fortran?

When you "create the DLL", you need to understand MATLAB's conventions for how routines are called. Assuming that the process of creating the DLL also creates an "import library" (a .LIB), then you just call the routine like any other and link with the import library. This assumes that the DLL routine's calling and argument conventions match that of the Fortran compiler you are using.

0 Kudos
Ahmad_Falahatpisheh
977 Views
I am running user-subroutine of ABAQUS which is compiled by Intel Visual Fortran. I am writing the code in FORTRAN77 format.
0 Kudos
Steven_L_Intel1
Employee
977 Views

ABAQUS and MATLAB are not the same. If the DLL you want to call was built by Intel Visual Fortran, then a .LIB should have been created when the DLL was linked. You would link to that .LIB to define the routines in the DLL. You will still need to know what conventions were used. There may be some issues specific to ABAQUS/MATLAB that I am not familiar with.

From the caller side, just call the routine with the required arguments as you would any other Fortran routine.

I assume that when you say "FORTRAN 77 format" you mean fixed-form source. You are not using a FORTRAN 77 compiler.

0 Kudos
Ahmad_Falahatpisheh
977 Views
I am using FORTRAN77 format but with Intel Visual Fortran Compiler. Should DLL created by different programs (like MATLAB) be loaded differently? I mean do DLLs follow any specific standard regardless of the OS and program which creates those DLLs? Thank you.
0 Kudos
Steven_L_Intel1
Employee
977 Views

First of all, DLL is a Windows-specific term, though most other operating systems have a similar concept. "shared library" is a more universal term.

Calling a routine that is in a DLL is no different from calling a routine in a static library. With both you need to know what the routine expects for arguments, how they are passed, and the exact external name of the routine (uppercase, lowercase, mixed). On IA-32 Windows you also need to know if the routine uses the STDCALL or C calling convention. In both cases you need to be provided with the .LIB file generated from the library build. In the case of a DLL, this is the "export library" automatically created by the linker when the DLL is built. (It is possible to call a routine in a DLL without the export library, but that is more complicated.)

You would then consult your compiler's documentation for how to call a routine with those particular requirements.

0 Kudos
Reply