Merge branch 'ecmwf:develop' into feature/stepConversion

This commit is contained in:
rdosinski 2024-03-08 08:15:55 +00:00 committed by GitHub
commit c6737bb195
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 84 additions and 137 deletions

View File

@ -72,7 +72,7 @@ int main(int argc, char** argv)
}
/* open output file */
of = fopen(ofilename, "w");
of = fopen(ofilename, "wb");
if (!of) {
fprintf(stderr, "ERROR: unable to open output file %s\n", ofilename);
exit(1);

View File

@ -9,20 +9,20 @@
. ./include.ctest.sh
#if [ ! -f "${data_dir}/sample.grib2" ]
#then
# echo SKIP: $0
# exit
#fi
label="grib_multi_write_c"
tempGrib=temp.$label.grib
tempText=temp.$label.txt
${examples_dir}/c_grib_multi_write ${data_dir}/sample.grib2 ${data_dir}/multi_sample.grib2 > /dev/null
${examples_dir}/c_grib_multi_write ${data_dir}/sample.grib2 $tempGrib > /dev/null
${tools_dir}/grib_get -p step ${data_dir}/multi_sample.grib2 > ${data_dir}/multi_step.test
${tools_dir}/grib_get -p step $tempGrib > $tempText
diff ${data_dir}/multi_step.test ${data_dir}/multi_step.txt
step=`${tools_dir}/grib_get -M -p step ${data_dir}/multi_sample.grib2`
reference=${data_dir}/multi_step.txt
diff $reference $tempText
# -M = Turn multi-field support off
step=`${tools_dir}/grib_get -M -p step $tempGrib`
[ $step -eq 12 ]
rm -f ${data_dir}/multi_sample.grib2 ${data_dir}/multi_step.test
# Clean up
rm -f $tempGrib $tempText

Binary file not shown.

View File

@ -17,7 +17,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
MEMBERS = const char* owner
MEMBERS = int bit_index
END_CLASS_DEF
@ -36,7 +36,6 @@ or edit "accessor.class" and rerun ./make_class.pl
static int pack_long(grib_accessor*, const long* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_bit
@ -60,7 +59,7 @@ static grib_accessor_class _grib_accessor_class_bit = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -112,10 +111,6 @@ static void init(grib_accessor* a, const long len, grib_arguments* arg)
self->bit_index = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{

View File

@ -24,7 +24,7 @@ CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long
IMPLEMENTS = unpack_string_array
IMPLEMENTS = init;dump;destroy
IMPLEMENTS = init;destroy
IMPLEMENTS = value_count
MEMBERS = const char* expandedDescriptors
MEMBERS = grib_accessor* expandedDescriptorsAccessor
@ -47,7 +47,6 @@ static int unpack_long(grib_accessor*, long* val, size_t* len);
static int unpack_string_array(grib_accessor*, char**, size_t* len);
static int value_count(grib_accessor*, long*);
static void destroy(grib_context*, grib_accessor*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_bufrdc_expanded_descriptors
@ -71,7 +70,7 @@ static grib_accessor_class _grib_accessor_class_bufrdc_expanded_descriptors = {
&init, /* init */
0, /* post_init */
&destroy, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
&value_count, /* get number of values */
@ -125,11 +124,6 @@ static void init(grib_accessor* a, const long len, grib_arguments* args)
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static grib_accessor* get_accessor(grib_accessor* a)
{
grib_accessor_bufrdc_expanded_descriptors* self = (grib_accessor_bufrdc_expanded_descriptors*)a;

View File

@ -26,7 +26,7 @@ SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long
IMPLEMENTS = unpack_double
IMPLEMENTS = unpack_string_array
IMPLEMENTS = init;dump;destroy
IMPLEMENTS = init;destroy
IMPLEMENTS = value_count; get_native_type
MEMBERS = const char* unexpandedDescriptors
MEMBERS = const char* sequence
@ -59,7 +59,6 @@ static int unpack_long(grib_accessor*, long* val, size_t* len);
static int unpack_string_array(grib_accessor*, char**, size_t* len);
static int value_count(grib_accessor*, long*);
static void destroy(grib_context*, grib_accessor*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_expanded_descriptors
@ -90,7 +89,7 @@ static grib_accessor_class _grib_accessor_class_expanded_descriptors = {
&init, /* init */
0, /* post_init */
&destroy, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
&value_count, /* get number of values */
@ -180,11 +179,6 @@ static void init(grib_accessor* a, const long len, grib_arguments* args)
a->length = 0;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static bufr_descriptors_array* do_expand(grib_accessor* a, bufr_descriptors_array* unexpanded, change_coding_params* ccp, int* err);
#define BUFR_DESCRIPTORS_ARRAY_USED_SIZE(v) ((v)->n)

View File

@ -17,7 +17,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long;unpack_string
IMPLEMENTS = init;dump;value_count
IMPLEMENTS = init;value_count
MEMBERS=const char* century
MEMBERS=const char* year
MEMBERS=const char* month
@ -40,7 +40,6 @@ static int pack_long(grib_accessor*, const long* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static int unpack_string(grib_accessor*, char*, size_t* len);
static int value_count(grib_accessor*, long*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_g1date
@ -66,7 +65,7 @@ static grib_accessor_class _grib_accessor_class_g1date = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
&value_count, /* get number of values */
@ -122,11 +121,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
self->day = grib_arguments_get_name(hand, c, n++);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_g1date* self = (grib_accessor_g1date*)a;

View File

@ -22,7 +22,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
MEMBERS=const char* date
END_CLASS_DEF
@ -39,7 +39,6 @@ or edit "accessor.class" and rerun ./make_class.pl
*/
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_g1monthlydate
@ -62,7 +61,7 @@ static grib_accessor_class _grib_accessor_class_g1monthlydate = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -115,11 +114,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_g1monthlydate* self = (grib_accessor_g1monthlydate*)a;

View File

@ -17,7 +17,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
MEMBERS=const char* date
MEMBERS=const char* time
MEMBERS=const char* step
@ -36,7 +36,6 @@ or edit "accessor.class" and rerun ./make_class.pl
*/
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_g1verificationdate
@ -61,7 +60,7 @@ static grib_accessor_class _grib_accessor_class_g1verificationdate = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -117,11 +116,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_g1verificationdate* self = (grib_accessor_g1verificationdate*)a;

View File

@ -16,7 +16,7 @@
START_CLASS_DEF
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long;init;dump
IMPLEMENTS = unpack_long;pack_long;init
MEMBERS=const char* century
MEMBERS=const char* year
MEMBERS=const char* month
@ -37,7 +37,6 @@ or edit "accessor.class" and rerun ./make_class.pl
static int pack_long(grib_accessor*, const long* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_g2date
@ -63,7 +62,7 @@ static grib_accessor_class _grib_accessor_class_g2date = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -116,11 +115,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
self->day = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
const grib_accessor_g2date* self = (grib_accessor_g2date*)a;

View File

@ -17,7 +17,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_double;pack_double
IMPLEMENTS = unpack_long;pack_long;init;dump;is_missing
IMPLEMENTS = unpack_long;pack_long;init;is_missing
MEMBERS=const char* type_first
MEMBERS=const char* scale_first
MEMBERS=const char* value_first
@ -41,7 +41,6 @@ static int pack_double(grib_accessor*, const double* val, size_t* len);
static int pack_long(grib_accessor*, const long* val, size_t* len);
static int unpack_double(grib_accessor*, double* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_g2level
@ -67,7 +66,7 @@ static grib_accessor_class _grib_accessor_class_g2level = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -126,11 +125,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
a->flags |= GRIB_ACCESSOR_FLAG_COPY_IF_CHANGING_EDITION;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static bool is_tigge(grib_handle* h)
{
long productionStatus = 0;

View File

@ -17,7 +17,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
MEMBERS=const char* typicalYear
MEMBERS=const char* typicalMonth
MEMBERS=const char* typicalDay
@ -39,7 +39,6 @@ or edit "accessor.class" and rerun ./make_class.pl
static int pack_long(grib_accessor*, const long* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_rdbtime_guess_date
@ -66,7 +65,7 @@ static grib_accessor_class _grib_accessor_class_rdbtime_guess_date = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -124,11 +123,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
/* a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; */
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_rdbtime_guess_date* self = (grib_accessor_rdbtime_guess_date*)a;

View File

@ -16,7 +16,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
IMPLEMENTS = next_offset
IMPLEMENTS = byte_count
IMPLEMENTS = value_count
@ -45,7 +45,6 @@ static long byte_count(grib_accessor*);
static long byte_offset(grib_accessor*);
static long next_offset(grib_accessor*);
static int value_count(grib_accessor*, long*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
static void update_size(grib_accessor*, size_t);
@ -70,7 +69,7 @@ static grib_accessor_class _grib_accessor_class_signed_bits = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
&next_offset, /* next_offset */
0, /* get length of string */
&value_count, /* get number of values */
@ -152,11 +151,6 @@ static void init(grib_accessor* a, const long len, grib_arguments* args)
a->length = compute_byte_count(a);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
return GRIB_NOT_IMPLEMENTED;

View File

@ -16,7 +16,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
IMPLEMENTS = next_offset
IMPLEMENTS = byte_count
IMPLEMENTS = value_count
@ -45,7 +45,6 @@ static long byte_count(grib_accessor*);
static long byte_offset(grib_accessor*);
static long next_offset(grib_accessor*);
static int value_count(grib_accessor*, long*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
static void update_size(grib_accessor*, size_t);
@ -70,7 +69,7 @@ static grib_accessor_class _grib_accessor_class_spd = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
&next_offset, /* next_offset */
0, /* get length of string */
&value_count, /* get number of values */
@ -153,11 +152,6 @@ static void init(grib_accessor* a, const long len, grib_arguments* args)
a->length = compute_byte_count(a);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_spd* self = (grib_accessor_spd*)a;

View File

@ -18,7 +18,7 @@
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long
IMPLEMENTS = unpack_string
IMPLEMENTS = init;dump
IMPLEMENTS = init
MEMBERS=const char* hour
MEMBERS=const char* minute
MEMBERS=const char* second
@ -39,7 +39,6 @@ or edit "accessor.class" and rerun ./make_class.pl
static int pack_long(grib_accessor*, const long* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static int unpack_string(grib_accessor*, char*, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_time
@ -64,7 +63,7 @@ static grib_accessor_class _grib_accessor_class_time = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -119,11 +118,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
self->second = grib_arguments_get_name(hand, c, n++);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
const grib_accessor_time* self = (grib_accessor_time*)a;

View File

@ -17,7 +17,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
MEMBERS=const char* date
MEMBERS=const char* time
MEMBERS=const char* step
@ -40,7 +40,6 @@ or edit "accessor.class" and rerun ./make_class.pl
*/
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_validity_date
@ -69,7 +68,7 @@ static grib_accessor_class _grib_accessor_class_validity_date = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -165,11 +164,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_validity_date* self = (grib_accessor_validity_date*)a;

View File

@ -18,7 +18,7 @@
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long
IMPLEMENTS = unpack_string
IMPLEMENTS = init;dump
IMPLEMENTS = init
MEMBERS=const char* date
MEMBERS=const char* time
MEMBERS=const char* step
@ -41,7 +41,6 @@ or edit "accessor.class" and rerun ./make_class.pl
static int unpack_long(grib_accessor*, long* val, size_t* len);
static int unpack_string(grib_accessor*, char*, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_validity_time
@ -69,7 +68,7 @@ static grib_accessor_class _grib_accessor_class_validity_time = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -164,11 +163,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_validity_time* self = (grib_accessor_validity_time*)a;

View File

@ -208,11 +208,16 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
const double dval = *val;
if (*len != 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values", a->name, 1);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %d values", a->name, 1);
*len = 1;
return GRIB_ARRAY_TOO_SMALL;
}
//if (std::isnan(dval)) {
// grib_context_log(a->context, GRIB_LOG_ERROR, "%s: Invalid number for %s: %g", __func__, a->name, dval);
// return GRIB_INVALID_ARGUMENT;
//}
self->dval = dval;
if (dval < (double)LONG_MIN || dval > (double)LONG_MAX)
self->type = GRIB_TYPE_DOUBLE;

View File

@ -1748,6 +1748,13 @@ static void set_value(grib_values* value, char* str, int equal)
case GRIB_TYPE_UNDEFINED:
value->long_value = strtol(buf, &p, 10);
if (*p == 0) {
// check the conversion from string to long
if ((errno == ERANGE && (value->long_value == LONG_MAX || value->long_value == LONG_MIN)) ||
(errno != 0 && value->long_value == 0)) {
fprintf(stderr, "ECCODES WARNING : Setting %s=%s causes overflow/underflow\n", value->name, buf);
fprintf(stderr, "ECCODES WARNING : Value adjusted to %ld\n", value->long_value);
//perror("strtol");
}
value->type = GRIB_TYPE_LONG;
value->has_value = 1;
}

View File

@ -26,9 +26,9 @@ sample_bufr4=$ECCODES_SAMPLES_PATH/BUFR4.tmpl
# ------------------
infile=$sample_grib2
result=$(${tools_dir}/grib_get -p maximum:s $infile)
[ "$result" = "1" ]
[ "$result" = "273" ]
result=$(${tools_dir}/grib_get -s formatForDoubles=%e -p maximum:s $infile)
[ "$result" = "1.000000e+00" ]
[ "$result" = "2.730000e+02" ]
infile=${data_dir}/sample.grib2
result=$(${tools_dir}/grib_get -s formatForDoubles=%e -p minimum:s $infile)

View File

@ -28,6 +28,13 @@ sample_ccsds=$ECCODES_SAMPLES_PATH/ccsds_grib2.tmpl
unset ECCODES_GRIB_DATA_QUALITY_CHECKS
unset ECCODES_EXTRA_DEFINITION_PATH
echo "Data quality checks enabled. Packing samples should work"
# -------------------------------------------------------------
export ECCODES_GRIB_DATA_QUALITY_CHECKS=1
${tools_dir}/grib_copy -r $sample_g1 /dev/null
${tools_dir}/grib_copy -r $sample_g2 /dev/null
unset ECCODES_GRIB_DATA_QUALITY_CHECKS
# These input files are 2m temperature with min=221.76 and max=311.619
input1=${data_dir}/reduced_gaussian_surface.grib1
input2=${data_dir}/reduced_gaussian_surface.grib2
@ -51,6 +58,7 @@ set -e
grep -q 'more than the allowable limit' $tempErr
unset ECCODES_DEBUG
echo "Data quality checks enabled but only as a warning. Repacking should pass..."
# --------------------------------------------------------------------------------
export ECCODES_GRIB_DATA_QUALITY_CHECKS=2
@ -110,7 +118,8 @@ ${tools_dir}/grib_set -s paramId=$pid,scaleValuesBy=0.01 $input2 $tempOut
echo "Test close to the limit..."
# ---------------------------------
${tools_dir}/grib_set -s paramId=$pid $sample_g2 $tempGrib2
# The GRIB2 sample has max values of 273. We need to use 1 for this test
${tools_dir}/grib_set -s paramId=$pid,values=1 $sample_g2 $tempGrib2
${tools_dir}/grib_set -s scaleValuesBy=3 $tempGrib2 $tempOut # OK
set +e
${tools_dir}/grib_set -s scaleValuesBy=3.6 $tempGrib2 $tempOut
@ -189,11 +198,13 @@ cat > $tempDir/param_limits.def <<EOF
} : double_type, hidden;
EOF
# Step of 12 satisfies the condition: it is even and > 4
${tools_dir}/grib_set -s paramId=260509,step=12,scaleValuesBy=1000 $sample_g2 $tempGrib2
# The GRIB2 sample has max values of 273. We need to use 1 for this test
${tools_dir}/grib_set -s paramId=260509,step=12,values=1,scaleValuesBy=1000 $sample_g2 $tempGrib2
# Step of 0 doesn't satisfy the condition so will use 400
# The GRIB2 sample has max values of 273. We need to use 1 for this test
set +e
${tools_dir}/grib_set -s paramId=260509,scaleValuesBy=1000 $sample_g2 $tempGrib2
${tools_dir}/grib_set -s paramId=260509,values=1,scaleValuesBy=1000 $sample_g2 $tempGrib2
status=$?
set -e
[ $status -ne 0 ]

View File

@ -10,6 +10,9 @@
. ./include.ctest.sh
label="grib_decimalPrecision_test"
temp=temp.$label.grib
REDIRECT=/dev/null
files="regular_latlon_surface.grib2 \
@ -29,7 +32,6 @@ for file in $files; do
done
# ECC-458: spectral_complex packing
temp=temp.grib_decimalPrecision.grib
infile=${data_dir}/spectral_complex.grib1
# Catch errors re negative values
export ECCODES_FAIL_IF_LOG_MESSAGE=1
@ -42,7 +44,7 @@ sample2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
${tools_dir}/grib_set -s decimalScaleFactor=3 $sample1 $temp
grib_check_key_equals $temp min,max,const,decimalScaleFactor,referenceValue '47485.4 47485.4 1 3 47485.4'
${tools_dir}/grib_set -s decimalScaleFactor=3 $sample2 $temp
grib_check_key_equals $temp min,max,const,decimalScaleFactor,referenceValue '1 1 1 3 1'
grib_check_key_equals $temp min,max,const,decimalScaleFactor,referenceValue '273 273 1 3 273'
# Clean up
rm -f $temp

View File

@ -23,6 +23,6 @@ $sample_grib2 $temp
grib_check_key_equals $temp Ni,Nj "16 31"
grib_check_key_equals $temp centreLatitudeInDegrees,centreLongitudeInDegrees "0 30"
grib_check_key_equals $temp minimum,maximum "1 1"
grib_check_key_equals $temp minimum,maximum "273 273"
rm -f $temp

View File

@ -19,7 +19,7 @@ temp=${data_dir}/temp.$label.out
infile=${data_dir}/regular_gaussian_surface.grib2
# Set without -s. Expected to fail
# Set without -s
# ----------------------------------------------------
set +e
${tools_dir}/grib_set -p levtype $infile $outfile > $temp 2>&1
@ -28,7 +28,7 @@ set -e
[ $status -ne 0 ]
grep -q "provide some keys to set" $temp
# Set with empty -s. Expected to fail
# Set with empty -s
# ----------------------------------------------------
set +e
${tools_dir}/grib_set -s '' $infile $outfile > $temp 2>&1
@ -37,7 +37,7 @@ set -e
[ $status -ne 0 ]
grep -q "provide some keys to set" $temp
# Out-of-bounds value. Expected to fail
# Out-of-bounds value
# ----------------------------------------------------
input=${data_dir}/reduced_gaussian_sub_area.grib2
set +e
@ -47,7 +47,7 @@ set -e
[ $status -ne 0 ]
grep -q "Trying to encode value of 1000 but the maximum allowable value is 255 (number of bits=8)" $temp
# Negative value for an unsigned key. Expected to fail
# Negative value for an unsigned key
# ----------------------------------------------------
input=${data_dir}/reduced_gaussian_sub_area.grib2
set +e
@ -181,6 +181,11 @@ set -e
[ $status -ne 0 ]
grep -q "centre: No such code table entry.*Did you mean.*ecmf" $temp
# Overflow/Underflow
# ------------------------
input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
${tools_dir}/grib_set -s missingValue=9223372036854776666 $input $outfile > $temp 2>&1
grep -q "ECCODES WARNING : Setting .* causes overflow/underflow" $temp
# ------------------------
# Unreadable message