mirror of https://github.com/ecmwf/eccodes.git
ECC-1280: Check to avoid divide by zero
This commit is contained in:
parent
76d82b7c4b
commit
d00c94e4ce
|
@ -254,17 +254,19 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
|
||||||
else {
|
else {
|
||||||
r_eq = r_pol = radius * 0.001; /*conv to km*/
|
r_eq = r_pol = radius * 0.001; /*conv to km*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nrInRadiusOfEarth == 0) {
|
||||||
|
grib_context_log(h->context, GRIB_LOG_ERROR, "Key %s must be greater than zero", sNrInRadiusOfEarth);
|
||||||
|
return GRIB_GEOCALCULUS_PROBLEM;
|
||||||
|
}
|
||||||
|
|
||||||
angular_size = 2.0 * asin(1.0 / nrInRadiusOfEarth);
|
angular_size = 2.0 * asin(1.0 / nrInRadiusOfEarth);
|
||||||
height = nrInRadiusOfEarth * r_eq;
|
height = nrInRadiusOfEarth * r_eq;
|
||||||
|
|
||||||
lap = latOfSubSatellitePointInDegrees;
|
lap = latOfSubSatellitePointInDegrees;
|
||||||
lop = lonOfSubSatellitePointInDegrees;
|
lop = lonOfSubSatellitePointInDegrees;
|
||||||
/* lap *= 1e-6; // default scaling factor */
|
|
||||||
/* lop *= 1e-6; */
|
|
||||||
if (lap != 0.0)
|
if (lap != 0.0)
|
||||||
return GRIB_NOT_IMPLEMENTED;
|
return GRIB_NOT_IMPLEMENTED;
|
||||||
/*lap *= DEG2RAD;*/
|
|
||||||
/*lop *= DEG2RAD;*/
|
|
||||||
|
|
||||||
/*orient_angle = orientationInDegrees;*/
|
/*orient_angle = orientationInDegrees;*/
|
||||||
/* if (orient_angle != 0.0) return GRIB_NOT_IMPLEMENTED; */
|
/* if (orient_angle != 0.0) return GRIB_NOT_IMPLEMENTED; */
|
||||||
|
@ -275,7 +277,10 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
|
||||||
y0 = Yo;
|
y0 = Yo;
|
||||||
|
|
||||||
/* adjustBadlyEncodedEcmwfGribs(h, &nx, &ny, &dx, &dy, &xp, &yp); */
|
/* adjustBadlyEncodedEcmwfGribs(h, &nx, &ny, &dx, &dy, &xp, &yp); */
|
||||||
|
if (dx == 0 || dy == 0) {
|
||||||
|
grib_context_log(h->context, GRIB_LOG_ERROR, "Keys %s and %s must be greater than zero", sDx, sDy);
|
||||||
|
return GRIB_GEOCALCULUS_PROBLEM;
|
||||||
|
}
|
||||||
rx = angular_size / dx;
|
rx = angular_size / dx;
|
||||||
ry = (r_pol / r_eq) * angular_size / dy;
|
ry = (r_pol / r_eq) * angular_size / dy;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue