From 2f9cc4803d0eceee549ef46d8b3adfbfd6ef8402 Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 31 Jul 2024 17:27:13 +0100 Subject: [PATCH] chemId/paramId split: Fix case when mars class is changed but datasetForLocal does not --- definitions/grib2/section.4.def | 9 ++++++- tests/CMakeLists.txt | 1 + tests/grib2_datasetForLocal.sh | 48 +++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100755 tests/grib2_datasetForLocal.sh diff --git a/definitions/grib2/section.4.def b/definitions/grib2/section.4.def index cda4986f9..8767a5135 100644 --- a/definitions/grib2/section.4.def +++ b/definitions/grib2/section.4.def @@ -51,7 +51,14 @@ concept datasetForLocal(unknown) { "unknown" = { dummy=1; } } -if (datasetForLocal isnot "unknown") { +# If the keys marsClass or productionStatusOfProcessedData change in memory, +# need to trigger the change of conceptsDirs +transient redo_concept_dirs = 0; +when( changed(marsClass) || changed(productionStatusOfProcessedData) ) { + set redo_concept_dirs = 1; +} + +if ( redo_concept_dirs || datasetForLocal isnot "unknown") { constant conceptsDir2 = "grib2/localConcepts/[datasetForLocal]": hidden; constant conceptsDir1 = "grib2": hidden; } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b0cca7394..132050f68 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -195,6 +195,7 @@ if( HAVE_BUILD_TOOLS ) grib_count grib_clone_headers_only grib2_paramType + grib2_datasetForLocal wmo_read_bufr_from_file wmo_read_gts_from_file wmo_read_any_from_file diff --git a/tests/grib2_datasetForLocal.sh b/tests/grib2_datasetForLocal.sh new file mode 100755 index 000000000..4907aa1c5 --- /dev/null +++ b/tests/grib2_datasetForLocal.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# 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. +# + +. ./include.ctest.sh + +REDIRECT=/dev/null + +label="grib2_datasetforlocal_test" +tempGribA=temp.$label.A.grib +tempGribB=temp.$label.B.grib +tempGribC=temp.$label.C.grib +tempFilt=temp.$label.filt +tempLog=temp.$label.log +tempOut=temp.$label.txt +tempRef=temp.$label.ref + +# ERA6 +# ----- +sample=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl +# Make changes in stages +${tools_dir}/grib_set -s marsClass=e6,productDefinitionTemplateNumber=42 $sample $tempGribA +${tools_dir}/grib_set -s paramId=233033 $tempGribA $tempGribB + +# Now all in one go +${tools_dir}/grib_set -s marsClass=e6,productDefinitionTemplateNumber=42,paramId=233033 $sample $tempGribC +cmp $tempGribB $tempGribC + +# DestinE +# -------- +sample=$ECCODES_SAMPLES_PATH/GRIB2.tmpl + +${tools_dir}/grib_set -s centre=0,productionStatusOfProcessedData=12 $sample $tempGribA +${tools_dir}/grib_set -s paramId=210061 $tempGribA $tempGribB + +${tools_dir}/grib_set -s centre=0,productionStatusOfProcessedData=12,paramId=210061 $sample $tempGribC +cmp $tempGribB $tempGribC + +#grib_check_key_equals $temp k1,k2 "v1 v2" + +# Clean up +rm -f $tempGribA $tempGribB $tempGribC $tempFilt $tempLog $tempOut $tempRef