- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello;
I am new to fortan. I am using Intel fortran81.
I want to know how I can call fortran subroutine defined in a fortran dll file from a main program written in fortran.
Could you provide me a sampleof both(fortran dll and fortran main program).
Thankx in advance.
Regards
Avinash
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am curious as to why you're using such an old version of the compiler.
There's nothing special you need to do to call a routine provided in a DLL other than link with the DLL's export library. If you have a Fortran executable calling a Fortran DLL, you should build the executable with the /libs:dll option otherwise you might have trouble using I/O or allocatable variables.
Here's a simple sample:
dllsub.f90
subroutine dllsub
!dec$ attributes dllexport :: dllsub
print *, "Hello from dllsub!"
end subroutine dllsub
main.f90
program main
call dllsub
end program main
Build commands:
ifort /dll dllsub.f90
ifort /libs:dll main.f90 dllsub.lib
You can optionally add:
!dec$ attributes dllimport :: dllsub
to the source for main.f90, but it is not required for routines. (It is for imported variables.)
There's nothing special you need to do to call a routine provided in a DLL other than link with the DLL's export library. If you have a Fortran executable calling a Fortran DLL, you should build the executable with the /libs:dll option otherwise you might have trouble using I/O or allocatable variables.
Here's a simple sample:
dllsub.f90
subroutine dllsub
!dec$ attributes dllexport :: dllsub
print *, "Hello from dllsub!"
end subroutine dllsub
main.f90
program main
call dllsub
end program main
Build commands:
ifort /dll dllsub.f90
ifort /libs:dll main.f90 dllsub.lib
You can optionally add:
!dec$ attributes dllimport :: dllsub
to the source for main.f90, but it is not required for routines. (It is for imported variables.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Steve;
Thankyou very much for your help.
I am working with a tool called Abaqus. The version I use of this tool requires Intel Compiler 8x.That's why I have to use the old compiler.
Regards
Avinash

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page