Fast connection between fortran 77 and 90

In summary, the speaker is seeking advice on how to implement functionality from Fortran90 routines into an old Fortran77 program. They are considering using common blocks and module statements to connect the data structures, but are unsure if it will be fast enough. They also mention their success in calling Fortran 77 subroutines from Fortran 95, but have not been able to call Fortran 77 functions. They suggest using a compiler that can handle both Fortran 77 and Fortran 90 code, such as gfortran.
  • #1
querky
1
0
Hi!

I'm having kind of a "little" problem. I got an old program written in Fortran77 and I want to implement some functionality from Fortran90 routines. The routines are quite long, so I'm not able to rewrite them in F77...

Is there a possibility to connect the routines so that they can communicate (exchange variable values) in a fast way.

I have though about the COMMON Blocks of F77 and the MODULE Statements in F90. Is there a way of connecting these data structures in a way, that a F90 program can read a F77 COMMON Block. (I though about a I/O-interface but I think this is too slow)

Thanks for your help!
 
Last edited:
Technology news on Phys.org
  • #2
Hey

The connection between Fortran 77 and Fortran 90 is in my opinion a bit tricky. I have myself succeeded to call Fortran 77 subroutines from Fortran 95 (I assume it works in Fortran 90 also) by using the 'call' statement. I have not succeed to call the Fortran 77 functions but I had to rewrite them as subroutines instead. I don't think it is possible to call Fortran 90 code from Fortran 77. To compile the code I think you need a compiler which is able to compile both Fortran 77 and Fortran 90 code, e.g. gfortran
I hope this helps
 
  • #3


Hello,

Thank you for reaching out. It is definitely possible to connect Fortran77 and Fortran90 routines in a fast and efficient way. One option is to use the Fortran interoperability features, which allow for data sharing between different versions of Fortran. This can be done using the ISO_C_BINDING module in Fortran90 and the corresponding C interoperability features in Fortran77.

Another option is to use the Fortran interface block, which allows for direct communication between different Fortran routines. This can be achieved by declaring the Fortran77 routines as external subroutines or functions in the Fortran90 code and then calling them as needed.

In terms of the COMMON blocks and MODULE statements, it is possible to use them for data sharing between Fortran77 and Fortran90, but it may require some additional work to ensure compatibility between the two versions. You may need to use the BIND attribute in Fortran90 to ensure that the data structures are compatible with the COMMON blocks in Fortran77.

I hope this helps and good luck with your project!
 

1. What are the major differences between Fortran 77 and Fortran 90?

Fortran 90 introduced several new features, including dynamic memory allocation, modules, and structured data types, that were not available in Fortran 77. It also removed some of the limitations of Fortran 77, such as the maximum number of characters per line and the requirement for variables to be declared before use.

2. Can Fortran 77 and Fortran 90 be used together in the same program?

Yes, Fortran 90 was designed to be backwards compatible with Fortran 77. This means that Fortran 77 code can be included in a Fortran 90 program and both can be compiled and run together. However, it is recommended to update all code to Fortran 90 for better performance and functionality.

3. How do I convert my Fortran 77 code to Fortran 90?

There are several tools and resources available to help with the conversion process. Some compilers have built-in conversion tools, and there are also online tutorials and guides that walk through the differences between the two versions and how to update code.

4. Can I still use my old Fortran 77 libraries in a Fortran 90 program?

Yes, Fortran 90 allows for the inclusion of Fortran 77 libraries in a program. However, it is important to note that the new features and syntax of Fortran 90 may not be available when using the Fortran 77 libraries.

5. Is it worth upgrading from Fortran 77 to Fortran 90?

Yes, there are many benefits to upgrading to Fortran 90. It is a more modern and efficient language, with improved functionality and performance. It also allows for easier integration with other programming languages and libraries, making it a valuable tool for scientific research and data analysis.

Similar threads

  • Programming and Computer Science
Replies
14
Views
2K
  • Programming and Computer Science
Replies
34
Views
3K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
8
Views
5K
  • Programming and Computer Science
Replies
8
Views
3K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
2
Views
5K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
Back
Top