Skip to content

Commit

Permalink
PEP
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-seaice committed Sep 18, 2024
1 parent 9ec70a6 commit 09bee92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
14 changes: 7 additions & 7 deletions payu/models/cesm_cmeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ 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
Expand All @@ -217,7 +217,7 @@ def _setup_checks(self):
comp = "MED" # med and cpl names are both used in runconfig
else:
comp = realm.upper()

if comp in self.runconfig.get_component_list():
io_section = f"{comp}_modelio"
nc_type = self.runconfig.get(io_section, "pio_typename")
Expand All @@ -242,17 +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 (niotasks<=0) :
if (niotasks <= 0):
warn(f"The pio_numiotasks for {io_section} in {NUOPC_CONFIG} is "
"not set, using model default")
if (iostride<=0) :
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,
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
8 changes: 5 additions & 3 deletions test/models/access-om3/test_access_om3.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,15 @@ def test__setup_checks_pio_async(pio_typename, pio_async_interface):

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

teardown_cmeps_config()


@pytest.mark.parametrize("pio_numiotasks, pio_stride", [
(1, -99),
(-99, 1),
(-99, 1),
])
def test__setup_checks_bad_io(pio_numiotasks, pio_stride):
cmeps_config(1)
Expand All @@ -310,4 +311,5 @@ def test__setup_checks_bad_io(pio_numiotasks, pio_stride):
):
model._setup_checks()

teardown_cmeps_config()
teardown_cmeps_config()

0 comments on commit 09bee92

Please sign in to comment.