mirror of https://github.com/ecmwf/eccodes.git
ECC-1847: Fix case when input has typeOfLevel=unknown
This commit is contained in:
parent
19d71254f7
commit
97dd1741aa
|
@ -97,3 +97,4 @@
|
|||
'road' = {typeOfFirstFixedSurface=187; typeOfSecondFixedSurface=255;}
|
||||
'roadLayer' = {typeOfFirstFixedSurface=187; typeOfSecondFixedSurface=187;}
|
||||
'urbanCanyon' = {typeOfFirstFixedSurface=187; typeOfSecondFixedSurface=185;}
|
||||
'unknown' = {dummy=0;}
|
||||
|
|
|
@ -11,8 +11,9 @@
|
|||
. ./include.ctest.sh
|
||||
|
||||
label="grib_typeOfLevel_test"
|
||||
temp=temp.$label.txt
|
||||
tempGrib=temp.$label.grib
|
||||
tempText=temp.$label.txt
|
||||
tempGribA=temp.$label.A.grib
|
||||
tempGribB=temp.$label.B.grib
|
||||
|
||||
if [ ! -d "$ECCODES_DEFINITION_PATH" ]; then
|
||||
echo "Test $0 disabled. No definitions directory"
|
||||
|
@ -23,32 +24,40 @@ sample_g1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
|
|||
sample_g2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
||||
|
||||
# Make sure all typeOfLevel values are unique
|
||||
# --------------------------------------------
|
||||
def_file="$ECCODES_DEFINITION_PATH/grib2/typeOfLevelConcept.def"
|
||||
|
||||
rm -f $temp
|
||||
rm -f $tempText
|
||||
|
||||
# uniq -d outputs a single copy of each line that is repeated in the input
|
||||
grep "^'" $def_file | awk -F= '{print $1}' | tr -d "' " | sort | uniq -d > $temp
|
||||
grep "^'" $def_file | awk -F= '{print $1}' | tr -d "' " | sort | uniq -d > $tempText
|
||||
|
||||
if [ -s "$temp" ]; then
|
||||
if [ -s "$tempText" ]; then
|
||||
# File exists and has a size greater than zero
|
||||
echo "ERROR: Duplicates found in $def_file" >&2
|
||||
cat $temp
|
||||
cat $tempText
|
||||
exit 1
|
||||
else
|
||||
echo "No duplicates in $def_file"
|
||||
fi
|
||||
|
||||
# ECC-1847: Setting invalid value for 'typeOfLevel' does not fail
|
||||
# ----------------------------------------------------------------
|
||||
for sample in $sample_g1 $sample_g2; do
|
||||
set +e
|
||||
${tools_dir}/grib_set -s typeOfLevel=rubbish $sample $tempGrib 2>$temp
|
||||
${tools_dir}/grib_set -s typeOfLevel=rubbish $sample $tempGribA 2>$tempText
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "Concept no match" $temp
|
||||
grep -q "Concept no match" $tempText
|
||||
done
|
||||
|
||||
# Change of PDT with typeOfLevel=unknown
|
||||
${tools_dir}/grib_set -s productDefinitionTemplateNumber=0,typeOfFirstFixedSurface=0 $sample_g2 $tempGribA
|
||||
grib_check_key_equals $tempGribA typeOfLevel 'unknown'
|
||||
${tools_dir}/grib_set -s productDefinitionTemplateNumber=1 $tempGribA $tempGribB
|
||||
grib_check_key_equals $tempGribB typeOfLevel,productDefinitionTemplateNumber 'unknown 1'
|
||||
|
||||
|
||||
# Clean up
|
||||
rm -f $temp $tempGrib
|
||||
rm -f $tempText $tempGribA $tempGribB
|
||||
|
|
Loading…
Reference in New Issue