Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create_test: add --driver support for e3sm #4673

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code looks like a bug. The presence of one test with Vdriver would change the driver for all the tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's been there for a long time, seems like we would have seen problems by now if that were the case. On the other hand, I agree.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean adding one Vdriver a test in a suite would change all tests in that suite?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rljacob , yes. self._cime_driver is shared for all tests.

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")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also looked really problematic. Setting the driver to nuopc even if that doesn't match cime_driver?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PIO async mode is only supported in nuopc - but since cesm only supports the nuopc driver now, this is okay to remove.

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
Loading