From 4d9b39231b13305fdf02b2857c52c40f00aeb8c3 Mon Sep 17 00:00:00 2001 From: Christina Holt Date: Tue, 23 Jul 2024 13:17:53 -0600 Subject: [PATCH 1/2] Fix an issue with multi-day durations. --- src/uwtools/drivers/mpas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uwtools/drivers/mpas.py b/src/uwtools/drivers/mpas.py index 79d28d8e9..914908e54 100644 --- a/src/uwtools/drivers/mpas.py +++ b/src/uwtools/drivers/mpas.py @@ -48,7 +48,7 @@ def namelist_file(self): base_file = self._driver_config["namelist"].get("base_file") yield file(Path(base_file)) if base_file else None duration = timedelta(hours=self._driver_config["length"]) - str_duration = str(duration).replace(" days, ", "") + str_duration = str(duration).replace(" days, ", "_") namelist = self._driver_config["namelist"] update_values = namelist.get("update_values", {}) update_values.setdefault("nhyd_model", {}).update( From 4a392194eaa93182eb7b96a7ef5969c87ef72685 Mon Sep 17 00:00:00 2001 From: Christina Holt Date: Tue, 23 Jul 2024 14:42:57 -0600 Subject: [PATCH 2/2] Add a test for this new duration syntax --- src/uwtools/tests/drivers/test_mpas.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/uwtools/tests/drivers/test_mpas.py b/src/uwtools/tests/drivers/test_mpas.py index dd71dc02a..f8659ffd3 100644 --- a/src/uwtools/tests/drivers/test_mpas.py +++ b/src/uwtools/tests/drivers/test_mpas.py @@ -186,7 +186,22 @@ def test_MPAS_namelist_file(caplog, driverobj): path = Path(refs(driverobj.namelist_file())) assert dst.is_file() assert logged(caplog, f"Wrote config to {path}") - assert isinstance(f90nml.read(dst), f90nml.Namelist) + nml = f90nml.read(dst) + assert isinstance(nml, f90nml.Namelist) + + +def test_MPAS_namelist_file_long_duration(caplog, config, cycle): + log.setLevel(logging.DEBUG) + config["mpas"]["length"] = 120 + driverobj = MPAS(config=config, cycle=cycle) + dst = driverobj._rundir / "namelist.atmosphere" + assert not dst.is_file() + path = Path(refs(driverobj.namelist_file())) + assert dst.is_file() + assert logged(caplog, f"Wrote config to {path}") + nml = f90nml.read(dst) + assert isinstance(nml, f90nml.Namelist) + assert nml["nhyd_model"]["config_run_duration"] == "5_0:00:00" def test_MPAS_namelist_file_fails_validation(caplog, driverobj):