Ch25 Discussion
Discussion Guide
Warm-up (think–pair–share, 5 min). "You inherit a directory of 10,000 .dat files, each a grid of
full-precision numbers, from a researcher who left the lab. What can you learn from them, and what can't
you? What one thing would have made them usable?" Surface that full precision is not the problem — muteness
is — and land "self-describing" before any API.
Main discussion (15–20 min).
1. The four failures. Put "bulky / slow / lossy / mute" on the board and ask which ones unformatted binary
(Ch. 7) fixes. Draw out that it fixes three and makes the fourth (and portability) worse. This is the
chapter's thesis; make them derive it.
2. Row-major vs column-major. Show the nf90_def_var(..., [x_dimid, y_dimid]) writer and the
temperature(y, x) that ncdump prints. Ask: is the data transposed? Collect votes, then reveal it is a
display convention the library bridges — and that "fixing" it would cause a transpose. Connect to the
column-major memory model of Ch. 5.
3. Handles vs allocatables. Ask why HDF5 makes you close every dataspace when a Fortran allocatable
array needs nothing. Draw out that an HDF5 id is a library object outside the compiler's knowledge —
the same reason C interop (Ch. 14) and any external resource needs manual management. Tie to the
leak-in-a-loop bug.
Group activity (10–12 min). Hand each group a different ncdump -h/h5dump -H header (some CF-compliant,
some not, some HDF5) and have them (a) state the shape and type of the main variable, (b) list what metadata
is present and what is missing for reproducibility, and (c) decide whether they would trust the file and why.
The skill — reading a header and auditing it — is exactly the working scientist's daily task and transfers to
any file they meet.
Exit ticket. "State in one sentence each: (a) what 'self-describing' means and why raw unformatted binary
is not, and (b) the correct order of nf90_enddef and nf90_put_var, and what goes wrong if you swap them."
A pass names metadata (shape/type/byte-order/units) travelling with the data and endianness/shape unrecorded
in raw binary for (a), and enddef before put_var; writing in define mode fails for (b).