Skip to content

Commit 041cfa6

Browse files
sbryngelsonclaude
andcommitted
Fix parameter checklist and validation attribution
- Expand 3-location to 4-location checklist: add m_global_parameters.fpp as required step for declaring Fortran variables (without this, adding a parameter to the namelist in m_start_up.fpp causes a compile error) - Fix fastjsonschema attribution: JSON schema validation is in case.py and params/registry.py, not in case_validator.py which does physics constraint checking Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7895c6f commit 041cfa6

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

.claude/rules/parameter-system.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ MFC has ~3,300 simulation parameters defined in Python and read by Fortran via n
99
- Parameters are indexed families: `patch_icpp(i)%attr`, `fluid_pp(i)%attr`, etc.
1010
- Each has type, default, constraints, and tags
1111

12-
2. **Validation**: `toolchain/mfc/case_validator.py`
13-
- JSON schema validation via fastjsonschema
14-
- Physics constraint checking (e.g., volume fractions sum to 1)
15-
- Dependency validation (required/recommended params)
12+
2. **Validation** (two layers):
13+
- `toolchain/mfc/case.py` / `toolchain/mfc/params/registry.py` — JSON schema validation
14+
via fastjsonschema (type checking, defaults)
15+
- `toolchain/mfc/case_validator.py` — Physics constraint checking
16+
(e.g., volume fractions sum to 1, dependency validation)
1617

1718
3. **Input Generation**: `toolchain/mfc/run/input.py`
1819
- Python case dict → Fortran namelist `.inp` file
@@ -24,13 +25,15 @@ MFC has ~3,300 simulation parameters defined in Python and read by Fortran via n
2425

2526
## Adding a New Parameter (3-location checklist)
2627

27-
YOU MUST update all 3 locations. Missing any causes silent failures.
28+
YOU MUST update all 4 locations. Missing any causes silent failures or compile errors.
2829

2930
1. **`toolchain/mfc/params/definitions.py`**: Add parameter with type, default, constraints
30-
2. **`src/*/m_start_up.fpp`**: Add to the Fortran `namelist` declaration in the relevant
31+
2. **`src/*/m_global_parameters.fpp`**: Declare the Fortran variable in the relevant
3132
target(s). If the param is used by simulation only, add it there. If shared, add to
32-
all three targets' m_start_up.fpp.
33-
3. **`toolchain/mfc/case_validator.py`**: Add validation rules if the parameter has
33+
all three targets' m_global_parameters.fpp.
34+
3. **`src/*/m_start_up.fpp`**: Add to the Fortran `namelist` declaration in the relevant
35+
target(s).
36+
4. **`toolchain/mfc/case_validator.py`**: Add validation rules if the parameter has
3437
physics constraints. Include `PHYSICS_DOCS` entry with title, category, explanation.
3538

3639
## Case Files

CLAUDE.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,11 @@ NEVER use `stop` or `error stop`. Use `call s_mpi_abort()`.
136136
NEVER use `goto`, `COMMON` blocks, or global `save` variables.
137137

138138
Every `@:ALLOCATE(...)` MUST have a matching `@:DEALLOCATE(...)`.
139-
Every new parameter MUST be added in 3 places:
139+
Every new parameter MUST be added in 4 places:
140140
1. `toolchain/mfc/params/definitions.py` (parameter definition)
141-
2. Fortran namelist in `src/*/m_start_up.fpp` (namelist binding)
142-
3. `toolchain/mfc/case_validator.py` (if constraints exist)
141+
2. Fortran variable declaration in `src/*/m_global_parameters.fpp`
142+
3. Fortran namelist in `src/*/m_start_up.fpp` (namelist binding)
143+
4. `toolchain/mfc/case_validator.py` (if constraints exist)
143144

144145
Changes to `src/common/` affect ALL three executables. Test comprehensively.
145146

0 commit comments

Comments
 (0)