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

cast result of malloc

parent bc590a12
......@@ -256,7 +256,7 @@ void *Adisit(void *argument)
if ( nlevel1 != nlevel2 ) cdoAbort("temperature and salinity have different number of levels!");
nlevel = nlevel1;
pressure = malloc(nlevel*sizeof(double));
pressure = (double*) malloc(nlevel*sizeof(double));
zaxisInqLevels(zaxisID, pressure);
if ( pin >= 0 )
......@@ -274,9 +274,9 @@ void *Adisit(void *argument)
field_init(&tho);
field_init(&sao);
field_init(&tis);
tho.ptr = malloc(gridsize*nlevel*sizeof(double));
sao.ptr = malloc(gridsize*nlevel*sizeof(double));
tis.ptr = malloc(gridsize*nlevel*sizeof(double));
tho.ptr = (double*) malloc(gridsize*nlevel*sizeof(double));
sao.ptr = (double*) malloc(gridsize*nlevel*sizeof(double));
tis.ptr = (double*) malloc(gridsize*nlevel*sizeof(double));
tho.nmiss = 0;
sao.nmiss = 0;
......
......@@ -150,12 +150,12 @@ void *Arith(void *argument)
field_init(&field1);
field_init(&field2);
field1.ptr = malloc(gridsize*sizeof(double));
field2.ptr = malloc(gridsize*sizeof(double));
field1.ptr = (double*) malloc(gridsize*sizeof(double));
field2.ptr = (double*) malloc(gridsize*sizeof(double));
if ( filltype == FILL_VAR || filltype == FILL_VARTS )
{
vardata2 = malloc(gridsize*nlevels2*sizeof(double));
varnmiss2 = malloc(nlevels2*sizeof(int));
vardata2 = (double*) malloc(gridsize*nlevels2*sizeof(double));
varnmiss2 = (int*) malloc(nlevels2*sizeof(int));
}
if ( cdoVerbose ) cdoPrint("Number of timesteps: file1 %d, file2 %d", ntsteps1, ntsteps2);
......@@ -183,14 +183,14 @@ void *Arith(void *argument)
if ( filltype == FILL_TS )
{
nvars = vlistNvars(vlistIDx2);
vardata = malloc(nvars*sizeof(double *));
varnmiss = malloc(nvars*sizeof(int *));
vardata = (double **) malloc(nvars*sizeof(double *));
varnmiss = (int **) malloc(nvars*sizeof(int *));
for ( varID = 0; varID < nvars; varID++ )
{
gridsize = gridInqSize(vlistInqVarGrid(vlistIDx2, varID));
nlev = zaxisInqSize(vlistInqVarZaxis(vlistIDx2, varID));
vardata[varID] = malloc(nlev*gridsize*sizeof(double));
varnmiss[varID] = malloc(nlev*sizeof(int));
vardata[varID] = (double*) malloc(nlev*gridsize*sizeof(double));
varnmiss[varID] = (int*) malloc(nlev*sizeof(int));
}
}
}
......
......@@ -36,7 +36,7 @@ int *fill_vars(int vlistID)
{
int varID;
int nvars = vlistNvars(vlistID);
int *vars = malloc(nvars*sizeof(int));
int *vars = (int*) malloc(nvars*sizeof(int));
if ( cdoNumVarnames )
{
......@@ -117,7 +117,7 @@ void *Arithc(void *argument)
gridsize = vlistGridsizeMax(vlistID1);
field_init(&field);
field.ptr = malloc(gridsize*sizeof(double));
field.ptr = (double*) malloc(gridsize*sizeof(double));
field.weight = NULL;
tsID = 0;
......
......@@ -116,7 +116,7 @@ void *Arithdays(void *argument)
gridsize = vlistGridsizeMax(vlistID1);
field_init(&field);
field.ptr = malloc(gridsize*sizeof(double));
field.ptr = (double*) malloc(gridsize*sizeof(double));
field.weight = NULL;
tsID = 0;
......
......@@ -71,7 +71,7 @@ void *Arithlat(void *argument)
gridsize = vlistGridsizeMax(vlistID1);
array = malloc(gridsize*sizeof(double));
array = (double*) malloc(gridsize*sizeof(double));
tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
......
......@@ -140,8 +140,8 @@ void *CDIread(void *argument)
gridsize = vlistGridsizeMax(vlistID);
if ( darray == NULL ) darray = malloc(gridsize*sizeof(double));
if ( farray == NULL && memtype == MEMTYPE_FLOAT ) farray = malloc(gridsize*sizeof(float));
if ( darray == NULL ) darray = (double*) malloc(gridsize*sizeof(double));
if ( farray == NULL && memtype == MEMTYPE_FLOAT ) farray = (float*) malloc(gridsize*sizeof(float));
t0 = timer_val(timer_read);
......
......@@ -75,7 +75,7 @@ void *CDItest(void *argument)
streamDefVlist(streamID2, vlistID2);
gridsize = vlistGridsizeMax(vlistID1);
array = malloc(gridsize*sizeof(double));
array = (double*) malloc(gridsize*sizeof(double));
tsID1 = 0;
tsID2 = 0;
......
......@@ -166,19 +166,19 @@ void *CDIwrite(void *argument)
cdoPrint("nvars : %d", nvars);
}
vars = malloc(nvars*sizeof(double **));
vars = (double ***) malloc(nvars*sizeof(double **));
for ( varID = 0; varID < nvars; varID++ )
{
vars[varID] = malloc(nlevs*sizeof(double *));
vars[varID] = (double **) malloc(nlevs*sizeof(double *));
for ( levelID = 0; levelID < nlevs; levelID++ )
{
vars[varID][levelID] = malloc(gridsize*sizeof(double));
vars[varID][levelID] = (double*) malloc(gridsize*sizeof(double));
for ( i = 0; i < gridsize; ++i )
vars[varID][levelID][i] = varID + rand()/(RAND_MAX+1.0);
}
}
if ( memtype == MEMTYPE_FLOAT ) farray = malloc(gridsize*sizeof(float));
if ( memtype == MEMTYPE_FLOAT ) farray = (float*) malloc(gridsize*sizeof(float));
vlistID = vlistCreate();
......
......@@ -106,7 +106,7 @@ void *Cat(void *argument)
if ( ! lcopy )
{
gridsize = vlistGridsizeMax(vlistID1);
array = malloc(gridsize*sizeof(double));
array = (double*) malloc(gridsize*sizeof(double));
}
}
else
......
......@@ -204,8 +204,8 @@ void *Change(void *argument)
{
zaxisID1 = vlistZaxis(vlistID2, index);
nlevs = zaxisInqSize(zaxisID1);
levels = malloc(nlevs*sizeof(double));
newlevels = malloc(nlevs*sizeof(double));
levels = (double*) malloc(nlevs*sizeof(double));
newlevels = (double*) malloc(nlevs*sizeof(double));
zaxisInqLevels(zaxisID1, levels);
for ( k = 0; k < nlevs; k++ ) newlevels[k] = levels[k];
......@@ -255,7 +255,7 @@ void *Change(void *argument)
zaxisID1 = vlistInqVarZaxis(vlistID2, varID);
nlevs = zaxisInqSize(zaxisID1);
levels = malloc(nlevs*sizeof(double));
levels = (double*) malloc(nlevs*sizeof(double));
zaxisInqLevels(zaxisID1, levels);
nfound = 0;
for ( k = 0; k < nlevs; k++ )
......@@ -317,7 +317,7 @@ void *Change(void *argument)
streamDefVlist(streamID2, vlistID2);
gridsize = vlistGridsizeMax(vlistID2);
array = malloc(gridsize*sizeof(double));
array = (double*) malloc(gridsize*sizeof(double));
tsID1 = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID1)) )
......
......@@ -75,9 +75,9 @@ void *Change_e5slm(void *argument)
gridsize = gridInqSize(vlistInqVarGrid(vlistIDslm, 0));
array = malloc(gridsize*sizeof(double));
cland = malloc(gridsize*sizeof(double));
lsea = malloc(gridsize*sizeof(short));
array = (double*) malloc(gridsize*sizeof(double));
cland = (double*) malloc(gridsize*sizeof(double));
lsea = (short*) malloc(gridsize*sizeof(short));
streamInqTimestep(streamIDslm, 0);
......@@ -102,7 +102,7 @@ void *Change_e5slm(void *argument)
nvars = vlistNvars(vlistID1);
codes = malloc(nvars*sizeof(short));
codes = (short*) malloc(nvars*sizeof(short));
for ( varID = 0; varID < nvars; ++varID )
{
......
......@@ -234,13 +234,13 @@ void *Cloudlayer(void *argument)
nlevel = zaxisInqSize(zaxisID);
nhlev = nlevel+1;
aclcac = malloc(gridsize*nlevel*sizeof(double));
aclcac = (double*) malloc(gridsize*nlevel*sizeof(double));
for ( varID = 0; varID < nvars2; ++varID )
cloud[varID] = malloc(gridsize*sizeof(double));
cloud[varID] = (double*) malloc(gridsize*sizeof(double));
if ( zaxisInqType(zaxisID) == ZAXIS_PRESSURE )
{
plevs = malloc(nlevel*sizeof(double));
plevs = (double*) malloc(nlevel*sizeof(double));
zaxisInqLevels(zaxisID, plevs);
if ( plevs[0] > plevs[nlevel-1] )
{
......@@ -281,11 +281,11 @@ void *Cloudlayer(void *argument)
{
double *vct;
vct = malloc(nvct*sizeof(double));
vct = (double*) malloc(nvct*sizeof(double));
zaxisInqVct(zaxisID, vct);
nlevs = nlevel + 1;
plevs = malloc(nlevs*sizeof(double));
plevs = (double*) malloc(nlevs*sizeof(double));
vct2plev(vct, plevs, nlevs);
free(vct);
......
......@@ -302,10 +302,10 @@ void command_init()
taxisID = vlistInqTaxis(gl_vlistID);
gridsize = vlistGridsizeMax(gl_vlistID);
gl_data = malloc(gridsize*sizeof(double));
gl_data = (double*) malloc(gridsize*sizeof(double));
gl_nvars = vlistNvars(gl_vlistID);
all_vars = malloc(gl_nvars*sizeof(vars_t));
all_vars = (vars_t*) malloc(gl_nvars*sizeof(vars_t));
for ( varID = 0; varID < gl_nvars; ++varID )
{
......
......@@ -112,9 +112,9 @@ void *Comp(void *argument)
gridsize = vlistGridsizeMax(vlistIDx1);
array1 = malloc(gridsize*sizeof(double));
array2 = malloc(gridsize*sizeof(double));
array3 = malloc(gridsize*sizeof(double));
array1 = (double*) malloc(gridsize*sizeof(double));
array2 = (double*) malloc(gridsize*sizeof(double));
array3 = (double*) malloc(gridsize*sizeof(double));
arrayx1 = array1;
arrayx2 = array2;
......@@ -143,12 +143,12 @@ void *Comp(void *argument)
if ( filltype == FILL_TS )
{
nvars = vlistNvars(vlistIDx2);
vardata = malloc(nvars*sizeof(double *));
vardata = (double **) malloc(nvars*sizeof(double *));
for ( varID = 0; varID < nvars; varID++ )
{
gridsize = gridInqSize(vlistInqVarGrid(vlistIDx2, varID));
nlev = zaxisInqSize(vlistInqVarZaxis(vlistIDx2, varID));
vardata[varID] = malloc(nlev*gridsize*sizeof(double));
vardata[varID] = (double*) malloc(nlev*gridsize*sizeof(double));
}
}
}
......
......@@ -78,8 +78,8 @@ void *Compc(void *argument)
gridsize = vlistGridsizeMax(vlistID1);
array1 = malloc(gridsize*sizeof(double));
array2 = malloc(gridsize*sizeof(double));
array1 = (double*) malloc(gridsize*sizeof(double));
array2 = (double*) malloc(gridsize*sizeof(double));
streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
......
......@@ -74,9 +74,9 @@ void *Complextorect(void *argument)
streamDefVlist(streamID3, vlistID3);
gridsize = vlistGridsizeMax(vlistID1);
array1 = malloc(2*gridsize*sizeof(double));
array2 = malloc(gridsize*sizeof(double));
array3 = malloc(gridsize*sizeof(double));
array1 = (double*) malloc(2*gridsize*sizeof(double));
array2 = (double*) malloc(gridsize*sizeof(double));
array3 = (double*) malloc(gridsize*sizeof(double));
tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
......
......@@ -95,9 +95,9 @@ void *Cond(void *argument)
if ( filltype == FILL_REC && gridsize != gridInqSize(vlistGrid(vlistID1, 0)) )
cdoAbort("Stream1 >%s< has wrong gridsize!", cdoStreamName(0)->args);
array1 = malloc(gridsize*sizeof(double));
array2 = malloc(gridsize*sizeof(double));
array3 = malloc(gridsize*sizeof(double));
array1 = (double*) malloc(gridsize*sizeof(double));
array2 = (double*) malloc(gridsize*sizeof(double));
array3 = (double*) malloc(gridsize*sizeof(double));
if ( cdoVerbose )
cdoPrint("Number of timesteps: file1 %d, file2 %d", ntsteps1, ntsteps2);
......@@ -110,14 +110,14 @@ void *Cond(void *argument)
cdoPrint("Filling up stream1 >%s< by copying the first timestep.", cdoStreamName(0)->args);
nvars = vlistNvars(vlistID1);
vardata1 = malloc(nvars*sizeof(double *));
varnmiss1 = malloc(nvars*sizeof(int *));
vardata1 = (double **) malloc(nvars*sizeof(double *));
varnmiss1 = (int **) malloc(nvars*sizeof(int *));
for ( varID = 0; varID < nvars; varID++ )
{
gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
nlev = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
vardata1[varID] = malloc(nlev*gridsize*sizeof(double));
varnmiss1[varID] = malloc(nlev*sizeof(int));
vardata1[varID] = (double*) malloc(nlev*gridsize*sizeof(double));
varnmiss1[varID] = (int*) malloc(nlev*sizeof(int));
}
}
}
......
......@@ -98,10 +98,10 @@ void *Cond2(void *argument)
if ( filltype == FILL_REC && gridsize != gridInqSize(vlistGrid(vlistID1, 0)) )
cdoAbort("Stream1 >%s< has wrong gridsize!", cdoStreamName(0)->args);
array1 = malloc(gridsize*sizeof(double));
array2 = malloc(gridsize*sizeof(double));
array3 = malloc(gridsize*sizeof(double));
array4 = malloc(gridsize*sizeof(double));
array1 = (double*) malloc(gridsize*sizeof(double));
array2 = (double*) malloc(gridsize*sizeof(double));
array3 = (double*) malloc(gridsize*sizeof(double));
array4 = (double*) malloc(gridsize*sizeof(double));
if ( cdoVerbose )
cdoPrint("Number of timesteps: file1 %d, file2 %d, file3 %d",
......@@ -115,14 +115,14 @@ void *Cond2(void *argument)
cdoPrint("Filling up stream1 >%s< by copying the first timestep.", cdoStreamName(0)->args);
nvars = vlistNvars(vlistID1);
vardata1 = malloc(nvars*sizeof(double *));
varnmiss1 = malloc(nvars*sizeof(int *));
vardata1 = (double **) malloc(nvars*sizeof(double *));
varnmiss1 = (int **) malloc(nvars*sizeof(int *));
for ( varID = 0; varID < nvars; varID++ )
{
gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
nlev = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
vardata1[varID] = malloc(nlev*gridsize*sizeof(double));
varnmiss1[varID] = malloc(nlev*sizeof(int));
vardata1[varID] = (double*) malloc(nlev*gridsize*sizeof(double));
varnmiss1[varID] = (int*) malloc(nlev*sizeof(int));
}
}
}
......
......@@ -69,8 +69,8 @@ void *Condc(void *argument)
gridsize = vlistGridsizeMax(vlistID1);
array1 = malloc(gridsize*sizeof(double));
array2 = malloc(gridsize*sizeof(double));
array1 = (double*) malloc(gridsize*sizeof(double));
array2 = (double*) malloc(gridsize*sizeof(double));
streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
......
......@@ -152,7 +152,7 @@ void *Consecstat (void *argument)
vlistDefTaxis(ovlistID, otaxisID);
field_init(&field);
field.ptr = malloc(vlistGridsizeMax(ovlistID)*sizeof(double));
field.ptr = (double*) malloc(vlistGridsizeMax(ovlistID)*sizeof(double));
nvars = vlistNvars(ivlistID);
vars = field_calloc(ivlistID, FIELD_PTR);
......
Markdown is supported
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