Chapter 17 — Teaching Notes

One-line purpose. Turn students who can write modern Fortran into students who can read FORTRAN 77 without panic — the columns, COMMON, EQUIVALENCE, the jumps, and implicit typing — and map every legacy construct to its modern replacement, using the PLATE kernel as the worked reading exercise.

Key ideas to emphasize

  • Reading precedes rewriting. The whole part's ethic ("never rewrite what you can refactor") starts with the discipline of understanding old code before changing it. Hammer the five-step method (§17.6): shape → shared state → loops/exits → kernel → hand-trace. Students who read line 1 before the shape will drown; students who read the shape first will float.
  • COMMON is a global untyped memory pool, associated by position. This is the load-bearing idea of §17.2 and the reason the module of Chapter 8 mattered. The Find the Bug with the re-ordered COMMON declaration (silent corruption, no compiler error) is the moment it lands — spend time there.
  • EQUIVALENCE is deliberate aliasing — the exact thing modern Fortran forbids to go fast (tie back to Chapter 1's no-aliasing advantage). Diagnose the intent (reuse / reshape / bit-reinterpret) before replacing it; each maps to a different modern construct (allocatable / reshape / transfer).
  • Implicit typing has two edges: the silent typo (a mistyped name becomes a new garbage variable) and accidental integer arithmetic (IN names, integer division). Both are why implicit none exists.
  • The legacy zoo is a translation table, not a mystery. GO TOdo/exit; computed GOTOselect case; arithmetic IFif; statement function → internal pure function. Once students see the map, the fear evaporates.

Misconceptions to preempt

  • "The old code is broken / incompetent." No — it is history; every strange feature answered a real 1970s constraint (punch cards, no dynamic memory, tiny compilers). Read it as archaeology.
  • "Fixed-form is just a style; I can reformat freely." No — columns 1–6 are semantic. Retyping a statement flush-left breaks it. (The column-6 continuation trap is the classic first casualty.)
  • "Legacy = bad, so rewrite it." No — legacy usually means validated. The rational move is modernize + regression-test, not rewrite (set up by Case Study 2, paid off in Chapter 18).
  • "COMMON is just a struct." No — there is no type checking and association is positional, so a mismatched declaration silently reinterprets bytes.

A live demonstration (5–10 minutes)

Put the PLATE RELAX subroutine on screen and reconstruct it live with the five-step method — do not read top-to-bottom. Ask the room: "What are the routine names? Where's the shared state? Which label is a loop-back? Which four lines are the physics?" Then hand-trace the first Jacobi sweep of the 4×4 problem (interior (2,2) = ¼·100 = 25) on the board, and derive the steady state by symmetry (8b=100 → 12.5/37.5). Optional: compile plate-legacy.f with gfortran -std=legacy and show it prints exactly 37.5000 / 12.5000 — the payoff of a hand-verified reading.

Class-time budget (~60 min)

  • 8 min: fixed-form columns + the -std=legacy build (§17.1); the column-6 trap.
  • 12 min: COMMON/BLOCK DATA, the positional-association bug (§17.2), module as the cure (link Ch. 8).
  • 8 min: EQUIVALENCE and its three intents + dangers (§17.3).
  • 10 min: the control-flow zoo, each with its modern replacement (§17.4).
  • 7 min: implicit typing + DATA + Hollerith (§17.5); the two edges.
  • 12 min: the guided tour of PLATE (§17.6), live, with the five-step method and the hand trace.
  • 3 min: the Project Checkpoint — read/build/annotate/pin the kernel; frame Chapter 18.

Prerequisites to review

Chapter 4 (structured control: do/exit/select case) and Chapter 8 (modules, use, positional vs named) — the two spaced-review targets, and the exact modern constructs the legacy ones map onto. A quick refresher on column-major order (Chapter 5) helps the EQUIVALENCE-flatten example.

Connections

Back: Ch. 1 (no-aliasing), Ch. 2 (implicit none, fixed-vs-free), Ch. 4, Ch. 5, Ch. 6, Ch. 8, Ch. 13. Forward: Ch. 18 (modernize the very kernel read here — "after every step the output must not move"), Ch. 19 (the translation dictionary), Ch. 24 (the real PDE heat solver the kernel foreshadows).

Note for the instructor: the PLATE kernel here is deliberately identical to the "before" listing in Chapter 18 §18.4, so the read → modernize narrative is seamless. (Chapter 19's current plate-legacy.f differs; teach from the Chapter 17/18 version.)