Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discuss legacy code -- how to modernize, interoperate with, and transition away from #460

Open
Beliavsky opened this issue Sep 12, 2024 · 0 comments

Comments

@Beliavsky
Copy link
Contributor

Beliavsky commented Sep 12, 2024

Although the main goal of the fortran-lang site is to inform people about modern Fortran, there are many people with legacy Fortran codes who would like to transition away from the language, or at least provide interfaces in Python or another language, so that the code can be used by people without knowledge of Fortran. I think the site should also provide information for them. Here is an outline of that I think should be covered, addressed to such people.

  1. Are you sure you need to modify the code? Modern Fortran is mostly backward compatible with older versions. The free gfortran compiler has an std=legacy option to compile old codes. (Analogous options for other compilers should be mentioned.)
  2. If a Fortran compiler is not available on your platform or cannot be installed on it, the f2c tool translates Fortran 77 into compilable C code.
  3. Modern Fortran has features that will avoid bugs present in older Fortran codes. Put implicit none in all program units to force all variables to be declared. Even if your goal is to move away from Fortran, it is better to start with a Fortran code with all variables declared and errors detected.
  4. There are free and commercial tools to analyze and refactor Fortran codes. The site would discuss some of the tools at https://github.com/Beliavsky/Fortran-Tools, including plusFORT. fpt, CamFort, Codee, and (for Fortran 77 and earlier code) ftnchek.
  5. There are consultants (the site would list a few) whose knowledge of legacy and modern Fortran and familiarity with modernization tools may enable to them to modernize a legacy Fortran more quickly and correctly than people "in-house" would.
  6. Many Fortran codes have been given Python interfaces that enable people to use them without dealing with the Fortran code directly. There is the widely-used f2py tool, and more generally you can use ctypes.
  7. Fortran code can be called from C and C++ using the interoperability features of Fortran 2003.
  8. There are projects such as Fortran2Cpp, loki, and Rose to transpile Fortran to other languages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant