Fortran Join 2 FORTRAN Codes: Problem Solved w/ Intel Compiler & Linux

AI Thread Summary
To integrate two FORTRAN codes, one being the main program and the other a geophysics calculation tool, it is essential to address the structure of the second code, which contains over 2000 lines and multiple subroutines. Directly incorporating the second code as a module is problematic due to errors related to the placement of executable statements, specifically the OPEN statements, which must be positioned above any executable code in the module. To resolve this, the second program can either be merged into the main program to create a single source file or modified to compile into a code library that the main program can call. This approach allows for an effective interface between the two programs while adhering to FORTRAN's structural requirements.
Milentije
Messages
47
Reaction score
0
I have a problem,actually I want to join two FORTRAN codes.One of them is main and the other calculates some issues(geophysics stuff).I am not sure that the second code can be represented as subroutine because it has 2000+ lines,with 10 subroutines inside itself.How to solve this?Is it possible that one executable calls the other?I am working on Linux,with Intel Fortran compiler.
 
Technology news on Phys.org
I need interface between two programs.I can not put second program as module cause I get errors like this:
mt2ddib1.for(23): error #6274: This statement must not appear in the specification part of a module
open(2,file='test_p7.dat',status='old')
--------^
mt2ddib1.for(29): error #6274: This statement must not appear in the specification part of a module
open(3,file='test_sh7.dat',status='old')
--------^
mt2ddib1.for(30): error #6274: This statement must not appear in the specification part of a module
open(4,file='test_res.dat',status='old')
--------^
mt2ddib1.for(35): error #6274: This statement must not appear in the specification part of a module
open(50,file='e.dat',status='unknown')
 
The four OPEN statements are in the wrong places. Apparently mt2ddib1.for has some variable declarations somewhere after line 35. The declarations need to be moved so that they are above any executable statements (such as your OPEN statements).
 
If you have the source code for the second program, you can either merge it into the first program and make one composite source file, or you can adapt the routines of the second program so that they can be compiled and collected into a code library which is callable by the first program.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Replies
3
Views
2K
Replies
59
Views
11K
Replies
8
Views
4K
Replies
4
Views
2K
Replies
5
Views
3K
Replies
2
Views
2K
Back
Top