From e84b3d9724a16c9d5e2a784cb1a5ca3a813dccb3 Mon Sep 17 00:00:00 2001 From: Pedro Maciel Date: Wed, 20 Nov 2024 21:43:53 +0000 Subject: [PATCH] eckit::geo iterator force-init main without tools --- src/geo_iterator/grib_iterator.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/geo_iterator/grib_iterator.cc b/src/geo_iterator/grib_iterator.cc index 4b08c5d93..cc3187c75 100644 --- a/src/geo_iterator/grib_iterator.cc +++ b/src/geo_iterator/grib_iterator.cc @@ -15,6 +15,8 @@ #include "eccodes_config.h" #if defined(HAVE_ECKIT_GEO) + #include "eckit/runtime/Main.h" + #include "eccodes/geo/GeoIterator.h" // eccodes macros conflict with eckit @@ -110,6 +112,17 @@ grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int #if defined(HAVE_ECKIT_GEO) static const auto* eckit_geo = codes_getenv("ECCODES_ECKIT_GEO"); if (eckit_geo != nullptr && strcmp(eckit_geo, "1") == 0) { + struct InitMain + { + InitMain() + { + if (!eckit::Main::ready()) { + static char* argv[]{ const_cast("grib_iterator_new") }; + eckit::Main::initialise(1, argv); + } + } + } static const init_main; + i->iterator = new eccodes::geo::GeoIterator(const_cast(ch), flags); } else