How to convert a big fortran IV code to matlab ?
47 views (last 30 days)
I am in deep trouble trying to convert a very old fortran IV code written in 1984 to matlab.
I have tried firstly to find a tool in order to go from fortran IV to f90, but I am a complete beginner of fortran language...
The code is 2500 lines and has many many subroutines, I am losing hope and I am thinking of convert it manually... What do you think ?
Here is the study linked to the code : https://ntrs.nasa.gov/citations/19850022698
Thanks for your help
Jan on 16 Mar 2022
I'd never trust an automatic translation. But if you try it, make it as simple as possible: no intermediate conversion to FORTRAN 90.
Fortunately 2500 lines of FORTRAN is small enough to be conveted manually. This will be abou 1000 or less lines of Matlab code.
But what about using the FORTRAN code directly through a Mex wrapper? Do you have a FORTRAN compiler? Then all you have to do is to convert the Matlab variables to the equivalent representation of FORTRAN variables.
I've used f2c successfully to do this with an integrator. The original code has over 100'000 lines of code. Calling C from Matlab is easy also.
Ben Barrowes on 17 Mar 2022
Your link goes to a PDF scan of the code. Do you have this code in a proper Fortran text file? Have you been able to compile it? Those are necessary first steps before trying to convert the code into Matlab.
Once you have running Fortran code, f2matlab has a good shot at getting you closer to runnable matlab code, but you would have to refactor all the goto's out first.
If you get stuck on the conversion, send me a PM With the working Fortran code, and I can take a look.