From 044cc0d26c03481d28a8ee1418e096fb32dff9d5 Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 4 Sep 2024 15:09:09 +0100 Subject: [PATCH 01/22] Tools: codes_config build type --- tools/codes_config.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/codes_config.in b/tools/codes_config.in index cd5d9c726..53fe1f8bf 100755 --- a/tools/codes_config.in +++ b/tools/codes_config.in @@ -33,7 +33,7 @@ print_feature() fi } - +build_type="@CMAKE_BUILD_TYPE@" info() { echo "ecCodes version (${ECCODES_VERSION_STR}), git-sha1 ${ECCODES_GIT_SHA1}" @@ -45,7 +45,12 @@ info() echo " processor : @CMAKE_SYSTEM_PROCESSOR@" echo " sources : @PROJECT_SOURCE_DIR@" echo " c++ compiler : @CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@" - echo " flags : @CMAKE_CXX_FLAGS@" + # Add the most common build type + if [ $build_type = "RelWithDebInfo" ]; then + echo " flags : @CMAKE_CXX_FLAGS_RELWITHDEBINFO@" + else + echo " flags : @CMAKE_CXX_FLAGS@" + fi # echo " fortran compiler: @CMAKE_Fortran_COMPILER_ID@ @CMAKE_Fortran_COMPILER_VERSION@" # echo " flags : @ECCODES_Fortran_FLAGS@" echo "" From eef74b1e28ab3d65514f7246b647df8742e20302 Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 4 Sep 2024 15:28:35 +0100 Subject: [PATCH 02/22] Tools: codes_config installation --- tools/CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 923848fe8..e2016a726 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -96,8 +96,13 @@ else() endif() ######################################## -configure_file( codes_config.in codes_config @ONLY ) -install( FILES ${CMAKE_CURRENT_BINARY_DIR}/codes_config +configure_file( codes_config.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/codes_config @ONLY ) +file(COPY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/codes_config + DESTINATION ${CMAKE_BINARY_DIR}/bin + FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ + GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + +install( FILES ${CMAKE_BINARY_DIR}/bin/codes_config DESTINATION ${INSTALL_BIN_DIR} PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ From 2db38ede1cda7f33113b134ae53c96dd58f589bf Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 5 Sep 2024 11:37:47 +0100 Subject: [PATCH 03/22] Const correctness --- src/action_class_close.cc | 2 +- src/eccodes_prototypes.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/action_class_close.cc b/src/action_class_close.cc index 00108c607..8b8db96a0 100644 --- a/src/action_class_close.cc +++ b/src/action_class_close.cc @@ -65,7 +65,7 @@ static void init_class(grib_action_class* c) } /* END_CLASS_IMP */ -grib_action* grib_action_create_close(grib_context* context, char* filename) +grib_action* grib_action_create_close(grib_context* context, const char* filename) { char buf[1024]; grib_action_close* a; diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index d65c8a908..bde1fc807 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -86,7 +86,7 @@ grib_action* grib_action_create_write(grib_context* context, const char* name, i grib_action* grib_action_create_print(grib_context* context, const char* name, char* outname); /* action_class_close.cc */ -grib_action* grib_action_create_close(grib_context* context, char* filename); +grib_action* grib_action_create_close(grib_context* context, const char* filename); /* action_class_variable.cc */ grib_action* grib_action_create_variable(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); From 36dd16810f85c50739a24b6b3c95aa9e33a69e4d Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 5 Sep 2024 14:46:32 +0100 Subject: [PATCH 04/22] Tools: codes_config thread options --- tools/codes_config.in | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/codes_config.in b/tools/codes_config.in index 53fe1f8bf..819f673e6 100755 --- a/tools/codes_config.in +++ b/tools/codes_config.in @@ -55,11 +55,13 @@ info() # echo " flags : @ECCODES_Fortran_FLAGS@" echo "" echo "Features:" - echo " AEC : $(print_feature @HAVE_AEC@)" - echo " MEMFS : $(print_feature @HAVE_MEMFS@)" - echo " NETCDF : $(print_feature @HAVE_NETCDF@)" - echo " JPG : $(print_feature @HAVE_JPEG@)" - echo " PNG : $(print_feature @HAVE_PNG@)" + echo " AEC : $(print_feature @HAVE_AEC@)" + echo " MEMFS : $(print_feature @HAVE_MEMFS@)" + echo " ECCODES_THREADS : $(print_feature @GRIB_PTHREADS@)" + echo " ECCODES_OMP_THREADS : $(print_feature @GRIB_OMP_THREADS@)" + echo " JPG : $(print_feature @HAVE_JPEG@)" + echo " PNG : $(print_feature @HAVE_PNG@)" + echo " NETCDF : $(print_feature @HAVE_NETCDF@)" echo "" # echo "Dependencies: " # if [ -n "@ECCODES_HAVE_ECKIT@" ]; then From 23651d524f9d6a3ca56443da579fcaeba27ade7e Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 5 Sep 2024 16:41:05 +0100 Subject: [PATCH 05/22] Dead code removal --- src/grib_geography.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/grib_geography.cc b/src/grib_geography.cc index 844a38abb..c864fec9e 100644 --- a/src/grib_geography.cc +++ b/src/grib_geography.cc @@ -143,8 +143,8 @@ static int compute_gaussian_latitudes(long trunc, double* lats) lats[nlat - 1 - jlat] = -lats[jlat]; } - if (nlat != (trunc * 2)) - lats[trunc + 1] = 0.0; + //if (nlat != (trunc * 2)) + // lats[trunc + 1] = 0.0; return GRIB_SUCCESS; } From 845a4616657b9c7f656ca3c50c01937778d73bd5 Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 5 Sep 2024 16:49:41 +0100 Subject: [PATCH 06/22] Compiler warnings --- src/grib_context.cc | 4 ++-- src/grib_fieldset.cc | 30 +++++++++++------------------- src/grib_filepool.cc | 4 ++-- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/grib_context.cc b/src/grib_context.cc index 75681a195..b8d71ae0e 100644 --- a/src/grib_context.cc +++ b/src/grib_context.cc @@ -810,14 +810,14 @@ void grib_context_reset(grib_context* c) if (c->grib_definition_files_dir) { grib_string_list* next = c->grib_definition_files_dir; - grib_string_list* cur = NULL; + grib_string_list* cur = NULL; while (next) { cur = next; next = next->next; grib_context_free(c, cur->value); grib_context_free(c, cur); } - c->grib_definition_files_dir=0; + c->grib_definition_files_dir = 0; } if (c->multi_support_on) diff --git a/src/grib_fieldset.cc b/src/grib_fieldset.cc index a37013844..3bee07caf 100644 --- a/src/grib_fieldset.cc +++ b/src/grib_fieldset.cc @@ -113,14 +113,12 @@ static int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int t static void grib_fieldset_delete_columns(grib_fieldset* set) { - int i = 0; - grib_context* c; - if (!set) return; - c = set->context; - for (i = 0; i < set->columns_size; i++) { + const grib_context* c = set->context; + + for (size_t i = 0; i < set->columns_size; i++) { int j = 0; switch (set->columns[i].type) { case GRIB_TYPE_LONG: @@ -146,22 +144,19 @@ static void grib_fieldset_delete_columns(grib_fieldset* set) static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize) { - double* newdoubles; - long* newlongs; - char** newstrings; - int* newerrors; - int i = 0; - grib_context* c; - if (!set || !set->columns) return GRIB_INVALID_ARGUMENT; - c = set->context; + double* newdoubles = NULL; + long* newlongs = NULL; + char** newstrings = NULL; + int* newerrors = NULL; + const grib_context* c = set->context; if (newsize <= set->columns[0].values_array_size) return 0; - for (i = 0; i < set->columns_size; i++) { + for (size_t i = 0; i < set->columns_size; i++) { switch (set->columns[i].type) { case GRIB_TYPE_LONG: newlongs = (long*)grib_context_realloc(c, set->columns[i].long_values, @@ -818,12 +813,9 @@ static int grib_fieldset_resize_int_array(grib_int_array* a, size_t newsize) static void grib_fieldset_delete_int_array(grib_int_array* f) { - grib_context* c = NULL; - - if (!f) - return; - c = f->context; + if (!f) return; + const grib_context* c = f->context; grib_context_free(c, f->el); grib_context_free(c, f); } diff --git a/src/grib_filepool.cc b/src/grib_filepool.cc index 21f0a5b22..f651c590d 100644 --- a/src/grib_filepool.cc +++ b/src/grib_filepool.cc @@ -287,8 +287,8 @@ void grib_file_pool_delete_file(grib_file* file) void grib_file_close(const char* filename, int force, int* err) { - grib_file* file = NULL; - grib_context* context = grib_context_get_default(); + grib_file* file = NULL; + const grib_context* context = grib_context_get_default(); /* Performance: keep the files open to avoid opening and closing files when writing the output. */ /* So only call fclose() when too many files are open. */ From da32d6d8da3ed60db1ee978bdb839b24365c3b56 Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 5 Sep 2024 17:48:54 +0100 Subject: [PATCH 07/22] Remove grib_emoslib.h --- src/CMakeLists.txt | 1 - src/grib_emoslib.h | 13 ------------- 2 files changed, 14 deletions(-) delete mode 100644 src/grib_emoslib.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2f6a232fb..a6bf02848 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -357,7 +357,6 @@ list( APPEND eccodes_src_files eccodes_prototypes.h grib_dumper_class.h grib_dumper_factory.h - grib_emoslib.h grib_iterator_class.h grib_iterator_factory.h grib_nearest_class.h diff --git a/src/grib_emoslib.h b/src/grib_emoslib.h deleted file mode 100644 index 0b15aef3a..000000000 --- a/src/grib_emoslib.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * (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. - */ - -int igglat_(long* KLAT, float* PGAUSS, long* KPR, long* KERR); -void gribex_(long* KSEC0, long* KSEC1, long* KSEC2, double* PSEC2, long* KSEC3, double* PSEC3, long* KSEC4, - double* PSEC4, long* KLENP, void* KGRIB, long* KLENG, long* KWORD, char* HOPER, long* KRET); From 3ac390825c87a8dd2135bab02e14127a26d01c22 Mon Sep 17 00:00:00 2001 From: Robert Osinski Date: Fri, 6 Sep 2024 09:57:23 +0000 Subject: [PATCH 08/22] ECC-1915: GRIB2 CMCC origin for class=ci --- definitions/mars/grib.mmsa.em.def | 2 +- definitions/mars/grib.mmsa.fcmean.def | 2 +- definitions/mars/grib.mmsf.an.def | 2 +- definitions/mars/grib.mmsf.fc.def | 2 +- definitions/mars/grib.msmm.em.def | 2 +- definitions/mars/grib.msmm.fcmax.def | 2 +- definitions/mars/grib.msmm.fcmean.def | 2 +- definitions/mars/grib.msmm.fcmin.def | 2 +- definitions/mars/grib.msmm.fcstdev.def | 2 +- definitions/mars/grib.msmm.hcmean.def | 18 +++++++++++++++++- 10 files changed, 26 insertions(+), 10 deletions(-) mode change 120000 => 100644 definitions/mars/grib.msmm.hcmean.def diff --git a/definitions/mars/grib.mmsa.em.def b/definitions/mars/grib.mmsa.em.def index 6d152901b..a4e6f175f 100644 --- a/definitions/mars/grib.mmsa.em.def +++ b/definitions/mars/grib.mmsa.em.def @@ -6,7 +6,7 @@ if (class is "od") { alias mars.system = systemNumber; } if (class is "c3") { alias mars.system = systemNumber; } # See ECC-624 -if (centre == 80 && subCentre == 98 && class is "c3") { +if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { constant cnmc_cmcc = 'cmcc'; alias mars.origin = cnmc_cmcc; } diff --git a/definitions/mars/grib.mmsa.fcmean.def b/definitions/mars/grib.mmsa.fcmean.def index f828d5a8c..213517b04 100644 --- a/definitions/mars/grib.mmsa.fcmean.def +++ b/definitions/mars/grib.mmsa.fcmean.def @@ -8,7 +8,7 @@ if (class is "od") { alias mars.system = systemNumber; } if (class is "c3") { alias mars.system = systemNumber; } # See ECC-624 -if (centre == 80 && subCentre == 98 && class is "c3") { +if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { constant cnmc_cmcc = 'cmcc'; alias mars.origin = cnmc_cmcc; } diff --git a/definitions/mars/grib.mmsf.an.def b/definitions/mars/grib.mmsf.an.def index 86ccb55b5..20e418ce5 100644 --- a/definitions/mars/grib.mmsf.an.def +++ b/definitions/mars/grib.mmsf.an.def @@ -15,7 +15,7 @@ if (class isnot "gw") { # ECC-1448 } # See ECC-624 -if (centre == 80 && subCentre == 98 && class is "c3") { +if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { constant cnmc_cmcc = 'cmcc'; alias mars.origin = cnmc_cmcc; } diff --git a/definitions/mars/grib.mmsf.fc.def b/definitions/mars/grib.mmsf.fc.def index 30b2f7394..6fe01e2a6 100644 --- a/definitions/mars/grib.mmsf.fc.def +++ b/definitions/mars/grib.mmsf.fc.def @@ -18,7 +18,7 @@ if (class isnot "gw") { # ECC-1448 } # See ECC-624 -if (centre == 80 && subCentre == 98 && class is "c3") { +if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { constant cnmc_cmcc = 'cmcc'; alias mars.origin = cnmc_cmcc; } diff --git a/definitions/mars/grib.msmm.em.def b/definitions/mars/grib.msmm.em.def index 3131d45a7..663003e8e 100644 --- a/definitions/mars/grib.msmm.em.def +++ b/definitions/mars/grib.msmm.em.def @@ -11,7 +11,7 @@ if (class is "en") { alias mars.system = systemNumber; } if (class is "c3") { alias mars.system = systemNumber; } # See ECC-624 -if (centre == 80 && subCentre == 98 && class is "c3") { +if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { constant cnmc_cmcc = 'cmcc'; alias mars.origin = cnmc_cmcc; } diff --git a/definitions/mars/grib.msmm.fcmax.def b/definitions/mars/grib.msmm.fcmax.def index 573343213..b548cbdc0 100644 --- a/definitions/mars/grib.msmm.fcmax.def +++ b/definitions/mars/grib.msmm.fcmax.def @@ -12,7 +12,7 @@ if (class is "en") { alias mars.system = systemNumber; } if (class is "c3") { alias mars.system = systemNumber; } # See ECC-624 -if (centre == 80 && subCentre == 98 && class is "c3") { +if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { constant cnmc_cmcc = 'cmcc'; alias mars.origin = cnmc_cmcc; } diff --git a/definitions/mars/grib.msmm.fcmean.def b/definitions/mars/grib.msmm.fcmean.def index a13ca9918..c532f33fd 100644 --- a/definitions/mars/grib.msmm.fcmean.def +++ b/definitions/mars/grib.msmm.fcmean.def @@ -13,7 +13,7 @@ if (class is "c3") { alias mars.system = systemNumber; } if (class is "ci") { alias mars.system = systemNumber; } # See ECC-624 -if (centre == 80 && subCentre == 98 && class is "c3") { +if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { constant cnmc_cmcc = 'cmcc'; alias mars.origin = cnmc_cmcc; } diff --git a/definitions/mars/grib.msmm.fcmin.def b/definitions/mars/grib.msmm.fcmin.def index 59f10189a..c052e512e 100644 --- a/definitions/mars/grib.msmm.fcmin.def +++ b/definitions/mars/grib.msmm.fcmin.def @@ -12,7 +12,7 @@ if (class is "en") { alias mars.system = systemNumber; } if (class is "c3") { alias mars.system = systemNumber; } # See ECC-624 -if (centre == 80 && subCentre == 98 && class is "c3") { +if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { constant cnmc_cmcc = 'cmcc'; alias mars.origin = cnmc_cmcc; } diff --git a/definitions/mars/grib.msmm.fcstdev.def b/definitions/mars/grib.msmm.fcstdev.def index f4b8c2414..20b330ba3 100644 --- a/definitions/mars/grib.msmm.fcstdev.def +++ b/definitions/mars/grib.msmm.fcstdev.def @@ -13,7 +13,7 @@ if (class is "en") { alias mars.system = systemNumber; } if (class is "c3") { alias mars.system = systemNumber; } # See ECC-624 -if (centre == 80 && subCentre == 98 && class is "c3") { +if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { constant cnmc_cmcc = 'cmcc'; alias mars.origin = cnmc_cmcc; } diff --git a/definitions/mars/grib.msmm.hcmean.def b/definitions/mars/grib.msmm.hcmean.def deleted file mode 120000 index 0b5cb2f13..000000000 --- a/definitions/mars/grib.msmm.hcmean.def +++ /dev/null @@ -1 +0,0 @@ -grib.msmm.em.def \ No newline at end of file diff --git a/definitions/mars/grib.msmm.hcmean.def b/definitions/mars/grib.msmm.hcmean.def new file mode 100644 index 000000000..6e1de7002 --- /dev/null +++ b/definitions/mars/grib.msmm.hcmean.def @@ -0,0 +1,17 @@ +# assert(16); +alias mars.fcmonth = marsForecastMonth; +unalias mars.step; + +alias mars.origin = centre; +alias mars.method = methodNumber; + +if (class is "od") { alias mars.system = systemNumber; } +if (class is "me") { alias mars.system = systemNumber; } +if (class is "en") { alias mars.system = systemNumber; } +if (class is "c3") { alias mars.system = systemNumber; } + +# See ECC-624 +if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci" (class is "c3" || class is "ci")) { + constant cnmc_cmcc = 'cmcc'; + alias mars.origin = cnmc_cmcc; +} From 87992950b85cc06506b70bc392b2fa3ca1bb302f Mon Sep 17 00:00:00 2001 From: Robert Osinski Date: Fri, 6 Sep 2024 10:34:37 +0000 Subject: [PATCH 09/22] ECC-1915: unalias mars.method for class cerise --- definitions/mars/grib.mmsa.em.def | 3 +++ definitions/mars/grib.mmsa.fcmean.def | 3 +++ definitions/mars/grib.msmm.em.def | 3 +++ definitions/mars/grib.msmm.fcmax.def | 3 +++ definitions/mars/grib.msmm.fcmin.def | 2 ++ definitions/mars/grib.msmm.fcstdev.def | 2 ++ definitions/mars/grib.msmm.hcmean.def | 2 ++ 7 files changed, 18 insertions(+) diff --git a/definitions/mars/grib.mmsa.em.def b/definitions/mars/grib.mmsa.em.def index a4e6f175f..36ac9adc5 100644 --- a/definitions/mars/grib.mmsa.em.def +++ b/definitions/mars/grib.mmsa.em.def @@ -10,3 +10,6 @@ if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { constant cnmc_cmcc = 'cmcc'; alias mars.origin = cnmc_cmcc; } + +if (class is "ci") { unalias mars.method; } + diff --git a/definitions/mars/grib.mmsa.fcmean.def b/definitions/mars/grib.mmsa.fcmean.def index 213517b04..3b7f185b3 100644 --- a/definitions/mars/grib.mmsa.fcmean.def +++ b/definitions/mars/grib.mmsa.fcmean.def @@ -12,3 +12,6 @@ if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { constant cnmc_cmcc = 'cmcc'; alias mars.origin = cnmc_cmcc; } + +if (class is "ci") { unalias mars.method; } + diff --git a/definitions/mars/grib.msmm.em.def b/definitions/mars/grib.msmm.em.def index 663003e8e..86376c834 100644 --- a/definitions/mars/grib.msmm.em.def +++ b/definitions/mars/grib.msmm.em.def @@ -15,3 +15,6 @@ if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { constant cnmc_cmcc = 'cmcc'; alias mars.origin = cnmc_cmcc; } + +if (class is "ci") { unalias mars.method; } + diff --git a/definitions/mars/grib.msmm.fcmax.def b/definitions/mars/grib.msmm.fcmax.def index b548cbdc0..b64b923a1 100644 --- a/definitions/mars/grib.msmm.fcmax.def +++ b/definitions/mars/grib.msmm.fcmax.def @@ -16,3 +16,6 @@ if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { constant cnmc_cmcc = 'cmcc'; alias mars.origin = cnmc_cmcc; } + +if (class is "ci") { unalias mars.method; } + diff --git a/definitions/mars/grib.msmm.fcmin.def b/definitions/mars/grib.msmm.fcmin.def index c052e512e..158383e2c 100644 --- a/definitions/mars/grib.msmm.fcmin.def +++ b/definitions/mars/grib.msmm.fcmin.def @@ -16,3 +16,5 @@ if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { constant cnmc_cmcc = 'cmcc'; alias mars.origin = cnmc_cmcc; } + +if (class is "ci") { unalias mars.method; } diff --git a/definitions/mars/grib.msmm.fcstdev.def b/definitions/mars/grib.msmm.fcstdev.def index 20b330ba3..3a563515b 100644 --- a/definitions/mars/grib.msmm.fcstdev.def +++ b/definitions/mars/grib.msmm.fcstdev.def @@ -17,3 +17,5 @@ if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { constant cnmc_cmcc = 'cmcc'; alias mars.origin = cnmc_cmcc; } + +if (class is "ci") { unalias mars.method; } diff --git a/definitions/mars/grib.msmm.hcmean.def b/definitions/mars/grib.msmm.hcmean.def index 6e1de7002..8fc0cda27 100644 --- a/definitions/mars/grib.msmm.hcmean.def +++ b/definitions/mars/grib.msmm.hcmean.def @@ -15,3 +15,5 @@ if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci" (class is constant cnmc_cmcc = 'cmcc'; alias mars.origin = cnmc_cmcc; } + +if (class is "ci") { unalias mars.method; } From 1ffdb64b7ddb5d65a7baf512518c8452f054297b Mon Sep 17 00:00:00 2001 From: Robert Osinski Date: Fri, 6 Sep 2024 10:41:30 +0000 Subject: [PATCH 10/22] correction of typos --- definitions/mars/grib.msmm.hcmean.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/definitions/mars/grib.msmm.hcmean.def b/definitions/mars/grib.msmm.hcmean.def index 8fc0cda27..cbdd6704a 100644 --- a/definitions/mars/grib.msmm.hcmean.def +++ b/definitions/mars/grib.msmm.hcmean.def @@ -11,7 +11,7 @@ if (class is "en") { alias mars.system = systemNumber; } if (class is "c3") { alias mars.system = systemNumber; } # See ECC-624 -if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci" (class is "c3" || class is "ci")) { +if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { constant cnmc_cmcc = 'cmcc'; alias mars.origin = cnmc_cmcc; } From afaf3d6bc52b7f09c668f729c7d3b989d16c8b7c Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 6 Sep 2024 14:00:40 +0100 Subject: [PATCH 11/22] Tools: codes_config options --- tools/codes_config.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/codes_config.in b/tools/codes_config.in index 819f673e6..fa15d0115 100755 --- a/tools/codes_config.in +++ b/tools/codes_config.in @@ -36,7 +36,7 @@ print_feature() build_type="@CMAKE_BUILD_TYPE@" info() { - echo "ecCodes version (${ECCODES_VERSION_STR}), git-sha1 ${ECCODES_GIT_SHA1}" + echo "ecCodes version ${ECCODES_VERSION_STR}, git-sha1 ${ECCODES_GIT_SHA1}" echo "" echo "Build:" echo " build type : @CMAKE_BUILD_TYPE@" @@ -55,6 +55,7 @@ info() # echo " flags : @ECCODES_Fortran_FLAGS@" echo "" echo "Features:" + echo " FORTRAN : $(print_feature @HAVE_FORTRAN@)" echo " AEC : $(print_feature @HAVE_AEC@)" echo " MEMFS : $(print_feature @HAVE_MEMFS@)" echo " ECCODES_THREADS : $(print_feature @GRIB_PTHREADS@)" From ac4dc27fed28dd01d9107f35905ab6d5861387a1 Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 6 Sep 2024 14:14:24 +0100 Subject: [PATCH 12/22] cppcheck warning: Member variable 'name' also defined in base class --- src/accessor/grib_accessor_class_getenv.cc | 9 +++++---- src/accessor/grib_accessor_class_getenv.h | 5 ++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/accessor/grib_accessor_class_getenv.cc b/src/accessor/grib_accessor_class_getenv.cc index a6d6f9c72..89ec5d90d 100644 --- a/src/accessor/grib_accessor_class_getenv.cc +++ b/src/accessor/grib_accessor_class_getenv.cc @@ -18,10 +18,11 @@ void grib_accessor_class_getenv_t::init(grib_accessor* a, const long l, grib_arg { grib_accessor_class_ascii_t::init(a, l, args); grib_accessor_getenv_t* self = (grib_accessor_getenv_t*)a; - static char undefined[] = "undefined"; + static char undefined[] = "undefined"; + grib_handle* hand = grib_handle_of_accessor(a); - self->name = grib_arguments_get_string(grib_handle_of_accessor(a), args, 0); - self->default_value = grib_arguments_get_string(grib_handle_of_accessor(a), args, 1); + self->envvar = grib_arguments_get_string(hand, args, 0); + self->default_value = grib_arguments_get_string(hand, args, 1); if (!self->default_value) self->default_value = undefined; self->value = 0; @@ -39,7 +40,7 @@ int grib_accessor_class_getenv_t::unpack_string(grib_accessor* a, char* val, siz size_t l = 0; if (!self->value) { - v = getenv(self->name); + v = getenv(self->envvar); if (!v) v = (char*)self->default_value; self->value = v; diff --git a/src/accessor/grib_accessor_class_getenv.h b/src/accessor/grib_accessor_class_getenv.h index b04c58a4d..ee43f136b 100644 --- a/src/accessor/grib_accessor_class_getenv.h +++ b/src/accessor/grib_accessor_class_getenv.h @@ -15,7 +15,7 @@ class grib_accessor_getenv_t : public grib_accessor_ascii_t { public: - const char* name; + const char* envvar; char* value; const char* default_value; }; @@ -23,7 +23,7 @@ public: class grib_accessor_class_getenv_t : public grib_accessor_class_ascii_t { public: - grib_accessor_class_getenv_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor_class_getenv_t(const char* envvar) : grib_accessor_class_ascii_t(envvar) {} grib_accessor* create_empty_accessor() override { return new grib_accessor_getenv_t{}; } int pack_string(grib_accessor*, const char*, size_t* len) override; int unpack_string(grib_accessor*, char*, size_t* len) override; @@ -31,4 +31,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; - From d48e3f7fcca6c67bc0a6489d10fedbf665318913 Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 6 Sep 2024 14:14:33 +0100 Subject: [PATCH 13/22] Const correctness --- src/accessor/grib_accessor_class_gen.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/accessor/grib_accessor_class_gen.cc b/src/accessor/grib_accessor_class_gen.cc index 3a721f196..cfe2707a6 100644 --- a/src/accessor/grib_accessor_class_gen.cc +++ b/src/accessor/grib_accessor_class_gen.cc @@ -310,7 +310,7 @@ long grib_accessor_class_gen_t::byte_offset(grib_accessor* a) int grib_accessor_class_gen_t::unpack_bytes(grib_accessor* a, unsigned char* val, size_t* len) { - unsigned char* buf = grib_handle_of_accessor(a)->buffer->data; + const unsigned char* buf = grib_handle_of_accessor(a)->buffer->data; const long length = a->byte_count(); const long offset = a->byte_offset(); From 1f2fbf4710c88da96b2d4b22146213b06b646185 Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 6 Sep 2024 14:39:45 +0100 Subject: [PATCH 14/22] Const correctness --- src/accessor/grib_accessor_class_g1bitmap.cc | 2 +- ...rib_accessor_class_g1end_of_interval_monthly.cc | 14 ++++++++------ src/accessor/grib_accessor_class_group.cc | 2 +- src/accessor/grib_accessor_class_gts_header.cc | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/accessor/grib_accessor_class_g1bitmap.cc b/src/accessor/grib_accessor_class_g1bitmap.cc index 331b800c5..afb713b30 100644 --- a/src/accessor/grib_accessor_class_g1bitmap.cc +++ b/src/accessor/grib_accessor_class_g1bitmap.cc @@ -77,7 +77,7 @@ int grib_accessor_class_g1bitmap_t::value_count(grib_accessor* a, long* count) int grib_accessor_class_g1bitmap_t::unpack_bytes(grib_accessor* a, unsigned char* val, size_t* len) { - unsigned char* buf = grib_handle_of_accessor(a)->buffer->data; + const unsigned char* buf = grib_handle_of_accessor(a)->buffer->data; grib_accessor_g1bitmap_t* self = (grib_accessor_g1bitmap_t*)a; long tlen; int err; diff --git a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc index 3bf953598..b8b02853a 100644 --- a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc +++ b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc @@ -18,7 +18,7 @@ void grib_accessor_class_g1end_of_interval_monthly_t::init(grib_accessor* a, con { grib_accessor_class_abstract_vector_t::init(a, l, c); grib_accessor_g1end_of_interval_monthly_t* self = (grib_accessor_g1end_of_interval_monthly_t*)a; - int n = 0; + int n = 0; self->verifyingMonth = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; @@ -26,7 +26,7 @@ void grib_accessor_class_g1end_of_interval_monthly_t::init(grib_accessor* a, con a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; self->number_of_elements = 6; - self->v = (double*)grib_context_malloc(a->context, sizeof(double) * self->number_of_elements); + self->v = (double*)grib_context_malloc(a->context, sizeof(double) * self->number_of_elements); a->length = 0; a->dirty = 1; @@ -90,8 +90,8 @@ int grib_accessor_class_g1end_of_interval_monthly_t::unpack_double(grib_accessor int grib_accessor_class_g1end_of_interval_monthly_t::value_count(grib_accessor* a, long* count) { - grib_accessor_g1end_of_interval_monthly_t* self = (grib_accessor_g1end_of_interval_monthly_t*)a; - *count = self->number_of_elements; + const grib_accessor_g1end_of_interval_monthly_t* self = (grib_accessor_g1end_of_interval_monthly_t*)a; + *count = self->number_of_elements; return 0; } @@ -111,9 +111,8 @@ int grib_accessor_class_g1end_of_interval_monthly_t::compare(grib_accessor* a, g long count = 0; size_t alen = 0; size_t blen = 0; - int err = 0; - err = a->value_count(&count); + int err = a->value_count(&count); if (err) return err; alen = count; @@ -133,7 +132,10 @@ int grib_accessor_class_g1end_of_interval_monthly_t::compare(grib_accessor* a, g a->dirty = 1; err = a->unpack_double(aval, &alen); + if (err) return err; err = b->unpack_double(bval, &blen); + if (err) return err; + for (size_t i = 0; i < alen && retval == GRIB_SUCCESS; ++i) { if (aval[i] != bval[i]) retval = GRIB_DOUBLE_VALUE_MISMATCH; } diff --git a/src/accessor/grib_accessor_class_group.cc b/src/accessor/grib_accessor_class_group.cc index 74051d17d..c6e52bb9c 100644 --- a/src/accessor/grib_accessor_class_group.cc +++ b/src/accessor/grib_accessor_class_group.cc @@ -17,7 +17,7 @@ grib_accessor_class* grib_accessor_class_group = &_grib_accessor_class_group; void grib_accessor_class_group_t::init(grib_accessor* a, const long len, grib_arguments* arg) { grib_accessor_class_gen_t::init(a, len, arg); - grib_buffer* buffer = grib_handle_of_accessor(a)->buffer; + const grib_buffer* buffer = grib_handle_of_accessor(a)->buffer; grib_accessor_group_t* self = (grib_accessor_group_t*)a; size_t i = 0; diff --git a/src/accessor/grib_accessor_class_gts_header.cc b/src/accessor/grib_accessor_class_gts_header.cc index 5b158c6d1..d069b1c58 100644 --- a/src/accessor/grib_accessor_class_gts_header.cc +++ b/src/accessor/grib_accessor_class_gts_header.cc @@ -59,6 +59,6 @@ int grib_accessor_class_gts_header_t::value_count(grib_accessor* a, long* count) size_t grib_accessor_class_gts_header_t::string_length(grib_accessor* a) { - grib_handle* h = grib_handle_of_accessor(a); + const grib_handle* h = grib_handle_of_accessor(a); return h->gts_header_len; } From 6115373ce44d29ec58fb9cc1dc6a824d817af0e7 Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 6 Sep 2024 14:40:17 +0100 Subject: [PATCH 15/22] cppcheck warning: Member variables 'offset' and 'length' also defined in base class --- src/accessor/grib_accessor_class_md5.cc | 10 +++++----- src/accessor/grib_accessor_class_md5.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/accessor/grib_accessor_class_md5.cc b/src/accessor/grib_accessor_class_md5.cc index 40cbae672..a148787af 100644 --- a/src/accessor/grib_accessor_class_md5.cc +++ b/src/accessor/grib_accessor_class_md5.cc @@ -25,9 +25,9 @@ void grib_accessor_class_md5_t::init(grib_accessor* a, const long len, grib_argu grib_string_list* current = 0; grib_context* context = a->context; - self->offset = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->length = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, n++); - self->blocklist = NULL; + self->offset_key = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); + self->length_key = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, n++); + self->blocklist = NULL; while ((b = (char*)grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++)) != NULL) { if (!self->blocklist) { self->blocklist = (grib_string_list*)grib_context_malloc_clear(context, sizeof(grib_string_list)); @@ -99,9 +99,9 @@ int grib_accessor_class_md5_t::unpack_string(grib_accessor* a, char* v, size_t* return GRIB_BUFFER_TOO_SMALL; } - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offset, &offset)) != GRIB_SUCCESS) + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offset_key, &offset)) != GRIB_SUCCESS) return ret; - if ((ret = grib_expression_evaluate_long(grib_handle_of_accessor(a), self->length, &length)) != GRIB_SUCCESS) + if ((ret = grib_expression_evaluate_long(grib_handle_of_accessor(a), self->length_key, &length)) != GRIB_SUCCESS) return ret; mess = (unsigned char*)grib_context_malloc(a->context, length); memcpy(mess, grib_handle_of_accessor(a)->buffer->data + offset, length); diff --git a/src/accessor/grib_accessor_class_md5.h b/src/accessor/grib_accessor_class_md5.h index ae66f397f..42e58e002 100644 --- a/src/accessor/grib_accessor_class_md5.h +++ b/src/accessor/grib_accessor_class_md5.h @@ -17,8 +17,8 @@ class grib_accessor_md5_t : public grib_accessor_gen_t { public: /* Members defined in md5 */ - const char* offset; - grib_expression* length; + const char* offset_key; + grib_expression* length_key; grib_string_list* blocklist; }; From fc73927c42566f824a484093bfc1f616148febd4 Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 6 Sep 2024 14:44:02 +0100 Subject: [PATCH 16/22] Const correctness --- src/accessor/grib_accessor_class_non_alpha.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/accessor/grib_accessor_class_non_alpha.cc b/src/accessor/grib_accessor_class_non_alpha.cc index 7e434dfb6..48d9cef34 100644 --- a/src/accessor/grib_accessor_class_non_alpha.cc +++ b/src/accessor/grib_accessor_class_non_alpha.cc @@ -17,12 +17,10 @@ grib_accessor_class* grib_accessor_class_non_alpha = &_grib_accessor_class_non_a void grib_accessor_class_non_alpha_t::init(grib_accessor* a, const long len, grib_arguments* arg) { grib_accessor_class_gen_t::init(a, len, arg); - grib_buffer* buffer = grib_handle_of_accessor(a)->buffer; - size_t i = 0; - unsigned char* v; - v = buffer->data + a->offset; - i = 0; + const grib_buffer* buffer = grib_handle_of_accessor(a)->buffer; + unsigned char* v = buffer->data + a->offset; + size_t i = 0; while ((*v < 33 || *v > 126) && i <= buffer->ulength) { v++; i++; From 6924dc014a530537c558b43c576816a4e77877c7 Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 6 Sep 2024 14:59:39 +0100 Subject: [PATCH 17/22] Const correctness --- src/accessor/grib_accessor_class_signed.cc | 7 +++---- src/accessor/grib_accessor_class_uint64.cc | 6 +++--- src/accessor/grib_accessor_class_uint64_little_endian.cc | 9 ++++----- src/accessor/grib_accessor_class_uint8.cc | 2 +- src/accessor/grib_accessor_class_unsigned.cc | 4 ++-- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/accessor/grib_accessor_class_signed.cc b/src/accessor/grib_accessor_class_signed.cc index 36c20bd59..d240836ac 100644 --- a/src/accessor/grib_accessor_class_signed.cc +++ b/src/accessor/grib_accessor_class_signed.cc @@ -199,17 +199,16 @@ long grib_accessor_class_signed_t::next_offset(grib_accessor* a) int grib_accessor_class_signed_t::is_missing(grib_accessor* a) { - int i = 0; - unsigned char ff = 0xff; + unsigned char ff = 0xff; unsigned long offset = a->offset; - grib_handle* hand = grib_handle_of_accessor(a); + const grib_handle* hand = grib_handle_of_accessor(a); if (a->length == 0) { Assert(a->vvalue != NULL); return a->vvalue->missing; } - for (i = 0; i < a->length; i++) { + for (long i = 0; i < a->length; i++) { if (hand->buffer->data[offset] != ff) return 0; offset++; diff --git a/src/accessor/grib_accessor_class_uint64.cc b/src/accessor/grib_accessor_class_uint64.cc index a800a4630..78e1a54c0 100644 --- a/src/accessor/grib_accessor_class_uint64.cc +++ b/src/accessor/grib_accessor_class_uint64.cc @@ -16,9 +16,9 @@ grib_accessor_class* grib_accessor_class_uint64 = &_grib_accessor_class_uint64; int grib_accessor_class_uint64_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - long value = 0; - long pos = a->offset; - unsigned char* data = grib_handle_of_accessor(a)->buffer->data; + long value = 0; + long pos = a->offset; + const unsigned char* data = grib_handle_of_accessor(a)->buffer->data; unsigned long long result = 0, tmp; int i; diff --git a/src/accessor/grib_accessor_class_uint64_little_endian.cc b/src/accessor/grib_accessor_class_uint64_little_endian.cc index 25e537dbe..b98b7a90f 100644 --- a/src/accessor/grib_accessor_class_uint64_little_endian.cc +++ b/src/accessor/grib_accessor_class_uint64_little_endian.cc @@ -16,17 +16,16 @@ grib_accessor_class* grib_accessor_class_uint64_little_endian = &_grib_accessor_ int grib_accessor_class_uint64_little_endian_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - long value = 0; - long pos = a->offset; - unsigned char* data = grib_handle_of_accessor(a)->buffer->data; + long value = 0; + long pos = a->offset; + const unsigned char* data = grib_handle_of_accessor(a)->buffer->data; unsigned long long result = 0, tmp; - int i; if (*len < 1) { return GRIB_ARRAY_TOO_SMALL; } - for (i = 7; i >= 0; i--) { + for (int i = 7; i >= 0; i--) { result <<= 8; result |= data[pos + i]; } diff --git a/src/accessor/grib_accessor_class_uint8.cc b/src/accessor/grib_accessor_class_uint8.cc index 90236aa50..9840353df 100644 --- a/src/accessor/grib_accessor_class_uint8.cc +++ b/src/accessor/grib_accessor_class_uint8.cc @@ -18,7 +18,7 @@ int grib_accessor_class_uint8_t::unpack_long(grib_accessor* a, long* val, size_t { long value = 0; long pos = a->offset; - unsigned char* data = grib_handle_of_accessor(a)->buffer->data; + const unsigned char* data = grib_handle_of_accessor(a)->buffer->data; if (*len < 1) { return GRIB_ARRAY_TOO_SMALL; diff --git a/src/accessor/grib_accessor_class_unsigned.cc b/src/accessor/grib_accessor_class_unsigned.cc index 14ca831a3..d2394072d 100644 --- a/src/accessor/grib_accessor_class_unsigned.cc +++ b/src/accessor/grib_accessor_class_unsigned.cc @@ -162,7 +162,7 @@ int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, in int grib_accessor_class_unsigned_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a; + const grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a; long rlen = 0; unsigned long i = 0; @@ -245,7 +245,7 @@ int grib_accessor_class_unsigned_t::is_missing(grib_accessor* a) { const unsigned char ff = 0xff; unsigned long offset = a->offset; - grib_handle* hand = grib_handle_of_accessor(a); + const grib_handle* hand = grib_handle_of_accessor(a); if (a->length == 0) { Assert(a->vvalue != NULL); From 526ca4bb3240621a0c86f404ec4bb9ee559cabc2 Mon Sep 17 00:00:00 2001 From: foxtran <39676482+foxtran@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:56:24 +0200 Subject: [PATCH 18/22] Fetch ecbuild if not downloaded before --- CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e5290fa0..434b0b2af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,18 @@ cmake_minimum_required( VERSION 3.12 FATAL_ERROR ) -find_package( ecbuild 3.7 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild) +find_package( ecbuild 3.7 HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild) +if(NOT ecbuild_FOUND) + message(STATUS "Fetching ecbuild...") + include(FetchContent) + FetchContent_Declare( + ecbuild + GIT_REPOSITORY https://github.com/ecmwf/ecbuild.git + GIT_TAG 3.8.5 + ) + FetchContent_MakeAvailable(ecbuild) + find_package( ecbuild 3.7 REQUIRED ) +endif() # Initialise project project( eccodes LANGUAGES CXX ) From 5437cee025a4928bddeb3419de1c9fea956e4e66 Mon Sep 17 00:00:00 2001 From: "Igor S. Gerasimov" Date: Thu, 5 Sep 2024 22:53:39 +0200 Subject: [PATCH 19/22] MakeAvailable -> Populate --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 434b0b2af..794208436 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,8 +27,8 @@ if(NOT ecbuild_FOUND) GIT_REPOSITORY https://github.com/ecmwf/ecbuild.git GIT_TAG 3.8.5 ) - FetchContent_MakeAvailable(ecbuild) - find_package( ecbuild 3.7 REQUIRED ) + FetchContent_Populate(ecbuild) + find_package( ecbuild 3.7 REQUIRED HINTS ${ecbuild_SOURCE_DIR}) endif() # Initialise project From f25cedfad21389bf375ddfe12c4e9c4edc200f64 Mon Sep 17 00:00:00 2001 From: "Igor S. Gerasimov" Date: Sat, 7 Sep 2024 10:59:26 +0200 Subject: [PATCH 20/22] Merge FetchContent_Declare and FetchContent_Populate --- CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 794208436..03ec9e2a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,12 +22,10 @@ find_package( ecbuild 3.7 HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOUR if(NOT ecbuild_FOUND) message(STATUS "Fetching ecbuild...") include(FetchContent) - FetchContent_Declare( - ecbuild + FetchContent_Populate(ecbuild GIT_REPOSITORY https://github.com/ecmwf/ecbuild.git GIT_TAG 3.8.5 ) - FetchContent_Populate(ecbuild) find_package( ecbuild 3.7 REQUIRED HINTS ${ecbuild_SOURCE_DIR}) endif() From 15685f9922b36ba2f9ac077d789cfc73c8d52a28 Mon Sep 17 00:00:00 2001 From: shahramn Date: Mon, 9 Sep 2024 21:00:46 +0100 Subject: [PATCH 21/22] Tools: Set key 'file' for grib_ls --- tools/grib_ls.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/grib_ls.cc b/tools/grib_ls.cc index c5d06df01..08578502f 100644 --- a/tools/grib_ls.cc +++ b/tools/grib_ls.cc @@ -371,10 +371,6 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) } if (!json_latlon && options->json_output) { - if (options->current_infile && options->current_infile->name) { - size_t len = strlen(options->current_infile->name); - grib_set_string(h, "file", options->current_infile->name, &len); - } if (!first_handle && options->handle_count > 1) { fprintf(stdout, ",\n"); } @@ -383,6 +379,12 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) first_handle = 0; } } + + if (options->current_infile && options->current_infile->name) { + size = strlen(options->current_infile->name); + grib_set_string(h, "file", options->current_infile->name, &size); + } + new_handle = "\n,"; return 0; } From b74bc1e46c7861804a8040eed3714da2f1bef98d Mon Sep 17 00:00:00 2001 From: shahramn Date: Tue, 10 Sep 2024 18:14:35 +0100 Subject: [PATCH 22/22] Definitions: Simplify IF statements --- definitions/mars/grib.mmam.fcmean.def | 5 +++-- definitions/mars/grib.msmm.em.def | 7 +++---- definitions/mars/grib.msmm.fcmax.def | 7 +++---- definitions/mars/grib.msmm.fcmean.def | 8 +++----- definitions/mars/grib.msmm.fcmin.def | 8 +++----- definitions/mars/grib.msmm.fcstdev.def | 7 +++---- definitions/mars/grib.msmm.hcmean.def | 7 +++---- definitions/mars/grib.ocea.an.def | 7 ++++--- definitions/mars/grib.ocea.ff.def | 6 +++--- definitions/mars/grib.ocea.fx.def | 6 +++--- definitions/mars/grib.ocea.of.def | 6 +++--- definitions/mars/grib.ocea.or.def | 6 +++--- definitions/mars/grib.swmm.fcmax.def | 6 +++--- definitions/mars/grib.swmm.fcmean.def | 6 +++--- definitions/mars/grib.swmm.fcmin.def | 6 +++--- definitions/mars/grib.swmm.fcstdev.def | 6 +++--- 16 files changed, 49 insertions(+), 55 deletions(-) diff --git a/definitions/mars/grib.mmam.fcmean.def b/definitions/mars/grib.mmam.fcmean.def index a2ece7923..84c4cce2f 100644 --- a/definitions/mars/grib.mmam.fcmean.def +++ b/definitions/mars/grib.mmam.fcmean.def @@ -4,5 +4,6 @@ alias mars.fcmonth = marsForecastMonth; unalias mars.step; alias mars.method = methodNumber; -if (class is "od") { alias mars.system = systemNumber; } -if (class is "en") { alias mars.system = systemNumber; } +if (class is "od" || class is "en") { + alias mars.system = systemNumber; +} diff --git a/definitions/mars/grib.msmm.em.def b/definitions/mars/grib.msmm.em.def index 86376c834..cce87213b 100644 --- a/definitions/mars/grib.msmm.em.def +++ b/definitions/mars/grib.msmm.em.def @@ -5,10 +5,9 @@ unalias mars.step; alias mars.origin = centre; alias mars.method = methodNumber; -if (class is "od") { alias mars.system = systemNumber; } -if (class is "me") { alias mars.system = systemNumber; } -if (class is "en") { alias mars.system = systemNumber; } -if (class is "c3") { alias mars.system = systemNumber; } +if (class is "od" || class is "me" || class is "en" || class is "c3") { + alias mars.system = systemNumber; +} # See ECC-624 if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { diff --git a/definitions/mars/grib.msmm.fcmax.def b/definitions/mars/grib.msmm.fcmax.def index b64b923a1..52eecab7d 100644 --- a/definitions/mars/grib.msmm.fcmax.def +++ b/definitions/mars/grib.msmm.fcmax.def @@ -6,10 +6,9 @@ alias mars.number = perturbationNumber; alias mars.origin = centre; alias mars.method = methodNumber; -if (class is "od") { alias mars.system = systemNumber; } -if (class is "me") { alias mars.system = systemNumber; } -if (class is "en") { alias mars.system = systemNumber; } -if (class is "c3") { alias mars.system = systemNumber; } +if (class is "od" || class is "me" || class is "en" || class is "c3") { + alias mars.system = systemNumber; +} # See ECC-624 if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { diff --git a/definitions/mars/grib.msmm.fcmean.def b/definitions/mars/grib.msmm.fcmean.def index c532f33fd..7a7ff8e66 100644 --- a/definitions/mars/grib.msmm.fcmean.def +++ b/definitions/mars/grib.msmm.fcmean.def @@ -6,11 +6,9 @@ alias mars.method = methodNumber; unalias mars.step; -if (class is "od") { alias mars.system = systemNumber; } -if (class is "me") { alias mars.system = systemNumber; } -if (class is "en") { alias mars.system = systemNumber; } -if (class is "c3") { alias mars.system = systemNumber; } -if (class is "ci") { alias mars.system = systemNumber; } +if (class is "od" || class is "me" || class is "en" || class is "c3" || class is "ci") { + alias mars.system = systemNumber; +} # See ECC-624 if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { diff --git a/definitions/mars/grib.msmm.fcmin.def b/definitions/mars/grib.msmm.fcmin.def index 158383e2c..0c3d347d0 100644 --- a/definitions/mars/grib.msmm.fcmin.def +++ b/definitions/mars/grib.msmm.fcmin.def @@ -5,11 +5,9 @@ alias mars.number = perturbationNumber; alias mars.origin = centre; alias mars.method = methodNumber; - -if (class is "od") { alias mars.system = systemNumber; } -if (class is "me") { alias mars.system = systemNumber; } -if (class is "en") { alias mars.system = systemNumber; } -if (class is "c3") { alias mars.system = systemNumber; } +if (class is "od" || class is "me" || class is "en" || class is "c3") { + alias mars.system = systemNumber; +} # See ECC-624 if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { diff --git a/definitions/mars/grib.msmm.fcstdev.def b/definitions/mars/grib.msmm.fcstdev.def index 3a563515b..86ac736a4 100644 --- a/definitions/mars/grib.msmm.fcstdev.def +++ b/definitions/mars/grib.msmm.fcstdev.def @@ -7,10 +7,9 @@ unalias mars.step; alias mars.method = methodNumber; -if (class is "od") { alias mars.system = systemNumber; } -if (class is "me") { alias mars.system = systemNumber; } -if (class is "en") { alias mars.system = systemNumber; } -if (class is "c3") { alias mars.system = systemNumber; } +if (class is "od" || class is "me" || class is "en" || class is "c3") { + alias mars.system = systemNumber; +} # See ECC-624 if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { diff --git a/definitions/mars/grib.msmm.hcmean.def b/definitions/mars/grib.msmm.hcmean.def index cbdd6704a..9fd3f4b70 100644 --- a/definitions/mars/grib.msmm.hcmean.def +++ b/definitions/mars/grib.msmm.hcmean.def @@ -5,10 +5,9 @@ unalias mars.step; alias mars.origin = centre; alias mars.method = methodNumber; -if (class is "od") { alias mars.system = systemNumber; } -if (class is "me") { alias mars.system = systemNumber; } -if (class is "en") { alias mars.system = systemNumber; } -if (class is "c3") { alias mars.system = systemNumber; } +if (class is "od" || class is "me" || class is "en" || class is "c3") { + alias mars.system = systemNumber; +} # See ECC-624 if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) { diff --git a/definitions/mars/grib.ocea.an.def b/definitions/mars/grib.ocea.an.def index d682c50bd..13ff8360e 100644 --- a/definitions/mars/grib.ocea.an.def +++ b/definitions/mars/grib.ocea.an.def @@ -1,5 +1,6 @@ alias mars.number = perturbationNumber; alias mars.method = methodNumber; -if (class is "od") { alias mars.system = systemNumber; } -if (class is "me") { alias mars.system = systemNumber; } -if (class is "en") { alias mars.system = systemNumber; } + +if (class is "od" || class is "me" || class is "en") { + alias mars.system = systemNumber; +} diff --git a/definitions/mars/grib.ocea.ff.def b/definitions/mars/grib.ocea.ff.def index d682c50bd..5a03a2e58 100644 --- a/definitions/mars/grib.ocea.ff.def +++ b/definitions/mars/grib.ocea.ff.def @@ -1,5 +1,5 @@ alias mars.number = perturbationNumber; alias mars.method = methodNumber; -if (class is "od") { alias mars.system = systemNumber; } -if (class is "me") { alias mars.system = systemNumber; } -if (class is "en") { alias mars.system = systemNumber; } +if (class is "od" || class is "me" || class is "en") { + alias mars.system = systemNumber; +} diff --git a/definitions/mars/grib.ocea.fx.def b/definitions/mars/grib.ocea.fx.def index d682c50bd..5a03a2e58 100644 --- a/definitions/mars/grib.ocea.fx.def +++ b/definitions/mars/grib.ocea.fx.def @@ -1,5 +1,5 @@ alias mars.number = perturbationNumber; alias mars.method = methodNumber; -if (class is "od") { alias mars.system = systemNumber; } -if (class is "me") { alias mars.system = systemNumber; } -if (class is "en") { alias mars.system = systemNumber; } +if (class is "od" || class is "me" || class is "en") { + alias mars.system = systemNumber; +} diff --git a/definitions/mars/grib.ocea.of.def b/definitions/mars/grib.ocea.of.def index d682c50bd..5a03a2e58 100644 --- a/definitions/mars/grib.ocea.of.def +++ b/definitions/mars/grib.ocea.of.def @@ -1,5 +1,5 @@ alias mars.number = perturbationNumber; alias mars.method = methodNumber; -if (class is "od") { alias mars.system = systemNumber; } -if (class is "me") { alias mars.system = systemNumber; } -if (class is "en") { alias mars.system = systemNumber; } +if (class is "od" || class is "me" || class is "en") { + alias mars.system = systemNumber; +} diff --git a/definitions/mars/grib.ocea.or.def b/definitions/mars/grib.ocea.or.def index d682c50bd..5a03a2e58 100644 --- a/definitions/mars/grib.ocea.or.def +++ b/definitions/mars/grib.ocea.or.def @@ -1,5 +1,5 @@ alias mars.number = perturbationNumber; alias mars.method = methodNumber; -if (class is "od") { alias mars.system = systemNumber; } -if (class is "me") { alias mars.system = systemNumber; } -if (class is "en") { alias mars.system = systemNumber; } +if (class is "od" || class is "me" || class is "en") { + alias mars.system = systemNumber; +} diff --git a/definitions/mars/grib.swmm.fcmax.def b/definitions/mars/grib.swmm.fcmax.def index a628fb1a2..864aed20f 100644 --- a/definitions/mars/grib.swmm.fcmax.def +++ b/definitions/mars/grib.swmm.fcmax.def @@ -4,6 +4,6 @@ alias mars.number = perturbationNumber; unalias mars.step; alias mars.method = methodNumber; -if (class is "od") { alias mars.system = systemNumber; } -if (class is "me") { alias mars.system = systemNumber; } -if (class is "en") { alias mars.system = systemNumber; } +if (class is "od" || class is "me" || class is "en") { + alias mars.system = systemNumber; +} diff --git a/definitions/mars/grib.swmm.fcmean.def b/definitions/mars/grib.swmm.fcmean.def index a628fb1a2..864aed20f 100644 --- a/definitions/mars/grib.swmm.fcmean.def +++ b/definitions/mars/grib.swmm.fcmean.def @@ -4,6 +4,6 @@ alias mars.number = perturbationNumber; unalias mars.step; alias mars.method = methodNumber; -if (class is "od") { alias mars.system = systemNumber; } -if (class is "me") { alias mars.system = systemNumber; } -if (class is "en") { alias mars.system = systemNumber; } +if (class is "od" || class is "me" || class is "en") { + alias mars.system = systemNumber; +} diff --git a/definitions/mars/grib.swmm.fcmin.def b/definitions/mars/grib.swmm.fcmin.def index a628fb1a2..864aed20f 100644 --- a/definitions/mars/grib.swmm.fcmin.def +++ b/definitions/mars/grib.swmm.fcmin.def @@ -4,6 +4,6 @@ alias mars.number = perturbationNumber; unalias mars.step; alias mars.method = methodNumber; -if (class is "od") { alias mars.system = systemNumber; } -if (class is "me") { alias mars.system = systemNumber; } -if (class is "en") { alias mars.system = systemNumber; } +if (class is "od" || class is "me" || class is "en") { + alias mars.system = systemNumber; +} diff --git a/definitions/mars/grib.swmm.fcstdev.def b/definitions/mars/grib.swmm.fcstdev.def index a628fb1a2..864aed20f 100644 --- a/definitions/mars/grib.swmm.fcstdev.def +++ b/definitions/mars/grib.swmm.fcstdev.def @@ -4,6 +4,6 @@ alias mars.number = perturbationNumber; unalias mars.step; alias mars.method = methodNumber; -if (class is "od") { alias mars.system = systemNumber; } -if (class is "me") { alias mars.system = systemNumber; } -if (class is "en") { alias mars.system = systemNumber; } +if (class is "od" || class is "me" || class is "en") { + alias mars.system = systemNumber; +}