From 6d9d11cab0e408af056dccb81c35c9c8098e0bd1 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 27 Dec 2022 12:36:19 +0000 Subject: [PATCH 1/3] Tools: Comments --- tools/grib_compare.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/grib_compare.c b/tools/grib_compare.c index b2c18e8fd..99145169a 100644 --- a/tools/grib_compare.c +++ b/tools/grib_compare.c @@ -260,6 +260,9 @@ int grib_tool_init(grib_runtime_options* options) const char* filename[1]; filename[0] = options->infile_extra->name; /* First file */ options->random = 1; + /* Setting 'orderby' will cause the second file to also be read as a sorted fieldset + * See file: grib_tool.c function: grib_tool + */ options->orderby = strdup(orderby); options->idx = grib_fieldset_new_from_files(context, filename, nfiles, 0, 0, 0, orderby, &ret); @@ -1145,6 +1148,14 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option } */ } +#if 0 + { + long of1,of2; /* Debugging: print offset of each handle */ + grib_get_long(h1, "offset", &of1); grib_get_long(h2, "offset", &of2); + printf("of1=%lu of2=%lu\n",of1,of2); + } +#endif + if (headerMode) { const void *msg1 = NULL, *msg2 = NULL; size_t size1 = 0, size2 = 0; From d5047d3f465f37431a8b0015fbea6e7197bae4f5 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 27 Dec 2022 13:19:33 +0000 Subject: [PATCH 2/3] Tools: Error messages --- tools/bufr_compare.c | 3 +-- tools/grib_compare.c | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/bufr_compare.c b/tools/bufr_compare.c index e9b38785b..d1c4f6074 100644 --- a/tools/bufr_compare.c +++ b/tools/bufr_compare.c @@ -1279,9 +1279,8 @@ static int compare_all_dump_keys(grib_handle* handle1, grib_handle* handle2, gri } } iter = grib_keys_iterator_new(handle1, 0, NULL); - if (!iter) { - grib_context_log(context, GRIB_LOG_ERROR, "unable to create keys iterator"); + grib_context_log(context, GRIB_LOG_ERROR, "unable to create the BUFR keys iterator"); exit(1); } diff --git a/tools/grib_compare.c b/tools/grib_compare.c index 99145169a..92ebea613 100644 --- a/tools/grib_compare.c +++ b/tools/grib_compare.c @@ -1136,6 +1136,7 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option int i = 0; const char* name = NULL; grib_keys_iterator* iter = NULL; + grib_context* context = handle1->context; /* mask only if no -c option or headerMode (-H)*/ if (blocklist && (!listFromCommandLine || headerMode)) { @@ -1172,7 +1173,7 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option iter = grib_keys_iterator_new(h11, GRIB_KEYS_ITERATOR_SKIP_COMPUTED, NULL); if (!iter) { - printf("ERROR: unable to get keys iterator\n"); + grib_context_log(context, GRIB_LOG_ERROR, "unable to create the GRIB keys iterator"); exit(1); } From d2353984287803aa2e1b1b8c237a688627c7949a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 27 Dec 2022 13:19:50 +0000 Subject: [PATCH 3/3] ECC-1498: BUFR subset extraction by area: Memory leaks --- src/grib_accessor_class_bufr_data_array.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/grib_accessor_class_bufr_data_array.c b/src/grib_accessor_class_bufr_data_array.c index 4b51c9bf2..3ec37cf78 100644 --- a/src/grib_accessor_class_bufr_data_array.c +++ b/src/grib_accessor_class_bufr_data_array.c @@ -3380,6 +3380,9 @@ static int process_elements(grib_accessor* a, int flag, long onlySubset, long st } } + if (subsetList) + grib_context_free(c, subsetList);/* ECC-1498 */ + return err; }