Skip to content

Commit

Permalink
ECC-1800: GRIB2: Failure setting stepUnits=s,paramId=210203
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramn committed Apr 11, 2024
1 parent 7f653dd commit c30b50f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/grib_accessor_class_g2step_range.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
if ((ret = grib_get_long_internal(h, "forceStepUnits", &force_step_units)) != GRIB_SUCCESS)
return ret;

if (h->loader) { // h->loader is set only when rebuilding or reparsing
force_step_units = 255; // See ECC-1768 and ECC-1800
}

try {
std::vector<eccodes::Step> steps = parse_range(val, eccodes::Unit{force_step_units});
if (steps.size() == 0) {
Expand Down
19 changes: 19 additions & 0 deletions tests/grib_sub_hourly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -542,5 +542,24 @@ set -e
[ $status -ne 0 ]
grep -q "Invalid unit" $tempText


# ECC-1800: Set stepUnits before paramIds, which cause changes in the PTDN
${tools_dir}/grib_set -s stepUnits=s,paramId=210203 $sample_g2 $temp # is_chemical
grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,productDefinitionTemplateNumber' '13 s 40'

${tools_dir}/grib_set -s stepUnits=s,paramId=131060 $sample_g2 $temp # probability forecasts
grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,productDefinitionTemplateNumber' '13 s 9'

${tools_dir}/grib_set -s stepUnits=s,paramId=210073 $sample_g2 $temp # is_aerosol
grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,productDefinitionTemplateNumber' '13 s 48'

${tools_dir}/grib_set -s stepUnits=s,paramId=210170 $sample_g2 $temp # is_chemical_srcsink
grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,productDefinitionTemplateNumber' '13 s 76'

# Add a case with filter too
echo "set stepUnits='s'; set paramId=210203; write;" | ${tools_dir}/grib_filter -o $temp - $sample_g2
grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,productDefinitionTemplateNumber' '13 s 40'


# Clean up
rm -f $temp $temp2 $tempFilt $tempText

0 comments on commit c30b50f

Please sign in to comment.