C# – Converting Fortran 77 Code to C#

cfortran

I'm trying to convert a Fortan77 program to C#. I have a subroutine with about 650 lines of code and horrific GOTO statements all over the place. I'm having a lot of trouble even starting to visualise the flow of the subroutine to figure out what it does.

Is there anybody with experience in this sort of thing who could give me any advice on how to get an overview of this subroutine? Are there some tools available to speed up or facilitate this type of conversion?

Best Answer

In my experience, a good way to go about this is to create a flow-chart of the Fortran code. Try to separate out the targets of the GOTO statements into separate blocks, and use the diagram to try to understand the code on a high level.

See if you can logically replace the GOTOs with loops or function calls; if the resulting diagram is in the form of a tree-structure, it is relatively easy to convert to C# without resorting to GOTOs. In the end though, you will need to understand the code intimately to be able to maintain and use the result with confidence.

Related Topic