Merge branch 'develop' into feature/ECC-1620_sub-hourly

This commit is contained in:
Shahram Najm 2023-12-09 17:43:51 +00:00
commit f297de4278
33 changed files with 27722 additions and 30227 deletions

View File

@ -1339,3 +1339,15 @@
parameterCategory = 128 ; parameterCategory = 128 ;
parameterNumber = 124 ; parameterNumber = 124 ;
} }
#Vertical integral of water vapour
'p55.162' = {
discipline = 192 ;
parameterCategory = 162 ;
parameterNumber = 55 ;
}
#Snow depth
'sdsien' = {
discipline = 192 ;
parameterCategory = 190 ;
parameterNumber = 141 ;
}

View File

@ -1339,3 +1339,15 @@
parameterCategory = 128 ; parameterCategory = 128 ;
parameterNumber = 124 ; parameterNumber = 124 ;
} }
#Vertical integral of water vapour
'Vertical integral of water vapour' = {
discipline = 192 ;
parameterCategory = 162 ;
parameterNumber = 55 ;
}
#Snow depth
'Snow depth' = {
discipline = 192 ;
parameterCategory = 190 ;
parameterNumber = 141 ;
}

View File

@ -1339,3 +1339,15 @@
parameterCategory = 128 ; parameterCategory = 128 ;
parameterNumber = 124 ; parameterNumber = 124 ;
} }
#Vertical integral of water vapour
'162055' = {
discipline = 192 ;
parameterCategory = 162 ;
parameterNumber = 55 ;
}
#Snow depth
'190141' = {
discipline = 192 ;
parameterCategory = 190 ;
parameterNumber = 141 ;
}

View File

@ -1339,3 +1339,15 @@
parameterCategory = 128 ; parameterCategory = 128 ;
parameterNumber = 124 ; parameterNumber = 124 ;
} }
#Vertical integral of water vapour
'viwv' = {
discipline = 192 ;
parameterCategory = 162 ;
parameterNumber = 55 ;
}
#Snow depth
'sdsien' = {
discipline = 192 ;
parameterCategory = 190 ;
parameterNumber = 141 ;
}

View File

@ -1339,3 +1339,15 @@
parameterCategory = 128 ; parameterCategory = 128 ;
parameterNumber = 124 ; parameterNumber = 124 ;
} }
#Vertical integral of water vapour
'kg m**-2' = {
discipline = 192 ;
parameterCategory = 162 ;
parameterNumber = 55 ;
}
#Snow depth
'kg m**-2' = {
discipline = 192 ;
parameterCategory = 190 ;
parameterNumber = 141 ;
}

View File

@ -62,6 +62,8 @@ int main(int argc, char** argv)
/* Can also set to MISSING via codes_set_string */ /* Can also set to MISSING via codes_set_string */
CODES_CHECK(codes_set_string(h, "scaleFactorOfFirstFixedSurface", "missing", &str_len), 0); CODES_CHECK(codes_set_string(h, "scaleFactorOfFirstFixedSurface", "missing", &str_len), 0);
CODES_CHECK(codes_set_string(h, "scaledValueOfFirstFixedSurface", "missing", &str_len), 0); CODES_CHECK(codes_set_string(h, "scaledValueOfFirstFixedSurface", "missing", &str_len), 0);
/* Set a Code Table key to missing via codes_set_string */
CODES_CHECK(codes_set_string(h, "typeOfFirstFixedSurface", "missing", &str_len), 0);
/* see GRIB-490 */ /* see GRIB-490 */
CODES_CHECK(codes_get_long(h, "Ni", &Ni), 0); CODES_CHECK(codes_get_long(h, "Ni", &Ni), 0);

View File

@ -20,6 +20,10 @@ if [ -f "${tools_dir}/grib_get" ]; then
[ "$sf" = "MISSING" ] [ "$sf" = "MISSING" ]
sf=`${tools_dir}/grib_get -p scaledValueOfFirstFixedSurface $tempGrib` sf=`${tools_dir}/grib_get -p scaledValueOfFirstFixedSurface $tempGrib`
[ "$sf" = "MISSING" ] [ "$sf" = "MISSING" ]
# Code Table key being set to missing
sf=`${tools_dir}/grib_get -p typeOfFirstFixedSurface:i, $tempGrib`
[ "$sf" = "255" ]
fi fi
rm -f $tempGrib rm -f $tempGrib

View File

@ -196,6 +196,7 @@ int main(int argc, char** argv)
/* 255 = Missing (grib2/tables/4/4.5.table) */ /* 255 = Missing (grib2/tables/4/4.5.table) */
CODES_CHECK(codes_set_long(h, "typeOfSecondFixedSurface", 255), 0); CODES_CHECK(codes_set_long(h, "typeOfSecondFixedSurface", 255), 0);
CODES_CHECK(codes_set_missing(h, "typeOfSecondFixedSurface"), 0);
CODES_CHECK(codes_set_missing(h, "scaleFactorOfSecondFixedSurface"), 0); CODES_CHECK(codes_set_missing(h, "scaleFactorOfSecondFixedSurface"), 0);
CODES_CHECK(codes_set_missing(h, "scaledValueOfSecondFixedSurface"), 0); CODES_CHECK(codes_set_missing(h, "scaledValueOfSecondFixedSurface"), 0);

Binary file not shown.

View File

@ -1147,6 +1147,7 @@ int grib_set_missing(grib_handle* h, const char* name);
int grib_is_missing_long(grib_accessor* a, long x); int grib_is_missing_long(grib_accessor* a, long x);
int grib_is_missing_double(grib_accessor* a, double x); int grib_is_missing_double(grib_accessor* a, double x);
int grib_is_missing_string(grib_accessor* a, const unsigned char* x, size_t len); int grib_is_missing_string(grib_accessor* a, const unsigned char* x, size_t len);
int grib_accessor_can_be_missing(grib_accessor* a, int* err);
int grib_accessor_is_missing(grib_accessor* a, int* err); int grib_accessor_is_missing(grib_accessor* a, int* err);
int grib_is_missing(const grib_handle* h, const char* name, int* err); int grib_is_missing(const grib_handle* h, const char* name, int* err);
int grib_is_defined(const grib_handle* h, const char* name); int grib_is_defined(const grib_handle* h, const char* name);
@ -1160,8 +1161,8 @@ int grib_set_float_array(grib_handle* h, const char* name, const float* val, siz
int grib_set_long_array_internal(grib_handle* h, const char* name, const long* val, size_t length); int grib_set_long_array_internal(grib_handle* h, const char* name, const long* val, size_t length);
int grib_set_long_array(grib_handle* h, const char* name, const long* val, size_t length); int grib_set_long_array(grib_handle* h, const char* name, const long* val, size_t length);
int grib_get_long_internal(grib_handle* h, const char* name, long* val); int grib_get_long_internal(grib_handle* h, const char* name, long* val);
int grib_is_in_dump(grib_handle* h, const char* name); int grib_is_in_dump(const grib_handle* h, const char* name);
int grib_attributes_count(grib_accessor* a, size_t* size); int grib_attributes_count(const grib_accessor* a, size_t* size);
int grib_get_long(const grib_handle* h, const char* name, long* val); int grib_get_long(const grib_handle* h, const char* name, long* val);
int grib_get_double_internal(grib_handle* h, const char* name, double* val); int grib_get_double_internal(grib_handle* h, const char* name, double* val);
int grib_get_double(const grib_handle* h, const char* name, double* val); int grib_get_double(const grib_handle* h, const char* name, double* val);
@ -1207,7 +1208,7 @@ int grib_set_values(grib_handle* h, grib_values* args, size_t count);
int grib_get_nearest_smaller_value(grib_handle* h, const char* name, double val, double* nearest); int grib_get_nearest_smaller_value(grib_handle* h, const char* name, double val, double* nearest);
void grib_print_values(const char* title, grib_values* values); void grib_print_values(const char* title, grib_values* values);
int grib_values_check(grib_handle* h, grib_values* values, int count); int grib_values_check(grib_handle* h, grib_values* values, int count);
int grib_key_equal(grib_handle* h1, grib_handle* h2, const char* key, int type, int* err); int grib_key_equal(const grib_handle* h1, const grib_handle* h2, const char* key, int type, int* err);
int codes_copy_key(grib_handle* h1, grib_handle* h2, const char* key, int type); int codes_copy_key(grib_handle* h1, grib_handle* h2, const char* key, int type);
int codes_compare_key(grib_handle* h1, grib_handle* h2, const char* key, int compare_flags); int codes_compare_key(grib_handle* h1, grib_handle* h2, const char* key, int compare_flags);

View File

@ -50,7 +50,7 @@ static void thread_init()
CLASS = accessor CLASS = accessor
SUPER = grib_accessor_class_unsigned SUPER = grib_accessor_class_unsigned
IMPLEMENTS = init;dump;unpack_string;pack_expression;unpack_long IMPLEMENTS = init;dump;unpack_string;pack_expression;unpack_long
IMPLEMENTS = value_count;pack_string; destroy; get_native_type; IMPLEMENTS = value_count;pack_string; destroy; get_native_type;pack_missing
MEMBERS = const char* tablename MEMBERS = const char* tablename
MEMBERS = const char* masterDir MEMBERS = const char* masterDir
MEMBERS = const char* localDir MEMBERS = const char* localDir
@ -71,6 +71,7 @@ or edit "accessor.class" and rerun ./make_class.pl
*/ */
static int get_native_type(grib_accessor*); static int get_native_type(grib_accessor*);
static int pack_missing(grib_accessor*);
static int pack_string(grib_accessor*, const char*, size_t* len); static int pack_string(grib_accessor*, const char*, size_t* len);
static int pack_expression(grib_accessor*, grib_expression*); static int pack_expression(grib_accessor*, grib_expression*);
static int unpack_long(grib_accessor*, long* val, size_t* len); static int unpack_long(grib_accessor*, long* val, size_t* len);
@ -115,7 +116,7 @@ static grib_accessor_class _grib_accessor_class_codetable = {
0, /* get offset to bytes */ 0, /* get offset to bytes */
&get_native_type, /* get native type */ &get_native_type, /* get native type */
0, /* get sub_section */ 0, /* get sub_section */
0, /* pack_missing */ &pack_missing, /* pack_missing */
0, /* is_missing */ 0, /* is_missing */
0, /* pack_long */ 0, /* pack_long */
&unpack_long, /* unpack_long */ &unpack_long, /* unpack_long */
@ -736,6 +737,10 @@ static int pack_string(grib_accessor* a, const char* buffer, size_t* len)
return grib_pack_long(a, &lValue, &l); return grib_pack_long(a, &lValue, &l);
} }
if (STR_EQUAL_NOCASE(buffer, "missing")) {
return pack_missing(a);
}
grib_accessor_codetable* self = (grib_accessor_codetable*)a; grib_accessor_codetable* self = (grib_accessor_codetable*)a;
grib_codetable* table; grib_codetable* table;
long i; long i;
@ -912,3 +917,27 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
*len = rlen; *len = rlen;
return GRIB_SUCCESS; return GRIB_SUCCESS;
} }
static int pack_missing(grib_accessor* a)
{
// Many of the code tables do have a 'Missing' entry (all bits = 1)
// So it is more user-friendly to allow setting codetable keys to
// missing. For tables that do not have such an entry, an error is issued
grib_accessor_codetable* self = (grib_accessor_codetable*)a;
grib_handle* h = grib_handle_of_accessor(a);
const long nbytes = a->length;
const long nbits = nbytes*8;
const long maxVal = (1<<nbits) - 1;
int err = codes_codetable_check_code_figure(h, a->name, maxVal);
if (!err) {
size_t l = 1;
return grib_pack_long(a, &maxVal, &l);
}
grib_context_log(a->context, GRIB_LOG_ERROR, "There is no 'missing' entry in Code Table %s (%s)",
self->tablename, grib_get_error_message(err));
return err;
}

View File

@ -258,7 +258,7 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
long v = 0; /* The converted value */ long v = 0; /* The converted value */
// ECC-1722 // ECC-1722
if (strcmp_nocase(val, "missing")==0) { if (STR_EQUAL_NOCASE(val, "missing")) {
return pack_missing(a); return pack_missing(a);
} }

View File

@ -201,6 +201,8 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type);
/* Return true if two strings are equal */ /* Return true if two strings are equal */
#define STR_EQUAL(a, b) (strcmp((a), (b)) == 0) #define STR_EQUAL(a, b) (strcmp((a), (b)) == 0)
/* Return true if two strings are equal, ignoring case */
#define STR_EQUAL_NOCASE(a, b) (strcmp_nocase((a), (b)) == 0)
#include "grib_api.h" #include "grib_api.h"
@ -862,6 +864,7 @@ struct grib_handle
/* grib_trie* bufr_elements_table; */ /* grib_trie* bufr_elements_table; */
}; };
/* For GRIB2 multi-field messages */
struct grib_multi_handle struct grib_multi_handle
{ {
grib_context* context; /** < context attached to this handle */ grib_context* context; /** < context attached to this handle */
@ -938,7 +941,6 @@ struct grib_accessor_class
}; };
typedef struct grib_multi_support grib_multi_support; typedef struct grib_multi_support grib_multi_support;
struct grib_multi_support struct grib_multi_support
{ {
FILE* file; FILE* file;
@ -955,7 +957,6 @@ struct grib_multi_support
/* Hash_array */ /* Hash_array */
typedef struct grib_hash_array_value grib_hash_array_value; typedef struct grib_hash_array_value grib_hash_array_value;
struct grib_hash_array_value struct grib_hash_array_value
{ {
grib_hash_array_value* next; grib_hash_array_value* next;
@ -968,7 +969,6 @@ struct grib_hash_array_value
/* Concepts */ /* Concepts */
typedef struct grib_concept_condition grib_concept_condition; typedef struct grib_concept_condition grib_concept_condition;
struct grib_concept_condition struct grib_concept_condition
{ {
grib_concept_condition* next; grib_concept_condition* next;
@ -985,7 +985,6 @@ struct grib_concept_value_name
}; };
typedef struct grib_concept_value grib_concept_value; typedef struct grib_concept_value grib_concept_value;
struct grib_concept_value struct grib_concept_value
{ {
grib_concept_value* next; grib_concept_value* next;
@ -1416,7 +1415,6 @@ struct cvs_MD5Context
/* --- */ /* --- */
typedef struct grib_rule_entry grib_rule_entry; typedef struct grib_rule_entry grib_rule_entry;
struct grib_rule_entry struct grib_rule_entry
{ {
grib_rule_entry* next; grib_rule_entry* next;
@ -1425,7 +1423,6 @@ struct grib_rule_entry
}; };
typedef struct grib_rule grib_rule; typedef struct grib_rule grib_rule;
struct grib_rule struct grib_rule
{ {
grib_rule* next; grib_rule* next;
@ -1434,7 +1431,6 @@ struct grib_rule
}; };
typedef struct grib_case grib_case; typedef struct grib_case grib_case;
struct grib_case struct grib_case
{ {
grib_arguments* values; grib_arguments* values;
@ -1531,4 +1527,3 @@ typedef struct j2k_encode_helper
#endif #endif
#endif #endif

View File

@ -100,6 +100,55 @@ static int destroy(grib_dumper* d)
return GRIB_SUCCESS; return GRIB_SUCCESS;
} }
static void default_long_value(grib_dumper* d, grib_accessor* a, long actualValue)
{
grib_dumper_debug* self = (grib_dumper_debug*)d;
grib_action* act = a->creator;
if (act->default_value == NULL)
return;
grib_handle* h = grib_handle_of_accessor(a);
grib_expression* expression = grib_arguments_get_expression(h, act->default_value, 0);
if (!expression)
return;
const int type = grib_expression_native_type(h, expression);
if (type == GRIB_TYPE_LONG) {
long defaultValue = 0;
if (grib_expression_evaluate_long(h, expression, &defaultValue) == GRIB_SUCCESS && defaultValue != actualValue) {
if (defaultValue == GRIB_MISSING_LONG)
fprintf(self->dumper.out, " (default=MISSING)");
else
fprintf(self->dumper.out, " (default=%ld)",defaultValue);
}
}
}
// static void default_string_value(grib_dumper* d, grib_accessor* a, const char* actualValue)
// {
// grib_dumper_debug* self = (grib_dumper_debug*)d;
// grib_action* act = a->creator;
// if (act->default_value == NULL)
// return;
// grib_handle* h = grib_handle_of_accessor(a);
// grib_expression* expression = grib_arguments_get_expression(h, act->default_value, 0);
// if (!expression)
// return;
// const int type = grib_expression_native_type(h, expression);
// DEBUG_ASSERT(type == GRIB_TYPE_STRING);
// if (type == GRIB_TYPE_STRING) {
// char tmp[1024] = {0,};
// size_t s_len = sizeof(tmp);
// int err = 0;
// const char* p = grib_expression_evaluate_string(h, expression, tmp, &s_len, &err);
// if (!err && !STR_EQUAL(p, actualValue)) {
// fprintf(self->dumper.out, " (default=%s)", p);
// }
// }
// }
static void aliases(grib_dumper* d, grib_accessor* a) static void aliases(grib_dumper* d, grib_accessor* a)
{ {
int i; int i;
@ -202,6 +251,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
fprintf(self->dumper.out, " *** ERR=%d (%s) [grib_dumper_debug::dump_long]", err, grib_get_error_message(err)); fprintf(self->dumper.out, " *** ERR=%d (%s) [grib_dumper_debug::dump_long]", err, grib_get_error_message(err));
aliases(d, a); aliases(d, a);
default_long_value(d, a, value);
fprintf(self->dumper.out, "\n"); fprintf(self->dumper.out, "\n");
} }

View File

@ -81,7 +81,7 @@ int grib_set_expression(grib_handle* h, const char* name, grib_expression* e)
int grib_set_long_internal(grib_handle* h, const char* name, long val) int grib_set_long_internal(grib_handle* h, const char* name, long val)
{ {
grib_context* c = h->context; const grib_context* c = h->context;
int ret = GRIB_SUCCESS; int ret = GRIB_SUCCESS;
grib_accessor* a = NULL; grib_accessor* a = NULL;
size_t l = 1; size_t l = 1;
@ -213,8 +213,8 @@ int grib_copy_namespace(grib_handle* dest, const char* name, grib_handle* src)
grib_accessor* a = NULL; grib_accessor* a = NULL;
key_err = first; key_err = first;
while (key_err) { while (key_err) {
char* key = key_err->name; const char* key = key_err->name;
err = &(key_err->err); err = &(key_err->err);
if (*err == GRIB_SUCCESS) { if (*err == GRIB_SUCCESS) {
key_err = key_err->next; key_err = key_err->next;
@ -571,7 +571,7 @@ int grib_set_missing(grib_handle* h, const char* name)
if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY)
return GRIB_READ_ONLY; return GRIB_READ_ONLY;
if (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) { if (grib_accessor_can_be_missing(a, &ret)) {
if (h->context->debug) if (h->context->debug)
fprintf(stderr, "ECCODES DEBUG grib_set_missing %s\n", name); fprintf(stderr, "ECCODES DEBUG grib_set_missing %s\n", name);
@ -641,6 +641,19 @@ int grib_accessor_is_missing(grib_accessor* a, int* err)
} }
} }
int grib_accessor_can_be_missing(grib_accessor* a, int* err)
{
if (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) {
return 1;
}
if (STR_EQUAL(a->cclass->name, "codetable")) {
// Special case of Code Table keys
// The vast majority have a 'Missing' entry
return 1;
}
return 0;
}
int grib_is_missing(const grib_handle* h, const char* name, int* err) int grib_is_missing(const grib_handle* h, const char* name, int* err)
{ {
grib_accessor* a = grib_find_accessor(h, name); grib_accessor* a = grib_find_accessor(h, name);
@ -650,7 +663,7 @@ int grib_is_missing(const grib_handle* h, const char* name, int* err)
/* Return true if the given key exists (is defined) in our grib message */ /* Return true if the given key exists (is defined) in our grib message */
int grib_is_defined(const grib_handle* h, const char* name) int grib_is_defined(const grib_handle* h, const char* name)
{ {
grib_accessor* a = grib_find_accessor(h, name); const grib_accessor* a = grib_find_accessor(h, name);
return (a ? 1 : 0); return (a ? 1 : 0);
} }
@ -938,16 +951,16 @@ int grib_get_long_internal(grib_handle* h, const char* name, long* val)
return ret; return ret;
} }
int grib_is_in_dump(grib_handle* h, const char* name) int grib_is_in_dump(const grib_handle* h, const char* name)
{ {
grib_accessor* a = grib_find_accessor(h, name); const grib_accessor* a = grib_find_accessor(h, name);
if (a != NULL && (a->flags & GRIB_ACCESSOR_FLAG_DUMP)) if (a != NULL && (a->flags & GRIB_ACCESSOR_FLAG_DUMP))
return 1; return 1;
else else
return 0; return 0;
} }
int grib_attributes_count(grib_accessor* a, size_t* size) int grib_attributes_count(const grib_accessor* a, size_t* size)
{ {
if (a) { if (a) {
*size = 0; *size = 0;
@ -1452,7 +1465,7 @@ int grib_get_length(const grib_handle* h, const char* name, size_t* length)
int grib_get_offset(const grib_handle* ch, const char* key, size_t* val) int grib_get_offset(const grib_handle* ch, const char* key, size_t* val)
{ {
grib_handle* h = (grib_handle*)ch; const grib_handle* h = (grib_handle*)ch;
grib_accessor* act = grib_find_accessor(h, key); grib_accessor* act = grib_find_accessor(h, key);
if (act) { if (act) {
*val = (size_t)grib_byte_offset(act); *val = (size_t)grib_byte_offset(act);
@ -1815,9 +1828,9 @@ int grib_set_values(grib_handle* h, grib_values* args, size_t count)
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (args[i].error != GRIB_SUCCESS) { if (args[i].error != GRIB_SUCCESS) {
grib_context_log(h->context, GRIB_LOG_ERROR, grib_context_log(h->context, GRIB_LOG_ERROR,
"grib_set_values[%d] %s (type=%s) failed: %s", "grib_set_values[%d] %s (type=%s) failed: %s (message %d)",
i, args[i].name, grib_get_type_name(args[i].type), i, args[i].name, grib_get_type_name(args[i].type),
grib_get_error_message(args[i].error)); grib_get_error_message(args[i].error), h->context->handle_file_count);
err = err == GRIB_SUCCESS ? args[i].error : err; err = err == GRIB_SUCCESS ? args[i].error : err;
} }
} }
@ -1918,7 +1931,7 @@ int grib_values_check(grib_handle* h, grib_values* values, int count)
return 0; return 0;
} }
int grib_key_equal(grib_handle* h1, grib_handle* h2, const char* key, int type, int* err) int grib_key_equal(const grib_handle* h1, const grib_handle* h2, const char* key, int type, int* err)
{ {
double d1 = 0, d2 = 0; double d1 = 0, d2 = 0;
long l1 = 0, l2 = 0; long l1 = 0, l2 = 0;

View File

@ -36,7 +36,7 @@ EOF
# Command should fail but not crash # Command should fail but not crash
set +e set +e
${tools_dir}/bufr_filter $tempFilt $sample_bufr4 > $tempOut ${tools_dir}/bufr_filter $tempFilt $sample_bufr4 2> $tempOut
stat=$? stat=$?
set -e set -e
echo stat=$stat echo stat=$stat

View File

@ -67,7 +67,7 @@ int main(int argc, char* argv[])
} }
while (codes_bufr_keys_iterator_next(kiter)) { while (codes_bufr_keys_iterator_next(kiter)) {
char* kname = codes_bufr_keys_iterator_get_name(kiter); const char* kname = codes_bufr_keys_iterator_get_name(kiter);
printf("%s\n", kname); printf("%s\n", kname);
} }
codes_bufr_keys_iterator_delete(kiter); codes_bufr_keys_iterator_delete(kiter);

File diff suppressed because it is too large Load Diff

View File

@ -49,7 +49,7 @@ void* runner(void* ptr)
pthread_exit(0); pthread_exit(0);
} }
static int encode_file(char* input_file, char* output_file) static int encode_file(const char* input_file, const char* output_file)
{ {
grib_handle* source_handle = NULL; grib_handle* source_handle = NULL;
const void* buffer = NULL; const void* buffer = NULL;

View File

@ -365,7 +365,7 @@ cat >$tempFilt <<EOF
assert(edition == 0); assert(edition == 0);
EOF EOF
set +e set +e
${tools_dir}/grib_filter $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut ${tools_dir}/grib_filter $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl 2> $tempOut
status=$? status=$?
set -e set -e
[ $status -ne 0 ] [ $status -ne 0 ]

2693
tests/grib_gridded_values.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -12,8 +12,12 @@
REDIRECT=/dev/null REDIRECT=/dev/null
label="grib_missing_test"
infile="${data_dir}/missing.grib2" infile="${data_dir}/missing.grib2"
outfile="${data_dir}/temp.missing_new.grib2" outfile="${data_dir}/temp.$label.grib2"
tempText=temp.$label.txt
tempGrib=temp.$label.grib
scaleFactorOfSecondFixedSurface=`${tools_dir}/grib_get -w count=1 -p scaleFactorOfSecondFixedSurface $infile` scaleFactorOfSecondFixedSurface=`${tools_dir}/grib_get -w count=1 -p scaleFactorOfSecondFixedSurface $infile`
[ "$scaleFactorOfSecondFixedSurface" = "0" ] [ "$scaleFactorOfSecondFixedSurface" = "0" ]
@ -29,10 +33,33 @@ scaleFactorOfSecondFixedSurface=`${tools_dir}/grib_get -w count=1 -p scaleFactor
scaledValueOfSecondFixedSurface=`${tools_dir}/grib_get -w count=1 -p scaledValueOfSecondFixedSurface $outfile` scaledValueOfSecondFixedSurface=`${tools_dir}/grib_get -w count=1 -p scaledValueOfSecondFixedSurface $outfile`
[ "$scaledValueOfSecondFixedSurface" = "MISSING" ] [ "$scaledValueOfSecondFixedSurface" = "MISSING" ]
# Codetable keys being set to 'missing'
# -----------------------------------------
sample1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
sample2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
# Make sure it works with the default sample
${tools_dir}/grib_set -s typeOfFirstFixedSurface=missing $sample2 $outfile
grib_check_key_equals $outfile 'typeOfFirstFixedSurface:i' '255'
# Make sure it works with the latest GRIB2 version code table 4.5
latest=`${tools_dir}/grib_get -p tablesVersionLatest $sample2`
${tools_dir}/grib_set -s tablesVersion=$latest $sample2 $tempGrib
${tools_dir}/grib_set -s typeOfFirstFixedSurface=missing $tempGrib $outfile
grib_check_key_equals $outfile 'typeOfFirstFixedSurface:i' '255'
rm -f $tempGrib
${tools_dir}/grib_set -s centre=missing $sample1 $outfile
grib_check_key_equals $outfile 'centre' 'consensus'
# Some code tables do not have a missing entry
set +e set +e
${tools_dir}/grib_set -s timeRangeIndicator=missing $sample1 $outfile 2>$tempText
status=$?
set -e
[ $status -ne 0 ]
grep -q "There is no 'missing' entry in Code Table 5.table" $tempText
${tools_dir}/grib_set -s centre=missing $infile $outfile 2> $REDIRECT > $REDIRECT
[ $? -ne 0 ] # Clean up
rm -f $outfile $tempText $tempGrib
rm -f $outfile

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@
#include "grib_api.h" #include "grib_api.h"
static void usage(char* prog) static void usage(const char* prog)
{ {
printf("usage: %s infile\n", prog); printf("usage: %s infile\n", prog);
exit(1); exit(1);

View File

@ -34,6 +34,7 @@ cat > $tempRef <<EOF
ECCODES ERROR : key 'a_deprecated_key' is unavailable in this version. ECCODES ERROR : key 'a_deprecated_key' is unavailable in this version.
ECCODES ERROR : Please use the following key(s): ECCODES ERROR : Please use the following key(s):
ECCODES ERROR : - typeOfOriginalFieldValues ECCODES ERROR : - typeOfOriginalFieldValues
ERROR: Key/value not found (message 1)
EOF EOF
diff $tempRef $tempErr diff $tempRef $tempErr

View File

@ -88,11 +88,11 @@ int main(int argc, char** argv)
parallel = 0; parallel = 0;
} }
if (parallel) { if (parallel) {
printf("Running parallel in %ld threads. %ld iterations (prod=%ld)\n", NUM_THREADS, FILES_PER_ITERATION, NUM_THREADS * FILES_PER_ITERATION); printf("Running parallel in %zu threads. %zu iterations (prod=%zu)\n", NUM_THREADS, FILES_PER_ITERATION, NUM_THREADS * FILES_PER_ITERATION);
printf("Options: dump=%d, clone=%d, write=%d\n", opt_dump, opt_clone, opt_write); printf("Options: dump=%d, clone=%d, write=%d\n", opt_dump, opt_clone, opt_write);
} }
else { else {
printf("Running sequentially in %ld runs. %ld iterations\n", NUM_THREADS, FILES_PER_ITERATION); printf("Running sequentially in %zu runs. %zu iterations\n", NUM_THREADS, FILES_PER_ITERATION);
} }
{ {
@ -146,7 +146,7 @@ void do_encode(void* ptr)
for (i = 0; i < FILES_PER_ITERATION; i++) { for (i = 0; i < FILES_PER_ITERATION; i++) {
grib_handle* h = grib_handle_clone(hs); grib_handle* h = grib_handle_clone(hs);
if (opt_write) { if (opt_write) {
snprintf(output_file, 50, "output/output_file_%ld-%ld.grib", data->number, i); snprintf(output_file, 50, "output/output_file_%zu-%zu.grib", data->number, i);
encode_values(h, output_file); encode_values(h, output_file);
} }
else { else {
@ -160,6 +160,6 @@ void do_encode(void* ptr)
strftime(stime, 32, "%H:%M:%S", &result); /* Try to get milliseconds here too*/ strftime(stime, 32, "%H:%M:%S", &result); /* Try to get milliseconds here too*/
/* asctime_r(&result, stime); */ /* asctime_r(&result, stime); */
printf("%s: Worker %ld finished.\n", stime, data->number); printf("%s: Worker %zu finished.\n", stime, data->number);
grib_handle_delete(hs); grib_handle_delete(hs);
} }

View File

@ -24,7 +24,7 @@ int opt_dump = 0; /* If 1 then dump handle to /dev/null */
int opt_clone = 0; /* If 1 then clone source handle */ int opt_clone = 0; /* If 1 then clone source handle */
int opt_write = 0; /* If 1 write handle to file */ int opt_write = 0; /* If 1 write handle to file */
static int encode_file(char* template_file, char* output_file) static int encode_file(const char* template_file, const char* output_file)
{ {
FILE *in, *out = NULL; FILE *in, *out = NULL;
grib_handle* source_handle = NULL; grib_handle* source_handle = NULL;
@ -138,11 +138,11 @@ int main(int argc, char** argv)
parallel = 0; parallel = 0;
} }
if (parallel) { if (parallel) {
printf("Running parallel in %ld threads. %ld iterations (prod=%ld)\n", NUM_THREADS, FILES_PER_ITERATION, NUM_THREADS * FILES_PER_ITERATION); printf("Running parallel in %zu threads. %zu iterations (prod=%zu)\n", NUM_THREADS, FILES_PER_ITERATION, NUM_THREADS * FILES_PER_ITERATION);
printf("Options: dump=%d, clone=%d, write=%d\n", opt_dump, opt_clone, opt_write); printf("Options: dump=%d, clone=%d, write=%d\n", opt_dump, opt_clone, opt_write);
} }
else { else {
printf("Running sequentially in %ld runs. %ld iterations\n", NUM_THREADS, FILES_PER_ITERATION); printf("Running sequentially in %zu runs. %zu iterations\n", NUM_THREADS, FILES_PER_ITERATION);
} }
{ {
@ -193,7 +193,7 @@ void do_stuff(void* ptr)
for (i = 0; i < FILES_PER_ITERATION; i++) { for (i = 0; i < FILES_PER_ITERATION; i++) {
if (opt_write) { if (opt_write) {
snprintf(output_file, 50, "output/output_file_%ld-%ld.grib", data->number, i); snprintf(output_file, 50, "output/output_file_%zu-%zu.grib", data->number, i);
encode_file(INPUT_FILE, output_file); encode_file(INPUT_FILE, output_file);
} }
else { else {
@ -206,5 +206,5 @@ void do_stuff(void* ptr)
strftime(stime, 32, "%H:%M:%S", &result); /* Try to get milliseconds here too*/ strftime(stime, 32, "%H:%M:%S", &result); /* Try to get milliseconds here too*/
/* asctime_r(&result, stime); */ /* asctime_r(&result, stime); */
printf("%s: Worker %ld finished.\n", stime, data->number); printf("%s: Worker %zu finished.\n", stime, data->number);
} }

View File

@ -14,7 +14,7 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
void usage(char* prog) void usage(const char* prog)
{ {
printf("usage: %s filename\n", prog); printf("usage: %s filename\n", prog);
exit(1); exit(1);
@ -32,7 +32,7 @@ int main(int argc, char* argv[])
if (argc != 2) usage(argv[0]); if (argc != 2) usage(argv[0]);
printf("sizeof(off_t)=%d sizeof(long)=%d\n", sizeof(off_t), sizeof(long)); printf("sizeof(off_t)=%zu sizeof(long)=%zu\n", sizeof(off_t), sizeof(long));
f = fopen(argv[1], "r"); f = fopen(argv[1], "r");
if (!f) { if (!f) {
@ -50,7 +50,7 @@ int main(int argc, char* argv[])
} }
rsizeout = fread(str, 1, rsizein, f); rsizeout = fread(str, 1, rsizein, f);
if (rsizeout != rsizein) { if (rsizeout != rsizein) {
printf("rsizein=%d rsizeout=%d\n", rsizein, rsizeout); printf("rsizein=%zu rsizeout=%zu\n", rsizein, rsizeout);
printf("end of file\n"); printf("end of file\n");
exit(1); exit(1);
} }

View File

@ -206,7 +206,7 @@ void gribex_check(int err) {
void usage(char* prog) { void usage(const char* prog) {
printf("usage: %s [-a outfile | -w outfile ] grib_file repetitions bitsPerValue\n",prog); printf("usage: %s [-a outfile | -w outfile ] grib_file repetitions bitsPerValue\n",prog);
exit(1); exit(1);
} }

View File

@ -53,7 +53,7 @@ int grib_tool_init(grib_runtime_options* options)
if (!options->action) { if (!options->action) {
const char* filt = options->infile_extra->name; const char* filt = options->infile_extra->name;
if (strcmp(filt, "-") == 0) filt = "stdin"; if (strcmp(filt, "-") == 0) filt = "stdin";
fprintf(stderr, "Error: %s: unable to create action\n", filt); fprintf(stderr, "ERROR: %s: unable to create action\n", filt);
exit(1); exit(1);
} }
@ -88,7 +88,8 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
err = grib_handle_apply_action(h, options->action); err = grib_handle_apply_action(h, options->action);
if (err != GRIB_SUCCESS && options->fail) { if (err != GRIB_SUCCESS && options->fail) {
printf("ERROR: %s\n", grib_get_error_message(err)); fprintf(stderr, "ERROR: %s (message %d)\n",
grib_get_error_message(err), h->context->handle_file_count);
exit(err); exit(err);
} }
return 0; return 0;

View File

@ -62,7 +62,7 @@ int grib_tool_before_getopt(grib_runtime_options* options)
int grib_tool_init(grib_runtime_options* options) int grib_tool_init(grib_runtime_options* options)
{ {
if (options->set_values_count == 0 && !options->repack && !options->constant) { if (options->set_values_count == 0 && !options->repack && !options->constant) {
printf("ERROR: please provide some keys to set through the -s option or use the -r/-d options\n"); fprintf(stderr, "ERROR: Please provide some keys to set through the -s option or use the -r/-d options\n");
exit(1); exit(1);
} }
if (options->verbose) if (options->verbose)
@ -73,7 +73,7 @@ int grib_tool_init(grib_runtime_options* options)
}*/ }*/
if (grib_options_on("n:") && grib_options_on("d:")) { if (grib_options_on("n:") && grib_options_on("d:")) {
printf("Error: -n and -d options are incompatible. Choose one of the two please.\n"); fprintf(stderr, "ERROR: -n and -d options are incompatible. Choose one of the two please.\n");
exit(1); exit(1);
} }

View File

@ -54,7 +54,7 @@ int grib_tool_init(grib_runtime_options* options)
if (!options->action) { if (!options->action) {
const char* filt = options->infile_extra->name; const char* filt = options->infile_extra->name;
if (strcmp(filt, "-") == 0) filt = "stdin"; if (strcmp(filt, "-") == 0) filt = "stdin";
fprintf(stderr, "Error: %s: unable to create action\n", filt); fprintf(stderr, "ERROR: %s: unable to create action\n", filt);
exit(1); exit(1);
} }
@ -86,7 +86,8 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
err = grib_handle_apply_action(h, options->action); err = grib_handle_apply_action(h, options->action);
if (err != GRIB_SUCCESS && options->fail) { if (err != GRIB_SUCCESS && options->fail) {
printf("ERROR: %s\n", grib_get_error_message(err)); fprintf(stderr, "ERROR: %s (message %d)\n",
grib_get_error_message(err), h->context->handle_file_count);
exit(err); exit(err);
} }
return 0; return 0;