ECC-1207: GRIB2: BiFourier packing error

This commit is contained in:
Shahram Najm 2021-02-25 21:17:24 +00:00
parent bb092a1663
commit e4edb7b81d
2 changed files with 12 additions and 12 deletions

View File

@ -411,19 +411,22 @@ static double laplam(bif_trunc_t* bt, const double val[])
}
lmax = l;
if (lmax == 0)
return 0.;
if (lmax == 0) { /* ECC-1207 */
free(itab1);
free(itab2);
return 0.;
}
if (lmax < 0) {
free(itab1);
free(itab2);
Assert(!"data_g2bifourier_packing::laplam: lmax must be >= 0");
return 0;
}
/*
* Now, itab2 contains all possible values of i*i+j*j, and itab1 contains
* the rank of all i*i+j*j
*/
if (lmax <= 0) {
free(itab1);
free(itab2);
Assert(!"data_g2bifourier_packing::laplam: lmax must be > 0");
return 0;
}
znorm = (double*)calloc(lmax, sizeof(double));
zw = (double*)malloc(sizeof(double) * lmax);

View File

@ -700,7 +700,7 @@ int main(int argc, char* argv[])
trunc[1].trunc = 77;
trunc[1].subtrunc = 77;
trunc[1].subnsmax = NSTRON;
trunc[2].subnmsmax = NSTRON;
trunc[1].subnmsmax = NSTRON;
trunc[1].len = 4 * (NSMAX + 1) * (NMSMAX + 1);
trunc[1].values = (double*)malloc(sizeof(double) * trunc[1].len);
trunc[1].name = "rectangle_rectangle";
@ -715,8 +715,6 @@ int main(int argc, char* argv[])
trunc[2].values = (double*)values;
trunc[2].name = "ellipse_full";
for (itrunc = 0; itrunc < 3; itrunc++) {
for (igrid = 0; igrid < 3; igrid++) {
GRIB_CHECK(((h = grib_handle_new_from_samples(NULL, "lambert_bf_grib2")) == NULL), 0);
@ -804,7 +802,6 @@ int main(int argc, char* argv[])
long int nsmax, nmsmax;
char geometry[128];
sprintf(f, "lam_bf_%s_%s.grib", grids[igrid], trunc[itrunc].name);
fp = fopen(f, "rb");
h = grib_handle_new_from_file(0, fp, &err);