Ch21 Discussion

Discussion Guide

Warm-up (think–pair–share, 5 min). "You need to solve a 500×500 linear system for a simulation. Do you write Gaussian elimination or call a library — and what, exactly, does the library know that your code wouldn't?" Surface pivoting, cache tuning, and thirty years of testing. Land the chapter's thesis before the mechanics.

Main discussion (15–20 min). 1. The overwrite. Put the dgesv signature on the board and ask which arguments change on exit. Collect guesses, then reveal that both a and b are overwritten. Ask what that means for computing a residual (you must copy first) — the single most practical takeaway. 2. The silent argument. Show the argument-swap bug from Exercise 21.12. Ask: why does -Wall not catch it? Draw out that LAPACK is an external procedure with no interface, so the compiler cannot check — which is why checking info and preferring a wrapper matter. Connect to why modern Fortran modules give free interface checking (Ch. 8) and LAPACK predates that. 3. Pivoting as robustness. Walk Case Study 1's zero-pivot system on the board: the naive routine divides by zero and returns NaN; pivoting swaps rows and solves. Ask what the tiny-pivot case adds (silent wrong answer, catastrophic cancellation — Ch. 20). Conclude: you call the library for robustness you didn't write, not just speed.

Group activity (10–12 min). In pairs, hand each group a different LAPACK routine name they have not seen (dpotrf, dgeqrf, dsygv, dtrtrs, zgesv) and have them decode it from the naming scheme and predict, from the letters alone, what it computes and whether it needs a workspace query. Then have them locate its reference page and check. The point: name-decoding + reading a page is LAPACK fluency, and it transfers to routines you have never used.

Exit ticket. "State, in one sentence each: (a) what dgesv overwrites and why you must copy first, and (b) what lda is for a 5×5 solve inside a real(dp) :: a(100,100) array." A pass names both a and b (LU factors / solution) for (a) and 100, the declared first dimension for (b).