Saving / resurrecting old Fortran programs
A general rule for resurrecting old code in any language is first try to get it working for known input/output via emulation or virtual machine. Many old codes were made before linters and other correctness checks we’ve long taken for granted. The codes may use non-standard tricks no one has thought about for years to squeeze tiny fractions of efficiency that haven’t been significant for decades.
After correct operation is established, Fortran 66 code often needs a few tweaks to work with modern compilers. The Fortran Wiki has an excellent article on modernizing Fortran syntax.
Always make a copy of the file first. Sometimes 10,000+ lines will match so it can be tedious to check. Similar operations may be needed if a mix of tabs and spaces are used.
To move line numbers left, run this regex and replace with null (nothing):
To make code start in column 7, recall that fixed format (Fortran <= 77) code has line numbers in columns 1-5 of each line numbers After the prior operation, push the actual code right of column 6 by replacing this regex with appropriate number of spaces:
Other compatibility notes:
$can be used like a semicolon in CDC Cyber Fortran
- put procedures in separate files for duplicated line numbers.