Part IV: Legacy Fortran

"Never rewrite what you can refactor." — the first rule of touching a working scientific code

Somewhere in your future there is a file with a .f extension, written before you were born, that computes something important and correct that no living person fully understands. It is riddled with COMMON blocks and GOTOs, its variables are typed by the first letter of their names, and its lines begin in column seven. It is also validated — checked against decades of experiments — which makes it far more valuable than the clean rewrite you are tempted to attempt. Part IV teaches you to read that code without panic, to modernize it without breaking it, and to know exactly which old construct maps to which new one.

This is, in a sense, a book within the book. It is the part the "reading track" reader comes for, and it is the part that will earn you your keep in any organization sitting on a mountain of legacy Fortran — which is to say, most of them. We treat old code not as an embarrassment but as an inheritance: the engineering can be improved while the science is preserved, and doing that well is a genuine skill.

What You Will Learn

Chapter 17 — Reading FORTRAN 77. Fixed-form source, COMMON blocks, EQUIVALENCE, GOTO, statement functions, implicit typing — the whole archaeology, so you can read old code fluently.

Chapter 18 — Modernizing Legacy Fortran. A practical, eight-step migration recipe, applied incrementally and safely, with regression tests that prove you changed the style without changing the science.

Chapter 19 — FORTRAN 77 to Modern Fortran. A translation dictionary: every legacy pattern mapped, side by side, to its modern replacement — a reference you will return to.

How This Part Fits

Part IV assumes control flow (Chapter 4) and — crucially — modules (Chapter 8), since the central move of modernization is replacing COMMON with modules. It stands somewhat apart from the numerical and performance arc: the Scientist and HPC tracks can defer it until they actually meet old code, while the Legacy track comes here straight after Part I. The running project gains a side quest here — a real 200-line FORTRAN 77 kernel that you modernize step by step.

Time Investment

Chapter Title Difficulty Est. hours
17 Reading FORTRAN 77 Intermediate 5
18 Modernizing Legacy Fortran Advanced 5
19 FORTRAN 77 to Modern Fortran Intermediate 4
Part IV total ~14 hours

Open Chapter 17 and meet the old code on its own terms — fixed columns, COMMON blocks, and all.

Chapters in This Part