Skip to content

Commit

Permalink
eckit::geo gridType=healpix/unstructured_grid
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaciel committed Oct 11, 2024
1 parent 3b61372 commit f3fa1ca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/grib_iterator_class_healpix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args) {
auto* self = (grib_iterator_healpix*)iter;
int err = GRIB_SUCCESS;

const auto* ITER = "HEALPix Geoiterator";
#define ITER "HEALPix Geoiterator"

const auto* s_Nside = grib_arguments_get_name(h, args, self->carg++);
const auto* s_Order = grib_arguments_get_name(h, args, self->carg++);
Expand Down Expand Up @@ -127,6 +127,9 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args) {
self->iter.reset(self->healpix->cbegin().release());
self->end.reset(self->healpix->cend().release());
}
catch (std::exception& e) {
grib_context_log(h->context, GRIB_LOG_ERROR, ITER ": %s", e.what());
}
catch (...) {
return GRIB_INTERNAL_ERROR;
}
Expand Down
23 changes: 16 additions & 7 deletions src/grib_iterator_class_unstructured.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,23 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args) {
return GRIB_GEOCALCULUS_PROBLEM;
}

// assign coordinates
auto [lats, lons] = std::unique_ptr<const eckit::geo::Grid>(eckit::geo::GridFactory::build(*spec))->to_latlons();
if (lats.size() != lons.size() || lats.size() != iter->nv) {
return GRIB_WRONG_GRID;
try {
// assign coordinates
auto [lats, lons] =
std::unique_ptr<const eckit::geo::Grid>(eckit::geo::GridFactory::build(*spec))->to_latlons();
if (lats.size() != lons.size() || lats.size() != iter->nv) {
return GRIB_WRONG_GRID;
}

lats.swap(self->lats);
lons.swap(self->lons);
}
catch (std::exception& e) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Unstructured Geoiterator: %s", e.what());
}
catch (...) {
return GRIB_INTERNAL_ERROR;
}

lats.swap(self->lats);
lons.swap(self->lons);

iter->e = -1;
return err;
Expand Down

0 comments on commit f3fa1ca

Please sign in to comment.