Fortran re-engineering example (3)

The next step involves fixing the small stuff, to get the program to actually compile. Most old Fortran programs can be compiled as is due to the backwards compatibility of Fortran compilers. However, convert the extension from .for to .f90 or .f95, and something will break. The first thing to break will be comments. All the “C” delimiters have to be changed to “!“. Then it might compile. Sometimes there are other finicky things that have to be fixed as well, but unstructured code will compile… usually. The “line continuation” operator will also have to change, from + to &.

Next, simple stuff like compressing the first format statement from 3 lines to 2, adding some whitespaces in places (e.g. if( → if ( ), and form single goto statements from “go to“. It is important to have a sequence of code files when re-engineering. Make some changes, document the changes in the file, and compile the program to make sure nothing breaks. Make a copy, and make new changes in that file. DO NOT make all the changes in the same file. That’s a CRAZY idea.

Finally, the variable declarations are modified to use :: .

Now here is what the program looks like:



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.