Ch12 Discussion
Discussion Guide
Warm-up (think–pair–share, 5 min). "You have a fixed-length character(len=20) :: name holding
'output'. You write name // '.dat' and the file lands somewhere wrong. What happened?" Surfaces the
trailing-blank trap before it is formally named, and motivates deferred-length strings.
Main discussion (15–20 min).
1. scan vs verify. Put both on the board with the same string and set, and have the class state, in one
sentence each, what each returns and one real task it solves (finding a delimiter; validating all-digits).
Then ask which one finds where a token starts and why. This is the chapter's most confusable pair;
make them articulate the duality.
2. Parse by column or by content? Present Case Study 1's fixed-column parser and one realistically-spaced
line. Ask the class to predict what each field grabs (they will find every field is wrong), then derive
the fix — tokenize by content. Use it to teach that a parser encodes a model of the data, and the
fixed-column model is simply false for whitespace-separated text.
3. Where does parsing end and validation begin? Show read(val, *) cfg%dt on dt = fast. Ask: should
the parser crash, guess, or reject? Draw out the iostat seam and the handoff to Chapter 13 — a good
place to discuss defensive programming as a professional habit.
Group activity (10 min). In pairs, extend frame_name to include an MPI rank, producing
heat_r003_000123.vtk (Exercise 12.20). One student writes the format string, the other hand-computes the
output for rank 3, step 123, and they check agreement. This exercises two internal-file integer fields and
foreshadows per-rank parallel output (Part VIII).
Exit ticket. "Write the one-line test for 'the string tok is entirely digits,' and say what
i6.6 produces for the integer 7." (Checks verify(tok,'0123456789')==0 and 000007 — the two ideas most
worth retaining.)