ECC-1927: GRIB: grid_second_order hanging when encoding fields with Infinite values (try 2)

This commit is contained in:
shahramn 2024-10-03 13:03:56 +01:00
parent 0fe66b042a
commit 7608b3001d
6 changed files with 12 additions and 16 deletions

View File

@ -36,7 +36,5 @@ IF (CLINFINITY == '1') THEN
ENDIF
CALL codes_set_real8_array (IGRIBH, "values", ZT)
! write (*,*) 'status=',status
! write (*,*) 'ZT= ',ZT(1)
END

View File

@ -10,30 +10,23 @@
. ./include.ctest.sh
for encoding in grid_simple grid_second_order
do
for encoding in grid_simple grid_second_order; do
for infinity in 0 1; do
for infinity in 0 1
do
if [ $infinity -eq 1 ]
then
if [ $infinity -eq 1 ]; then
set +e
fi
${examples_dir}/eccodes_f_grib_infinity_grid_second_order $encoding $infinity
c=$?
if [ $infinity -eq 1 ]
then
if [ $infinity -eq 1 ]; then
set -e
if [ $c -eq 0 ]
then
if [ $c -eq 0 ]; then
echo "Encoding infinite numbers should fail"
exit 1
fi
fi
done
done

View File

@ -262,7 +262,8 @@ int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, cons
}
binary_scale_factor = grib_get_binary_scale_fact(max, reference_value, bits_per_value, &err);
divisor = codes_power<double>(-binary_scale_factor, 2);
if (err) return err;
divisor = codes_power<double>(-binary_scale_factor, 2);
size_t nbytes = (bits_per_value + 7) / 8;
// ECC-1602: use native a data type (4 bytes for uint32_t) for values that require only 3 bytes

View File

@ -416,7 +416,6 @@ int grib_accessor_class_data_complex_packing_t::pack_double(grib_accessor* a, co
return GRIB_INTERNAL_ERROR;
}
binary_scale_factor = grib_get_binary_scale_fact(d * max, reference_value, bits_per_value, &ret);
if (ret == GRIB_UNDERFLOW) {
d = 0;
binary_scale_factor = 0;

View File

@ -601,6 +601,9 @@ int grib_accessor_class_data_g1second_order_general_extended_packing_t::pack_dou
else if (val[i] < min)
min = val[i];
}
if ((ret = grib_check_data_values_minmax(handle, min, max)) != GRIB_SUCCESS) {
return ret;
}
/* ECC-1219: packingType conversion from grid_ieee to grid_second_order */
if ((ret = get_bits_per_value(handle, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS)
@ -646,6 +649,7 @@ int grib_accessor_class_data_g1second_order_general_extended_packing_t::pack_dou
return GRIB_INTERNAL_ERROR;
}
binary_scale_factor = grib_get_binary_scale_fact(max, reference_value, bits_per_value, &ret);
if (ret != GRIB_SUCCESS) return ret;
divisor = codes_power<double>(-binary_scale_factor, 2);
}

View File

@ -405,6 +405,7 @@ int grib_accessor_class_data_png_packing_t::pack_double(grib_accessor* a, const
}
binary_scale_factor = grib_get_binary_scale_fact(max, reference_value, bits_per_value, &err);
if (err) return err;
divisor = codes_power<double>(-binary_scale_factor, 2);
#ifndef PNG_ANYBITS