Skip to content

Commit

Permalink
review comments & PEP
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-seaice committed Sep 18, 2024
1 parent 8dddc49 commit 25c8c31
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
16 changes: 13 additions & 3 deletions payu/models/cesm_cmeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ def _setup_checks(self):
if nthreads < 1:
raise ValueError(f"The number of {realm}_nthreads ({nthreads}) in "
f"{NUOPC_CONFIG} must be at least 1.")

if nthreads > 1:
npes = nthreads*ntasks*pestride
# this is taken from
# this is taken from
# https://github.com/ESCOMP/CMEPS/blob/5b7d76978e2fdc661ec2de4ba9834b985decadc6/cesm/driver/esm.F90#L1007
# the correct calculation might be (ntasks-1)*pestride*nthreads + nthreads
else:
Expand Down Expand Up @@ -242,7 +242,17 @@ def _setup_checks(self):
case "netcdf4p" | "pnetcdf":
niotasks = int(self.runconfig.get(io_section, "pio_numiotasks"))
iostride = int(self.runconfig.get(io_section, "pio_stride"))
if (ioroot + (niotasks-1)*iostride) >= npes:
if (niotasks<=0) :
warn(f"The pio_numiotasks for {io_section} in {NUOPC_CONFIG} is "
"not set, using model default")
if (iostride<=0) :
warn(f"The pio_stride for {io_section} in {NUOPC_CONFIG} is "
"not set, using model default")
if (all(
niotasks>0,
iostride>0,
ioroot + (niotasks-1)*iostride) >= npes
):
raise ValueError(
f"The iolayout for {io_section} in {NUOPC_CONFIG} is "
"requesting out of range cpus"
Expand Down
13 changes: 8 additions & 5 deletions test/models/access-om3/test_access_om3.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,11 @@ def test__setup_checks_bad_io(ncpu, pio_numiotasks, pio_stride, pio_root, pio_ty

teardown_cmeps_config()


@pytest.mark.parametrize("pio_typename, pio_async_interface", [
("netcdf4p", ".true."),
("pnetcdf", ".true."),
("netcdf", ".true."),
("netcdf4p", ".true."),
("pnetcdf", ".true."),
("netcdf", ".true."),
])
def test__setup_checks_pio_async(pio_typename, pio_async_interface):

Expand All @@ -273,7 +274,9 @@ def test__setup_checks_pio_async(pio_typename, pio_async_interface):

model.runconfig = MockRunConfig(test_runconf)

with pytest.warns(Warning, match = "does not do consistency checks for asynchronous pio"):
with pytest.warns(
Warning, match="does not do consistency checks for asynchronous pio"
):
model._setup_checks()

teardown_cmeps_config()
Expand Down Expand Up @@ -305,4 +308,4 @@ def test__setup_checks_not_pio_async(pio_typename, pio_async_interface):

model._setup_checks()

teardown_cmeps_config()
teardown_cmeps_config()

0 comments on commit 25c8c31

Please sign in to comment.