ECC-1847: GRIB: Setting invalid value for 'typeOfLevel' does not fail

This commit is contained in:
shahramn 2024-06-22 13:41:31 +01:00
parent 0f3a74620a
commit 8f90238d73
14 changed files with 43 additions and 34 deletions

View File

@ -41,6 +41,6 @@ padto padding_loc2_2(offsetSection1 + 328);
constant unknown="-";
concept_nofail clusteringDomain(unknown,"cluster_domain.def",conceptsMasterDir,conceptsLocalDirAll);
concept clusteringDomain(unknown,"cluster_domain.def",conceptsMasterDir,conceptsLocalDirAll);
alias number = clusterNumber;
alias domain = clusteringDomain;

View File

@ -2,14 +2,12 @@
# created: 6 Oct 2011
# modified: 13 Sep 2013
#
alias ls.dataType = marsType;
alias ls.dataType = marsType;
if (localDefinitionNumber == 83 ) {
concept_nofail ls.timerepres (unknown,"timeRepresConcept.def",conceptsLocalDirAll,conceptsMasterDir);
concept_nofail ls.sort (unknown,"sortConcept.def",conceptsLocalDirAll,conceptsMasterDir);
concept_nofail ls.landtype (unknown,"landTypeConcept.def",conceptsLocalDirAll,conceptsMasterDir);
concept_nofail ls.aerosolbinnumber (unknown,"aerosolConcept.def",conceptsLocalDirAll,conceptsMasterDir);
concept ls.timerepres (unknown,"timeRepresConcept.def",conceptsLocalDirAll,conceptsMasterDir);
concept ls.sort (unknown,"sortConcept.def",conceptsLocalDirAll,conceptsMasterDir);
concept ls.landtype (unknown,"landTypeConcept.def",conceptsLocalDirAll,conceptsMasterDir);
concept ls.aerosolbinnumber (unknown,"aerosolConcept.def",conceptsLocalDirAll,conceptsMasterDir);
}

View File

@ -24,6 +24,6 @@ if ( localDefinitionNumber == 83 ) {
alias mars.landtype = matchLandType;
alias mars.aerosolbinnumber = matchAerosolBinNumber;
concept_nofail matchAerosolPacking (unknown,"aerosolPackingConcept.def",conceptsLocalMarsDirAll,conceptsMasterMarsDir);
concept matchAerosolPacking (unknown,"aerosolPackingConcept.def",conceptsLocalMarsDirAll,conceptsMasterMarsDir);
alias mars.aerosolpacking = matchAerosolPacking;
}

View File

@ -58,8 +58,8 @@ alias levelType=indicatorOfTypeOfLevel;
transient pressureUnits="hPa";
concept_nofail typeOfLevelECMF (unknown, "typeOfLevel.def",conceptsMasterDir,conceptsLocalDirECMF);
concept_nofail vertical.typeOfLevel (typeOfLevelECMF, "typeOfLevel.def",conceptsDir2,conceptsDir1);
concept typeOfLevelECMF (unknown, "typeOfLevel.def",conceptsMasterDir,conceptsLocalDirECMF);
concept vertical.typeOfLevel (typeOfLevelECMF, "typeOfLevel.def",conceptsDir2,conceptsDir1);
when ( typeOfLevel is "isobaricInPa" ) { set pressureUnits="Pa"; }
else { set pressureUnits="hPa";}

View File

@ -2,10 +2,10 @@
# See ECC-1846
if (centre is "ecmf" or datasetForLocal is "era6") {
concept_nofail modelName(unknown, "modelNameConcept.def", conceptsMasterDir, conceptsLocalDirAll): no_copy, dump, read_only;
concept modelName(unknown, "modelNameConcept.def", conceptsMasterDir, conceptsLocalDirAll): no_copy, dump, read_only;
if (!(modelName is "unknown")) {
concept_nofail modelVersion(unknown, "modelVersionConcept_[modelName].def", conceptsMasterDir, conceptsLocalDirAll): no_copy, dump, read_only;
concept modelVersion(unknown, "modelVersionConcept_[modelName].def", conceptsMasterDir, conceptsLocalDirAll): no_copy, dump, read_only;
# alias ls.model = modelName;
# alias mars.model = modelName;
}

View File

@ -1,16 +1,15 @@
# author: Sebastien Villaume
# created: 14 Feb 2014
#
constant g1conceptsMasterDir="grib1" : hidden;
constant g1conceptsLocalDirAll="grib1/localConcepts/[centre:s]" : hidden;
alias ls.dataType = marsType;
alias ls.dataType = marsType;
if (localDefinitionNumber == 83 ) {
concept_nofail ls.timerepres (unknown,"timeRepresConcept.def",g1conceptsLocalDirAll,g1conceptsMasterDir);
concept_nofail ls.sort (unknown,"sortConcept.def",g1conceptsLocalDirAll,g1conceptsMasterDir);
concept_nofail ls.landtype (unknown,"landTypeConcept.def",g1conceptsLocalDirAll,g1conceptsMasterDir);
concept_nofail ls.aerosolbinnumber (unknown,"aerosolConcept.def",g1conceptsLocalDirAll,g1conceptsMasterDir);
concept ls.timerepres (unknown,"timeRepresConcept.def",g1conceptsLocalDirAll,g1conceptsMasterDir);
concept ls.sort (unknown,"sortConcept.def",g1conceptsLocalDirAll,g1conceptsMasterDir);
concept ls.landtype (unknown,"landTypeConcept.def",g1conceptsLocalDirAll,g1conceptsMasterDir);
concept ls.aerosolbinnumber (unknown,"aerosolConcept.def",g1conceptsLocalDirAll,g1conceptsMasterDir);
}

View File

@ -22,7 +22,7 @@ if ( localDefinitionNumber == 83 ) {
alias mars.landtype = matchLandType;
alias mars.aerosolbinnumber = matchAerosolBinNumber;
concept_nofail matchAerosolPacking (unknown,"aerosolPackingConcept.def",conceptsLocalMarsDirAll,conceptsMasterMarsDir);
concept matchAerosolPacking (unknown,"aerosolPackingConcept.def",conceptsLocalMarsDirAll,conceptsMasterMarsDir);
alias mars.aerosolpacking = matchAerosolPacking;
}

View File

@ -24,7 +24,7 @@ unsigned[4] scaledValueOfSecondFixedSurface = missing() : can_be_missing,dump,ed
transient pressureUnits="hPa";
concept_nofail vertical.typeOfLevel (unknown,"typeOfLevelConcept.def",conceptsDir2,conceptsDir1);
concept vertical.typeOfLevel (unknown,"typeOfLevelConcept.def",conceptsDir2,conceptsDir1);
alias levelType=typeOfFirstFixedSurface;

View File

@ -4,19 +4,15 @@
# created: 14 Feb 2014
#
#########################
constant g1conceptsMasterDir="grib1" : hidden;
constant g1conceptsLocalDirAll="grib1/localConcepts/[centre:s]" : hidden;
alias ls.dataType = marsType;
if (localDefinitionNumber == 83 ) {
concept_nofail ls.timerepres (unknown,"timeRepresConcept.def",g1conceptsLocalDirAll,g1conceptsMasterDir);
concept_nofail ls.sort (unknown,"sortConcept.def",g1conceptsLocalDirAll,g1conceptsMasterDir);
concept_nofail ls.landtype (unknown,"landTypeConcept.def",g1conceptsLocalDirAll,g1conceptsMasterDir);
concept_nofail ls.aerosolbinnumber (unknown,"aerosolConcept.def",g1conceptsLocalDirAll,g1conceptsMasterDir);
concept ls.timerepres (unknown,"timeRepresConcept.def",g1conceptsLocalDirAll,g1conceptsMasterDir);
concept ls.sort (unknown,"sortConcept.def",g1conceptsLocalDirAll,g1conceptsMasterDir);
concept ls.landtype (unknown,"landTypeConcept.def",g1conceptsLocalDirAll,g1conceptsMasterDir);
concept ls.aerosolbinnumber (unknown,"aerosolConcept.def",g1conceptsLocalDirAll,g1conceptsMasterDir);
}

View File

@ -40,7 +40,7 @@ if ( localDefinitionNumber == 83 ) {
alias mars.landtype = matchLandType;
alias mars.aerosolbinnumber = matchAerosolBinNumber;
concept_nofail matchAerosolPacking (unknown,"aerosolPackingConcept.def",conceptsLocalMarsDirAll,conceptsMasterMarsDir);
concept matchAerosolPacking (unknown,"aerosolPackingConcept.def",conceptsLocalMarsDirAll,conceptsMasterMarsDir);
alias mars.aerosolpacking = matchAerosolPacking;
}

View File

@ -24,7 +24,7 @@ unsigned[4] scaledValueOfSecondFixedSurface = missing() : can_be_missing,dump,ed
transient pressureUnits="hPa";
concept_nofail vertical.typeOfLevel (unknown) {
concept vertical.typeOfLevel (unknown) {
#set uses the last one
#get returns the first match
'surface' = { typeOfFirstFixedSurface=1; typeOfSecondFixedSurface=255; }

View File

@ -14,7 +14,7 @@ unsigned[4] scaledValueOfFirstFixedSurface = missing() : can_be_missing,dump,ed
####
transient pressureUnits="hPa";
concept_nofail vertical.typeOfLevel (unknown) {
concept vertical.typeOfLevel (unknown) {
#set uses the last one
#get returns the first match
'surface' = { typeOfFirstFixedSurface=1; }

View File

@ -26,7 +26,7 @@ unsigned[4] scaledValueOfSecondFixedSurface = missing() : can_be_missing,dump,ed
#######
transient pressureUnits="hPa";
concept_nofail vertical.typeOfLevel (unknown) {
concept vertical.typeOfLevel (unknown) {
#set uses the last one
#get returns the first match
'surface' = { typeOfFirstFixedSurface=1; typeOfSecondFixedSurface=255; }

View File

@ -12,12 +12,16 @@
label="grib_typeOfLevel_test"
temp=temp.$label.txt
tempGrib=temp.$label.grib
if [ ! -d "$ECCODES_DEFINITION_PATH" ]; then
echo "Test $0 disabled. No definitions directory"
exit 0
fi
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"
@ -35,4 +39,16 @@ else
echo "No duplicates in $def_file"
fi
rm -f $temp
# 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
status=$?
set -e
[ $status -ne 0 ]
grep -q "Concept no match" $temp
done
# Clean up
rm -f $temp $tempGrib