diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc index 2ee15e425..166be66de 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc @@ -584,8 +584,6 @@ int grib_accessor_data_g1second_order_general_extended_packing_t::pack_double(co grib_handle* handle = grib_handle_of_accessor(this); long optimize_scaling_factor = 0; - double_dirty_ = 1; - numberOfValues = *len; min = max = val[0]; @@ -606,6 +604,9 @@ int grib_accessor_data_g1second_order_general_extended_packing_t::pack_double(co if ((ret = grib_get_long_internal(handle, optimize_scaling_factor_, &optimize_scaling_factor)) != GRIB_SUCCESS) return ret; + // ECC-1986: Make sure we set the dirty flag after calling get_bits_per_value + double_dirty_ = 1; + if (optimize_scaling_factor) { const int compat_gribex = handle->context->gribex_mode_on && edition_ == 1; const int compat_32bit = 1; diff --git a/tests/grib_second_order.sh b/tests/grib_second_order.sh index 0d44a87cb..241f4af7c 100755 --- a/tests/grib_second_order.sh +++ b/tests/grib_second_order.sh @@ -210,6 +210,18 @@ ${tools_dir}/grib_set -s scaleValuesBy=1.01 $input $temp1 ${tools_dir}/grib_dump $temp1 grib_check_key_equals $temp1 packingType grid_second_order +# ECC-1986: GRIB1: Setting field values in second order packing +cat > $tempFilt< 20000 ); + } +EOF +input=lfpw.grib1 +${tools_dir}/grib_filter $tempFilt $input + # Clean up rm -f $temp_stat1 $temp_stat2