2016-05-04 15:04:21 +00:00
|
|
|
#!/bin/sh
|
2020-01-28 14:32:34 +00:00
|
|
|
# (C) Copyright 2005- ECMWF.
|
2016-05-04 15:04:21 +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
|
2016-05-04 15:04:21 +00:00
|
|
|
|
2021-11-10 12:09:19 +00:00
|
|
|
label="grib_check_param_concepts_test"
|
2024-10-10 16:37:44 +00:00
|
|
|
tempText=temp.$label.txt
|
|
|
|
tempGrib=temp.$label.grib
|
2024-01-09 13:13:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
if [ $ECCODES_ON_WINDOWS -eq 1 ]; then
|
|
|
|
echo "$0: This test is currently disabled on Windows"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2024-08-31 12:19:52 +00:00
|
|
|
check_grib_defs()
|
|
|
|
{
|
2024-09-03 15:51:43 +00:00
|
|
|
CHECK_DEFS=$proj_dir/definitions/check_grib_defs.pl
|
2024-08-31 12:19:52 +00:00
|
|
|
if [ -x "$CHECK_DEFS" ]; then
|
|
|
|
# Now check the name.def, paramId.def, shortName.def... files
|
|
|
|
# in the current directory
|
|
|
|
$CHECK_DEFS
|
|
|
|
fi
|
|
|
|
}
|
2024-01-09 13:13:32 +00:00
|
|
|
|
2016-05-04 15:04:21 +00:00
|
|
|
#
|
2021-02-10 18:03:20 +00:00
|
|
|
# Do various checks on the concepts files
|
2021-02-10 16:03:11 +00:00
|
|
|
#
|
|
|
|
|
2024-10-10 16:37:44 +00:00
|
|
|
# -----------------------------------
|
|
|
|
echo "Check for duplicate encodings"
|
|
|
|
# -----------------------------------
|
2024-10-15 13:51:27 +00:00
|
|
|
paramIdFiles="$ECCODES_DEFINITION_PATH/grib2/paramId.def $ECCODES_DEFINITION_PATH/grib2/localConcepts/ecmf/paramId.def"
|
|
|
|
|
2024-10-10 16:37:44 +00:00
|
|
|
# Flatten the file so we get just the encoding part.
|
|
|
|
# uniq -d outputs a single copy of each line that is repeated in the input
|
2024-10-15 13:51:27 +00:00
|
|
|
for paramIdFile in $paramIdFiles; do
|
|
|
|
cat $paramIdFile | tr '\n' ' ' | tr '\t' ' ' | tr '#' '\n' | sed "s/^.* '//" | sed "s/'//" | awk '{$1="";print}' | sort |uniq -d > $tempText
|
|
|
|
if [ -s "$tempText" ]; then
|
|
|
|
# File exists and has a size greater than zero
|
|
|
|
echo "ERROR: Duplicate parameter encoding(s) found in $paramIdFile" >&2
|
|
|
|
cat $tempText | sed -e 's/ ;/;/g'
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "No duplicates in $paramIdFile"
|
|
|
|
fi
|
|
|
|
done
|
2024-10-10 16:37:44 +00:00
|
|
|
|
2024-11-11 11:23:22 +00:00
|
|
|
|
|
|
|
# -----------------------------------
|
|
|
|
echo "Check for bad shortNames"
|
|
|
|
# -----------------------------------
|
|
|
|
shortNameFile="$ECCODES_DEFINITION_PATH/grib2/shortName.def"
|
|
|
|
grep "^'.*=" $shortNameFile | sed -e 's/ = {//' > $tempText
|
|
|
|
set +e
|
|
|
|
grep ' ' $tempText # This grep should fail. No spaces must be found
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -ne 0 ]
|
|
|
|
|
2021-02-10 18:03:20 +00:00
|
|
|
# First check the GRIB2 paramId.def and shortName.def
|
|
|
|
# ----------------------------------------------------
|
2021-02-10 16:03:11 +00:00
|
|
|
$EXEC ${test_dir}/grib_check_param_concepts paramId $ECCODES_DEFINITION_PATH/grib2/paramId.def
|
2024-11-18 11:29:11 +00:00
|
|
|
datasets="ecmf uerra cerise hydro s2s tigge era6 destine era nextgems"
|
2024-04-16 14:40:12 +00:00
|
|
|
for a_dataset in $datasets; do
|
|
|
|
$EXEC ${test_dir}/grib_check_param_concepts paramId $ECCODES_DEFINITION_PATH/grib2/localConcepts/$a_dataset/paramId.def
|
|
|
|
done
|
2021-02-10 16:03:11 +00:00
|
|
|
|
|
|
|
$EXEC ${test_dir}/grib_check_param_concepts shortName $ECCODES_DEFINITION_PATH/grib2/shortName.def
|
2024-04-16 14:40:12 +00:00
|
|
|
for a_dataset in $datasets; do
|
|
|
|
$EXEC ${test_dir}/grib_check_param_concepts shortName $ECCODES_DEFINITION_PATH/grib2/localConcepts/$a_dataset/shortName.def
|
|
|
|
done
|
2021-02-10 16:03:11 +00:00
|
|
|
|
2024-04-22 12:35:25 +00:00
|
|
|
# Check WMO name.def etc
|
|
|
|
$EXEC ${test_dir}/grib_check_param_concepts name $ECCODES_DEFINITION_PATH/grib2/name.def
|
|
|
|
$EXEC ${test_dir}/grib_check_param_concepts units $ECCODES_DEFINITION_PATH/grib2/units.def
|
2024-08-02 11:37:53 +00:00
|
|
|
$EXEC ${test_dir}/grib_check_param_concepts cfVarName $ECCODES_DEFINITION_PATH/grib2/cfVarName.def
|
|
|
|
$EXEC ${test_dir}/grib_check_param_concepts cfVarName $ECCODES_DEFINITION_PATH/grib2/localConcepts/ecmf/cfVarName.def
|
2024-04-22 12:35:25 +00:00
|
|
|
|
|
|
|
|
2024-08-02 11:37:53 +00:00
|
|
|
# Check the group: name.def paramId.def shortName.def units.def
|
|
|
|
# -------------------------------------------------------------
|
2019-07-25 10:36:48 +00:00
|
|
|
# Check whether the Test::More Perl module is available
|
|
|
|
set +e
|
|
|
|
perl -e 'use Test::More;'
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
if [ $status -ne 0 ]; then
|
|
|
|
echo "Perl Test::More not installed. Test will be skipped"
|
|
|
|
exit 0
|
|
|
|
fi
|
2019-05-16 13:50:32 +00:00
|
|
|
|
2016-05-04 15:04:21 +00:00
|
|
|
defs_dirs="
|
|
|
|
$ECCODES_DEFINITION_PATH/grib1
|
|
|
|
$ECCODES_DEFINITION_PATH/grib2
|
|
|
|
$ECCODES_DEFINITION_PATH/grib1/localConcepts/ecmf
|
|
|
|
$ECCODES_DEFINITION_PATH/grib2/localConcepts/ecmf
|
2016-11-24 14:10:19 +00:00
|
|
|
|
|
|
|
$ECCODES_DEFINITION_PATH/grib1/localConcepts/ekmi
|
|
|
|
$ECCODES_DEFINITION_PATH/grib1/localConcepts/enmi
|
|
|
|
$ECCODES_DEFINITION_PATH/grib1/localConcepts/lfpw
|
|
|
|
$ECCODES_DEFINITION_PATH/grib1/localConcepts/lowm
|
|
|
|
$ECCODES_DEFINITION_PATH/grib1/localConcepts/rjtd
|
|
|
|
|
2021-09-30 10:12:40 +00:00
|
|
|
$ECCODES_DEFINITION_PATH/grib2/localConcepts/uerra
|
|
|
|
$ECCODES_DEFINITION_PATH/grib2/localConcepts/hydro
|
2024-03-21 11:05:32 +00:00
|
|
|
$ECCODES_DEFINITION_PATH/grib2/localConcepts/cerise
|
2021-12-17 20:15:31 +00:00
|
|
|
$ECCODES_DEFINITION_PATH/grib2/localConcepts/tigge
|
2021-12-17 13:31:44 +00:00
|
|
|
$ECCODES_DEFINITION_PATH/grib2/localConcepts/s2s
|
2024-03-21 11:05:32 +00:00
|
|
|
$ECCODES_DEFINITION_PATH/grib2/localConcepts/era6
|
2024-04-16 14:40:12 +00:00
|
|
|
$ECCODES_DEFINITION_PATH/grib2/localConcepts/era
|
2024-03-21 11:05:32 +00:00
|
|
|
$ECCODES_DEFINITION_PATH/grib2/localConcepts/destine
|
2021-09-30 10:12:40 +00:00
|
|
|
|
2016-11-24 14:10:19 +00:00
|
|
|
$ECCODES_DEFINITION_PATH/grib2/localConcepts/egrr
|
|
|
|
$ECCODES_DEFINITION_PATH/grib2/localConcepts/ekmi
|
|
|
|
$ECCODES_DEFINITION_PATH/grib2/localConcepts/eswi
|
|
|
|
$ECCODES_DEFINITION_PATH/grib2/localConcepts/lfpw
|
2016-05-04 15:04:21 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
for dir in $defs_dirs; do
|
|
|
|
cd $dir
|
2024-08-31 12:19:52 +00:00
|
|
|
check_grib_defs
|
2016-05-04 15:04:21 +00:00
|
|
|
done
|
2021-11-10 12:09:19 +00:00
|
|
|
|
|
|
|
cd $test_dir
|
|
|
|
|
2023-06-23 14:09:45 +00:00
|
|
|
# -------------------------------
|
|
|
|
echo "WMO legacy parameters..."
|
|
|
|
# -------------------------------
|
|
|
|
ECMF_DIR=$ECCODES_DEFINITION_PATH/grib2
|
|
|
|
|
|
|
|
tempDir=temp.${label}.dir
|
|
|
|
rm -fr $tempDir
|
|
|
|
mkdir -p $tempDir
|
|
|
|
cd $tempDir
|
2024-08-02 12:39:41 +00:00
|
|
|
|
|
|
|
# See ECC-1886 re cfVarName files
|
2023-06-23 14:09:45 +00:00
|
|
|
#cp $ECMF_DIR/cfName.legacy.def cfName.def
|
|
|
|
#cp $ECMF_DIR/cfVarName.legacy.def cfVarName.def
|
|
|
|
cp $ECMF_DIR/name.legacy.def name.def
|
|
|
|
cp $ECMF_DIR/paramId.legacy.def paramId.def
|
|
|
|
cp $ECMF_DIR/shortName.legacy.def shortName.def
|
|
|
|
cp $ECMF_DIR/units.legacy.def units.def
|
2024-08-31 12:19:52 +00:00
|
|
|
check_grib_defs
|
2023-06-23 14:09:45 +00:00
|
|
|
cd $test_dir
|
|
|
|
rm -fr $tempDir
|
|
|
|
|
2021-11-10 12:09:19 +00:00
|
|
|
# -------------------------------
|
|
|
|
echo "ECMWF legacy parameters..."
|
|
|
|
# -------------------------------
|
|
|
|
ECMF_DIR=$ECCODES_DEFINITION_PATH/grib2/localConcepts/ecmf
|
|
|
|
|
|
|
|
tempDir=temp.${label}.dir
|
|
|
|
rm -fr $tempDir
|
|
|
|
mkdir -p $tempDir
|
|
|
|
cd $tempDir
|
|
|
|
cp $ECMF_DIR/cfName.legacy.def cfName.def
|
2024-08-02 11:37:53 +00:00
|
|
|
# cp $ECMF_DIR/cfVarName.legacy.def cfVarName.def
|
2021-11-10 12:09:19 +00:00
|
|
|
cp $ECMF_DIR/name.legacy.def name.def
|
|
|
|
cp $ECMF_DIR/paramId.legacy.def paramId.def
|
|
|
|
cp $ECMF_DIR/shortName.legacy.def shortName.def
|
|
|
|
cp $ECMF_DIR/units.legacy.def units.def
|
2024-08-31 12:19:52 +00:00
|
|
|
check_grib_defs
|
2023-06-23 14:09:45 +00:00
|
|
|
cd $test_dir
|
|
|
|
rm -fr $tempDir
|
2021-11-10 12:09:19 +00:00
|
|
|
|
2022-12-17 14:37:45 +00:00
|
|
|
# -------------------------------
|
|
|
|
echo "Check duplicates"
|
|
|
|
# -------------------------------
|
|
|
|
paramIdFile=$ECCODES_DEFINITION_PATH/grib2/paramId.def
|
|
|
|
pids=$(grep "^'" $paramIdFile | awk -F"'" '{printf "%s\n", $2}')
|
|
|
|
set +e
|
|
|
|
for p in $pids; do
|
|
|
|
# For each paramId found in the top-level WMO file, check if it also exists
|
|
|
|
# in the ECMWF local one
|
|
|
|
grep "'$p'" $ECCODES_DEFINITION_PATH/grib2/localConcepts/ecmf/paramId.def
|
|
|
|
if [ $? -ne 1 ]; then
|
|
|
|
echo "ERROR: check paramId $p. Is it duplicated?"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
2024-10-09 14:01:29 +00:00
|
|
|
# -------------------------------
|
|
|
|
echo "ECC-1932"
|
|
|
|
# -------------------------------
|
|
|
|
sample1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
|
|
|
|
${tools_dir}/grib_set -s centre=egrr,indicatorOfParameter=167 $sample1 $tempGrib
|
|
|
|
grib_check_key_equals $tempGrib cfVarName t2m
|
|
|
|
rm -f $tempGrib
|
|
|
|
|
2024-10-10 16:37:44 +00:00
|
|
|
|
|
|
|
rm -f $tempText $tempGrib
|
|
|
|
|
2021-11-10 12:09:19 +00:00
|
|
|
cd $test_dir
|
|
|
|
rm -fr $tempDir
|