Skip to content

Commit

Permalink
GRIB2 product template selection: Test
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramn committed Oct 18, 2024
1 parent 26a74b0 commit 182dc8e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/accessor/grib_accessor_class_concept.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions tests/grib2_product_templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 182dc8e

Please sign in to comment.