Ch07 Discussion

Discussion Guide

Warm-up (think–pair–share, 5 min). Put print '(f6.2)', 3.14159 and print '(f4.2)', 12.5 on the board. Each student writes the exact output (spaces included) before discussing with a neighbor. Surfaces the width/decimals grammar and the asterisk-overflow rule in one minute of doing rather than telling.

Main discussion (15–20 min). 1. Where did the nine minutes go? Walk Case Study 1's dump_text. Ask the class to estimate its cost before revealing the calculator. Use it to teach that I/O is a performance topic and that a per-value write in a hot loop is a code smell. 2. Text or binary? Pose a concrete choice: "You must save a $2000^2$ field every step for a week-long run — text or binary, and why?" Draw out lossy-vs-bulky, self-describing-vs-not, and human-readable-vs-fast. Land on: binary for the checkpoint, text (or a plot) for a human summary. 3. Fail fast or recover? From Case Study 2: a job has queued two days, then hits nx = 0 in its config. Should it error stop, or fall back to defaults and run? Argue both — there is no single right answer, which is the point.

Group activity (10 min). In pairs, students take example-02-file-io.f90 and (a) change it to write all three values on one line (Exercise 7.9), predicting whether the list-directed read still works, then (b) add an iostat guard to the read and deliberately delete data.txt between write and read to watch the guard fire. Report what iomsg said. Reinforces §7.3 and §7.6 by breaking things on purpose.

Exit ticket. "Write the one line that ends a read loop at end-of-file portably, and say why -1 is wrong." (Checks §7.6: if (ios == iostat_end) exit, because the EOF value is processor-defined.)