@@ -6,6 +6,13 @@ toolchain for building/running/testing, and supports GPU acceleration via OpenAC
66OpenMP target offload. It must compile with gfortran, nvfortran, Cray ftn, and Intel ifx (CI-gated).
77AMD flang is additionally supported for OpenMP target offload GPU builds.
88
9+ ## Working Style
10+
11+ Make surgical changes: every changed line should trace to the request. Don't refactor,
12+ reformat, or "improve" adjacent code — in a four-compiler, golden-file-gated codebase,
13+ incidental edits are how regressions slip in. For general behavioral guidance (simplicity,
14+ surfacing assumptions, verifiable success criteria), invoke the ` karpathy-guidelines ` skill.
15+
916## Commands
1017
1118Prefer using ` ./mfc.sh ` as the entry point for building, running, testing, formatting,
@@ -15,81 +22,41 @@ compilers directly unless you have a specific reason.
1522
1623All commands run from the repo root via ` ./mfc.sh ` .
1724
18- ``` bash
19- # Building
20- ./mfc.sh build -j 8 # Build all 3 targets (pre_process, simulation, post_process)
21- ./mfc.sh build -t simulation -j 8 # Build only simulation
22- ./mfc.sh build --gpu acc -j 8 # Build with OpenACC GPU support
23- ./mfc.sh build --gpu mp -j 8 # Build with OpenMP target offload GPU support
24- ./mfc.sh build --debug -j 8 # Debug build
25- ./mfc.sh build -i case.py --case-optimization -j 8 # Case-optimized build (10x speedup)
26-
27- # Running
28- ./mfc.sh run case.py -n 4 # Run case with 4 MPI ranks
29- ./mfc.sh run case.py --no-build # Run without rebuilding
30- ./mfc.sh run case.py -e batch -N 2 -n 4 -c phoenix -a ACCOUNT # Batch submit on Phoenix
31-
32- # Testing
33- ./mfc.sh test -j 8 # Run full test suite (560+ tests)
34- ./mfc.sh test --only 1D -j 8 # Only 1D tests
35- ./mfc.sh test --only 2D Bubbles -j 8 # Only 2D bubble tests
36- ./mfc.sh test --only < UUID> -j 8 # Run one specific test by UUID
37- ./mfc.sh test -l # List all tests with UUIDs and traces
38- ./mfc.sh test -% 10 -j 8 # Run 10% random sample
39- ./mfc.sh test --generate --only < feature> # Regenerate golden files after intentional output change
40-
41- # Verification (pre-commit CI checks)
42- ./mfc.sh precheck -j 8 # Run all 6 lint checks (same as CI gate)
43- ./mfc.sh format -j 8 # Auto-format Fortran (.fpp/.f90) + Python
44- ./mfc.sh lint # Ruff lint + Python unit tests
45- ./mfc.sh spelling # Spell check
46-
47- # Module loading (HPC clusters only — must use `source`)
48- source ./mfc.sh load -c p -m g # Load Phoenix GPU modules
49- source ./mfc.sh load -c f -m g # Load Frontier GPU modules
50- source ./mfc.sh load -c p -m c # Load Phoenix CPU modules
51-
52- # Other
53- ./mfc.sh validate case.py # Validate case file without running
54- ./mfc.sh params < query> # Search 3,400 case parameters
55- ./mfc.sh clean # Remove build artifacts
56- ./mfc.sh new < name> # Create new case from template
57- ```
58-
59- ## System Identification and Module Loading
60-
61- MFC targets HPC clusters. Before building on a cluster, load the correct modules
62- via ` source ./mfc.sh load -c <slug> -m <mode> ` .
63-
64- To identify the current system, check multiple signals — hostname alone is not always
65- sufficient (compute nodes may differ from login nodes):
25+ Run ` ./mfc.sh <command> --help ` for the full flag set; the most-used invocations:
6626
6727``` bash
68- hostname # e.g., login-phoenix-gnr-2.pace.gatech.edu
69- echo $LMOD_SYSHOST # e.g., "phoenix" (most reliable when set)
70- echo $CRAY_LD_LIBRARY_PATH # Non-empty → Cray system (Frontier, Carpenter Cray)
71- echo $MODULESHOME # Confirms module system is available
28+ # Build / run / test (-j N = parallel jobs)
29+ ./mfc.sh build -j 8 # all 3 targets; flags: -t <target>, --gpu acc|mp, --debug,
30+ # -i case.py --case-optimization (10x speedup)
31+ ./mfc.sh run case.py -n 4 # run with 4 MPI ranks; --no-build; -e batch (toolchain/templates/)
32+ ./mfc.sh test -j 8 # full suite; --only <1D|Bubbles|UUID>, -l, -% N (sample),
33+ # --generate (regenerate golden files after an intended output change)
34+
35+ # Verify before committing
36+ ./mfc.sh precheck -j 8 # all CI lint checks
37+ ./mfc.sh format -j 8 # auto-format Fortran (.fpp/.f90) + Python
38+ ./mfc.sh lint # ruff lint + Python unit tests (spelling: ./mfc.sh spelling)
39+
40+ # Case files
41+ ./mfc.sh validate case.py # validate without running
42+ ./mfc.sh params < query> # search case parameters
43+ ./mfc.sh new < name> # new case from template (clean: ./mfc.sh clean)
7244```
7345
74- Supported systems and their slugs (full list in ` toolchain/modules ` ):
46+ Module loading ( ` source ./mfc.sh load -c <slug> -m <mode> ` ) is covered under System Identification below.
7547
76- | Slug | System | GPU Backend | Example |
77- | ------| --------| -------------| ---------|
78- | ` p ` | GT Phoenix | OpenACC (nvfortran) | ` source ./mfc.sh load -c p -m g ` |
79- | ` f ` | OLCF Frontier | OpenACC/OpenMP (Cray ftn) | ` source ./mfc.sh load -c f -m g ` |
80- | ` tuo ` | LLNL Tuolumne | OpenMP (Cray ftn) | ` source ./mfc.sh load -c tuo -m g ` |
81- | ` d ` | NCSA Delta | OpenACC (nvfortran) | ` source ./mfc.sh load -c d -m g ` |
82- | ` b ` | PSC Bridges2 | OpenACC (nvfortran) | ` source ./mfc.sh load -c b -m g ` |
83- | ` cc ` | DoD Carpenter (Cray) | CPU only | ` source ./mfc.sh load -c cc -m c ` |
84- | ` c ` | DoD Carpenter (GNU) | CPU only | ` source ./mfc.sh load -c c -m c ` |
85- | ` o ` | Brown Oscar | OpenACC (nvfortran) | ` source ./mfc.sh load -c o -m g ` |
86- | ` h ` | UF HiPerGator | OpenACC (nvfortran) | ` source ./mfc.sh load -c h -m g ` |
48+ ## System Identification and Module Loading
8749
88- The ` -m ` flag selects mode: ` g ` /` gpu ` for GPU builds, ` c ` /` cpu ` for CPU-only.
89- Batch job templates for ` ./mfc.sh run -e batch -c <system> ` are in ` toolchain/templates/ ` .
50+ On an HPC cluster, load modules before building: ` source ./mfc.sh load -c <slug> -m <mode> `
51+ (` -m g ` /` gpu ` or ` c ` /` cpu ` ). The ` source ` is required — plain ` ./mfc.sh load ` errors, since
52+ the command sets environment variables in the current shell.
9053
91- IMPORTANT: ` source ` (or ` . ` ) is required for ` load ` — it sets environment variables
92- in the current shell. Using ` ./mfc.sh load ` without ` source ` will error.
54+ Slugs live in ` toolchain/modules ` (e.g. ` p ` Phoenix, ` f ` Frontier, ` tuo ` Tuolumne, ` d ` Delta,
55+ ` b ` Bridges2, ` c ` /` cc ` Carpenter GNU/Cray, ` o ` Oscar, ` h ` HiPerGator; GPU backend per system
56+ is defined there). To identify the current system, check ` $LMOD_SYSHOST ` (most reliable),
57+ then a non-empty ` $CRAY_LD_LIBRARY_PATH ` (→ Cray: Frontier / Carpenter-Cray), then ` hostname `
58+ — login and compute nodes may differ. Batch templates for ` ./mfc.sh run -e batch -c <system> `
59+ are in ` toolchain/templates/ ` .
9360
9461## Development Workflow Contract
9562
@@ -99,7 +66,7 @@ IMPORTANT: Follow this loop for ALL code changes. Do not skip steps.
99662 . ** Plan** — For multi-file changes, outline your approach before implementing.
100673 . ** Implement** — Make small, focused changes. One logical change per commit.
101684 . ** Format** — Run ` ./mfc.sh format -j 8 ` to auto-format.
102- 5 . ** Verify** — Run ` ./mfc.sh precheck -j 8 ` (same 6 checks as CI lint gate).
69+ 5 . ** Verify** — Run ` ./mfc.sh precheck -j 8 ` (same checks as the CI lint gate).
103706 . ** Build** — Run ` ./mfc.sh build -j 8 ` to verify compilation.
104717 . ** Test** — Run relevant tests: ` ./mfc.sh test --only <feature> -j 8 ` .
10572 For changes to ` src/common/ ` , test ALL three targets: ` ./mfc.sh test -j 8 ` .
@@ -119,11 +86,11 @@ src/
11986 simulation/ # CFD solver (GPU-accelerated via OpenACC / OpenMP target offload)
12087 post_process/ # Data output and visualization
12188toolchain/ # Python CLI, build system, testing, parameter management
122- mfc/params/definitions.py # ~3,400 parameter definitions (source of truth)
89+ mfc/params/definitions.py # parameter definitions (source of truth)
12390 mfc/case_validator.py # Physics constraint validation
12491 mfc/test/ # Test runner and case generation
12592examples/ # Example simulation cases (case.py files)
126- tests/ # 560+ regression test golden files
93+ tests/ # regression test golden files
12794```
12895
12996Source files are ` .fpp ` (Fortran + Fypp macros), preprocessed to ` .f90 ` by CMake.
@@ -137,6 +104,7 @@ NEVER use double-precision intrinsics: `dsqrt`, `dexp`, `dlog`, `dble`, `dabs`,
137104NEVER use ` d ` exponent literals (` 1.0d0 ` ). Use ` 1.0_wp ` instead.
138105NEVER use ` stop ` or ` error stop ` . Use ` call s_mpi_abort() ` or ` @:PROHIBIT() ` /` @:ASSERT() ` .
139106NEVER use ` goto ` , ` COMMON ` blocks, or global ` save ` variables.
107+ (Headline subset; full lint-enforced list — incl. Python/shell rules — in ` .claude/rules/fortran-conventions.md ` .)
140108
141109Every ` @:ALLOCATE(...) ` MUST have a matching ` @:DEALLOCATE(...) ` .
142110Every new parameter MUST be added in at least 2 places (3 if it has constraints):
@@ -153,13 +121,14 @@ Changes to `src/common/` affect ALL three executables. Test comprehensively.
153121- Modules: ` m_<feature> ` (e.g., ` m_bubbles ` )
154122- Public subroutines: ` s_<verb>_<noun> ` (e.g., ` s_compute_pressure ` )
155123- Public functions: ` f_<verb>_<noun> `
124+ - Private/local variables: no prefix required. Constants: descriptive names, not ALL_CAPS.
156125- 2-space indentation, lowercase keywords, explicit ` intent ` on all arguments
157126
158127## Precision System
159128
160129- ` wp ` = working precision (computation). ` stp ` = storage precision (field data arrays and I/O).
161- - Default: both double. Single mode: both single. Mixed: wp=double, stp=half.
162- - MPI types must match: ` mpi_p ` ↔ ` wp ` , ` mpi_io_p ` ↔ ` stp ` .
130+ - Both double by default. See ` .claude/rules/fortran-conventions.md ` for single/mixed
131+ modes, casting rules, and MPI type matching ( ` mpi_p ` ↔ ` wp ` , ` mpi_io_p ` ↔ ` stp ` ) .
163132
164133## Code Review Priorities
165134
0 commit comments