Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix download test data script. #84

Merged
merged 20 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
10 changes: 5 additions & 5 deletions .github/workflows/containerized-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ jobs:
# Flags and KGOs for Intel Fortran Compiler Classic
- compiler: ifort
fcflags: -m64 -g -traceback -heap-arrays -assume realloc_lhs -extend-source 132 -check bounds,uninit,pointers,stack -stand f08
gdkgo1: https://docs.google.com/uc?export=download&id=1TpXY-vXkwAnym9nNjzUxt1q_8c8T7X8T
gdkgo2: https://docs.google.com/uc?export=download&id=1ic-2B3dIx1kIoi-Nd1ndLbLAe_LIWDGP
gdkgo1: https://docs.google.com/uc?export=download&id=1eyRCT9e7j7SKsKhbfJBuwBoN5DlsrW7L
gdkgo2: https://docs.google.com/uc?export=download&id=1uTffyCdWLPvRHDkVtZZiBfc3spbk4_Tf
# Flags and KGOs for Intel Fortran Compiler
- compiler: ifx
fcflags: -debug -traceback -O0 -heap-arrays -assume realloc_lhs -extend-source 132 -stand f08
gdkgo1: https://docs.google.com/uc?export=download&id=19N7wXou-2Zv0oVAnwn4Ucs8Ghr-C0SMt
gdkgo2: https://docs.google.com/uc?export=download&id=1EUO6C_v0rq0NMXkLGqZDKX99kknnMRQN
gdkgo1: https://docs.google.com/uc?export=download&id=1VrPkQmDpt6otch-tsaka-62tiMDuJNz_
gdkgo2: https://docs.google.com/uc?export=download&id=1m6JdHlSAMmK8zT-X3pfxSORPJURiITkQ
# Set container images
- compiler: ifort
image: ghcr.io/earth-system-radiation/rte-rrtmgp-ci:oneapi
- compiler: ifx
image: ghcr.io/earth-system-radiation/rte-rrtmgp-ci:oneapi
# Common variables
- kgo_version: v002
- kgo_version: v003
container:
image: ${{ matrix.image }}
env:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
python-version: [3.11]
include:
- compiler_short_name: gfortran
- kgo_version: v002
- kgo_version: v003
defaults:
run:
shell: bash -el {0}
Expand All @@ -53,9 +53,9 @@ jobs:
ATOL: 0.0
RTOL: 0.0
KGO_VERSION: ${{ matrix.kgo_version }}
GDKGO1: https://docs.google.com/uc?export=download&id=11dKcIL3EQr7s6jbo4f9GsoW0SufesGbq
GDKGO2: https://docs.google.com/uc?export=download&id=1s5Ha6Hqnv_hWbRUs8KQpJ4Lxy8uvJDar
GDKGO3: https://docs.google.com/uc?export=download&id=1kY1lRgzd0UhDiQef2u-VgTQql_iut3U2
GDKGO1: https://docs.google.com/uc?export=download&id=1oQBJGFg0F8k-LhRGsCYn-qWzmMMVfQ6K
GDKGO2: https://docs.google.com/uc?export=download&id=1b7qwJWqDzoZGcIP0qyUprTV_LErCGpT6
GDKGO3: https://docs.google.com/uc?export=download&id=1NvTo3bYaGpz-FUpZ4jta_kRzA04xTCsn
F90_SHORT_NAME: ${{ matrix.compiler_short_name }}
# Sequence of tasks that will be executed as part of the job
steps:
Expand Down
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**.o
**.a
**.mod
driver/run/cosp2_test
driver/data/inputs/UKMO/*_global.nc
driver/data/outputs/UKMO/*kgo.v*.nc
driver/data/outputs/UKMO/*.nc
!driver/data/outputs/cosp2_output_um.gfortran.kgo.nc
driver/data/outputs/UKMO/*md5
driver/data/outputs/UKMO/*.out
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ The offline drivers read sample snapshots from the Met Office Unified Model, use

`./cosp2_test cosp2_input_nl.um_global.txt`

Currently, there are 2 input namelists: `cosp2_input_nl.txt` uses a small test input file (`cosp_input.nc`), stored in the github repository; `cosp2_input_nl.um_global.txt` uses a global field (`cosp_input.um_global.nc`). The global input file and its associated known good output (`cosp2_output.um_global.gfortran.kgo.nc`) are stored externally in Google Drive, and they can be retrieved by running `download_test_data.sh` from within the `driver/` directory.
Currently, there are 2 input namelists: `cosp2_input_nl.txt` uses a small test input file (`cosp_input.nc`), stored in the github repository; `cosp2_input_nl.um_global.txt` uses a global field (`cosp_input.um_global.nc`). The global input file and its associated known good output (`cosp2_output.um_global.gfortran.kgo.vXXX.nc`) are stored externally in Google Drive, and they can be retrieved by running `download_test_data.sh` from within the `driver/` directory.`vXXX` represents the version of the known good output files, f.e. `v002`. You can set an environmet variable (f.e. if you are in bash shell: `export KGO_VERSION=v002`)

1. Regression testing (comparing to reference data)
1. Reference data or known good output (KGO) for a small test case is provided with COSP2. The data can be found at `driver/data/outputs/UKMO/`.
1. To compare driver output to the KGO, in `driver/`, invoke Python 3 script `compare_to_kgo.py`. This script requires the following Python modules: numpy, netCDF4, argparse, and sys. The following example shows how to call this script from the command line:
1. To compare driver output to the KGO, in `driver/`, invoke Python 3 script `compare_to_kgo.py`. This script requires the following Python modules: numpy, netCDF4, argparse, and sys. The following example shows how to call this script from the command line. Replace `vXXX` with the latest version you have acquired through `./download_test_data.sh`:

`python compare_to_kgo.py data/outputs/UKMO/cosp2_output_um.gfortran.kgo.nc data/outputs/UKMO/cosp2_output_um.nc --atol=1.0e-20 --rtol=0.0005`
`python compare_to_kgo.py data/outputs/UKMO/cosp2_output.um_global.gfortran.kgo.vXXX.nc data/outputs/UKMO/cosp2_output.um_global.nc --atol=1.0e-20 --rtol=0.0005`

The script accepts thresholds for absolute and relative tolerances, named `atol` and `rtol` respectively. By default the script will report all differences, i.e. `--atol=0.0 --rtol=0.0`. The example above allows for a relative tolerance of 0.05\% in the subset of absolute differences larger or equal than 1.0e-20. Previous tests indicate that these thresholds are appropriate when gfortran is used to build the driver program. If a different compiler is available, it is encouraged to build the driver using that compiler to increase the robustness of the tests. For non-gfortran compilers, the differences may be larger. This is not necessarily an issue, but further investigations may be required.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
75344f82d97187e351ed25a616fa1761 cosp2_output.um_global.gfortran.kgo.v003.nc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5194a0a17bc7eb5e9e95e8b8d8788953 cosp2_output.um_global.ifort.kgo.v003.nc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b9f700627457a1e7483d2150da3ef18d cosp2_output.um_global.ifx.kgo.v003.nc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dfe6a5f87e3e2e6a1399d067fa23e36d cosp2_output.um_global_model_levels.gfortran.kgo.v003.nc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7703e5395f4fff4961b97fe86621f996 cosp2_output_um.gfortran.kgo.v003.nc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0e75e4adac759d797d1264d76490fa9d cosp2_output_um.ifort.kgo.v003.nc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bcfb46c32c3f78df0771175a7a0b21b5 cosp2_output_um.ifx.kgo.v003.nc
51 changes: 33 additions & 18 deletions driver/download_test_data.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
KGO_VERSION=v001
#/bin/bash

if [[ -n ${KGO_VERSION} ]] ; then
echo "KGO_VERSION=$KGO_VERSION"
else
export KGO_VERSION=v003
echo "set KGO_VERSION=$KGO_VERSION"
fi


kgo_links=( "https://docs.google.com/uc?export=download&id=1oQBJGFg0F8k-LhRGsCYn-qWzmMMVfQ6K" \
"https://docs.google.com/uc?export=download&id=1b7qwJWqDzoZGcIP0qyUprTV_LErCGpT6" \
"https://docs.google.com/uc?export=download&id=1NvTo3bYaGpz-FUpZ4jta_kRzA04xTCsn" )

out_type=( "cosp2_output_um.gfortran.kgo" \
"cosp2_output.um_global.gfortran.kgo" \
"cosp2_output.um_global_model_levels.gfortran.kgo" )

# Input: global UM
DRIVER_DIR=${PWD}
GDFILE='https://docs.google.com/uc?export=download&id=17eK4_DVEvFOE9Uf6siXJDpWZJKT1aqkU'
OUTPATH=data/inputs/UKMO/cosp_input.um_global.nc.gz
wget --no-check-certificate $GDFILE -O $OUTPATH
gunzip ${OUTPATH}
gunzip -f ${OUTPATH}
cd data/inputs/UKMO
md5sum -c cosp_input.um_global.nc.md5
# KGO: global UM
cd ${DRIVER_DIR}
GDFILE='https://docs.google.com/uc?export=download&id=1uQBPUEXlniQWEp2nU3iC6d8CO3GM9cvP'
OUTPATH=data/outputs/UKMO/cosp2_output.um_global.gfortran.kgo.$KGO_VERSION.nc.gz
wget --no-check-certificate $GDFILE -O $OUTPATH
gunzip ${OUTPATH}
cd data/outputs/UKMO
md5sum -c cosp2_output.um_global.gfortran.kgo.$KGO_VERSION.nc.md5
# KGO: UM
cd ${DRIVER_DIR}
GDFILE='https://docs.google.com/uc?export=download&id=1gSEdJJpqhfElsFNcTF_r4A_0vIMEWGla'
OUTPATH=data/outputs/UKMO/cosp2_output_um.gfortran.kgo.$KGO_VERSION.nc.gz
wget --no-check-certificate $GDFILE -O $OUTPATH
gunzip ${OUTPATH}
cd data/outputs/UKMO
md5sum -c cosp2_output_um.gfortran.kgo.$KGO_VERSION.nc.md5

if [[ ${KGO_VERSION} == "v002" ]] ; then
for i in ${!kgo_links[@]}; do
cd ${DRIVER_DIR}
GDFILE=${kgo_links[$i]}
OUTPATH=data/outputs/UKMO/${out_type[$i]}.$KGO_VERSION.nc.gz
wget --no-check-certificate $GDFILE -O $OUTPATH
gunzip -f ${OUTPATH}
cd data/outputs/UKMO
md5sum -c ${out_type[$i]}.$KGO_VERSION.nc.md5
done
else
echo "wrong KGO_VERSION supplied, try 'export KGO_VERSION=v002'"
fi
Loading