2013-03-25 12:04:10 +00:00
|
|
|
#!/bin/sh
|
2020-01-28 14:32:34 +00:00
|
|
|
# (C) Copyright 2005- ECMWF.
|
2013-03-25 12:04:10 +00:00
|
|
|
#
|
|
|
|
# This software is licensed under the terms of the Apache Licence Version 2.0
|
|
|
|
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
|
|
|
#
|
|
|
|
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
|
|
|
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
|
|
|
#
|
|
|
|
|
2022-04-03 22:02:48 +00:00
|
|
|
. ./include.ctest.sh
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2022-02-16 16:33:16 +00:00
|
|
|
label="grib_tigge_check_test"
|
2013-03-25 12:04:10 +00:00
|
|
|
REDIRECT=/dev/null
|
2022-02-16 16:33:16 +00:00
|
|
|
TEMP=temp.$label.tigge
|
2013-03-25 12:04:10 +00:00
|
|
|
|
|
|
|
dir="${data_dir}/tigge/"
|
|
|
|
|
2022-02-16 16:33:16 +00:00
|
|
|
# Parameter 168: at 2m and 1.5m above ground
|
|
|
|
# -------------------------------------------
|
|
|
|
sample_g2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
|
|
|
${tools_dir}/grib_filter -o $TEMP - $sample_g2 << EOF
|
|
|
|
set centre = "ammc";
|
|
|
|
set productionStatusOfProcessedData=4; # TIGGE
|
|
|
|
set discipline=0;
|
|
|
|
set parameterCategory=0;
|
|
|
|
set parameterNumber=6;
|
|
|
|
set typeOfFirstFixedSurface=103;
|
|
|
|
set scaledValueOfFirstFixedSurface=15;
|
|
|
|
set scaleFactorOfFirstFixedSurface=1;
|
|
|
|
write;
|
|
|
|
EOF
|
2022-02-16 16:34:55 +00:00
|
|
|
grib_check_key_equals $TEMP paramId,shortName '168 2d'
|
2022-02-16 16:33:16 +00:00
|
|
|
|
|
|
|
${tools_dir}/grib_filter -o $TEMP - $sample_g2 << EOF
|
|
|
|
set centre = "ammc";
|
|
|
|
set productionStatusOfProcessedData=4; # TIGGE
|
|
|
|
set discipline=0;
|
|
|
|
set parameterCategory=0;
|
|
|
|
set parameterNumber=6;
|
|
|
|
set typeOfFirstFixedSurface=103;
|
|
|
|
set scaledValueOfFirstFixedSurface=2;
|
|
|
|
set scaleFactorOfFirstFixedSurface=0;
|
|
|
|
write;
|
|
|
|
EOF
|
2022-02-16 16:34:55 +00:00
|
|
|
grib_check_key_equals $TEMP paramId,shortName '168 2d'
|
2022-02-16 16:33:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Check tigge global
|
|
|
|
# ------------------
|
|
|
|
for file in ${dir}tigge_*.grib; do
|
2017-02-03 14:22:21 +00:00
|
|
|
${tigge_dir}/tigge_check ${file} 2> $REDIRECT > $REDIRECT
|
2013-03-25 12:04:10 +00:00
|
|
|
done
|
|
|
|
|
2022-02-16 16:33:16 +00:00
|
|
|
# Check tigge-lam
|
|
|
|
# ------------------
|
|
|
|
for file in ${dir}tiggelam_*.grib; do
|
2017-02-03 14:22:21 +00:00
|
|
|
${tigge_dir}/tigge_check -l ${file} 2> $REDIRECT > $REDIRECT
|
2013-03-25 12:04:10 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
|
2016-08-15 15:48:09 +00:00
|
|
|
# Test non-TIGGE files too. We now expect tigge_check to fail!
|
|
|
|
# All the GRIB files in the samples are non-TIGGE
|
2022-02-16 16:33:16 +00:00
|
|
|
# -------------------------------------------------------------
|
2016-08-15 15:48:09 +00:00
|
|
|
for file in ${ECCODES_SAMPLES_PATH}/regular_*.tmpl; do
|
2014-06-18 16:14:01 +00:00
|
|
|
set +e
|
2017-02-03 14:22:21 +00:00
|
|
|
${tigge_dir}/tigge_check ${file} 2> $REDIRECT > $REDIRECT
|
2014-06-18 16:14:01 +00:00
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
if [ $status -eq 0 ]; then
|
2014-03-31 12:57:06 +00:00
|
|
|
# should have failed and returned a non-zero exit code
|
|
|
|
exit 1
|
|
|
|
fi
|
2013-03-25 12:04:10 +00:00
|
|
|
done
|
|
|
|
|
2022-02-16 16:33:16 +00:00
|
|
|
|
2014-06-18 16:14:01 +00:00
|
|
|
# GRIB-531
|
2022-02-16 16:33:16 +00:00
|
|
|
# ---------
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_get -nparameter ${data_dir}/tigge_pf_ecmwf.grib2 > $TEMP
|
2014-06-18 16:14:01 +00:00
|
|
|
diff ${data_dir}/tigge_pf_ecmwf.grib2.ref $TEMP
|
|
|
|
|
2022-02-16 16:33:16 +00:00
|
|
|
# GRIB-205. Changing productionStatusOfProcessedData
|
|
|
|
# should not change anything else
|
|
|
|
# ---------------------------------------------------
|
2014-08-15 10:54:12 +00:00
|
|
|
input=${dir}/tigge_ecmf_sfc_sd.grib
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_set -s productionStatusOfProcessedData=5 $input $TEMP
|
|
|
|
${tools_dir}/grib_compare -bproductionStatusOfProcessedData $input $TEMP
|
2014-08-15 10:54:12 +00:00
|
|
|
|
2014-06-18 16:14:01 +00:00
|
|
|
rm -f $TEMP
|
2016-08-15 15:48:09 +00:00
|
|
|
|
|
|
|
# GRIB-757 validity date/time check fails for the following:
|
|
|
|
tigge_bad_validity="
|
|
|
|
tigge_kwbc_sfc_sf.grib
|
|
|
|
tigge_kwbc_sfc_slhf.grib
|
|
|
|
tigge_kwbc_sfc_sshf.grib
|
|
|
|
tigge_kwbc_sfc_ssr.grib
|
|
|
|
tigge_kwbc_sfc_str.grib
|
|
|
|
tigge_kwbc_sfc_ttr.grib
|
|
|
|
"
|
|
|
|
for file in $tigge_bad_validity; do
|
|
|
|
set +e
|
2017-02-03 14:22:21 +00:00
|
|
|
${tigge_dir}/tigge_check -w ${dir}${file} > $TEMP
|
2016-08-15 15:48:09 +00:00
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -eq 1 ]
|
|
|
|
cat $TEMP
|
|
|
|
grep -q "invalid validity Date/Time" $TEMP
|
|
|
|
done
|
|
|
|
|
2022-07-17 10:42:16 +00:00
|
|
|
|
|
|
|
# ECC-1428
|
|
|
|
# ----------
|
|
|
|
set +e
|
|
|
|
${tools_dir}/grib_set -s productionStatusOfProcessedData=5,marsType=xx $sample_g2 $TEMP
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -ne 0 ]
|
|
|
|
|
2023-04-17 18:25:20 +00:00
|
|
|
# ECC-1081
|
|
|
|
# ---------
|
|
|
|
${tools_dir}/grib_set -s level=2 ${data_dir}/tigge/tigge_ecmf_pv_pt.grib $TEMP
|
|
|
|
grib_check_key_equals $TEMP level 2
|
|
|
|
# ${tools_dir}/grib_dump -O -p section_4 $TEMP
|
|
|
|
${tools_dir}/grib_compare ${data_dir}/tigge/tigge_ecmf_pv_pt.grib $TEMP
|
|
|
|
|
2022-07-17 10:42:16 +00:00
|
|
|
|
2016-08-15 15:48:09 +00:00
|
|
|
rm -f $TEMP
|