From 76418fb63b8df185a87a642a5b94c165ac5e866f 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