From f9ba1ad66dab89e783a25a1db527256159b0e8c4 Mon Sep 17 00:00:00 2001 From: Robert Osinski Date: Fri, 5 Jan 2024 15:44:30 +0000 Subject: [PATCH 01/34] Initial commit --- .../localConcepts/ecmf/marsLevtypeConcept.def | 1 + .../localConcepts/ecmf/typeOfLevelConcept.def | 2 ++ .../grib2/tables/local/ecmf/1/0.0.table | 2 ++ .../grib2/tables/local/ecmf/1/4.1.254.table | 2 ++ .../tables/local/ecmf/1/4.2.254.254.table | 22 +++++++++++++++++++ .../grib2/tables/local/ecmf/1/4.5.table | 1 + definitions/mars/type.table | 1 + 7 files changed, 31 insertions(+) create mode 100644 definitions/grib2/localConcepts/ecmf/typeOfLevelConcept.def create mode 100644 definitions/grib2/tables/local/ecmf/1/0.0.table create mode 100644 definitions/grib2/tables/local/ecmf/1/4.1.254.table create mode 100644 definitions/grib2/tables/local/ecmf/1/4.2.254.254.table diff --git a/definitions/grib2/localConcepts/ecmf/marsLevtypeConcept.def b/definitions/grib2/localConcepts/ecmf/marsLevtypeConcept.def index 8a568ab6f..1f2c64121 100644 --- a/definitions/grib2/localConcepts/ecmf/marsLevtypeConcept.def +++ b/definitions/grib2/localConcepts/ecmf/marsLevtypeConcept.def @@ -6,3 +6,4 @@ 'o2d' = {typeOfFirstFixedSurface=102; typeOfSecondFixedSurface=255;gridDefinitionTemplateNumber=101;numberOfGridUsed=5;} 'o2d' = {typeOfFirstFixedSurface=102; typeOfSecondFixedSurface=255;gridDefinitionTemplateNumber=101;numberOfGridUsed=6;} 'o2d' = {typeOfFirstFixedSurface=102; typeOfSecondFixedSurface=255;gridDefinitionTemplateNumber=101;numberOfGridUsed=7;} +'sfc' = {typeOfFirstFixedSurface=254;} diff --git a/definitions/grib2/localConcepts/ecmf/typeOfLevelConcept.def b/definitions/grib2/localConcepts/ecmf/typeOfLevelConcept.def new file mode 100644 index 000000000..1f3b6d47b --- /dev/null +++ b/definitions/grib2/localConcepts/ecmf/typeOfLevelConcept.def @@ -0,0 +1,2 @@ +# Concept typeOfLevel +'MarsSfcFromMultipleLevels' = {typeOfFirstFixedSurface=254;} diff --git a/definitions/grib2/tables/local/ecmf/1/0.0.table b/definitions/grib2/tables/local/ecmf/1/0.0.table new file mode 100644 index 000000000..a48f89506 --- /dev/null +++ b/definitions/grib2/tables/local/ecmf/1/0.0.table @@ -0,0 +1,2 @@ +# Code table 0.0 for ECMWF - Discipline of processed data in the GRIB message, number of GRIB Master table +254 254 Model internal fields diff --git a/definitions/grib2/tables/local/ecmf/1/4.1.254.table b/definitions/grib2/tables/local/ecmf/1/4.1.254.table new file mode 100644 index 000000000..39abd06a3 --- /dev/null +++ b/definitions/grib2/tables/local/ecmf/1/4.1.254.table @@ -0,0 +1,2 @@ +# Product discipline 254 for ECMWF - Model internal fields +254 254 Covariances diff --git a/definitions/grib2/tables/local/ecmf/1/4.2.254.254.table b/definitions/grib2/tables/local/ecmf/1/4.2.254.254.table new file mode 100644 index 000000000..b97ea25e4 --- /dev/null +++ b/definitions/grib2/tables/local/ecmf/1/4.2.254.254.table @@ -0,0 +1,22 @@ +# Code table 4.2 - discipline=254 category=254 for ECMWF +192 192 Covariance between 2-metre temperature and volumetric soil water layer 1 [K m**3 m**-3] +193 193 Covariance between 2-metre relative humidity and volumetric soil water layer 1 [K m**3 m**-3] +194 194 Covariance between surface soil moisture and volumetric soil water layer 1 [m**3 m**-3 m**3 m**-3] +195 195 Covariance between 2-metre temperature and volumetric soil water layer 2 [K m**3 m**-3] +196 196 Covariance between 2-metre relative humidity and volumetric soil water layer 2 [% m**3 m**-3] +197 197 Covariance between surface soil moisture and volumetric soil water layer 2 [m**3 m**-3 m**3 m**-3] +198 198 Covariance between 2-metre temperature and volumetric soil water layer 3 [K m**3 m**-3] +199 199 Covariance between 2-metre relative humidity and volumetric soil water layer 3 [% m**3 m**-3] +200 200 Covariance between surface soil moisture and volumetric soil water layer 3 [m**3 m**-3 m**3 m**-3] +201 201 Covariance between 2-metre temperature and soil temperature layer 1 [K K] +202 202 Covariance between 2-metre relative humidity and soil temperature layer 1 [% K] +203 203 Covariance between 2-metre temperature and soil temperature layer 2 [K K] +204 204 Covariance between 2-metre relative humidity and soil temperature layer 2 [% K] +205 205 Covariance between 2-metre temperature and soil temperature layer 3 [K K] +206 206 Covariance between 2-metre relative humidity and soil temperature layer 3 [% K] +207 207 Covariance between 2-metre temperature and temperature of snow layer 1 [K K] +208 208 Covariance between 2-metre relative humidity and temperature of snow layer 1 [% K] +209 209 Covariance between 2-metre temperature and temperature of snow layer 2 [K K] +210 210 Covariance between 2-metre relative humidity and temperature of snow layer 2 [% K] +211 211 Covariance between 2-metre temperature and temperature of snow layer 3 [K K] +212 212 Covariance between 2-metre relative humidity and temperature of snow layer 3 [% K] diff --git a/definitions/grib2/tables/local/ecmf/1/4.5.table b/definitions/grib2/tables/local/ecmf/1/4.5.table index d479c0944..64153aaee 100644 --- a/definitions/grib2/tables/local/ecmf/1/4.5.table +++ b/definitions/grib2/tables/local/ecmf/1/4.5.table @@ -1 +1,2 @@ 173 173 Top surface of snow, over ice, on sea, lake or river +254 254 MARS levtype SFC originating from fields on multiple levels diff --git a/definitions/mars/type.table b/definitions/mars/type.table index 4850d9f43..1985ee678 100644 --- a/definitions/mars/type.table +++ b/definitions/mars/type.table @@ -73,3 +73,4 @@ 92 pfc Point values 93 ppm Point value metrics 94 gwt Weather types +95 est Ensemble statistics From 81f40a3735e4f2dc79f6890355914698ef3717d5 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 9 Jan 2024 10:23:13 +0000 Subject: [PATCH 02/34] Check return value of grib_buffer_replace --- ...g1second_order_general_extended_packing.cc | 6 ++--- ...ib_accessor_class_data_g1simple_packing.cc | 6 +++-- src/grib_accessor_class_g1_message_length.cc | 23 ++++++------------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/grib_accessor_class_data_g1second_order_general_extended_packing.cc b/src/grib_accessor_class_data_g1second_order_general_extended_packing.cc index 2f1946b7b..e8dc5b1bb 100644 --- a/src/grib_accessor_class_data_g1second_order_general_extended_packing.cc +++ b/src/grib_accessor_class_data_g1second_order_general_extended_packing.cc @@ -1350,10 +1350,10 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) /* ECC-259: Set correct number of values */ ret = grib_set_long_internal(a->parent->h, self->number_of_values, *len); - if (ret) - return ret; + if (ret) return ret; - grib_buffer_replace(a, buffer, size, 1, 1); + ret = grib_buffer_replace(a, buffer, size, 1, 1); + if (ret) return ret; grib_context_free(a->context, buffer); grib_context_free(a->context, X); diff --git a/src/grib_accessor_class_data_g1simple_packing.cc b/src/grib_accessor_class_data_g1simple_packing.cc index c863f7595..e9f4aefdc 100644 --- a/src/grib_accessor_class_data_g1simple_packing.cc +++ b/src/grib_accessor_class_data_g1simple_packing.cc @@ -236,7 +236,8 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len) constantFieldHalfByte = 0; if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->half_byte, constantFieldHalfByte)) != GRIB_SUCCESS) return ret; - grib_buffer_replace(a, NULL, 0, 1, 1); + ret = grib_buffer_replace(a, NULL, 0, 1, 1); + if (ret != GRIB_SUCCESS) return ret; return GRIB_SUCCESS; break; case GRIB_NO_VALUES: @@ -252,7 +253,8 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len) return ret; if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->half_byte, constantFieldHalfByte)) != GRIB_SUCCESS) return ret; - grib_buffer_replace(a, NULL, 0, 1, 1); + ret = grib_buffer_replace(a, NULL, 0, 1, 1); + if (ret != GRIB_SUCCESS) return ret; return GRIB_SUCCESS; break; case GRIB_INVALID_BPV: diff --git a/src/grib_accessor_class_g1_message_length.cc b/src/grib_accessor_class_g1_message_length.cc index 44e2f84bc..1d38e7ea4 100644 --- a/src/grib_accessor_class_g1_message_length.cc +++ b/src/grib_accessor_class_g1_message_length.cc @@ -106,7 +106,7 @@ grib_accessor_class* grib_accessor_class_g1_message_length = &_grib_accessor_cla static void init(grib_accessor* a, const long len, grib_arguments* args) { grib_accessor_g1_message_length* self = (grib_accessor_g1_message_length*)a; - self->sec4_length = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); + self->sec4_length = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); } int grib_get_g1_message_size(grib_handle* h, grib_accessor* tl, grib_accessor* s4, @@ -134,15 +134,12 @@ int grib_get_g1_message_size(grib_handle* h, grib_accessor* tl, grib_accessor* s if (slen < 120 && (tlen & 0x800000)) { /* printf("DECODING large grib tlen=%ld slen=%ld\n",tlen,slen); */ - tlen &= 0x7fffff; tlen *= 120; tlen -= slen; tlen += 4; slen = tlen - s4->offset - 4; /* 4 is for 7777 */ - - /*printf("DECODING large grib total=%ld section4=%ld\n",tlen,slen);*/ } *total_length = tlen; @@ -184,7 +181,6 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) slen = t120 * 120 - tlen; tlen = 0x800000 | t120; - /* printf("ENCODING large grib total = %ld tlen=%ld slen=%ld \n",*val,tlen,slen); */ *len = 1; if ((ret = grib_pack_long(s4, &slen, len)) != GRIB_SUCCESS) return ret; @@ -198,11 +194,9 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) { long total_length = -1, sec4_length = -1; - grib_get_g1_message_size(grib_handle_of_accessor(a), - a, + grib_get_g1_message_size(grib_handle_of_accessor(a), a, grib_find_accessor(grib_handle_of_accessor(a), self->sec4_length), - &total_length, - &sec4_length); + &total_length, &sec4_length); if (total_length != *val) { const char* cclass_name = a->cclass->name; grib_context_log(a->context, GRIB_LOG_ERROR, @@ -212,7 +206,6 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try encoding as GRIB2\n"); return GRIB_ENCODING_ERROR; } - Assert(total_length == *val); } return GRIB_SUCCESS; @@ -222,16 +215,14 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) { grib_accessor_g1_message_length* self = (grib_accessor_g1_message_length*)a; int ret; - long total_length, sec4_length; - if ((ret = grib_get_g1_message_size(grib_handle_of_accessor(a), - a, + if ((ret = grib_get_g1_message_size(grib_handle_of_accessor(a), a, grib_find_accessor(grib_handle_of_accessor(a), self->sec4_length), - &total_length, - &sec4_length)) != GRIB_SUCCESS) + &total_length, &sec4_length)) != GRIB_SUCCESS) + { return ret; - + } *val = total_length; return GRIB_SUCCESS; From 86db8002ad161570cfe9d5999505f3d9221aef78 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 9 Jan 2024 13:13:32 +0000 Subject: [PATCH 03/34] Testing: Windows --- tests/bufr_dump_decode_filter.sh | 10 +++++++--- tests/bufr_json_data.sh | 6 ++++++ tests/grib_check_param_concepts.sh | 8 ++++++++ tests/grib_mars_keys1.sh | 5 +++++ tests/grib_mars_keys2.sh | 4 ++++ tests/grib_tigge_conversions1.sh | 7 +++++++ tests/grib_tigge_conversions2.sh | 6 ++++++ tests/list_codetable_flagtable_keys.sh | 7 +++++++ 8 files changed, 50 insertions(+), 3 deletions(-) diff --git a/tests/bufr_dump_decode_filter.sh b/tests/bufr_dump_decode_filter.sh index f36b03577..d2a06c196 100755 --- a/tests/bufr_dump_decode_filter.sh +++ b/tests/bufr_dump_decode_filter.sh @@ -8,14 +8,18 @@ # virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. # -set -x . ./include.ctest.sh -cd ${data_dir}/bufr - # Define a common label for all the tmp files label="bufr_dump_decode_filter_test" +if [ $ECCODES_ON_WINDOWS -eq 1 ]; then + echo "$0: This test is currently disabled on Windows" + exit 0 +fi + +cd ${data_dir}/bufr + # Create log file fLog=temp.${label}".log" rm -f $fLog diff --git a/tests/bufr_json_data.sh b/tests/bufr_json_data.sh index eedf01f33..5e0991373 100755 --- a/tests/bufr_json_data.sh +++ b/tests/bufr_json_data.sh @@ -16,6 +16,12 @@ tempOut=temp.${label}.txt tempBufr=temp.${label}.bufr +if [ $ECCODES_ON_WINDOWS -eq 1 ]; then + echo "$0: This test is currently disabled on Windows" + exit 0 +fi + + REDIRECT=/dev/null cd ${data_dir}/bufr diff --git a/tests/grib_check_param_concepts.sh b/tests/grib_check_param_concepts.sh index 940762ddc..24b2a3e5f 100755 --- a/tests/grib_check_param_concepts.sh +++ b/tests/grib_check_param_concepts.sh @@ -11,6 +11,14 @@ . ./include.ctest.sh label="grib_check_param_concepts_test" + + +if [ $ECCODES_ON_WINDOWS -eq 1 ]; then + echo "$0: This test is currently disabled on Windows" + exit 0 +fi + + # # Do various checks on the concepts files # diff --git a/tests/grib_mars_keys1.sh b/tests/grib_mars_keys1.sh index d13d880fd..29b6b841a 100755 --- a/tests/grib_mars_keys1.sh +++ b/tests/grib_mars_keys1.sh @@ -15,6 +15,11 @@ tempOut=temp.${label}.out tempGrib=temp.${label}.grib tempRef=temp.${label}.ref +if [ $ECCODES_ON_WINDOWS -eq 1 ]; then + echo "$0: This test is currently disabled on Windows" + exit 0 +fi + grib1_sample=$ECCODES_SAMPLES_PATH/GRIB1.tmpl grib2_sample=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl types_table=$ECCODES_DEFINITION_PATH/mars/type.table diff --git a/tests/grib_mars_keys2.sh b/tests/grib_mars_keys2.sh index 5d4b13425..2396e0236 100755 --- a/tests/grib_mars_keys2.sh +++ b/tests/grib_mars_keys2.sh @@ -16,6 +16,10 @@ tempGrib=temp.${label}.grib grib1_sample=$ECCODES_SAMPLES_PATH/GRIB1.tmpl grib2_sample=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl +if [ $ECCODES_ON_WINDOWS -eq 1 ]; then + echo "$0: This test is currently disabled on Windows" + exit 0 +fi # Check lowercase/uppercase ${tools_dir}/grib_set -s class=YT,type=EM,stream=DCWV $grib1_sample $tempGrib diff --git a/tests/grib_tigge_conversions1.sh b/tests/grib_tigge_conversions1.sh index 088066951..fc7c75a33 100755 --- a/tests/grib_tigge_conversions1.sh +++ b/tests/grib_tigge_conversions1.sh @@ -21,6 +21,13 @@ dir="${data_dir}/tigge" temp1="temp.${label}.grib1_" temp2="temp.${label}.grib2_" + +if [ $ECCODES_ON_WINDOWS -eq 1 ]; then + echo "$0: This test is currently disabled on Windows" + exit 0 +fi + + # --- Do I want to exclude any file pattern from the comparison ? exclusion_pattern="tcw|ssr|str|skt|cap|ci|ttr|st|sm|sd|slhf|sshf" diff --git a/tests/grib_tigge_conversions2.sh b/tests/grib_tigge_conversions2.sh index 4bf8666b4..3d80771e6 100755 --- a/tests/grib_tigge_conversions2.sh +++ b/tests/grib_tigge_conversions2.sh @@ -21,6 +21,12 @@ dir="${data_dir}/tigge" temp1="temp.${label}.grib1_" temp2="temp.${label}.grib2_" + +if [ $ECCODES_ON_WINDOWS -eq 1 ]; then + echo "$0: This test is currently disabled on Windows" + exit 0 +fi + # --- Do I want to exclude any file pattern from the comparison ? exclusion_pattern="tcw|ssr|str|skt|cap|ci|ttr|st|sm|sd|slhf|sshf" diff --git a/tests/list_codetable_flagtable_keys.sh b/tests/list_codetable_flagtable_keys.sh index b5733f394..96e930161 100755 --- a/tests/list_codetable_flagtable_keys.sh +++ b/tests/list_codetable_flagtable_keys.sh @@ -13,6 +13,13 @@ OUTPUT=all_codetable_flagtable_keys.txt TEMP=temp.list_codetable_flagtable_keys.txt + +if [ $ECCODES_ON_WINDOWS -eq 1 ]; then + echo "$0: This test is currently disabled on Windows" + exit 0 +fi + + [ -z "$ECCODES_DEFINITION_PATH" ] || ECCODES_DEFINITION_PATH=`${tools_dir}/codes_info -d` touch $TEMP From 9f565bed858bbf62f3095ecc946065ec05c04042 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 9 Jan 2024 15:42:16 +0000 Subject: [PATCH 04/34] Const correctness --- src/action_class_if.cc | 2 +- src/action_class_write.cc | 2 +- src/bufr_keys_iterator.cc | 4 ++-- src/bufr_util.cc | 6 +++--- src/codes_util.cc | 4 ++-- src/eccodes_prototypes.h | 2 +- src/grib_accessor_class_bitmap.cc | 2 +- src/grib_accessor_class_bufr_data_array.cc | 2 +- src/grib_accessor_class_scale_values.cc | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/action_class_if.cc b/src/action_class_if.cc index a5d28725a..0302e0625 100644 --- a/src/action_class_if.cc +++ b/src/action_class_if.cc @@ -92,7 +92,7 @@ static void init_class(grib_action_class* c) grib_action* grib_action_create_if(grib_context* context, grib_expression* expression, grib_action* block_true, grib_action* block_false, int transient, - int lineno, char* file_being_parsed) + int lineno, const char* file_being_parsed) { char name[1024]; const size_t nameLen = sizeof(name); diff --git a/src/action_class_write.cc b/src/action_class_write.cc index 6b18a90d6..dc29ad050 100644 --- a/src/action_class_write.cc +++ b/src/action_class_write.cc @@ -174,7 +174,7 @@ static int execute(grib_action* act, grib_handle* h) } if (h->gts_header) { - char gts_trailer[4] = { '\x0D', '\x0D', '\x0A', '\x03' }; + const char gts_trailer[4] = { '\x0D', '\x0D', '\x0A', '\x03' }; if (fwrite(gts_trailer, 1, 4, of->handle) != 4) { grib_context_log(act->context, (GRIB_LOG_ERROR) | (GRIB_LOG_PERROR), "Error writing GTS trailer to %s", filename); diff --git a/src/bufr_keys_iterator.cc b/src/bufr_keys_iterator.cc index cc8b1b3ca..e1ab89697 100644 --- a/src/bufr_keys_iterator.cc +++ b/src/bufr_keys_iterator.cc @@ -199,7 +199,7 @@ char* codes_bufr_keys_iterator_get_name(const bufr_keys_iterator* ckiter) bufr_keys_iterator* kiter = (bufr_keys_iterator*)ckiter; int* r = 0; char* ret = 0; - grib_context* c = kiter->handle->context; + const grib_context* c = kiter->handle->context; DEBUG_ASSERT(kiter->current); if (kiter->prefix) { @@ -236,7 +236,7 @@ grib_accessor* codes_bufr_keys_iterator_get_accessor(bufr_keys_iterator* kiter) int codes_bufr_keys_iterator_delete(bufr_keys_iterator* kiter) { if (kiter) { - grib_context* c = kiter->handle->context; + const grib_context* c = kiter->handle->context; kiter->key_name = NULL; if (kiter->seen) grib_trie_delete(kiter->seen); diff --git a/src/bufr_util.cc b/src/bufr_util.cc index 7691c1fe0..0b4ffb0e7 100644 --- a/src/bufr_util.cc +++ b/src/bufr_util.cc @@ -18,7 +18,7 @@ int compute_bufr_key_rank(grib_handle* h, grib_string_list* keys, const char* ke grib_string_list* prev = keys; int theRank = 0; size_t size = 0; - grib_context* c = h->context; + const grib_context* c = h->context; DEBUG_ASSERT(h->product_kind == PRODUCT_BUFR); while (next && next->value && strcmp(next->value, key)) { @@ -1114,7 +1114,7 @@ int codes_bufr_header_get_string(codes_bufr_header* bh, const char* key, char* v // Returns 1 if the BUFR key is in the header and 0 if it is in the data section int codes_bufr_key_is_header(const grib_handle* h, const char* key, int* err) { - grib_accessor* acc = grib_find_accessor(h, key); + const grib_accessor* acc = grib_find_accessor(h, key); if (!acc) { *err = GRIB_NOT_FOUND; return 0; @@ -1126,7 +1126,7 @@ int codes_bufr_key_is_header(const grib_handle* h, const char* key, int* err) // Returns 1 if the BUFR key is a coordinate descriptor int codes_bufr_key_is_coordinate(const grib_handle* h, const char* key, int* err) { - grib_accessor* acc = grib_find_accessor(h, key); + const grib_accessor* acc = grib_find_accessor(h, key); if (!acc) { *err = GRIB_NOT_FOUND; return 0; diff --git a/src/codes_util.cc b/src/codes_util.cc index 61174f2f9..1b73432f8 100644 --- a/src/codes_util.cc +++ b/src/codes_util.cc @@ -133,7 +133,7 @@ char* codes_getenv(const char* name) int codes_check_grib_ieee_packing_value(int value) { - grib_context* c = grib_context_get_default(); + const grib_context* c = grib_context_get_default(); if (value != 32 && value != 64) { grib_context_log(c, GRIB_LOG_ERROR, "Invalid value for ECCODES_GRIB_IEEE_PACKING: should be 32 or 64"); return GRIB_INVALID_ARGUMENT; @@ -146,7 +146,7 @@ int codes_flush_sync_close_file(FILE* f) { int err = 0; int fd = 0; - grib_context* c = grib_context_get_default(); + const grib_context* c = grib_context_get_default(); Assert(f); fd = fileno(f); diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index aba20c9b4..f9e208e88 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -20,7 +20,7 @@ grib_action* grib_action_create_alias(grib_context* context, const char* name, c grib_action* grib_action_create_gen(grib_context* context, const char* name, const char* op, const long len, grib_arguments* params, grib_arguments* default_value, int flags, const char* name_space, const char* set); /* action_class_if.cc */ -grib_action* grib_action_create_if(grib_context* context, grib_expression* expression, grib_action* block_true, grib_action* block_false, int transient, int lineno, char* file_being_parsed); +grib_action* grib_action_create_if(grib_context* context, grib_expression* expression, grib_action* block_true, grib_action* block_false, int transient, int lineno, const char* file_being_parsed); /* action_class_switch.cc */ grib_action* grib_action_create_switch(grib_context* context, grib_arguments* args, grib_case* Case, grib_action* Default); diff --git a/src/grib_accessor_class_bitmap.cc b/src/grib_accessor_class_bitmap.cc index a25d79a49..e5825a3c3 100644 --- a/src/grib_accessor_class_bitmap.cc +++ b/src/grib_accessor_class_bitmap.cc @@ -193,7 +193,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) long tlen = 0; long i = 0; int err = 0; - grib_handle* hand = grib_handle_of_accessor(a); + const grib_handle* hand = grib_handle_of_accessor(a); err = grib_value_count(a, &tlen); if (err) diff --git a/src/grib_accessor_class_bufr_data_array.cc b/src/grib_accessor_class_bufr_data_array.cc index ec0baa494..9f745ba56 100644 --- a/src/grib_accessor_class_bufr_data_array.cc +++ b/src/grib_accessor_class_bufr_data_array.cc @@ -254,7 +254,7 @@ static size_t get_length(grib_accessor* a) grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; size_t len = 0; - grib_handle* h = grib_handle_of_accessor(a); + const grib_handle* h = grib_handle_of_accessor(a); grib_get_size(h, self->bufrDataEncodedName, &len); diff --git a/src/grib_accessor_class_scale_values.cc b/src/grib_accessor_class_scale_values.cc index bae505f23..8c4b33fcb 100644 --- a/src/grib_accessor_class_scale_values.cc +++ b/src/grib_accessor_class_scale_values.cc @@ -131,7 +131,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) size_t size = 0; int ret = 0, i = 0; grib_accessor_scale_values* self = (grib_accessor_scale_values*)a; - grib_context* c = a->context; + const grib_context* c = a->context; grib_handle* h = grib_handle_of_accessor(a); if (*val == 1) From 3bb3e025f8ff7a9161021da98bd4934ae62172e2 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 10 Jan 2024 12:42:17 +0000 Subject: [PATCH 05/34] Tools: deprecated options --- tests/bufr_copy.sh | 2 +- tests/gts_get.sh | 9 ++++++++- tests/metar_ls.sh | 5 +++++ tools/gts_copy.cc | 14 +++++++------- tools/gts_dump.cc | 7 +++---- tools/metar_copy.cc | 1 - tools/metar_ls.cc | 6 ------ 7 files changed, 24 insertions(+), 20 deletions(-) diff --git a/tests/bufr_copy.sh b/tests/bufr_copy.sh index eb3b877fb..10a44688e 100755 --- a/tests/bufr_copy.sh +++ b/tests/bufr_copy.sh @@ -30,7 +30,7 @@ echo "Test: copy synop messages ..." rm -f $fBufrTmp echo "Test: copy synop messages " >> $fLog -${tools_dir}/bufr_copy -w dataCategory=0 $fBufrInput $fBufrTmp >> $fLog +${tools_dir}/bufr_copy -p typicalDate -w dataCategory=0 $fBufrInput $fBufrTmp >> $fLog for i in 1 2 3 ;do category=`${tools_dir}/bufr_get -w count=$i -p dataCategory:l $fBufrTmp` diff --git a/tests/gts_get.sh b/tests/gts_get.sh index 2f50f10f6..cf6b2b51d 100755 --- a/tests/gts_get.sh +++ b/tests/gts_get.sh @@ -29,7 +29,14 @@ ${tools_dir}/gts_get -p TT,AA,II,CCCC,YY,GG,gg,BBB $gts_file >/dev/null #---------------------------------------------- # Test "-w" switch #---------------------------------------------- -${tools_dir}/gts_get -p TT -w count=3 $gts_file >/dev/null +${tools_dir}/gts_get -p TT -w count=3 $gts_file + + +#---------------------------------------------- +# Test "-s" switch +#---------------------------------------------- +result=$( ${tools_dir}/gts_get -s YY=ab -p YY -w count=3 $gts_file ) +[ "$result" = "ab" ] gts_file=${data_dir}/gts.grib diff --git a/tests/metar_ls.sh b/tests/metar_ls.sh index 779619b8f..65571ca34 100755 --- a/tests/metar_ls.sh +++ b/tests/metar_ls.sh @@ -42,6 +42,11 @@ ${tools_dir}/metar_ls $f >> $fLog ${tools_dir}/metar_ls -w CCCC=VILK $f >> $fLog +#------------------------------------------- +# Test "-s" switch +#------------------------------------------- +${tools_dir}/metar_ls -s dummy=1 -w count=5 $f >> $fLog + #------------------------------------------- # Test "-p" switch #------------------------------------------- diff --git a/tools/gts_copy.cc b/tools/gts_copy.cc index 9fdf7041a..bf17f85e9 100644 --- a/tools/gts_copy.cc +++ b/tools/gts_copy.cc @@ -73,14 +73,14 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) { - int err = 0; - if (!options->skip) { - if (options->set_values_count != 0) - err = grib_set_values(h, options->set_values, options->set_values_count); + // int err = 0; + // if (!options->skip) { + // if (options->set_values_count != 0) + // err = grib_set_values(h, options->set_values, options->set_values_count); - if (err != GRIB_SUCCESS && options->fail) - exit(err); - } + // if (err != GRIB_SUCCESS && options->fail) + // exit(err); + // } grib_tools_write_message(options, h); return 0; diff --git a/tools/gts_dump.cc b/tools/gts_dump.cc index eff44c548..a58f93ddf 100644 --- a/tools/gts_dump.cc +++ b/tools/gts_dump.cc @@ -95,8 +95,7 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi if (!options->current_infile->name) return 0; snprintf(tmp, 1024, "FILE: %s ", options->current_infile->name); - if (!grib_options_on("C")) - fprintf(stdout, "***** %s\n", tmp); + fprintf(stdout, "***** %s\n", tmp); return 0; } @@ -114,8 +113,8 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) grib_set_flag(h, options->print_keys[i].name, GRIB_ACCESSOR_FLAG_DUMP); snprintf(tmp, 1024, "MESSAGE %d ( length=%ld )", options->handle_count, length); - if (!grib_options_on("C")) - fprintf(stdout, "#============== %-38s ==============\n", tmp); + + fprintf(stdout, "#============== %-38s ==============\n", tmp); if (!strcmp(options->dump_mode, "default")) { GRIB_CHECK_NOLINE(grib_get_string(h, "identifier", identifier, &idlen), 0); printf("%s {\n", identifier); diff --git a/tools/metar_copy.cc b/tools/metar_copy.cc index 0ea7e14d4..9e4e14ef7 100644 --- a/tools/metar_copy.cc +++ b/tools/metar_copy.cc @@ -31,7 +31,6 @@ grib_option grib_options[] = { "double (key:d) or an integer (key:i)\n\t\ttype can be defined. Default type " "is string.\n", 0, 1, 0 }, - { "B:", 0, 0, 0, 1, 0 }, { "V", 0, 0, 0, 1, 0 }, { "W:", 0, 0, 0, 1, 0 }, { "U", 0, 0, 1, 0, 0 }, diff --git a/tools/metar_ls.cc b/tools/metar_ls.cc index 98c748863..630cf62a7 100644 --- a/tools/metar_ls.cc +++ b/tools/metar_ls.cc @@ -17,24 +17,18 @@ grib_option grib_options[] = { { "F:", 0, 0, 1, 1, "%g" }, { "P:", 0, 0, 0, 1, 0 }, { "w:", 0, 0, 0, 1, 0 }, - // { "j", 0, "json output\n", 0, 1, 0 }, - { "B:", 0, 0, 0, 1, 0 }, - /* {"l:",0,0,0,1,0}, */ { "s:", 0, 0, 0, 1, 0 }, - /* {"i:",0,0,0,1,0}, */ { "n:", 0, 0, 1, 1, "ls" }, { "m", 0, 0, 0, 1, 0 }, { "V", 0, 0, 0, 1, 0 }, { "W:", 0, 0, 1, 1, "10" }, { "S", 0, 0, 1, 0, 0 }, - /* {"M",0,0,0,1,0}, */ { "H", 0, 0, 1, 0, 0 }, { "g", 0, 0, 0, 1, 0 }, { "P", 0, 0, 1, 0, 0 }, { "T:", 0, 0, 1, 0, "M" }, { "7", 0, 0, 0, 1, 0 }, { "v", 0, 0, 1, 0, 0 } - /*{"x",0,0,0,1,0}*/ }; const char* tool_description = From 6081d7c0d53502d09b0ea84dd7ed5668be954277 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 10 Jan 2024 12:42:45 +0000 Subject: [PATCH 06/34] Testing: Tools options --- tests/bufr_ls.sh | 7 +++++++ tests/bufr_set.sh | 5 +++++ tests/grib_copy.sh | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/bufr_ls.sh b/tests/bufr_ls.sh index 0aed3128e..865d97032 100755 --- a/tests/bufr_ls.sh +++ b/tests/bufr_ls.sh @@ -80,6 +80,13 @@ set -e [ $status -ne 0 ] grep -w "unreadable message" $fLog +set +e +${tools_dir}/bufr_ls -j $fTmp > $fLog 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -w "unreadable message" $fLog + # Clean up rm -f $fLog $res_ls diff --git a/tests/bufr_set.sh b/tests/bufr_set.sh index f8224c0e1..55e6eea80 100755 --- a/tests/bufr_set.sh +++ b/tests/bufr_set.sh @@ -52,6 +52,11 @@ for i in 1 2 3 ;do [ $centre = "222" ] done +# Strict option +f=aeolus_wmo_26.bufr +${tools_dir}/bufr_set -S -w localNumberOfObservations=40 -s rdbType=3 $f $fBufrTmp +cnt=$( ${tools_dir}/bufr_count $fBufrTmp ) +[ $cnt -eq 3 ] #----------------------------------------------------- # Test: setting data values for single message file diff --git a/tests/grib_copy.sh b/tests/grib_copy.sh index 09b0c50f1..79546fb54 100755 --- a/tests/grib_copy.sh +++ b/tests/grib_copy.sh @@ -27,7 +27,8 @@ val2=`${tools_dir}/gts_get -p AA $temp` [ "$val1" = "$val2" ] [ "$val1" = "XK" ] -${tools_dir}/grib_copy -w count=1 $input $temp +${tools_dir}/grib_copy -p edition -w count=1 $input $temp +${tools_dir}/grib_copy -p shortName -w count=2 $input $temp set +e ${tools_dir}/gts_get -p AA $temp status=$? From b5f86e688a2f18b10444431b7a5207300a63be24 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 10 Jan 2024 12:43:12 +0000 Subject: [PATCH 07/34] Actions: Dead code removal --- src/action_class_put.cc | 90 ++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 46 deletions(-) diff --git a/src/action_class_put.cc b/src/action_class_put.cc index 49ec4bf6e..4c61c10e2 100644 --- a/src/action_class_put.cc +++ b/src/action_class_put.cc @@ -77,64 +77,62 @@ static void init_class(grib_action_class* c) grib_action* grib_action_create_put(grib_context* context, const char* name, grib_arguments* args) { - grib_action_put* a = NULL; - grib_action_class* c = grib_action_class_put; - grib_action* act = (grib_action*)grib_context_malloc_clear_persistent(context, c->size); - act->next = NULL; - act->name = grib_context_strdup_persistent(context, name); - act->op = grib_context_strdup_persistent(context, "forward"); - act->cclass = c; - act->context = context; - a = (grib_action_put*)act; - a->args = args; - return act; + grib_context_log(context, GRIB_LOG_FATAL, "Function '%s' is deprecated", __func__); + return NULL; + // grib_action_put* a = NULL; + // grib_action_class* c = grib_action_class_put; + // grib_action* act = (grib_action*)grib_context_malloc_clear_persistent(context, c->size); + // act->next = NULL; + // act->name = grib_context_strdup_persistent(context, name); + // act->op = grib_context_strdup_persistent(context, "forward"); + // act->cclass = c; + // act->context = context; + // a = (grib_action_put*)act; + // a->args = args; + // return act; } static int create_accessor(grib_section* p, grib_action* act, grib_loader* h) { - grib_action_put* a = (grib_action_put*)act; + grib_context_log(act->context, GRIB_LOG_FATAL, "Action '%s' is deprecated", act->op); + return GRIB_NOT_IMPLEMENTED; - grib_section* ts = NULL; + // grib_action_put* a = (grib_action_put*)act; + // grib_section* ts = NULL; + // grib_accessor* ga = NULL; + // ga = grib_find_accessor(p->h, grib_arguments_get_name(p->h, a->args, 1)); + // if (ga) + // ts = ga->sub_section; + // /* ts = grib_get_sub_section(ga); */ + // else + // return GRIB_BUFFER_TOO_SMALL; - grib_accessor* ga = NULL; - - ga = grib_find_accessor(p->h, grib_arguments_get_name(p->h, a->args, 1)); - if (ga) - ts = ga->sub_section; - /* ts = grib_get_sub_section(ga); */ - else - return GRIB_BUFFER_TOO_SMALL; - - if (ts) { - ga = grib_accessor_factory(ts, act, 0, a->args); - if (ga) - grib_push_accessor(ga, ts->block); - else - return GRIB_BUFFER_TOO_SMALL; - } - else { - grib_context_log(act->context, GRIB_LOG_ERROR, "Action_class_put : create_accessor_buffer : No Section named %s to export %s ", grib_arguments_get_name(p->h, a->args, 1), grib_arguments_get_name(p->h, a->args, 0)); - } - return GRIB_SUCCESS; + // if (ts) { + // ga = grib_accessor_factory(ts, act, 0, a->args); + // if (ga) + // grib_push_accessor(ga, ts->block); + // else + // return GRIB_BUFFER_TOO_SMALL; + // } + // else { + // grib_context_log(act->context, GRIB_LOG_ERROR, "Action_class_put : create_accessor_buffer : No Section named %s to export %s ", grib_arguments_get_name(p->h, a->args, 1), grib_arguments_get_name(p->h, a->args, 0)); + // } + // return GRIB_SUCCESS; } static void dump(grib_action* act, FILE* f, int lvl) { - grib_action_put* a = (grib_action_put*)act; - - int i = 0; - - for (i = 0; i < lvl; i++) - grib_context_print(act->context, f, " "); - - grib_context_print(act->context, f, "put %s as %s in %s\n", grib_arguments_get_name(0, a->args, 0), act->name, grib_arguments_get_name(0, a->args, 1)); + // grib_action_put* a = (grib_action_put*)act; + // int i = 0; + // for (i = 0; i < lvl; i++) + // grib_context_print(act->context, f, " "); + // grib_context_print(act->context, f, "put %s as %s in %s\n", grib_arguments_get_name(0, a->args, 0), act->name, grib_arguments_get_name(0, a->args, 1)); } static void destroy(grib_context* context, grib_action* act) { - grib_action_put* a = (grib_action_put*)act; - - grib_arguments_free(context, a->args); - grib_context_free_persistent(context, act->name); - grib_context_free_persistent(context, act->op); + // grib_action_put* a = (grib_action_put*)act; + // grib_arguments_free(context, a->args); + // grib_context_free_persistent(context, act->name); + // grib_context_free_persistent(context, act->op); } From 2ae963866379d4cfebcfdca191fe852e9563d340 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 10 Jan 2024 13:18:20 +0000 Subject: [PATCH 08/34] Testing: Deprecated statements --- src/action_class_put.cc | 125 +------------------------- src/action_class_trigger.cc | 4 +- src/action_class_while.cc | 2 +- src/deprecated/action_class_put.cc | 140 +++++++++++++++++++++++++++++ tests/codes_deprecated.sh | 17 ++-- 5 files changed, 156 insertions(+), 132 deletions(-) create mode 100644 src/deprecated/action_class_put.cc diff --git a/src/action_class_put.cc b/src/action_class_put.cc index 4c61c10e2..8574ab2c4 100644 --- a/src/action_class_put.cc +++ b/src/action_class_put.cc @@ -8,131 +8,12 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/*************************************************************************** - * Jean Baptiste Filippi - 01.11.2005 * - ***************************************************************************/ #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = action - IMPLEMENTS = create_accessor - IMPLEMENTS = dump - IMPLEMENTS = destroy - MEMBERS = grib_arguments* args - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -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 create_accessor(grib_section*,grib_action*,grib_loader*); - - -typedef struct grib_action_put { - grib_action act; - /* Members defined in put */ - grib_arguments* args; -} grib_action_put; - - -static grib_action_class _grib_action_class_put = { - 0, /* super */ - "action_class_put", /* name */ - sizeof(grib_action_put), /* size */ - 0, /* inited */ - &init_class, /* init_class */ - 0, /* init */ - &destroy, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - &create_accessor, /* create_accessor*/ - - 0, /* notify_change */ - 0, /* reparse */ - 0, /* execute */ -}; - -grib_action_class* grib_action_class_put = &_grib_action_class_put; - -static void init_class(grib_action_class* c) -{ -} -/* END_CLASS_IMP */ - +// No longer used: For the original intent see +// src/deprecated/action_class_put.cc grib_action* grib_action_create_put(grib_context* context, const char* name, grib_arguments* args) { - grib_context_log(context, GRIB_LOG_FATAL, "Function '%s' is deprecated", __func__); + grib_context_log(context, GRIB_LOG_ERROR, "The 'export' statement is deprecated"); return NULL; - // grib_action_put* a = NULL; - // grib_action_class* c = grib_action_class_put; - // grib_action* act = (grib_action*)grib_context_malloc_clear_persistent(context, c->size); - // act->next = NULL; - // act->name = grib_context_strdup_persistent(context, name); - // act->op = grib_context_strdup_persistent(context, "forward"); - // act->cclass = c; - // act->context = context; - // a = (grib_action_put*)act; - // a->args = args; - // return act; -} - -static int create_accessor(grib_section* p, grib_action* act, grib_loader* h) -{ - grib_context_log(act->context, GRIB_LOG_FATAL, "Action '%s' is deprecated", act->op); - return GRIB_NOT_IMPLEMENTED; - - // grib_action_put* a = (grib_action_put*)act; - // grib_section* ts = NULL; - // grib_accessor* ga = NULL; - // ga = grib_find_accessor(p->h, grib_arguments_get_name(p->h, a->args, 1)); - // if (ga) - // ts = ga->sub_section; - // /* ts = grib_get_sub_section(ga); */ - // else - // return GRIB_BUFFER_TOO_SMALL; - - // if (ts) { - // ga = grib_accessor_factory(ts, act, 0, a->args); - // if (ga) - // grib_push_accessor(ga, ts->block); - // else - // return GRIB_BUFFER_TOO_SMALL; - // } - // else { - // grib_context_log(act->context, GRIB_LOG_ERROR, "Action_class_put : create_accessor_buffer : No Section named %s to export %s ", grib_arguments_get_name(p->h, a->args, 1), grib_arguments_get_name(p->h, a->args, 0)); - // } - // return GRIB_SUCCESS; -} - -static void dump(grib_action* act, FILE* f, int lvl) -{ - // grib_action_put* a = (grib_action_put*)act; - // int i = 0; - // for (i = 0; i < lvl; i++) - // grib_context_print(act->context, f, " "); - // grib_context_print(act->context, f, "put %s as %s in %s\n", grib_arguments_get_name(0, a->args, 0), act->name, grib_arguments_get_name(0, a->args, 1)); -} - -static void destroy(grib_context* context, grib_action* act) -{ - // grib_action_put* a = (grib_action_put*)act; - // grib_arguments_free(context, a->args); - // grib_context_free_persistent(context, act->name); - // grib_context_free_persistent(context, act->op); } diff --git a/src/action_class_trigger.cc b/src/action_class_trigger.cc index f4a7413dc..c62893db6 100644 --- a/src/action_class_trigger.cc +++ b/src/action_class_trigger.cc @@ -10,8 +10,10 @@ #include "grib_api_internal.h" +// No longer used: For the original intent see +// src/deprecated/action_class_trigger.cc grib_action* grib_action_create_trigger(grib_context* context, grib_arguments* args, grib_action* block) { - grib_context_log(context, GRIB_LOG_FATAL, "The 'trigger' statement is deprecated"); + grib_context_log(context, GRIB_LOG_ERROR, "The 'trigger' statement is deprecated"); return NULL; } diff --git a/src/action_class_while.cc b/src/action_class_while.cc index 6ec144d15..e7d7dde75 100644 --- a/src/action_class_while.cc +++ b/src/action_class_while.cc @@ -14,6 +14,6 @@ // src/deprecated/action_class_while.cc grib_action* grib_action_create_while(grib_context* context, grib_expression* expression, grib_action* block) { - grib_context_log(context, GRIB_LOG_FATAL, "The 'while' statement is deprecated"); + grib_context_log(context, GRIB_LOG_ERROR, "The 'while' statement is deprecated"); return NULL; } diff --git a/src/deprecated/action_class_put.cc b/src/deprecated/action_class_put.cc new file mode 100644 index 000000000..49ec4bf6e --- /dev/null +++ b/src/deprecated/action_class_put.cc @@ -0,0 +1,140 @@ +/* + * (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. + */ + +/*************************************************************************** + * Jean Baptiste Filippi - 01.11.2005 * + ***************************************************************************/ +#include "grib_api_internal.h" + +/* + This is used by make_class.pl + + START_CLASS_DEF + CLASS = action + IMPLEMENTS = create_accessor + IMPLEMENTS = dump + IMPLEMENTS = destroy + MEMBERS = grib_arguments* args + END_CLASS_DEF + + */ + +/* START_CLASS_IMP */ + +/* + +Don't edit anything between START_CLASS_IMP and END_CLASS_IMP +Instead edit values between START_CLASS_DEF and END_CLASS_DEF +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 create_accessor(grib_section*,grib_action*,grib_loader*); + + +typedef struct grib_action_put { + grib_action act; + /* Members defined in put */ + grib_arguments* args; +} grib_action_put; + + +static grib_action_class _grib_action_class_put = { + 0, /* super */ + "action_class_put", /* name */ + sizeof(grib_action_put), /* size */ + 0, /* inited */ + &init_class, /* init_class */ + 0, /* init */ + &destroy, /* destroy */ + + &dump, /* dump */ + 0, /* xref */ + + &create_accessor, /* create_accessor*/ + + 0, /* notify_change */ + 0, /* reparse */ + 0, /* execute */ +}; + +grib_action_class* grib_action_class_put = &_grib_action_class_put; + +static void init_class(grib_action_class* c) +{ +} +/* END_CLASS_IMP */ + +grib_action* grib_action_create_put(grib_context* context, const char* name, grib_arguments* args) +{ + grib_action_put* a = NULL; + grib_action_class* c = grib_action_class_put; + grib_action* act = (grib_action*)grib_context_malloc_clear_persistent(context, c->size); + act->next = NULL; + act->name = grib_context_strdup_persistent(context, name); + act->op = grib_context_strdup_persistent(context, "forward"); + act->cclass = c; + act->context = context; + a = (grib_action_put*)act; + a->args = args; + return act; +} + +static int create_accessor(grib_section* p, grib_action* act, grib_loader* h) +{ + grib_action_put* a = (grib_action_put*)act; + + grib_section* ts = NULL; + + grib_accessor* ga = NULL; + + ga = grib_find_accessor(p->h, grib_arguments_get_name(p->h, a->args, 1)); + if (ga) + ts = ga->sub_section; + /* ts = grib_get_sub_section(ga); */ + else + return GRIB_BUFFER_TOO_SMALL; + + if (ts) { + ga = grib_accessor_factory(ts, act, 0, a->args); + if (ga) + grib_push_accessor(ga, ts->block); + else + return GRIB_BUFFER_TOO_SMALL; + } + else { + grib_context_log(act->context, GRIB_LOG_ERROR, "Action_class_put : create_accessor_buffer : No Section named %s to export %s ", grib_arguments_get_name(p->h, a->args, 1), grib_arguments_get_name(p->h, a->args, 0)); + } + return GRIB_SUCCESS; +} + +static void dump(grib_action* act, FILE* f, int lvl) +{ + grib_action_put* a = (grib_action_put*)act; + + int i = 0; + + for (i = 0; i < lvl; i++) + grib_context_print(act->context, f, " "); + + grib_context_print(act->context, f, "put %s as %s in %s\n", grib_arguments_get_name(0, a->args, 0), act->name, grib_arguments_get_name(0, a->args, 1)); +} + +static void destroy(grib_context* context, grib_action* act) +{ + grib_action_put* a = (grib_action_put*)act; + + grib_arguments_free(context, a->args); + grib_context_free_persistent(context, act->name); + grib_context_free_persistent(context, act->op); +} diff --git a/tests/codes_deprecated.sh b/tests/codes_deprecated.sh index 3dd59188b..e953b8d30 100755 --- a/tests/codes_deprecated.sh +++ b/tests/codes_deprecated.sh @@ -24,11 +24,7 @@ echo "Deprecated while statement" cat >$tempFilt < $tempOut 2>&1 -status=$? -set -e -[ $status -ne 0 ] grep -q "statement is deprecated" $tempOut @@ -37,13 +33,18 @@ echo "Deprecated trigger statement" cat >$tempFilt < $tempOut 2>&1 -status=$? -set -e -[ $status -ne 0 ] grep -q "statement is deprecated" $tempOut +echo "Deprecated export statement" +# ----------------------------------------- +cat >$tempFilt < $tempOut 2>&1 +grep -q "is deprecated" $tempOut + + # Clean up rm -f $tempGrib $tempFilt $tempOut $tempRef From 21a76256ce68b4d4dd0a9b7ba1ae3ccd29524aea Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 10 Jan 2024 13:26:23 +0000 Subject: [PATCH 09/34] Testing: Unused accessors --- src/grib_accessor_class_signed_bits.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/grib_accessor_class_signed_bits.cc b/src/grib_accessor_class_signed_bits.cc index 7082f827e..1750af3eb 100644 --- a/src/grib_accessor_class_signed_bits.cc +++ b/src/grib_accessor_class_signed_bits.cc @@ -159,6 +159,8 @@ static void dump(grib_accessor* a, grib_dumper* dumper) static int unpack_long(grib_accessor* a, long* val, size_t* len) { + return GRIB_NOT_IMPLEMENTED; +#if 0 grib_accessor_signed_bits* self = (grib_accessor_signed_bits*)a; int i; int ret = 0; @@ -193,10 +195,13 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) *len = rlen; return GRIB_SUCCESS; +#endif } static int pack_long(grib_accessor* a, const long* val, size_t* len) { + return GRIB_NOT_IMPLEMENTED; +#if 0 grib_accessor_signed_bits* self = (grib_accessor_signed_bits*)a; int ret = 0; long off = 0; @@ -232,6 +237,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) grib_context_free(a->context, buf); return ret; +#endif } static int value_count(grib_accessor* a, long* numberOfElements) From ea84ba63810c5f69d150725dbd31ef62d9e7d13e Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 10 Jan 2024 14:43:23 +0000 Subject: [PATCH 10/34] Testing: is_in_list expression --- src/grib_expression_class_is_in_list.cc | 25 +++++++------- tests/CMakeLists.txt | 1 + tests/filter_is_in_list.sh | 45 +++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 12 deletions(-) create mode 100755 tests/filter_is_in_list.sh diff --git a/src/grib_expression_class_is_in_list.cc b/src/grib_expression_class_is_in_list.cc index 4a6c3dc3b..0d61cf82c 100644 --- a/src/grib_expression_class_is_in_list.cc +++ b/src/grib_expression_class_is_in_list.cc @@ -173,22 +173,23 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* result) static int evaluate_double(grib_expression* g, grib_handle* h, double* result) { - grib_expression_is_in_list* e = (grib_expression_is_in_list*)g; - int err = 0; - char mybuf[1024] = {0,}; - size_t size = 1024; + return GRIB_NOT_IMPLEMENTED; + // grib_expression_is_in_list* e = (grib_expression_is_in_list*)g; + // int err = 0; + // char mybuf[1024] = {0,}; + // size_t size = 1024; - grib_trie* list = load_list(h->context, g, &err); + // grib_trie* list = load_list(h->context, g, &err); - if ((err = grib_get_string_internal(h, e->name, mybuf, &size)) != GRIB_SUCCESS) - return err; + // if ((err = grib_get_string_internal(h, e->name, mybuf, &size)) != GRIB_SUCCESS) + // return err; - if (grib_trie_get(list, mybuf)) - *result = 1; - else - *result = 0; + // if (grib_trie_get(list, mybuf)) + // *result = 1; + // else + // *result = 0; - return err; + // return err; } static string evaluate_string(grib_expression* g, grib_handle* h, char* buf, size_t* size, int* err) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3bed4fc84..9c50bad59 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -97,6 +97,7 @@ if( HAVE_BUILD_TOOLS ) grib_ifsParam grib_packing_order filter_substr + filter_is_in_list filter_transient_darray grib_uerra grib_ecpoint diff --git a/tests/filter_is_in_list.sh b/tests/filter_is_in_list.sh new file mode 100755 index 000000000..4f771a43b --- /dev/null +++ b/tests/filter_is_in_list.sh @@ -0,0 +1,45 @@ +#!/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="filter_is_in_list_test" +temp=temp.$label.txt +sample=$ECCODES_SAMPLES_PATH/GRIB2.tmpl + +# Evaluate long +${tools_dir}/grib_filter - $sample <$temp < Date: Wed, 10 Jan 2024 15:50:30 +0000 Subject: [PATCH 11/34] Action write: check for -ve value --- src/action_class_write.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/action_class_write.cc b/src/action_class_write.cc index dc29ad050..8f92d5753 100644 --- a/src/action_class_write.cc +++ b/src/action_class_write.cc @@ -103,7 +103,7 @@ static int execute(grib_action* act, grib_handle* h) { grib_action_write* a = (grib_action_write*)act; int err = GRIB_SUCCESS; - size_t size; + size_t size = 0; const void* buffer = NULL; const char* filename = NULL; char string[1024] = {0,}; @@ -116,13 +116,13 @@ static int execute(grib_action* act, grib_handle* h) } if (strlen(a->name) != 0) { - err = grib_recompose_name(h, NULL, a->name, string, 0); + err = grib_recompose_name(h, NULL, a->name, string, 0); filename = string; } else { if (act->context->outfilename) { filename = act->context->outfilename; - err = grib_recompose_name(h, NULL, act->context->outfilename, string, 0); + err = grib_recompose_name(h, NULL, act->context->outfilename, string, 0); if (!err) filename = string; } @@ -159,14 +159,16 @@ static int execute(grib_action* act, grib_handle* h) if (a->padtomultiple) { char* zeros = NULL; + if (a->padtomultiple < 0) + return GRIB_INVALID_ARGUMENT; size_t padding = a->padtomultiple - size % a->padtomultiple; - /* printf("XXX padding=%d size=%d padtomultiple=%d\n",padding,size,a->padtomultiple); */ + /* printf("XXX padding=%zu size=%zu padtomultiple=%d\n", padding, size,a->padtomultiple); */ zeros = (char*)calloc(padding, 1); if (!zeros) return GRIB_OUT_OF_MEMORY; if (fwrite(zeros, 1, padding, of->handle) != padding) { grib_context_log(act->context, (GRIB_LOG_ERROR) | (GRIB_LOG_PERROR), - "Error writing to %s", filename); + "Error writing to '%s'", filename); free(zeros); return GRIB_IO_PROBLEM; } @@ -177,7 +179,7 @@ static int execute(grib_action* act, grib_handle* h) const char gts_trailer[4] = { '\x0D', '\x0D', '\x0A', '\x03' }; if (fwrite(gts_trailer, 1, 4, of->handle) != 4) { grib_context_log(act->context, (GRIB_LOG_ERROR) | (GRIB_LOG_PERROR), - "Error writing GTS trailer to %s", filename); + "Error writing GTS trailer to '%s'", filename); return GRIB_IO_PROBLEM; } } From cf737502681851ad976d1f44e02c51edf5efe577 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 10 Jan 2024 15:50:44 +0000 Subject: [PATCH 12/34] Testing: filter write --- tests/grib_filter.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/grib_filter.sh b/tests/grib_filter.sh index c65daa128..5758f8813 100755 --- a/tests/grib_filter.sh +++ b/tests/grib_filter.sh @@ -406,6 +406,32 @@ EOF ${tools_dir}/grib_filter $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl +# Write statement with padding +# ------------------------------------------------------------------------ +input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl + +echo 'write;' | ${tools_dir}/grib_filter -o $tempGrib - $input +cmp $input $tempGrib # No padding added + +echo 'write(0);' | ${tools_dir}/grib_filter -o $tempGrib - $input +cmp $input $tempGrib # zero bytes padding + +echo 'write(10);' | ${tools_dir}/grib_filter -o $tempGrib - $input +set +e +cmp $input $tempGrib # output should be different byte-wise +status=$? +set -e +[ $status -ne 0 ] +${tools_dir}/grib_compare $input $tempGrib # compare should succeed + +set +e +echo 'write(-10);' | ${tools_dir}/grib_filter -o $tempGrib - $input > $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Invalid argument" $tempOut + + # Bad filter set +e ${tools_dir}/grib_filter a_non_existent_filter_file $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut 2>&1 From cbd277dc64c6255721e36e6838da402780512030 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 10 Jan 2024 16:05:58 +0000 Subject: [PATCH 13/34] Testing: filter GTS headers --- tests/grib_filter.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/grib_filter.sh b/tests/grib_filter.sh index 5758f8813..50c2a5105 100755 --- a/tests/grib_filter.sh +++ b/tests/grib_filter.sh @@ -432,7 +432,22 @@ set -e grep -q "Invalid argument" $tempOut +# GTS header +# --------------- +input=$data_dir/gts.grib +echo 'write;' | ${tools_dir}/grib_filter -g -o $tempGrib - $input +cmp $input $tempGrib + +echo 'write;' | ${tools_dir}/grib_filter -o $tempGrib - $input +set +e +cmp $input $tempGrib +status=$? +set -e +[ $status -ne 0 ] + + # Bad filter +# ---------------- set +e ${tools_dir}/grib_filter a_non_existent_filter_file $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut 2>&1 status=$? From f3f8025d574a6674fe44863b2246fc372ed8a319 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 10 Jan 2024 16:20:12 +0000 Subject: [PATCH 14/34] Testing: GRIB1 data_dummy_field packing --- tests/grib_copy.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/grib_copy.sh b/tests/grib_copy.sh index 79546fb54..1aeac80e6 100755 --- a/tests/grib_copy.sh +++ b/tests/grib_copy.sh @@ -103,6 +103,12 @@ set -e grep -w "unreadable message" $fLog +#------------------------------------------------------------------- +echo "Test: dummy field ..." +#------------------------------------------------------------------- +input=${data_dir}/missing_field.grib1 +${tools_dir}/grib_copy -r $input $temp + #${tools_dir}/grib_copy -w count=1 -X 57143 $input $temp #Last msg #r1=`${tools_dir}/grib_get -w count=37 -n ls $input` #r2=`${tools_dir}/grib_get -n ls $temp` From 78aa5199616d9a9265930bc008b0d53a5846814a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 10 Jan 2024 16:20:19 +0000 Subject: [PATCH 15/34] Testing: GRIB1 data_dummy_field packing --- src/grib_accessor_class_data_dummy_field.cc | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/grib_accessor_class_data_dummy_field.cc b/src/grib_accessor_class_data_dummy_field.cc index 0f654045c..65b6d5a8f 100644 --- a/src/grib_accessor_class_data_dummy_field.cc +++ b/src/grib_accessor_class_data_dummy_field.cc @@ -132,19 +132,18 @@ grib_accessor_class* grib_accessor_class_data_dummy_field = &_grib_accessor_clas static void init(grib_accessor* a, const long v, grib_arguments* args) { grib_accessor_data_dummy_field* self = (grib_accessor_data_dummy_field*)a; - self->missing_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->numberOfPoints = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->missing_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->numberOfPoints = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); } static int unpack_double(grib_accessor* a, double* val, size_t* len) { grib_accessor_data_dummy_field* self = (grib_accessor_data_dummy_field*)a; - size_t i = 0; - size_t n_vals = 0; + size_t i = 0, n_vals = 0; long numberOfPoints; double missing_value = 0; - int err = 0; + int err = 0; if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &numberOfPoints)) != GRIB_SUCCESS) return err; @@ -174,15 +173,11 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) { grib_accessor_data_dummy_field* self = (grib_accessor_data_dummy_field*)a; - size_t n_vals = *len; int err = 0; - long bits_per_value = 0; - long half_byte = 0; - - size_t buflen = 0; + size_t buflen = 0; unsigned char* buf = NULL; if (*len == 0) @@ -213,8 +208,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) static int value_count(grib_accessor* a, long* numberOfPoints) { grib_accessor_data_dummy_field* self = (grib_accessor_data_dummy_field*)a; - int err = 0; - *numberOfPoints = 0; + int err = 0; + *numberOfPoints = 0; if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, numberOfPoints)) != GRIB_SUCCESS) { grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to get count of %s (%s)", a->name, grib_get_error_message(err)); From 9c693eabab94f5ecce780303ef3e690788bbf079 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 10 Jan 2024 17:08:29 +0000 Subject: [PATCH 16/34] Tools: Error messages --- tools/bufr_index_build.cc | 2 +- tools/codes_export_resource.cc | 1 + tools/grib_index_build.cc | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/bufr_index_build.cc b/tools/bufr_index_build.cc index ac29bd6b7..d05a2f622 100644 --- a/tools/bufr_index_build.cc +++ b/tools/bufr_index_build.cc @@ -86,7 +86,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil printf("--- %s: processing %s\n", tool_name, file); ret = grib_index_add_file(idx, file); if (ret) { - printf("error: %s\n", grib_get_error_message(ret)); + fprintf(stderr, "Error: %s\n", grib_get_error_message(ret)); exit(ret); } return 0; diff --git a/tools/codes_export_resource.cc b/tools/codes_export_resource.cc index 400373d83..f2d484fbb 100644 --- a/tools/codes_export_resource.cc +++ b/tools/codes_export_resource.cc @@ -75,6 +75,7 @@ int main(int argc, char* argv[]) fout = fopen(out_file, "wb"); if (!fout) { fprintf(stderr, "Failed to open output file '%s'\n", out_file); + perror(out_file); return 1; } fin = codes_fopen(full_path, "r"); diff --git a/tools/grib_index_build.cc b/tools/grib_index_build.cc index 6e933da2b..0d294fbaf 100644 --- a/tools/grib_index_build.cc +++ b/tools/grib_index_build.cc @@ -83,7 +83,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil printf("--- %s: processing %s\n", tool_name, file); ret = grib_index_add_file(idx, file); if (ret) { - printf("error: %s\n", grib_get_error_message(ret)); + fprintf(stderr, "Error: %s\n", grib_get_error_message(ret)); exit(ret); } return 0; From d061202a59685e9d5677dbc3de54edefaa51f10a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 10 Jan 2024 17:09:10 +0000 Subject: [PATCH 17/34] Testing: Error conditions (indexing tools) --- tests/bufr_indexing.sh | 15 ++++++++++++++- tests/codes_export_resource.sh | 6 ++++++ tests/grib_indexing.sh | 12 ++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/tests/bufr_indexing.sh b/tests/bufr_indexing.sh index a3030d46c..297f71bba 100755 --- a/tests/bufr_indexing.sh +++ b/tests/bufr_indexing.sh @@ -12,6 +12,7 @@ label="bufr_indexing_test" tempIndex=temp.$label.$$.idx +tempBufr=temp.$label.$$.bufr tempOut=temp.$label.$$.out tempRef=temp.$label.$$.ref @@ -41,5 +42,17 @@ ${tools_dir}/bufr_index_build -k mars.ident -o $tempIndex $infile |\ grep -q "mars.ident = { 01001, 01003, 01007 }" +# ------------------ +# Error conditions +# ------------------ +echo BUFR > $tempBufr +set +e +${tools_dir}/bufr_index_build $tempBufr > $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "End of resource reached" $tempOut + + # Clean up -rm -f $tempIndex $tempOut $tempRef +rm -f $tempIndex $tempOut $tempRef $tempBufr diff --git a/tests/codes_export_resource.sh b/tests/codes_export_resource.sh index fddb45c45..13623c8a3 100755 --- a/tests/codes_export_resource.sh +++ b/tests/codes_export_resource.sh @@ -67,6 +67,12 @@ status=$? set -e [ $status -eq 1 ] +set +e +${tools_dir}/codes_export_resource -s GRIB2 / +status=$? +set -e +[ $status -eq 1 ] + # Clean up rm -f $temp diff --git a/tests/grib_indexing.sh b/tests/grib_indexing.sh index 58980f85d..69d1031bc 100755 --- a/tests/grib_indexing.sh +++ b/tests/grib_indexing.sh @@ -153,6 +153,18 @@ ${tools_dir}/grib_index_build -N -o $tempIndex1 $sample1 > /dev/null ${tools_dir}/grib_dump $tempIndex1 >/dev/null +# ------------------ +# Error conditions +# ------------------ +echo GRIB > $tempGribFile1 +set +e +${tools_dir}/grib_index_build $tempGribFile1 > $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "End of resource reached" $tempOut + + # Clean up rm -f $tempOut $tempRef rm -f $tempIndex $tempIndex1 $tempIndex2 $tempGribFile1 $tempGribFile2 From 5e843d160024cb9064e590f4947615e4b8a07146 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 10 Jan 2024 17:26:12 +0000 Subject: [PATCH 18/34] Testing: GTS/METAR tools --- tests/gts_dump.sh | 1 + tools/metar_dump.cc | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/gts_dump.sh b/tests/gts_dump.sh index b8c8db2e8..21733d0a6 100755 --- a/tests/gts_dump.sh +++ b/tests/gts_dump.sh @@ -20,6 +20,7 @@ cd ${data_dir}/gts gts_file=EGRR20150317121020_00493212.DAT ${tools_dir}/gts_dump -w count=1 $gts_file +${tools_dir}/gts_dump -w count=2 $gts_file ${tools_dir}/gts_dump -Dat $gts_file ${tools_dir}/gts_dump -OH $gts_file diff --git a/tools/metar_dump.cc b/tools/metar_dump.cc index f992d1f36..52c5b45be 100644 --- a/tools/metar_dump.cc +++ b/tools/metar_dump.cc @@ -99,7 +99,7 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi if (!options->current_infile->name) return 0; snprintf(tmp, 1024, "FILE: %s ", options->current_infile->name); - if ( !grib_options_on("C") && !grib_options_on("j") ) + if ( !grib_options_on("j") ) fprintf(stdout, "***** %s\n", tmp); return 0; } @@ -118,7 +118,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) grib_set_flag(h, options->print_keys[i].name, GRIB_ACCESSOR_FLAG_DUMP); snprintf(tmp, 1024, "MESSAGE %d ( length=%ld )", options->handle_count, length); - if (!grib_options_on("C") && !grib_options_on("j")) + if (!grib_options_on("j")) fprintf(stdout, "#============== %-38s ==============\n", tmp); if (!strcmp(options->dump_mode, "default")) { GRIB_CHECK_NOLINE(grib_get_string(h, "identifier", identifier, &idlen), 0); From ff522d0990388e5ca4eee453a30fb4644c220ae3 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 10 Jan 2024 17:38:46 +0000 Subject: [PATCH 19/34] Tools: Dead code removal --- tools/bufr_compare.cc | 52 ------------------------------------------- 1 file changed, 52 deletions(-) diff --git a/tools/bufr_compare.cc b/tools/bufr_compare.cc index 9a1905944..d2d1f0e7a 100644 --- a/tools/bufr_compare.cc +++ b/tools/bufr_compare.cc @@ -698,7 +698,6 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g char *sval1 = NULL, *sval2 = NULL; char **svals1 = NULL, **svals2 = NULL; - unsigned char *uval1 = NULL, *uval2 = NULL; double *dval1 = NULL, *dval2 = NULL; long *lval1 = NULL, *lval2 = NULL; double maxdiff = 0; @@ -1094,60 +1093,9 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g printf(" as bytes\n"); if (options->mode == MODE_BUFR) return 0; - if (len1 < 2) - len1 = 512; - if (len2 < 2) - len2 = 512; - uval1 = (unsigned char*)grib_context_malloc(handle1->context, len1 * sizeof(unsigned char)); - uval2 = (unsigned char*)grib_context_malloc(handle2->context, len2 * sizeof(unsigned char)); - - if ((err1 = grib_get_bytes(handle1, name, uval1, &len1)) != GRIB_SUCCESS) { - printInfo(handle1); - save_error(c, name); - printf("Error: cannot get bytes value of [%s] in %s field: %s\n", - name, first_str, grib_get_error_message(err1)); - } - - if ((err2 = grib_get_bytes(handle2, name, uval2, &len2)) != GRIB_SUCCESS) { - printInfo(handle1); - save_error(c, name); - printf("Error: cannot get bytes value of [%s] in %s field: %s\n", - name, second_str, grib_get_error_message(err2)); - } - - if (err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS) { - if (memcmp(uval1, uval2, len1) != 0) { - for (i = 0; i < len1; i++) { - if (uval1[i] != uval2[i]) { - printInfo(handle1); - save_error(c, name); - if (len1 == 1) - printf("[%s] byte values are different: [%02x] and [%02x]\n", - name, uval1[i], uval2[i]); - else - printf("[%s] byte value %d of %ld are different: [%02x] and [%02x]\n", - name, i, (long)len1, uval1[i], uval2[i]); - - err1 = GRIB_VALUE_MISMATCH; - break; - } - } - err1 = GRIB_VALUE_MISMATCH; - } - } - - grib_context_free(handle1->context, uval1); - grib_context_free(handle2->context, uval2); - - if (err1) - return err1; - if (err2) - return err2; break; case GRIB_TYPE_LABEL: - if (verbose) - printf(" as label\n"); break; default: From 45f47d1b9063e7771bc0222fae74ac20d254409e Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 10 Jan 2024 17:57:20 +0000 Subject: [PATCH 20/34] Indexing: Make functions local --- src/eccodes_prototypes.h | 13 --------- src/grib_index.cc | 58 ++++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 42 deletions(-) diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index f9e208e88..febe5573e 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -635,19 +635,6 @@ grib_action* grib_action_create_set_missing(grib_context* context, const char* n /* grib_index.cc*/ int grib_index_compress(grib_index* index); -int grib_read_uchar(FILE* fh, unsigned char* val); -int grib_read_short(FILE* fh, short* val); -int grib_read_long(FILE* fh, long* val); -int grib_read_unsigned_long(FILE* fh, unsigned long* val); -int grib_write_uchar(FILE* fh, unsigned char val); -int grib_write_short(FILE* fh, short val); -int grib_write_long(FILE* fh, long val); -int grib_write_unsigned_long(FILE* fh, unsigned long val); -int grib_write_string(FILE* fh, const char* s); -int grib_write_identifier(FILE* fh, const char* id); -int grib_write_null_marker(FILE* fh); -int grib_write_not_null_marker(FILE* fh); -char* grib_read_string(grib_context* c, FILE* fh, int* err); grib_field_tree* grib_read_field_tree(grib_context* c, FILE* fh, grib_file** files, int* err); grib_index* grib_index_new(grib_context* c, const char* key, int* err); void grib_index_delete(grib_index* index); diff --git a/src/grib_index.cc b/src/grib_index.cc index ca6e0defc..2432d620d 100644 --- a/src/grib_index.cc +++ b/src/grib_index.cc @@ -274,7 +274,7 @@ static grib_index_key* grib_index_new_key(grib_context* c, grib_index_key* keys, return keys; } -int grib_read_uchar(FILE* fh, unsigned char* val) +static int grib_read_uchar(FILE* fh, unsigned char* val) { if (fread(val, sizeof(unsigned char), 1, fh) < 1) { if (feof(fh)) @@ -285,7 +285,7 @@ int grib_read_uchar(FILE* fh, unsigned char* val) return GRIB_SUCCESS; } -int grib_read_short(FILE* fh, short* val) +static int grib_read_short(FILE* fh, short* val) { if (fread(val, sizeof(short), 1, fh) < 1) { if (feof(fh)) @@ -296,7 +296,18 @@ int grib_read_short(FILE* fh, short* val) return GRIB_SUCCESS; } -int grib_read_long(FILE* fh, long* val) +// static int grib_read_long(FILE* fh, long* val) +// { +// if (fread(val, sizeof(long), 1, fh) < 1) { +// if (feof(fh)) +// return GRIB_END_OF_FILE; +// else +// return GRIB_IO_PROBLEM; +// } +// return GRIB_SUCCESS; +// } + +static int grib_read_unsigned_long(FILE* fh, unsigned long* val) { if (fread(val, sizeof(long), 1, fh) < 1) { if (feof(fh)) @@ -307,46 +318,35 @@ int grib_read_long(FILE* fh, long* val) return GRIB_SUCCESS; } -int grib_read_unsigned_long(FILE* fh, unsigned long* val) -{ - if (fread(val, sizeof(long), 1, fh) < 1) { - if (feof(fh)) - return GRIB_END_OF_FILE; - else - return GRIB_IO_PROBLEM; - } - return GRIB_SUCCESS; -} - -int grib_write_uchar(FILE* fh, unsigned char val) +static int grib_write_uchar(FILE* fh, unsigned char val) { if (fwrite(&val, sizeof(unsigned char), 1, fh) < 1) return GRIB_IO_PROBLEM; return GRIB_SUCCESS; } -int grib_write_short(FILE* fh, short val) +static int grib_write_short(FILE* fh, short val) { if (fwrite(&val, sizeof(short), 1, fh) < 1) return GRIB_IO_PROBLEM; return GRIB_SUCCESS; } -int grib_write_long(FILE* fh, long val) +// static int grib_write_long(FILE* fh, long val) +// { +// if (fwrite(&val, sizeof(long), 1, fh) < 1) +// return GRIB_IO_PROBLEM; +// return GRIB_SUCCESS; +// } + +static int grib_write_unsigned_long(FILE* fh, unsigned long val) { if (fwrite(&val, sizeof(long), 1, fh) < 1) return GRIB_IO_PROBLEM; return GRIB_SUCCESS; } -int grib_write_unsigned_long(FILE* fh, unsigned long val) -{ - if (fwrite(&val, sizeof(long), 1, fh) < 1) - return GRIB_IO_PROBLEM; - return GRIB_SUCCESS; -} - -int grib_write_string(FILE* fh, const char* s) +static int grib_write_string(FILE* fh, const char* s) { size_t len = 0; if (s == NULL) @@ -358,22 +358,22 @@ int grib_write_string(FILE* fh, const char* s) return GRIB_SUCCESS; } -int grib_write_identifier(FILE* fh, const char* ID) +static int grib_write_identifier(FILE* fh, const char* ID) { return grib_write_string(fh, ID); } -int grib_write_null_marker(FILE* fh) +static int grib_write_null_marker(FILE* fh) { return grib_write_uchar(fh, NULL_MARKER); } -int grib_write_not_null_marker(FILE* fh) +static int grib_write_not_null_marker(FILE* fh) { return grib_write_uchar(fh, NOT_NULL_MARKER); } -char* grib_read_string(grib_context* c, FILE* fh, int* err) +static char* grib_read_string(grib_context* c, FILE* fh, int* err) { unsigned char len = 0; char* s = NULL; From d3e7e2ecb28e794e291dd70ee946815fdc305870 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 10 Jan 2024 21:05:38 +0000 Subject: [PATCH 21/34] Testing: Fortran key setting --- examples/F90/grib_set_gvc.f90 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/F90/grib_set_gvc.f90 b/examples/F90/grib_set_gvc.f90 index af6a340ec..08d0ef7a0 100644 --- a/examples/F90/grib_set_gvc.f90 +++ b/examples/F90/grib_set_gvc.f90 @@ -15,8 +15,12 @@ program set use eccodes implicit none - integer :: infile, outfile - integer :: igrib + integer :: infile, outfile + integer :: igrib + real(4) :: nlev_real4 = 12.21 + real(8) :: nlev_real8 = 12.21 + integer(4) :: PDTN_int = 11 + integer(8) :: PDTN_long = 11 call codes_open_file(infile, '../../data/sample.grib2', 'r') @@ -25,13 +29,15 @@ program set call codes_grib_new_from_file(infile, igrib) ! individual ensemble forecast - call codes_set(igrib, 'productDefinitionTemplateNumber', 11) + call codes_set(igrib, 'productDefinitionTemplateNumber', PDTN_int) + call codes_set(igrib, 'productDefinitionTemplateNumber', PDTN_long) ! select level type as Generalized Vertical Height Coordinate call codes_set(igrib, 'typeOfLevel', 'generalVertical') ! now set keys specific to this level type - call codes_set(igrib, 'nlev', 12.21) + call codes_set(igrib, 'nlev', nlev_real4) + call codes_set(igrib, 'nlev', nlev_real8) call codes_set(igrib, 'numberOfVGridUsed', 13.55) ! check integrity of GRIB message From 6f4a3f625a951ec9f77be7c4b81481e1593de777 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 11 Jan 2024 12:37:38 +0000 Subject: [PATCH 22/34] Fortran: Dead code removal --- fortran/grib_fortran.c | 48 ++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.c index d9ab1f459..9a4b48996 100644 --- a/fortran/grib_fortran.c +++ b/fortran/grib_fortran.c @@ -748,6 +748,7 @@ static int _clear_index(int index_id) return GRIB_SUCCESS; } +#if 0 static int _clear_multi_handle(int multi_handle_id) { l_grib_multi_handle* current = multi_handle_set; @@ -761,6 +762,7 @@ static int _clear_multi_handle(int multi_handle_id) } return GRIB_SUCCESS; } +#endif static int clear_handle(int handle_id) { @@ -782,6 +784,7 @@ static int clear_index(int index_id) return ret; } +#if 0 static int clear_multi_handle(int multi_handle_id) { int ret=0; @@ -791,6 +794,7 @@ static int clear_multi_handle(int multi_handle_id) GRIB_MUTEX_UNLOCK(&multi_handle_mutex); return ret; } +#endif static int _clear_keys_iterator(int keys_iterator_id) { @@ -1214,22 +1218,23 @@ int grib_f_skip_function_(int* iterid) { /*****************************************************************************/ int grib_f_keys_iterator_get_name_(int* iterid,char* name,int len) { - size_t lsize=len; + size_t input_len = len; + size_t lsize = len; char buf[1024]={0,}; grib_keys_iterator* kiter=get_keys_iterator(*iterid); if (!kiter) return GRIB_INVALID_KEYS_ITERATOR; - fort_char_clean(name,len); + fort_char_clean(name, len); sprintf(buf,"%s",grib_keys_iterator_get_name(kiter)); - lsize=strlen(buf); - if (len < lsize) return GRIB_ARRAY_TOO_SMALL; + lsize = strlen(buf); + if (input_len < lsize) return GRIB_ARRAY_TOO_SMALL; - memcpy(name,buf,lsize); + memcpy(name, buf, lsize); - czstr_to_fortran(name,len); + czstr_to_fortran(name, len); return 0; } @@ -1279,23 +1284,24 @@ int codes_f_bufr_keys_iterator_next_(int* iterid) { } /*****************************************************************************/ -int codes_f_bufr_keys_iterator_get_name_(int* iterid,char* name,int len) { - size_t lsize=len; - char buf[1024]={0,}; +int codes_f_bufr_keys_iterator_get_name_(int* iterid, char* name, int len) { + size_t input_len = len; + size_t lsize = len; + char buf[1024] = {0,}; - bufr_keys_iterator* kiter=get_bufr_keys_iterator(*iterid); + bufr_keys_iterator* kiter = get_bufr_keys_iterator(*iterid); if (!kiter) return GRIB_INVALID_KEYS_ITERATOR; - fort_char_clean(name,len); + fort_char_clean(name, len); - sprintf(buf,"%s",codes_bufr_keys_iterator_get_name(kiter)); - lsize=strlen(buf); - if (len < lsize) return GRIB_ARRAY_TOO_SMALL; + sprintf(buf, "%s", codes_bufr_keys_iterator_get_name(kiter)); + lsize = strlen(buf); + if (input_len < lsize) return GRIB_ARRAY_TOO_SMALL; - memcpy(name,buf,lsize); + memcpy(name, buf, lsize); - czstr_to_fortran(name,len); + czstr_to_fortran(name, len); return 0; } @@ -1758,9 +1764,9 @@ int grib_f_index_release_(int* hid){ return clear_index(*hid); } -int grib_f_multi_handle_release_(int* hid){ +/* int grib_f_multi_handle_release_(int* hid){ return clear_multi_handle(*hid); -} +} */ int grib_f_release_(int* hid){ return clear_handle(*hid); @@ -1818,7 +1824,7 @@ int grib_f_print_(int* gid, char* key, int len){ } #endif /*****************************************************************************/ -int grib_f_get_error_string_(int* err, char* buf, int len){ +int grib_f_get_error_string_(int* err, char* buf, int len) { const char* err_msg = grib_get_error_message(*err); const size_t erlen = strlen(err_msg); if( len < erlen) return GRIB_ARRAY_TOO_SMALL; @@ -1827,7 +1833,7 @@ int grib_f_get_error_string_(int* err, char* buf, int len){ } /*****************************************************************************/ -int grib_f_get_api_version_(int* apiVersion,int len){ +int grib_f_get_api_version_(int* apiVersion,int len) { *apiVersion = grib_get_api_version(); return GRIB_SUCCESS; } @@ -2221,7 +2227,7 @@ int grib_f_get_real4_elements_(int* gid, char* key,int* index, float *val,int* s int err = GRIB_SUCCESS; char buf[1024]; size_t lsize = *size; - long i=0; + size_t i = 0; double* val8 = NULL; if(!h) return GRIB_INVALID_GRIB; From 5e6313407f467ad07d1b3f3e4c319f407296d119 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 11 Jan 2024 13:40:07 +0000 Subject: [PATCH 23/34] Fortran: Reformatting --- fortran/grib_fortran.c | 353 +++++++++++++++++++++++++---------------- 1 file changed, 215 insertions(+), 138 deletions(-) diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.c index 9a4b48996..be814a1bd 100644 --- a/fortran/grib_fortran.c +++ b/fortran/grib_fortran.c @@ -845,7 +845,8 @@ static int clear_bufr_keys_iterator(int keys_iterator_id) /*****************************************************************************/ #if 0 -int grib_f_read_any_headers_only_from_file_(int* fid, char* buffer, size_t* nbytes) { +int grib_f_read_any_headers_only_from_file_(int* fid, char* buffer, size_t* nbytes) +{ grib_context* c; int err=0; FILE* f=get_file(*fid); @@ -861,7 +862,8 @@ int grib_f_read_any_headers_only_from_file_(int* fid, char* buffer, size_t* nbyt #endif /*****************************************************************************/ -int grib_f_read_any_from_file_(int* fid, void* buffer, size_t* nbytes) { +int grib_f_read_any_from_file_(int* fid, void* buffer, size_t* nbytes) +{ grib_context* c; int err=0; FILE* f=get_file(*fid); @@ -876,7 +878,8 @@ int grib_f_read_any_from_file_(int* fid, void* buffer, size_t* nbytes) { } /*****************************************************************************/ -int grib_f_write_file_(int* fid, void* buffer, size_t* nbytes) { +int grib_f_write_file_(int* fid, void* buffer, size_t* nbytes) +{ grib_context* c; FILE* f=get_file(*fid); @@ -895,7 +898,8 @@ int grib_f_write_file_(int* fid, void* buffer, size_t* nbytes) { } /*****************************************************************************/ -int grib_f_read_file_(int* fid, void* buffer, size_t* nbytes) { +int grib_f_read_file_(int* fid, void* buffer, size_t* nbytes) +{ grib_context* c; FILE* f=get_file(*fid); @@ -914,7 +918,8 @@ int grib_f_read_file_(int* fid, void* buffer, size_t* nbytes) { } /*****************************************************************************/ -int grib_f_open_file_(int* fid, char* name , char* op, int lname, int lop) { +int grib_f_open_file_(int* fid, char* name , char* op, int lname, int lop) +{ FILE* f = NULL; int ioerr=0; char oper[1024]; /* GRIB-576: open mode */ @@ -961,7 +966,8 @@ int grib_f_open_file_(int* fid, char* name , char* op, int lname, int lop) { } /*****************************************************************************/ -int grib_f_close_file_(int* fid){ +int grib_f_close_file_(int* fid) +{ return clear_file(*fid); } @@ -990,12 +996,14 @@ void grib_f_write_on_fail_(int* gid) { grib_f_write_on_fail(gid); } /*****************************************************************************/ -int grib_f_multi_support_on_(){ +int grib_f_multi_support_on_() +{ grib_multi_support_on(0); return GRIB_SUCCESS; } -int grib_f_multi_support_off_(){ +int grib_f_multi_support_off_() +{ grib_multi_support_off(0); return GRIB_SUCCESS; } @@ -1128,7 +1136,8 @@ int grib_f_iterator_delete_(int* iterid) { #endif /*FORTRAN_GEOITERATOR_SUPPORT*/ /*****************************************************************************/ -static int _grib_f_keys_iterator_new_(int* gid,int* iterid,char* name_space,int len) { +static int _grib_f_keys_iterator_new_(int* gid,int* iterid,char* name_space,int len) +{ int err=0; char buf[1024]; grib_handle* h; @@ -1146,7 +1155,8 @@ static int _grib_f_keys_iterator_new_(int* gid,int* iterid,char* name_space,int *iterid=-1; return err; } -int grib_f_keys_iterator_new_(int* gid,int* iterid,char* name_space,int len) { +int grib_f_keys_iterator_new_(int* gid,int* iterid,char* name_space,int len) +{ int ret=0; GRIB_MUTEX_INIT_ONCE(&once,&init) GRIB_MUTEX_LOCK(&keys_iterator_mutex) @@ -1156,7 +1166,8 @@ int grib_f_keys_iterator_new_(int* gid,int* iterid,char* name_space,int len) { } /*****************************************************************************/ -int grib_f_keys_iterator_next_(int* iterid) { +int grib_f_keys_iterator_next_(int* iterid) +{ grib_keys_iterator* iter=get_keys_iterator(*iterid); if (!iter) return GRIB_INVALID_KEYS_ITERATOR; @@ -1164,60 +1175,70 @@ int grib_f_keys_iterator_next_(int* iterid) { } /*****************************************************************************/ -int grib_f_keys_iterator_delete_(int* iterid) { +int grib_f_keys_iterator_delete_(int* iterid) +{ return clear_keys_iterator(*iterid); } /*****************************************************************************/ -int grib_f_gribex_mode_on_() { +int grib_f_gribex_mode_on_() +{ grib_gribex_mode_on(0); return GRIB_SUCCESS; } -int grib_f_gribex_mode_off_() { +int grib_f_gribex_mode_off_() +{ grib_gribex_mode_off(0); return GRIB_SUCCESS; } /*****************************************************************************/ -int grib_f_skip_computed_(int* iterid) { +int grib_f_skip_computed_(int* iterid) +{ grib_keys_iterator* iter=get_keys_iterator(*iterid); if (!iter) return GRIB_INVALID_KEYS_ITERATOR; return grib_keys_iterator_set_flags(iter,GRIB_KEYS_ITERATOR_SKIP_COMPUTED); } -int grib_f_skip_coded_(int* iterid) { +int grib_f_skip_coded_(int* iterid) +{ grib_keys_iterator* iter=get_keys_iterator(*iterid); if (!iter) return GRIB_INVALID_KEYS_ITERATOR; return grib_keys_iterator_set_flags(iter,GRIB_KEYS_ITERATOR_SKIP_CODED); } -int grib_f_skip_edition_specific_(int* iterid) { +int grib_f_skip_edition_specific_(int* iterid) +{ grib_keys_iterator* iter=get_keys_iterator(*iterid); if (!iter) return GRIB_INVALID_KEYS_ITERATOR; return grib_keys_iterator_set_flags(iter,GRIB_KEYS_ITERATOR_SKIP_EDITION_SPECIFIC); } -int grib_f_skip_duplicates_(int* iterid) { +int grib_f_skip_duplicates_(int* iterid) +{ grib_keys_iterator* iter=get_keys_iterator(*iterid); if (!iter) return GRIB_INVALID_KEYS_ITERATOR; return grib_keys_iterator_set_flags(iter,GRIB_KEYS_ITERATOR_SKIP_DUPLICATES); } -int grib_f_skip_read_only_(int* iterid) { +int grib_f_skip_read_only_(int* iterid) +{ grib_keys_iterator* iter=get_keys_iterator(*iterid); if (!iter) return GRIB_INVALID_KEYS_ITERATOR; return grib_keys_iterator_set_flags(iter,GRIB_KEYS_ITERATOR_SKIP_READ_ONLY); } -int grib_f_skip_function_(int* iterid) { +int grib_f_skip_function_(int* iterid) +{ grib_keys_iterator* iter=get_keys_iterator(*iterid); if (!iter) return GRIB_INVALID_KEYS_ITERATOR; return grib_keys_iterator_set_flags(iter,GRIB_KEYS_ITERATOR_SKIP_FUNCTION); } /*****************************************************************************/ -int grib_f_keys_iterator_get_name_(int* iterid,char* name,int len) { +int grib_f_keys_iterator_get_name_(int* iterid,char* name,int len) +{ size_t input_len = len; size_t lsize = len; char buf[1024]={0,}; @@ -1240,7 +1261,8 @@ int grib_f_keys_iterator_get_name_(int* iterid,char* name,int len) { } /*****************************************************************************/ -int grib_f_keys_iterator_rewind_(int* kiter) { +int grib_f_keys_iterator_rewind_(int* kiter) +{ grib_keys_iterator* i=get_keys_iterator(*kiter); if (!i) return GRIB_INVALID_KEYS_ITERATOR; @@ -1249,7 +1271,8 @@ int grib_f_keys_iterator_rewind_(int* kiter) { /* BUFR keys iterator */ /*****************************************************************************/ -static int _codes_f_bufr_keys_iterator_new_(int* gid,int* iterid) { +static int _codes_f_bufr_keys_iterator_new_(int* gid,int* iterid) +{ int err=0; grib_handle* h; bufr_keys_iterator* iter; @@ -1267,7 +1290,8 @@ static int _codes_f_bufr_keys_iterator_new_(int* gid,int* iterid) { *iterid=-1; return err; } -int codes_f_bufr_keys_iterator_new_(int* gid,int* iterid) { +int codes_f_bufr_keys_iterator_new_(int* gid,int* iterid) +{ int ret=0; GRIB_MUTEX_INIT_ONCE(&once,&init) GRIB_MUTEX_LOCK(&keys_iterator_mutex) @@ -1276,7 +1300,8 @@ int codes_f_bufr_keys_iterator_new_(int* gid,int* iterid) { return ret; } /*****************************************************************************/ -int codes_f_bufr_keys_iterator_next_(int* iterid) { +int codes_f_bufr_keys_iterator_next_(int* iterid) +{ bufr_keys_iterator* iter=get_bufr_keys_iterator(*iterid); if (!iter) return GRIB_INVALID_KEYS_ITERATOR; @@ -1284,7 +1309,8 @@ int codes_f_bufr_keys_iterator_next_(int* iterid) { } /*****************************************************************************/ -int codes_f_bufr_keys_iterator_get_name_(int* iterid, char* name, int len) { +int codes_f_bufr_keys_iterator_get_name_(int* iterid, char* name, int len) +{ size_t input_len = len; size_t lsize = len; char buf[1024] = {0,}; @@ -1306,7 +1332,8 @@ int codes_f_bufr_keys_iterator_get_name_(int* iterid, char* name, int len) { return 0; } /*****************************************************************************/ -int codes_f_bufr_keys_iterator_rewind_(int* kiter) { +int codes_f_bufr_keys_iterator_rewind_(int* kiter) +{ bufr_keys_iterator* i=get_bufr_keys_iterator(*kiter); if (!i) return GRIB_INVALID_KEYS_ITERATOR; @@ -1314,12 +1341,14 @@ int codes_f_bufr_keys_iterator_rewind_(int* kiter) { } /*****************************************************************************/ -int codes_f_bufr_keys_iterator_delete_(int* iterid) { +int codes_f_bufr_keys_iterator_delete_(int* iterid) +{ return clear_bufr_keys_iterator(*iterid); } /*****************************************************************************/ -int grib_f_new_from_message_(int* gid, void* buffer, size_t* bufsize) { +int grib_f_new_from_message_(int* gid, void* buffer, size_t* bufsize) +{ grib_handle *h = NULL; h = grib_handle_new_from_message_copy(0, buffer, *bufsize); if (h){ @@ -1331,12 +1360,14 @@ int grib_f_new_from_message_(int* gid, void* buffer, size_t* bufsize) { } /* See SUP-3893: Need to provide an 'int' version */ -int grib_f_new_from_message_int_(int* gid, int* buffer , size_t* bufsize) { +int grib_f_new_from_message_int_(int* gid, int* buffer , size_t* bufsize) +{ /* Call the version with void pointer */ return grib_f_new_from_message_(gid, (void*)buffer, bufsize); } /*****************************************************************************/ -int grib_f_new_from_message_copy_(int* gid, void* buffer, size_t* bufsize){ +int grib_f_new_from_message_copy_(int* gid, void* buffer, size_t* bufsize) +{ grib_handle *h = NULL; h = grib_handle_new_from_message_copy(0, buffer, *bufsize); if(h){ @@ -1348,7 +1379,8 @@ int grib_f_new_from_message_copy_(int* gid, void* buffer, size_t* bufsize){ } /*****************************************************************************/ -int grib_f_new_from_samples_(int* gid, char* name, int lname){ +int grib_f_new_from_samples_(int* gid, char* name, int lname) +{ char fname[1024]; grib_handle *h = grib_handle_new_from_samples(NULL,cast_char(fname,name,lname)); /* grib_context_set_debug(h->context,1);*/ @@ -1362,7 +1394,8 @@ int grib_f_new_from_samples_(int* gid, char* name, int lname){ } /*****************************************************************************/ -int codes_bufr_f_new_from_samples_(int* gid, char* name, int lname){ +int codes_bufr_f_new_from_samples_(int* gid, char* name, int lname) +{ char fname[1024]; grib_handle* h = codes_bufr_handle_new_from_samples(NULL,cast_char(fname,name,lname)); /* grib_context_set_debug(h->context,1);*/ @@ -1376,7 +1409,8 @@ int codes_bufr_f_new_from_samples_(int* gid, char* name, int lname){ } /*****************************************************************************/ -int grib_f_clone_(int* gidsrc,int* giddest){ +int grib_f_clone_(int* gidsrc,int* giddest) +{ grib_handle *src = get_handle(*gidsrc); grib_handle *dest = NULL; @@ -1409,7 +1443,8 @@ int grib_f_copy_key_(int* gidsrc, char* key, int* giddest, int len) } /*****************************************************************************/ -int grib_f_util_sections_copy_(int* gidfrom,int* gidto,int* what,int *gidout){ +int grib_f_util_sections_copy_(int* gidfrom,int* gidto,int* what,int *gidout) +{ int err=0; grib_handle *hfrom = get_handle(*gidfrom); grib_handle *hto = get_handle(*gidto); @@ -1425,7 +1460,8 @@ int grib_f_util_sections_copy_(int* gidfrom,int* gidto,int* what,int *gidout){ } /*****************************************************************************/ -int grib_f_copy_namespace_(int* gidsrc,char* name,int* giddest,int len){ +int grib_f_copy_namespace_(int* gidsrc,char* name,int* giddest,int len) +{ char buf[1024]={0,}; grib_handle *src = get_handle(*gidsrc); grib_handle *dest = get_handle(*giddest); @@ -1437,7 +1473,8 @@ int grib_f_copy_namespace_(int* gidsrc,char* name,int* giddest,int len){ } /*****************************************************************************/ -int any_f_scan_file_(int* fid, int* n) { +int any_f_scan_file_(int* fid, int* n) +{ int err = 0; off_t offset=0; void *data = NULL; @@ -1508,7 +1545,8 @@ int any_f_new_from_scanned_file_(int* fid, int* msgid, int* gid) } /*****************************************************************************/ -int any_f_load_all_from_file_(int* fid, int* n) { +int any_f_load_all_from_file_(int* fid, int* n) +{ int err = 0; off_t offset=0; void* data = NULL; @@ -1563,7 +1601,8 @@ int any_f_new_from_loaded_(int* msgid, int* gid) } /*****************************************************************************/ -int codes_f_clear_loaded_from_file_(void) { +int codes_f_clear_loaded_from_file_(void) +{ grib_context* c = grib_context_get_default(); /* grib_oarray_delete_content(c,binary_messages); */ grib_oarray_delete(c, binary_messages); @@ -1571,7 +1610,8 @@ int codes_f_clear_loaded_from_file_(void) { } /*****************************************************************************/ -int grib_f_count_in_file_(int* fid,int* n) { +int grib_f_count_in_file_(int* fid,int* n) +{ int err = 0; FILE* f = get_file(*fid); if (f) err = grib_count_in_file(0, f, n); @@ -1579,7 +1619,8 @@ int grib_f_count_in_file_(int* fid,int* n) { } /*****************************************************************************/ -int any_f_new_from_file_(int* fid, int* gid) { +int any_f_new_from_file_(int* fid, int* gid) +{ int err = 0; FILE* f = get_file(*fid); grib_handle* h = NULL; @@ -1600,7 +1641,8 @@ int any_f_new_from_file_(int* fid, int* gid) { } /*****************************************************************************/ -int bufr_f_new_from_file_(int* fid, int* gid){ +int bufr_f_new_from_file_(int* fid, int* gid) +{ int err = 0; FILE* f = get_file(*fid); @@ -1617,12 +1659,13 @@ int bufr_f_new_from_file_(int* fid, int* gid){ } } - *gid=-1; + *gid = -1; return GRIB_INVALID_FILE; } /*****************************************************************************/ -int grib_f_new_from_file_(int* fid, int* gid){ +int grib_f_new_from_file_(int* fid, int* gid) +{ int err = 0; FILE* f = get_file(*fid); @@ -1644,7 +1687,8 @@ int grib_f_new_from_file_(int* fid, int* gid){ } /*****************************************************************************/ -int grib_f_headers_only_new_from_file_(int* fid, int* gid){ +int grib_f_headers_only_new_from_file_(int* fid, int* gid) +{ int err = 0; FILE* f = get_file(*fid); grib_handle *h = NULL; @@ -1666,7 +1710,8 @@ int grib_f_headers_only_new_from_file_(int* fid, int* gid){ } /*****************************************************************************/ -int grib_f_new_from_index_(int* iid, int* gid) { +int grib_f_new_from_index_(int* iid, int* gid) +{ int err = 0; grib_index* i = get_index(*iid); grib_handle *h = NULL; @@ -1687,7 +1732,8 @@ int grib_f_new_from_index_(int* iid, int* gid) { } /*****************************************************************************/ -int grib_f_index_new_from_file_(char* file, char* keys, int* gid, int lfile, int lkeys) { +int grib_f_index_new_from_file_(char* file, char* keys, int* gid, int lfile, int lkeys) +{ int err = 0; char fname[1024] = {0,}; char knames[1024] = {0,}; @@ -1710,7 +1756,8 @@ int grib_f_index_new_from_file_(char* file, char* keys, int* gid, int lfile, int } /*****************************************************************************/ -int grib_f_index_add_file_(int* iid, char* file, int lfile) { +int grib_f_index_add_file_(int* iid, char* file, int lfile) +{ grib_index *i = get_index(*iid); int err = GRIB_SUCCESS; char buf[1024]; @@ -1724,7 +1771,8 @@ int grib_f_index_add_file_(int* iid, char* file, int lfile) { } /*****************************************************************************/ -int grib_f_index_read_(char* file, int* gid, int lfile) { +int grib_f_index_read_(char* file, int* gid, int lfile) +{ int err = 0; char fname[1024]={0,}; @@ -1746,7 +1794,8 @@ int grib_f_index_read_(char* file, int* gid, int lfile) { } /*****************************************************************************/ -int grib_f_index_write_(int* gid, char* file, int lfile) { +int grib_f_index_write_(int* gid, char* file, int lfile) +{ grib_index *i = get_index(*gid); int err = GRIB_SUCCESS; char buf[1024]; @@ -1760,7 +1809,8 @@ int grib_f_index_write_(int* gid, char* file, int lfile) { } /*****************************************************************************/ -int grib_f_index_release_(int* hid){ +int grib_f_index_release_(int* hid) +{ return clear_index(*hid); } @@ -1768,7 +1818,8 @@ int grib_f_index_release_(int* hid){ return clear_multi_handle(*hid); } */ -int grib_f_release_(int* hid){ +int grib_f_release_(int* hid) +{ return clear_handle(*hid); } @@ -1794,9 +1845,9 @@ static void do_the_dump(grib_handle* h) grib_dump_content(h,stdout, "wmo", dump_flags, NULL); } } -int grib_f_dump_(int* gid){ +int grib_f_dump_(int* gid) +{ grib_handle *h = get_handle(*gid); - if(!h) return GRIB_INVALID_GRIB; else @@ -1807,7 +1858,8 @@ int grib_f_dump_(int* gid){ /*****************************************************************************/ #ifdef USE_GRIB_PRINT -int grib_f_print_(int* gid, char* key, int len){ +int grib_f_print_(int* gid, char* key, int len) +{ grib_handle *h = get_handle(*gid); int err = GRIB_SUCCESS; grib_dumper* d = NULL; @@ -1824,7 +1876,8 @@ int grib_f_print_(int* gid, char* key, int len){ } #endif /*****************************************************************************/ -int grib_f_get_error_string_(int* err, char* buf, int len) { +int grib_f_get_error_string_(int* err, char* buf, int len) +{ const char* err_msg = grib_get_error_message(*err); const size_t erlen = strlen(err_msg); if( len < erlen) return GRIB_ARRAY_TOO_SMALL; @@ -1833,7 +1886,8 @@ int grib_f_get_error_string_(int* err, char* buf, int len) { } /*****************************************************************************/ -int grib_f_get_api_version_(int* apiVersion,int len) { +int grib_f_get_api_version_(int* apiVersion,int len) +{ *apiVersion = grib_get_api_version(); return GRIB_SUCCESS; } @@ -1856,7 +1910,8 @@ int grib_f_get_size_int_(int* gid, char* key, int* val, int len) } } -int grib_f_get_size_long_(int* gid, char* key, long* val, int len){ +int grib_f_get_size_long_(int* gid, char* key, long* val, int len) +{ grib_handle *h = get_handle(*gid); int err = GRIB_SUCCESS; char buf[1024]; @@ -1872,7 +1927,8 @@ int grib_f_get_size_long_(int* gid, char* key, long* val, int len){ } /*****************************************************************************/ -int grib_f_index_get_size_int_(int* gid, char* key, int* val, int len){ +int grib_f_index_get_size_int_(int* gid, char* key, int* val, int len) +{ grib_index *h = get_index(*gid); int err = GRIB_SUCCESS; char buf[1024]; @@ -1887,7 +1943,8 @@ int grib_f_index_get_size_int_(int* gid, char* key, int* val, int len){ } } -int grib_f_index_get_size_long_(int* gid, char* key, long* val, int len){ +int grib_f_index_get_size_long_(int* gid, char* key, long* val, int len) +{ grib_index *h = get_index(*gid); int err = GRIB_SUCCESS; char buf[1024]; @@ -1903,7 +1960,8 @@ int grib_f_index_get_size_long_(int* gid, char* key, long* val, int len){ } /*****************************************************************************/ -int grib_f_get_int_(int* gid, char* key, int* val, int len){ +int grib_f_get_int_(int* gid, char* key, int* val, int len) +{ grib_handle *h = get_handle(*gid); long long_val; int err = GRIB_SUCCESS; @@ -1915,7 +1973,8 @@ int grib_f_get_int_(int* gid, char* key, int* val, int len){ return err; } -int grib_f_get_long_(int* gid, char* key, long* val, int len){ +int grib_f_get_long_(int* gid, char* key, long* val, int len) +{ grib_handle *h = get_handle(*gid); int err = GRIB_SUCCESS; char buf[1024]; @@ -1926,7 +1985,8 @@ int grib_f_get_long_(int* gid, char* key, long* val, int len){ } /*****************************************************************************/ -int grib_f_get_native_type_(int* gid, char* key, int* val, int len){ +int grib_f_get_native_type_(int* gid, char* key, int* val, int len) +{ grib_handle *h = get_handle(*gid); int type_val = 0; int err = GRIB_SUCCESS; @@ -1939,8 +1999,8 @@ int grib_f_get_native_type_(int* gid, char* key, int* val, int len){ } /*****************************************************************************/ -int grib_f_get_int_array_(int* gid, char* key, int *val, int* size, int len){ - +int grib_f_get_int_array_(int* gid, char* key, int *val, int* size, int len) +{ grib_handle *h = get_handle(*gid); long* long_val = NULL; int err = GRIB_SUCCESS; @@ -1970,8 +2030,8 @@ int grib_f_get_int_array_(int* gid, char* key, int *val, int* size, int len){ return err; } /*****************************************************************************/ -int grib_f_get_long_array_(int* gid, char* key, long *val, int* size, int len){ - +int grib_f_get_long_array_(int* gid, char* key, long *val, int* size, int len) +{ grib_handle *h = get_handle(*gid); int err = GRIB_SUCCESS; char buf[1024]; @@ -1986,8 +2046,8 @@ int grib_f_get_long_array_(int* gid, char* key, long *val, int* size, int len){ } /*****************************************************************************/ -int grib_f_get_byte_array_(int* gid, char* key, unsigned char *val, int* size, int len, int lenv){ - +int grib_f_get_byte_array_(int* gid, char* key, unsigned char *val, int* size, int len, int lenv) +{ grib_handle *h = get_handle(*gid); int err = GRIB_SUCCESS; char buf[1024]; @@ -2002,8 +2062,8 @@ int grib_f_get_byte_array_(int* gid, char* key, unsigned char *val, int* size, i } /*****************************************************************************/ -int grib_f_index_get_string_(int* gid, char* key, char* val, int *eachsize,int* size, int len){ - +int grib_f_index_get_string_(int* gid, char* key, char* val, int *eachsize,int* size, int len) +{ grib_index *h = get_index(*gid); int err = GRIB_SUCCESS; int i; @@ -2043,8 +2103,8 @@ int grib_f_index_get_string_(int* gid, char* key, char* val, int *eachsize,int* } /*****************************************************************************/ -int grib_f_index_get_long_(int* gid, char* key, long *val, int* size, int len){ - +int grib_f_index_get_long_(int* gid, char* key, long *val, int* size, int len) +{ grib_index *h = get_index(*gid); int err = GRIB_SUCCESS; char buf[1024]; @@ -2057,14 +2117,13 @@ int grib_f_index_get_long_(int* gid, char* key, long *val, int* size, int len){ } /*****************************************************************************/ -int grib_f_index_get_int_(int* gid, char* key, int *val, int* size, int len){ - +int grib_f_index_get_int_(int* gid, char* key, int *val, int* size, int len) +{ grib_index *h = get_index(*gid); int err = GRIB_SUCCESS; char buf[1024]; - size_t lsize = *size; + size_t lsize = *size, i = 0; long* lval=0; - int i; if(!h) return GRIB_INVALID_GRIB; @@ -2080,8 +2139,8 @@ int grib_f_index_get_int_(int* gid, char* key, int *val, int* size, int len){ } /*****************************************************************************/ -int grib_f_index_get_real8_(int* gid, char* key, double *val, int* size, int len){ - +int grib_f_index_get_real8_(int* gid, char* key, double *val, int* size, int len) +{ grib_index *h = get_index(*gid); int err = GRIB_SUCCESS; char buf[1024]; @@ -2094,7 +2153,8 @@ int grib_f_index_get_real8_(int* gid, char* key, double *val, int* size, int len } /*****************************************************************************/ -int grib_f_set_int_array_(int* gid, char* key, int* val, int* size, int len){ +int grib_f_set_int_array_(int* gid, char* key, int* val, int* size, int len) +{ grib_handle *h = get_handle(*gid); int err = GRIB_SUCCESS; char buf[1024]; @@ -2125,7 +2185,8 @@ int grib_f_set_int_array_(int* gid, char* key, int* val, int* size, int len){ } /*****************************************************************************/ -int grib_f_set_long_array_(int* gid, char* key, long* val, int* size, int len){ +int grib_f_set_long_array_(int* gid, char* key, long* val, int* size, int len) +{ grib_handle *h = get_handle(*gid); char buf[1024]; size_t lsize = *size; @@ -2136,7 +2197,8 @@ int grib_f_set_long_array_(int* gid, char* key, long* val, int* size, int len){ } /*****************************************************************************/ -int grib_f_set_byte_array_(int* gid, char* key, unsigned char* val, int* size, int len, int lenv){ +int grib_f_set_byte_array_(int* gid, char* key, unsigned char* val, int* size, int len, int lenv) +{ grib_handle *h = get_handle(*gid); int err = GRIB_SUCCESS; char buf[1024]; @@ -2151,7 +2213,8 @@ int grib_f_set_byte_array_(int* gid, char* key, unsigned char* val, int* size, i } /*****************************************************************************/ -int grib_f_set_int_(int* gid, char* key, int* val, int len){ +int grib_f_set_int_(int* gid, char* key, int* val, int len) +{ grib_handle *h = get_handle(*gid); char buf[1024]; long long_val = *val; @@ -2159,7 +2222,8 @@ int grib_f_set_int_(int* gid, char* key, int* val, int len){ return grib_set_long(h, cast_char(buf,key,len), long_val); } -int grib_f_set_long_(int* gid, char* key, long* val, int len){ +int grib_f_set_long_(int* gid, char* key, long* val, int len) +{ grib_handle *h = get_handle(*gid); char buf[1024]; if(!h) return GRIB_INVALID_GRIB; @@ -2167,7 +2231,8 @@ int grib_f_set_long_(int* gid, char* key, long* val, int len){ } /*****************************************************************************/ -int grib_f_set_missing_(int* gid, char* key,int len){ +int grib_f_set_missing_(int* gid, char* key,int len) +{ grib_handle *h = get_handle(*gid); char buf[1024]; @@ -2176,7 +2241,8 @@ int grib_f_set_missing_(int* gid, char* key,int len){ return grib_set_missing(h, cast_char(buf,key,len)); } -int grib_f_is_missing_(int* gid, char* key,int* isMissing,int len){ +int grib_f_is_missing_(int* gid, char* key,int* isMissing,int len) +{ int err=0; grib_handle *h = get_handle(*gid); char buf[1024]; @@ -2187,7 +2253,8 @@ int grib_f_is_missing_(int* gid, char* key,int* isMissing,int len){ } /*****************************************************************************/ -int grib_f_is_defined_(int* gid, char* key,int* isDefined,int len){ +int grib_f_is_defined_(int* gid, char* key,int* isDefined,int len) +{ grib_handle *h = get_handle(*gid); char buf[1024]; if(!h) return GRIB_INVALID_GRIB; @@ -2197,8 +2264,8 @@ int grib_f_is_defined_(int* gid, char* key,int* isDefined,int len){ } /*****************************************************************************/ -int grib_f_set_real4_(int* gid, char* key, float* val, int len){ - +int grib_f_set_real4_(int* gid, char* key, float* val, int len) +{ grib_handle *h = get_handle(*gid); char buf[1024]; double val8 = *val; @@ -2207,8 +2274,8 @@ int grib_f_set_real4_(int* gid, char* key, float* val, int len){ return grib_set_double(h, cast_char(buf,key,len), val8); } -int grib_f_get_real4_element_(int* gid, char* key, int* index,float* val, int len){ - +int grib_f_get_real4_element_(int* gid, char* key, int* index,float* val, int len) +{ grib_handle *h = get_handle(*gid); int err = GRIB_SUCCESS; char buf[1024]; @@ -2221,8 +2288,8 @@ int grib_f_get_real4_element_(int* gid, char* key, int* index,float* val, int le return err; } -int grib_f_get_real4_elements_(int* gid, char* key,int* index, float *val,int* size, int len){ - +int grib_f_get_real4_elements_(int* gid, char* key,int* index, float *val,int* size, int len) +{ grib_handle *h = get_handle(*gid); int err = GRIB_SUCCESS; char buf[1024]; @@ -2249,8 +2316,8 @@ int grib_f_get_real4_elements_(int* gid, char* key,int* index, float *val,int* s return err; } -int grib_f_get_real4_(int* gid, char* key, float* val, int len){ - +int grib_f_get_real4_(int* gid, char* key, float* val, int len) +{ grib_handle *h = get_handle(*gid); int err = GRIB_SUCCESS; char buf[1024]; @@ -2400,21 +2467,21 @@ int grib_f_index_select_string_(int* gid, char* key, char* val, int len, int val int grib_f_index_select_int_(int* gid, char* key, int* val, int len) { grib_index *h = get_index(*gid); - long lval=*val; - char buf[1024]; + long lval = *val; + char buf[1024] = {0,}; - if(!h) return GRIB_INVALID_GRIB; - return grib_index_select_long(h, cast_char(buf,key,len), lval); + if (!h) return GRIB_INVALID_GRIB; + return grib_index_select_long(h, cast_char(buf, key, len), lval); } /*****************************************************************************/ int grib_f_index_select_long_(int* gid, char* key, long* val, int len) { grib_index *h = get_index(*gid); - char buf[1024]; + char buf[1024] = {0,}; - if(!h) return GRIB_INVALID_GRIB; - return grib_index_select_long(h, cast_char(buf,key,len), *val); + if (!h) return GRIB_INVALID_GRIB; + return grib_index_select_long(h, cast_char(buf, key, len), *val); } /*****************************************************************************/ @@ -2438,8 +2505,8 @@ int grib_f_get_real8_(int* gid, char* key, double* val, int len) } /*****************************************************************************/ -int grib_f_get_real8_element_(int* gid, char* key,int* index, double* val, int len){ - +int grib_f_get_real8_element_(int* gid, char* key,int* index, double* val, int len) +{ grib_handle *h = get_handle(*gid); char buf[1024]; @@ -2449,8 +2516,8 @@ int grib_f_get_real8_element_(int* gid, char* key,int* index, double* val, int l } /*****************************************************************************/ -int grib_f_get_real8_elements_(int* gid, char* key,int* index, double* val, int *size, int len){ - +int grib_f_get_real8_elements_(int* gid, char* key,int* index, double* val, int *size, int len) +{ grib_handle *h = get_handle(*gid); char buf[1024]; @@ -2489,10 +2556,9 @@ int grib_f_find_nearest_single_(int* gid,int* is_lsm, double* inlats,double* inlons, double* outlats,double* outlons, double* values,double* distances, - int* indexes) { - + int* indexes) +{ grib_handle *h = get_handle(*gid); - if(!h) return GRIB_INVALID_GRIB; return grib_nearest_find_multiple(h,*is_lsm, @@ -2505,10 +2571,9 @@ int grib_f_find_nearest_multiple_(int* gid,int* is_lsm, double* inlats,double* inlons, double* outlats,double* outlons, double* values,double* distances, - int* indexes, int* npoints) { - + int* indexes, int* npoints) +{ grib_handle *h = get_handle(*gid); - if(!h) return GRIB_INVALID_GRIB; return grib_nearest_find_multiple(h,*is_lsm, @@ -2517,8 +2582,8 @@ int grib_f_find_nearest_multiple_(int* gid,int* is_lsm, } /*****************************************************************************/ -int grib_f_get_real8_array_(int* gid, char* key, double*val, int* size, int len){ - +int grib_f_get_real8_array_(int* gid, char* key, double*val, int* size, int len) +{ grib_handle *h = get_handle(*gid); int err = GRIB_SUCCESS; char buf[1024]; @@ -2534,8 +2599,8 @@ int grib_f_get_real8_array_(int* gid, char* key, double*val, int* size, int len) } /*****************************************************************************/ -int grib_f_set_force_real8_array_(int* gid, char* key, double*val, int* size, int len){ - +int grib_f_set_force_real8_array_(int* gid, char* key, double*val, int* size, int len) +{ grib_handle *h = get_handle(*gid); char buf[1024]; size_t lsize = *size; @@ -2546,8 +2611,8 @@ int grib_f_set_force_real8_array_(int* gid, char* key, double*val, int* size, in } /*****************************************************************************/ -int grib_f_set_real8_array_(int* gid, char* key, double*val, int* size, int len){ - +int grib_f_set_real8_array_(int* gid, char* key, double*val, int* size, int len) +{ grib_handle *h = get_handle(*gid); char buf[1024]; size_t lsize = *size; @@ -2636,8 +2701,8 @@ int grib_f_set_string_array_(int* gid, char* key, char* val,int* nvals,int* slen } /*****************************************************************************/ -int grib_f_get_string_(int* gid, char* key, char* val,int len, int len2){ - +int grib_f_get_string_(int* gid, char* key, char* val,int len, int len2) +{ grib_handle *h = get_handle(*gid); int err = GRIB_SUCCESS; char buf[1024]; @@ -2664,8 +2729,8 @@ static int is_all_spaces(const char *s) } /*****************************************************************************/ -int grib_f_set_string_(int* gid, char* key, char* val, int len, int len2){ - +int grib_f_set_string_(int* gid, char* key, char* val, int len, int len2) +{ grib_handle *h = get_handle(*gid); char* val_str = NULL; @@ -2686,8 +2751,8 @@ int grib_f_set_string_(int* gid, char* key, char* val, int len, int len2){ } /*****************************************************************************/ -int grib_f_get_data_real4_(int* gid,float* lats, float* lons,float* values,size_t* size) { - +int grib_f_get_data_real4_(int* gid,float* lats, float* lons,float* values,size_t* size) +{ grib_handle *h = get_handle(*gid); int err = GRIB_SUCCESS; double *lat8=NULL,*lon8=NULL,*val8 = NULL; @@ -2717,14 +2782,15 @@ int grib_f_get_data_real4_(int* gid,float* lats, float* lons,float* values,size_ return err; } -int grib_f_get_data_real8_(int* gid,double* lats, double* lons,double* values,size_t* size) { +int grib_f_get_data_real8_(int* gid,double* lats, double* lons,double* values,size_t* size) +{ grib_handle *h = get_handle(*gid); return grib_get_data(h,lats,lons,values); - } /*****************************************************************************/ -int grib_f_get_message_size_(int* gid, size_t *len){ +int grib_f_get_message_size_(int* gid, size_t *len) +{ grib_handle *h = get_handle(*gid); if(!h) return GRIB_INVALID_GRIB; *len = h->buffer->ulength; @@ -2732,7 +2798,8 @@ int grib_f_get_message_size_(int* gid, size_t *len){ } /*****************************************************************************/ -int grib_f_copy_message_(int* gid, void* mess, size_t* len){ +int grib_f_copy_message_(int* gid, void* mess, size_t* len) +{ grib_handle *h = get_handle(*gid); if(!h) return GRIB_INVALID_GRIB; @@ -2749,7 +2816,8 @@ int grib_f_copy_message_(int* gid, void* mess, size_t* len){ } /*****************************************************************************/ -void grib_f_check_(int* err,char* call,char* str,int lencall,int lenstr){ +void grib_f_check_(int* err,char* call,char* str,int lencall,int lenstr) +{ char bufstr[1024]={0,}; char bufcall[1024]={0,}; grib_context* c=grib_context_get_default(); @@ -2764,7 +2832,8 @@ void grib_f_check_(int* err,char* call,char* str,int lencall,int lenstr){ } /*****************************************************************************/ -int grib_f_write_(int* gid, int* fid) { +int grib_f_write_(int* gid, int* fid) +{ grib_handle *h = get_handle(*gid); FILE* f = get_file(*fid); const void* mess = NULL; @@ -2783,7 +2852,8 @@ int grib_f_write_(int* gid, int* fid) { } /*****************************************************************************/ -int grib_f_multi_write_(int* gid, int* fid) { +int grib_f_multi_write_(int* gid, int* fid) +{ grib_multi_handle *h = get_multi_handle(*gid); FILE* f = get_file(*fid); @@ -2793,7 +2863,8 @@ int grib_f_multi_write_(int* gid, int* fid) { return grib_multi_handle_write(h,f); } -int grib_f_multi_append_(int* ingid, int* sec,int* mgid) { +int grib_f_multi_append_(int* ingid, int* sec,int* mgid) +{ grib_handle *h = get_handle(*ingid); grib_multi_handle *mh = get_multi_handle(*mgid); @@ -2808,18 +2879,21 @@ int grib_f_multi_append_(int* ingid, int* sec,int* mgid) { } /*****************************************************************************/ -int codes_f_bufr_multi_element_constant_arrays_on_() { +int codes_f_bufr_multi_element_constant_arrays_on_() +{ codes_bufr_multi_element_constant_arrays_on(NULL); return GRIB_SUCCESS; } -int codes_f_bufr_multi_element_constant_arrays_off_() { +int codes_f_bufr_multi_element_constant_arrays_off_() +{ codes_bufr_multi_element_constant_arrays_off(NULL); return GRIB_SUCCESS; } /*****************************************************************************/ -int grib_f_set_definitions_path_(char* path, int len){ +int grib_f_set_definitions_path_(char* path, int len) +{ grib_context* c = grib_context_get_default(); char buf[1024]; grib_context_set_definitions_path(c, cast_char(buf,path,len)); @@ -2827,7 +2901,8 @@ int grib_f_set_definitions_path_(char* path, int len){ } /*****************************************************************************/ -int grib_f_set_samples_path_(char* path, int len){ +int grib_f_set_samples_path_(char* path, int len) +{ grib_context* c = grib_context_get_default(); char buf[1024]; grib_context_set_samples_path(c, cast_char(buf,path,len)); @@ -2835,11 +2910,13 @@ int grib_f_set_samples_path_(char* path, int len){ } /*****************************************************************************/ -int grib_f_julian_to_datetime_(double* jd,long* year,long* month,long* day,long *hour,long *minute,long *second) { +int grib_f_julian_to_datetime_(double* jd,long* year,long* month,long* day,long *hour,long *minute,long *second) +{ return grib_julian_to_datetime(*jd,year,month,day,hour,minute,second); } /*****************************************************************************/ -int grib_f_datetime_to_julian_(long* year,long* month,long* day, long* hour,long* minute,long* second,double* jd) { +int grib_f_datetime_to_julian_(long* year,long* month,long* day, long* hour,long* minute,long* second,double* jd) +{ return grib_datetime_to_julian(*year,*month,*day,*hour,*minute,*second,jd); } From 5619ade9c28f8f9427f93829075b6e62b67cd0af Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 11 Jan 2024 13:40:31 +0000 Subject: [PATCH 24/34] Examples: Test long integer interface --- examples/F90/bufr_ecc-1019.f90 | 9 +++++---- examples/F90/grib_ecc-1316.f90 | 12 +++++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/examples/F90/bufr_ecc-1019.f90 b/examples/F90/bufr_ecc-1019.f90 index d595c624b..5974132e6 100644 --- a/examples/F90/bufr_ecc-1019.f90 +++ b/examples/F90/bufr_ecc-1019.f90 @@ -11,6 +11,7 @@ program operator_3_test implicit none integer :: iret, outfile, ibufr integer(kind=4), dimension(:), allocatable :: ivalues + integer(kind=8), dimension(:), allocatable :: lvalues character(len=100) :: outfile_name call getarg(1, outfile_name) @@ -21,10 +22,10 @@ program operator_3_test stop 1 endif - allocate(ivalues(1)) - ivalues=(/ -16383 /) - call codes_set(ibufr,'inputOverriddenReferenceValues',ivalues) - deallocate(ivalues) + allocate(lvalues(1)) + lvalues=(/ -16383 /) + call codes_set(ibufr,'inputOverriddenReferenceValues',lvalues) + deallocate(lvalues) allocate(ivalues(3)) ivalues=(/ 2,2,2 /) diff --git a/examples/F90/grib_ecc-1316.f90 b/examples/F90/grib_ecc-1316.f90 index b6f521ce5..913d49fde 100644 --- a/examples/F90/grib_ecc-1316.f90 +++ b/examples/F90/grib_ecc-1316.f90 @@ -12,6 +12,9 @@ program grib_ecc_1316 implicit none integer :: iret, ostep, olevel, onumber + ! Test both interfaces: 4 byte and 8 byte integers + integer(4) :: step_int = 96, level_int = 0, number_int = 0 + integer(8) :: step_long = 96, level_long = 0, number_long = 0 character(len=80) :: parameterName integer :: idx, igrib, count1 = 0 @@ -19,9 +22,12 @@ program grib_ecc_1316 call codes_index_create(idx, '../../data/tigge_cf_ecmwf.grib2', & 'parameterName,number,level,step') - call codes_index_select(idx, 'step', 96) - call codes_index_select(idx, 'level', 0) - call codes_index_select(idx, 'number', 0) + call codes_index_select(idx, 'step', step_int) + call codes_index_select(idx, 'level', level_int) + call codes_index_select(idx, 'number', number_int) + call codes_index_select(idx, 'step', step_long) + call codes_index_select(idx, 'level', level_long) + call codes_index_select(idx, 'number', number_long) call codes_index_select(idx, 'parameterName', 'Soil moisture') do while (.true.) From b3ae7cdef625e0ad4070703ea91459b7c98bdb62 Mon Sep 17 00:00:00 2001 From: Robert Osinski Date: Thu, 11 Jan 2024 13:42:03 +0000 Subject: [PATCH 25/34] correction of unit --- definitions/grib2/tables/local/ecmf/1/4.2.254.254.table | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/definitions/grib2/tables/local/ecmf/1/4.2.254.254.table b/definitions/grib2/tables/local/ecmf/1/4.2.254.254.table index b97ea25e4..170a12cab 100644 --- a/definitions/grib2/tables/local/ecmf/1/4.2.254.254.table +++ b/definitions/grib2/tables/local/ecmf/1/4.2.254.254.table @@ -1,6 +1,6 @@ # Code table 4.2 - discipline=254 category=254 for ECMWF 192 192 Covariance between 2-metre temperature and volumetric soil water layer 1 [K m**3 m**-3] -193 193 Covariance between 2-metre relative humidity and volumetric soil water layer 1 [K m**3 m**-3] +193 193 Covariance between 2-metre relative humidity and volumetric soil water layer 1 [% m**3 m**-3] 194 194 Covariance between surface soil moisture and volumetric soil water layer 1 [m**3 m**-3 m**3 m**-3] 195 195 Covariance between 2-metre temperature and volumetric soil water layer 2 [K m**3 m**-3] 196 196 Covariance between 2-metre relative humidity and volumetric soil water layer 2 [% m**3 m**-3] From e65ca5f98cc4ab500f90920237387b72228fa98a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 11 Jan 2024 16:16:37 +0000 Subject: [PATCH 26/34] Expressions/Actions: Unused functions --- src/action_class_assert.cc | 12 ++++++------ src/grib_expression_class_is_integer.cc | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/action_class_assert.cc b/src/action_class_assert.cc index 804dedda0..4261524fd 100644 --- a/src/action_class_assert.cc +++ b/src/action_class_assert.cc @@ -107,12 +107,12 @@ static int create_accessor(grib_section* p, grib_action* act, grib_loader* h) static void dump(grib_action* act, FILE* f, int lvl) { - int i = 0; - grib_action_assert* self = (grib_action_assert*)act; - for (i = 0; i < lvl; i++) - grib_context_print(act->context, f, " "); - grib_expression_print(act->context, self->expression, 0); - printf("\n"); + // int i = 0; + // grib_action_assert* self = (grib_action_assert*)act; + // for (i = 0; i < lvl; i++) + // grib_context_print(act->context, f, " "); + // grib_expression_print(act->context, self->expression, 0); + // printf("\n"); } static void destroy(grib_context* context, grib_action* act) diff --git a/src/grib_expression_class_is_integer.cc b/src/grib_expression_class_is_integer.cc index c42ae9f86..03554ece7 100644 --- a/src/grib_expression_class_is_integer.cc +++ b/src/grib_expression_class_is_integer.cc @@ -155,14 +155,14 @@ static string evaluate_string(grib_expression* g, grib_handle* h, char* buf, siz static void print(grib_context* c, grib_expression* g, grib_handle* f) { - grib_expression_is_integer* e = (grib_expression_is_integer*)g; - printf("access('%s", e->name); - if (f) { - long s = 0; - grib_get_long(f, e->name, &s); - printf("=%ld", s); - } - printf("')"); + // grib_expression_is_integer* e = (grib_expression_is_integer*)g; + // printf("access('%s", e->name); + // if (f) { + // long s = 0; + // grib_get_long(f, e->name, &s); + // printf("=%ld", s); + // } + // printf("')"); } static void destroy(grib_context* c, grib_expression* g) From c35fdc2471d6a6b1ad7666a7364f0310028e28ba Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 11 Jan 2024 16:56:33 +0000 Subject: [PATCH 27/34] Unused variables --- src/grib_accessor_class_bufr_data_array.cc | 8 ++++---- src/grib_accessor_class_g1bitmap.cc | 4 ++-- src/grib_accessor_class_g2bitmap.cc | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/grib_accessor_class_bufr_data_array.cc b/src/grib_accessor_class_bufr_data_array.cc index 9f745ba56..c1bff6ea6 100644 --- a/src/grib_accessor_class_bufr_data_array.cc +++ b/src/grib_accessor_class_bufr_data_array.cc @@ -2427,7 +2427,7 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset bufr_descriptor* descriptor; /*grib_section* sectionUp=0;*/ grib_section* groupSection = 0; - long groupNumber = 0; + // long groupNumber = 0; /*long indexOfGroupNumber=0;*/ int depth; int max_depth = -1; /* highest value of depth */ @@ -2481,7 +2481,7 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset self->tempStrings = self->numberOfSubsets? grib_sarray_new(c, self->numberOfSubsets, 500) : NULL; end = self->compressedData ? 1 : self->numberOfSubsets; - groupNumber = 1; + // groupNumber = 1; gaGroup = grib_accessor_factory(self->dataKeys, &creatorGroup, 0, NULL); //gaGroup->bufr_group_number = groupNumber; @@ -2525,7 +2525,7 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset self->unpackMode == CODES_BUFR_UNPACK_STRUCTURE) { const int sidx = descriptor->Y + significanceQualifierIndexArray[descriptor->X] * NUMBER_OF_QUALIFIERS_PER_CATEGORY; DEBUG_ASSERT(sidx > 0); - groupNumber++; + // groupNumber++; add_coord_flag = 1; if (significanceQualifierGroup[sidx]) { @@ -2569,7 +2569,7 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset else if (descriptor->code == 31031 && incrementBitmapIndex != 0) { /* bitmap */ bitmapIndex++; - groupNumber++; + // groupNumber++; incrementBitmapIndex = 0; if (bitmapIndex >= MAX_NUMBER_OF_BITMAPS) { //grib_context_log(c, GRIB_LOG_ERROR, "Bitmap error: bitmap index=%d, max num bitmaps=%d\n", bitmapIndex, MAX_NUMBER_OF_BITMAPS); diff --git a/src/grib_accessor_class_g1bitmap.cc b/src/grib_accessor_class_g1bitmap.cc index b624d4dbe..519638f6a 100644 --- a/src/grib_accessor_class_g1bitmap.cc +++ b/src/grib_accessor_class_g1bitmap.cc @@ -125,7 +125,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) size_t i; int err = 0; long pos = 0; - long bmaplen = 0; + //long bmaplen = 0; const int bit_padding = 16; double miss_values = 0; tlen = ((*len + bit_padding - 1) / bit_padding * bit_padding) / 8; @@ -141,7 +141,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) if (val[i] == miss_values) pos++; else { - bmaplen++; + //bmaplen++; grib_set_bit_on(buf, &pos); } } diff --git a/src/grib_accessor_class_g2bitmap.cc b/src/grib_accessor_class_g2bitmap.cc index 3d928e804..441ad70a6 100644 --- a/src/grib_accessor_class_g2bitmap.cc +++ b/src/grib_accessor_class_g2bitmap.cc @@ -134,7 +134,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) size_t i; int err = 0; long pos = 0; - long bmaplen = 0; + // long bmaplen = 0; double miss_values = 0; tlen = (*len + 7) / 8; @@ -149,7 +149,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) if (val[i] == miss_values) pos++; else { - bmaplen++; + // bmaplen++; grib_set_bit_on(buf, &pos); } } From 52f6530493e2d0ab3422d0fe1941e2e0dfc33993 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 11 Jan 2024 17:25:52 +0000 Subject: [PATCH 28/34] Testing: Avoid comparing floats as strings (SD-88343) --- tests/bufr_extract_headers.sh | 2 +- tests/grib_tigge_conversions1.sh | 11 +++++++---- tests/grib_tigge_conversions2.sh | 11 +++++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/bufr_extract_headers.sh b/tests/bufr_extract_headers.sh index ad6e2b534..32cd620ec 100755 --- a/tests/bufr_extract_headers.sh +++ b/tests/bufr_extract_headers.sh @@ -203,7 +203,7 @@ tropical_cyclone.bufr tros_31.bufr " -KEYS='localLongitude1,localLatitude1,localLongitude2,localLatitude2,localNumberOfObservations,satelliteID,restricted' +KEYS='typicalDate,localNumberOfObservations,satelliteID,restricted' for bf in ${bufr_files}; do input=${data_dir}/bufr/$bf $EXEC ${test_dir}/bufr_extract_headers $KEYS $input > $temp1 diff --git a/tests/grib_tigge_conversions1.sh b/tests/grib_tigge_conversions1.sh index fc7c75a33..0147738f8 100755 --- a/tests/grib_tigge_conversions1.sh +++ b/tests/grib_tigge_conversions1.sh @@ -31,18 +31,21 @@ fi # --- Do I want to exclude any file pattern from the comparison ? exclusion_pattern="tcw|ssr|str|skt|cap|ci|ttr|st|sm|sd|slhf|sshf" +# Some very small floating-point differences shown for these +blacklist="-b iDirectionIncrementInDegrees,jDirectionIncrementInDegrees" + for file in ${dir}/tigge_[a-e]*.grib; do exclude=`echo $file | awk " /$exclusion_pattern/ {print \"found\";} "` if [ -z "$exclude" ]; then rm -f ${temp1} ${temp2} # 2 to 1 conversion check - ${tools_dir}/grib_set -s editionNumber=1 ${file} ${temp1} 2> $REDIRECT > $REDIRECT - ${tools_dir}/grib_compare -P -c data:n,geography:n ${temp1} ${file} 2> $REDIRECT > $REDIRECT + ${tools_dir}/grib_set -s editionNumber=1 ${file} ${temp1} + ${tools_dir}/grib_compare $blacklist -P -c data:n,geography:n ${temp1} ${file} # 1 to 2 conversion check - ${tools_dir}/grib_set -s editionNumber=2 ${temp1} ${temp2} 2> $REDIRECT > $REDIRECT - ${tools_dir}/grib_compare -P -c shortName,data:n,geography:n ${temp2} ${file} 2> $REDIRECT > $REDIRECT + ${tools_dir}/grib_set -s editionNumber=2 ${temp1} ${temp2} + ${tools_dir}/grib_compare $blacklist -P -c shortName,data:n,geography:n ${temp2} ${file} fi done diff --git a/tests/grib_tigge_conversions2.sh b/tests/grib_tigge_conversions2.sh index 3d80771e6..73b7a5455 100755 --- a/tests/grib_tigge_conversions2.sh +++ b/tests/grib_tigge_conversions2.sh @@ -30,18 +30,21 @@ fi # --- Do I want to exclude any file pattern from the comparison ? exclusion_pattern="tcw|ssr|str|skt|cap|ci|ttr|st|sm|sd|slhf|sshf" +# Some very small floating-point differences shown for these +blacklist="-b iDirectionIncrementInDegrees,jDirectionIncrementInDegrees" + for file in ${dir}/tigge_[f-z]*.grib; do exclude=`echo $file | awk " /$exclusion_pattern/ {print \"found\";} "` if [ -z "$exclude" ]; then rm -f ${temp1} ${temp2} # 2 to 1 conversion check - ${tools_dir}/grib_set -s editionNumber=1 ${file} ${temp1} 2> $REDIRECT > $REDIRECT - ${tools_dir}/grib_compare -P -c data:n,geography:n ${temp1} ${file} 2> $REDIRECT > $REDIRECT + ${tools_dir}/grib_set -s editionNumber=1 ${file} ${temp1} + ${tools_dir}/grib_compare $blacklist -P -c data:n,geography:n ${temp1} ${file} # 1 to 2 conversion check - ${tools_dir}/grib_set -s editionNumber=2 ${temp1} ${temp2} 2> $REDIRECT > $REDIRECT - ${tools_dir}/grib_compare -P -c shortName,data:n,geography:n ${temp2} ${file} 2> $REDIRECT > $REDIRECT + ${tools_dir}/grib_set -s editionNumber=2 ${temp1} ${temp2} + ${tools_dir}/grib_compare $blacklist -P -c shortName,data:n,geography:n ${temp2} ${file} fi done From eb4bf8dea7f161621eb0ece14dd8eeed9fcaeaa3 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 11 Jan 2024 17:59:58 +0000 Subject: [PATCH 29/34] Compiler warnings: Unused variables --- ...data_g1second_order_general_extended_packing.cc | 5 +++-- src/grib_accessor_class_data_g2secondary_bitmap.cc | 4 ++-- src/grib_accessor_class_data_sh_packed.cc | 9 +++++---- src/grib_accessor_class_smart_table.cc | 7 ++++--- src/grib_handle.cc | 14 ++++++++------ tools/grib_get_data.cc | 3 --- tools/grib_to_netcdf.cc | 2 -- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/grib_accessor_class_data_g1second_order_general_extended_packing.cc b/src/grib_accessor_class_data_g1second_order_general_extended_packing.cc index e8dc5b1bb..4bc5a7900 100644 --- a/src/grib_accessor_class_data_g1second_order_general_extended_packing.cc +++ b/src/grib_accessor_class_data_g1second_order_general_extended_packing.cc @@ -359,7 +359,8 @@ static int unpack(grib_accessor* a, double* dvalues, float* fvalues, size_t* len double reference_value; long binary_scale_factor; long decimal_scale_factor; - long j, count = 0; + long j; + // long count = 0; long *groupWidths = NULL, *groupLengths = NULL; long orderOfSPD = 0; long* SPD = 0; @@ -456,7 +457,7 @@ static int unpack(grib_accessor* a, double* dvalues, float* fvalues, size_t* len &X[n]); for (j = 0; j < groupLengths[i]; j++) { X[n] += firstOrderValues[i]; - count++; + // count++; n++; } diff --git a/src/grib_accessor_class_data_g2secondary_bitmap.cc b/src/grib_accessor_class_data_g2secondary_bitmap.cc index 7511b78cf..cceb3d765 100644 --- a/src/grib_accessor_class_data_g2secondary_bitmap.cc +++ b/src/grib_accessor_class_data_g2secondary_bitmap.cc @@ -126,7 +126,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) long primary_len = 0, secondary_len = 0; double* primary_bitmap = NULL; double* secondary_bitmap = NULL; - long i = 0, j = 0, on = 0, k = 0, m = 0; + long i = 0, j = 0, k = 0, m = 0; double missing_value = 0, present_value = 0; long expand_by = 0; @@ -177,7 +177,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) primary_bitmap[k++] = present_value; for (j = 0; j < expand_by; j++) secondary_bitmap[m++] = val[i + j]; - on++; + //on++; } } diff --git a/src/grib_accessor_class_data_sh_packed.cc b/src/grib_accessor_class_data_sh_packed.cc index a02d60275..25687d262 100644 --- a/src/grib_accessor_class_data_sh_packed.cc +++ b/src/grib_accessor_class_data_sh_packed.cc @@ -204,7 +204,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) size_t i = 0; int ret = GRIB_SUCCESS; - long hcount = 0, lcount = 0, hpos = 0, lup = 0, mmax = 0, n_vals = 0; + // long lup = 0; + long hcount = 0, lcount = 0, hpos = 0, mmax = 0, n_vals = 0; double* scals = NULL; /* double *pscals=NULL; */ @@ -330,12 +331,12 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) i = 0; while (maxv > 0) { - lup = mmax; + // lup = mmax; if (sub_k >= 0) { for (hcount = 0; hcount < sub_k + 1; hcount++) { decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes)); decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes)); - lup++; + // lup++; } sub_k--; } @@ -352,7 +353,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) reference_value); if (mmax == 0) val[i - 1] = 0; - lup++; + // lup++; } maxv--; diff --git a/src/grib_accessor_class_smart_table.cc b/src/grib_accessor_class_smart_table.cc index 61b5d49e3..dd6cfcd41 100644 --- a/src/grib_accessor_class_smart_table.cc +++ b/src/grib_accessor_class_smart_table.cc @@ -284,7 +284,8 @@ static int grib_load_smart_table(grib_context* c, const char* filename, { char line[1024] = {0,}; FILE* f = NULL; - int lineNumber, numberOfColumns, code; + // int lineNumber; + int numberOfColumns, code; grib_context_log(c, GRIB_LOG_DEBUG, "Loading code table from %s", filename); @@ -313,14 +314,14 @@ static int grib_load_smart_table(grib_context* c, const char* filename, t->recomposed_name[2] = grib_context_strdup_persistent(c, recomposed_name); } - lineNumber = 0; + // lineNumber = 0; while (fgets(line, sizeof(line) - 1, f)) { char* s = line; char* p; line[strlen(line) - 1] = 0; - ++lineNumber; + // ++lineNumber; while (*s != '\0' && isspace(*s)) s++; diff --git a/src/grib_handle.cc b/src/grib_handle.cc index f476ab9f2..e2dd6ec7c 100644 --- a/src/grib_handle.cc +++ b/src/grib_handle.cc @@ -597,7 +597,8 @@ static grib_handle* grib_handle_new_multi(grib_context* c, unsigned char** data, long edition = 0; size_t seclen = 0; unsigned char* secbegin = 0; - int secnum = 0, seccount = 0; + int secnum = 0; + // int seccount = 0; int err = 0, i = 0; grib_multi_support* gm = NULL; @@ -631,9 +632,9 @@ static grib_handle* grib_handle_new_multi(grib_context* c, unsigned char** data, secbegin = gm->sections[gm->section_number]; seclen = gm->sections_length[gm->section_number]; secnum = gm->section_number; - seccount = 0; + // seccount = 0; while (grib2_get_next_section((unsigned char*)message, olen, &secbegin, &seclen, &secnum, &err)) { - seccount++; + // seccount++; /*printf(" - %d - section %d length=%d\n",(int)seccount,(int)secnum,(int)seclen);*/ gm->sections[secnum] = secbegin; @@ -716,7 +717,8 @@ static grib_handle* grib_handle_new_from_file_multi(grib_context* c, FILE* f, in long edition = 0; size_t seclen = 0; unsigned char* secbegin = 0; - int secnum = 0, seccount = 0; + int secnum = 0; + // int seccount = 0; int err = 0, i = 0; grib_multi_support* gm = NULL; off_t gts_header_offset = 0; @@ -784,9 +786,9 @@ static grib_handle* grib_handle_new_from_file_multi(grib_context* c, FILE* f, in secbegin = gm->sections[gm->section_number]; seclen = gm->sections_length[gm->section_number]; secnum = gm->section_number; - seccount = 0; + // seccount = 0; while (grib2_get_next_section((unsigned char*)data, olen, &secbegin, &seclen, &secnum, &err)) { - seccount++; + // seccount++; /*printf(" - %d - section %d length=%d\n",(int)seccount,(int)secnum,(int)seclen);*/ gm->sections[secnum] = secbegin; diff --git a/tools/grib_get_data.cc b/tools/grib_get_data.cc index 54185ac61..814664ef0 100644 --- a/tools/grib_get_data.cc +++ b/tools/grib_get_data.cc @@ -92,7 +92,6 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) long* bitmap = NULL; /* bitmap array */ size_t bmp_len = 0; double *data_values = 0, *lats = 0, *lons = 0; - int n = 0; size_t size = 0, num_bytes = 0; long hasMissingValues = 0; @@ -239,7 +238,6 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) if (print_keys) print_key_values(values, options->print_keys_count); fprintf(dump_file, "\n"); - n++; } } else if (skip_missing == 1) { @@ -259,7 +257,6 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) if (print_keys) print_key_values(values, options->print_keys_count); fprintf(dump_file, "\n"); - n++; } } } diff --git a/tools/grib_to_netcdf.cc b/tools/grib_to_netcdf.cc index b46145123..47c9e8335 100644 --- a/tools/grib_to_netcdf.cc +++ b/tools/grib_to_netcdf.cc @@ -1607,7 +1607,6 @@ static void cube_indexes( int i = 0; int index = 0; int n = 1; - int ok = 0; if (size < c) { grib_context_log(ctx, GRIB_LOG_ERROR, "Internal error in cube_indexes. size=%d < axis=%d", size, c); @@ -1649,7 +1648,6 @@ static void cube_indexes( if (h->compare ? h->compare[i](w, v) : (w == v)) { index += j * n; n *= dims; - ok++; ((hypercube*)h)->index_cache[i] = j; break; } From 94e804c71600c4e23e06520e01f62ab8bd4db67f Mon Sep 17 00:00:00 2001 From: Robert Osinski Date: Fri, 12 Jan 2024 10:57:01 +0000 Subject: [PATCH 30/34] renamed level in local ECMWF table --- definitions/grib2/localConcepts/ecmf/typeOfLevelConcept.def | 2 +- definitions/grib2/tables/local/ecmf/1/4.5.table | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/definitions/grib2/localConcepts/ecmf/typeOfLevelConcept.def b/definitions/grib2/localConcepts/ecmf/typeOfLevelConcept.def index 1f3b6d47b..3044148ff 100644 --- a/definitions/grib2/localConcepts/ecmf/typeOfLevelConcept.def +++ b/definitions/grib2/localConcepts/ecmf/typeOfLevelConcept.def @@ -1,2 +1,2 @@ # Concept typeOfLevel -'MarsSfcFromMultipleLevels' = {typeOfFirstFixedSurface=254;} +'abstractLevel' = {typeOfFirstFixedSurface=254;} diff --git a/definitions/grib2/tables/local/ecmf/1/4.5.table b/definitions/grib2/tables/local/ecmf/1/4.5.table index 64153aaee..573e9d12f 100644 --- a/definitions/grib2/tables/local/ecmf/1/4.5.table +++ b/definitions/grib2/tables/local/ecmf/1/4.5.table @@ -1,2 +1,2 @@ 173 173 Top surface of snow, over ice, on sea, lake or river -254 254 MARS levtype SFC originating from fields on multiple levels +254 254 Abstract level with no vertical localization or meaning From cd9a4b2f0a9fb951ed3edc09c4d89c6f060aa90a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 12 Jan 2024 11:11:27 +0000 Subject: [PATCH 31/34] ECC-1744: Rounding errors in 2 tests with intel LLVM-based compilers 2023.2 --- tests/bufr_extract_headers.sh | 10 +++------- tests/grib_tigge_conversions1.sh | 2 +- tests/grib_tigge_conversions2.sh | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/bufr_extract_headers.sh b/tests/bufr_extract_headers.sh index 32cd620ec..1b7961cb4 100755 --- a/tests/bufr_extract_headers.sh +++ b/tests/bufr_extract_headers.sh @@ -99,8 +99,8 @@ for bf in ${bufr_files}; do done -# BUFRs with localLatitude1, localLongitude2 etc -# ---------------------------------------------- +# BUFRs with specific keys to compare +# ------------------------------------ bufr_files=" aaen_55.bufr aben_55.bufr @@ -179,21 +179,16 @@ modw_87.bufr monw_87.bufr nomi_206.bufr nos1_208.bufr -nos2_208.bufr nos3_208.bufr nos4_208.bufr -nos5_208.bufr nos6_208.bufr -nos7_208.bufr nos8_208.bufr pgps_110.bufr -rada_250.bufr rado_250.bufr s4kn_165.bufr sb19_206.bufr sbu8_206.bufr smin_49.bufr -smis_49.bufr smiu_49.bufr smos_203.bufr sn4k_165.bufr @@ -203,6 +198,7 @@ tropical_cyclone.bufr tros_31.bufr " +# ECC-1744: Do not compare floating-point keys like localLatitude1, localLongitude2 KEYS='typicalDate,localNumberOfObservations,satelliteID,restricted' for bf in ${bufr_files}; do input=${data_dir}/bufr/$bf diff --git a/tests/grib_tigge_conversions1.sh b/tests/grib_tigge_conversions1.sh index 0147738f8..848798d9e 100755 --- a/tests/grib_tigge_conversions1.sh +++ b/tests/grib_tigge_conversions1.sh @@ -31,7 +31,7 @@ fi # --- Do I want to exclude any file pattern from the comparison ? exclusion_pattern="tcw|ssr|str|skt|cap|ci|ttr|st|sm|sd|slhf|sshf" -# Some very small floating-point differences shown for these +# ECC-1744: Some very small floating-point differences shown for these blacklist="-b iDirectionIncrementInDegrees,jDirectionIncrementInDegrees" for file in ${dir}/tigge_[a-e]*.grib; do diff --git a/tests/grib_tigge_conversions2.sh b/tests/grib_tigge_conversions2.sh index 73b7a5455..a07fbdcb2 100755 --- a/tests/grib_tigge_conversions2.sh +++ b/tests/grib_tigge_conversions2.sh @@ -30,7 +30,7 @@ fi # --- Do I want to exclude any file pattern from the comparison ? exclusion_pattern="tcw|ssr|str|skt|cap|ci|ttr|st|sm|sd|slhf|sshf" -# Some very small floating-point differences shown for these +# ECC-1744: Some very small floating-point differences shown for these blacklist="-b iDirectionIncrementInDegrees,jDirectionIncrementInDegrees" for file in ${dir}/tigge_[f-z]*.grib; do From a5406e2063a568d778888ca2bb5eb0ce687f7d61 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 12 Jan 2024 11:12:18 +0000 Subject: [PATCH 32/34] ECC-1743: GRIB2: new hydro and wave parameters --- definitions/grib2/cfVarName.def | 64 +++++++++++++++++++++++++++++++++ definitions/grib2/name.def | 64 +++++++++++++++++++++++++++++++++ definitions/grib2/paramId.def | 64 +++++++++++++++++++++++++++++++++ definitions/grib2/shortName.def | 64 +++++++++++++++++++++++++++++++++ definitions/grib2/units.def | 64 +++++++++++++++++++++++++++++++++ 5 files changed, 320 insertions(+) diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index 797e0ec9e..4fc68355c 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -958,6 +958,36 @@ parameterCategory = 0 ; parameterNumber = 52 ; } +#Envelope-maximum individual wave height +'envhmax' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 93 ; + } +#Time domain maximum individual crest height +'tdcmax' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 94 ; + } +#Time domain maximum individual wave height +'tdhmax' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 95 ; + } +#Space time maximum individual crest height +'stcmax' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 96 ; + } +#Space time maximum individual wave height +'sthmax' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 97 ; + } #Wave Spectral Skewness 'wss' = { discipline = 10 ; @@ -4454,6 +4484,40 @@ parameterCategory = 0 ; parameterNumber = 9 ; } +#Lake depth +'lakdph' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 15 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 162 ; + } +#River depth +'rivdph' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 16 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 162 ; + } +#River outflow of water +'rivout' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 17 ; + } +#Floodplain outflow of water +'fldout' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 18 ; + } +#Floodpath outflow of water +'pthflw' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 19 ; + } #Latitude 'lat' = { discipline = 0 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index 2ed74a3cd..a596d2950 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -958,6 +958,36 @@ parameterCategory = 0 ; parameterNumber = 52 ; } +#Envelope-maximum individual wave height +'Envelope-maximum individual wave height' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 93 ; + } +#Time domain maximum individual crest height +'Time domain maximum individual crest height' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 94 ; + } +#Time domain maximum individual wave height +'Time domain maximum individual wave height' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 95 ; + } +#Space time maximum individual crest height +'Space time maximum individual crest height' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 96 ; + } +#Space time maximum individual wave height +'Space time maximum individual wave height' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 97 ; + } #Wave Spectral Skewness 'Wave Spectral Skewness' = { discipline = 10 ; @@ -4454,6 +4484,40 @@ parameterCategory = 0 ; parameterNumber = 9 ; } +#Lake depth +'Lake depth' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 15 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 162 ; + } +#River depth +'River depth' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 16 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 162 ; + } +#River outflow of water +'River outflow of water' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 17 ; + } +#Floodplain outflow of water +'Floodplain outflow of water' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 18 ; + } +#Floodpath outflow of water +'Floodpath outflow of water' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 19 ; + } #Latitude 'Latitude' = { discipline = 0 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index baebb7f27..cd3ccc913 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -958,6 +958,36 @@ parameterCategory = 0 ; parameterNumber = 52 ; } +#Envelope-maximum individual wave height +'140130' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 93 ; + } +#Time domain maximum individual crest height +'140131' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 94 ; + } +#Time domain maximum individual wave height +'140132' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 95 ; + } +#Space time maximum individual crest height +'140133' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 96 ; + } +#Space time maximum individual wave height +'140134' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 97 ; + } #Wave Spectral Skewness '140207' = { discipline = 10 ; @@ -4454,6 +4484,40 @@ parameterCategory = 0 ; parameterNumber = 9 ; } +#Lake depth +'240030' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 15 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 162 ; + } +#River depth +'240031' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 16 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 162 ; + } +#River outflow of water +'240032' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 17 ; + } +#Floodplain outflow of water +'240033' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 18 ; + } +#Floodpath outflow of water +'240034' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 19 ; + } #Latitude '250001' = { discipline = 0 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 28070723b..e0a5039d9 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -958,6 +958,36 @@ parameterCategory = 0 ; parameterNumber = 52 ; } +#Envelope-maximum individual wave height +'envhmax' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 93 ; + } +#Time domain maximum individual crest height +'tdcmax' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 94 ; + } +#Time domain maximum individual wave height +'tdhmax' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 95 ; + } +#Space time maximum individual crest height +'stcmax' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 96 ; + } +#Space time maximum individual wave height +'sthmax' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 97 ; + } #Wave Spectral Skewness 'wss' = { discipline = 10 ; @@ -4454,6 +4484,40 @@ parameterCategory = 0 ; parameterNumber = 9 ; } +#Lake depth +'lakdph' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 15 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 162 ; + } +#River depth +'rivdph' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 16 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 162 ; + } +#River outflow of water +'rivout' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 17 ; + } +#Floodplain outflow of water +'fldout' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 18 ; + } +#Floodpath outflow of water +'pthflw' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 19 ; + } #Latitude 'lat' = { discipline = 0 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index cee71a951..2a197be6f 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -958,6 +958,36 @@ parameterCategory = 0 ; parameterNumber = 52 ; } +#Envelope-maximum individual wave height +'m' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 93 ; + } +#Time domain maximum individual crest height +'m' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 94 ; + } +#Time domain maximum individual wave height +'m' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 95 ; + } +#Space time maximum individual crest height +'m' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 96 ; + } +#Space time maximum individual wave height +'m' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 97 ; + } #Wave Spectral Skewness 'Numeric' = { discipline = 10 ; @@ -4454,6 +4484,40 @@ parameterCategory = 0 ; parameterNumber = 9 ; } +#Lake depth +'m' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 15 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 162 ; + } +#River depth +'m' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 16 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 162 ; + } +#River outflow of water +'m**3 s**-1' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 17 ; + } +#Floodplain outflow of water +'m**3 s**-1' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 18 ; + } +#Floodpath outflow of water +'m**3 s**-1' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 19 ; + } #Latitude 'Degree N' = { discipline = 0 ; From 27ef7b906223b712a5e935de747ec41fd289ed61 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 12 Jan 2024 13:38:57 +0000 Subject: [PATCH 33/34] Debugging: Output list of key/value pairs being set --- src/eccodes_prototypes.h | 2 +- src/grib_value.cc | 31 +++++++++++++++++++++++-------- tests/unit_tests.cc | 6 +++--- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index febe5573e..1a57e46ae 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -1187,7 +1187,7 @@ int grib_get_long_array(const grib_handle* h, const char* name, long* val, size_ int grib_get_values(grib_handle* h, grib_values* args, size_t count); 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); -void grib_print_values(const char* title, grib_values* values); +void grib_print_values(const char* title, grib_values* values, FILE* out); int grib_values_check(grib_handle* h, grib_values* values, int count); 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); diff --git a/src/grib_value.cc b/src/grib_value.cc index 2ac9cb3ce..9c0365789 100644 --- a/src/grib_value.cc +++ b/src/grib_value.cc @@ -131,6 +131,11 @@ int grib_set_long(grib_handle* h, const char* name, long val) return ret; } + + if (h->context->debug) { + fprintf(stderr, "ECCODES DEBUG grib_set_long %s=%ld (Key not found)\n", name, val); + } + return GRIB_NOT_FOUND; } @@ -476,6 +481,11 @@ int grib_set_string(grib_handle* h, const char* name, const char* val, size_t* l } return ret; } + + if (h->context->debug) { + fprintf(stderr, "ECCODES DEBUG grib_set_string %s=|%s| (Key not found)\n", name, val); + } + return GRIB_NOT_FOUND; } @@ -1769,6 +1779,12 @@ int grib_set_values(grib_handle* h, grib_values* args, size_t count) for (i = 0; i < count; i++) args[i].error = GRIB_NOT_FOUND; + if (h->context->debug) { + for (i = 0; i < count; i++) { + grib_print_values("ECCODES DEBUG set key/value pairs", &args[i], stderr); + } + } + while (more) { more = 0; for (i = 0; i < count; i++) { @@ -1839,23 +1855,22 @@ int grib_get_nearest_smaller_value(grib_handle* h, const char* name, return grib_nearest_smaller_value(act, val, nearest); } -void grib_print_values(const char* title, grib_values* values) +void grib_print_values(const char* title, grib_values* values, FILE* out) { - while(values) { - printf("%s: %s%s", title, values->name, (values->equal?"=":"!=")); + if (values) { + fprintf(out, "%s: %s=", title, values->name); switch (values->type) { case GRIB_TYPE_LONG: - printf("%ld", values->long_value); + fprintf(out, "%ld", values->long_value); break; case GRIB_TYPE_DOUBLE: - printf("%g", values->double_value); + fprintf(out, "%g", values->double_value); break; case GRIB_TYPE_STRING: - printf("%s", values->string_value); + fprintf(out, "%s", values->string_value); break; } - printf(" (type=%s)\n", grib_get_type_name(values->type)); - values = values->next; + fprintf(out, " (type=%s)\n", grib_get_type_name(values->type)); } } diff --git a/tests/unit_tests.cc b/tests/unit_tests.cc index 0fb193e41..695de023c 100644 --- a/tests/unit_tests.cc +++ b/tests/unit_tests.cc @@ -454,7 +454,7 @@ static void test_parse_keyval_string() values_required, GRIB_TYPE_UNDEFINED, values1, &count); Assert( !err ); Assert( count == 2 ); - grib_print_values("print values test: values1", values1); + grib_print_values("print values test: values1", values1, stdout); Assert( strcmp(values1[0].name, "key1")==0 ); Assert( strcmp(values1[0].string_value, "value1")==0 ); @@ -474,7 +474,7 @@ static void test_parse_keyval_string() values_required, GRIB_TYPE_LONG, values2, &count); Assert( !err ); Assert( count == 1 ); - grib_print_values("print values test: values2", values2); + grib_print_values("print values test: values2", values2, stdout); Assert( strcmp(values2[0].name, "x")==0 ); Assert( values2[0].long_value == 14 ); Assert( values2[0].equal == 1 ); @@ -485,7 +485,7 @@ static void test_parse_keyval_string() values_required, GRIB_TYPE_DOUBLE, values3, &count); Assert( !err ); Assert( count == 1 ); - grib_print_values("print values test: values3", values3); + grib_print_values("print values test: values3", values3, stdout); Assert( strcmp(values3[0].name, "mars.level")==0 ); free( (void*)values3[0].name ); } From 080f08363d03f4c3ec3ed5cf7931fd693c464bf5 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 12 Jan 2024 13:43:25 +0000 Subject: [PATCH 34/34] ECC-1745: GRIB2: Local ECMWF parameters for covariances --- .../grib2/localConcepts/ecmf/cfVarName.def | 168 ++++++++++++++++++ definitions/grib2/localConcepts/ecmf/name.def | 168 ++++++++++++++++++ .../grib2/localConcepts/ecmf/paramId.def | 168 ++++++++++++++++++ .../grib2/localConcepts/ecmf/shortName.def | 168 ++++++++++++++++++ .../grib2/localConcepts/ecmf/units.def | 168 ++++++++++++++++++ 5 files changed, 840 insertions(+) diff --git a/definitions/grib2/localConcepts/ecmf/cfVarName.def b/definitions/grib2/localConcepts/ecmf/cfVarName.def index 3f3a05316..9e62226b7 100644 --- a/definitions/grib2/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib2/localConcepts/ecmf/cfVarName.def @@ -13825,6 +13825,174 @@ typeOfSecondFixedSurface = 255 ; typeOfStatisticalProcessing = 1 ; } +#Covariance between 2-metre temperature and volumetric soil water layer 1 +'covar_t2m_swvl1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and volumetric soil water layer 1 +'covar_rh2m_swvl1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 193 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between surface soil moisture and volumetric soil water layer 1 +'covar_ssm_swvl1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 194 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and volumetric soil water layer 2 +'covar_t2m_swvl2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and volumetric soil water layer 2 +'covar_rh2m_swvl2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between surface soil moisture and volumetric soil water layer 2 +'covar_ssm_swvl2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 197 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and volumetric soil water layer 3 +'covar_t2m_swvl3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 198 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and volumetric soil water layer 3 +'covar_rh2m_swvl3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 199 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between surface soil moisture and volumetric soil water layer 3 +'covar_ssm_swvl3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 200 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and soil temperature layer 1 +'covar_t2m_stl1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 201 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and soil temperature layer 1 +'covar_rh2m_stl1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 202 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and soil temperature layer 2 +'covar_t2m_stl2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 203 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and soil temperature layer 2 +'covar_rh2m_stl2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 204 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and soil temperature layer 3 +'covar_t2m_stl3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 205 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and soil temperature layer 3 +'covar_rh2m_stl3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 206 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and temperature of snow layer 1 +'covar_t2m_tsn1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 207 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and temperature of snow layer 1 +'covar_rh2m_tsn1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 208 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and temperature of snow layer 2 +'covar_t2m_tsn2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 209 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and temperature of snow layer 2 +'covar_rh2m_tsn2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 210 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and temperature of snow layer 3 +'covar_t2m_tsn3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 211 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and temperature of snow layer 3 +'covar_rh2m_tsn3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 212 ; + typeOfFirstFixedSurface = 254 ; + } #Surface roughness length for heat 'srlh' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/ecmf/name.def b/definitions/grib2/localConcepts/ecmf/name.def index a0081e32f..30466e4c5 100644 --- a/definitions/grib2/localConcepts/ecmf/name.def +++ b/definitions/grib2/localConcepts/ecmf/name.def @@ -13825,6 +13825,174 @@ typeOfSecondFixedSurface = 255 ; typeOfStatisticalProcessing = 1 ; } +#Covariance between 2-metre temperature and volumetric soil water layer 1 +'Covariance between 2-metre temperature and volumetric soil water layer 1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and volumetric soil water layer 1 +'Covariance between 2-metre relative humidity and volumetric soil water layer 1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 193 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between surface soil moisture and volumetric soil water layer 1 +'Covariance between surface soil moisture and volumetric soil water layer 1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 194 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and volumetric soil water layer 2 +'Covariance between 2-metre temperature and volumetric soil water layer 2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and volumetric soil water layer 2 +'Covariance between 2-metre relative humidity and volumetric soil water layer 2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between surface soil moisture and volumetric soil water layer 2 +'Covariance between surface soil moisture and volumetric soil water layer 2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 197 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and volumetric soil water layer 3 +'Covariance between 2-metre temperature and volumetric soil water layer 3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 198 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and volumetric soil water layer 3 +'Covariance between 2-metre relative humidity and volumetric soil water layer 3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 199 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between surface soil moisture and volumetric soil water layer 3 +'Covariance between surface soil moisture and volumetric soil water layer 3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 200 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and soil temperature layer 1 +'Covariance between 2-metre temperature and soil temperature layer 1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 201 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and soil temperature layer 1 +'Covariance between 2-metre relative humidity and soil temperature layer 1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 202 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and soil temperature layer 2 +'Covariance between 2-metre temperature and soil temperature layer 2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 203 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and soil temperature layer 2 +'Covariance between 2-metre relative humidity and soil temperature layer 2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 204 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and soil temperature layer 3 +'Covariance between 2-metre temperature and soil temperature layer 3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 205 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and soil temperature layer 3 +'Covariance between 2-metre relative humidity and soil temperature layer 3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 206 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and temperature of snow layer 1 +'Covariance between 2-metre temperature and temperature of snow layer 1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 207 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and temperature of snow layer 1 +'Covariance between 2-metre relative humidity and temperature of snow layer 1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 208 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and temperature of snow layer 2 +'Covariance between 2-metre temperature and temperature of snow layer 2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 209 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and temperature of snow layer 2 +'Covariance between 2-metre relative humidity and temperature of snow layer 2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 210 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and temperature of snow layer 3 +'Covariance between 2-metre temperature and temperature of snow layer 3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 211 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and temperature of snow layer 3 +'Covariance between 2-metre relative humidity and temperature of snow layer 3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 212 ; + typeOfFirstFixedSurface = 254 ; + } #Surface roughness length for heat 'Surface roughness length for heat' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/ecmf/paramId.def b/definitions/grib2/localConcepts/ecmf/paramId.def index 8b6604847..6ba1493c0 100644 --- a/definitions/grib2/localConcepts/ecmf/paramId.def +++ b/definitions/grib2/localConcepts/ecmf/paramId.def @@ -13825,6 +13825,174 @@ typeOfSecondFixedSurface = 255 ; typeOfStatisticalProcessing = 1 ; } +#Covariance between 2-metre temperature and volumetric soil water layer 1 +'254001' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and volumetric soil water layer 1 +'254002' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 193 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between surface soil moisture and volumetric soil water layer 1 +'254003' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 194 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and volumetric soil water layer 2 +'254004' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and volumetric soil water layer 2 +'254005' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between surface soil moisture and volumetric soil water layer 2 +'254006' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 197 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and volumetric soil water layer 3 +'254007' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 198 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and volumetric soil water layer 3 +'254008' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 199 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between surface soil moisture and volumetric soil water layer 3 +'254009' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 200 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and soil temperature layer 1 +'254010' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 201 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and soil temperature layer 1 +'254011' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 202 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and soil temperature layer 2 +'254012' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 203 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and soil temperature layer 2 +'254013' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 204 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and soil temperature layer 3 +'254014' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 205 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and soil temperature layer 3 +'254015' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 206 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and temperature of snow layer 1 +'254016' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 207 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and temperature of snow layer 1 +'254017' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 208 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and temperature of snow layer 2 +'254018' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 209 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and temperature of snow layer 2 +'254019' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 210 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and temperature of snow layer 3 +'254020' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 211 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and temperature of snow layer 3 +'254021' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 212 ; + typeOfFirstFixedSurface = 254 ; + } #Surface roughness length for heat '260651' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/ecmf/shortName.def b/definitions/grib2/localConcepts/ecmf/shortName.def index 0a3476f15..1ec2bca2e 100644 --- a/definitions/grib2/localConcepts/ecmf/shortName.def +++ b/definitions/grib2/localConcepts/ecmf/shortName.def @@ -13825,6 +13825,174 @@ typeOfSecondFixedSurface = 255 ; typeOfStatisticalProcessing = 1 ; } +#Covariance between 2-metre temperature and volumetric soil water layer 1 +'covar_t2m_swvl1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and volumetric soil water layer 1 +'covar_rh2m_swvl1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 193 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between surface soil moisture and volumetric soil water layer 1 +'covar_ssm_swvl1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 194 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and volumetric soil water layer 2 +'covar_t2m_swvl2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and volumetric soil water layer 2 +'covar_rh2m_swvl2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between surface soil moisture and volumetric soil water layer 2 +'covar_ssm_swvl2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 197 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and volumetric soil water layer 3 +'covar_t2m_swvl3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 198 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and volumetric soil water layer 3 +'covar_rh2m_swvl3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 199 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between surface soil moisture and volumetric soil water layer 3 +'covar_ssm_swvl3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 200 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and soil temperature layer 1 +'covar_t2m_stl1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 201 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and soil temperature layer 1 +'covar_rh2m_stl1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 202 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and soil temperature layer 2 +'covar_t2m_stl2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 203 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and soil temperature layer 2 +'covar_rh2m_stl2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 204 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and soil temperature layer 3 +'covar_t2m_stl3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 205 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and soil temperature layer 3 +'covar_rh2m_stl3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 206 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and temperature of snow layer 1 +'covar_t2m_tsn1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 207 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and temperature of snow layer 1 +'covar_rh2m_tsn1' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 208 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and temperature of snow layer 2 +'covar_t2m_tsn2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 209 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and temperature of snow layer 2 +'covar_rh2m_tsn2' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 210 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and temperature of snow layer 3 +'covar_t2m_tsn3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 211 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and temperature of snow layer 3 +'covar_rh2m_tsn3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 212 ; + typeOfFirstFixedSurface = 254 ; + } #Surface roughness length for heat 'srlh' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/ecmf/units.def b/definitions/grib2/localConcepts/ecmf/units.def index f1a5418f3..36b703fe7 100644 --- a/definitions/grib2/localConcepts/ecmf/units.def +++ b/definitions/grib2/localConcepts/ecmf/units.def @@ -13825,6 +13825,174 @@ typeOfSecondFixedSurface = 255 ; typeOfStatisticalProcessing = 1 ; } +#Covariance between 2-metre temperature and volumetric soil water layer 1 +'K m**3 m**-3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and volumetric soil water layer 1 +'% m**3 m**-3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 193 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between surface soil moisture and volumetric soil water layer 1 +'m**3 m**-3 m**3 m**-3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 194 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and volumetric soil water layer 2 +'K m**3 m**-3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and volumetric soil water layer 2 +'% m**3 m**-3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between surface soil moisture and volumetric soil water layer 2 +'m**3 m**-3 m**3 m**-3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 197 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and volumetric soil water layer 3 +'K m**3 m**-3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 198 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and volumetric soil water layer 3 +'% m**3 m**-3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 199 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between surface soil moisture and volumetric soil water layer 3 +'m**3 m**-3 m**3 m**-3' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 200 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and soil temperature layer 1 +'K K' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 201 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and soil temperature layer 1 +'% K' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 202 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and soil temperature layer 2 +'K K' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 203 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and soil temperature layer 2 +'% K' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 204 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and soil temperature layer 3 +'K K' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 205 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and soil temperature layer 3 +'% K' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 206 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and temperature of snow layer 1 +'K K' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 207 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and temperature of snow layer 1 +'% K' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 208 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and temperature of snow layer 2 +'K K' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 209 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and temperature of snow layer 2 +'% K' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 210 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre temperature and temperature of snow layer 3 +'K K' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 211 ; + typeOfFirstFixedSurface = 254 ; + } +#Covariance between 2-metre relative humidity and temperature of snow layer 3 +'% K' = { + localTablesVersion = 1 ; + discipline = 254 ; + parameterCategory = 254 ; + parameterNumber = 212 ; + typeOfFirstFixedSurface = 254 ; + } #Surface roughness length for heat 'm' = { localTablesVersion = 1 ;