mirror of https://github.com/ecmwf/eccodes.git
Merge branch 'feature/modernisation_merge_accessor_classes' of github.com:ecmwf/eccodes into feature/modernisation_merge_accessor_classes
This commit is contained in:
commit
17e195f8e2
|
@ -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
|
|
@ -85,6 +85,7 @@ 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_data_ccsds_packing_t::pack_double(const double* val, size_t* len)
|
||||
{
|
||||
grib_handle* hand = grib_handle_of_accessor(this);
|
||||
|
@ -253,7 +254,8 @@ int grib_accessor_data_ccsds_packing_t::pack_double(const double* val, size_t* l
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -302,8 +304,8 @@ int grib_accessor_data_ccsds_packing_t::pack_double(const double* val, size_t* l
|
|||
}
|
||||
break;
|
||||
default:
|
||||
grib_context_log(context_, GRIB_LOG_ERROR, "%s pack_double: packing %s, bits_per_value=%ld (max 32)",
|
||||
cclass_name, name_, bits_per_value);
|
||||
grib_context_log(context_, GRIB_LOG_ERROR, "%s pack_double: packing %s, bitsPerValue=%ld (max %ld)",
|
||||
cclass_name, name_, bits_per_value, MAX_BITS_PER_VALUE);
|
||||
err = GRIB_INVALID_BPV;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -500,8 +502,8 @@ int grib_accessor_data_ccsds_packing_t::unpack(T* val, size_t* len)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
grib_context_log(context_, GRIB_LOG_ERROR, "%s %s: unpacking %s, bits_per_value=%ld (max 32)",
|
||||
cclass_name, __func__, name_, bits_per_value);
|
||||
grib_context_log(context_, GRIB_LOG_ERROR, "%s %s: unpacking %s, bitsPerValue=%ld (max %ld)",
|
||||
cclass_name, __func__, name_, bits_per_value, MAX_BITS_PER_VALUE);
|
||||
err = GRIB_INVALID_BPV;
|
||||
goto cleanup;
|
||||
}
|
||||
|
|
|
@ -412,7 +412,6 @@ int grib_accessor_data_complex_packing_t::pack_double(const double* val, size_t*
|
|||
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;
|
||||
|
|
|
@ -596,6 +596,9 @@ int grib_accessor_data_g1second_order_general_extended_packing_t::pack_double(co
|
|||
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, bits_per_value_, &bits_per_value)) != GRIB_SUCCESS)
|
||||
|
@ -641,6 +644,7 @@ int grib_accessor_data_g1second_order_general_extended_packing_t::pack_double(co
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -1461,7 +1461,7 @@ int grib_accessor_data_g22order_packing_t::pack_double(const double* val, size_t
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
int grib_accessor_data_g22order_packing_t::unpack(T* val, const size_t* len)
|
||||
int grib_accessor_data_g22order_packing_t::unpack(T* val, size_t* len)
|
||||
{
|
||||
static_assert(std::is_floating_point<T>::value, "Requires floating points numbers");
|
||||
const char* cclass_name = class_name_;
|
||||
|
@ -1562,6 +1562,14 @@ int grib_accessor_data_g22order_packing_t::unpack(T* val, const size_t* len)
|
|||
|
||||
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(context_, (n_vals) * sizeof(long));
|
||||
if (!sec_val) return GRIB_OUT_OF_MEMORY;
|
||||
memset(sec_val, 0, (n_vals) * sizeof(long)); // See SUP-718
|
||||
|
|
|
@ -49,5 +49,5 @@ private:
|
|||
const char* orderOfSpatialDifferencing_;
|
||||
const char* numberOfOctetsExtraDescriptors_;
|
||||
|
||||
template <typename T> int unpack(T* val, const size_t* len);
|
||||
template <typename T> int unpack(T* val, size_t* len);
|
||||
};
|
||||
|
|
|
@ -397,6 +397,7 @@ int grib_accessor_data_png_packing_t::pack_double(const double* val, size_t* len
|
|||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -218,10 +218,9 @@ static grib_concept_value* get_concept_impl(grib_handle* h, grib_action_concept*
|
|||
char master[1024] = {0,};
|
||||
char local[1024] = {0,};
|
||||
char masterDir[1024] = {0,};
|
||||
size_t lenMasterDir = 1024;
|
||||
size_t lenMasterDir = sizeof(masterDir);
|
||||
char key[4096] = {0,};
|
||||
char* full = 0;
|
||||
int id;
|
||||
const size_t bufLen = sizeof(buf);
|
||||
const size_t keyLen = sizeof(key);
|
||||
|
||||
|
@ -234,7 +233,15 @@ static grib_concept_value* get_concept_impl(grib_handle* h, grib_action_concept*
|
|||
Assert(self->masterDir);
|
||||
grib_get_string(h, self->masterDir, masterDir, &lenMasterDir);
|
||||
|
||||
snprintf(buf, bufLen, "%s/%s", masterDir, self->basename);
|
||||
// See ECC-1920: The basename could be a key or a string
|
||||
char* basename = self->basename; // default is a string
|
||||
Assert(basename);
|
||||
char baseNameValue[1024] = {0,}; // its value if a key
|
||||
size_t lenBaseName = sizeof(baseNameValue);
|
||||
if (grib_get_string(h, self->basename, baseNameValue, &lenBaseName) == GRIB_SUCCESS) {
|
||||
basename = baseNameValue; // self->basename was a key whose value is baseNameValue
|
||||
}
|
||||
snprintf(buf, bufLen, "%s/%s", masterDir, basename);
|
||||
|
||||
grib_recompose_name(h, NULL, buf, master, 1);
|
||||
|
||||
|
@ -242,13 +249,13 @@ static grib_concept_value* get_concept_impl(grib_handle* h, grib_action_concept*
|
|||
char localDir[1024] = {0,};
|
||||
size_t lenLocalDir = 1024;
|
||||
grib_get_string(h, self->localDir, localDir, &lenLocalDir);
|
||||
snprintf(buf, bufLen, "%s/%s", localDir, self->basename);
|
||||
snprintf(buf, bufLen, "%s/%s", localDir, basename);
|
||||
grib_recompose_name(h, NULL, buf, local, 1);
|
||||
}
|
||||
|
||||
snprintf(key, keyLen, "%s%s", master, local);
|
||||
|
||||
id = grib_itrie_get_id(h->context->concepts_index, key);
|
||||
int id = grib_itrie_get_id(h->context->concepts_index, key);
|
||||
if ((c = h->context->concepts[id]) != NULL)
|
||||
return c;
|
||||
|
||||
|
@ -274,7 +281,7 @@ static grib_concept_value* get_concept_impl(grib_handle* h, grib_action_concept*
|
|||
else {
|
||||
grib_context_log(context, GRIB_LOG_FATAL,
|
||||
"unable to find definition file %s in %s:%s\nDefinition files path=\"%s\"",
|
||||
self->basename, master, local, context->grib_definition_files_path);
|
||||
basename, master, local, context->grib_definition_files_path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ static std::vector<double> HEALPix_longitudes(size_t N, size_t i)
|
|||
return longitudes;
|
||||
}
|
||||
|
||||
static int iterate_healpix(grib_iterator_healpix* self, long N)
|
||||
static int iterate_healpix(grib_iterator_healpix* self, long N, bool nested)
|
||||
{
|
||||
size_t Ny = 4 * static_cast<size_t>(N) - 1;
|
||||
auto Nd = static_cast<double>(N);
|
||||
|
@ -241,7 +241,7 @@ static int iterate_healpix(grib_iterator_healpix* self, long N)
|
|||
// Equator
|
||||
latitudes[2 * N - 1] = 0.0;
|
||||
|
||||
if (self->nested) {
|
||||
if (nested) {
|
||||
if (!is_power_of_2(N)) {
|
||||
grib_context* c = grib_context_get_default();
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "%s: For nested ordering, Nside must be a power of 2", ITER);
|
||||
|
@ -389,7 +389,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
|
|||
}
|
||||
|
||||
try {
|
||||
err = iterate_healpix(self, N);
|
||||
err = iterate_healpix(self, N, self->nested);
|
||||
}
|
||||
catch (...) {
|
||||
return GRIB_INTERNAL_ERROR;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -875,6 +875,20 @@ static int write_out_error_data_file(const double* data_values, size_t data_valu
|
|||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
static long get_bitsPerValue_for_packingType(const int specPackingType, const long specBitsPerValue)
|
||||
{
|
||||
if (specPackingType == GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE) {
|
||||
if (specBitsPerValue > 60) return 60;
|
||||
}
|
||||
else if (specPackingType == GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER) {
|
||||
if (specBitsPerValue > 60) return 32;
|
||||
}
|
||||
else if (specPackingType == GRIB_UTIL_PACKING_TYPE_CCSDS) {
|
||||
if (specBitsPerValue > 32) return 32;
|
||||
}
|
||||
return specBitsPerValue; //original
|
||||
}
|
||||
|
||||
static int get_grib_sample_name(grib_handle* h, long editionNumber,
|
||||
const grib_util_grid_spec* spec, const char* grid_type, char* sample_name)
|
||||
{
|
||||
|
@ -1341,17 +1355,26 @@ grib_handle* grib_util_set_spec(grib_handle* h,
|
|||
Assert(grib_get_long(h, "bitsPerValue", &bitsPerValue) == 0);
|
||||
SET_LONG_VALUE("bitsPerValue", bitsPerValue);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES:
|
||||
SET_LONG_VALUE("bitsPerValue", packing_spec->bitsPerValue);
|
||||
break;
|
||||
case GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES: {
|
||||
// See ECC-1921
|
||||
const long bitsPerValue = get_bitsPerValue_for_packingType(packing_spec->packing_type, packing_spec->bitsPerValue);
|
||||
if (bitsPerValue != packing_spec->bitsPerValue) {
|
||||
fprintf(stderr, "ECCODES WARNING : Cannot pack with requested bitsPerValue (%ld). Using %ld\n",
|
||||
packing_spec->bitsPerValue, bitsPerValue);
|
||||
}
|
||||
SET_LONG_VALUE("bitsPerValue", bitsPerValue);
|
||||
}
|
||||
break;
|
||||
|
||||
case GRIB_UTIL_ACCURACY_SAME_DECIMAL_SCALE_FACTOR_AS_INPUT: {
|
||||
long decimalScaleFactor = 0;
|
||||
Assert(grib_get_long(h, "decimalScaleFactor", &decimalScaleFactor) == 0);
|
||||
SET_LONG_VALUE("decimalScaleFactor", decimalScaleFactor);
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case GRIB_UTIL_ACCURACY_USE_PROVIDED_DECIMAL_SCALE_FACTOR:
|
||||
SET_LONG_VALUE("decimalScaleFactor", packing_spec->decimalScaleFactor);
|
||||
|
|
2008
src/grib_yacc.cc
2008
src/grib_yacc.cc
File diff suppressed because it is too large
Load Diff
|
@ -703,13 +703,17 @@ trigger_block: TRIGGER '(' argument_list ')' '{' instructions '}' { $$ = grib_ac
|
|||
|
||||
concept_block: CONCEPT IDENT '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$2,$4,0,0,0,0,0,0,$6,0); free($2); }
|
||||
| CONCEPT IDENT '(' IDENT ')' '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$2,$7,0,0,$4,0,0,0,$9,0); free($2);free($4); }
|
||||
| CONCEPT IDENT '(' IDENT ',' STRING ',' IDENT ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$2,0,$6,0,$4,$8,$10,0,$12,0); free($2);free($6);free($4);free($8);free($10); }
|
||||
| CONCEPT IDENT '(' IDENT ',' STRING ',' IDENT ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$2,0,$6,0,$4,$8,$10,0,$12,0); free($2);free($6);free($4);free($8);free($10); }
|
||||
| CONCEPT IDENT '(' IDENT ',' IDENT ',' IDENT ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$2,0,$6,0,$4,$8,$10,0,$12,0); free($2);free($6);free($4);free($8);free($10); }
|
||||
| CONCEPT IDENT '(' IDENT ',' STRING ',' IDENT ',' IDENT ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$2,0,$6,0,$4,$8,$10,$12,$14,0); free($2);free($6);free($4);free($8);free($10);free($12); }
|
||||
| CONCEPT IDENT '(' IDENT ',' STRING ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$2,0,$6,0,$4,$8,0,0,$10,0); free($2);free($6);free($4);free($8); }
|
||||
|
||||
| CONCEPT IDENT '.' IDENT '(' IDENT ',' STRING ',' IDENT ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$4,0,$8,$2,$6,$10,$12,0,$14,0); free($4);free($8);free($6);free($10); free($12); free($2);}
|
||||
| CONCEPT IDENT '.' IDENT '(' IDENT ',' IDENT ',' IDENT ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$4,0,$8,$2,$6,$10,$12,0,$14,0); free($4);free($8);free($6);free($10); free($12); free($2);}
|
||||
| CONCEPT IDENT '.' IDENT '(' IDENT ',' STRING ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$4,0,$8,$2,$6,$10,0,0,$12,0); free($4);free($8);free($6);free($10); free($2);}
|
||||
| CONCEPT IDENT '.' IDENT '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$4,$6,0,$2,0,0,0,0,$8,0); free($2);free($4); }
|
||||
| CONCEPT IDENT '.' IDENT '(' IDENT ')' '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$4,$9,0,$2,$6,0,0,0,$11,0); free($2);free($4);free($6); }
|
||||
|
||||
| CONCEPT_NOFAIL IDENT '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$2,$4,0,0,0,0,0,0,$6,1); free($2); }
|
||||
| CONCEPT_NOFAIL IDENT '(' IDENT ')' '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$2,$7,0,0,$4,0,0,0,$9,1); free($2);free($4); }
|
||||
| CONCEPT_NOFAIL IDENT '(' IDENT ',' STRING ',' IDENT ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$2,0,$6,0,$4,$8,$10,0,$12,1); free($2);free($6);free($4);free($8);free($10); }
|
||||
|
|
|
@ -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,6 +275,7 @@ if( HAVE_BUILD_TOOLS )
|
|||
grib_ecc-1467
|
||||
grib_ecc-1764
|
||||
grib_ecc-1792
|
||||
grib_ecc-1806
|
||||
grib_ecc-1907
|
||||
grib_modelName
|
||||
grib_sub_hourly
|
||||
|
|
|
@ -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 )
|
||||
|
||||
|
|
Loading…
Reference in New Issue