Skip to content

Commit

Permalink
Fix an issue with multi-day durations. (ufs-community#543)
Browse files Browse the repository at this point in the history
MPAS expects an underscore for multi-day forecasts when specifying forecast duration.
  • Loading branch information
christinaholtNOAA committed Aug 1, 2024
1 parent dc7df99 commit 6c3bb36
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/uwtools/drivers/mpas.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def namelist_file(self):
yield asset(path, path.is_file)
yield None
duration = timedelta(hours=self._driver_config["length"])
str_duration = str(duration).replace(" days, ", "")
str_duration = str(duration).replace(" days, ", "_")
try:
namelist = self._driver_config["namelist"]
except KeyError as e:
Expand Down
17 changes: 16 additions & 1 deletion src/uwtools/tests/drivers/test_mpas.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,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):
Expand Down

0 comments on commit 6c3bb36

Please sign in to comment.