Skip to content

feat(params): support real(stp) declarations in Fortran codegen#1458

Open
sbryngelson wants to merge 7 commits into
MFlowCode:masterfrom
sbryngelson:param-storage-precision
Open

feat(params): support real(stp) declarations in Fortran codegen#1458
sbryngelson wants to merge 7 commits into
MFlowCode:masterfrom
sbryngelson:param-storage-precision

Conversation

@sbryngelson
Copy link
Copy Markdown
Member

@sbryngelson sbryngelson commented May 29, 2026

Summary

Two small follow-ups on top of #1456 (auto-generated Fortran namelists/decls).

1. real(stp) support in the parameter codegen

After #1456, every REAL parameter the generator emits is hardcoded to real(wp) (fortran_gen.py's _FORTRAN_TYPES). That's correct for the current parameter set — every generated scalar/array is computation-side wp, and true storage-precision (stp) field data is a derived type / allocatable that the generator deliberately excludes. But there was no way to make the generator emit real(stp) if a future scalar or FORTRAN_ARRAY_DIMS array genuinely needed it — it would silently get wp.

This adds an explicit, declarable escape hatch:

  • ParamDef.storage_precision: bool = False
  • fortran_type_decl honors it for REAL/ANALYTIC_REALreal(stp) (covers both scalar and array paths)
  • _r(..., storage_precision=True) threads it through

Behavior-preserving for the current parameter set: generated output is byte-identical (all reals remain real(wp), no stp leaks). Verified via the full params_tests suite (126 passed) plus a new test_fortran_type_real_storage_precision.

Known limitation (inherent): a REAL param still defaults to wp; this can't detect unstated intent. The only alternative — a hardcoded must-be-stp name list — is circular. So defaulting to wp with an explicit opt-in is the right floor.

2. Agent-guidance docs: correctness + slimming

CLAUDE.md and .claude/rules/* are all auto-loaded into agent context every turn, so accuracy and non-duplication matter. This pass:

  • Fixes a wrong formula: buff_size was documented as 2*weno_polyn + 2 (only the viscous-WENO case); corrected to the real per-scheme set (WENO/MUSCL/IGR + Lagrange/IB floors) with a pointer to s_configure_coordinate_bounds.
  • Fixes misdirection: runtime-validation guidance pointed at m_checker.fpp files whose s_check_inputs are empty for pre/post; rewrote it to say where a check actually runs (shared → m_checker_common.fpp, sim-only → simulation/m_checker.fpp, pre/post-only → their files).
  • Slims + dedupes: trims reference enumerations (Commands cheat-sheet, GPU-macro list, #ifdef tail) to essentials + source-of-truth pointers; collapses the duplicated wp/stp definition to one home; adds a Working Style section pointing at the karpathy-guidelines skill; fixes the stale "6 checks" → "7 checks" count. No enforceable rule or domain fact removed.

Test plan

  • ./mfc.sh format -j 8 (no changes)
  • params_tests: 126 passed (incl. new stp test)
  • Generated decls confirmed byte-identical for existing params
  • doc claims verified against source (buff_size, empty pre/post checkers)
  • pre-commit precheck hook passed on every commit
  • Full ./mfc.sh precheck -j 8 / CI

@sbryngelson sbryngelson marked this pull request as ready for review May 29, 2026 19:40
@qodo-code-review
Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant