Skip to content

Commit 0aa5d45

Browse files
Merge pull request #88 from CFMIP/ci_workflow_test
Split CI workflows into gfortran and containerized
2 parents c60fbc6 + 6b55443 commit 0aa5d45

9 files changed

+221
-184
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
# Maintain dependencies for GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "daily"
8+
target-branch: "master"
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Continuous integration in containers
2+
on: [push, pull_request, workflow_dispatch]
3+
4+
jobs:
5+
Containerized-CI:
6+
runs-on: ubuntu-22.04
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
compiler: [ifort, ifx]
11+
include:
12+
# Flags and KGOs for Intel Fortran Compiler Classic
13+
- compiler: ifort
14+
fcflags: -m64 -g -traceback -heap-arrays -assume realloc_lhs -extend-source 132 -check bounds,uninit,pointers,stack -stand f08
15+
gdkgo1: https://docs.google.com/uc?export=download&id=1TpXY-vXkwAnym9nNjzUxt1q_8c8T7X8T
16+
gdkgo2: https://docs.google.com/uc?export=download&id=1ic-2B3dIx1kIoi-Nd1ndLbLAe_LIWDGP
17+
# Flags and KGOs for Intel Fortran Compiler
18+
- compiler: ifx
19+
fcflags: -debug -traceback -O0 -heap-arrays -assume realloc_lhs -extend-source 132 -stand f08
20+
gdkgo1: https://docs.google.com/uc?export=download&id=19N7wXou-2Zv0oVAnwn4Ucs8Ghr-C0SMt
21+
gdkgo2: https://docs.google.com/uc?export=download&id=1EUO6C_v0rq0NMXkLGqZDKX99kknnMRQN
22+
# Set container images
23+
- compiler: ifort
24+
image: ghcr.io/earth-system-radiation/rte-rrtmgp-ci:oneapi
25+
- compiler: ifx
26+
image: ghcr.io/earth-system-radiation/rte-rrtmgp-ci:oneapi
27+
container:
28+
image: ${{ matrix.image }}
29+
env:
30+
F90: ${{ matrix.compiler }}
31+
FC: ${{ matrix.compiler }}
32+
F90FLAGS: ${{ matrix.fcflags }}
33+
# Make variables:
34+
NFHOME: /opt/netcdf-fortran
35+
# KGO tests variables
36+
ATOL: 0.0
37+
RTOL: 0.0
38+
KGO_VERSION: v002
39+
GDKGO1: ${{ matrix.gdkgo1 }}
40+
GDKGO2: ${{ matrix.gdkgo2 }}
41+
steps:
42+
#
43+
# Checks-out repository under $GITHUB_WORKSPACE
44+
#
45+
- uses: actions/checkout@v4
46+
47+
###############################################################################
48+
# Build COSP and retrieve input and test files
49+
###############################################################################
50+
# Build COSP2 driver. Intel Fortran stores automatic arrays in the stack
51+
# by default, whereas GNU Fortran stores them in the heap. This can cause
52+
# segmentation faults with ifort, especially in memory-intensive applications
53+
# like COSP. We tell ifort to use heap arrays.
54+
- name: Build driver
55+
run: |
56+
${F90} --version
57+
cd build
58+
make -j driver
59+
# Retrieve and expand large data files
60+
- name: Retrieve input files
61+
run: |
62+
GDFILE='https://docs.google.com/uc?export=download&id=17eK4_DVEvFOE9Uf6siXJDpWZJKT1aqkU'
63+
OUTPATH=driver/data/inputs/UKMO/cosp_input.um_global.nc.gz
64+
curl -sSfL -o $OUTPATH $GDFILE
65+
gunzip ${OUTPATH}
66+
cd driver/data/inputs/UKMO
67+
md5sum -c cosp_input.um_global.nc.md5
68+
- name: Retrieve KGOs for basic test
69+
run: |
70+
cd ${GITHUB_WORKSPACE}
71+
OUTPATH=driver/data/outputs/UKMO/cosp2_output_um.$F90.kgo.$KGO_VERSION.nc.gz
72+
curl -sSfL -o $OUTPATH $GDKGO1
73+
gunzip ${OUTPATH}
74+
cd driver/data/outputs/UKMO
75+
# md5sum -c cosp2_output_um.${F90}.kgo.$KGO_VERSION.nc.md5
76+
- name: Retrieve KGOs for global test
77+
run: |
78+
cd ${GITHUB_WORKSPACE}
79+
OUTPATH=driver/data/outputs/UKMO/cosp2_output.um_global.${F90}.kgo.$KGO_VERSION.nc.gz
80+
curl -sSfL -o $OUTPATH $GDKGO2
81+
gunzip ${OUTPATH}
82+
cd driver/data/outputs/UKMO
83+
# md5sum -c cosp2_output.um_global.${F90}.kgo.$KGO_VERSION.nc.md5
84+
###############################################################################
85+
# Run COSP2 tests. Basic test and UM global snapshot
86+
###############################################################################
87+
- name: Basic test and UM global snapshot
88+
run: |
89+
cd driver/run
90+
./cosp2_test cosp2_input_nl.txt
91+
./cosp2_test cosp2_input_nl.um_global.txt
92+
###############################################################################
93+
# Compare results against known good outputs. As above,
94+
# we split it in as many steps as tests.
95+
###############################################################################
96+
# 1. Basic test
97+
- name: Basic against known good output (KGO)
98+
run: |
99+
cd driver
100+
KGO=data/outputs/UKMO/cosp2_output_um.${F90}.kgo.$KGO_VERSION.nc
101+
TST=data/outputs/UKMO/cosp2_output_um.nc
102+
python compare_to_kgo.py ${KGO} ${TST} --atol=${ATOL} --rtol=${RTOL}
103+
# 2. UM global snapshot.
104+
- name: UM global against known good output (KGO)
105+
run: |
106+
cd driver
107+
KGO=data/outputs/UKMO/cosp2_output.um_global.${F90}.kgo.$KGO_VERSION.nc
108+
TST=data/outputs/UKMO/cosp2_output.um_global.nc
109+
python compare_to_kgo.py ${KGO} ${TST} --atol=${ATOL} --rtol=${RTOL}
110+
###############################################################################
111+
# Produce plots when it fails during global snapshot tests,
112+
# and create a tarball with outputs.
113+
###############################################################################
114+
- name: Produce plots and create tarball
115+
if: failure()
116+
run: |
117+
TST_MLEV=data/outputs/UKMO/cosp2_output.um_global_model_levels.nc
118+
cd driver
119+
if [[ -e data/outputs/UKMO/cosp2_output.um_global.nc ]]; then
120+
python plot_test_outputs.py
121+
fi
122+
if [[ -e data/outputs/UKMO/cosp2_output.um_global_model_levels.nc ]]; then
123+
python plot_test_outputs.py --tst_file=$TST_MLEV
124+
fi
125+
cd data/outputs/UKMO
126+
tar --ignore-failed-read -czf outputs.UKMO.tgz cosp2_output.um_global.nc \
127+
cosp2_output_um.nc cosp2_output.um_global_model_levels.nc *.png \
128+
cosp2_output.um_global.out
129+
ls -lh
130+
###############################################################################
131+
# Make output files available if any test fails
132+
###############################################################################
133+
- name: Upload output file if test fails
134+
if: failure()
135+
uses: actions/upload-artifact@v1.0.0
136+
with:
137+
name: outputs.UKMO.tgz
138+
path: driver/data/outputs/UKMO/outputs.UKMO.tgz

0 commit comments

Comments
 (0)