Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner

Two FORTRAN program

I have 2 different FORTRAN programs (quite big programs). Let us call program 'A' and 'B'

My program 'B' needs to use a subroutine of program A (exactly the same subroutine). Is it possible to call that subroutine of A from a subroutine of B?

Any examples will be appreciated.

Peter

 

0 Kudos
2 Replies
Highlighted

What you normally do is

What you normally do is separate the subroutine into its own source file then either:

a) Add the source file to both of your projects/makefile for (A and B).

b) Compile the shared subroutine(s) into a Library project, then add this library (and dependency on) to both of your projects. The recommended practice in Fortran is to place the subroutine into a CONTAINS section of a module, then USE the module in A and B. The path to the .mod file must be in your INCLUDE path, the path to the resultant .obj file (when not placed into a library) may also need to be specified.

Jim Dempsey

0 Kudos
Highlighted

If you are using Microsoft

If you are using Microsoft Visual Studio, you can have a single Solution that has three Projects:

   one Project to build the subroutine(s) Library or Modules
   one Project to build program A (dependent on the Library Project)
   and one Project to build program B (dependent on the Library Project).

For debugging you then set the Startup Project to your choice of either A or B.

Jim Dempsey

0 Kudos