Skip to content

Commit 8e0a394

Browse files
committed
docs: update parameter-addition rule from 4-location to 2-location
Fortran decls and namelist bindings are now auto-generated. Simple scalar params only need definitions.py (_r + _nv) + cmake reconfigure.
1 parent 0fada8f commit 8e0a394

3 files changed

Lines changed: 19 additions & 16 deletions

File tree

.claude/rules/common-pitfalls.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Before submitting a PR:
5959
- [ ] `./mfc.sh precheck -j 8` (5 CI lint checks)
6060
- [ ] `./mfc.sh build -j 8` (compiles)
6161
- [ ] `./mfc.sh test --only <relevant> -j 8` (tests pass)
62-
- [ ] If adding parameters: all 4 locations updated
62+
- [ ] If adding parameters: definitions.py (_r + _nv) updated; cmake reconfigured; case_validator.py if constraints
6363
- [ ] If modifying `src/common/`: all three targets tested
6464
- [ ] If changing output: golden files regenerated for affected tests
6565
- [ ] One logical change per commit

.claude/rules/parameter-system.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,22 @@ MFC has ~3,400 simulation parameters defined in Python and read by Fortran via n
2323
- Reads `&user_inputs` namelist
2424
- Each parameter must be declared in the namelist statement
2525

26-
## Adding a New Parameter (4-location checklist)
26+
## Adding a New Parameter (2-location checklist)
2727

28-
YOU MUST update the first 3 locations. Missing any causes silent failures or compile errors.
29-
Location 4 is required only if the parameter has physics constraints.
28+
Fortran declarations and namelist bindings are now auto-generated from definitions.py
29+
at CMake configure time — no manual Fortran edits needed for simple scalar parameters.
3030

31-
1. **`toolchain/mfc/params/definitions.py`**: Add parameter with type, default, constraints
32-
2. **`src/*/m_global_parameters.fpp`**: Declare the Fortran variable in the relevant
33-
target(s). If the param is used by simulation only, add it there. If shared, add to
34-
all three targets' m_global_parameters.fpp.
35-
3. **`src/*/m_start_up.fpp`**: Add to the Fortran `namelist` declaration in the relevant
36-
target(s).
37-
4. **`toolchain/mfc/case_validator.py`**: Add validation rules if the parameter has
31+
1. **`toolchain/mfc/params/definitions.py`**: Add parameter with `_r()` (type, default,
32+
constraints) AND add it to `NAMELIST_VARS` via `_nv()` for the relevant target(s).
33+
After editing, re-run cmake (or `./mfc.sh build`) to regenerate the Fortran includes.
34+
2. **`toolchain/mfc/case_validator.py`**: Add validation rules if the parameter has
3835
physics constraints. Include `PHYSICS_DOCS` entry with title, category, explanation.
3936

37+
**Exceptions — still require manual Fortran edits:**
38+
- Array variables (e.g. `logical, dimension(num_fluids_max)`) → declare in `src/*/m_global_parameters.fpp`
39+
- Derived-type members (`fluid_pp%attr`, `patch_icpp(i)%attr`) → declare in the relevant derived type
40+
- Case-optimization parameters → add to `CASE_OPT_PARAMS` and the `#:else` block in `src/simulation/m_global_parameters.fpp`
41+
4042
## Case Files
4143
- Case files are Python scripts (`.py`) that define a dict of parameters
4244
- Validated with `./mfc.sh validate case.py`

CLAUDE.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,12 @@ NEVER use `stop` or `error stop`. Use `call s_mpi_abort()` or `@:PROHIBIT()`/`@:
139139
NEVER use `goto`, `COMMON` blocks, or global `save` variables.
140140

141141
Every `@:ALLOCATE(...)` MUST have a matching `@:DEALLOCATE(...)`.
142-
Every new parameter MUST be added in at least 3 places (4 if it has constraints):
143-
1. `toolchain/mfc/params/definitions.py` (parameter definition)
144-
2. Fortran variable declaration in `src/*/m_global_parameters.fpp`
145-
3. Fortran namelist in `src/*/m_start_up.fpp` (namelist binding)
146-
4. `toolchain/mfc/case_validator.py` (only if parameter has physics constraints)
142+
Every new parameter MUST be added in at least 2 places (3 if it has constraints):
143+
1. `toolchain/mfc/params/definitions.py` (parameter definition + NAMELIST_VARS target set)
144+
2. `toolchain/mfc/case_validator.py` (only if parameter has physics constraints)
145+
Note: Fortran declarations and namelist bindings are auto-generated from definitions.py
146+
at CMake configure time. Simple scalars need no manual Fortran edits. Array/derived-type
147+
variables still require a manual declaration in `src/*/m_global_parameters.fpp`.
147148

148149
Changes to `src/common/` affect ALL three executables. Test comprehensively.
149150

0 commit comments

Comments
 (0)