Ch03 Discussion

Discussion Guide

Warm-up (think–pair–share, 5 min). Put real(dp) :: x; x = 1 / 2; print *, x on the board and ask: "What prints, and why?" Most will say 0.5. The reveal (0.000) surfaces the trap and the misconception that the left-hand type controls the right-hand arithmetic. Let the surprise do the teaching.

Main discussion (15–20 min). 1. Where the type is decided. Walk pct = above / n * 100 (CS-01) one operation at a time, asking the class to name the type and value after each. They should arrive at 0 themselves. Then ask: "At which operation was the answer already lost?" (The first division.) This builds the operand-types-decide model. 2. Single or double? Pose it as a real trade-off, not a moral: "Single is 2× faster on a memory-bound loop and half the memory. Double has 8 more correct digits. When would you choose single?" (Large arrays, accuracy budget met, GPU/bandwidth-bound work.) The goal is that they see precision as an engineering decision, echoing Ch. 1's "performance is not accidental." 3. Portability. "Why not just write real(8)?" Have them articulate that the 8 is the compiler's business and selected_real_kind(15, 307) is the scientist's requirement. Tie to reproducibility across machines — a real thing that bites real research groups.

Group activity (10 min). In pairs, each pair writes three arithmetic expressions: one that looks real but evaluates in integer arithmetic (a hidden trap), one correct real expression, and one legitimate use of integer division (e.g., "how many whole 8-cell blocks fit in n cells?"). Swap with another pair and predict each other's outputs. Collect the best hidden trap for the board. Reinforces that integer division is a feature to be used deliberately, not merely a hazard.

Exit ticket. "Write the one-line rule that guarantees a real-valued division, and give the dp definition from memory." (Rule: make at least one operand real, via a _dp literal or real(k, dp); integer, parameter :: dp = selected_real_kind(15, 307).) Anything capturing both is a pass.