Skip to content

Commit

Permalink
Merge pull request #54 from ACCESS-NRI/50-access-esm1p5-qa-ice-histor…
Browse files Browse the repository at this point in the history
…y-nml-test

ACCESS-ESM1.5 QA test: CICE icefields_nml configuration
  • Loading branch information
jo-basevi authored Aug 28, 2024
2 parents 6f2e5cf + 0e91aec commit 34abb46
Show file tree
Hide file tree
Showing 13 changed files with 319 additions and 15 deletions.
53 changes: 53 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,50 @@ 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

icefields_nml_error_msg = (
f"Expected CICE configuration to have {ICE_HISTORY_NML_FNAME} that "
f"contains an {ICEFIELDS_NML_NAME} namelist. This is to keep icefields "
f"namelist separate from the {CICE_IN_NML_FNAME} 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 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 icefields_nml not in cice_in.nml
cice_in_path = cice_control_path / CICE_IN_NML_FNAME
assert cice_in_path.is_file(), (
f"No {CICE_IN_NML_FNAME} file found. This is a required "
"configuration file for the CICE model component."
)
cice_in = f90nml.read(cice_in_path)
assert ICEFIELDS_NML_NAME not in cice_in, (
f"{ICEFIELDS_NML_NAME} namelist found in {CICE_IN_NML_FNAME}. "
f"This should only be in {ICE_HISTORY_NML_FNAME} to prevent duplication."
)

# Check no repeated fields between the two namelist files
common_nmls = set(cice_in) & set(ice_history_nml)
for nml in common_nmls:
repeated_fields = set(cice_in[nml]) & set(ice_history_nml[nml])
assert repeated_fields == set(), (
f"Found repeated fields for '{nml}' namelist"
f" in {CICE_IN_NML_FNAME} and {ICE_HISTORY_NML_FNAME}"
f": {repeated_fields}"
)
5 changes: 5 additions & 0 deletions tests/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os
from pathlib import Path

HERE = os.path.dirname(__file__)
RESOURCES_DIR = Path(f"{HERE}/resources")
30 changes: 30 additions & 0 deletions tests/qa/test_test_access_esm1p5_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import shlex
import subprocess

from tests.common import RESOURCES_DIR


def test_test_access_esm1p5_config_release_release_preindustrial():
"""Test ACCESS-ESM1.5 specific config tests"""
access_esm1p5_configs = RESOURCES_DIR / "access" / "configurations"
test_config = access_esm1p5_configs / "release-preindustrial+concentrations"

assert test_config.exists()

test_cmd = (
"model-config-tests -s "
# Run all access_esm1p5 specific tests
"-m access_esm1p5 "
f"--control-path {test_config} "
# Use target branch as can't mock get_git_branch function in utils
f"--target-branch release-preindustrial+concentrations"
)

result = subprocess.run(shlex.split(test_cmd), capture_output=True, text=True)

# Expect the tests to have passed
if result.returncode:
# Print out test logs if there are errors
print(f"Test stdout: {result.stdout}\nTest stderr: {result.stderr}")

assert result.returncode == 0
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import os
import shlex
import shutil
import subprocess
from pathlib import Path

import yaml

HERE = os.path.dirname(__file__)
RESOURCES_DIR = Path(f"{HERE}/resources")
from tests.common import RESOURCES_DIR


def test_test_access_om2_config_release_1deg_jra55_ryf():
Expand Down
5 changes: 1 addition & 4 deletions tests/test_test_config.py → tests/qa/test_test_config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import os
import shlex
import subprocess
from pathlib import Path

HERE = os.path.dirname(__file__)
RESOURCES_DIR = Path(f"{HERE}/resources")
from tests.common import RESOURCES_DIR


def test_test_config_access_om2():
Expand Down
4 changes: 4 additions & 0 deletions tests/resources/access/configurations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Example test configuration

This contains some files of configuration from the [ACCESS-NRI/access-esm1.5-configs](https://github.com/ACCESS-NRI/access-esm1.5-configs) repository. The configurations contain only the files
checked with QA checks, so they are incomplete configurations.
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# A tutorial for running ACCESS ESM1.5 can be found at
# https://access-hive.org.au/models/run-a-model/run-access-esm
# Full details about the payu configuration settings are available at
# https://payu.readthedocs.io/en/latest/config.html


# PBS configuration

# If submitting to a different project to your default, uncomment line below
# and replace PROJECT_CODE with appropriate code. This may require setting shortpath
# project: PROJECT_CODE

# Force payu to always find, and save, files in this scratch project directory
# shortpath: /scratch/PROJECT_CODE

# Note: if laboratory is relative path, it is relative to shortpath/$USER
laboratory: access-esm

jobname: pre-industrial
queue: normal
walltime: 2:30:00

# Modules for loading model executables
modules:
use:
- /g/data/vk83/modules
load:
- access-esm1p5/2024.05.0

# Model configuration
model: access

submodels:
- name: atmosphere
model: um
ncpus: 192
exe: um_hg3.exe
input:
# Aerosols
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/pre-industrial/atmosphere/aerosol/global.N96/2020.05.19/OCFF_1850_ESM1.anc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/pre-industrial/atmosphere/aerosol/global.N96/2020.05.19/BC_hi_1850_ESM1.anc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/pre-industrial/atmosphere/aerosol/global.N96/2020.05.19/scycl_1850_ESM1_v4.anc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/pre-industrial/atmosphere/aerosol/global.N96/2020.05.19/Bio_1850_ESM1.anc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/atmosphere/aerosol/global.N96/2020.05.19/biogenic_351sm.N96L38
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/atmosphere/aerosol/global.N96/2020.05.19/sulpc_oxidants_N96_L38
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/atmosphere/aerosol/global.N96/2020.05.19/DMS_conc.N96
# Forcing
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/pre-industrial/atmosphere/forcing/global.N96/2020.05.19/ozone_1850_ESM1.anc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/pre-industrial/atmosphere/forcing/resolution_independent/2020.05.19/volcts_18502000ave.dat
# Land
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/pre-industrial/atmosphere/land/biogeochemistry/global.N96/2020.05.19/Ndep_1850_ESM1.anc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/atmosphere/land/soiltype/global.N96/2020.05.19/qrparm.soil_igbp_vg
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/atmosphere/land/vegetation/global.N96/2020.05.19/cable_vegfunc_N96.anc
- /g/data/vk83/configurations/inputs/access-esm1p5/share/atmosphere/land/biogeochemistry/resolution_independent/2020.05.19/modis_phenology_csiro.txt
- /g/data/vk83/configurations/inputs/access-esm1p5/share/atmosphere/land/biogeochemistry/resolution_independent/2020.05.19/pftlookup_csiro_v16_17tiles_wtlnds.csv
- /g/data/vk83/configurations/inputs/access-esm1p5/share/atmosphere/land/biogeophysics/resolution_independent/2020.05.19/def_soil_params.txt
- /g/data/vk83/configurations/inputs/access-esm1p5/share/atmosphere/land/biogeophysics/resolution_independent/2020.05.19/def_veg_params.txt
# Spectral
- /g/data/vk83/configurations/inputs/access-esm1p5/share/atmosphere/spectral/resolution_independent/2020.05.19/spec3a_sw_hadgem1_6on
- /g/data/vk83/configurations/inputs/access-esm1p5/share/atmosphere/spectral/resolution_independent/2020.05.19/spec3a_lw_hadgem1_6on
# Grids
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/atmosphere/grids/global.N96/2020.05.19/qrparm.mask
- /g/data/vk83/configurations/inputs/access-esm1p5/share/atmosphere/grids/resolution_independent/2020.05.19/vertlevs_G3
# STASH
- /g/data/vk83/configurations/inputs/access-esm1p5/share/atmosphere/stash/2020.05.19/

- name: ocean
model: mom
ncpus: 180
exe: fms_ACCESS-CM.x
input:
# Biogeochemistry
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/ocean/biogeochemistry/global.1deg/2020.05.19/dust.nc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/ocean/biogeochemistry/global.1deg/2020.05.19/ocmip2_press_monthly_om1p5_bc.nc
- /g/data/vk83/configurations/inputs/access-esm1p5/share/ocean/biogeochemistry/global.1deg/2024.07.12/bgc_param.nc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/unused/ocean/biogeochemistry/global.1deg/2020.05.19/ocmip2_fice_monthly_om1p5_bc.nc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/unused/ocean/biogeochemistry/global.1deg/2020.05.19/ocmip2_xkw_monthly_om1p5_bc.nc
# Tides
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/ocean/tides/global.1deg/2020.05.19/roughness_amp.nc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/ocean/tides/global.1deg/2020.05.19/tideamp.nc
# Shortwave
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/ocean/shortwave_penetration/global.1deg/2020.05.19/ssw_atten_depth.nc
# Grids
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/ocean/grids/mosaic/global.1deg/2020.05.19/grid_spec.nc

- name: ice
model: cice
ncpus: 12
exe: cice_access_360x300_12x1_12p.exe
input:
# Grids
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/ice/grids/global.1deg/2020.05.19/kmt.nc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/ice/grids/global.1deg/2020.05.19/grid.nc
# Climatology
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/ice/climatology/global.1deg/2020.05.19/monthly_sstsss.nc

- name: coupler
model: oasis
ncpus: 0
input:
# Grids
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/coupler/grids/global.oi_1deg.a_N96/2020.05.19/grids.nc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/coupler/grids/global.oi_1deg.a_N96/2020.05.19/areas.nc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/coupler/grids/global.oi_1deg.a_N96/2020.05.19/masks.nc
# Remapping weights
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/coupler/remapping_weights/global.oi_1deg.a_N96/2020.05.19/rmp_cice_to_um1t_CONSERV_FRACNNEI.nc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/coupler/remapping_weights/global.oi_1deg.a_N96/2020.05.19/rmp_um1u_to_cice_CONSERV_FRACNNEI.nc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/coupler/remapping_weights/global.oi_1deg.a_N96/2020.05.19/rmp_um1t_to_cice_CONSERV_DESTAREA.nc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/coupler/remapping_weights/global.oi_1deg.a_N96/2020.05.19/rmp_cice_to_um1u_CONSERV_FRACNNEI.nc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/coupler/remapping_weights/global.oi_1deg.a_N96/2020.05.19/rmp_um1v_to_cice_CONSERV_FRACNNEI.nc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/coupler/remapping_weights/global.oi_1deg.a_N96/2020.05.19/rmp_um1t_to_cice_CONSERV_FRACNNEI.nc
- /g/data/vk83/configurations/inputs/access-esm1p5/modern/share/coupler/remapping_weights/global.oi_1deg.a_N96/2020.05.19/rmp_cice_to_um1v_CONSERV_FRACNNEI.nc

# Collation
collate:
exe: mppnccombine.spack
restart: true
mem: 4GB
walltime: 1:00:00
mpi: false

restart: /g/data/vk83/configurations/inputs/access-esm1p5/modern/pre-industrial/restart/

# Timing controls
calendar:
start:
year: 101
month: 1
days: 1

runtime:
years: 1
months: 0
days: 0

runspersub: 1

# Misc
restart_freq: 10YS

runlog: true
manifest:
reproduce:
exe: True


stacksize: unlimited
qsub_flags: -W umask=027


# Sync options for automatically copying data from ephemeral scratch space to
# longer term storage
sync:
enable: False # set path below and change to true
path: null # Set to location on /g/data or a remote server and path (rsync syntax)

# If a postscript included (such as the automated netcdf conversion), the latest output and restart files will not
# be automatically synced at the end of a run. To sync the latest output after a postscript has completed,
# manually run `payu sync` from the command line.

# userscripts:

postscript: -v PAYU_CURRENT_OUTPUT_DIR,PROJECT -lstorage=${PBS_NCI_STORAGE} ./scripts/NetCDF-conversion/UM_conversion_job.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
&setup_nml
days_per_year = 365
, year_init = 0001
, istep0 = 0
/
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
&setup_nml
, histfreq = 'd','m','x','x','x'
, histfreq_n = 1, 1, 1, 1, 1
, hist_avg = .true.
/

&icefields_nml
mock_field = .true.
/
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
format: yamanifest
version: 1.0
---
work/atmosphere/um_hg3.exe:
fullpath: /g/data/vk83/apps/spack/0.22/restricted/ukmo/release/linux-rocky8-x86_64_v4/intel-19.0.3.199/um7-git.2024.07.03_access-esm1.5-kgxooyp2s476dd4zc5mgtwhxfknkhnoe/bin/um_hg3.exe
hashes:
binhash: 3180dda616c7dfe63d8134e00bff2641
md5: 1b7874ffb5e34ec50b6a68abbb7769a6
work/ice/cice_access_360x300_12x1_12p.exe:
fullpath: /g/data/vk83/apps/spack/0.22/restricted/ukmo/release/linux-rocky8-x86_64_v4/intel-19.0.3.199/cice4-git.2024.05.21_access-esm1.5-hhtnigwxdyz7ta4dv3gvhwulze6hxqra/bin/cice_access_360x300_12x1_12p.exe
hashes:
binhash: 818f213e53d30fc307b565c35939382c
md5: 04fd88249ebc16e3f560fc265838e9d1
work/ocean/fms_ACCESS-CM.x:
fullpath: /g/data/vk83/apps/spack/0.22/restricted/ukmo/release/linux-rocky8-x86_64_v4/intel-19.0.3.199/mom5-git.access-esm1.5_2024.06.20_access-esm1.5-wxxrc3ivrjz76yx565ddkuuiwoqpalko/bin/fms_ACCESS-CM.x
hashes:
binhash: a7a3151fb1b814f9e94f05e637b86a44
md5: 241db68e6164fac77c59da99ffb1d3b1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
contact: Add your name here
email: Add your email address here
created: Add the date you started the experiment here (YYYY-MM-DD)
description: |-
ACCESS-ESM1.5 global coupled model configuration running in co2 concentration driven mode under pre-industrial forcings, as described in Ziehn et al. (2020), https://doi.org/10.1071/ES19035.
Pre-industrial forcing data including atmospheric co2 concentrations are primarily sourced from UKMO versions of CMIP6 inputs, with additional atmospheric forcings sourced from CMIP5 and land cover data adapted from Lawrence et al. (2012), https://doi.org/10.1175/JCLI-D-11-00256.1.
notes: |-
The developers of ACCESS-ESM1.5 request that users of these model configurations:
(a) Cite https://doi.org/10.1071/ES19035
(b) Include an acknowledgment such as the following:
"The authors thank CSIRO for developing the ACCESS-ESM1.5 model configuration and making it freely available to researchers."
ACCESS-NRI requests users follow the guidelines for acknowledging ACCESS-NRI and include a statement such as:
"This research used the ACCESS-ESM1.5 model infrastructure provided by ACCESS-NRI, which is enabled by the Australian Government's National Collaborative Research Infrastructure Strategy (NCRIS)."
keywords:
- global
- access-esm1.5
realm:
- atmos
- land
- ocean
- ocnBgchem
- seaIce
nominal_resolution: 100 km
reference: https://doi.org/10.1071/ES19035
license: CC-BY-4.0
model: ACCESS-ESM1.5
version: '1.0'
url: https://github.com/ACCESS-NRI/access-esm1.5-configs.git
4 changes: 1 addition & 3 deletions tests/test_model_extract_checksums.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
import os
from pathlib import Path
from unittest.mock import Mock

Expand All @@ -8,10 +7,9 @@
import requests

from model_config_tests.models import index as model_index
from tests.common import RESOURCES_DIR

MODEL_NAMES = model_index.keys()
HERE = os.path.dirname(__file__)
RESOURCES_DIR = Path(f"{HERE}/resources")


@pytest.mark.parametrize("model_name", MODEL_NAMES)
Expand Down
Loading

0 comments on commit 34abb46

Please sign in to comment.