mirror of https://github.com/ecmwf/eccodes.git
ECC-1927: GRIB: grid_second_order hanging when encoding fields with Infinite values (try 1)
This commit is contained in:
parent
af1bd19b60
commit
0fe66b042a
|
@ -55,6 +55,7 @@ if( HAVE_BUILD_TOOLS )
|
|||
grib_get_set_uuid
|
||||
grib_clone
|
||||
grib_ecc-1316
|
||||
grib_infinity_grid_second_order
|
||||
bufr_attributes
|
||||
bufr_clone
|
||||
bufr_expanded
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
! (C) Copyright 2005- ECMWF.
|
||||
!
|
||||
! This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
!
|
||||
! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
!
|
||||
! Description: issue with grid_second_order hanging when encoding fields with infinite values
|
||||
!
|
||||
!
|
||||
USE eccodes
|
||||
USE ieee_arithmetic
|
||||
|
||||
IMPLICIT NONE
|
||||
|
||||
INTEGER :: IGRIBH
|
||||
REAL(KIND=8) :: ZT (421*441)
|
||||
|
||||
CHARACTER*32 :: CLPACKING ! grid_simple / grid_second_order
|
||||
CHARACTER*32 :: CLINFINITY ! 0 / 1
|
||||
|
||||
CALL GETARG (1, CLPACKING)
|
||||
CALL GETARG (2, CLINFINITY)
|
||||
|
||||
CALL codes_grib_new_from_samples(IGRIBH, "regular_ll_sfc_grib2")
|
||||
CALL codes_set_long (IGRIBH, "Ni", 421_8)
|
||||
CALL codes_set_long (IGRIBH, "Nj", 441_8)
|
||||
CALL codes_set_long (IGRIBH, "bitsPerValue", 16_8)
|
||||
CALL codes_set_string (IGRIBH, "packingType", TRIM (CLPACKING))
|
||||
|
||||
ZT = 0._8
|
||||
|
||||
IF (CLINFINITY == '1') THEN
|
||||
ZT (1) = IEEE_VALUE (0._8, IEEE_POSITIVE_INF)
|
||||
ENDIF
|
||||
|
||||
CALL codes_set_real8_array (IGRIBH, "values", ZT)
|
||||
! write (*,*) 'status=',status
|
||||
! write (*,*) 'ZT= ',ZT(1)
|
||||
|
||||
END
|
|
@ -0,0 +1,39 @@
|
|||
#!/bin/sh
|
||||
# (C) Copyright 2005- ECMWF.
|
||||
#
|
||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
#
|
||||
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
#
|
||||
|
||||
. ./include.ctest.sh
|
||||
|
||||
for encoding in grid_simple grid_second_order
|
||||
do
|
||||
|
||||
for infinity in 0 1
|
||||
do
|
||||
|
||||
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
|
||||
set -e
|
||||
if [ $c -eq 0 ]
|
||||
then
|
||||
echo "Encoding infinite numbers should fail"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
done
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "grib_scaling.h"
|
||||
#include "grib_api_internal.h"
|
||||
#include <math.h>
|
||||
|
||||
// Unfortunately, metkit uses grib_power() (illegal usage of private API)
|
||||
// As soon as it is fixed, the wrapper below can be deleted
|
||||
|
@ -26,6 +27,11 @@ long grib_get_binary_scale_fact(double max, double min, long bpval, int* error)
|
|||
unsigned long maxint = 0;
|
||||
const size_t ulong_size = sizeof(maxint) * 8;
|
||||
|
||||
if ((isnan(range) || isinf(range))) {
|
||||
*error = GRIB_OUT_OF_RANGE; /*overflow*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* See ECC-246
|
||||
unsigned long maxint = codes_power<double>(bpval,2) - 1;
|
||||
double dmaxint=(double)maxint;
|
||||
|
|
Loading…
Reference in New Issue