Self-Assessment Quiz: Reading FORTRAN 77
Twenty questions to confirm you can read fixed-form legacy code and map each old construct to its modern replacement. Aim for 16 or more. Answers and a topic map are at the end — try the whole quiz first.
Question 1
In fixed-form source, a statement label goes in columns: - A. 1–5 - B. 6 - C. 7–72 - D. 73–80
Question 2
A nonblank character in column 6 of a fixed-form line means: - A. The line is a comment - B. The line continues the previous statement - C. The line is a statement label - D. The line is ignored
Question 3
Which character in column 1 makes an entire fixed-form line a comment in strict FORTRAN 77?
- A. !
- B. #
- C. C or *
- D. //
Question 4
Under implicit typing, a variable named NSTEP is:
- A. REAL
- B. INTEGER
- C. CHARACTER
- D. undeclared and therefore an error
Question 5
A COMMON block associates the variables of different routines:
- A. By name
- B. By position (storage order)
- C. By type only
- D. Alphabetically
Question 6
Two routines declare COMMON /B/ X, Y, N and COMMON /B/ X, N, Y. The result is:
- A. A compile-time error
- B. A link-time error
- C. Silent data corruption — N and Y are swapped in memory, unchecked
- D. Correct sharing, because the names match
Question 7
The only program unit that may initialize a named COMMON block is:
- A. The main program
- B. Any subroutine
- C. A BLOCK DATA unit
- D. A FUNCTION
Question 8
EQUIVALENCE (A, B) asserts that:
- A. A equals B in value
- B. A and B occupy the same memory (they are the same bytes)
- C. A is a copy of B
- D. A and B have the same type
Question 9
The modern intrinsic that safely expresses "reinterpret these bits as another type" (an EQUIVALENCE use)
is:
- A. reshape
- B. transfer
- C. merge
- D. pack
Question 10
GO TO (10, 20, 30), K transfers control to label 20 when K is:
- A. 0
- B. 1
- C. 2
- D. 3
Question 11
The arithmetic IF statement IF (E) 10, 20, 30 jumps to label 20 when E is:
- A. negative
- B. zero
- C. positive
- D. undefined
Question 12
A statement function must be placed:
- A. Anywhere in the routine
- B. After the declarations and before the first executable statement
- C. Only in the main program
- D. Inside a BLOCK DATA
Question 13
The modern replacement for a statement function is:
- A. A COMMON block
- B. An internal (contained) procedure
- C. A GO TO
- D. An EQUIVALENCE
Question 14
An ENTRY statement gives a subprogram:
- A. A second entry point sharing its body and local state
- B. A return value
- C. A comment
- D. A new COMMON block
Question 15
-std=legacy is the gfortran flag that:
- A. Optimizes for speed
- B. Accepts obsolete features and reads fixed-form source
- C. Enables OpenMP
- D. Turns on all warnings
Question 16
The Hollerith constant 4HHEAT represents:
- A. The integer 4
- B. The four characters HEAT
- C. A hexadecimal number
- D. A label
Question 17
In the PLATE kernel, the separate array TNEW — filled with new values computed from the old T, then
copied back after the sweep — tells you the relaxation method is:
- A. Gauss–Seidel
- B. Jacobi
- C. Successive over-relaxation
- D. Conjugate gradient
Question 18
The COMMON-based data model of a large FORTRAN 77 program is best described as:
- A. A set of components each owning private state
- B. One global pool of untyped memory that any routine may reinterpret
- C. A relational database
- D. A stack of local variables
Question 19
Reading the PLATE kernel, the four-line "heart" that implements the physics is:
- A. The SETBC boundary loops
- B. The IMPLICIT DOUBLE PRECISION declaration
- C. The stencil update TNEW(I,J) = AVG(T(I-1,J), …) plus the DIFF/DMAX change-tracking
- D. The WRITE statements in OUTPT
Question 20
True or false: modernizing a validated legacy code should begin by rewriting it from scratch to be sure it is clean.
Answer Key
| Q | Ans | Why |
|---|---|---|
| 1 | A | Labels live in columns 1–5. |
| 2 | B | A nonblank in column 6 continues the previous statement. |
| 3 | C | C or * in column 1 flags a whole-line comment (no ! in strict F77). |
| 4 | B | Names starting I–N are integer by default. |
| 5 | B | COMMON associates by position/storage order, not by name. |
| 6 | C | Reordered declarations silently swap the bytes; separate compilation hides it. |
| 7 | C | Only BLOCK DATA may initialize named COMMON. |
| 8 | B | EQUIVALENCE shares memory — the variables are the same bytes. |
| 9 | B | transfer(source, mold) reinterprets bits, typed and portable. |
| 10 | C | The computed GOTO selects the K-th label; K=2 → the second, 20. |
| 11 | B | Arithmetic IF jumps to the middle label on zero. |
| 12 | B | After declarations, before the first executable statement. |
| 13 | B | An internal procedure — checked interface, intent, multi-line. |
| 14 | A | A second entry point sharing the routine's body and locals. |
| 15 | B | It accepts obsolete features and treats the source as fixed-form. |
| 16 | B | nHtext names n characters; 4HHEAT is HEAT. |
| 17 | B | Computing a separate TNEW from the old T (not updating in place) is the signature of Jacobi. |
| 18 | B | COMMON is a global untyped memory pool, reinterpretable per routine. |
| 19 | C | The stencil average plus change-tracking is the numerical core. |
| 20 | False | Modernize/refactor to preserve validated numerics; never rewrite first. |
Topics to review by question
- Q1–3, 15 → §17.1 (fixed-form columns; the
-std=legacybuild). - Q4, 16 → §17.5 (implicit typing; Hollerith).
- Q5–7, 18 → §17.2 (
COMMON,BLOCK DATA, the global-memory model). - Q8–9 → §17.3 (
EQUIVALENCEand its modern replacements). - Q10–14 → §17.4 (computed
GOTO, arithmeticIF, statement functions,ENTRY). - Q17, 19 → §17.6 (reading the
PLATEkernel: Jacobi, the four-line heart). - Q20 → the Part IV ethic (legacy is an inheritance; modernize, don't rewrite).
Scored below 16? Reread the flagged sections. The single most important idea is that every legacy construct has a known modern counterpart — once you can name the map, old code stops being frightening.