diff --git a/src/accessor/grib_accessor_class_concept.cc b/src/accessor/grib_accessor_class_concept.cc index a94ffd208..3a9a5d031 100644 --- a/src/accessor/grib_accessor_class_concept.cc +++ b/src/accessor/grib_accessor_class_concept.cc @@ -377,6 +377,7 @@ static int grib_concept_apply(grib_accessor* a, const char* name) err = grib_set_values_silent(h, values, count, /*silent=*/1); if (err) { // GRIB2 product template selection + bool resubmit = false; for (int i = 0; i < count; i++) { if (values[i].error == GRIB_NOT_FOUND) { // Repair the most common cause of failure: input GRIB handle @@ -384,6 +385,7 @@ static int grib_concept_apply(grib_accessor* a, const char* name) if (STR_EQUAL(values[i].name, "typeOfStatisticalProcessing")) { // Switch from instantaneous to interval-based if (grib_set_long(h, "selectStepTemplateInterval", 1) == GRIB_SUCCESS) { + resubmit = true; grib_set_values(h, &values[i], 1); } } @@ -395,7 +397,9 @@ static int grib_concept_apply(grib_accessor* a, const char* name) } } - err = grib_set_values(h, values, count); + if (resubmit) { + err = grib_set_values(h, values, count); + } } } return err; diff --git a/tests/grib2_product_templates.sh b/tests/grib2_product_templates.sh index 34fb6fbad..5cbcd0797 100755 --- a/tests/grib2_product_templates.sh +++ b/tests/grib2_product_templates.sh @@ -74,6 +74,15 @@ 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 a failure. paramId=140114 contains wave keys +set +e +$tools_dir/grib_set -s paramId=140114 $sample_g2 $tempGribA 2>$tempText +status=$? +set -e +[ $status -ne 0 ] +# cat $tempText +# check for "typeOfWavePeriodInterval (type=long) failed: Key/value not found" in error log + # Clean up rm -f $tempText $tempGribA $tempGribB