Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d0eb0f1
Added some of Ted's p3 testing changes/runtime switches. Added runtim…
dawson29 Jul 15, 2026
2a72240
Added new runtime options for p3 for cat_init_new to choose ice categ…
dawson29 Jul 17, 2026
6260c19
Added some notes from recent Claude cowork session. Lots of minor mod…
dawson29 Jul 19, 2026
cbe54f8
Add category-swap divergence diagnostics; document investigation outcome
dawson29 Jul 19, 2026
ba78be7
Add seed-isolation switches p3_clipdp/p3_epsdp/p3_limdp; record onset…
dawson29 Jul 20, 2026
fa35224
Add p3_nucdp switch; document combined-run protocol after single-swit…
dawson29 Jul 20, 2026
4441c73
Add p3_nanpoison stale-state hunt after combined-run null excludes al…
dawson29 Jul 20, 2026
ee440ae
Guard 0/0 in diag_effi_ave at ice-free points (found by p3_nanpoison …
dawson29 Jul 20, 2026
7bf1600
Split non-short-circuiting conditional: 0/0 qiliq/qitot at empty cate…
dawson29 Jul 20, 2026
32f7eb6
Fix stale f1pr16 in iice_loop2: the category-swap divergence seed
dawson29 Jul 20, 2026
31fafbd
Record clean p3_nanpoison rerun: stale f1pr16 was the only trap
dawson29 Jul 20, 2026
a9e23ea
Close the category-swap investigation; spec the tendency-application …
dawson29 Jul 20, 2026
ad03ca7
Restore production MPI build configuration after the trap-hunt debug …
dawson29 Jul 20, 2026
11300ba
Achieve P3 category-swap bit-identity; remove diagnostic switches
dawson29 Jul 21, 2026
137e439
Updated Makefile for Bell
dawson29 Jul 21, 2026
84b472e
Turned log_maxnsmall back to true by default
dawson29 Jul 22, 2026
b7dcda3
Updated to manually merge in changes from NSSL3M_Feb_2025 branch
dawson29 Jul 23, 2026
861737d
Added new per-category max Ni limiter for P3 from later versions.
dawson29 Jul 25, 2026
cd0ecce
Added switch to turn of Ni limiter by setting max_Ni parameter to -1 …
dawson29 Jul 25, 2026
990adc9
Add P3 ptypes 64-67: 5- and 6-ice-category configurations
dawson29 Jul 27, 2026
aff3413
Add CLAUDE.md and ignore machine-specific Claude Code settings
dawson29 Jul 27, 2026
b9ba789
Bring NOTES.md current: ptypes 64-67, post-07-20 tree changes, deferr…
dawson29 Jul 27, 2026
d7fc86d
Correct the subroutine name in the NSSL3M merge notes
dawson29 Jul 27, 2026
48092ba
Add small-value gating switches and limiter instrumentation for P3
dawson29 Aug 2, 2026
0124dd1
Updated small value gating and added H-M rime splintering namelist sw…
dawson29 Aug 5, 2026
e395055
Merge branch 'master' into P3_work
dawson29 Aug 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ qr_acr*dat
# CM1 processes the .F files into .f90 during the build process so we should ignore
# these too
*.f90

# Claude Code machine-specific settings (netCDF/HDF5 paths differ per machine)
.claude/settings.local.json
90 changes: 90 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# CM1 r21.0 — P3 microphysics working copy

CM1 (Bryan cloud model) with heavy local modifications to the P3 (Predicted
Particle Properties) microphysics scheme. Working branch `P3_work`; main branch
is `master`. Several sibling worktrees of the same repo exist under
`~/Projects/cm1r21.0*` — check `git worktree list` before assuming a path.

## Building

```bash
cd src && make
```

Links the executable to `run/cm1.exe`.

- `src/Makefile` is the **active** build config — a copy of one of the
`Makefile_<machine>` variants with the hardware section uncommented. Current
settings: `mpif90` (gfortran), `-ffree-form -ffree-line-length-none -O2
-finline-functions`, `-DMPI`. Variants in the tree: `Makefile_laptop_mpi`,
`Makefile_laptop_single`, `Makefile_bell`, `Makefile_derecho`.
- The laptop Makefiles need `NETCDFC_DIR`, `NETCDF4_DIR` and `HDF5_DIR` in the
environment. These are Homebrew prefixes on this machine and are supplied to
Claude Code via `.claude/settings.local.json` (gitignored, machine-specific).
Without them the netCDF-using files fail with `Cannot open module file
'netcdf.mod'`. `Makefile_bell` uses different variable names
(`NETCDF_FORTRAN_HOME` etc.); `Makefile_derecho` uses `NETCDF`.
- Debug builds (used for FP-trap hunts) swap `OPTS` for
`-O0 -g -ffpe-trap=invalid -fcheck=bounds` and require a full rebuild.

### Generated files — never edit these

- `src/*.f90` — cpp output from the corresponding `.F`. Edit only the `.F`.
- `run/onefile.F` — a concatenation of all sources, regenerated by every `make`.
Gitignored. Grep hits here are duplicates of `src/`; ignore them.

## P3 configurations (`ptype` in `&param2`)

All are 2-moment cloud water and rain. Ice-category count, moment count and
liquid-fraction prediction are baked into the ptype:

| ptype | ice cats | ice moments | liqFrac |
|-------|----------|-------------|---------|
| 50–53 | 1–2 | 1–3 mom | no |
| 54, 56, 57 | 2, 3, 4 | 3-mom | no |
| 60–63 | 1, 2, 3, 4 | 3-mom | yes |
| 64, 65 | 5, 6 | 3-mom | no |
| 66, 67 | 5, 6 | 3-mom | yes |

Adding or changing a P3 configuration touches, at minimum: `src/param.F`
(ptype range tests, `param_mp` name, the `p3_init` dispatch, and the
`numq`/`qname`/`qunit`/`qmag`/`cloudvar`/`np3a`/`np3o` block), `src/mp_driver.F`
(the per-ptype `p3a` pack/unpack and `mp_p3_wrapper_wrf` call),
`src/writeout.F` (per-category diagnostic output), and
`src/radiation_driver.F` (effective-radius ptype list).

Scheme options live in the `&p3_params` namelist group (declared and broadcast
in `param.F`, applied in `p3_init`). With `p3_cat_init_new = .true.` the
destination category for each of the six ice-initiation mechanisms is set by
`p3_catdest_<mechanism>_n<N>`, where `N` is the number of ice categories in the
active configuration — so ptype 57 reads the `_n4` values, 64/66 the `_n5`
values, and 65/67 the `_n6` values.

## Running

`run/` needs the P3 lookup tables (`p3_lookupTable_1.dat-v6.7-{2,3}momI`,
`p3_lookupTable_2.dat-v6.1`) alongside `cm1.exe` and `namelist.input`.
`run/namelist.input` is a default/reference copy — it does **not** track the
configuration of any particular production run.

Note that older executables will refuse a namelist containing `&p3_params`
keys they were not compiled with (`Cannot match namelist object name ...`), so
A/B runs against an older binary need the newer keys stripped.

## Category-swap / bit-reproducibility investigation

`NOTES.md` and `p3_category_swap_audit.md` are the running record of a long
investigation into why permuting P3 ice-category destination assignments broke
bit-identity. Read `NOTES.md` before touching category reductions or the
tendency-application code — several fixes there are load-bearing. In-tree
tooling kept from that work:

- `p3_chksum` / `p3_chkpts` in `&p3_params` — per-timestep field checksums and
per-point raw dumps, written PRE and POST each `p3_main` call.
- `compare_p3_chksum.py` and `decode_point.sh` in the repo root.
- `qsum_invariant` in `&p3_params` — permutation-invariant host-side moisture
sums; needed for swap/invariance runs, default off.

The general fix pattern for a category-order dependence is: replace a
fixed-slot-order category sum with a double-precision accumulate-then-round, or
a value-sorted `sortsumq` on the host side.
Loading