Skip to content

Commit

Permalink
ECC-1986: GRIB1: Setting field values in second order packing
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramn committed Nov 26, 2024
1 parent ddb6bcf commit f4279fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions tests/grib_second_order.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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<<EOF
if (count==1) {
# min = 19074.9, max = 20717.6
assert( min < 20000 );
set offsetValuesBy = 1000.0;
assert( min > 20000 );
}
EOF
input=lfpw.grib1
${tools_dir}/grib_filter $tempFilt $input


# Clean up
rm -f $temp_stat1 $temp_stat2
Expand Down

0 comments on commit f4279fc

Please sign in to comment.