Crashing WRF; or, How to Try Not To
A nine-crash detective story, and the namelist parameters it teaches: time steps, damping, feedback, tiling, and the diagnostic that did it.
The confession
This course exists because we crashed the same model nine times in two days. Same backtrace every time, deterministic as a metronome — and every fix we shipped was wrong, until the last one. The story is worth telling in detail, because the ways a WRF run dies are also a tour of the namelist parameters that matter most, and because the shape of our mistake — fixing the thing that moved the crash instead of the thing that caused it — is the classic trap of numerical debugging.
How WRF dies, taxonomy edition
Broadly, four ways. Loudly and honestly: a CFL violation, printed by name in the logs (“points exceeded cfl=2”) — the model told you the time step outran the physics. Loudly and numerically: NaNs propagating through a field until a floating-point trap fires — usually the same disease later in its course.Politely: real.exe or metgrid rejecting your configuration before a single time step — annoying, but the cheapest failure you can have. And silently: a segmentation fault with a bare backtrace, no CFL warning, no NaN — the model walked off the end of an array somewhere, and the reason is structural, not meteorological. Ours was the fourth kind, which is why it took nine runs.
time_step, and the speed limit that isn’t optional
The first parameter anyone learns: time_step (seconds) must respect the fastest thing crossing your grid. The folk rule is 6 seconds per kilometer of dx — a 10 km outer domain wants ~60 s, and 48 is comfortably safe. Nested domains inherit the step through parent_time_step_ratio, so a 10 km → 2 km → 667 m → 222 m ladder steps 48 / 9.6 / 3.2 / 1.07 s. Blow the limit and you get the loud, honest death. The alternative, use_adaptive_time_step, lets the model float the step against a target CFL number (target_cfl, typically 1.2); it’s faster on calm days and it means one less number to tune — but it also makes the model’s schedule weather-dependent, which matters in a moment.
The damping suite, or: sub-kilometer domains are drama queens
Below ~1 km, resolved updrafts get violent enough to punch vertical velocities the acoustic solver hates. Three parameters keep the peace: w_damping = 1(a sponge on extreme vertical motion), epssm (off-centering the acoustic steps; 0.2 default, 0.4 on steep-terrain nests), and a sane eta_levels ladder — the vertical column itself. That last one is sneaky: eta_levels must be strictly monotonic and its count must equal e_vert on every domain; a single duplicated level from a copy-paste produces a rejection if you’re lucky and garbage if you’re not. Validators should check all of this before a run ever starts, which is why ours now does.
feedback, tiles, and two red herrings we chased anyway
feedback decides whether nests write their finer answer back onto their parents (two-way nesting) or just read boundaries (one-way, feedback = 0). Two-way is the default and usually fine; on some geometries it participates in genuine WRF bugs, and turning it off costs a forecast-consumer almost nothing — the fine domains, where you actually look, are unchanged. We blamed it for our crash. We were wrong, but the exoneration run taught us that, so it wasn’t wasted.
Likewise OpenMP tiling: WRF slices each domain into one-per-thread strips of rows, and a domain with fewer than two rows per thread produces degenerate tiles that can segfault outright. The rule that survives: cap threads by the smallestdomain’s rows, not the largest’s. We fixed a real bug there mid-hunt. The crash continued. That’s the trap in its purest form: a true fix that isn’t the fix looks identical to progress until the next run dies.
The actual villain: nwp_diagnostics
nwp_diagnostics = 1 switches on a storm-chaser package: updraft helicity, 10 m wind maxima (WSPD10MAX), max vertical velocity, computed every step and reset on output boundaries. Inside it, the helicity routine integrates a 2–5 km AGL layer — and on some terrain, on some domain placements, its level indexing walks out of bounds. Deterministically. The crash moved when we changed the time step, the CFL target, or the output cadence — because all of those change whenthe vulnerable code runs, not whether it’s vulnerable. Nine runs of evidence, one symbolized backtrace (cal_helicity), one A/B with only that flag flipped: full horizon, clean. If you take one habit from this course: when a crash is deterministic but immune to every physics knob, suspect the diagnostics and the I/O schedule before the dynamics. And if you don’t need severe-weather max fields, leave nwp_diagnostics off — it changes outputs, never the forecast.
Output plumbing can hurt you too
frames_per_auxhist— how many frames accumulate per output file — sounds cosmetic and isn’t. Files that close hourly enable progressive publishing; one giant appending file is the idiom for a domain nobody reads mid-run. And because max-diagnostics reset on file boundaries, output cadence feeds back into which code runs when — our crash time moved hours when this changed. Treat I/O settings as part of the numerical experiment, not decoration.
The meta-lesson
Every wrong fix we shipped was locally justified: real bugs, really fixed. What finally cracked the case wasn’t cleverness, it was discipline: change one variable per run, keep a verdict table, get a symbolized backtrace instead of theorizing from crash timing, and respect the counter-example (a config that runs clean on one geometry and dies on another is telling you the trigger is data, not physics). The validator rules, the automatic parameter healing, and the crash corpus that came out of this saga are all just that discipline, written down as software.