Skip to content

Commit cf13fa1

Browse files
authored
Fix Homebrew install: (#1355)
1 parent fbaa8c6 commit cf13fa1

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

toolchain/mfc/params/namelist_parser.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,16 +490,29 @@ def get_fortran_constants() -> Dict[str, int]:
490490
"""
491491
Get Fortran compile-time constants from m_constants.fpp.
492492
493-
Cached after first call. Returns empty dict if source unavailable.
493+
Cached after first call. Falls back to built-in defaults when the Fortran
494+
source is unavailable (e.g. Homebrew installs where src/ is not shipped).
494495
"""
495496
global _FORTRAN_CONSTANTS_CACHE # noqa: PLW0603
496497
if _FORTRAN_CONSTANTS_CACHE is None:
497498
root = get_mfc_root()
498499
path = root / "src" / "common" / "m_constants.fpp"
499500
_FORTRAN_CONSTANTS_CACHE = parse_fortran_constants(path)
501+
if not _FORTRAN_CONSTANTS_CACHE:
502+
_FORTRAN_CONSTANTS_CACHE = _FALLBACK_CONSTANTS.copy()
500503
return _FORTRAN_CONSTANTS_CACHE
501504

502505

506+
# Fallback values for when m_constants.fpp is not available at runtime.
507+
# Keep in sync with src/common/m_constants.fpp.
508+
_FALLBACK_CONSTANTS: Dict[str, int] = {
509+
"num_fluids_max": 10,
510+
"num_probes_max": 10,
511+
"num_patches_max": 1000,
512+
"num_bc_patches_max": 10,
513+
}
514+
515+
503516
def get_mfc_root() -> Path:
504517
"""Get the MFC root directory from this file's location."""
505518
# This file is at toolchain/mfc/params/namelist_parser.py

0 commit comments

Comments
 (0)