View previous topic :: View next topic |
Author |
Message |
Anonymous Guest
|
Posted: Wed May 24, 2006 3:58 am Post subject: Library of subroutines |
|
|
Hi
Does anyone know how to create a library of subroutines on PLATO3 which would then be automatically be accessible by means of a USE statement at the beginning of the program?
I have dozens of subroutines which I use regularly, so what I'd like to do would be to create a library called MAIN containing these subroutines, then at the beginning of a program I would have the statement: USE MAIN
Thereafter I could call any subroutine by saying CALL <name_of _subroutine>
Any help would be greatly appreciated as I have no idea how to do this.
Thanks,
Mikhail Kalashnikov |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Wed May 24, 2006 12:39 pm Post subject: Library of subroutines |
|
|
Mikhail
The standard approach is to create a dynamic link library (DLL) of external subprograms rather than module procedures. To do this you simply create a project for a DLL rather than an executable.
In another project you can then access the DLL by using a "Reference" in the Project Explorer window. In this situation you do not need a USE statement in the code. External subroutines (in the DLL) can be called without declaring them. Functions should be declared like variables according to their return type, e.g,
REAL x, func
.....
x = func(2.0)
However...
If a call is made to an external subprogram that uses OPTIONAL or KEYWORD arguments or passes arrays that are "assumed shape" (i.e. use a colon rather than a star) then you must provide an INTERFACE that declares the subprogram.
|
|
Back to top |
|
|
Anonymous Guest
|
Posted: Thu May 25, 2006 3:56 am Post subject: Library of subroutines |
|
|
Paul
Thanks very much for your help. However, I am still having some trouble.
I selected "New project" and from there I chose "Fortran DLL".
Then, from the "project" menu, I selected "Add existing item" and selected all of the subroutines and functions which I wanted to include.
These subprograms were then listed in "source files" on the right hand side of the screen.
Next I hit "build" and the compilation completed without any errors.
Then, however a message appeared saying "Cannot create DLL: nothing to export"
What am I missing here?
Sorry about all the questions. I'm new to Fortran.
Thanks again
Mikhail Kalashnikov
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Thu May 25, 2006 6:11 am Post subject: Library of subroutines |
|
|
In the Project Properties dialog select Configuration Properties->Linker Options->Linker Options->Export all. |
|
Back to top |
|
|
Anonymous Guest
|
Posted: Thu May 25, 2006 7:20 am Post subject: Library of subroutines |
|
|
Thanks a million Paul!
Mikhail Kalashnikov |
|
Back to top |
|
|
|