From 9a2041b87a0bba2b2c41410a279c270475d61f3e Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 4 Nov 2024 17:16:19 +0000 Subject: [PATCH] GRIB2 product template selection: chemical src/sink and wave period range --- src/accessor/grib_accessor_class_concept.cc | 21 +++++++++++++++------ tests/grib2_product_templates.sh | 7 +++---- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/accessor/grib_accessor_class_concept.cc b/src/accessor/grib_accessor_class_concept.cc index 249dde888..9dd0b71a5 100644 --- a/src/accessor/grib_accessor_class_concept.cc +++ b/src/accessor/grib_accessor_class_concept.cc @@ -389,12 +389,21 @@ static int grib_concept_apply(grib_accessor* a, const char* name) grib_set_values(h, &values[i], 1); } } - // else if (STR_EQUAL(values[i].name, "sourceSinkChemicalPhysicalProcess")) { - // if (grib_set_long(h, "is_chemical_srcsink", 1) == GRIB_SUCCESS) { - // resubmit = true; - // grib_set_values(h, &values[i], 1); - // } - // } + else if (STR_EQUAL(values[i].name, "typeOfWavePeriodInterval")) { + grib_context_log(h->context, GRIB_LOG_DEBUG, "%s: Switch to waves selected by period range", __func__); + // TODO(masn): Add a new key e.g. is_wave_period_range + if (grib_set_long(h, "productDefinitionTemplateNumber", 103) == GRIB_SUCCESS) { + resubmit = true; + grib_set_values(h, &values[i], 1); + } + } + else if (STR_EQUAL(values[i].name, "sourceSinkChemicalPhysicalProcess")) { + grib_context_log(h->context, GRIB_LOG_DEBUG, "%s: Switch to chemical src/sink", __func__); + if (grib_set_long(h, "is_chemical_srcsink", 1) == GRIB_SUCCESS) { + resubmit = true; + grib_set_values(h, &values[i], 1); + } + } } } diff --git a/tests/grib2_product_templates.sh b/tests/grib2_product_templates.sh index 579592462..60836df31 100755 --- a/tests/grib2_product_templates.sh +++ b/tests/grib2_product_templates.sh @@ -74,14 +74,13 @@ grib_check_key_equals $tempGribA productDefinitionTemplateNumber 8 grib_check_key_equals $tempGribA typeOfStatisticalProcessing,stepType '2 max' grib_check_key_equals $tempGribA shortName,name 'max_visp Time-maximum visibility through precipitation' -# Test an expected failure. paramId=140114 contains wave keys +# Test an expected failure, e.g., paramId=239375 has constituentType set +e -$tools_dir/grib_set -s paramId=140114 $sample_g2 $tempGribA 2>$tempText +$tools_dir/grib_set -s paramId=239375 $sample_g2 $tempGribA 2>$tempText status=$? set -e [ $status -ne 0 ] -grep -q "typeOfWavePeriodInterval .* failed: Key/value not found" $tempText -grep -q "scaleFactorOfLowerWavePeriodLimit .* failed: Key/value not found" $tempText +grep -q "constituentType .* failed: Key/value not found" $tempText # Clean up