Skip to content

Commit

Permalink
Merge pull request #4580 from jedwards4b/standalone_component
Browse files Browse the repository at this point in the history
Standalone component
  • Loading branch information
jedwards4b authored Feb 16, 2024
2 parents 1b208b8 + 8df8357 commit 2f38b10
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 21 deletions.
11 changes: 7 additions & 4 deletions CIME/SystemTests/system_tests_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
expect,
get_current_commit,
SharedArea,
is_comp_standalone,
)
from CIME.test_status import *
from CIME.hist_utils import (
Expand Down Expand Up @@ -289,10 +290,12 @@ def run(self, skip_pnl=False):
if self._case.get_value("COMPARE_BASELINE"):
if do_baseline_ops:
self._phase_modifying_call(BASELINE_PHASE, self._compare_baseline)
self._phase_modifying_call(MEMCOMP_PHASE, self._compare_memory)
self._phase_modifying_call(
THROUGHPUT_PHASE, self._compare_throughput
)
comp_standalone, _ = is_comp_standalone(self._case)
if not comp_standalone:
self._phase_modifying_call(MEMCOMP_PHASE, self._compare_memory)
self._phase_modifying_call(
THROUGHPUT_PHASE, self._compare_throughput
)
else:
with self._test_status:
self._test_status.set_status(BASELINE_PHASE, TEST_PEND_STATUS)
Expand Down
23 changes: 11 additions & 12 deletions CIME/case/case_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from CIME.config import Config
from CIME.utils import gzip_existing_file, new_lid, run_and_log_case_status
from CIME.utils import run_sub_or_cmd, append_status, safe_copy, model_log, CIMEError
from CIME.utils import get_model, batch_jobid
from CIME.utils import batch_jobid, is_comp_standalone
from CIME.get_timing import get_timing

import shutil, time, sys, os, glob
Expand Down Expand Up @@ -292,16 +292,12 @@ def _post_run_check(case, lid):
###############################################################################

rundir = case.get_value("RUNDIR")
model = case.get_value("MODEL")
driver = case.get_value("COMP_INTERFACE")
model = get_model()

fv3_standalone = False
comp_standalone, model = is_comp_standalone(case)

if "CPL" not in case.get_values("COMP_CLASSES"):
fv3_standalone = True
if driver == "nuopc":
if fv3_standalone:
if comp_standalone:
file_prefix = model
else:
file_prefix = "med"
Expand All @@ -322,7 +318,6 @@ def _post_run_check(case, lid):
cpl_logs = [os.path.join(rundir, file_prefix + ".log." + lid)]

cpl_logfile = cpl_logs[0]

# find the last model.log and cpl.log
model_logfile = os.path.join(rundir, model + ".log." + lid)
if not os.path.isfile(model_logfile):
Expand All @@ -332,15 +327,19 @@ def _post_run_check(case, lid):
else:
count_ok = 0
for cpl_logfile in cpl_logs:
print(f"cpl_logfile {cpl_logfile}")
if not os.path.isfile(cpl_logfile):
break
with open(cpl_logfile, "r") as fd:
if fv3_standalone and "HAS ENDED" in fd.read():
logfile = fd.read()
if (
comp_standalone
and "HAS ENDED" in logfile
or "END OF MODEL RUN" in logfile
):
count_ok += 1
elif not fv3_standalone and "SUCCESSFUL TERMINATION" in fd.read():
elif not comp_standalone and "SUCCESSFUL TERMINATION" in logfile:
count_ok += 1
if count_ok != cpl_ninst:
if count_ok < cpl_ninst:
expect(False, "Model did not complete - see {} \n ".format(cpl_logfile))


Expand Down
11 changes: 6 additions & 5 deletions CIME/case/case_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,13 @@ def _case_setup_impl(
)
if comp == "cam":
camroot = case.get_value("COMP_ROOT_DIR_ATM")
logger.debug("Running cam.case_setup.py")
run_cmd_no_fail(
"python {cam}/cime_config/cam.case_setup.py {cam} {case}".format(
cam=camroot, case=caseroot
if os.path.exists(os.path.join(camroot, "cam.case_setup.py")):
logger.debug("Running cam.case_setup.py")
run_cmd_no_fail(
"python {cam}/cime_config/cam.case_setup.py {cam} {case}".format(
cam=camroot, case=caseroot
)
)
)

_build_usernl_files(case, "drv", "cpl")

Expand Down
19 changes: 19 additions & 0 deletions CIME/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from argparse import Action
from contextlib import contextmanager

# pylint: disable=deprecated-module
from distutils import file_util

# Return this error code if the scripts worked but tests failed
Expand Down Expand Up @@ -2736,3 +2737,21 @@ def add_flag_to_cmd(flag, val):

separator = "" if no_space else " "
return "{}{}{}".format(flag, separator, str(val).strip())


def is_comp_standalone(case):
"""
Test if the case is a single component standalone
such as FKESSLER
"""
stubcnt = 0
classes = case.get_values("COMP_CLASSES")
for comp in classes:
if case.get_value("COMP_{}".format(comp)) == "s{}".format(comp.lower()):
stubcnt = stubcnt + 1
else:
model = comp.lower()
numclasses = len(classes)
if stubcnt >= numclasses - 2:
return True, model
return False, get_model()

0 comments on commit 2f38b10

Please sign in to comment.