Skip to content

Commit

Permalink
Merge pull request #4673 from ESMCI/jgfouca/create_test_driver
Browse files Browse the repository at this point in the history
create_test: add --driver support for e3sm

Also, fix a couple issues in driver handling in test_scheduler.

Test suite:
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes [CIME Github issue #]

User interface changes?:

Update gh-pages html (Y/N)?:
  • Loading branch information
jgfouca authored Sep 4, 2024
2 parents 8238b66 + e351cca commit 847d3c5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
10 changes: 10 additions & 0 deletions CIME/scripts/create_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ def parse_command_line(args, description):
"\nNOTE: this can also be done after the fact with bless_test_results",
)

parser.add_argument(
"--driver",
help="Override driver specified in tests and use this one.",
)

default = get_default_setting(config, "COMPILER", None, check_main=True)

parser.add_argument(
Expand Down Expand Up @@ -775,6 +780,7 @@ def parse_command_line(args, description):
args.workflow,
args.chksum,
args.force_rebuild,
args.driver,
)


Expand Down Expand Up @@ -936,6 +942,7 @@ def create_test(
workflow,
chksum,
force_rebuild,
driver,
):
###############################################################################
impl = TestScheduler(
Expand Down Expand Up @@ -977,6 +984,7 @@ def create_test(
workflow=workflow,
chksum=chksum,
force_rebuild=force_rebuild,
driver=driver,
)

success = impl.run_tests(
Expand Down Expand Up @@ -1081,6 +1089,7 @@ def _main_func(description=None):
workflow,
chksum,
force_rebuild,
driver,
) = parse_command_line(sys.argv, description)

success = False
Expand Down Expand Up @@ -1134,6 +1143,7 @@ def _main_func(description=None):
workflow,
chksum,
force_rebuild,
driver,
)
run_count += 1

Expand Down
32 changes: 21 additions & 11 deletions CIME/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,12 @@ def __init__(
workflow=None,
chksum=False,
force_rebuild=False,
driver=None,
):
###########################################################################
self._cime_root = get_cime_root()
self._cime_model = get_model()
self._cime_driver = get_cime_default_driver()
self._cime_driver = driver if driver is not None else get_cime_default_driver()
self._save_timing = save_timing
self._queue = queue
self._test_data = (
Expand Down Expand Up @@ -649,6 +650,7 @@ def _create_newcase_phase(self, test):
mpilib = None
ninst = 1
ncpl = 1
driver = self._cime_driver
if case_opts is not None:
for case_opt in case_opts: # pylint: disable=not-an-iterable
if case_opt.startswith("M"):
Expand Down Expand Up @@ -681,15 +683,16 @@ def _create_newcase_phase(self, test):
)
)
elif case_opt.startswith("V"):
self._cime_driver = case_opt[1:]
create_newcase_cmd += " --driver {}".format(self._cime_driver)
driver = case_opt[1:]

create_newcase_cmd += " --driver {}".format(driver)

if (
"--ninst" in create_newcase_cmd
and not "--multi-driver" in create_newcase_cmd
):
if "--driver nuopc" in create_newcase_cmd or (
"--driver" not in create_newcase_cmd and self._cime_driver == "nuopc"
"--driver" not in create_newcase_cmd and driver == "nuopc"
):
expect(False, "_N option not supported by nuopc driver, use _C instead")

Expand All @@ -704,7 +707,7 @@ def _create_newcase_phase(self, test):
self._log_output(test, error)
return False, error

files = Files(comp_interface=self._cime_driver)
files = Files(comp_interface=driver)
testmods_dir = files.get_value(
"TESTS_MODS_DIR", {"component": component}
)
Expand Down Expand Up @@ -783,23 +786,28 @@ def _xml_phase(self, test):
test_dir = self._get_test_dir(test)
envtest = EnvTest(test_dir)

# Find driver. It may be different for the current test if V testopt is used
driver = self._cime_driver
if case_opts is not None:
for case_opt in case_opts: # pylint: disable=not-an-iterable
if case_opt.startswith("V"):
driver = case_opt[1:]

# Determine list of component classes that this coupler/driver knows how
# to deal with. This list follows the same order as compset longnames follow.
files = Files(comp_interface=self._cime_driver)
files = Files(comp_interface=driver)
ufs_driver = os.environ.get("UFS_DRIVER")
attribute = None
if ufs_driver:
attribute = {"component": ufs_driver}

drv_config_file = files.get_value("CONFIG_CPL_FILE", attribute=attribute)

if self._cime_driver == "nuopc" and not os.path.exists(drv_config_file):
if driver == "nuopc" and not os.path.exists(drv_config_file):
drv_config_file = files.get_value("CONFIG_CPL_FILE", {"component": "cpl"})
expect(
os.path.exists(drv_config_file),
"File {} not found, cime driver {}".format(
drv_config_file, self._cime_driver
),
"File {} not found, cime driver {}".format(drv_config_file, driver),
)

drv_comp = Component(drv_config_file, "CPL")
Expand Down Expand Up @@ -924,7 +932,9 @@ def _xml_phase(self, test):
elif opt.startswith("A"):
# A option is for testing in ASYNC IO mode, only available with nuopc driver and pio2
envtest.set_test_parameter("PIO_ASYNC_INTERFACE", "TRUE")
envtest.set_test_parameter("CIME_DRIVER", "nuopc")
expect(
driver == "nuopc", "ASYNC IO mode only works with nuopc driver"
)
envtest.set_test_parameter("PIO_VERSION", "2")
match = re.match("A([0-9]+)x?([0-9])*", opt)
envtest.set_test_parameter("PIO_NUMTASKS_CPL", match.group(1))
Expand Down

0 comments on commit 847d3c5

Please sign in to comment.