Skip to content

Commit 32612ab

Browse files
authored
Merge pull request #134 from ACCESS-NRI/133-esm-collation
ESM1.6 qa checks for io_layout
2 parents 5c12d7c + 2dce9f0 commit 32612ab

1 file changed

Lines changed: 51 additions & 16 deletions

File tree

src/model_config_tests/qa/test_access_esm1p6_config.py

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
ICE_HISTORY_NML_FNAME = "ice_history.nml"
3939
ICEFIELDS_NML_NAME = "icefields_nml"
4040

41+
MOM_INPUT_NML_FNAME = "input.nml"
42+
OCEAN_MODEL_NML_NAME = "ocean_model_nml"
43+
VALID_IO_LAYOUT = [1, 1]
44+
4145

4246
### Some functions to avoid copying assertion error text
4347
def error_field_nonexistence(field: str, file: str) -> str:
@@ -203,24 +207,55 @@ def test_config_restart_freq(self, config):
203207
"restart_freq", "config.yaml", VALID_RESTART_FREQ
204208
)
205209

206-
def test_mppnccombine_fast_collate_exe(self, config):
207-
if "collate" in config:
208-
assert (
209-
config["collate"]["exe"] == VALID_MPPNCCOMBINE_EXE
210-
), error_field_incorrect(
211-
"collate.exe", "config.yaml", VALID_MPPNCCOMBINE_EXE
212-
)
210+
def test_collation_disabled(self, config, branch):
211+
"""
212+
Check that collation is not enabled.
213+
"""
214+
if branch.config_scenario == "amip":
215+
pytest.skip("amip scenarios do not contain the MOM sub-model")
213216

214-
assert "mpi" in config["collate"], error_field_nonexistence(
215-
"collate.mpi", "config.yaml"
216-
)
217+
assert "collate" in config, error_field_nonexistence("collate", "config.yaml")
217218

218-
# Loading the yaml into a dict also converts
219-
# `collate.mpi:true`/`collate.mpi:false` to `True`/`False` so we
220-
# can assert if it is a `bool`.
221-
assert isinstance(config["collate"]["mpi"], bool), error_field_incorrect(
222-
"collate.mpi", "config.yaml", "true or false"
223-
)
219+
assert "enable" in config["collate"], error_field_nonexistence(
220+
"collate.enable", "config.yaml"
221+
)
222+
223+
assert not config["collate"]["enable"], error_field_incorrect(
224+
"collate.enable", "config.yaml", False
225+
)
226+
227+
def test_mom_io(self, branch, config, control_path):
228+
"""
229+
Check that io_layout set to 1,1 in MOM namelist
230+
"""
231+
if branch.config_scenario == "amip":
232+
pytest.skip("amip scenarios do not contain the MOM sub-model")
233+
234+
# Find MOM sub-model control path
235+
model_name = None
236+
for sub_model in config["submodels"]:
237+
if sub_model["model"] == "mom":
238+
model_name = sub_model["name"]
239+
assert model_name
240+
mom_control_path = control_path / model_name
241+
242+
# Check input.nml exists
243+
mom_input_path = mom_control_path / MOM_INPUT_NML_FNAME
244+
assert mom_input_path.is_file(), (
245+
f"No {MOM_INPUT_NML_FNAME} file found. This is a required "
246+
"configuration file for the MOM model component."
247+
)
248+
249+
mom_input = f90nml.read(mom_input_path)
250+
251+
assert "io_layout" in mom_input[OCEAN_MODEL_NML_NAME], error_field_nonexistence(
252+
"io_layout", MOM_INPUT_NML_FNAME
253+
)
254+
assert (
255+
mom_input["ocean_model_nml"]["io_layout"] == VALID_IO_LAYOUT
256+
), error_field_incorrect(
257+
"io_layout", MOM_INPUT_NML_FNAME, ",".join(str(i) for i in VALID_IO_LAYOUT)
258+
)
224259

225260
def test_cice_configuration_icefields_nml_in_ice_history_nml(
226261
self, branch, config, control_path

0 commit comments

Comments
 (0)