Skip to content

Commit 4ee421d

Browse files
Merge pull request #84 from mvdebolskiy/fix/download-data
Fix download test data script.
2 parents d6b5c8e + 2ef74da commit 4ee421d

File tree

3 files changed

+46
-21
lines changed

3 files changed

+46
-21
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
**.o
2+
**.a
3+
**.mod
4+
driver/run/cosp2_test
5+
driver/data/inputs/UKMO/*_global.nc
6+
driver/data/outputs/UKMO/*kgo.v*.nc
7+
driver/data/outputs/UKMO/*.nc
8+
!driver/data/outputs/cosp2_output_um.gfortran.kgo.nc
9+
driver/data/outputs/UKMO/*md5
10+
driver/data/outputs/UKMO/*.out

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ The offline drivers read sample snapshots from the Met Office Unified Model, use
5050

5151
`./cosp2_test cosp2_input_nl.um_global.txt`
5252

53-
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.
53+
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`)
5454

5555
1. Regression testing (comparing to reference data)
5656
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/`.
57-
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:
57+
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`:
5858

59-
`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`
59+
`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`
6060

6161
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.

driver/download_test_data.sh

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,40 @@
1-
KGO_VERSION=v001
1+
#/bin/bash
2+
3+
if [[ -n ${KGO_VERSION} ]] ; then
4+
echo "KGO_VERSION=$KGO_VERSION"
5+
else
6+
export KGO_VERSION=v003
7+
echo "set KGO_VERSION=$KGO_VERSION"
8+
fi
9+
10+
11+
kgo_links=( "https://docs.google.com/uc?export=download&id=1oQBJGFg0F8k-LhRGsCYn-qWzmMMVfQ6K" \
12+
"https://docs.google.com/uc?export=download&id=1b7qwJWqDzoZGcIP0qyUprTV_LErCGpT6" \
13+
"https://docs.google.com/uc?export=download&id=1NvTo3bYaGpz-FUpZ4jta_kRzA04xTCsn" )
14+
15+
out_type=( "cosp2_output_um.gfortran.kgo" \
16+
"cosp2_output.um_global.gfortran.kgo" \
17+
"cosp2_output.um_global_model_levels.gfortran.kgo" )
18+
219
# Input: global UM
320
DRIVER_DIR=${PWD}
421
GDFILE='https://docs.google.com/uc?export=download&id=17eK4_DVEvFOE9Uf6siXJDpWZJKT1aqkU'
522
OUTPATH=data/inputs/UKMO/cosp_input.um_global.nc.gz
623
wget --no-check-certificate $GDFILE -O $OUTPATH
7-
gunzip ${OUTPATH}
24+
gunzip -f ${OUTPATH}
825
cd data/inputs/UKMO
926
md5sum -c cosp_input.um_global.nc.md5
10-
# KGO: global UM
11-
cd ${DRIVER_DIR}
12-
GDFILE='https://docs.google.com/uc?export=download&id=1uQBPUEXlniQWEp2nU3iC6d8CO3GM9cvP'
13-
OUTPATH=data/outputs/UKMO/cosp2_output.um_global.gfortran.kgo.$KGO_VERSION.nc.gz
14-
wget --no-check-certificate $GDFILE -O $OUTPATH
15-
gunzip ${OUTPATH}
16-
cd data/outputs/UKMO
17-
md5sum -c cosp2_output.um_global.gfortran.kgo.$KGO_VERSION.nc.md5
18-
# KGO: UM
19-
cd ${DRIVER_DIR}
20-
GDFILE='https://docs.google.com/uc?export=download&id=1gSEdJJpqhfElsFNcTF_r4A_0vIMEWGla'
21-
OUTPATH=data/outputs/UKMO/cosp2_output_um.gfortran.kgo.$KGO_VERSION.nc.gz
22-
wget --no-check-certificate $GDFILE -O $OUTPATH
23-
gunzip ${OUTPATH}
24-
cd data/outputs/UKMO
25-
md5sum -c cosp2_output_um.gfortran.kgo.$KGO_VERSION.nc.md5
27+
28+
if [[ ${KGO_VERSION} == "v002" ]] ; then
29+
for i in ${!kgo_links[@]}; do
30+
cd ${DRIVER_DIR}
31+
GDFILE=${kgo_links[$i]}
32+
OUTPATH=data/outputs/UKMO/${out_type[$i]}.$KGO_VERSION.nc.gz
33+
wget --no-check-certificate $GDFILE -O $OUTPATH
34+
gunzip -f ${OUTPATH}
35+
cd data/outputs/UKMO
36+
md5sum -c ${out_type[$i]}.$KGO_VERSION.nc.md5
37+
done
38+
else
39+
echo "wrong KGO_VERSION supplied, try 'export KGO_VERSION=v002'"
40+
fi

0 commit comments

Comments
 (0)