Commit e63fc487 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Removed unnecessary casts to size_t.

parent eb17ccb5
......@@ -78,7 +78,7 @@ cdfLazyGridInqAreaPtr(grid_t *grid)
lock_lazy_load(lazyGrid);
if (grid->area == cdfPendingLoad)
{
grid->area = (double *)Malloc((size_t)grid->size * sizeof(double));
grid->area = (double *)Malloc(grid->size * sizeof(double));
cdf_get_var_double(lazyGrid->cellAreaGet.datasetNCId,
lazyGrid->cellAreaGet.varNCId, grid->area);
}
......@@ -151,8 +151,8 @@ cdfLazyGridInqXYVal(grid_t *grid, size_t index,
}
else if ( valsGet->ndims == 2)
{
indexND[0] = index / (size_t)grid->x.size;
indexND[1] = index % (size_t)grid->x.size;
indexND[0] = index / grid->x.size;
indexND[1] = index % grid->x.size;
}
else
indexND[0] = index;
......@@ -168,6 +168,7 @@ cdfLazyGridInqXYVal(grid_t *grid, size_t index,
v = vals[index];
else
v = 0.0;
return v;
}
......@@ -271,8 +272,7 @@ cdfLazyGridInqXBoundsPtr(grid_t *grid)
lock_lazy_load(lazyGrid);
if (grid->x.bounds == cdfPendingLoad)
{
grid->x.bounds = (double *)Malloc((size_t)grid->nvertex
* (size_t)grid->size * sizeof(double));
grid->x.bounds = (double *)Malloc((size_t)grid->nvertex * grid->size * sizeof(double));
cdf_get_var_double(lazyGrid->xBoundsGet.datasetNCId,
lazyGrid->xBoundsGet.varNCId, grid->x.bounds);
}
......@@ -313,10 +313,8 @@ cdfLazyGridInqYBoundsPtr(grid_t *grid)
lock_lazy_load(lazyGrid);
if (grid->y.bounds == cdfPendingLoad)
{
grid->y.bounds = (double *)Malloc((size_t)grid->nvertex
* (size_t)grid->size * sizeof(double));
cdf_get_var_double(lazyGrid->yBoundsGet.datasetNCId,
lazyGrid->yBoundsGet.varNCId, grid->y.bounds);
grid->y.bounds = (double *)Malloc((size_t)grid->nvertex * grid->size * sizeof(double));
cdf_get_var_double(lazyGrid->yBoundsGet.datasetNCId, lazyGrid->yBoundsGet.varNCId, grid->y.bounds);
}
unlock_lazy_load(lazyGrid);
return lazyGrid->baseVtable->inqYBoundsPtr(grid);
......@@ -341,9 +339,10 @@ static void
cdfLazyGridCopyArrayFields(grid_t *gridptrOrig, grid_t *gridptrDup)
{
size_t nrowlon = (size_t)gridptrOrig->nrowlon;
size_t gridsize = (size_t)gridptrOrig->size;
size_t gridsize = gridptrOrig->size;
int gridtype = gridptrOrig->type;
int irregular = gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED;
if ( nrowlon )
{
gridptrDup->rowlon = (int *)Malloc(nrowlon * sizeof (int));
......@@ -352,34 +351,28 @@ cdfLazyGridCopyArrayFields(grid_t *gridptrOrig, grid_t *gridptrDup)
if ( gridptrOrig->x.vals != NULL && gridptrOrig->x.vals != cdfPendingLoad )
{
size_t size = irregular ? gridsize : (size_t)gridptrOrig->x.size;
size_t size = irregular ? gridsize : gridptrOrig->x.size;
gridptrDup->x.vals = (double *)Malloc(size * sizeof (double));
memcpy(gridptrDup->x.vals, gridptrOrig->x.vals, size * sizeof (double));
}
if ( gridptrOrig->y.vals != NULL && gridptrOrig->y.vals != cdfPendingLoad )
{
size_t size = irregular ? gridsize : (size_t)gridptrOrig->y.size;
size_t size = irregular ? gridsize : gridptrOrig->y.size;
gridptrDup->y.vals = (double *)Malloc(size * sizeof (double));
memcpy(gridptrDup->y.vals, gridptrOrig->y.vals, size * sizeof (double));
}
if ( gridptrOrig->x.bounds != NULL && gridptrOrig->x.bounds != cdfPendingLoad )
{
size_t size = (irregular ? gridsize : (size_t)gridptrOrig->x.size)
* (size_t)gridptrOrig->nvertex;
size_t size = (irregular ? gridsize : gridptrOrig->x.size) * (size_t)gridptrOrig->nvertex;
gridptrDup->x.bounds = (double *)Malloc(size * sizeof (double));
memcpy(gridptrDup->x.bounds, gridptrOrig->x.bounds, size * sizeof (double));
}
if ( gridptrOrig->y.bounds != NULL && gridptrOrig->y.bounds != cdfPendingLoad )
{
size_t size = (irregular ? gridsize : (size_t)gridptrOrig->y.size)
* (size_t)gridptrOrig->nvertex;
size_t size = (irregular ? gridsize : gridptrOrig->y.size) * (size_t)gridptrOrig->nvertex;
gridptrDup->y.bounds = (double *)Malloc(size * sizeof (double));
memcpy(gridptrDup->y.bounds, gridptrOrig->y.bounds, size * sizeof (double));
}
......@@ -388,7 +381,6 @@ cdfLazyGridCopyArrayFields(grid_t *gridptrOrig, grid_t *gridptrDup)
if ( gridptrOrig->area != NULL && gridptrOrig->area != cdfPendingLoad )
{
size_t size = gridsize;
gridptrDup->area = (double *)Malloc(size * sizeof (double));
memcpy(gridptrDup->area, gridptrOrig->area, size * sizeof (double));
}
......@@ -397,7 +389,6 @@ cdfLazyGridCopyArrayFields(grid_t *gridptrOrig, grid_t *gridptrDup)
if ( gridptrOrig->mask != NULL )
{
size_t size = gridsize;
gridptrDup->mask = (mask_t *)Malloc(size * sizeof(mask_t));
memcpy(gridptrDup->mask, gridptrOrig->mask, size * sizeof (mask_t));
}
......@@ -405,7 +396,6 @@ cdfLazyGridCopyArrayFields(grid_t *gridptrOrig, grid_t *gridptrDup)
if ( gridptrOrig->mask_gme != NULL )
{
size_t size = gridsize;
gridptrDup->mask_gme = (mask_t *)Malloc(size * sizeof (mask_t));
memcpy(gridptrDup->mask_gme, gridptrOrig->mask_gme, size * sizeof(mask_t));
}
......@@ -414,8 +404,7 @@ cdfLazyGridCopyArrayFields(grid_t *gridptrOrig, grid_t *gridptrDup)
static grid_t *
cdfLazyGridCopy(grid_t *gridptrOrig)
{
struct cdfLazyGrid *lazyGridDup
= (struct cdfLazyGrid *)Malloc(sizeof (*lazyGridDup));
struct cdfLazyGrid *lazyGridDup = (struct cdfLazyGrid *)Malloc(sizeof (*lazyGridDup));
gridptrOrig->vtable->copyScalarFields(gridptrOrig, &lazyGridDup->base);
gridptrOrig->vtable->copyArrayFields(gridptrOrig, &lazyGridDup->base);
return &lazyGridDup->base;
......
......@@ -496,7 +496,7 @@ void cdfReadVarDP(stream_t *streamptr, int varID, double *data, size_t *nmiss)
cdf_get_vara_double(fileID, ncvarid, start, count, data);
size_t size = gridInqSize(gridID)*(size_t)zaxisInqSize(zaxisID);
size_t size = gridInqSize(gridID) * (size_t)zaxisInqSize(zaxisID);
double missval = vlistInqVarMissval(vlistID, varID);
const bool haveMissVal = vlistInqVarMissvalUsed(vlistID, varID);
double validRange[2];
......@@ -704,9 +704,9 @@ void cdfReadVarSliceDPPart(stream_t *streamptr, int varID, int levelID, int varT
int ncvarid = streamptr->vars[varID].ncvarid;
int gridId = vlistInqVarGrid(vlistID, varID);
//int time = vlistInqVarTsteptype(vlistID, varID);
size_t gridsize = (size_t)gridInqSize(gridId);
size_t xsize = (size_t)gridInqXsize(gridId);
size_t ysize = (size_t)gridInqYsize(gridId);
size_t gridsize = gridInqSize(gridId);
size_t xsize = gridInqXsize(gridId);
size_t ysize = gridInqYsize(gridId);
unsigned int position = 0;
for (int i=0 ; i<4 ; i++)
......@@ -771,9 +771,9 @@ void cdfReadVarSliceSPPart(stream_t *streamptr, int varID, int levelID, int varT
int ncvarid = streamptr->vars[varID].ncvarid;
int gridId = vlistInqVarGrid(vlistID, varID);
// int time = vlistInqVarTsteptype(vlistID, varID);
size_t gridsize = (size_t)gridInqSize(gridId);
size_t xsize = (size_t)gridInqXsize(gridId);
size_t ysize = (size_t)gridInqYsize(gridId);
size_t gridsize = gridInqSize(gridId);
size_t xsize = gridInqXsize(gridId);
size_t ysize = gridInqYsize(gridId);
unsigned int position = 0;
for (int i=0 ; i<4 ; i++)
......@@ -895,7 +895,7 @@ void cdfReadVarDPPart(stream_t *streamptr, int varID, int varType, int startpoin
cdf_get_vara_double(fileID, ncvarid, start, count, data);
size_t size = (size_t)gridInqSize(gridID)*(size_t)zaxisInqSize(zaxisID);
size_t size = gridInqSize(gridID) * (size_t)zaxisInqSize(zaxisID);
double missval = vlistInqVarMissval(vlistID, varID);
const bool haveMissVal = vlistInqVarMissvalUsed(vlistID, varID);
double validRange[2];
......@@ -937,7 +937,7 @@ void cdfReadVarSPPart(stream_t *streamptr, int varID, int varType, int startpoin
cdf_get_vara_float(fileID, ncvarid, start, count, data);
size_t size = (size_t)gridInqSize(gridID)*(size_t)zaxisInqSize(zaxisID);
size_t size = gridInqSize(gridID) * (size_t)zaxisInqSize(zaxisID);
float missval = vlistInqVarMissval(vlistID, varID);
const bool haveMissVal = vlistInqVarMissvalUsed(vlistID, varID);
double validRange[2];
......
......@@ -523,19 +523,19 @@ void gribapiGetGridGaussianReduced(grib_handle *gh, grid_t *grid, int editionNum
grid->np = (int)lpar;
FAIL_ON_GRIB_ERROR(grib_get_long, gh, "Nj", &lpar);
int nlat = (int)lpar;
size_t nlat = (size_t)lpar;
grid->size = numberOfPoints;
grid->nrowlon = nlat;
grid->rowlon = (int *) Malloc((size_t)nlat * sizeof (int));
long *pl = (long *) Malloc((size_t)nlat * sizeof (long));
size_t dummy = (size_t)nlat;
grid->nrowlon = (int)nlat;
grid->rowlon = (int *) Malloc(nlat * sizeof(int));
long *pl = (long *) Malloc(nlat * sizeof(long));
size_t dummy = nlat;
FAIL_ON_GRIB_ERROR(grib_get_long_array, gh, "pl", pl, &dummy);
for ( int i = 0; i < nlat; ++i ) grid->rowlon[i] = (int)pl[i];
for ( size_t i = 0; i < nlat; ++i ) grid->rowlon[i] = (int)pl[i];
Free(pl);
grid->y.size = (size_t)nlat;
grid->y.size = nlat;
grid->x.inc = 0;
grid->y.inc = 0;
grid->x.flag = 0;
......
......@@ -3099,8 +3099,7 @@ gridDefBoundsGeneric(grid_t *gridptr, const double *bounds, size_t regularSize,
size_t nvertex = (size_t)gridptr->nvertex;
if ( nvertex == 0 )
{
Warning("nvertex undefined for gridID = %d. Cannot define bounds!",
gridptr->self);
Warning("nvertex undefined for gridID = %d. Cannot define bounds!", gridptr->self);
return;
}
size_t size = nvertex * (irregular ? gridptr->size : regularSize);
......
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