Skip to content

Commit fd569f1

Browse files
committed
eckit::geo iterator force-init main without tools
1 parent 37b81b0 commit fd569f1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/geo_iterator/grib_iterator.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "eccodes_config.h"
1616

1717
#if defined(HAVE_ECKIT_GEO)
18+
#include "eckit/runtime/Main.h"
19+
1820
#include "eccodes/geo/GeoIterator.h"
1921

2022
// eccodes macros conflict with eckit
@@ -110,6 +112,17 @@ grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int
110112
#if defined(HAVE_ECKIT_GEO)
111113
static const auto* eckit_geo = codes_getenv("ECCODES_ECKIT_GEO");
112114
if (eckit_geo != nullptr && strcmp(eckit_geo, "1") == 0) {
115+
struct InitMain
116+
{
117+
InitMain()
118+
{
119+
if (!eckit::Main::ready()) {
120+
static char* argv[]{ const_cast<char*>("grib_iterator_new") };
121+
eckit::Main::initialise(1, argv);
122+
}
123+
}
124+
} static const init_main;
125+
113126
i->iterator = new eccodes::geo::GeoIterator(const_cast<grib_handle*>(ch), flags);
114127
}
115128
else

0 commit comments

Comments
 (0)