Skip to content

Commit

Permalink
ACCESS-ESM1.5 QA test: CICE icefields_nml configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-basevi committed Aug 26, 2024
1 parent 1244b2d commit b469971
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/model_config_tests/qa/test_access_esm1p5_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import warnings
from typing import Any

import f90nml
import pytest

from model_config_tests.qa.test_config import check_manifest_exes_in_spack_location
Expand All @@ -17,6 +18,7 @@
# Name of Model Repository - used for retrieving spack location files for released versions
ACCESS_ESM1P5_REPOSITORY_NAME = "ACCESS-ESM1.5"


######################################
# Bunch of expected values for tests #
######################################
Expand All @@ -30,6 +32,10 @@
VALID_RESTART_FREQ: str = "10YS"
VALID_MPPNCCOMBINE_EXE: str = "mppnccombine.spack"

CICE_IN_NML_FNAME = "cice_in.nml"
ICE_HISTORY_NML_FNAME = "ice_history.nml"
ICEFIELDS_NML_NAME = "icefields_nml"


### Some functions to avoid copying assertion error text
def error_field_nonexistence(field: str, file: str) -> str:
Expand Down Expand Up @@ -191,3 +197,34 @@ def test_mppnccombine_fast_collate_exe(self, config):
assert isinstance(config["collate"]["mpi"], bool), error_field_incorrect(
"collate.mpi", "config.yaml", "true or false"
)

def test_cice_configuration_icefields_nml_in_ice_history_nml(
self, config, control_path
):
# Find CICE sub-model control path
model_name = None
for sub_model in config["submodels"]:
if sub_model["model"] == "cice":
model_name = sub_model["name"]
assert model_name
cice_control_path = control_path / model_name

Check warning on line 210 in src/model_config_tests/qa/test_access_esm1p5_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_esm1p5_config.py#L205-L210

Added lines #L205 - L210 were not covered by tests

icefields_nml_error_msg = (

Check warning on line 212 in src/model_config_tests/qa/test_access_esm1p5_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_esm1p5_config.py#L212

Added line #L212 was not covered by tests
"Expected CICE configuration to have ice_history.nml that "
"contains an icefields_nml namelist. This is to keep icefields "
"namelist separate from the cice_in.nml to allow simpler changes."
)

# Check ice_history.nml exists
ice_history_nml_path = cice_control_path / ICE_HISTORY_NML_FNAME
assert ice_history_nml_path.is_file(), icefields_nml_error_msg

Check warning on line 220 in src/model_config_tests/qa/test_access_esm1p5_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_esm1p5_config.py#L219-L220

Added lines #L219 - L220 were not covered by tests

# Check icefields_nml in ice_history.nml
ice_history_nml = f90nml.read(ice_history_nml_path)
assert ICEFIELDS_NML_NAME in ice_history_nml, icefields_nml_error_msg

Check warning on line 224 in src/model_config_tests/qa/test_access_esm1p5_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_esm1p5_config.py#L223-L224

Added lines #L223 - L224 were not covered by tests

# Check icefields_nml not in cice_in.nml
cice_in_path = cice_control_path / CICE_IN_NML_FNAME
assert cice_in_path.is_file()
cice_in = f90nml.read(cice_in_path)
assert ICEFIELDS_NML_NAME not in cice_in, icefields_nml_error_msg

Check warning on line 230 in src/model_config_tests/qa/test_access_esm1p5_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_esm1p5_config.py#L227-L230

Added lines #L227 - L230 were not covered by tests

0 comments on commit b469971

Please sign in to comment.