mirror of https://github.com/ecmwf/eccodes.git
Remove _numberOfValues bifourier_truncation from
definitions/grib2/template.5.53.def (avoid warning from grib_dump -O). Check GRIB messages produced by tests/lam_bf.c & tests/lam_gp.c. Fix warning issued by cppcheck on src/grib_accessor_class_data_g2bifourier_packing.c.
This commit is contained in:
parent
711ce42192
commit
cc92f7e530
|
@ -18,8 +18,6 @@ transient computeLaplacianOperator=1 : hidden;
|
|||
codetable[1] biFourierSubTruncationType ('3.99.table',masterDir,localDir) : dump;
|
||||
unsigned[1] biFourierDoNotPackAxes = 0 : dump;
|
||||
|
||||
# TODO: What is I?
|
||||
meta _numberOfValues bifourier_truncation(I,J,numberOfValues): read_only;
|
||||
|
||||
constant laplacianScalingFactorUnset = -2147483647;
|
||||
signed[4] laplacianScalingFactor : edition_specific ;
|
||||
|
|
|
@ -302,7 +302,11 @@ static void diamond (long ni, long nj, long itrunc[], long jtrunc[])
|
|||
do { \
|
||||
insub = (i <= bt->sub_i) && (j <= bt->sub_j); \
|
||||
if (insub) \
|
||||
insub = (i <= bt->itruncation_sub[j]) && (j <= bt->jtruncation_sub[i]); \
|
||||
{ \
|
||||
int insubi = (i <= bt->itruncation_sub[j]); \
|
||||
int insubj = (j <= bt->jtruncation_sub[i]); \
|
||||
insub = insubi && insubj; \
|
||||
} \
|
||||
if (bt->keepaxes) \
|
||||
insub = insub || (i == 0) || (j == 0); \
|
||||
} while (0)
|
||||
|
|
|
@ -111,12 +111,10 @@ int grib_jasper_encode(grib_context *c, j2k_encode_helper *helper)
|
|||
image.clrspc_ = JAS_CLRSPC_SGRAY;
|
||||
image.cmprof_ = 0;
|
||||
|
||||
#if JASPER_VERSION_MAJOR == 1
|
||||
/* ECC-396: Support for Jasper 2.0
|
||||
* Jasper version 1 had the 'inmem_' data member but
|
||||
* version 2 removed it from the interface */
|
||||
image.inmem_ = 1;
|
||||
#endif
|
||||
|
||||
cmpt.tlx_ = 0;
|
||||
cmpt.tly_ = 0;
|
||||
|
|
|
@ -729,6 +729,71 @@ int main (int argc, char * argv[])
|
|||
}
|
||||
|
||||
GRIB_CHECK (grib_handle_delete (h), 0);
|
||||
|
||||
/* Check message correctness */
|
||||
{
|
||||
char f[128];
|
||||
FILE * fp;
|
||||
double * vals;
|
||||
double norm = 0.;
|
||||
int i, err;
|
||||
size_t values_len, geometry_len;
|
||||
long int LxInMetres, LyInMetres, LuxInMetres, LuyInMetres, LcxInMetres, LcyInMetres;
|
||||
long int nsmax, nmsmax;
|
||||
char geometry[128];
|
||||
|
||||
|
||||
sprintf (f, "lam_bf_%s.grib", grids[igrid]);
|
||||
fp = fopen (f, "r");
|
||||
h = grib_handle_new_from_file (0, fp, &err);
|
||||
vals = (double *)malloc (sizeof (double) * ILCHAM);
|
||||
values_len = ILCHAM;
|
||||
GRIB_CHECK (grib_get_double_array (h, "values", vals, &values_len), 0);
|
||||
for (i = 0; i < ILCHAM; i++)
|
||||
norm += (values[i] - vals[i]) * (values[i] - vals[i]);
|
||||
norm = sqrt (norm / ILCHAM);
|
||||
free (vals);
|
||||
|
||||
if (norm > 0.0001)
|
||||
{
|
||||
printf ("Error too large !\n");
|
||||
abort ();
|
||||
}
|
||||
fclose (fp);
|
||||
|
||||
GRIB_CHECK (grib_get_long (h, "biFourierResolutionParameterN", &nsmax), 0);
|
||||
GRIB_CHECK (grib_get_long (h, "biFourierResolutionParameterM", &nmsmax), 0);
|
||||
|
||||
GRIB_CHECK (grib_get_long (h, "LxInMetres", &LxInMetres), 0);
|
||||
GRIB_CHECK (grib_get_long (h, "LyInMetres", &LyInMetres), 0);
|
||||
|
||||
GRIB_CHECK (grib_get_long (h, "LuxInMetres", &LuxInMetres), 0);
|
||||
GRIB_CHECK (grib_get_long (h, "LuyInMetres", &LuyInMetres), 0);
|
||||
|
||||
GRIB_CHECK (grib_get_long (h, "LcxInMetres", &LcxInMetres), 0);
|
||||
GRIB_CHECK (grib_get_long (h, "LcyInMetres", &LcyInMetres), 0);
|
||||
|
||||
if (LxInMetres != 2000 || LyInMetres != 2000 || LuxInMetres != 1800 ||
|
||||
LuyInMetres != 1800 || LcxInMetres != 100 || LcyInMetres != 100 ||
|
||||
NSMAX != nsmax || NMSMAX != nmsmax)
|
||||
{
|
||||
printf ("Geometry is incorrect\n");
|
||||
abort ();
|
||||
}
|
||||
|
||||
geometry_len = 128;
|
||||
GRIB_CHECK (grib_get_string (h, "gridType", geometry, &geometry_len), 0);
|
||||
if (strcmp (geometry, grids[igrid]))
|
||||
{
|
||||
printf ("Geometry is incorrect\n");
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
GRIB_CHECK (grib_handle_delete (h), 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -932,6 +932,61 @@ int main (int argc, char * argv[])
|
|||
}
|
||||
|
||||
GRIB_CHECK (grib_handle_delete (h), 0);
|
||||
|
||||
/* Check message correctness */
|
||||
{
|
||||
char f[128];
|
||||
FILE * fp;
|
||||
double * vals;
|
||||
double norm = 0.;
|
||||
int i, err;
|
||||
size_t values_len, geometry_len;
|
||||
long int Nux, Nuy, Ncx, Ncy;
|
||||
char geometry[128];
|
||||
|
||||
sprintf (f, "lam_gp_%s.grib", grids[igrid]);
|
||||
fp = fopen (f, "r");
|
||||
h = grib_handle_new_from_file (0, fp, &err);
|
||||
vals = (double *)malloc (sizeof (double) * 4096);
|
||||
values_len = 4096;
|
||||
GRIB_CHECK (grib_get_double_array (h, "values", vals, &values_len), 0);
|
||||
for (i = 0; i < 4096; i++)
|
||||
norm += (values[i] - vals[i]) * (values[i] - vals[i]);
|
||||
norm = sqrt (norm / 4096);
|
||||
free (vals);
|
||||
printf ("%s : %lf\n", grids[igrid], norm);
|
||||
if (norm > 0.0001)
|
||||
{
|
||||
printf ("Error too large !\n");
|
||||
abort ();
|
||||
}
|
||||
fclose (fp);
|
||||
|
||||
|
||||
GRIB_CHECK (grib_get_long (h, "Nux", &Nux), 0);
|
||||
GRIB_CHECK (grib_get_long (h, "Nuy", &Nuy), 0);
|
||||
GRIB_CHECK (grib_get_long (h, "Ncx", &Ncx), 0);
|
||||
GRIB_CHECK (grib_get_long (h, "Ncy", &Ncy), 0);
|
||||
|
||||
if (Nux != 53 || Nuy != 53 || Ncx != 8 || Ncy != 8)
|
||||
{
|
||||
printf ("Geometry is incorrect\n");
|
||||
abort ();
|
||||
}
|
||||
|
||||
geometry_len = 128;
|
||||
GRIB_CHECK (grib_get_string (h, "gridType", geometry, &geometry_len), 0);
|
||||
if (strcmp (geometry, grids[igrid]))
|
||||
{
|
||||
printf ("Geometry is incorrect\n");
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
GRIB_CHECK (grib_handle_delete (h), 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue