Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/ersem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,25 @@ jobs:
python -m pip install pytest
pytest github-actions/gotm-fabm-ersem/test_state_variables.py github-actions/gotm-fabm-ersem/test_gotm.py

test-gotm-testcase-yamls-debian:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Installing GOTM-FABM-ERSEM dependences
run: ./github-actions/gotm-fabm-ersem/gotm-fabm-ersem-dep-debian.sh
- name: Building and installing GOTM-FABM-ERSEM
run: |
BRANCH=${{ github.head_ref }}
./github-actions/gotm-fabm-ersem/gotm-fabm-ersem-build.sh -b $BRANCH -f '-DCMAKE_Fortran_FLAGS="-fcheck=all"'
- name: Running GOTM testcase YAML tests
run: |
python -m pip install pytest
pytest github-actions/gotm-fabm-ersem/test_testcase_yamls.py

build-fabm0d-gotm-ersem-debian:
runs-on: ubuntu-latest
steps:
Expand Down
60 changes: 60 additions & 0 deletions github-actions/gotm-fabm-ersem/gotm-testcase-yaml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

set -euo pipefail

if [ "$#" -ne 1 ]; then
echo "Usage: $0 <testcase-yaml>" >&2
exit 2
fi

TESTCASE_YAML="$1"
if [ ! -f "${TESTCASE_YAML}" ]; then
echo "Testcase YAML not found: ${TESTCASE_YAML}" >&2
exit 2
fi

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_DIR="$(cd "${SCRIPT_DIR}/../.." && pwd)"
SETUPS_DIR="${GOTM_ERSEM_SETUPS_DIR:-${REPO_DIR}/ersem-setups}"
L4_DIR="${SETUPS_DIR}/L4"
GOTM_BIN="${GOTM_BIN:-${HOME}/local/gotm/bin/gotm}"
GOTM_TEST_STOP="${GOTM_TEST_STOP:-2007-02-01 00:00:00}"

if [ ! -x "${GOTM_BIN}" ]; then
echo "GOTM executable not found or not executable: ${GOTM_BIN}" >&2
exit 2
fi

if [ ! -d "${SETUPS_DIR}" ]; then
echo "Cloning config repo"
git clone https://github.com/pmlmodelling/ersem-setups.git "${SETUPS_DIR}"
fi

ORIGINAL_GOTM_YAML="$(mktemp "${L4_DIR}/gotm.yaml.original.XXXXXX")"
TEST_GOTM_YAML="$(mktemp "${L4_DIR}/gotm.yaml.testcase.XXXXXX")"
cp "${L4_DIR}/gotm.yaml" "${ORIGINAL_GOTM_YAML}"

cleanup() {
cp "${ORIGINAL_GOTM_YAML}" "${L4_DIR}/gotm.yaml"
rm -f "${ORIGINAL_GOTM_YAML}" "${TEST_GOTM_YAML}"
}
trap cleanup EXIT

awk -v stop="${GOTM_TEST_STOP}" '
/^time:[[:space:]]*$/ { in_time = 1 }
/^[^[:space:]]/ && !/^time:[[:space:]]*$/ { in_time = 0 }
in_time && /^[[:space:]]+stop:[[:space:]]/ {
sub(/stop:.*/, "stop: " stop)
updated = 1
}
{ print }
END { if (!updated) exit 1 }
' "${L4_DIR}/gotm.yaml" > "${TEST_GOTM_YAML}"

echo "Running GOTM with testcase YAML: ${TESTCASE_YAML}"
echo "Using temporary gotm.yaml stop date: ${GOTM_TEST_STOP}"
cp "${TEST_GOTM_YAML}" "${L4_DIR}/gotm.yaml"
cp "${TESTCASE_YAML}" "${L4_DIR}/fabm.yaml"
cd "${L4_DIR}"

"${GOTM_BIN}" --ignore_unknown_config
42 changes: 42 additions & 0 deletions github-actions/gotm-fabm-ersem/test_testcase_yamls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""
Check that GOTM runs with every testcase YAML configuration.
"""

import subprocess
from pathlib import Path

import pytest


REPO_DIR = Path(__file__).resolve().parents[2]
TESTCASE_DIR = REPO_DIR / "testcases"
RUNNER = Path(__file__).with_name("gotm-testcase-yaml.sh")

YAML_PATTERNS = ("*.yaml", "*.yml")
TESTCASE_YAMLS = sorted(
{path for pattern in YAML_PATTERNS for path in TESTCASE_DIR.rglob(pattern)}
)


def yaml_id(path):
return path.relative_to(TESTCASE_DIR).as_posix()


@pytest.mark.parametrize("testcase_yaml", TESTCASE_YAMLS, ids=yaml_id)
def test_gotm_runs_with_testcase_yaml(testcase_yaml):
"""
Run GOTM with an ERSEM testcase YAML copied to the L4 setup.
"""
result = subprocess.run(
["bash", str(RUNNER), str(testcase_yaml)],
cwd=REPO_DIR,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)

assert result.returncode == 0, (
f"GOTM failed for {testcase_yaml.relative_to(REPO_DIR)}\n"
f"stdout:\n{result.stdout}\n"
f"stderr:\n{result.stderr}"
)
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.04 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.2 # respired fraction of primary production (-)
qnlc: 0.0042 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.0001 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down Expand Up @@ -352,6 +353,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.04 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.2 # respired fraction of primary production (-)
qnlc: 0.005 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.000225 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down Expand Up @@ -415,6 +417,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.045 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.2 # respired fraction of primary production (-)
qnlc: 0.006 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.00035 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down Expand Up @@ -475,6 +478,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.035 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.2 # respired fraction of primary production (-)
qnlc: 0.0042 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.0001 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.04 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.2 # respired fraction of primary production (-)
qnlc: 0.0042 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.0001 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down Expand Up @@ -345,6 +346,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.04 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.2 # respired fraction of primary production (-)
qnlc: 0.005 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.000225 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down Expand Up @@ -408,6 +410,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.045 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.2 # respired fraction of primary production (-)
qnlc: 0.006 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.00035 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down Expand Up @@ -468,6 +471,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.035 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.2 # respired fraction of primary production (-)
qnlc: 0.0042 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.0001 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down
4 changes: 4 additions & 0 deletions testcases/ersem-15.06/fabm-ersem-15.06-L4-ben-docdyn-iop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.04 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.2 # respired fraction of primary production (-)
qnlc: 0.0042 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.0001 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down Expand Up @@ -335,6 +336,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.04 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.2 # respired fraction of primary production (-)
qnlc: 0.005 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.000225 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down Expand Up @@ -398,6 +400,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.045 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.2 # respired fraction of primary production (-)
qnlc: 0.006 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.00035 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down Expand Up @@ -458,6 +461,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.035 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.2 # respired fraction of primary production (-)
qnlc: 0.0042 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.0001 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.04 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.2 # respired fraction of primary production (-)
qnlc: 0.0042 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.0001 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down Expand Up @@ -339,6 +340,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.04 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.2 # respired fraction of primary production (-)
qnlc: 0.005 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.000225 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down Expand Up @@ -402,6 +404,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.045 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.2 # respired fraction of primary production (-)
qnlc: 0.006 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.00035 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down Expand Up @@ -462,6 +465,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.035 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.2 # respired fraction of primary production (-)
qnlc: 0.0042 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.0001 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.05 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.05 # excreted fraction of primary production (-)
exulim: 0.95 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.1 # respired fraction of primary production (-)
qnlc: 0.00687 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.000428 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down Expand Up @@ -321,6 +322,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.05 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.25 # respired fraction of primary production (-)
qnlc: 0.00687 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.000428 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down Expand Up @@ -383,6 +385,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.05 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.2 # excreted fraction of primary production (-)
exulim: 0.8 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.25 # respired fraction of primary production (-)
qnlc: 0.00687 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.000428 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down Expand Up @@ -442,6 +445,7 @@ instances:
q10: 2.0 # Q_10 temperature coefficient (-)
srs: 0.05 # specific rest respiration at reference temperature (1/d)
pu_ea: 0.05 # excreted fraction of primary production (-)
exulim: 0.95 # excreted fraction of primary production due to nutrient stress,maximum=1._rk-self%pu_ea
pu_ra: 0.25 # respired fraction of primary production (-)
qnlc: 0.00687 # minimum nitrogen to carbon ratio (mmol N/mg C)
qplc: 0.000428 # minimum phosphorus to carbon ratio (mmol P/mg C)
Expand Down
Loading
Loading