From 0dc3c273cc5065c6d6980cb610b7e40649aa9c09 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 19 Feb 2024 11:26:59 +0000 Subject: [PATCH] ECC-1768: GRIB2: Issue with setting PDTN 8, stepUnits and step at the same time (Initial try) --- src/grib_accessor_class_g2step_range.cc | 5 +++++ tests/bufr_compare.sh | 25 +++++++++++++++++++++++++ tests/grib_sub_hourly.sh | 14 ++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/src/grib_accessor_class_g2step_range.cc b/src/grib_accessor_class_g2step_range.cc index c39601a40..685c8a29b 100644 --- a/src/grib_accessor_class_g2step_range.cc +++ b/src/grib_accessor_class_g2step_range.cc @@ -211,6 +211,11 @@ 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; + // TODO(maee): A better solution should be found + if (h->loader) { // h->loader is set only when rebuilding or reparsing + force_step_units = 255; // See ECC-1768 + } + try { std::vector steps = parse_range(val, eccodes::Unit{force_step_units}); if (steps.size() == 0) { diff --git a/tests/bufr_compare.sh b/tests/bufr_compare.sh index 882fa3293..27f0c071b 100755 --- a/tests/bufr_compare.sh +++ b/tests/bufr_compare.sh @@ -351,6 +351,31 @@ set -e [ $status -ne 0 ] grep -q "unreadable message" $fLog +###??? +f1="aaen_55.bufr" +f2="aaen_55.bufr" +set +e +${tools_dir}/bufr_compare -H -c edition $f1 $f2 > $fLog 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "options are incompatible" $fLog + +set +e +${tools_dir}/bufr_compare -a edition $f1 $f2 > $fLog 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "a option requires -c option" $fLog + + +set +e +${tools_dir}/bufr_compare nosuchfile $f1 > $fLog 2>&1 +status=$? +set -e +[ $status -ne 0 ] + + # Clean up # ------------- diff --git a/tests/grib_sub_hourly.sh b/tests/grib_sub_hourly.sh index 75b113b7e..fdd174c28 100755 --- a/tests/grib_sub_hourly.sh +++ b/tests/grib_sub_hourly.sh @@ -520,6 +520,20 @@ cat $tempFilt ${tools_dir}/grib_filter $tempFilt $data_dir/constant_field.grib2 unset ECCODES_GRIB_HOURLY_STEPS_WITH_UNITS + +# Changing the product definition template +# ---------------------------------------- +# See ECC-1768 +${tools_dir}/grib_set -s step=62m $sample_g2 $temp +${tools_dir}/grib_set -s productDefinitionTemplateNumber=8 $temp $temp2 + +${tools_dir}/grib_set -s productDefinitionTemplateNumber=8,stepUnits=s,step=0 $sample_g2 $temp +grib_check_key_equals $temp '-p stepUnits:s,startStep,productDefinitionTemplateNumber' 's 0s 8' + +${tools_dir}/grib_set -s productDefinitionTemplateNumber=8,stepUnits=m,step=60 $sample_g2 $temp +grib_check_key_equals $temp '-p stepUnits:s,productDefinitionTemplateNumber' 'h 8' + + # Bad stepUnits set +e ${tools_dir}/grib_set -s stepUnits=190 $sample_g2 $temp > $tempText 2>&1