Print name of Geoiterator in error messages

This commit is contained in:
Shahram Najm 2022-02-06 17:45:29 +00:00
parent b6c72d346c
commit 9164be0020
7 changed files with 35 additions and 33 deletions

View File

@ -9,9 +9,8 @@
*/
/***************************************************************************
* Jean Baptiste Filippi - 01.11.2005 *
* Enrico Fucile
* *
* Jean Baptiste Filippi - 01.11.2005 *
* Enrico Fucile *
***************************************************************************/
#include "grib_api_internal.h"
@ -47,12 +46,12 @@ grib_iterator* grib_iterator_factory(grib_handle* h, grib_arguments* args, unsig
*ret = grib_iterator_init(it, h, args);
if (*ret == GRIB_SUCCESS)
return it;
grib_context_log(h->context, GRIB_LOG_DEBUG, "grib_iterator_factory: error %d instantiating iterator %s", *ret, table[i].type);
grib_context_log(h->context, GRIB_LOG_ERROR, "Geoiterator factory: error %d instantiating iterator %s", *ret, table[i].type);
grib_iterator_delete(it);
return NULL;
}
grib_context_log(h->context, GRIB_LOG_ERROR, "grib_iterator_factory : Unknown type : %s for iterator", type);
grib_context_log(h->context, GRIB_LOG_ERROR, "Geoiterator factory: Unknown type : %s for iterator", type);
return NULL;
}

View File

@ -190,7 +190,7 @@ static int iterate_reduced_gaussian_subarea_legacy(grib_iterator* iter, grib_han
if (iter->e >= iter->nv) {
size_t np = count_subarea_points(h, get_reduced_row, pl, plsize, lon_first, lon_last);
grib_context_log(h->context, GRIB_LOG_ERROR,
"Reduced Gaussian iterator (sub-area legacy). Num points=%ld, size(values)=%ld", np, iter->nv);
"Reduced Gaussian Geoiterator (sub-area legacy). Num points=%ld, size(values)=%ld", np, iter->nv);
return GRIB_WRONG_GRID;
}
@ -251,7 +251,7 @@ static int iterate_reduced_gaussian_subarea_algorithm2(grib_iterator* iter, grib
/* Only print error message on the second pass */
size_t np = count_subarea_points(h, get_reduced_row, pl, plsize, lon_first, lon_last);
grib_context_log(h->context, GRIB_LOG_ERROR,
"Reduced Gaussian iterator (sub-area). Num points=%ld, size(values)=%ld", np, iter->nv);
"Reduced Gaussian Geoiterator (sub-area). Num points=%ld, size(values)=%ld", np, iter->nv);
return GRIB_WRONG_GRID;
}
self->los[iter->e] = lon2;

View File

@ -98,8 +98,10 @@ static double* pointer_to_data(unsigned int i, unsigned int j,
return NULL;
}
/* Apply the scanning mode flags which may require data array to be transformed */
/* to standard west-to-east (+i) south-to-north (+j) mode */
/* Apply the scanning mode flags which may require data array to be transformed
* to standard west-to-east (+i) south-to-north (+j) mode.
* The data array passed in should have 'numPoints' elements.
*/
int transform_iterator_data(grib_context* context, double* data,
long iScansNegatively, long jScansPositively,
long jPointsAreConsecutive, long alternativeRowScanning,
@ -118,11 +120,11 @@ int transform_iterator_data(grib_context* context, double* data,
if (!iScansNegatively && !jScansPositively && !jPointsAreConsecutive && !alternativeRowScanning &&
nx > 0 && ny > 0) {
/* regular grid +i -j: convert from we:ns to we:sn */
/* Regular grid +i -j: convert from we:ns to we:sn */
size_t row_size = ((size_t)nx) * sizeof(double);
data2 = (double*)grib_context_malloc(context, row_size);
if (!data2) {
grib_context_log(context, GRIB_LOG_ERROR, "Error allocating %ld bytes", row_size);
grib_context_log(context, GRIB_LOG_ERROR, "Geoiterator data: Error allocating %ld bytes", row_size);
return GRIB_OUT_OF_MEMORY;
}
for (iy = 0; iy < ny / 2; iy++) {
@ -135,18 +137,18 @@ int transform_iterator_data(grib_context* context, double* data,
}
if (nx < 1 || ny < 1) {
grib_context_log(context, GRIB_LOG_ERROR, "Invalid values for Nx and/or Ny");
grib_context_log(context, GRIB_LOG_ERROR, "Geoiterator data: Invalid values for Nx and/or Ny");
return GRIB_GEOCALCULUS_PROBLEM;
}
data2 = (double*)grib_context_malloc(context, numPoints * sizeof(double));
if (!data2) {
grib_context_log(context, GRIB_LOG_ERROR, "Error allocating %ld bytes", numPoints * sizeof(double));
grib_context_log(context, GRIB_LOG_ERROR, "Geoiterator data: Error allocating %ld bytes", numPoints * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
pData0 = data2;
for (iy = 0; iy < ny; iy++) {
long deltaX = 0;
pData1 = pointer_to_data(0, iy, iScansNegatively, jScansPositively, jPointsAreConsecutive, alternativeRowScanning, nx, ny, data);
pData1 = pointer_to_data(0, iy, iScansNegatively, jScansPositively, jPointsAreConsecutive, alternativeRowScanning, nx, ny, data);
if (!pData1) {
grib_context_free(context, data2);
return GRIB_GEOCALCULUS_PROBLEM;
@ -191,13 +193,13 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
return err;
if (numberOfPoints != dli) {
grib_context_log(h->context, GRIB_LOG_ERROR, "%s != size(%s) (%ld!=%ld)",
grib_context_log(h->context, GRIB_LOG_ERROR, "Geoiterator: %s != size(%s) (%ld!=%ld)",
s_numPoints, s_rawData, numberOfPoints, dli);
return GRIB_WRONG_GRID;
}
iter->nv = dli;
if (iter->nv == 0) {
grib_context_log(h->context, GRIB_LOG_ERROR, "size(%s) is %ld", s_rawData, dli);
grib_context_log(h->context, GRIB_LOG_ERROR, "Geoiterator: size(%s) is %ld", s_rawData, dli);
return GRIB_WRONG_GRID;
}
iter->data = (double*)grib_context_malloc(h->context, (iter->nv) * sizeof(double));

View File

@ -205,12 +205,12 @@ static int init_sphere(grib_handle* h,
/* Allocate latitude and longitude arrays */
self->lats = (double*)grib_context_malloc(h->context, nv * sizeof(double));
if (!self->lats) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", nv * sizeof(double));
grib_context_log(h->context, GRIB_LOG_ERROR, "Lambert conformal Geoiterator: Error allocating %ld bytes", nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
self->lons = (double*)grib_context_malloc(h->context, nv * sizeof(double));
if (!self->lats) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", nv * sizeof(double));
grib_context_log(h->context, GRIB_LOG_ERROR, "Lambert conformal Geoiterator: Error allocating %ld bytes", nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
@ -302,7 +302,7 @@ static int init_oblate(grib_handle* h,
} else {
con = latFirstInRadians * ns;
if (con <= 0) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Point cannot be projected");
grib_context_log(h->context, GRIB_LOG_ERROR, "Lambert conformal Geoiterator: Point cannot be projected");
return GRIB_GEOCALCULUS_PROBLEM;
}
rh1 = 0;
@ -316,12 +316,12 @@ static int init_oblate(grib_handle* h,
/* Allocate latitude and longitude arrays */
self->lats = (double*)grib_context_malloc(h->context, nv * sizeof(double));
if (!self->lats) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", nv * sizeof(double));
grib_context_log(h->context, GRIB_LOG_ERROR, "Lambert conformal Geoiterator: Error allocating %ld bytes", nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
self->lons = (double*)grib_context_malloc(h->context, nv * sizeof(double));
if (!self->lats) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", nv * sizeof(double));
grib_context_log(h->context, GRIB_LOG_ERROR, "Lambert conformal Geoiterator: Error allocating %ld bytes", nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
@ -351,7 +351,8 @@ static int init_oblate(grib_handle* h,
ts = pow((rh1 / (earthMajorAxisInMetres * F)), con);
latRad = compute_phi(e, ts, &err);
if (err) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Failed to compute the latitude angle, phi2, for the inverse");
grib_context_log(h->context, GRIB_LOG_ERROR,
"Lambert conformal Geoiterator: Failed to compute the latitude angle, phi2, for the inverse");
grib_context_free(h->context, self->lats);
grib_context_free(h->context, self->lons);
return err;
@ -414,7 +415,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
}
if (iter->nv != nx * ny) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Wrong number of points (%ld!=%ldx%ld)", iter->nv, nx, ny);
grib_context_log(h->context, GRIB_LOG_ERROR, "Lambert conformal Geoiterator: Wrong number of points (%ld!=%ldx%ld)", iter->nv, nx, ny);
return GRIB_WRONG_GRID;
}
@ -446,7 +447,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
/* Standard Parallels cannot be equal and on opposite sides of the equator */
if (fabs(Latin1InDegrees + Latin2InDegrees) < EPSILON) {
grib_context_log(h->context, GRIB_LOG_ERROR,
"Cannot have equal latitudes for standard parallels on opposite sides of equator");
"Lambert conformal Geoiterator: Cannot have equal latitudes for standard parallels on opposite sides of equator");
return GRIB_WRONG_GRID;
}

View File

@ -202,7 +202,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
}
if (south > north) {
grib_context_log(h->context, GRIB_LOG_ERROR,
"First and last latitudes are inconsistent with scanning order: lat1=%g, lat2=%g jScansPositively=%ld",
"Lat/Lon Geoiterator: First and last latitudes are inconsistent with scanning order: lat1=%g, lat2=%g jScansPositively=%ld",
lat1, lat2, jScansPositively);
return GRIB_WRONG_GRID;
}

View File

@ -171,7 +171,7 @@ static int init_mercator(grib_handle* h,
/* Forward projection: convert lat,lon to x,y */
if (fabs(fabs(latFirstInRadians) - M_PI_2) <= EPSILON) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Mercator: Transformation cannot be computed at the poles");
grib_context_log(h->context, GRIB_LOG_ERROR, "Mercator Geoiterator: Transformation cannot be computed at the poles");
return GRIB_GEOCALCULUS_PROBLEM;
}
else {
@ -186,12 +186,12 @@ static int init_mercator(grib_handle* h,
/* Allocate latitude and longitude arrays */
self->lats = (double*)grib_context_malloc(h->context, nv * sizeof(double));
if (!self->lats) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", nv * sizeof(double));
grib_context_log(h->context, GRIB_LOG_ERROR, "Mercator Geoiterator: Error allocating %ld bytes", nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
self->lons = (double*)grib_context_malloc(h->context, nv * sizeof(double));
if (!self->lats) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", nv * sizeof(double));
grib_context_log(h->context, GRIB_LOG_ERROR, "Mercator Geoiterator: Error allocating %ld bytes", nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
@ -210,7 +210,7 @@ static int init_mercator(grib_handle* h,
ts = exp(-_y / (earthMajorAxisInMetres * m1));
latRad = compute_phi(e, ts, &err);
if (err) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Mercator: Failed to compute the latitude angle, phi2, for the inverse");
grib_context_log(h->context, GRIB_LOG_ERROR, "Mercator Geoiterator: Failed to compute the latitude angle, phi2, for the inverse");
grib_context_free(h->context, self->lats);
grib_context_free(h->context, self->lons);
return err;
@ -270,7 +270,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
}
if (iter->nv != ni * nj) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Wrong number of points (%ld!=%ldx%ld)", iter->nv, ni, nj);
grib_context_log(h->context, GRIB_LOG_ERROR, "Mercator Geoiterator: Wrong number of points (%ld!=%ldx%ld)", iter->nv, ni, nj);
return GRIB_WRONG_GRID;
}

View File

@ -162,7 +162,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
return ret;
if (iter->nv != nx * ny) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Wrong number of points (%ld!=%ldx%ld)", iter->nv, nx, ny);
grib_context_log(h->context, GRIB_LOG_ERROR, "Polar stereographic Geoiterator: Wrong number of points (%ld!=%ldx%ld)", iter->nv, nx, ny);
return GRIB_WRONG_GRID;
}
if ((ret = grib_get_double_internal(h, s_latFirstInDegrees, &latFirstInDegrees)) != GRIB_SUCCESS)
@ -242,12 +242,12 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
}
self->lats = (double*)grib_context_malloc(h->context, iter->nv * sizeof(double));
if (!self->lats) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", iter->nv * sizeof(double));
grib_context_log(h->context, GRIB_LOG_ERROR, "Polar stereographic Geoiterator: Error allocating %ld bytes", iter->nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
self->lons = (double*)grib_context_malloc(h->context, iter->nv * sizeof(double));
if (!self->lats) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", iter->nv * sizeof(double));
grib_context_log(h->context, GRIB_LOG_ERROR, "Polar stereographic Geoiterator: Error allocating %ld bytes", iter->nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
lats = self->lats;