mirror of https://github.com/ecmwf/eccodes.git
ECC-1331: Better to fail rather than generate wrong results
This commit is contained in:
parent
286ea11744
commit
4d927258ac
|
@ -134,60 +134,66 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
|
|||
|
||||
grib_iterator_polar_stereographic* self = (grib_iterator_polar_stereographic*)iter;
|
||||
|
||||
const char* sradius = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* snx = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* sny = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* slatFirstInDegrees = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* slonFirstInDegrees = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* ssouthPoleOnPlane = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* scentralLongitude = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* scentralLatitude = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* sDx = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* sDy = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* siScansNegatively = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* sjScansPositively = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* sjPointsAreConsecutive = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* salternativeRowScanning = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* s_radius = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* s_nx = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* s_ny = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* s_latFirstInDegrees = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* s_lonFirstInDegrees = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* s_southPoleOnPlane = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* s_centralLongitude = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* s_centralLatitude = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* s_Dx = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* s_Dy = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* s_iScansNegatively = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* s_jScansPositively = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* s_jPointsAreConsecutive = grib_arguments_get_name(h, args, self->carg++);
|
||||
const char* s_alternativeRowScanning = grib_arguments_get_name(h, args, self->carg++);
|
||||
|
||||
if (grib_is_earth_oblate(h)) {
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR, "Polar stereographic only supported for spherical earth.");
|
||||
return GRIB_GEOCALCULUS_PROBLEM;
|
||||
}
|
||||
|
||||
if ((ret = grib_get_double_internal(h, sradius, &radius)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_double_internal(h, s_radius, &radius)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_long_internal(h, snx, &nx)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_long_internal(h, s_nx, &nx)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_long_internal(h, sny, &ny)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_long_internal(h, s_ny, &ny)) != GRIB_SUCCESS)
|
||||
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);
|
||||
return GRIB_WRONG_GRID;
|
||||
}
|
||||
if ((ret = grib_get_double_internal(h, slatFirstInDegrees, &latFirstInDegrees)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_double_internal(h, s_latFirstInDegrees, &latFirstInDegrees)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_double_internal(h, slonFirstInDegrees, &lonFirstInDegrees)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_double_internal(h, s_lonFirstInDegrees, &lonFirstInDegrees)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_long_internal(h, ssouthPoleOnPlane, &southPoleOnPlane)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_long_internal(h, s_southPoleOnPlane, &southPoleOnPlane)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_long_internal(h, scentralLongitude, ¢ralLongitudeInDegrees)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_long_internal(h, s_centralLongitude, ¢ralLongitudeInDegrees)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_long_internal(h, scentralLatitude, ¢ralLatitudeInDegrees)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_long_internal(h, s_centralLatitude, ¢ralLatitudeInDegrees)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_double_internal(h, sDx, &Dx)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_double_internal(h, s_Dx, &Dx)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_double_internal(h, sDy, &Dy)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_double_internal(h, s_Dy, &Dy)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_long_internal(h, sjPointsAreConsecutive, &jPointsAreConsecutive)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_long_internal(h, s_jPointsAreConsecutive, &jPointsAreConsecutive)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_long_internal(h, sjScansPositively, &jScansPositively)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_long_internal(h, s_jScansPositively, &jScansPositively)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_long_internal(h, siScansNegatively, &iScansNegatively)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_long_internal(h, s_iScansNegatively, &iScansNegatively)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_long_internal(h, salternativeRowScanning, &alternativeRowScanning)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_long_internal(h, s_alternativeRowScanning, &alternativeRowScanning)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
|
||||
if (alternativeRowScanning) {
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR, "Polar stereographic not supported when alternativeRowScanning=1 "
|
||||
"i.e., When adjacent rows scan in the opposite direction");
|
||||
return GRIB_GEOCALCULUS_PROBLEM;
|
||||
}
|
||||
|
||||
centralLongitude = centralLongitudeInDegrees * DEG2RAD;
|
||||
centralLatitude = centralLatitudeInDegrees * DEG2RAD;
|
||||
lonFirst = lonFirstInDegrees * DEG2RAD;
|
||||
|
|
Loading…
Reference in New Issue