Skip to content

Commit 233a1f6

Browse files
sbryngelsonclaude
andcommitted
Add build-flag compatibility checks to Python case validator
Move three Fortran @:PROHIBIT checks that test case parameters against build configuration flags into case_validator.py, so they fire before any binary is invoked rather than at Fortran runtime: - parallel_io = T requires --mpi (all stages, via check_build_flags) - precision = 2 requires no --single (post_process, in check_output_format) - 3D cylindrical + p > 0 requires no --single (simulation only, via check_geometry_precision_simulation) CFG() from state.py carries the active build config (mpi, single, mixed). During standalone './mfc.sh validate', CFG() holds defaults (mpi=T, single=F) so these checks do not produce false positives. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8c7a747 commit 233a1f6

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

toolchain/mfc/case_validator.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from functools import lru_cache
2020
from .common import MFCException
2121
from .params.definitions import CONSTRAINTS
22+
from .state import CFG
2223

2324

2425
# Physics documentation for check methods.
@@ -1794,6 +1795,10 @@ def check_output_format(self):
17941795
if precision is not None:
17951796
self.prohibit(precision not in [1, 2],
17961797
"precision must be 1 or 2")
1798+
self.prohibit(
1799+
precision == 2 and CFG().single,
1800+
"precision = 2 (double output) requires MFC built without --single"
1801+
)
17971802

17981803
def check_vorticity(self):
17991804
"""Checks vorticity parameters (post-process)"""
@@ -2330,13 +2335,41 @@ def check_velocity_components(self):
23302335
self.prohibit(vel3 != 0,
23312336
f"patch_icpp({i})%vel(3) = {vel3} but p = 0 (1D/2D simulation)")
23322337

2338+
# ===================================================================
2339+
# Build-Flag Compatibility Checks
2340+
# ===================================================================
2341+
2342+
def check_build_flags(self):
2343+
"""Checks case parameters against the active build configuration.
2344+
2345+
These catch incompatibilities between case settings and how the
2346+
MFC binaries were compiled (--mpi/--no-mpi, --single, etc.)
2347+
before any binary is invoked.
2348+
"""
2349+
parallel_io = self.get('parallel_io', 'F') == 'T'
2350+
self.prohibit(
2351+
parallel_io and not CFG().mpi,
2352+
"parallel_io = T requires MFC built with --mpi"
2353+
)
2354+
2355+
def check_geometry_precision_simulation(self):
2356+
"""Checks that 3D cylindrical geometry is not used with --single builds."""
2357+
cyl_coord = self.get('cyl_coord', 'F') == 'T'
2358+
p = self.get('p', 0)
2359+
self.prohibit(
2360+
CFG().single and cyl_coord and p is not None and p > 0,
2361+
"Fully 3D cylindrical geometry (cyl_coord = T, p > 0) is not supported "
2362+
"in single precision (--single)"
2363+
)
2364+
23332365
# ===================================================================
23342366
# Main Validation Entry Points
23352367
# ===================================================================
23362368

23372369
def validate_common(self):
23382370
"""Validate parameters common to all stages"""
23392371
self.check_parameter_types() # Type validation first
2372+
self.check_build_flags()
23402373
self.check_simulation_domain()
23412374
self.check_domain_bounds()
23422375
self.check_model_eqns_and_num_fluids()
@@ -2359,6 +2392,7 @@ def validate_common(self):
23592392
def validate_simulation(self):
23602393
"""Validate simulation-specific parameters"""
23612394
self.validate_common()
2395+
self.check_geometry_precision_simulation()
23622396
self.check_finite_difference()
23632397
self.check_time_stepping()
23642398
self.check_riemann_solver()

toolchain/mfc/lint_docs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,8 @@ def check_physics_docs_coverage(repo_root: Path) -> list[str]:
423423
"check_output_format", # output format selection
424424
"check_restart", # restart file logistics
425425
"check_parallel_io_pre_process", # parallel I/O settings
426+
"check_build_flags", # build-flag compatibility (no physics meaning)
427+
"check_geometry_precision_simulation", # build-flag compatibility (no physics meaning)
426428
"check_misc_pre_process", # miscellaneous pre-process flags
427429
"check_bc_patches", # boundary patch geometry
428430
"check_grid_stretching", # grid stretching parameters

0 commit comments

Comments
 (0)