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

In summary, the conversation discusses a problem where the speaker wants to join two FORTRAN codes, but is unsure if the second code can be represented as a subroutine due to its length and multiple subroutines. They are using Linux and the Intel Fortran compiler and need an interface between the two programs. However, when trying to put the second program as a module, they encounter errors related to OPEN statements being in the wrong place. The solution suggested is to either merge the source code of the second program into the first or adapt the routines of the second program so they can be called as a code library.
  • #1
Milentije
48
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
  • #2
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')
 
  • #3
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).
 
  • #4
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.
 
  • #5


Thank you for sharing your question with us. Joining two FORTRAN codes can be a complex task, but it is certainly possible to do so using the Intel Fortran compiler on Linux. There are a few different approaches you could take to solve this problem, depending on your specific needs and the structure of your codes.

One option is to create a new main program that calls both of your existing codes as subroutines. This would require some restructuring of your codes, but it would allow you to have one executable that runs both codes. You could also consider using modules to share common variables and subroutines between the two codes.

Another option is to use the "include" statement to combine the two codes into one file. This would essentially merge the two codes together, but it may not be the most elegant solution and could lead to difficulties in maintaining and updating your code in the future.

It is also possible to have one executable call the other, but this would require some additional programming to set up communication between the two codes.

Overall, the best approach will depend on the specific requirements and structure of your codes. I recommend consulting with a FORTRAN expert or seeking guidance from the Intel Fortran compiler documentation to determine the best course of action for your particular situation. Best of luck with your project!
 

What is FORTRAN?

FORTRAN (short for Formula Translation) is a high-level programming language used for scientific, engineering, and mathematical computations. It was developed in the 1950s and is known for its efficiency and speed in solving complex mathematical and scientific problems.

What is the purpose of joining two FORTRAN codes?

Joining two FORTRAN codes allows for the combination of different functions and subroutines from each code to create a more comprehensive program. This can improve the efficiency and accuracy of the overall solution to a problem.

What is the Intel Compiler?

The Intel Compiler is a highly optimized compiler for Intel processors that can generate efficient code for a variety of programming languages, including FORTRAN. It is designed to take advantage of the specific features and capabilities of Intel processors to improve performance.

Why use the Intel Compiler for FORTRAN?

Using the Intel Compiler with FORTRAN can result in faster and more efficient code execution, as well as improved parallelization and vectorization capabilities. It also offers advanced debugging and optimization tools to help identify and fix any issues in the code.

Why use Linux for FORTRAN programming?

Linux is an open-source operating system that is popular among scientists and researchers due to its stability, flexibility, and support for high-performance computing. It also offers a wide range of development tools and libraries, making it a popular choice for FORTRAN programming.

Similar threads

  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
2
Replies
59
Views
9K
  • Programming and Computer Science
Replies
4
Views
589
Replies
6
Views
1K
  • Programming and Computer Science
Replies
8
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
Back
Top