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

Calling Fortran DLL from Fortran

fcedotal
Beginner
514 Views
I am brand new to Fortran. I have VB project that will have to call a Fortran DLL. For test purposes, to eliminate the VB to Fortran interface, I thought that I could write short main Fortran program to call the Fortran DLL and test the Fortran in the IDE debugger. This what I've tried.

Intel Fortran 7.0 in Visual C++ 6.0 IDE

I have 2 projects in a workspace.
The first consists of several files containing functions and subroutines compiled as a DLL. This compiles fine with no errors. The declaration of the subroutine main entry into the DLL has
SUBROUTINE MYDLL(S1, S2, S3)
!DEC$ ATTRIBUTES DLLEXPORT :: MYDLL
!DEC$ ATTRIBUTES ALIAS:'MYDLL'::MYDLL
calls to functions and other subroutines
rest of the code
END


The 2nd project is a Fortran main program that calls MYDLL. The main program contains the following

PROGRAM MAIN
!DEC$ ATTRIBUTES DLLIMPORT :: MYDLL
!DEC$ ATTRIBUTES ALIAS:'MYDLL'::MYDLL
CHAR (LEN=20) VAR1, VAR2, VAR3
some code
CALL MYDLL(VAR1, VAR2, VAR3)
more code
END

to import MYDLL.
When I try to compile, I get the following error on the CALL MYDLL line:
..main.for(8) Error 127 : This is not the name of a subroutine



0 Kudos
2 Replies
Steven_L_Intel1
Employee
514 Views
Try adding EXTERNAL MYDLL in the main program before the ATTRIBUTES directives.

Steve
0 Kudos
fcedotal
Beginner
514 Views
That helped. I am not moving on to debugging stage (problems) and will submit new post with that experience.
Thanks
0 Kudos
Reply