GRIB2 product template selection: fix test

This commit is contained in:
shahramn 2024-10-20 18:01:31 +01:00
parent 5e37c3e754
commit 11c571d5c2
2 changed files with 14 additions and 1 deletions

View File

@ -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;

View File

@ -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