diff --git a/src/accessor/grib_accessor_class_concept.cc b/src/accessor/grib_accessor_class_concept.cc index 02c93d193..b0de1e932 100644 --- a/src/accessor/grib_accessor_class_concept.cc +++ b/src/accessor/grib_accessor_class_concept.cc @@ -377,17 +377,20 @@ static int grib_concept_apply(grib_accessor* a, const char* name) 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 + // is instantaneous but paramId/shortName being set is for accum/avg etc 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); } } // else if (STR_EQUAL(values[i].name, "sourceSinkChemicalPhysicalProcess")) { -// if (grib_set_long(h, "is_chemical_srcsink", 1) == GRIB_SUCCESS) { -// resubmit = true; -// } -// } + // if (grib_set_long(h, "is_chemical_srcsink", 1) == GRIB_SUCCESS) { + // resubmit = true; + // } + // } } } if (resubmit) { diff --git a/tests/grib2_product_templates.sh b/tests/grib2_product_templates.sh index 29e70a96c..3541a0ce3 100755 --- a/tests/grib2_product_templates.sh +++ b/tests/grib2_product_templates.sh @@ -53,6 +53,15 @@ else echo "No duplicates in $def_file" fi +# Automatic PDT selection +# ------------------------ +grib_check_key_equals $sample_g2 productDefinitionTemplateNumber 0 +$tools_dir/grib_set -s shortName=tp $sample_g2 $tempGribA +grib_check_key_equals $tempGribA productDefinitionTemplateNumber 8 +grib_check_key_equals $tempGribA typeOfStatisticalProcessing 1 +grib_check_key_equals $tempGribA name 'Total precipitation' +grib_check_key_equals $tempGribA stepType 'accum' + # Clean up rm -f $tempText $tempGribA $tempGribB