Skip to content

Commit

Permalink
GRIB2 product template selection: chemical src/sink and wave period r…
Browse files Browse the repository at this point in the history
…ange
  • Loading branch information
shahramn committed Nov 4, 2024
1 parent 7206120 commit 9a2041b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
21 changes: 15 additions & 6 deletions src/accessor/grib_accessor_class_concept.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}

Expand Down
7 changes: 3 additions & 4 deletions tests/grib2_product_templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9a2041b

Please sign in to comment.