Skip to content

Commit

Permalink
Add valid values for --cupid-example
Browse files Browse the repository at this point in the history
We don't know the full list of valid values when parsing command line
arguments, so this check needs to be done in the body of the python script
  • Loading branch information
mnlevy1981 committed Sep 19, 2024
1 parent a52a042 commit bb3f37d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion helper_scripts/generate_cupid_config_for_cesm_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,22 @@ def generate_cupid_config(case_root, cesm_root, cupid_example):
sys.path.append(os.path.join(cesm_root, "cime"))
from CIME.case import Case

# Is cupid_example a valid value?
cupid_root = os.path.join(cesm_root, "tools", "CUPiD")
cupid_examples = os.path.join(cupid_root, "examples")
valid_examples = [
example
for example in next(os.walk(cupid_examples))[1]
if example not in ["ilamb", "nblibrary"]
]
if cupid_example not in valid_examples:
raise KeyError(
f"--cupid-example must be a subdirectory of {cupid_examples} ({valid_examples})",
)

with Case(case_root, read_only=False, record=True) as cesm_case:
case = cesm_case.get_value("CASE")
dout_s_root = cesm_case.get_value("DOUT_S_ROOT")
cupid_root = os.path.join(cesm_root, "tools", "CUPiD")

# Additional options we need to get from env_cupid.xml
nyears = 1
Expand Down

0 comments on commit bb3f37d

Please sign in to comment.