diff --git a/examples/F90/grib_infinity_grid_second_order.f90 b/examples/F90/grib_infinity_grid_second_order.f90 index cfcd2e32a..f61e6c492 100644 --- a/examples/F90/grib_infinity_grid_second_order.f90 +++ b/examples/F90/grib_infinity_grid_second_order.f90 @@ -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 diff --git a/examples/F90/grib_infinity_grid_second_order.sh b/examples/F90/grib_infinity_grid_second_order.sh index 1da3c47b2..38c2b579e 100755 --- a/examples/F90/grib_infinity_grid_second_order.sh +++ b/examples/F90/grib_infinity_grid_second_order.sh @@ -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 diff --git a/src/accessor/grib_accessor_class_data_ccsds_packing.cc b/src/accessor/grib_accessor_class_data_ccsds_packing.cc index 851e73e3a..44a7e2a89 100644 --- a/src/accessor/grib_accessor_class_data_ccsds_packing.cc +++ b/src/accessor/grib_accessor_class_data_ccsds_packing.cc @@ -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(-binary_scale_factor, 2); + if (err) return err; + divisor = codes_power(-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 diff --git a/src/accessor/grib_accessor_class_data_complex_packing.cc b/src/accessor/grib_accessor_class_data_complex_packing.cc index d3cf71a34..d946d6ae6 100644 --- a/src/accessor/grib_accessor_class_data_complex_packing.cc +++ b/src/accessor/grib_accessor_class_data_complex_packing.cc @@ -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; 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 f78bb1806..83354c174 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 @@ -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(-binary_scale_factor, 2); } diff --git a/src/accessor/grib_accessor_class_data_png_packing.cc b/src/accessor/grib_accessor_class_data_png_packing.cc index 999722f36..5f4a6701d 100644 --- a/src/accessor/grib_accessor_class_data_png_packing.cc +++ b/src/accessor/grib_accessor_class_data_png_packing.cc @@ -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(-binary_scale_factor, 2); #ifndef PNG_ANYBITS