From 8f90238d73c9da9afcd7844d1704c6906ea03045 Mon Sep 17 00:00:00 2001 From: shahramn Date: Sat, 22 Jun 2024 13:41:31 +0100 Subject: [PATCH] ECC-1847: GRIB: Setting invalid value for 'typeOfLevel' does not fail --- definitions/grib1/local.98.2.def | 2 +- definitions/grib1/ls_labeling.82.def | 12 +++++------- definitions/grib1/mars_labeling.82.def | 2 +- definitions/grib1/section.1.def | 4 ++-- .../grib2/local/ecmf/section4_extras.def | 4 ++-- definitions/grib2/ls_labeling.82.def | 11 +++++------ definitions/grib2/mars_labeling.82.def | 2 +- definitions/grib2/template.4.horizontal.def | 2 +- definitions/grib3/ls_labeling.82.def | 12 ++++-------- definitions/grib3/mars_labeling.82.def | 2 +- definitions/grib3/template.4.horizontal.def | 2 +- definitions/grib3/template.component.5.0.def | 2 +- definitions/grib3/template.component.5.1.def | 2 +- tests/grib_typeOfLevel.sh | 18 +++++++++++++++++- 14 files changed, 43 insertions(+), 34 deletions(-) diff --git a/definitions/grib1/local.98.2.def b/definitions/grib1/local.98.2.def index df56d0ad6..6e96be41e 100644 --- a/definitions/grib1/local.98.2.def +++ b/definitions/grib1/local.98.2.def @@ -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; diff --git a/definitions/grib1/ls_labeling.82.def b/definitions/grib1/ls_labeling.82.def index a76689eaa..94fb3511f 100644 --- a/definitions/grib1/ls_labeling.82.def +++ b/definitions/grib1/ls_labeling.82.def @@ -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); } diff --git a/definitions/grib1/mars_labeling.82.def b/definitions/grib1/mars_labeling.82.def index c38a8bfe1..3a38c3ee5 100644 --- a/definitions/grib1/mars_labeling.82.def +++ b/definitions/grib1/mars_labeling.82.def @@ -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; } diff --git a/definitions/grib1/section.1.def b/definitions/grib1/section.1.def index d62300f27..1c3edb5ac 100644 --- a/definitions/grib1/section.1.def +++ b/definitions/grib1/section.1.def @@ -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";} diff --git a/definitions/grib2/local/ecmf/section4_extras.def b/definitions/grib2/local/ecmf/section4_extras.def index 0727c4b9a..2477b2481 100644 --- a/definitions/grib2/local/ecmf/section4_extras.def +++ b/definitions/grib2/local/ecmf/section4_extras.def @@ -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; } diff --git a/definitions/grib2/ls_labeling.82.def b/definitions/grib2/ls_labeling.82.def index 42f68e0ea..2207abc7f 100644 --- a/definitions/grib2/ls_labeling.82.def +++ b/definitions/grib2/ls_labeling.82.def @@ -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); } diff --git a/definitions/grib2/mars_labeling.82.def b/definitions/grib2/mars_labeling.82.def index 13942b638..4621e581d 100644 --- a/definitions/grib2/mars_labeling.82.def +++ b/definitions/grib2/mars_labeling.82.def @@ -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; } diff --git a/definitions/grib2/template.4.horizontal.def b/definitions/grib2/template.4.horizontal.def index 2dc64c033..4702e0319 100644 --- a/definitions/grib2/template.4.horizontal.def +++ b/definitions/grib2/template.4.horizontal.def @@ -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; diff --git a/definitions/grib3/ls_labeling.82.def b/definitions/grib3/ls_labeling.82.def index d0eb0a320..1c22b9c75 100644 --- a/definitions/grib3/ls_labeling.82.def +++ b/definitions/grib3/ls_labeling.82.def @@ -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); } diff --git a/definitions/grib3/mars_labeling.82.def b/definitions/grib3/mars_labeling.82.def index 88328c1a2..be488f14a 100644 --- a/definitions/grib3/mars_labeling.82.def +++ b/definitions/grib3/mars_labeling.82.def @@ -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; } diff --git a/definitions/grib3/template.4.horizontal.def b/definitions/grib3/template.4.horizontal.def index ed1bc6025..01ae2be22 100644 --- a/definitions/grib3/template.4.horizontal.def +++ b/definitions/grib3/template.4.horizontal.def @@ -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; } diff --git a/definitions/grib3/template.component.5.0.def b/definitions/grib3/template.component.5.0.def index 0170577a6..e97bf4a17 100644 --- a/definitions/grib3/template.component.5.0.def +++ b/definitions/grib3/template.component.5.0.def @@ -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; } diff --git a/definitions/grib3/template.component.5.1.def b/definitions/grib3/template.component.5.1.def index dc3b84ac8..edd4add36 100644 --- a/definitions/grib3/template.component.5.1.def +++ b/definitions/grib3/template.component.5.1.def @@ -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; } diff --git a/tests/grib_typeOfLevel.sh b/tests/grib_typeOfLevel.sh index fa9a7634d..54d12dee2 100755 --- a/tests/grib_typeOfLevel.sh +++ b/tests/grib_typeOfLevel.sh @@ -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