Commit 3eb47457 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Moved grid xy size to struct gridaxis_t.

parent 82d5ba9d
......@@ -487,8 +487,8 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
/* FIXME: assert(numberOfPoints <= INT_MAX && numberOfPoints >= INT_MIN) */
grid->size = (int)numberOfPoints;
grid->xsize = (int)nlon;
grid->ysize = (int)nlat;
grid->x.size = (int)nlon;
grid->y.size = (int)nlat;
grid->xinc = 0;
grid->yinc = 0;
grid->xdef = 0;
......@@ -508,7 +508,7 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
/* if ( IS_NOT_EQUAL(grid->xfirst, 0) || IS_NOT_EQUAL(grid->xlast, 0) ) */
{
if ( grid->xsize > 1 )
if ( grid->x.size > 1 )
{
if ( (grid->xfirst >= grid->xlast) && (grid->xfirst >= 180) ) grid->xfirst -= 360;
......@@ -517,7 +517,7 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
/* correct xinc if necessary */
if ( IS_EQUAL(grid->xfirst, 0) && grid->xlast > 354 )
{
double xinc = 360. / grid->xsize;
double xinc = 360. / grid->x.size;
if ( fabs(grid->xinc-xinc) > 0.0 )
{
......@@ -532,7 +532,7 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
grid->ydef = 0;
/* if ( IS_NOT_EQUAL(grid->yfirst, 0) || IS_NOT_EQUAL(grid->ylast, 0) ) */
{
if ( grid->ysize > 1 )
if ( grid->y.size > 1 )
{
if ( editionNumber <= 1 )
{
......@@ -565,7 +565,7 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
for ( int i = 0; i < nlat; ++i ) grid->rowlon[i] = (int)pl[i];
Free(pl);
grid->ysize = nlat;
grid->y.size = nlat;
grid->xinc = 0;
grid->yinc = 0;
grid->xdef = 0;
......@@ -579,7 +579,7 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
/* if ( IS_NOT_EQUAL(grid->xfirst, 0) || IS_NOT_EQUAL(grid->xlast, 0) ) */
{
if ( grid->xsize > 1 )
if ( grid->x.size > 1 )
{
if ( (grid->xfirst > grid->xlast) && (grid->xfirst >= 180) ) grid->xfirst -= 360;
......@@ -588,7 +588,7 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
/* correct xinc if necessary */
if ( IS_EQUAL(grid->xfirst, 0) && grid->xlast > 354 )
{
double xinc = 360. / grid->xsize;
double xinc = 360. / grid->x.size;
if ( fabs(grid->xinc-xinc) > 0.0 )
{
......@@ -603,7 +603,7 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
grid->ydef = 0;
/* if ( IS_NOT_EQUAL(grid->yfirst, 0) || IS_NOT_EQUAL(grid->ylast, 0) ) */
{
if ( grid->ysize > 1 )
if ( grid->y.size > 1 )
{
if ( editionNumber <= 1 )
{
......@@ -627,8 +627,8 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
Error("numberOfPoints (%d) and gridSize (%d) differ!", (int)numberOfPoints, nlon*nlat);
grid->size = (int)numberOfPoints;
grid->xsize = nlon;
grid->ysize = nlat;
grid->x.size = nlon;
grid->y.size = nlat;
FAIL_ON_GRIB_ERROR(grib_get_double, gh, "DxInMetres", &grid->lcc.xinc);
FAIL_ON_GRIB_ERROR(grib_get_double, gh, "DyInMetres", &grid->lcc.yinc);
......@@ -732,13 +732,13 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
if ( nlon > 0 && nlat > 0 && nlon*nlat == grid->size )
{
grid->xsize = nlon;
grid->ysize = nlat;
grid->x.size = nlon;
grid->y.size = nlat;
}
else
{
grid->xsize = 0;
grid->ysize = 0;
grid->x.size = 0;
grid->y.size = 0;
}
break;
......
This diff is collapsed.
......@@ -49,6 +49,7 @@ struct gridaxis_t {
char units[CDI_MAX_NAME];
char dimname[CDI_MAX_NAME];
const char *stdname;
int size; // number of values
};
// Lambert Conformal Conic
......@@ -120,8 +121,6 @@ struct grid_t {
int *rowlon;
int nrowlon;
int size;
int xsize; /* number of values along X */
int ysize; /* number of values along Y */
int np; /* number of parallels between a pole and the equator */
short lcomplex;
short hasdims;
......
......@@ -4345,11 +4345,11 @@ void grid_set_chunktype(grid_t *grid, ncvar_t *ncvar)
}
else
{
if ( grid->xsize > 1 && grid->ysize > 1 && ndims > 1 &&
grid->xsize == ncvar->chunks[ndims-1] &&
grid->ysize == ncvar->chunks[ndims-2] )
if ( grid->x.size > 1 && grid->y.size > 1 && ndims > 1 &&
grid->x.size == ncvar->chunks[ndims-1] &&
grid->y.size == ncvar->chunks[ndims-2] )
ncvar->chunktype = CHUNK_GRID;
else if ( grid->xsize > 1 && grid->xsize == ncvar->chunks[ndims-1] )
else if ( grid->x.size > 1 && grid->x.size == ncvar->chunks[ndims-1] )
ncvar->chunktype = CHUNK_LINES;
else
ncvar->chunktype = CHUNK_AUTO;
......@@ -4524,8 +4524,8 @@ cdfLazyGridInqXYVal(grid_t *grid, size_t index,
}
else if ( valsGet->ndims == 2)
{
indexND[0] = index / (size_t)grid->xsize;
indexND[1] = index % (size_t)grid->xsize;
indexND[0] = index / (size_t)grid->x.size;
indexND[1] = index % (size_t)grid->x.size;
}
else
indexND[0] = index;
......@@ -4725,7 +4725,7 @@ cdfLazyGridCopyArrayFields(grid_t *gridptrOrig, grid_t *gridptrDup)
if ( gridptrOrig->xvals != NULL && gridptrOrig->xvals != cdfPendingLoad )
{
size_t size = irregular ? gridsize : (size_t)gridptrOrig->xsize;
size_t size = irregular ? gridsize : (size_t)gridptrOrig->x.size;
gridptrDup->xvals = (double *)Malloc(size * sizeof (double));
memcpy(gridptrDup->xvals, gridptrOrig->xvals, size * sizeof (double));
......@@ -4733,7 +4733,7 @@ cdfLazyGridCopyArrayFields(grid_t *gridptrOrig, grid_t *gridptrDup)
if ( gridptrOrig->yvals != NULL && gridptrOrig->yvals != cdfPendingLoad )
{
size_t size = irregular ? gridsize : (size_t)gridptrOrig->ysize;
size_t size = irregular ? gridsize : (size_t)gridptrOrig->y.size;
gridptrDup->yvals = (double *)Malloc(size * sizeof (double));
memcpy(gridptrDup->yvals, gridptrOrig->yvals, size * sizeof (double));
......@@ -4741,7 +4741,7 @@ cdfLazyGridCopyArrayFields(grid_t *gridptrOrig, grid_t *gridptrDup)
if ( gridptrOrig->xbounds != NULL && gridptrOrig->xbounds != cdfPendingLoad )
{
size_t size = (irregular ? gridsize : (size_t)gridptrOrig->xsize)
size_t size = (irregular ? gridsize : (size_t)gridptrOrig->x.size)
* (size_t)gridptrOrig->nvertex;
gridptrDup->xbounds = (double *)Malloc(size * sizeof (double));
......@@ -4750,7 +4750,7 @@ cdfLazyGridCopyArrayFields(grid_t *gridptrOrig, grid_t *gridptrDup)
if ( gridptrOrig->ybounds != NULL && gridptrOrig->ybounds != cdfPendingLoad )
{
size_t size = (irregular ? gridsize : (size_t)gridptrOrig->ysize)
size_t size = (irregular ? gridsize : (size_t)gridptrOrig->y.size)
* (size_t)gridptrOrig->nvertex;
gridptrDup->ybounds = (double *)Malloc(size * sizeof (double));
......@@ -5266,8 +5266,8 @@ void cdf_define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
case GRID_CURVILINEAR:
{
grid->size = (int)size;
grid->xsize = (int)xsize;
grid->ysize = (int)ysize;
grid->x.size = (int)xsize;
grid->y.size = (int)ysize;
if ( xvarid != UNDEFID )
{
grid->xdef = 1;
......@@ -5340,8 +5340,8 @@ void cdf_define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
{
grid->type = GRID_GENERIC;
grid->size = 1;
grid->xsize = 0;
grid->ysize = 0;
grid->x.size = 0;
grid->y.size = 0;
}
else
{
......@@ -5461,25 +5461,25 @@ void cdf_define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
if ( xdimid != UNDEFID && ydimid != UNDEFID && zdimid == UNDEFID )
{
if ( grid->xsize > grid->ysize && grid->ysize < 1000 )
if ( grid->x.size > grid->y.size && grid->y.size < 1000 )
{
ncvars[ncvarid].dimtype[ydimidx] = Z_AXIS;
ydimid = UNDEFID;
grid->size = grid->xsize;
grid->ysize = 0;
grid->size = grid->x.size;
grid->y.size = 0;
}
else if ( grid->ysize > grid->xsize && grid->xsize < 1000 )
else if ( grid->y.size > grid->x.size && grid->x.size < 1000 )
{
ncvars[ncvarid].dimtype[xdimidx] = Z_AXIS;
xdimid = ydimid;
ydimid = UNDEFID;
grid->size = grid->ysize;
grid->xsize = grid->ysize;
grid->ysize = 0;
grid->size = grid->y.size;
grid->x.size = grid->y.size;
grid->y.size = 0;
}
}
if ( grid->size != grid->xsize )
if ( grid->size != grid->x.size )
{
Warning("Unsupported array structure, skipped variable %s!", ncvars[ncvarid].name);
ncvars[ncvarid].isvar = -1;
......@@ -5501,8 +5501,8 @@ void cdf_define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
if ( grid->type == GRID_CURVILINEAR )
{
proj->size = grid->size;
proj->xsize = grid->xsize;
proj->ysize = grid->ysize;
proj->x.size = grid->x.size;
proj->y.size = grid->y.size;
}
// grid->proj = gridGenerate(proj);
......@@ -5512,9 +5512,9 @@ void cdf_define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
if ( CDI_Debug )
{
Message("grid: type = %d, size = %d, nx = %d, ny %d",
grid->type, grid->size, grid->xsize, grid->ysize);
grid->type, grid->size, grid->x.size, grid->y.size);
Message("proj: type = %d, size = %d, nx = %d, ny %d",
proj->type, proj->size, proj->xsize, proj->ysize);
proj->type, proj->size, proj->x.size, proj->y.size);
}
#if defined (PROJECTION_TEST)
......
......@@ -169,15 +169,15 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
if ( ISEC4_NumValues != ISEC2_NumLon*ISEC2_NumLat )
Error("numberOfPoints (%d) and gridSize (%d) differ!", ISEC4_NumValues, ISEC2_NumLon*ISEC2_NumLat);
grid->size = ISEC4_NumValues;
grid->xsize = ISEC2_NumLon;
grid->ysize = ISEC2_NumLat;
grid->x.size = ISEC2_NumLon;
grid->y.size = ISEC2_NumLat;
if ( gridtype == GRID_GAUSSIAN ) grid->np = ISEC2_NumPar;
grid->xinc = 0;
grid->yinc = 0;
grid->xdef = 0;
/* if ( ISEC2_FirstLon != 0 || ISEC2_LastLon != 0 ) */
{
if ( grid->xsize > 1 )
if ( grid->x.size > 1 )
{
bool recompinc = true;
......@@ -185,7 +185,7 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
if ( ISEC2_ResFlag && ISEC2_LonIncr > 0 )
{
if ( abs(ISEC2_LastLon - (ISEC2_FirstLon+ISEC2_LonIncr*(grid->xsize-1))) <= 2 )
if ( abs(ISEC2_LastLon - (ISEC2_FirstLon+ISEC2_LonIncr*(grid->x.size-1))) <= 2 )
{
recompinc = false;
grid->xinc = ISEC2_LonIncr * 0.001;
......@@ -193,12 +193,12 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
}
/* recompute xinc if necessary */
if ( recompinc ) grid->xinc = (ISEC2_LastLon - ISEC2_FirstLon) * 0.001 / (grid->xsize-1);
if ( recompinc ) grid->xinc = (ISEC2_LastLon - ISEC2_FirstLon) * 0.001 / (grid->x.size-1);
/* correct xinc if necessary */
if ( ISEC2_FirstLon == 0 && ISEC2_LastLon > 354000 && ISEC2_LastLon < 360000 )
{
double xinc = 360. / grid->xsize;
double xinc = 360. / grid->x.size;
if ( fabs(grid->xinc-xinc) > 0.0 )
{
......@@ -214,12 +214,12 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
grid->ydef = 0;
/* if ( ISEC2_FirstLat != 0 || ISEC2_LastLat != 0 ) */
{
if ( grid->ysize > 1 && compyinc )
if ( grid->y.size > 1 && compyinc )
{
bool recompinc = true;
if ( ISEC2_ResFlag && ISEC2_LatIncr > 0 )
{
if ( abs(ISEC2_LastLat - (ISEC2_FirstLat+ISEC2_LatIncr*(grid->ysize-1))) <= 2 )
if ( abs(ISEC2_LastLat - (ISEC2_FirstLat+ISEC2_LatIncr*(grid->y.size-1))) <= 2 )
{
recompinc = false;
grid->yinc = ISEC2_LatIncr * 0.001;
......@@ -227,7 +227,7 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
}
/* recompute yinc if necessary */
if ( recompinc ) grid->yinc = (ISEC2_LastLat - ISEC2_FirstLat) * 0.001 / (grid->ysize - 1);
if ( recompinc ) grid->yinc = (ISEC2_LastLat - ISEC2_FirstLat) * 0.001 / (grid->y.size - 1);
}
grid->yfirst = ISEC2_FirstLat * 0.001;
grid->ylast = ISEC2_LastLat * 0.001;
......@@ -241,20 +241,20 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
grid->size = ISEC4_NumValues;
grid->rowlon = ISEC2_RowLonPtr;
grid->nrowlon = ISEC2_NumLat;
grid->ysize = ISEC2_NumLat;
grid->y.size = ISEC2_NumLat;
grid->xinc = 0;
grid->yinc = 0;
grid->xdef = 0;
/* if ( ISEC2_FirstLon != 0 || ISEC2_LastLon != 0 ) */
{
if ( grid->xsize > 1 )
if ( grid->x.size > 1 )
{
if ( ISEC2_LastLon < ISEC2_FirstLon && ISEC2_LastLon < 0 ) ISEC2_LastLon += 360000;
if ( ISEC2_ResFlag && ISEC2_LonIncr > 0 )
grid->xinc = ISEC2_LonIncr * 0.001;
else
grid->xinc = (ISEC2_LastLon - ISEC2_FirstLon) * 0.001 / (grid->xsize - 1);
grid->xinc = (ISEC2_LastLon - ISEC2_FirstLon) * 0.001 / (grid->x.size - 1);
}
grid->xfirst = ISEC2_FirstLon * 0.001;
grid->xlast = ISEC2_LastLon * 0.001;
......@@ -263,12 +263,12 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
grid->ydef = 0;
/* if ( ISEC2_FirstLat != 0 || ISEC2_LastLat != 0 ) */
{
if ( grid->ysize > 1 )
if ( grid->y.size > 1 )
{
if ( ISEC2_ResFlag && ISEC2_LatIncr > 0 )
grid->yinc = ISEC2_LatIncr * 0.001;
else
grid->yinc = (ISEC2_LastLat - ISEC2_FirstLat) * 0.001 / (grid->ysize - 1);
grid->yinc = (ISEC2_LastLat - ISEC2_FirstLat) * 0.001 / (grid->y.size - 1);
}
grid->yfirst = ISEC2_FirstLat * 0.001;
grid->ylast = ISEC2_LastLat * 0.001;
......@@ -283,8 +283,8 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
ISEC4_NumValues, ISEC2_NumLon*ISEC2_NumLat);
grid->size = ISEC4_NumValues;
grid->xsize = ISEC2_NumLon;
grid->ysize = ISEC2_NumLat;
grid->x.size = ISEC2_NumLon;
grid->y.size = ISEC2_NumLat;
grid->lcc.xinc = ISEC2_Lambert_dx;
grid->lcc.yinc = ISEC2_Lambert_dy;
......@@ -324,8 +324,8 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
case GRID_GENERIC:
{
grid->size = ISEC4_NumValues;
grid->xsize = 0;
grid->ysize = 0;
grid->x.size = 0;
grid->y.size = 0;
break;
}
default:
......
......@@ -219,8 +219,8 @@ void extAddRecord(stream_t *streamptr, int param, int level, int xysize,
grid_t *grid = (grid_t *)Malloc(sizeof (*grid));
grid_init(grid);
cdiGridTypeInit(grid, GRID_GENERIC, xysize);
grid->xsize = xysize;
grid->ysize = 0;
grid->x.size = xysize;
grid->y.size = 0;
grid->xvals = NULL;
grid->yvals = NULL;
struct addIffNewRes gridAdded = cdiVlistAddGridIfNew(vlistID, grid, 0);
......@@ -243,8 +243,7 @@ void extAddRecord(stream_t *streamptr, int param, int level, int xysize,
streamptr->nrecs++;
if ( CDI_Debug )
Message("varID = %d gridID = %d levelID = %d",
varID, gridID, levelID);
Message("varID = %d gridID = %d levelID = %d", varID, gridID, levelID);
}
static
......
......@@ -668,8 +668,10 @@ void iegAddRecord(stream_t *streamptr, int param, int *pdb, int *gdb, double *vc
grid_t *grid = (grid_t *)Malloc(sizeof (*grid));
grid_init(grid);
cdiGridTypeInit(grid, gridtype, IEG_G_NumLon(gdb)*IEG_G_NumLat(gdb));
grid->xsize = IEG_G_NumLon(gdb);
grid->ysize = IEG_G_NumLat(gdb);
int xsize = IEG_G_NumLon(gdb);
int ysize = IEG_G_NumLat(gdb);
grid->x.size = xsize;
grid->y.size = ysize;
grid->xinc = 0;
grid->yinc = 0;
grid->xdef = 0;
......@@ -680,17 +682,17 @@ void iegAddRecord(stream_t *streamptr, int param, int *pdb, int *gdb, double *vc
/* if ( IEG_G_FirstLon != 0 || IEG_G_LastLon != 0 ) */
{
if ( grid->xsize > 1 )
if ( xsize > 1 )
{
if ( IEG_G_ResFlag(gdb) && IEG_G_LonIncr(gdb) > 0 )
grid->xinc = IEG_G_LonIncr(gdb) * resfac;
else
grid->xinc = (IEG_G_LastLon(gdb) - IEG_G_FirstLon(gdb)) * resfac / (grid->xsize - 1);
grid->xinc = (IEG_G_LastLon(gdb) - IEG_G_FirstLon(gdb)) * resfac / (xsize - 1);
/* correct xinc if necessary */
if ( IEG_G_FirstLon(gdb) == 0 && IEG_G_LastLon(gdb) > 354000 )
{
double xinc = 360. / grid->xsize;
double xinc = 360. / xsize;
/* FIXME: why not use grid->xinc != xinc as condition? */
if ( fabs(grid->xinc-xinc) > 0.0 )
{
......@@ -706,12 +708,12 @@ void iegAddRecord(stream_t *streamptr, int param, int *pdb, int *gdb, double *vc
grid->ydef = 0;
/* if ( IEG_G_FirstLat != 0 || IEG_G_LastLat != 0 ) */
{
if ( grid->ysize > 1 )
if ( ysize > 1 )
{
if ( IEG_G_ResFlag(gdb) && IEG_G_LatIncr(gdb) > 0 )
grid->yinc = IEG_G_LatIncr(gdb) * resfac;
else
grid->yinc = (IEG_G_LastLat(gdb) - IEG_G_FirstLat(gdb)) * resfac / (grid->ysize - 1);
grid->yinc = (IEG_G_LastLat(gdb) - IEG_G_FirstLat(gdb)) * resfac / (ysize - 1);
}
grid->yfirst = IEG_G_FirstLat(gdb) * resfac;
grid->ylast = IEG_G_LastLat(gdb) * resfac;
......
......@@ -212,8 +212,8 @@ void srv_add_record(stream_t *streamptr, int param, int level, int xsize, int ys
grid_t *grid = (grid_t *)Malloc(sizeof (*grid));
grid_init(grid);
cdiGridTypeInit(grid, GRID_GENERIC, xsize*ysize);
grid->xsize = xsize;
grid->ysize = ysize;
grid->x.size = xsize;
grid->y.size = ysize;
grid->xvals = NULL;
grid->yvals = NULL;
struct addIffNewRes gridAdded = cdiVlistAddGridIfNew(vlistID, grid, 0);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment