Metadata-Version: 2.4
Name: recast-woof-nam
Version: 0.2.1
Summary: GPU port of the NOAA/NCEP NAM (NMMB dynamics + NAM physics) 12 km CONUS parent
Author: Recast Systems
License-Expression: Apache-2.0
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: POSIX :: Linux
Classifier: Environment :: GPU :: NVIDIA CUDA
Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: cupy-cuda13x[ctk]
Requires-Dist: numpy
Requires-Dist: scipy
Requires-Dist: netCDF4
Requires-Dist: Pillow
Requires-Dist: gpuwm>=2.9.13
Requires-Dist: nvidia-nccl-cu13
Provides-Extra: modern
Requires-Dist: gpuwm-hex>=0.5.0; extra == "modern"
Dynamic: license-file

# WOOF-NAM

WOOF-NAM is a GPU port of NOAA/NCEP's North American Mesoscale model (NAM, nam.v4.2.11): the NMMB
(Nonhydrostatic Multiscale Model on the B grid) dynamics and the NAM's operational physics, running
on one NVIDIA card or on several cards of one machine. NCEP retired the NAM on 2026-11-03 12Z; this
package keeps the model running.

Distribution name `recast-woof-nam` (on PyPI: `pip install recast-woof-nam`), import name `namgpu`, command `woof-nam`, version 0.2.1.

## What it looks like

The 2025-03-14 12Z case, run from a fresh clone with `woof-nam run --source native --hours 24` (the NAM
analysis start, the digital filter, every physics scheme on). The sheets come from `woof-nam side-by-side`:
MRMS observed reflectivity, WOOF-NAM and the archived operational NAM 12 km forecast of the same cycle, on
the same map frame and colour scales.

![Composite reflectivity at +24 h: MRMS, WOOF-NAM, archived NAM](docs/evidence/f024_refc_mrms_woofnam_nam.png)

*Composite reflectivity, +24 h, valid 12Z 15 Mar 2025. MRMS | WOOF-NAM | NAM. Like the NAM, WOOF-NAM wraps
the comma head over the upper Midwest and puts the trailing line west of the observed one; neither model
has MRMS's second band across Mississippi and Alabama.*

![Composite reflectivity at +12 h: MRMS, WOOF-NAM, archived NAM](docs/evidence/f012_refc_mrms_woofnam_nam.png)

*Composite reflectivity, +12 h, valid 00Z 15 Mar 2025. WOOF-NAM and the NAM put the same curved line with a
40+ dBZ core over Iowa and Missouri; MRMS has it farther west, over Nebraska and Kansas.*

![Total precipitation at +24 h: WOOF-NAM, archived NAM](docs/evidence/f024_precip_total_woofnam_nam.png)

*Precipitation since the start, +24 h. WOOF-NAM | NAM: the same Pacific coast, upper Midwest and Ohio
Valley maxima.*

![2 m temperature at +24 h: WOOF-NAM, archived NAM](docs/evidence/f024_t2_woofnam_nam.png)

*2 m temperature, +24 h. WOOF-NAM | NAM.*

![2 m dewpoint at +24 h, WOOF-NAM](docs/evidence/f024_d2m_woofnam.png)

*2 m dewpoint, +24 h, one of the maps every `woof-nam run` draws.*

The +12 h sheets and the other maps are in [docs/evidence/](docs/evidence/).

## What you need

- **Linux** (x86_64) with Python 3.12 or newer.
- **An NVIDIA card with 24 GB or more for the 12 km grid; up to 85 GB on a 96 GB card without the fit.** The
  12 km forecast peaks at 22.5 GB on a 32 GB card; a 3 km nest of 333 x 333 points at 5.8 GB (see "Speed and
  memory"). On a card with less than 64 GB the run takes the 32 GB fit by itself: arrays that live inside one step are handed
  back after their last user, the radiation working set is dropped between calls and the radiation runs in
  8-row chunks. Every physics scheme stays on. The run log and `forecast-receipt.json` name the memory path
  that ran (`memory path: fit` or `full`); `NAMGPU_MEMORY_PATH=fit` or `full` picks one on any card.
  Fetching data, the static fields, maps and the side-by-side panels need no big card (the static-field
  build uses an NVIDIA card for a few seconds).
- **Or two or more 32 GB cards of one machine** (`woof-nam run --cards N`, see "Running on more than one
  card"): the 12 km grid ran on 2, 4 and 8 cards of 32 GB with the same bits on any number of cards; on 2
  cards each one peaks at about 13 GB.
- **An NVIDIA driver for CUDA 13.** No system CUDA toolkit is needed: pip installs the CUDA runtime
  and the compiler headers (`cupy-cuda13x[ctk]`). The kernels are compiled on the card at first use
  (NVRTC) and cached.
- **Disk:** 3.7 GB of inputs for a 24 h case (about 7 GB for 48 h), 2 GB for the terrain set,
  and room for the hourly history. The 24 h example case is fetched in about 2.5 minutes on a fast link.
- **Internet access** to NOAA's open-data buckets on AWS (NAM, GFS and MRMS). No account is needed.

## Install

```
python3 -m venv woof-nam-venv && source woof-nam-venv/bin/activate
pip install recast-woof-nam          # or from GitHub: pip install "recast-woof-nam @ git+https://github.com/recastsystems/woof-nam.git"
gpuwm fetch-geog --datasets topo_gmted2010_30s --root ~/WPS_GEOG              # GMTED2010 terrain, 174 MB download
woof-nam doctor                      # the card, CuPy/NVRTC, terrain data, writers, and what the card can run
```

pip installs `recast-woof-nam` with everything a run reads inside the package: the NAM parm files, the
NOAA radiation, CO2 and ozone fix files, the Noah tables and the CUDA kernels. It also installs
`cupy-cuda13x[ctk]`, numpy, scipy, netCDF4, Pillow and `gpuwm` (2.9.13 or newer), which supplies the
Rust GRIB2 decoder, the NetCDF writer, the map renderer `rw_wrfbatch` and the schemes the physics options run.
The terrain for gravity-wave drag is read from `NAMGPU_GEOG` (default `~/WPS_GEOG`).

**gpuwm-hex is optional.** The base install runs the NAM default physics, every grid and nest, `woof-nam suite`,
the GRIB2 products, maps and scores, and every physics option but two: TEMPO microphysics and MYNN v6.1. Those two,
and the suites that use TEMPO (`hrrrv5`, `rapv5`, `woof-nam-next-12km`, `woof-nam-next-7p6km`), need gpuwm-hex
0.5.0 or newer: `pip install "recast-woof-nam[modern]"`. Without it, a run that asks for one stops before it starts,
with one line that says so. `woof-nam doctor` shows whether gpuwm-hex is installed.

Everything runs through one command, `woof-nam`; `woof-nam --help` lists the steps and every step has
its own `--help`. Run them from one working folder: `cases/`, `static/` and `runs/` are made there
(set `NAMGPU_ROOT` to use another folder).

## Quick start

```
mkdir nam-work && cd nam-work
woof-nam fetch --cycle 2025031412 --hours 24 --case-dir cases/2025-03-14_12z     # 3.7 GB, ~2.5 min
woof-nam run --case 2025-03-14_12z --source native --hours 24 --out runs/2025-03-14_12z
woof-nam side-by-side mrms     --raw cases/2025-03-14_12z/raw/mrms --panels panels --hours 2025031512
woof-nam side-by-side archive  --raw cases/2025-03-14_12z/raw/nam --cycle 2025031412 --panels panels --hours 2025031512
woof-nam side-by-side woof-nam --history runs/2025-03-14_12z/wrfout_d01_* --panels panels --hours 2025031512
woof-nam side-by-side sheets   --panels panels --out sheets --hours 2025031512
```

The forecast (`woof-nam run`) needs the card above; every other line runs without it. With two or more cards
in the machine, add `--cards N` to the run (see "Running on more than one card") and check it against a
one-card run with `woof-nam compare runs/<one card> runs/<N cards>`.

## Start sources

`--source` on `woof-nam fetch` and `woof-nam run` picks the analysis the forecast starts from. Every source
goes through the same init (interpolation onto the NAM grid and its 60 levels on the GPU); only the table row
that says where the files are and which fields to read differs.

| `--source` | analysis | start times | ready after the start time | boundaries (every 3 h) | licence | for |
|---|---|---|---|---|---|---|
| `native` | archived NAM native analysis | cycles before 2026-11-03 12Z | archive only | GFS cycle 6 h older | US Government | the NAM's own start |
| `gfs` | GFS 0.25 degree | from 2021-01-01 00Z | about 3.5 h | GFS cycle 6 h older | US Government | real time and recent dates |
| `ifs-0p25` | ECMWF open data IFS HRES 0.25 degree | from 2025-03-14 12Z | about 7.5 h (00/12Z), 6.4 h (06/18Z) | same IFS cycle | CC BY 4.0 | real time and recent dates |
| `ifs` | ECMWF open data IFS HRES 0.1 degree | from 2026-10-20 12Z | about 9.6 h (00/12Z), 8.5 h (06/18Z) | same IFS cycle | CC BY 4.0 | real time and recent dates |
| `era5` | ECMWF ERA5 reanalysis 0.25 degree, hourly | 00, 06, 12 or 18Z from 1940-01-01 00Z | about 6 days | ERA5 analyses | CC BY 4.0 (Copernicus) | hindcasts and case studies |
| `rap` | NOAA RAP analysis, 13 km North America (radar-cycled) | from 2021-02-22 12Z | real time and archive | GFS cycle 6 h older; GFS outside RAP's grid and above 50 hPa | US Government | a radar-cycled start with its own clouds |
| `hrrr` | NOAA HRRR analysis, 3 km CONUS (radar-cycled) | from 2014-07-30 18Z | real time and archive | GFS cycle 6 h older; GFS outside CONUS and above 50 hPa | US Government | CONUS starts; soil: HRRR temperature, GFS moisture by default |
| `rrfs` | NOAA RRFS v1 analysis, 3 km | from 2026-08-12 00Z | real time and archive | as `hrrr` | US Government | as `hrrr` |
| `aifs` | ECMWF AIFS Single forecast (start: the IFS open-data analysis) | from 2025-03-14 12Z | real time and archive | AIFS forecast, every 6 h | CC BY 4.0 | AI-forecast boundaries |
| `aigfs` | NOAA AIGFS forecast (start: the GFS analysis) | from 2025-12-01 00Z | real time and archive | AIGFS forecast, every 6 h | US Government | AI-forecast boundaries |
| `gefs` | NOAA GEFS v12 member, 0.5 degree (`--member c00`, `p01`-`p30`) | from 2020-09-23 12Z | real time and archive | the same member, every 3 h | US Government | ensembles (`woof-nam ensemble`, the `sref16` domain) |

ERA5 is read without an account from Google's public ARCO-ERA5 copy, through gpuwm's own ERA5 reader.
The store publishes its last day itself, and `woof-nam fetch` refuses a run that ends past it and names
that day. On 2026-11-04 the last day was 2026-10-29: recent days are the preliminary ERA5T, and the final
ERA5 runs about four months behind. The few days ERA5 does not cover yet are what `gfs` and `ifs` are for. ERA5
has no forecast leads: the start and every boundary time are analyses, so the boundaries are as good as
the reanalysis at every hour of the run. A 24 h case fetches 9 hours, about 11.5 GB (1.3 GB per hour for
the NAM 12 km grid's latitude band, every longitude), in about 1.5 min on a fast link. The fields read and how
they are mapped to the NAM's: `namgpu/init/source_records.py` (`ERA5`).

## Get the input data

Every input comes from NOAA's open data on AWS. `woof-nam fetch` writes it to `<case-dir>/raw/` and
skips files that are already there. Name the case folder `YYYY-MM-DD_HHz`: `woof-nam run` reads the
start time from it.

**Archived NAM start (cycles before 2026-11-03 12Z).** This fetches the NAM native analysis
(`bgrd3d00`: the initial state and the static surface fields), the archived NAM forecast of the same
cycle for comparison, the GFS boundaries and MRMS reflectivity:

```
woof-nam fetch --cycle 2025031412 --hours 24 --case-dir cases/2025-03-14_12z
```

**GFS start (any cycle, including after the NAM's retirement).** This fetches GFS and MRMS only.
For a cycle with no NAM files on NOAA's bucket, the fetch does this by itself and says so.

```
woof-nam fetch --cycle 2026110412 --hours 24 --case-dir cases/2026-11-04_12z --gfs-only
```

A GFS start still needs the NAM grid's static surface fields (land mask, soil and vegetation type,
terrain) once. Build them from any archived NAM analysis, for example the example case's file:

```
woof-nam static cases/2025-03-14_12z/raw/nam/bgrd3d00.grib2
```

This writes `static/nam12_static.npz` (1.4 MB, a few seconds). Every later GFS start reuses it.

**IFS start (ECMWF open data, CC BY 4.0).** `--source ifs-0p25` (0.25 degree, cycles from 2025-03-14 12Z)
or `--source ifs` (0.1 degree, cycles from 2026-10-20 12Z) fetches the IFS start, its 3-hourly
boundaries from the same IFS cycle and MRMS. IFS open data has no sea-ice cover, so that one field
comes from the same cycle's GFS. An IFS start uses the same static fields as a GFS start.

```
woof-nam fetch --cycle 2025031412 --hours 24 --case-dir cases/2025-03-14_12z --source ifs-0p25
woof-nam run --case 2025-03-14_12z --source ifs-0p25 --hours 24 --out runs/2025-03-14_12z-ifs
```

**ERA5 start (hindcasts, CC BY 4.0).** `--source era5` fetches the ERA5 analysis at the start and every 3 h
after it, and MRMS where it exists (MRMS on NOAA's bucket starts in October 2020; older dates have no
reflectivity to compare with). ERA5 carries its own sea ice, snow, soil and sea-surface temperature, so
nothing comes from another model. An ERA5 start uses the same static fields as a GFS start.

```
woof-nam fetch --cycle 2025031412 --hours 24 --case-dir cases/2025-03-14_12z --source era5
woof-nam run --case 2025-03-14_12z --source era5 --hours 24 --out runs/2025-03-14_12z-era5
```

## Run one forecast

```
woof-nam run --case 2025-03-14_12z --source native --hours 24 --out runs/2025-03-14_12z
```

`--case` is the case folder from `woof-nam fetch` (a bare name is looked up under `cases/`).
`--source gfs` starts from GFS instead, `--source ifs-0p25` or `--source ifs` from the IFS, `--source era5`
from ERA5. The run writes:
- hourly history `wrfout_d01_<valid time>` (wrfout-shaped NetCDF);
- maps in `<out>/maps/<product>/` (composite reflectivity, 2 m temperature and dewpoint, 10 m and
  850 hPa wind, MSLP, 1 h precipitation);
- `forecast-receipt.json` (init time, ms per step, per-stage timing, end-of-run finite check).

`woof-nam init` builds and writes the initial state only (0 h history and maps), without a forecast.

## Restarts

`--restart-every 1h` writes the whole forecast state every hour. `--resume` continues from the newest set to
the run's original end, and a resumed run writes the same history files, byte for byte, as a run that was
never stopped.

```
woof-nam run --case 2025-03-14_12z --source native --hours 84 --out runs/x --restart-every 1h
# the machine goes away at 30 h; on this or another machine with woof-nam and the same case:
woof-nam run --resume runs/x/restart        # case, source, end hour and output folder come from the set
```

- **What a set holds.** A set is everything the step reads, taken right after that hour's history file:
  - every prognostic and physics field: soil, snow, the precipitation and max-field accumulators, the radiation state;
  - the digital-filter state;
  - the boundary arrays and the position in the boundary files;
  - the tables built at init;
  - the step and radiation counters and the clock.

  It is `<out>/restart/wrfrst_d01_<valid time>/`, 15-16 GiB for the 12 km grid on either memory path: on a card of
  64 GiB or more (the full path) a set leaves out the step scratch that path keeps between steps, as the 32 GB fit path
  has already released it. `<out>/restart/LATEST` names
  the newest complete set, and `forecast-receipt.json` gives its path as `restart_latest`. The run's boundary
  files are copied once into `<out>/restart/boco`, so a set also resumes on a machine whose case folder is
  somewhere else.
- **Safe to kill at any moment.** A set is written under a temporary name and renamed when it is complete, so a run
  killed mid-write keeps the previous set. `--restart-keep N` keeps the newest N sets (default 1).
- **Cost.**
  - Each set is one copy of the state from the card into pinned host memory, queued in step order. The step loop
    does not wait for it: 0.01-0.02 s of host time per set.
  - The files are written by a background thread while the forecast steps on: 34-130 s per set on a busy disk.
  - The first set of a run also allocates the 15 GiB pinned buffer: 6-10 s, once.
  - Host memory: one pinned buffer the size of the state.
- **Proof.** 2025-03-14 12Z native start, 6 h, one 32 GB card, both runs from one saved initial state:
  - a straight run, and a run killed with SIGKILL right after its 3 h set, then resumed from that set;
  - all 7 hourly history files (0-6 h) of the two runs are byte-identical (`cmp`, and `woof-nam compare`: 0 values differ);
  - the resumed process loaded the set in 5.8 s.
  - The same on the full memory path (a 96 GB card, 2023-03-31 12Z GFS start, both runs from one saved
    initial state): a 2 h run with `--restart-every 1h`, resumed to 3 h, wrote f00-f03 byte-identical to a straight
    3 h run (85 variables, 0 values differ). Each set was 16.2 GiB, written in 2-4 s; the resume loaded it in 8-9 s.
- **Scope.** One card. With `--cards N` the restart options stop with a message: each card would have to write its
  own rows and resume on the same N cards, and that path is not written yet.

A run that has to start from the same bits as another one saves the initial state with `--keep-init` (on one
card, after the init, into `<out>/init`). The second run then starts with `--init-from <out>/init`. That only
saves the init time: two runs of the same case on the same card are bit for bit the same with a fresh init too
(12 km, GFS start, digital filter, all physics, 6 h: every history hour, 0 of 6,295,450,910 values differ).

## Spin-up start

A cold start from the GFS analysis has no cloud, rain or snow and no model-made boundary layer at hour 0. The
operational NAM started each cycle 6 h earlier and caught up to it, so its hour 0 carried them. `--start spinup`
does the same with public data:

```
woof-nam run --case 2024-08-25_18z --source gfs --hours 84 --out runs/x --start spinup                 # IAU
woof-nam run --case 2024-08-25_18z --source gfs --hours 84 --out runs/x --start spinup --spinup-update nudge
```

- **What it does.**
  1. Starts from the GFS analysis 6 h before the cycle (`--spinup-hours`, a multiple of 6).
  2. Runs the model 6 h with physics on, using the boundaries of the same GFS cycle the forecast uses, so the
     boundary has no seam at the cycle.
  3. Brings PD, T, Q, U and V to the cycle's GFS analysis. The hydrometeors, W, TKE, soil and surface keep what
     the 6 h made.
     - `iau` (the default): the increment, analysis minus model at the cycle, goes in over a 6 h window centred
       on the cycle. The run rewinds to the window's start once, through a restart set (it re-executes as
       `woof-nam run --resume`).
     - `nudge`: the state is relaxed toward the analysis over the last hour before the cycle, with a 1 h
       relaxation time.
  4. Forecasts from the cycle. Hour 0 is the cycle; accumulators start at zero.
- **Inputs.** It needs three more GFS files: the analysis 6 h earlier and the 0 and 3 h leads of that cycle.
  `woof-nam fetch --spinup-hours 6` fetches them, and `run` fetches them itself when they are missing.
- **Cost** (12 km CONUS, one 96 GB card, 2024-08-25 18Z):
  - `iau` adds about 5.4 min to a cycle, `nudge` about 3.0 min.
  - Hour 0 held cloud water up to 2.4 g/kg, snow up to 9.7 g/kg and composite reflectivity to 51 dBZ, with 4.6 % of
    the grid over 20 dBZ. A cold start has none of these.
- **Scope.**
  - One card.
  - Sources gfs, ifs, ifs-0p25 and era5. The native row is one analysis file per case, and a parent run starts at
    its own hour 0.
  - The default `--start cold` path is unchanged: from one saved initial state, the 3 h histories of the engine
    before and after this change are bit for bit the same.

## Make maps

Every map is drawn by gpuwm's Rust renderer `rw_wrfbatch`. Each map is titled "WOOF-NAM 12 km" with
the init time, lead and field, plus the valid time. A forecast draws its own maps when it ends. To
redraw them from history files:

```
woof-nam maps runs/2025-03-14_12z/wrfout_d01_* --out runs/2025-03-14_12z/maps
```

To compare sources side by side (MRMS | WOOF-NAM | archived NAM, with the same colour scales, map frame
and image size), draw the panels for each source, then compose the sheets, as in the Quick start.
`--hours` takes valid times (`YYYYmmddHH`, one or more). A sheet needs every source's panel for its
hour; the MRMS and archived NAM panels can be drawn before any forecast has run.

Every `woof-nam` step is also a module (`python -m namgpu.init.init_fetch_case`, `namgpu.init.gfs_start`,
`namgpu.run_forecast`, `namgpu.run_init_case`, `namgpu.io.maps`, `namgpu.io.io_referee_panels`,
`namgpu.io.io_referee_sheets`, `namgpu.io.hist_compare`, `namgpu.licence_check`), with the same options.

## GRIB2 products (awphys shape)

`woof-nam products` writes one GRIB2 file per forecast hour in the shape of NOAA's NAM 12 km CONUS product
`nam.tHHz.awphysFF.tm00.grib2`, so code that reads NOAA's NAM files reads ours with two changes: the file name
starts with `woof-nam.`, and the generating process number is 254 where NOAA's is 84.

```
woof-nam products --run runs/2025-03-14_12z                   # every history hour of the run
woof-nam products --run runs/2025-03-14_12z --hours 0-6
woof-nam run --case 2025-03-14_12z --hours 84 --out runs/x --products   # write each hour while the forecast runs
woof-nam products --compare cases/2025-03-14_12z/raw/nam/awphys06.grib2 \
    runs/2025-03-14_12z/products/woof-nam.t12z.awphys06.tm00.grib2     # grid and inventory against NOAA's file
```

- **Files.** `<run>/products/woof-nam.tHHz.awphysFF.tm00.grib2` (HH = start hour, FF = forecast hour), a `.idx`
  beside each (exactly what `wgrib2 -s` prints, like NOAA's index files), and `index.json` for the run (file, bytes,
  records, valid time, and every record left out with its reason).
- **Grid.** NCEP grid 218: Lambert conformal, 614 x 428 points, 12.19 km, true latitude 25 N, orientation 265 E,
  NCEP's sphere. The grid section is byte-identical to NOAA's.
- **Records.** NOAA's discipline, category and parameter numbers, fixed surfaces, time ranges and record order, from
  the record table `namgpu/products/awphys.tsv` (one row per record of NOAA's file). The full 50-1000 hPa isobaric
  set every 25 hPa is in, with VVEL, DZDT, ABSV and TKE. Accumulations use NOAA's 12 h and 3 h buckets.
- **Packing.** GRIB2 complex packing, as in NOAA's files, with NOAA's own decimal and binary scale for each record.
  Values carry NOAA's precision.
- **How.** The history fields are regridded from the NMMB rotated lat-lon grid to grid 218 (bilinear; soil and
  vegetation classes and masks nearest), winds turned grid-relative as NCEP writes them, and handed to gpuwm's Rust
  GRIB2 exporter `rw_rrfs_upp`, which computes the derived fields and encodes on every core. Its column work
  runs on the GPU (`--post-device gpu`, the default). If a shared card runs out of memory, the hour waits for room
  and is rerun on the GPU instead of lost, and `index.json` lists the rerun. Every `--post-device` choice needs a
  CUDA device, `cpu` included: the writer computes the derived records of NOAA's files on a card only. With no
  device visible, `woof-nam products` stops before the first hour and says so in one line.
- **With the run.** `woof-nam run --products` returns once `<out>/products/DONE` is written, so a batch job that
  ends with the command keeps every hour. If the follower fails, the run exits non-zero with one line naming the
  hour; if it writes nothing new for `--products-stall-s` (900 s), the run stops it and exits non-zero.
  `--no-products-wait` returns at once, for a caller that waits on `DONE` itself. `woof-nam nest --products` waits
  the same way.
- **The exporter.** The GRIB2 writer is `rw_rrfs_upp` (gpuwm's Rust field-set writer with the NAM awphys profile),
  a 17 MB Linux x86-64 binary attached to the woof-nam GitHub release (manylinux_2_28: RHEL 8, Debian 10,
  Ubuntu 20.04 and later). The first
  `woof-nam products` (or `woof-nam run --products`) downloads it into `~/.woof-nam/bridges/` and checks its size
  and SHA-256 against the pins in the package before installing it. `woof-nam fetch-bridges` does the same ahead of
  time, and `woof-nam fetch-bridges --from FILE` installs a copy you already have (same pins). Set
  `WOOF_NAM_BRIDGE_URL` to fetch from a mirror, or `WOOF_NAM_RW_RRFS_UPP` to run your own build.
- **Speed.** Measured with 0.2.1 on one 32 GB card and 12 cores of a 24-core host that was busy with other work
  (2024-11-05 12Z from the NAM's analysis, maps and columns on): about 28 s of model per forecast hour; each
  GRIB2 hour took 27-66 s to frame and 12-26 s to write, two hours in flight. In a 12 h run f06 was in place
  6 min 15 s after the start and f12 after 10 min 40 s, 3 min 40 s after the forecast's last step.

**How many records.** A 0.2.1 file holds 451 records at f06 (443 at f00, 449 at f03), of NOAA's 454; the 3 left out
are named under "Not in the files" below. The four precipitation types are new in 0.2.0 and the accumulated snowfall
(WEASD) in 0.2.1, so a 0.2.0 file holds 450 at f06 and files from earlier versions at most 446. The first check
below was made with an earlier version and counts fewer.

**First check against NOAA (an earlier version).** 2025-03-14 12Z, a 6 h native start, f00-f06, each file against
NOAA's archived `nam.t12z.awphysFF.tm00.grib2` of the same hour:

| hour | records | match NOAA's inventory line and order | MB (NOAA's file) |
|---|---|---|---|
| f00 | 438 | 438 of 438 | 60.4 (54.9) |
| f01 | 442 | 442 of 444 | 63.0 (57.7) |
| f02 | 442 | 442 of 444 | 63.7 (57.9) |
| f03 | 442 | 442 of 444 | 64.5 (58.7) |
| f04 | 442 | 442 of 444 | 64.9 (58.8) |
| f05 | 442 | 442 of 444 | 65.6 (59.8) |
| f06 | 444 | 444 of 446 | 66.1 (60.4) |

- The grid section is byte-identical at every hour.
- The two records missing at f01-f06 are MAXUW and MAXVW (hourly 10 m maximum wind). The history of this check was
  written before the model wrote its hourly 10 m maximum wind. A run of this version writes it.
- f00 has fewer records because NOAA's analysis file has no hourly maxima, minima or accumulations either.
- Values, our forecast against NAM's on grid 218 at f06 (correlation): surface temperature 0.997, 2 m maximum and
  minimum temperature 0.999, 2 m maximum and minimum RH 0.986 and 0.987, gust 0.925, PBL height 0.952, Haines index
  0.951. `tools/grib2_value_check.py` prints correlation and bias for every record.
- In that history the vertical velocity is the bare W, without the terrain-forced term that W_TOT also carries, so
  VVEL and DZDT have NAM's structures at about 0.7 of its amplitude. A run of this version writes W_TOT, and
  the products use it.

**Checked again for 0.2.0.** 2026-01-23 12Z, GFS start, each file against NOAA's archived file of the same hour: f00
442 of 442, f03 448 of 448 and f06 450 of 450 records present at that hour match NOAA's inventory line and order
(MAXUW and MAXVW are written). `woof-nam inventory` against NOAA's 2026-11-03 06Z f01: 448 of NOAA's 452 records
written, the 3 below and WEASD (written from 0.2.1) not written, none unexplained. At f06, 408 of the 450 records
also carry NOAA's decimal and binary scale factors exactly and 42 differ in one or both (16 TKE, 13 HGT, 4 VVEL, 3
UGRD/VGRD pairs, DPT at 2 m, SNOD, LHTFL; `docs/COMPATIBILITY-TABLE.md` gives each).

**Not in the files.** 3 of NOAA's 454 records: visibility at cloud top, the Blackadar mixing length (NOAA's file holds
zero there) and lightning (LTNG). The four dominant precipitation types (CSNOW, CICEP, CFRZR, CRAIN) are written from
0.2.0, and the accumulated snowfall water (WEASD, NOAA's 12 h window) from 0.2.1, so a 0.2.1 file holds 451 records at
f06 (443 at f00, 449 at f03). A record that is missing is left out of the file, never written as zeros or under another record's
name. `docs/COMPATIBILITY.md` lists what a site changes, and `docs/COMPATIBILITY-TABLE.md` gives every record.

## Nest GRIB2 products (hiresf)

For a nest, `woof-nam products` writes NOAA's NAM nest files instead: one GRIB2 file per forecast hour named like
NOAA's (`woof-nam.tHHz.<nest>.hiresfFF.tm00.grib2` + `.idx`), on that nest's NOAA output grid, with NOAA's record list
and order.

```
woof-nam nest --center 32N,96W --size-km 1000 --res-km 3 --source gfs --start 2026110306 --hours 4 \
    --out runs/tx --products conusnest                         # write each hour while the nest runs
woof-nam products --run runs/tx/run --set conusnest            # or afterwards
woof-nam products --compare nam.t06z.conusnest.hiresf01.tm00.grib2 \
    runs/tx/run/products/woof-nam.t06z.conusnest.hiresf01.tm00.grib2   # grid and inventory against NOAA's file
```

| set (`--set`) | NOAA file | grid (byte-identical section 3 to NOAA's) |
|---|---|---|
| conusnest | nam.tHHz.conusnest.hiresfFF | Lambert 1799 x 1059, 3000 m (the HRRR grid) |
| alaskanest | nam.tHHz.alaskanest.hiresfFF | polar stereographic 1649 x 1105, 2976 m |
| hawaiinest | nam.tHHz.hawaiinest.hiresfFF | Mercator 321 x 225, 2500 m |
| priconest | nam.tHHz.priconest.hiresfFF | Mercator 544 x 310, 2500 m |
| firewxnest | nam.tHHz.firewxnest.hiresfFF | a Lambert box of NCEP's 1.27 km master grid around the nest (NCEP's rule; NOAA's own boxes for its two production points) |
| hiresf | (any other nest) | a Lambert box around the nest at its own spacing |

- **Which set.** `--set auto` (the default) writes awphys for the 12 km CONUS parent, and for a nest the NCEP nest its
  run names (`ncep_nest` in nest-receipt.json, or the nest's name in its domain), else `hiresf`.
- **Records.** The tables `namgpu/products/hiresf-conusnest.tsv` (876 records at f01-f60) and `hiresf.tsv` (871, the
  other four nests), made from NOAA's 2026-11-03 06Z files by `tools/hiresf_tables.py`. f00 is the same list without
  the hour's maxima and minima, with the bucket accumulations and averages as "0-0 day" windows, as NOAA's.
  U/V and USTM/VSTM are two-field messages (`N.1`/`N.2` in the `.idx`), as NOAA's 66 pairs per file.
- **Windows.** NCEP's nest windows: accumulations and averages over the 3 h bucket (0-1, 0-2, 0-3, 3-4, ...), from
  NMMB's own 3 h accumulators; hourly maxima and minima over the last hour. The fire-weather nest empties its
  accumulators every hour, as NCEP's did, so its files carry 0-1, 1-2, 2-3, ... (`hiresf-firewxnest.tsv`).
- **How.** As NCEP did for its nests (nearest-neighbour regrid of the nest's own columns; budget for APCP, WEASD and
  SNOD; winds grid-relative), but before the products are computed, so each record is made from the nest column at that point. Points
  of the grid outside the nest are missing (bitmap). The writer computes only the window of the grid the nest covers,
  so a nest smaller than NOAA's grid costs its own size.
- **Packing.** Complex packing (DRT 5.3) for every nest, at NOAA's per-record scale. NOAA's Hawaii, Puerto Rico and
  fire-weather files use JPEG2000 (DRT 5.40); the records are the same, only the packing template differs.
- **Writer.** The nest files need a `rw_rrfs_upp` built from gpuwm `woof/nam-hiresf` (two-field messages, the
  off-grid bitmap, polar stereographic and Mercator vorticity): `rw_rrfs_upp --capabilities` lists `pair_next
  mask_carrier`. Set `WOOF_NAM_RW_RRFS_UPP` to it; an older writer is refused in one line.

**Checked against NOAA** (3 h nests from GFS 2026-11-03 06Z on all five grids against NOAA's 06Z files of the same
hours): every record we write has NOAA's inventory text and GRIB2 keys and comes in NOAA's order at f00-f03 (CONUS
799 of 876 at f01 and 783 of 860 at f00; the other nests 794 of 871 and 782 of 859; Hawaii's flight levels lack
NOAA's bitmap, below), and the grid section is identical to NOAA's on all five grids. Two things a reader of NOAA's files changes: record numbers count the records in the file,
so after the first record we leave out (CICE on the lowest model level) ours run behind NOAA's (select by inventory
text, as `wgrib2 -match` does); and on the flight levels (305-3658 m above sea level) NOAA marks the points below the
ground missing, where ours carry a value. [docs/nests/COMPATIBILITY.md](docs/nests/COMPATIBILITY.md) has every record
of every nest.

**Not in the files** (71 records, the same in every hour and cycle, each named in `index.json` with its reason; the four
precipitation types, cloud-top temperature and the LCL pressure are written from 0.2.0):
cloud ice (CICE on 40 levels and the lowest level, TCOLI: the history keeps Ferrier-Aligo's ice whole in SNMR),
lightning, the Noah canopy resistances (CCOND, RSMIN, RCS, RCT, RCQ, RCSOL), moisture
divergence (MDIV), stream function, brightness temperature, the column heating rates, the melting-ice column, cloud-top
visibility, the grid-scale cloud base and top pressures, the supercooled liquid layer heights,
instantaneous 2-5 km updraft helicity, tropopause wind shear, momentum fluxes, clear-sky downward shortwave,
instantaneous ground heat flux and the Blackadar mixing length.

## Output size

For the 12 km grid, per forecast hour:

| output | per hour | f00-f84 (85 hours) |
|---|---|---|
| awphys GRIB2 (`woof-nam products`) | 60-66 MB (f00-f06) | about 5.6 GB |
| history `wrfout_d01_*`, lossless (zlib 1 + shuffle) | about 1.0 GB | about 86 GB |
| history, uncompressed (for scale) | 2.93 GB | - |
| restart set (`--restart-every`) | 15-16 GiB per set | `--restart-keep` sets (default 1) |

- The 84 h GRIB2 figure is 85 files at the f06 size. NOAA's own files run about 10 % smaller (60.4 MB at f06).
- The history is compressed losslessly by default: 2.93 GB -> 1.01 GB an hour (2.9x), and every value reads back
  exact. Any netCDF-4 or HDF5 reader opens it with no plugin.
- `--history-fields` picks the fields of each hourly history file: `products` (default: what the maps, side-by-side
  sheets and `woof-nam products` read), `full`, `state` (the 3-D model state), or a comma list. `--full-every 3h`
  (default) makes every 3rd hour carry every field. The presets change the size little (products 1,003 MB, full
  1,012 MB, state 862 MB an hour), because the awphys records need every 3-D field and those are 98 % of the bytes.
  The way to write less is fewer history hours, or deleting the history once the GRIB2 files are written.

## Scope

- **Domains** (`--domain`, rows of `namgpu/parm/domains.json`): the NAM 12 km CONUS parent (`conus12`, rotated lat-lon
  B grid, 954 x 835 x 60, 25 s step, the default); the NAM North America footprint at 7.6 km (`na7p6`, 1506 x 1318 x 60,
  15 s step); 7.6 km CONUS (`conus7p6`); 5 km and 4 km CONUS (`conus5`, `conus4`); a 16 km SREF-shape North America grid
  (`sref16`); 3 km nests anywhere (`woof-nam nest`, below).
- **Dynamics:** NMMB, ported from the NAM source to CUDA kernels.
- **Physics:** by default the NAM's suite as NCEP ran it, all on the GPU:
  - Ferrier-Aligo microphysics;
  - Betts-Miller-Janjic convection;
  - MYJ boundary layer and the Janjic surface layer;
  - Noah land surface;
  - RRTM longwave and shortwave (NCEP's RRTMG, hourly);
  - Janjic gravity-wave drag (GMTED2010 terrain).

  Newer schemes are selectable, one slot at a time or as a whole suite ("Physics suites and options" below). The
  default run is unchanged by them, bit for bit.
- **Start sources:** the archived NAM native analysis (`bgrd3d00`, for cycles before the
  retirement), GFS 0.25 degree for any date from 2021, ECMWF open data IFS (0.25 degree from 2025-03-14 12Z,
  0.1 degree from 2026-10-20 12Z) or the ERA5 reanalysis (from 1940). On the NAM and GFS starts the lateral
  boundaries come from the GFS cycle 6 hours older, as in the operational NAM; on an IFS start they come
  from the same IFS cycle; on an ERA5 start they are ERA5 analyses ("Start sources" above).
- **Not bitwise with the NAM.** The port runs in single precision with fast numerics. It is judged
  by whole wet forecasts beside the archived NAM forecast of the same cycle and MRMS reflectivity.

## Physics suites and options

The NAM suite (`nam`) is the default. Every other scheme is an option, selected one slot at a time (below) or as a whole with `--physics-suite` (rows of `namgpu/parm/physics_suites.json`):

| `--physics-suite` | what runs |
|---|---|
| `nam` (default) | the NAM v4.2.11 physics above |
| `hrrrv5` | the RRFS v2 hrrrv5 suite on the NMMB dycore: TEMPO, MYNN-EDMF, MYNN surface layer, RUC, RRTMG, GSL drag, no deep convection. Needs gpuwm-hex (TEMPO). |
| `rapv5` | NOAA RAP v5 pairing on the NMMB dycore: aerosol-aware Thompson (mp28), Grell-Freitas deep convection, MYNN-EDMF, MYNN surface layer, RUC, RRTMG, GSL drag. (gpuwm pairs Grell-Freitas with Thompson, not with TEMPO, so the convection-on suite uses mp28.) Needs gpuwm-hex: it keeps TEMPO's tracer table and tables. |
| `woof-nam-next-12km` | a preset on the NAM 12 km grid: the NAM's MYJ PBL, surface layer and BMJ convection kept; RUC land (9 levels) from HRRR's soil analysis where HRRR covers the grid and the CDF soil start elsewhere; TEMPO microphysics with melting-layer reflectivity; RTE+RRTMGP radiation; UGWP drag. Needs gpuwm-hex (TEMPO). The first run fetches the soil table of its start month and the HRRR soil classes. |
| `woof-nam-next-7p6km` | the same preset on the NAM North America footprint at 7.6 km (`na7p6`, 1506 x 1318), with New Tiedtke convection (shallow on) in place of BMJ. On a 96 GB card the run takes the fit memory path by itself. Needs gpuwm-hex (TEMPO). |

Single slots, each beside the NAM's other schemes:

| slot | option | select with |
|---|---|---|
| land surface | RUC (WRF v4.6.1), HRRR soil analysis start | `NAMGPU_LSM=ruc` (`NAMGPU_RUC_HRRR_SOIL=auto`, `NAMGPU_RUC_SOIL_STATIC=auto`) |
| land surface | Noah-MP (WRF-lineage v4.x) | `NAMGPU_LSM=noahmp` |
| soil start | CDF match to the NAM soil climate | `NAMGPU_SOIL_START=cdf NAMGPU_SOIL_CDF=auto` (a run fetches its month's table; `woof-nam fetch-soil-cdf` fetches all) |
| microphysics | TEMPO v3.2.5 (default for this option); v3.0.3 | `NAMGPU_MP=tempo`; add `NAMGPU_TEMPO_VERSION=v3.0.3` for the older version. Melting-layer reflectivity is on. |
| microphysics | Thompson, aerosol-aware Thompson, P3 | `--domain conus12-mp8`, `conus12-mp28`, `conus12-p3` |
| radiation | RTE+RRTMGP; WRF RRTMG | `NAMGPU_RADIATION=rrtmgp`; `NAMGPU_RADIATION=rrtmg` |
| boundary layer | YSU with the revised MM5 surface layer | `--pbl ysu` (`--topo-wind 1` adds the Jimenez-Dudhia subgrid terrain drag) |
| boundary layer | MYNN-EDMF with the MYNN surface layer | `NAMGPU_PBL=mynn-edmf` (BMJ shallow convection steps aside beside the EDMF mass flux) |
| boundary layer | MYNN-EDMF v6.1.1 with MYNN-SFC v6.1.0 (NCAR single-source repositories) | `NAMGPU_PBL=mynn-v61` |
| convection | Grell-Freitas (scale-aware); New Tiedtke | `NAMGPU_CONVECTION=gf`; `NAMGPU_CONVECTION=ntiedtke` |
| drag | NOAA-GSL UGWP drag suite | `--gwd ugwp` (`nam` default, `off`) |

The options and suites were measured on one card (`--cards 1`).

What each option needs beyond the base install:

- TEMPO in the NMMB microphysics slot (`NAMGPU_MP=tempo`): `pip install "recast-woof-nam[modern]"` (gpuwm-hex >= 0.5.0) and its tables,
  `gpuwm-hex physics-resources fetch`. The four TEMPO lookup files come from gpuwm-hex on the first TEMPO run
  (`NAMGPU_TEMPO_LOOKUP=<dir>` names a folder that holds them instead).
  The configfile key `tempo_version: v3.0.3` also selects the older version; `NAMGPU_TEMPO_VERSION` takes precedence.
  Both versions use the installed hex physics-resource packet's TEMPO maths header and shared lookup tables.
  `NAMGPU_TEMPO_REFL_MELT=0` explicitly selects the older reflectivity diagnostic. The frozen `nam` default does not run TEMPO.
- MYNN v6.1 (`NAMGPU_PBL=mynn-v61`): gpuwm-hex 0.5.0 or newer (its MYNN v6.1 port).
- RUC with HRRR static soil classes: the BNU soil set in the geog folder. A run fetches it (8 MB) into the first geog
  root if it is missing; to stage it ahead, `gpuwm fetch-geog --datasets bnu_soiltype_top --root ~/WPS_GEOG`.
- CDF soil start: the 12 monthly tables (about 268 MB each). A run fetches the table of its start month if it is
  missing; `woof-nam fetch-soil-cdf` installs all twelve ahead (`--months` for fewer).
- UGWP: the drag statistics are built from the geog terrain by `rw_hex_ugwp_oro` (`tools/ugwp-oro`, Rust, every core),
  once per grid and month; `woof-nam fetch-bridges` stages the prebuilt program, and the first run that needs it
  downloads it.

Each option was run as one scored 12 h arm beside the frozen NAM (2026-01-23 12Z, GFS start, CONUS ASOS, MRMS and Stage IV); with every option off the forecast is the frozen NAM's, bit for bit. `woof-nam score` (below) scores any run the same way.

## Score against observations

`woof-nam score` scores one or more runs of a case beside the observations and draws obs | control | run sheets:

```
woof-nam score --cycle 2026012312 --case-dir cases/2026-01-23_12z --run control=runs/control --run modern=runs/modern --out score
```

ASOS 2 m temperature, dewpoint and 10 m wind (bias, MAE, RMSE at each lead), MRMS composite reflectivity (FSS at 20 and
35 dBZ), Stage IV 6 h precipitation (ETS, FSS), and the archived NAM at the same stations as a reference column. The
observation readers `rw_asos` and `rw_stage4` are release assets: `woof-nam fetch-bridges` stages them, and the first
score that needs one downloads it, checked against the pins in the package. Sheets are drawn by gpuwm's Rust renderer.

## Speed and memory

One 96 GB card (full memory path), fresh clone and wheel install, 2025-03-14 12Z native start:
- **Digital filter (TDFI):** 70.7 s (150 backward and 150 forward steps of 8 s), before the forecast, as the
  NAM runs it.
- **24 h forecast:** 3,456 steps in 615 s, 178 ms per step (all physics, hourly history); 731 s for the whole
  `woof-nam run`, start state and maps included. Every field finite at the end.
- **Memory:** the forecast's pool ended at 74 GiB; the card peaked at 84.5 GB.

The fit memory path (taken by itself on cards under 64 GB), 0.1.1, 2026-11-05. Each run starts from one saved
initial state (`--init-from`), runs the digital filter and then the forecast with hourly history; the peak is the
forecast process on the card (NVML, sampled every 10 ms). Every history value is the same as with 0.1.1.dev6, which
peaked where the last column says.

| Grid (points) | Card | Run | Peak on the card | 0.1.1.dev6 | Forecast step |
|---|---|---|---|---|---|
| 12 km CONUS (954 x 835 x 60) | 32 GB card | 1 h, native 2025-03-14 12Z | 22,548 MiB | 28,638 MiB | 358.6 ms (362.7) |
| 12 km CONUS (954 x 835 x 60) | 32 GB card held to 23,963 MiB free (a 24 GB card) | 1 h, same start | 22,468 MiB | - | 343.2 ms |
| 12 km CONUS (954 x 835 x 60) | 2 cards of 32 GB, `--cards 2` | 1 h, same start | 13,094 + 12,996 MiB | - | same bits as 1 card |
| 3 km nest (333 x 333 x 60) | 32 GB card (shared) | 3 h, GFS 2025-03-14 12Z | 5,778 MiB | 8,654 MiB | - |
| 3 km nest (100 x 100 x 60) | 32 GB card (shared) | 1 h, GFS 2025-03-14 12Z | 3,322 MiB | 4,306 MiB | - |

- **Smallest card each grid fits:** the 12 km grid a 24 GB card (the run above; on a 24 GB card the column physics
  works in row bands by itself when a whole-domain call would not fit, with the same output); the 333 x 333 nest (and up to
  about 415 x 414, measured) an 8 GB card (below) and the 100 x 100 nest a 4 GB card, from its peak.
- **What the peak holds:** 2.44 GiB of it, on a 32 GB card, is the local memory the GPU reserves for the step
  kernels (10,016 bytes per resident thread; a card with fewer multiprocessors reserves less), and about 0.3 GiB is the
  CUDA context and modules. The rest is the run's memory pool, which grows only when a request needs it and hands
  unused blocks back after each init stage, radiation call and history write.
- The forecast-step column is the 1 h forecast loop after the filter, on a card running nothing else; the nest rows ran on
  a shared card, so they give no step time.

**An 8 GB card.** One 8 GB card (driver for CUDA 13.0), `pip install recast-woof-nam==0.1.2` into a fresh
venv (111 s), 3 km nests from GFS 2025-03-14 12Z through the door, every physics scheme on, the card running nothing
else, e.g. `woof-nam nest --center 38.5N,91W --size-km 1148 --size-y-km 989 --res-km 3 --source gfs --start 2025031412
--hours 3 --out runs/nest`. The peak is the whole card (nvidia-smi every 0.5 s); the step is the forecast loop after the
filter. The first run compiles the CUDA kernels on the card (272 modules in 21 s on 13 processes); later runs load
them from the cache in about 1 s.

| Grid (points) | Card | Run | Peak on the card | Forecast step | Door, start to sheets |
|---|---|---|---|---|---|
| 3 km nest (99 x 100 x 60) | 8 GB card | 1 h, GFS 2025-03-14 12Z | 2,011 MiB | 9.2 ms | 149 s (68 s of it the GFS download) |
| 3 km nest (328 x 330 x 60) | 8 GB card | 3 h, same start | 4,104 MiB | 71.0 ms | 256 s (inputs already fetched) |
| 3 km nest (360 x 359 x 60) | 8 GB card | 1 h, same start; radiation in 4-row chunks (0.1.2's pick) | 4,178 MiB | 142.8 ms | 238 s (inputs already fetched) |
| 3 km nest (378 x 377 x 60) | 8 GB card | 1 h, same start; 0.1.3, radiation in 16-row chunks | 5,008 MiB | 94.9 ms | 156 s (inputs already fetched) |
| 3 km nest (415 x 414 x 60) | 8 GB card | 1 h, same start; 0.1.3, radiation in 16-row chunks | 5,614 MiB | 112.9 ms | 189 s (inputs already fetched) |
| 3 km nest (99 x 100 x 60) | 8 GB card | 1 h, ERA5 2025-03-14 12Z (`--source era5`); 0.1.3 | 1,960 MiB | 9.6 ms | 121 s (48 s of it the ERA5 download) |

From 0.1.3 the door's estimate is 1-4 % above these peaks at 4- and 8-row chunks and 15-17 % above at 16, so on an 8 GB card it
admits nests up to about 490 x 490 points and gives them the largest radiation chunks that fit; `woof-nam doctor`
prints what the card in hand can run.

## Running on more than one card

The same forecast runs on several cards of one machine. Add `--cards N`:

```bash
woof-nam run --case 2025-03-14_12z --source native --hours 24 --out runs/2025-03-14_12z-4c --cards 4
woof-nam run ... --cards 4 --card-list 4,5,6,7      # pick the cards (default 0..N-1; or set NAM_CARDS)
```

Each card picks its memory path as on one card: under 64 GB every rank takes the 32 GB fit by itself (radiation
8 rows at a time). The 12 km runs in the table below used the full path with 8-row radiation
(`NAMGPU_MEMORY_PATH=full NAMGPU_RRTM_ROWS=8`), which fits 4 or 8 cards of 32 GB with room to spare and 2 only on
otherwise empty cards; on 2 cards leave the fit on.

What happens:

1. **The initial state is built once**, on the first card, and saved to `<out>/init/` (about 14 GB for the
   12 km grid). The run deletes it at the end; `--keep-init` keeps it, and `--init-from <folder>` reuses a saved
   one (from an earlier `--keep-init` run of the same case, source and hours). Add
   `--managed-init` when the whole-domain init does not fit one card.
2. **One process per card.** The grid is cut into bands of whole rows (row slabs): with `JM` rows and `N` cards
   each card owns `JM // N` rows, and the first `JM % N` cards one more. Every card keeps the full west-east width
   plus 3 halo rows on each side it shares with a neighbour. On the 12 km grid (954 x 835) that is 418 + 417
   rows on 2 cards, 209/208 on 4, 105/104 on 8.
3. **Halo rows are exchanged over NCCL** at the 21 places in the time step where NMMB itself exchanges halos,
   on the GPU stream, with no host sync. The cards need no peer-to-peer link; NCCL goes through host shared
   memory when there is none.
4. **Sums over the whole domain are made the same on any number of cards**: each card sums its own rows in a
   fixed order, the row sums are gathered, and every card adds them in row order 1..JM. One card uses the same
   code, so a forecast gives the same bits run after run.
5. **History is one file per hour, as on one card.** Each card hands its owned rows to a pool of writer processes
   (`--hist-workers`, default 4) through `/dev/shm`, which writes `wrfout_d01_<valid time>`; maps follow as usual.
   `<out>/forecast-receipt.json` lists ms/step, memory and the non-finite census per card; `<out>/rank<r>.log` is
   each card's log.

**Same bits on any number of cards.** Hourly history, 7 hours (0-6 h) x 26 variables, 0 values differ in every
pair below:
- the 12 km CONUS grid, native start 2025-03-14 12Z, every physics scheme on: 2 cards vs 4 cards, and two 4-card
  runs on different cards;
- a 954 x 279 band of the same grid (its centre rows; GFS start), which fits one 32 GB card: 1 card vs 2 cards,
  1 card vs 4 cards, and one card run twice;
- the same band through the installed `woof-nam run --cards 2` with the 32 GB fit on both cards (GFS start,
  digital filter + 1 h): 2 cards vs 1 card from the same saved init, 2 hours x 26 variables.

Check your own pair with `woof-nam compare <run a> <run b>` (exit 0 when every value is identical).

**Speed and memory, 12 km CONUS (954 x 835 x 60), 6 h, every physics scheme on.** Several cards: 32 GB
cards, no peer-to-peer link, NCCL 2.28 over host shared memory. ms/step is the whole-run average per card from the
receipt; the wall includes loading the saved init.

| Cards | Rows per card (owned + halo) | ms/step | Wall for 6 h (864 steps) | Memory per card |
|---|---|---|---|---|
| 1 (96 GB card) | 835 | 186-193 | about 165 s (24 h: 643 s) | 58-76 GB (pool about 58 GB) |
| 2 | 418 + 3, 417 + 3 | 174, 175 | 469 s (258 s of it loading the init on a busy host) | 26.9, 31.1 GiB |
| 4 | 209 + 3 to 6 | 89-102 | 123-151 s | 24.1-29.9 GiB |
| 8 | 105 + 3 to 6 | 53-55 | 92 s | 19.2-20.2 GiB |

So the full 12 km grid runs on one 32 GB card (the fit, 339 ms per step), on one 96 GB card (178 ms per step),
or faster on several cards.

**Other grids.** A grid is a row of `namgpu/parm/domains.json` and a configfile in `namgpu/parm/`; `woof-nam run
--domain NAME` (also `init`) selects it. `conus12` is the NAM 12 km parent (the default). `conus4` is 1371 x 1101 x 60
over NAM's CONUS-nest footprint, GFS start only: its static surface is built on the GPU from the WPS_GEOG land sets
(`NAMGPU_GEOG`, else `~/WPS_GEOG`) on the first run and again when the start month changes, and with `--cards N` its
initial state is built in CUDA managed memory. The 4 km grid ran 24 h on 8 cards of 32 GB (42.9 ms per step, 522 s
wall, 25-26 GB per card; from a checkout through `tools/run_nam_domain.sh`, which takes the same configfile).

Needs: one machine with N NVIDIA cards and the NCCL 2 library (`libnccl.so.2`) where CuPy can load it; about
14 GB of disk for the saved 12 km init; room in `/dev/shm` for one or two hours of history in flight.

## NOAA's NAM nests and the whole suite

NOAA's NAM ran five nests beside its 12 km run: CONUS, Alaska, Hawaii and Puerto Rico at 3 km to 60 h, and a 1.5 km
fire-weather nest to 36 h. Each is a row of `namgpu/nest/ncep_nests.py` with NCEP's own grid, step and keys, and the
whole suite is the table `namgpu/parm/nam_suite.json`:

```
woof-nam nest --ncep-nest hawaiinest --source gfs --start 2026110306 --out runs/hawaii --products   # one nest
woof-nam suite --cycle 2026110306 --out runs/suite-2026110306                                       # parent + all five
```

Each nest writes NOAA's nest files (`woof-nam.tHHz.<nest>.hiresfFF.tm00.grib2`) on NOAA's grid for it.
On the 4-card CONUS check (woof-nam 0.2.0, 4 cards of 96 GB, `woof-nam suite --cycle 2026012312 --domains
12km,conusnest --hours-cap 6`) each CONUS GRIB2 file was public 65-80 s after its history hour was written, and
writing products beside the run cost the four CONUS ranks about 14 % (9.4-9.7 s per forecast hour) from hour 3 on.
[docs/nests/RUNNING.md](docs/nests/RUNNING.md) covers every nest, the fire-weather point, card layouts and the output
folders; [docs/nests/COMPATIBILITY.md](docs/nests/COMPATIBILITY.md) compares the files with NOAA's record by record.

## 3 km nests anywhere

`woof-nam nest` runs a NAM-physics domain anywhere on Earth. One command builds the static fields for the
new grid, fetches the start and the boundaries, runs the forecast and draws the maps and comparison sheets:

```
woof-nam nest --center 35.7N,139.7E --size-km 1000 --res-km 3 --source gfs \
    --start 2026110218 --hours 48 --out runs/japan-3km
```

- `--center LAT,LON` with N/S/E/W or signed degrees; `--size-km` (and `--size-y-km` for a rectangle);
  `--res-km` 3, 4, 5 or 12. The 3 km row takes the NAM CONUS-nest step and physics keys (dt 6.25 s, radiation
  every 192 steps, no parameterised convection).
- `--source auto | gfs | ifs | ifs-0p25 | era5 | parent`. `auto` takes IFS 0.1 degree where it is published and GFS
  before; `era5` starts from the ERA5 reanalysis (from 1940 to about 6 days ago), as `woof-nam run --source era5`. `parent --parent-run DIR` is a one-way nest inside a WOOF-NAM 12 km run that wrote its hand-off set.
- Before it starts, the door checks the free memory on the card and refuses if the domain does not fit. It
  also refuses if no renderer is found. It writes `nest-receipt.json` with every stage's wall time, cores and
  VRAM. From a checkout, `tools/woof-nam nest ...` runs the same command.

Three whole 48 h runs, each 286 x 334 x 60 points at 3 km (1,000 km square), on one 32 GB card:

| case | start and boundaries | ms/step | forecast 48 h | VRAM (pool) | door, start to sheets |
|---|---|---|---|---|---|
| Missouri/Illinois squall line, 2025-03-14 12Z | WOOF-NAM 12 km parent (one-way) | 14.2 | 6.5 min | 26.8 GiB | 8.2 min |
| Japan, 2026-11-02 18Z | GFS 0.25 | 14.1 | 6.5 min | 22.7 GiB | 22.9 min |
| Southern Germany and the Alps, 2026-11-02 12Z | ECMWF IFS 0.1 | 13.8 | 6.4 min | 21.8 GiB | 21.1 min |

Most of the door time beyond the forecast goes on the download (GFS 7 min) and on drawing the referee
sheets. All three runs stayed finite to +48 h.

![Composite reflectivity, MRMS | WOOF-NAM 3 km nest | WOOF-NAM 12 km parent, +6 to +24 h](docs/nests/conus-parent-refc-f06-f24.png)

*Squall line, 2025-03-14 12Z (columns: MRMS, the 3 km nest, the 12 km parent; rows: +6, +12, +18, +24 h). The
nest draws the overnight line as one continuous band on about the axis MRMS has. The parent has a chain of
separate cells there. FSS at >= 40 dBZ (40 km window) is 0.24 for the nest and 0.15 for the parent at +18 h.
Two nest defects are visible from +12 h: echo along the boundary rows, and banded echo ahead of the line.*

![2 m temperature, WOOF-NAM 3 km Japan, +6, +12, +24 and +48 h](docs/nests/japan-gfs-t2m-f06-f48.png)

*Japan from GFS, 2026-11-02 18Z. The nest resolves valley, terrain and coastal structure that GFS 0.25 does
not have. Against 17-28 Japanese METARs, its 2 m temperature RMSE is 1.57, 1.93 and 1.82 C at +6, +12 and
+24 h (GFS: 1.42, 2.28, 2.50) and 1.40 C at +48 h (GFS 0.97). Its 2 m dewpoint over interior Honshu is too dry
(-1.35 C at +48 h).*

![ECMWF IFS 0.25 analysis | WOOF-NAM 3 km | ECMWF IFS 0.25 forecast, 2 m T, 2 m dewpoint, 10 m wind, MSLP and 6 h precipitation](docs/nests/europe-ifs-sheets-f12-f48.png)

*Southern Germany and the Alps from IFS 0.1, 2026-11-02 12Z (columns: the IFS analysis, the 3 km nest, the
IFS forecast). Against 139-147 METARs, the nest's 10 m wind matches IFS (lower RMSE at 9 of 12 leads). Its
2 m temperature is worse than IFS at every lead from +6 h: the gap is 0.1-0.3 C by day and largest at night.
Its 2 m dewpoint is drier than IFS, and it produces light rain and drizzle at about one fifth of the observed
frequency.*

### Live-parent and two-way nests

`woof-nam nest --concurrent` (or `--two-way`) runs a 12 km parent and the nest together, in one process on one card. The nest sits on
the parent's own grid and takes its lateral boundaries from the live parent at every parent step (25 s). Each parent
step with `--two-way`, box means of the nest's temperature, moisture, condensate and winds replace the parent's values over the
overlap, so the parent carries the nest's storms. This is NMMB's own parent-child coupling and two-way feedback;
`--2way-wgt` sets the nest's weight in the overlap (default 1.0). Nests run one-way by default, as NOAA's NAM did:
giving `--parent-center`, `--parent-size-km` or `--parent-size-y-km` without `--two-way` runs the live parent with
the feedback off, the same as `--concurrent`. `--two-way` enables feedback; two-way made Ian 27 hPa deeper than
observed in our test. The parent's and nest's history land in `<out>/parent/` and `<out>/nest/`.

```
woof-nam nest --two-way --center 24N,83W --size-km 1900 --size-y-km 1400 --res-km 3     --parent-size-km 3000 --parent-size-y-km 2600 --source gfs --start 2022092612 --hours 84 --out runs/ian-2way
```

The one-way hand-off is still there: `--source parent --parent-run DIR` runs a nest from a finished WOOF-NAM 12 km
run's hand-off history, and `woof-nam nest` with no parent options runs the nest alone from the source's boundaries.

On Hurricane Ian (GFS 2022-09-26 12Z, 84 h, one 96 GB card), the feedback brought the 12 km parent down to 919.6 hPa
at +48 h, within 1-9 hPa of the nest at every hour; without it the parent stayed at 974.0. The two-way nest was
910.5 hPa at +48 h against 931.6 with the feedback off and 937 in the best track, with a wider core and a track
further west; its deepest, 908.8 hPa, was 27 hPa below the observed 937 (one-way: 923.7). No seam shows at the
nest edge.

### Moving nests

`woof-nam nest --follow TRACKER` runs a nest that follows a storm. It runs one-way from its boundary source: a
finished WOOF-NAM 12 km run (`--source parent --parent-run DIR`) or GFS / IFS.

```
woof-nam nest --follow tc --storm-id 2024225N22135 --size-km 1000 --res-km 3 --source gfs \
    --start 2024081512 --hours 48 --out runs/ampil-follow
```

- `--follow tc | low | object:refl | object:uh | path`. `tc` follows a tropical cyclone's pressure minimum and
  `low` an extratropical low. `object:refl` and `object:uh` follow a reflectivity or updraft-helicity object.
  `path` follows a track you give in `--follow-config`.
- Give the start position with `--storm LAT,LON` or `--storm-id SID`, an IBTrACS v04r01 storm id; the door then
  reads that storm's best-track point at `--start`. `--center` is optional here and overrides the start centre.
- `--check-minutes` sets how often the tracker reads a finished hourly frame (default 60). `--follow-config`
  (inline JSON or a file) overrides the tracker's settings, e.g. `{"core_margin_km": 300}`.
- How a move works:
  - The tracker fixes the feature on every hourly frame.
  - When the feature nears the edge, the controller plans a move. A move lands on a boundary time of the source:
    every 3 h for GFS and IFS, every hour for a parent run.
  - While the forecast runs, up to 2 background workers (`NAMGPU_FOLLOW_PREP_MAX`) build the next window: its
    static fields, start and boundaries.
  - The new window is the old one shifted by whole grid cells. Where the two overlap, the nest keeps its own
    state. The new strip starts from the source, filtered by the same digital filter a fresh start gets.
- The receipt's `follow` block records every fix, every move, and the first 6 steps after each move. Maps and
  sheets follow the window. `tools/follow_lead_sheets.py` draws a lead's maps beside the move history up to it, and
  `tools/follow_score.py` scores a run against IBTrACS.
- The `tc` tracker keeps the storm at least max(150 km, 0.62 x the window's half-width) from the edge, which is about
  300 km on a 1000 km nest. That keeps the rain shield inside the window, not only the eye.
- A live parent (`--two-way`, `--concurrent`, `--parent-*`) does not move its nest, and `--follow` is
  refused there.
- Memory: the forecast and a background worker share the card, so a 1000 km moving nest at 3 km peaked at
  45-57 GiB on a 96 GB card.

48 h runs from GFS 0.25, 1000 km at 3 km on one 96 GB card, scored every 6 h (f06-f48) against IBTrACS
best track. "Static" is the same nest without `--follow`:

| storm, start | run | mean track error | mean central-pressure error | track error f24 / f36 / f48 | leads with the storm at the edge |
|---|---|---|---|---|---|
| Typhoon Ampil, 2024-08-15 12Z | moving, `tc` | **62.0 km** | **8.5 hPa** | 56 / 91 / 110 km | none |
| | static, centred on the storm at the start | 95.4 km | 23.5 hPa | 56 / 117 / 258 km | +30 to +48 h |
| | static, centred at 35.7N 139.7E | 68.8 km | 12.5 hPa | 46 / 74 / 228 km | +48 h |
| Cyclone Gabrielle, 2023-02-13 00Z | moving, `low` | 69.8 km | 1.9 hPa | 98 / 24 / 198 km | none |
| | static, centred on the storm at the start | 68.5 km | 1.9 hPa | 90 / 16 / 285 km | +42 to +48 h |
| | static, centred at 37.5S 175.5E | 81.9 km | 1.6 hPa | 84 / 33 / 280 km | +36 to +48 h |

The moving nest held both storms at every lead. The static nests lost them between +30 and +48 h, and lost
their intensity with them. While a static nest still holds the storm, its track error is close to the moving
nest's. After +36 h, the model's Gabrielle turns south where the best track goes east-south-east; the window
followed the model's low. Each 48 h forecast took 18-20 min on the card, including its moves.

On the first step after a move, the window-mean surface-pressure tendency is 5-9x what it was before the move.
It is back to 1.1-1.7x within the hour. Vertical motion along the old edge and in the new strip stays at its
level before the move, and no waves spread inward from the old edge.

![Typhoon Ampil, WOOF-NAM 3 km moving nest at +48 h: composite reflectivity, MSLP, every window with the best track, track and pressure error](docs/nests/ampil-follow-f48.png)

*Typhoon Ampil from GFS, 2024-08-15 12Z, +48 h. The window moved four times (+6, +18, +30 and +42 h). At +48 h
the storm and its rain shield are near the centre of the window.*

![Ampil track and central pressure: best track, two moving nests and two static nests](docs/nests/ampil-follow-vs-static-track.png)

*Ampil track and central pressure every 6 h. The static nest centred on the storm at the start loses it at
+30 h; from then on its pressure minimum is on the window edge (1004 hPa at +48 h). The static nest centred near
Tokyo holds it until +42 h. Both moving runs keep the storm to +48 h; their central pressure is 18-19 hPa too deep
at +18 h and 4-6 hPa too deep at +48 h. In the legend, "moving follow/all" is the default margin and "F1" is a
150 km margin.*

### Data sources for nests

Static fields come from the WPS_GEOG datasets `gpuwm fetch-geog` installs, read by
`namgpu/init/static_build.py`. Start, boundary and referee data are fetched from the open archives below.
Each row's licence is also written next to its table in the code (`static_build.DATASETS`,
`fetch_case.FETCH_ROWS`, `sources.SOURCES`, `referee_rows`). No NC-licensed data is read.

| use | dataset | source and licence |
|---|---|---|
| terrain | GMTED2010 30 arc-second | USGS/NGA (Danielson & Gesch 2011); U.S. public domain |
| land use | MODIS 20-category IGBP + lakes | NASA MODIS (MCD12Q1-derived); NASA open data |
| soil texture | SoilGrids250m texture classes | ISRIC (Hengl et al. 2017); CC BY 4.0, attribution in the static receipt |
| green fraction, albedo, max snow albedo | MODIS climatologies | NASA MODIS; Barlage et al. 2005 (max snow albedo) |
| deep-soil temperature | ERA5 1990-2019 climatology (WeatherBench 2) | Copernicus licence: free, commercial use allowed, attribution required |
| start and boundaries | GFS 0.25 degree | NOAA/NCEP, U.S. public domain (AWS NODD) |
| start and boundaries | ECMWF open data IFS 0.1 / 0.25 degree | ECMWF, CC BY 4.0 (credited on every map) |
| start and boundaries (`--source era5`) | ERA5 reanalysis 0.25 degree, from Google's public ARCO-ERA5 copy | Copernicus C3S, CC BY 4.0 (credited on every map) |
| snow, sea ice where IFS lacks them | GFS 0.25 degree f000, same cycle | NOAA/NCEP, U.S. public domain |
| parent start and boundaries | your own WOOF-NAM 12 km history | the parent's own start-source credit is carried onto the maps |
| truth (referee panels) | MRMS reflectivity and QPE; GPM IMERG | NOAA, U.S. public domain; NASA/JAXA open data |

## Layout

```
namgpu/            the package: config, grid, state, kernels/ (one .cu per unit), dynamics/,
                   boundary/, physics/, init/, io/, steps/, driver.py, cli.py (the woof-nam command)
namgpu/parm/       NAM parm files (NOAA, unmodified)
namgpu/data/       tables; fix/ NOAA radiation, CO2 and ozone fix files; fix/noah/ NCEP's NMMB Noah tables
namgpu/third_party/arwen/  ArWen (gpuwm) files reused, Apache-2.0
namgpu/UNITS.json  every port unit and its status
tools/             extract and check tools (development); fetch_fix.sh refreshes namgpu/data/fix
tests/             smoke_full.py (whole forecast), unit tests
cases/<case>/      CASE.md and the referee recipe; inputs are fetched, never committed
static/            nam12_static.npz for GFS starts, built once by woof-nam static (not committed)
CONTRACT.md        array layout, step order, kernel convention, done rule
```

## Known gaps

- **NOAA's nests:** the five NAM nests run as NCEP's rows (`woof-nam nest --ncep-nest`, and `woof-nam suite`
  for a whole cycle; [docs/nests/RUNNING.md](docs/nests/RUNNING.md)). Each nest takes its start and boundaries from
  the 12 km run's hourly history, not from NCEP's in-executable coupling, and the fire-weather nest from the 12 km run
  rather than from the 3 km nest. In the nest files, flight-level records carry values below the ground where NOAA's
  are missing, and cloud ice is not written (71 records in all, docs/nests/COMPATIBILITY.md).
- **Moving nests:** for the first 1-3 h after a move, the new strip holds the source's smooth rain, with a
  visible join along the old edge. The strip starts from GFS or IFS, not from the model's own state.
- **Multi-card:** one machine only (no multi-node runs). The 5 km and band configfiles are not rows of
  `domains.json` (not measured as a whole run); they run from a checkout through `tools/run_nam_domain.sh`.
- **Memory fit on several cards:** measured on the 954 x 279 band (2 cards, same bits as 1 card). The full
  12 km grid on several cards is measured on the full memory path only.
- **Restarts:** one card ("Restarts" above); the NAM's own restart files are not read.
- **GRIB2 products:** 3 of NOAA's 454 awphys records and 71 of NOAA's 876 conusnest (871 other nests) records are
  not produced ("GRIB2 products" and "Nest GRIB2 products" above). The prebuilt
  writer is for Linux x86-64; elsewhere, build `rw_rrfs_upp` from gpuwm and set `WOOF_NAM_RW_RRFS_UPP`.

## Licence

Apache-2.0 (LICENSE). The RRTMG radiation files derived from AER's code carry AER's BSD-3-Clause
notice, and the reused ArWen files are Apache-2.0. NOTICE lists every third-party origin and its
terms. `woof-nam licence-check` checks the per-file notices (in an install or a checkout).
