mirror of https://github.com/ecmwf/eccodes.git
Merge remote-tracking branch 'origin/develop' into feature/grib_time_processing_generalisation
This commit is contained in:
commit
01ee95d335
|
@ -52,7 +52,7 @@ install:
|
|||
m2w64-ntldd-git
|
||||
|
||||
# get deps. Drop libnetcdf
|
||||
- cmd: conda install -c conda-forge cmake
|
||||
- cmd: conda install -c conda-forge cmake libaec
|
||||
|
||||
#---------------------------------#
|
||||
# build configuration #
|
||||
|
@ -73,7 +73,7 @@ build_script:
|
|||
-D ENABLE_FORTRAN=0 ^
|
||||
-D ENABLE_NETCDF=0 ^
|
||||
-D ENABLE_JPG=1 ^
|
||||
-D ENABLE_AEC=0 ^
|
||||
-D ENABLE_AEC=1 ^
|
||||
-D IEEE_LE=1 ^
|
||||
-D ENABLE_MEMFS=1 ^
|
||||
-D ENABLE_EXTRA_TESTS=ON ^
|
||||
|
|
|
@ -8,3 +8,4 @@
|
|||
'eORCA12' = { numberOfGridUsed = 7; }
|
||||
'CORE2' = { numberOfGridUsed = 8; }
|
||||
'NG5' = { numberOfGridUsed = 9; }
|
||||
'DART' = { numberOfGridUsed = 10; }
|
||||
|
|
|
@ -186,3 +186,69 @@
|
|||
parameterCategory = 0 ;
|
||||
parameterNumber = 2 ;
|
||||
}
|
||||
#Maximum temperature
|
||||
'Maximum temperature' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 4 ;
|
||||
}
|
||||
#Minimum temperature
|
||||
'Minimum temperature' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 5 ;
|
||||
}
|
||||
#Minimum dew point depression
|
||||
'Minimum dew point depression' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 14 ;
|
||||
}
|
||||
#Maximum relative humidity
|
||||
'Maximum relative humidity' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 27 ;
|
||||
}
|
||||
#Maximum absolute humidity
|
||||
'Maximum absolute humidity' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 28 ;
|
||||
}
|
||||
#Maximum wind speed
|
||||
'Maximum wind speed' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 2 ;
|
||||
parameterNumber = 21 ;
|
||||
}
|
||||
#Net long wave radiation flux (surface)
|
||||
'Net long wave radiation flux (surface)' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 5 ;
|
||||
parameterNumber = 0 ;
|
||||
}
|
||||
#Net long wave radiation flux (top of atmosphere)
|
||||
'Net long wave radiation flux (top of atmosphere)' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 5 ;
|
||||
parameterNumber = 1 ;
|
||||
}
|
||||
#Maximum snow albedo
|
||||
'Maximum snow albedo' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 19 ;
|
||||
parameterNumber = 17 ;
|
||||
}
|
||||
#Soil temperature
|
||||
'Soil temperature' = {
|
||||
discipline = 2 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 2 ;
|
||||
}
|
||||
#Soil moisture
|
||||
'Soil moisture' = {
|
||||
discipline = 2 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 22 ;
|
||||
}
|
||||
|
|
|
@ -186,3 +186,69 @@
|
|||
parameterCategory = 0 ;
|
||||
parameterNumber = 2 ;
|
||||
}
|
||||
#Maximum temperature
|
||||
'3015' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 4 ;
|
||||
}
|
||||
#Minimum temperature
|
||||
'3016' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 5 ;
|
||||
}
|
||||
#Minimum dew point depression
|
||||
'260006' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 14 ;
|
||||
}
|
||||
#Maximum relative humidity
|
||||
'260023' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 27 ;
|
||||
}
|
||||
#Maximum absolute humidity
|
||||
'260024' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 28 ;
|
||||
}
|
||||
#Maximum wind speed
|
||||
'260064' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 2 ;
|
||||
parameterNumber = 21 ;
|
||||
}
|
||||
#Net long wave radiation flux (surface)
|
||||
'260095' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 5 ;
|
||||
parameterNumber = 0 ;
|
||||
}
|
||||
#Net long wave radiation flux (top of atmosphere)
|
||||
'260096' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 5 ;
|
||||
parameterNumber = 1 ;
|
||||
}
|
||||
#Maximum snow albedo
|
||||
'260161' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 19 ;
|
||||
parameterNumber = 17 ;
|
||||
}
|
||||
#Soil temperature
|
||||
'228139' = {
|
||||
discipline = 2 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 2 ;
|
||||
}
|
||||
#Soil moisture
|
||||
'228039' = {
|
||||
discipline = 2 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 22 ;
|
||||
}
|
||||
|
|
|
@ -186,3 +186,69 @@
|
|||
parameterCategory = 0 ;
|
||||
parameterNumber = 2 ;
|
||||
}
|
||||
#Maximum temperature
|
||||
'tmax' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 4 ;
|
||||
}
|
||||
#Minimum temperature
|
||||
'tmin' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 5 ;
|
||||
}
|
||||
#Minimum dew point depression
|
||||
'mindpd' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 14 ;
|
||||
}
|
||||
#Maximum relative humidity
|
||||
'maxrh' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 27 ;
|
||||
}
|
||||
#Maximum absolute humidity
|
||||
'maxah' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 28 ;
|
||||
}
|
||||
#Maximum wind speed
|
||||
'maxgust' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 2 ;
|
||||
parameterNumber = 21 ;
|
||||
}
|
||||
#Net long wave radiation flux (surface)
|
||||
'nlwrs' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 5 ;
|
||||
parameterNumber = 0 ;
|
||||
}
|
||||
#Net long wave radiation flux (top of atmosphere)
|
||||
'nlwrt' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 5 ;
|
||||
parameterNumber = 1 ;
|
||||
}
|
||||
#Maximum snow albedo
|
||||
'mxsalb' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 19 ;
|
||||
parameterNumber = 17 ;
|
||||
}
|
||||
#Soil temperature
|
||||
'st' = {
|
||||
discipline = 2 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 2 ;
|
||||
}
|
||||
#Soil moisture
|
||||
'sm' = {
|
||||
discipline = 2 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 22 ;
|
||||
}
|
||||
|
|
|
@ -186,3 +186,69 @@
|
|||
parameterCategory = 0 ;
|
||||
parameterNumber = 2 ;
|
||||
}
|
||||
#Maximum temperature
|
||||
'K' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 4 ;
|
||||
}
|
||||
#Minimum temperature
|
||||
'K' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 5 ;
|
||||
}
|
||||
#Minimum dew point depression
|
||||
'K' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 14 ;
|
||||
}
|
||||
#Maximum relative humidity
|
||||
'%' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 27 ;
|
||||
}
|
||||
#Maximum absolute humidity
|
||||
'kg m**-3' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 28 ;
|
||||
}
|
||||
#Maximum wind speed
|
||||
'm s**-1' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 2 ;
|
||||
parameterNumber = 21 ;
|
||||
}
|
||||
#Net long wave radiation flux (surface)
|
||||
'W m**-2' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 5 ;
|
||||
parameterNumber = 0 ;
|
||||
}
|
||||
#Net long wave radiation flux (top of atmosphere)
|
||||
'W m**-2' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 5 ;
|
||||
parameterNumber = 1 ;
|
||||
}
|
||||
#Maximum snow albedo
|
||||
'%' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 19 ;
|
||||
parameterNumber = 17 ;
|
||||
}
|
||||
#Soil temperature
|
||||
'K' = {
|
||||
discipline = 2 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 2 ;
|
||||
}
|
||||
#Soil moisture
|
||||
'kg m**-3' = {
|
||||
discipline = 2 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 22 ;
|
||||
}
|
||||
|
|
|
@ -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,41 @@
|
|||
! (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
|
||||
|
||||
! This should fail if CLINFINITY is 1 (inf passed in)
|
||||
CALL codes_set_real8_array (IGRIBH, "values", ZT)
|
||||
|
||||
END
|
|
@ -0,0 +1,37 @@
|
|||
#!/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.
|
||||
#
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# This is the test for the JIRA issue ECC-1927
|
||||
# grid_second_order hangs when encoding fields with infinite values
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
. ./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 have failed"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
done
|
||||
done
|
|
@ -90,6 +90,8 @@ static void print_aec_stream_info(struct aec_stream* strm, const char* func)
|
|||
fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.avail_in=%lu\n", func, strm->avail_in);
|
||||
}
|
||||
|
||||
#define MAX_BITS_PER_VALUE 32
|
||||
|
||||
int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len)
|
||||
{
|
||||
grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a;
|
||||
|
@ -260,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
|
||||
|
@ -309,8 +312,8 @@ int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, cons
|
|||
}
|
||||
break;
|
||||
default:
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR, "%s pack_double: packing %s, bits_per_value=%ld (max 32)",
|
||||
cclass_name, a->name, bits_per_value);
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR, "%s pack_double: packing %s, bitsPerValue=%ld (max %ld)",
|
||||
cclass_name, a->name, bits_per_value, MAX_BITS_PER_VALUE);
|
||||
err = GRIB_INVALID_BPV;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -508,8 +511,8 @@ static int unpack(grib_accessor* a, T* val, size_t* len)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: unpacking %s, bits_per_value=%ld (max 32)",
|
||||
cclass_name, __func__, a->name, bits_per_value);
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: unpacking %s, bitsPerValue=%ld (max %ld)",
|
||||
cclass_name, __func__, a->name, bits_per_value, MAX_BITS_PER_VALUE);
|
||||
err = GRIB_INVALID_BPV;
|
||||
goto cleanup;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -1464,7 +1464,7 @@ int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, c
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
static int unpack(grib_accessor* a, T* val, const size_t* len)
|
||||
static int unpack(grib_accessor* a, T* val, size_t* len)
|
||||
{
|
||||
static_assert(std::is_floating_point<T>::value, "Requires floating points numbers");
|
||||
grib_accessor_data_g22order_packing_t* self = reinterpret_cast<grib_accessor_data_g22order_packing_t*>(a);
|
||||
|
@ -1566,6 +1566,14 @@ static int unpack(grib_accessor* a, T* val, const size_t* len)
|
|||
|
||||
self->dirty = 0;
|
||||
|
||||
if (bits_per_value == 0) {
|
||||
for (i = 0; i < n_vals; i++) {
|
||||
val[i] = reference_value;
|
||||
}
|
||||
*len = n_vals;
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
sec_val = (long*)grib_context_malloc(a->context, (n_vals) * sizeof(long));
|
||||
if (!sec_val) return GRIB_OUT_OF_MEMORY;
|
||||
memset(sec_val, 0, (n_vals) * sizeof(long)); // See SUP-718
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
START_CLASS_DEF
|
||||
CLASS = action
|
||||
IMPLEMENTS = destroy;execute
|
||||
IMPLEMENTS = create_accessor
|
||||
MEMBERS = char *name
|
||||
MEMBERS = char *outname
|
||||
END_CLASS_DEF
|
||||
|
@ -36,6 +37,7 @@ or edit "action.class" and rerun ./make_class.pl
|
|||
|
||||
static void init_class (grib_action_class*);
|
||||
static void destroy (grib_context*,grib_action*);
|
||||
static int create_accessor(grib_section*,grib_action*,grib_loader*);
|
||||
static int execute(grib_action* a,grib_handle* h);
|
||||
|
||||
|
||||
|
@ -57,7 +59,7 @@ static grib_action_class _grib_action_class_print = {
|
|||
&destroy, /* destroy */
|
||||
0, /* dump */
|
||||
0, /* xref */
|
||||
0, /* create_accessor */
|
||||
&create_accessor, /* create_accessor */
|
||||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
&execute, /* execute */
|
||||
|
@ -141,3 +143,21 @@ static void destroy(grib_context* context, grib_action* act)
|
|||
grib_context_free_persistent(context, act->name);
|
||||
grib_context_free_persistent(context, act->op);
|
||||
}
|
||||
|
||||
static int create_accessor(grib_section* p, grib_action* act, grib_loader* h)
|
||||
{
|
||||
// ECC-1929: A print statement within the definitions does not
|
||||
// actually create an accessor. So we just run it
|
||||
grib_action_print* self = (grib_action_print*)act;
|
||||
|
||||
const int err = execute(act, p->h);
|
||||
if (err)
|
||||
grib_context_log(act->context, GRIB_LOG_ERROR, "Print: '%s' (%s)", self->name, grib_get_error_message(err));
|
||||
return err;
|
||||
|
||||
// We may want to be forgiving and ignore the error
|
||||
// if (act->context->debug) {
|
||||
// return err;
|
||||
// }
|
||||
// return GRIB_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
START_CLASS_DEF
|
||||
CLASS = action
|
||||
IMPLEMENTS = dump
|
||||
IMPLEMENTS = destroy;execute
|
||||
MEMBERS = char *name
|
||||
END_CLASS_DEF
|
||||
|
@ -32,7 +31,6 @@ or edit "action.class" and rerun ./make_class.pl
|
|||
*/
|
||||
|
||||
static void init_class (grib_action_class*);
|
||||
static void dump (grib_action* d, FILE*,int);
|
||||
static void destroy (grib_context*,grib_action*);
|
||||
static int execute(grib_action* a,grib_handle* h);
|
||||
|
||||
|
@ -52,7 +50,7 @@ static grib_action_class _grib_action_class_set_missing = {
|
|||
&init_class, /* init_class */
|
||||
0, /* init */
|
||||
&destroy, /* destroy */
|
||||
&dump, /* dump */
|
||||
0, /* dump */
|
||||
0, /* xref */
|
||||
0, /* create_accessor */
|
||||
0, /* notify_change */
|
||||
|
@ -95,17 +93,6 @@ static int execute(grib_action* a, grib_handle* h)
|
|||
return grib_set_missing(h, self->name);
|
||||
}
|
||||
|
||||
static void dump(grib_action* act, FILE* f, int lvl)
|
||||
{
|
||||
grib_context_log(act->context, GRIB_LOG_ERROR, "%s %s(): Not implemented", __FILE__, __func__);
|
||||
// int i = 0;
|
||||
// const grib_action_set_missing* self = (grib_action_set_missing*)act;
|
||||
// for (i = 0; i < lvl; i++)
|
||||
// grib_context_print(act->context, f, " ");
|
||||
// grib_context_print(act->context, f, self->name);
|
||||
// printf("\n");
|
||||
}
|
||||
|
||||
static void destroy(grib_context* context, grib_action* act)
|
||||
{
|
||||
grib_action_set_missing* a = (grib_action_set_missing*)act;
|
||||
|
|
|
@ -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,12 @@ 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;
|
||||
|
||||
// See ECC-1927
|
||||
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;
|
||||
|
|
|
@ -144,7 +144,6 @@ if( HAVE_BUILD_TOOLS )
|
|||
grib_ecc-1708
|
||||
grib_ecc-1691
|
||||
grib_ecc-1766
|
||||
grib_ecc-1806
|
||||
grib_ecc-1829
|
||||
bufr_ecc-1028
|
||||
bufr_ecc-1195
|
||||
|
@ -276,13 +275,16 @@ if( HAVE_BUILD_TOOLS )
|
|||
grib_ecc-1467
|
||||
grib_ecc-1764
|
||||
grib_ecc-1792
|
||||
grib_ecc-1806
|
||||
grib_ecc-1907
|
||||
grib_modelName
|
||||
grib_sub_hourly
|
||||
grib_set_bytes
|
||||
grib_set_force
|
||||
bufr_ecc-556
|
||||
codes_assert
|
||||
codes_ecc-1698
|
||||
codes_ecc-1929
|
||||
codes_get_string
|
||||
codes_codetable
|
||||
gts_get
|
||||
|
|
|
@ -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
|
||||
|
||||
label="codes_assert_test"
|
||||
|
||||
tempOut=temp.$label.txt
|
||||
sample_grib2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
||||
|
||||
tempDir=${label}.temp.dir
|
||||
rm -rf $tempDir
|
||||
mkdir -p $tempDir/definitions/grib2
|
||||
bootfile=$tempDir/definitions/grib2/boot.def
|
||||
cat $def_dir/grib2/boot.def > $bootfile
|
||||
echo 'assert( year == 1990 );' >> $bootfile
|
||||
echo >> $bootfile
|
||||
|
||||
export ECCODES_DEFINITION_PATH=$PWD/$tempDir/definitions
|
||||
# This will activate the print statement above
|
||||
${tools_dir}/grib_set -s year=1990 $sample_grib2 /dev/null
|
||||
|
||||
set +e
|
||||
${tools_dir}/grib_set -s year=1991 $sample_grib2 /dev/null > $tempOut 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "year.*Assertion failure" $tempOut
|
||||
|
||||
# Clean up
|
||||
rm -rf $tempDir
|
||||
rm -f $tempOut
|
|
@ -0,0 +1,33 @@
|
|||
#!/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
|
||||
|
||||
label="codes_ecc-1929_test"
|
||||
|
||||
tempOut=temp.$label.txt
|
||||
sample_grib2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
||||
|
||||
tempDir=${label}.temp.dir
|
||||
rm -rf $tempDir
|
||||
mkdir -p $tempDir/definitions/grib2
|
||||
bootfile=$tempDir/definitions/grib2/boot.def
|
||||
cat $def_dir/grib2/boot.def > $bootfile
|
||||
echo 'print "DEBUG: [gridType=] [typeOfLevel=]";' >> $bootfile
|
||||
echo >> $bootfile
|
||||
|
||||
export ECCODES_DEFINITION_PATH=$PWD/$tempDir/definitions
|
||||
# This will activate the print statement above
|
||||
${tools_dir}/grib_get -p edition $sample_grib2 > $tempOut
|
||||
grep -q "DEBUG: gridType=regular_ll typeOfLevel=surface" $tempOut
|
||||
|
||||
# Clean up
|
||||
rm -rf $tempDir
|
||||
rm -f $tempOut
|
|
@ -85,6 +85,17 @@ set -e
|
|||
[ $status -ne 0 ]
|
||||
grep -q "Unable to open file" $tempOut
|
||||
|
||||
|
||||
# Bad print
|
||||
# ----------
|
||||
set +e
|
||||
echo 'print ("/") "should fail";' | ${tools_dir}/grib_filter - $input > $tempOut 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "IO ERROR" $tempOut
|
||||
|
||||
|
||||
# Signed bits
|
||||
# -----------
|
||||
cat >$tempFilt <<EOF
|
||||
|
|
|
@ -75,6 +75,33 @@ input=${data_dir}/gfs.complex.mvmu.grib2
|
|||
stats=`${tools_dir}/grib_get -F%.2f -p max,min,avg $input`
|
||||
[ "$stats" = "2.81 0.00 0.30" ]
|
||||
|
||||
# ECC-1926
|
||||
# grid_complex_spatial_differencing with bpv=0
|
||||
# Create a data section similar to the attached file dswrf-1.grib2
|
||||
cat >$tempFilt<<EOF
|
||||
set packingType='grid_complex_spatial_differencing';
|
||||
set numberOfGroupsOfDataValues=0;
|
||||
set orderOfSpatialDifferencing=2;
|
||||
set primaryMissingValueSubstitute=0;
|
||||
set referenceForGroupWidths = 64;
|
||||
set numberOfBitsUsedForTheGroupWidths = 4;
|
||||
set referenceForGroupLengths = 203736800;
|
||||
set trueLengthOfLastGroup = 8;
|
||||
set numberOfBitsForScaledGroupLengths = 7;
|
||||
set numberOfOctetsExtraDescriptors = 1;
|
||||
write;
|
||||
EOF
|
||||
input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
||||
${tools_dir}/grib_filter -o $temp1 $tempFilt $input
|
||||
grib_check_key_equals $temp1 packingType,isConstant 'grid_complex_spatial_differencing 1'
|
||||
stats1=`${tools_dir}/grib_get -M -F%.0f -n statistics $input`
|
||||
stats2=`${tools_dir}/grib_get -M -F%.0f -n statistics $temp1`
|
||||
[ "$stats1" = "$stats2" ]
|
||||
${tools_dir}/grib_set -rs packingType=grid_simple $temp1 $temp2
|
||||
grib_check_key_equals $temp2 packingType,isConstant 'grid_simple 1'
|
||||
${tools_dir}/grib_compare -b totalLength,section5Length,dataRepresentationTemplateNumber $temp2 $temp1
|
||||
|
||||
|
||||
# Decode as string - Null op
|
||||
cat >$tempFilt<<EOF
|
||||
print "[computeStatistics:s]";
|
||||
|
|
|
@ -27,7 +27,7 @@ ecbuild_add_library( TARGET ecc_tools
|
|||
|
||||
# tools binaries
|
||||
list( APPEND ecc_tools_binaries
|
||||
codes_info codes_count codes_split_file
|
||||
codes_info codes_count codes_split_file codes_export_resource
|
||||
grib_histogram grib_filter grib_ls grib_dump
|
||||
grib2ppm grib_set grib_get grib_get_data grib_copy
|
||||
grib_compare codes_parser grib_index_build bufr_index_build
|
||||
|
@ -39,7 +39,6 @@ list( APPEND ecc_tools_binaries
|
|||
list( APPEND ecc_tools_binaries_extra
|
||||
grib_repair
|
||||
grib_to_json
|
||||
codes_export_resource
|
||||
grib_check_gaussian_grid
|
||||
bufr_split_by_rdbSubtype )
|
||||
|
||||
|
|
|
@ -18,9 +18,10 @@ grib_option grib_options[] = {
|
|||
{ "w:", "key[:{s|d|i}]=value,key[:{s|d|i}]=value,...",
|
||||
"\n\t\tWhere clause.\n\t\tSet is only executed for BUFR messages matching all the "
|
||||
"key/value constraints.\n\t\tIf a BUFR message does not match the constraints it is"
|
||||
" copied unchanged\n\t\tto the output_file. This behaviour can be changed "
|
||||
" copied unchanged\n\t\tto the output_bufr_file. This behaviour can be changed "
|
||||
"setting the option -S.\n\t\tFor each key a string (key:s), a double (key:d) or"
|
||||
" an integer (key:i)\n\t\ttype can be defined. Default type is string."
|
||||
"\n\t\tIn the value you can also use the forward-slash character '/' to specify an OR condition (i.e. a logical disjunction)"
|
||||
"\n\t\tNote: only one -w clause is allowed.\n",
|
||||
0, 1, 0 },
|
||||
{ "q", 0, 0, 1, 0, 0 },
|
||||
|
@ -36,12 +37,12 @@ grib_option grib_options[] = {
|
|||
};
|
||||
|
||||
const char* tool_description =
|
||||
"Sets key/value pairs in the input BUFR file and writes"
|
||||
"\n\teach message to the output_file."
|
||||
"Sets key/value pairs in the input BUFR file(s) and writes"
|
||||
"\n\teach message to the output_bufr_file."
|
||||
"\n\tIt fails when an error occurs (e.g. key not found).";
|
||||
const char* tool_name = "bufr_set";
|
||||
const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/bufr_set";
|
||||
const char* tool_usage = "[options] file file ... output_file";
|
||||
const char* tool_usage = "[options] bufr_file bufr_file ... output_bufr_file";
|
||||
|
||||
int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ ECCODES_PATCH_VERSION=@eccodes_VERSION_PATCH@
|
|||
# ECCODES_VERSION="$ECCODES_MAJOR_VERSION.$ECCODES_MINOR_VERSION.$ECCODES_PATCH_VERSION"
|
||||
|
||||
ECCODES_GIT_SHA1="@eccodes_GIT_SHA1@"
|
||||
if [ "x$ECCODES_GIT_SHA1" = "x" ]; then
|
||||
ECCODES_GIT_SHA1="unknown"
|
||||
fi
|
||||
|
||||
#################################################################
|
||||
# Commands
|
||||
|
|
|
@ -44,7 +44,7 @@ grib_option grib_options[] = {
|
|||
};
|
||||
|
||||
const char* tool_description =
|
||||
"Sets key/value pairs in the input GRIB file and writes"
|
||||
"Sets key/value pairs in the input GRIB file(s) and writes"
|
||||
"\n\teach message to the output_grib_file."
|
||||
"\n\tIt fails when an error occurs (e.g. key not found).";
|
||||
const char* tool_name = "grib_set";
|
||||
|
|
Loading…
Reference in New Issue