Commit 33e8f606 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

check VCT

parent 6f73055c
......@@ -256,7 +256,7 @@ void *Derivepar(void *argument)
if ( cdoVerbose )
cdoPrint("lhavevct=TRUE zaxisIDh = %d, nhlevf = %d", zaxisIDh, nlevel);
vct = malloc(nvct*sizeof(double));
vct = (double*) malloc(nvct*sizeof(double));
zaxisInqVct(zaxisID, vct);
if ( cdoVerbose )
......@@ -267,14 +267,14 @@ void *Derivepar(void *argument)
else
{
if ( cdoVerbose )
cdoPrint("nlevel /= (nvct/2 - 1): nlevel = %d", nlevel);
cdoPrint("nlevel = (nvct/2 - 1): nlevel = %d", nlevel);
}
}
}
}
if ( zaxisIDh == -1 )
cdoAbort("No data on hybrid model level found!");
cdoAbort("No 3D variable with hybrid sigma pressure coordinate found!");
nvars = vlistNvars(vlistID1);
......@@ -382,34 +382,32 @@ void *Derivepar(void *argument)
if ( tempID == -1 ) cdoAbort("Air temperature not found!");
array = malloc(ngp*sizeof(double));
array = (double*) malloc(ngp*sizeof(double));
geop = (double*) malloc(ngp*sizeof(double));
ps = (double*) malloc(ngp*sizeof(double));
temp = (double*) malloc(ngp*nhlevf*sizeof(double));
geop = malloc(ngp*sizeof(double));
ps = malloc(ngp*sizeof(double));
// lwater = (double*) malloc(ngp*nhlevf*sizeof(double));
// iwater = (double*) malloc(ngp*nhlevf*sizeof(double));
temp = malloc(ngp*nhlevf*sizeof(double));
// lwater = malloc(ngp*nhlevf*sizeof(double));
// iwater = malloc(ngp*nhlevf*sizeof(double));
half_press = malloc(ngp*(nhlevf+1)*sizeof(double));
half_press = (double*) malloc(ngp*(nhlevf+1)*sizeof(double));
if ( operatorID == GEOPOTHEIGHT )
{
if ( humID == -1 )
cdoWarning("%s not found - using algorithm without %s!", var_stdname(specific_humidity), var_stdname(specific_humidity));
else
hum = malloc(ngp*nhlevf*sizeof(double));
hum = (double*) malloc(ngp*nhlevf*sizeof(double));
geopotheight = malloc(ngp*(nhlevf+1)*sizeof(double));
geopotheight = (double*) malloc(ngp*(nhlevf+1)*sizeof(double));
}
if ( operatorID == SEALEVELPRESSURE )
{
full_press = malloc(ngp*nhlevf*sizeof(double));
full_press = (double*) malloc(ngp*nhlevf*sizeof(double));
surfaceID = zaxisFromName("surface");
sealevelpressure = malloc(ngp*sizeof(double));
sealevelpressure = (double*) malloc(ngp*sizeof(double));
}
if ( zaxisIDh != -1 && geopID == -1 )
......
......@@ -116,7 +116,7 @@ void *Pressure(void *argument)
{
double *level;
int l;
level = malloc(nlevel*sizeof(double));
level = (double*) malloc(nlevel*sizeof(double));
zaxisInqLevels(zaxisID, level);
for ( l = 0; l < nlevel; l++ )
{
......@@ -140,7 +140,7 @@ void *Pressure(void *argument)
nhlevf = nhlev;
nhlevh = nhlevf + 1;
vct = malloc(nvct*sizeof(double));
vct = (double*) malloc(nvct*sizeof(double));
zaxisInqVct(zaxisID, vct);
}
}
......@@ -154,7 +154,7 @@ void *Pressure(void *argument)
nhlevf = nhlev - 1;
nhlevh = nhlev;
vct = malloc(nvct*sizeof(double));
vct = (double*) malloc(nvct*sizeof(double));
zaxisInqVct(zaxisID, vct);
}
}
......@@ -166,7 +166,7 @@ void *Pressure(void *argument)
int voff = 4;
double *rvct = NULL;
rvct = malloc(nvct*sizeof(double));
rvct = (double*) malloc(nvct*sizeof(double));
zaxisInqVct(zaxisID,rvct);
if ( (int)(rvct[0]+0.5) == 100000 && rvct[voff] < rvct[voff+1] )
......@@ -178,7 +178,7 @@ void *Pressure(void *argument)
nhlevh = nhlev + 1;
vctsize = 2*nhlevh;
vct = malloc(vctsize*sizeof(double));
vct = (double*) malloc(vctsize*sizeof(double));
/* calculate VCT for LM */
......@@ -213,13 +213,13 @@ void *Pressure(void *argument)
if ( zaxisIDh != -1 && ngp > 0 )
{
ps_prog = malloc(ngp*sizeof(double));
deltap = malloc(ngp*nhlevf*sizeof(double));
full_press = malloc(ngp*nhlevf*sizeof(double));
half_press = malloc(ngp*nhlevh*sizeof(double));
ps_prog = (double*) malloc(ngp*sizeof(double));
deltap = (double*) malloc(ngp*nhlevf*sizeof(double));
full_press = (double*) malloc(ngp*nhlevf*sizeof(double));
half_press = (double*) malloc(ngp*nhlevh*sizeof(double));
}
else
cdoAbort("No data on hybrid model level found!");
cdoAbort("No 3D variable with hybrid sigma pressure coordinate found!");
if ( operatorID == PRESSURE_FL || operatorID == DELTAP )
zaxisIDp = zaxisCreate(ZAXIS_HYBRID, nhlevf);
......@@ -229,7 +229,7 @@ void *Pressure(void *argument)
{
double *level;
int l;
level = malloc(nhlevh*sizeof(double));
level = (double*) malloc(nhlevh*sizeof(double));
for ( l = 0; l < nhlevh; l++ ) level[l] = l+1;
zaxisDefLevels(zaxisIDp, level);
free(level);
......@@ -351,7 +351,7 @@ void *Pressure(void *argument)
cdoAbort("%s on spectral representation not supported!", var_stdname(surface_air_pressure));
gridsize = gridInqSize(gridID);
pdata = malloc(gridsize*sizeof(double));
pdata = (double*) malloc(gridsize*sizeof(double));
vlistID2 = vlistCreate();
......
......@@ -111,7 +111,7 @@ double *vctFromFile(const char *filename, int *nvct)
fp = fopen(filename, "r");
if ( fp == NULL ) { perror(filename); exit(EXIT_FAILURE); }
vct2 = malloc(maxvct*sizeof(double));
vct2 = (double*) malloc(maxvct*sizeof(double));
while ( readline(fp, line, 1024) )
{
......@@ -275,14 +275,14 @@ void *Remapeta(void *argument)
gridID = vlistInqVarGrid(vlistID1, varID);
nfis2gp = gridInqSize(gridID);
fis2 = malloc(nfis2gp*sizeof(double));
fis2 = (double*) malloc(nfis2gp*sizeof(double));
streamReadRecord(streamID1, fis2, &nmiss);
if ( nmiss )
{
missval = vlistInqVarMissval(vlistID1, varID);
imiss = malloc (nfis2gp*sizeof(int));
imiss = (int*) malloc (nfis2gp*sizeof(int));
for ( i = 0; i < nfis2gp; ++i )
{
if ( DBL_IS_EQUAL(fis2[i], missval) )
......@@ -341,7 +341,7 @@ void *Remapeta(void *argument)
}
zaxisID2 = zaxisCreate(ZAXIS_HYBRID, nhlevf2);
lev2 = malloc(nhlevf2*sizeof(double));
lev2 = (double*) malloc(nhlevf2*sizeof(double));
for ( i = 0; i < nhlevf2; ++i ) lev2[i] = i+1;
zaxisDefLevels(zaxisID2, lev2);
free(lev2);
......@@ -381,7 +381,7 @@ void *Remapeta(void *argument)
if ( cdoVerbose )
cdoPrint("lhavevct=TRUE zaxisIDh = %d, nhlevf1 = %d", zaxisIDh, nlevel);
vct1 = malloc(nvct1*sizeof(double));
vct1 = (double*) malloc(nvct1*sizeof(double));
zaxisInqVct(zaxisID, vct1);
vlistChangeZaxisIndex(vlistID2, i, zaxisID2);
......@@ -401,7 +401,9 @@ void *Remapeta(void *argument)
else
{
if ( cdoVerbose )
cdoPrint("nlevel /= (nvct1/2 - 1): nlevel = %d", nlevel);
cdoPrint("nlevel = (nvct1/2 - 1): nlevel = %d", nlevel);
if ( nlevel < (nvct1/2 - 1) )
cdoPrint("z-axis %d has only %d of %d hybrid sigma pressure levels!", i+1, nlevel, (nvct1/2 - 1));
}
}
else
......@@ -422,7 +424,7 @@ void *Remapeta(void *argument)
if ( zaxisIDh == -1 )
cdoWarning("No data on hybrid model level found!");
cdoWarning("No 3D variable with hybrid sigma pressure coordinate found!");
nvars = vlistNvars(vlistID1);
......@@ -495,52 +497,54 @@ void *Remapeta(void *argument)
cdoWarning("Temperature and Humidity not found!");
}
*/
if ( operatorID == REMAPETA ) {}
if ( operatorID == REMAPETAS || operatorID == REMAPETAZ)
{
sum1 = malloc(ngp*sizeof(double));
sum2 = malloc(ngp*sizeof(double));
sum1 = (double*) malloc(ngp*sizeof(double));
sum2 = (double*) malloc(ngp*sizeof(double));
}
if ( operatorID == REMAPETAZ )
{
deltap1 = malloc(ngp*nhlevf1*sizeof(double));
deltap2 = malloc(ngp*nhlevf2*sizeof(double));
half_press1 = malloc(ngp*(nhlevf1+1)*sizeof(double));
half_press2 = malloc(ngp*(nhlevf2+1)*sizeof(double));
deltap1 = (double*) malloc(ngp*nhlevf1*sizeof(double));
deltap2 = (double*) malloc(ngp*nhlevf2*sizeof(double));
half_press1 = (double*) malloc(ngp*(nhlevf1+1)*sizeof(double));
half_press2 = (double*) malloc(ngp*(nhlevf2+1)*sizeof(double));
}
array = malloc(ngp*sizeof(double));
array = (double*) malloc(ngp*sizeof(double));
fis1 = malloc(ngp*sizeof(double));
ps1 = malloc(ngp*sizeof(double));
fis1 = (double*) malloc(ngp*sizeof(double));
ps1 = (double*) malloc(ngp*sizeof(double));
if ( lfis2 == FALSE ) fis2 = malloc(ngp*sizeof(double));
if ( lfis2 == FALSE ) fis2 = (double*) malloc(ngp*sizeof(double));
if ( lfis2 == TRUE && ngp != nfis2gp ) cdoAbort("Orographies have different grid size!");
ps2 = malloc(ngp*sizeof(double));
ps2 = (double*) malloc(ngp*sizeof(double));
if ( ltq )
{
tscor = malloc(ngp*sizeof(double));
pscor = malloc(ngp*sizeof(double));
secor = malloc(ngp*sizeof(double));
tscor = (double*) malloc(ngp*sizeof(double));
pscor = (double*) malloc(ngp*sizeof(double));
secor = (double*) malloc(ngp*sizeof(double));
t1 = malloc(ngp*nhlevf1*sizeof(double));
q1 = malloc(ngp*nhlevf1*sizeof(double));
t1 = (double*) malloc(ngp*nhlevf1*sizeof(double));
q1 = (double*) malloc(ngp*nhlevf1*sizeof(double));
t2 = malloc(ngp*nhlevf2*sizeof(double));
q2 = malloc(ngp*nhlevf2*sizeof(double));
t2 = (double*) malloc(ngp*nhlevf2*sizeof(double));
q2 = (double*) malloc(ngp*nhlevf2*sizeof(double));
}
if ( nvars3D )
{
vars1 = malloc(nvars*sizeof(double));
vars2 = malloc(nvars*sizeof(double));
vars1 = (double**) malloc(nvars*sizeof(double*));
vars2 = (double**) malloc(nvars*sizeof(double*));
for ( varID = 0; varID < nvars3D; ++varID )
{
vars1[varID] = malloc(ngp*nhlevf1*sizeof(double));
vars2[varID] = malloc(ngp*nhlevf2*sizeof(double));
vars1[varID] = (double*) malloc(ngp*nhlevf1*sizeof(double));
vars2[varID] = (double*) malloc(ngp*nhlevf2*sizeof(double));
}
}
......
......@@ -42,10 +42,10 @@ void data_treat(double *zdata, double *xdata, double *ydata, long nx, long ny)
int *iscale = NULL;
long i, j;
zwork = malloc(3*nx*ny*sizeof(double));
xwork = malloc(3*nx*sizeof(double));
xscale = malloc(ny*sizeof(double));
iscale = malloc(ny*sizeof(int));
zwork = (double*) malloc(3*nx*ny*sizeof(double));
xwork = (double*) malloc(3*nx*sizeof(double));
xscale = (double*) malloc(ny*sizeof(double));
iscale = (int*) malloc(ny*sizeof(int));
double pi2 = 2*acos(-1.);
for ( i = 0; i < nx; ++i )
......@@ -784,7 +784,7 @@ void *SSOpar(void *argument)
if ( cdoVerbose )
cdoPrint("lhavevct=TRUE zaxisIDh = %d, nhlevf = %d", zaxisIDh, nlevel);
vct = malloc(nvct*sizeof(double));
vct = (double*) malloc(nvct*sizeof(double));
zaxisInqVct(zaxisID, vct);
if ( cdoVerbose )
......@@ -802,7 +802,7 @@ void *SSOpar(void *argument)
}
if ( zaxisIDh == -1 )
cdoAbort("No data on hybrid model level found!");
cdoAbort("No 3D variable with hybrid sigma pressure coordinate found!");
nvars = vlistNvars(vlistID1);
......@@ -866,18 +866,18 @@ void *SSOpar(void *argument)
if ( tempID == -1 ) cdoAbort("Temperature not found!");
array = malloc(ngp*sizeof(double));
array = (double*) malloc(ngp*sizeof(double));
geop = malloc(ngp*sizeof(double));
ps = malloc(ngp*sizeof(double));
geop = (double*) malloc(ngp*sizeof(double));
ps = (double*) malloc(ngp*sizeof(double));
temp = malloc(ngp*nhlevf*sizeof(double));
hum = malloc(ngp*nhlevf*sizeof(double));
lwater = malloc(ngp*nhlevf*sizeof(double));
iwater = malloc(ngp*nhlevf*sizeof(double));
temp = (double*) malloc(ngp*nhlevf*sizeof(double));
hum = (double*) malloc(ngp*nhlevf*sizeof(double));
lwater = (double*) malloc(ngp*nhlevf*sizeof(double));
iwater = (double*) malloc(ngp*nhlevf*sizeof(double));
half_press = malloc(ngp*(nhlevf+1)*sizeof(double));
geopotheight = malloc(ngp*(nhlevf+1)*sizeof(double));
half_press = (double*) malloc(ngp*(nhlevf+1)*sizeof(double));
geopotheight = (double*) malloc(ngp*(nhlevf+1)*sizeof(double));
if ( zaxisIDh != -1 && geopID == -1 )
{
......
......@@ -61,7 +61,7 @@ void *Vertint(void *argument)
int geopID = -1, tempID = -1, psID = -1, lnpsID = -1, gheightID = -1;
int code, param;
int pnum, pcat, pdis;
int sortlevels = TRUE;
//int sortlevels = TRUE;
int **varnmiss = NULL, *pnmiss = NULL;
int *varinterp = NULL;
char paramstr[32];
......@@ -114,7 +114,7 @@ void *Vertint(void *argument)
}
}
}
else
else if ( operatorID == ML2PLX || operatorID == ML2HLX || operatorID == ML2PLX_LP || operatorID == ML2HLX_LP )
{
Extrapolate = 1;
}
......@@ -175,7 +175,7 @@ void *Vertint(void *argument)
{
double *level;
int l;
level = malloc(nlevel*sizeof(double));
level = (double*) malloc(nlevel*sizeof(double));
zaxisInqLevels(zaxisID, level);
for ( l = 0; l < nlevel; l++ )
{
......@@ -199,7 +199,7 @@ void *Vertint(void *argument)
nhlevf = nhlev;
nhlevh = nhlevf + 1;
vct = malloc(nvct*sizeof(double));
vct = (double*) malloc(nvct*sizeof(double));
zaxisInqVct(zaxisID, vct);
vlistChangeZaxisIndex(vlistID2, i, zaxisIDp);
......@@ -220,7 +220,7 @@ void *Vertint(void *argument)
nhlevf = nhlev - 1;
nhlevh = nhlev;
vct = malloc(nvct*sizeof(double));
vct = (double*) malloc(nvct*sizeof(double));
zaxisInqVct(zaxisID, vct);
vlistChangeZaxisIndex(vlistID2, i, zaxisIDp);
......@@ -238,7 +238,7 @@ void *Vertint(void *argument)
int vctsize;
int voff = 4;
rvct = malloc(nvct*sizeof(double));
rvct = (double*) malloc(nvct*sizeof(double));
zaxisInqVct(zaxisID, rvct);
if ( (int)(rvct[0]+0.5) == 100000 && rvct[voff] < rvct[voff+1] )
......@@ -250,7 +250,7 @@ void *Vertint(void *argument)
nhlevh = nhlev + 1;
vctsize = 2*nhlevh;
vct = malloc(vctsize*sizeof(double));
vct = (double*) malloc(vctsize*sizeof(double));
vlistChangeZaxisIndex(vlistID2, i, zaxisIDp);
......@@ -288,16 +288,16 @@ void *Vertint(void *argument)
nvars = vlistNvars(vlistID1);
vars = malloc(nvars*sizeof(int));
vardata1 = malloc(nvars*sizeof(double*));
vardata2 = malloc(nvars*sizeof(double*));
varnmiss = malloc(nvars*sizeof(int*));
varinterp = malloc(nvars*sizeof(int));
vars = (int*) malloc(nvars*sizeof(int));
vardata1 = (double**) malloc(nvars*sizeof(double*));
vardata2 = (double**) malloc(nvars*sizeof(double*));
varnmiss = (int**) malloc(nvars*sizeof(int*));
varinterp = (int*) malloc(nvars*sizeof(int));
maxlev = nhlevh > nplev ? nhlevh : nplev;
if ( Extrapolate == 0 )
pnmiss = malloc(nplev*sizeof(int));
pnmiss = (int*) malloc(nplev*sizeof(int));
// check levels
if ( zaxisIDh != -1 )
......@@ -311,7 +311,7 @@ void *Vertint(void *argument)
{
if ( (ilev+1) != (int)levels[ilev] )
{
sortlevels = FALSE;
//sortlevels = FALSE;
break;
}
}
......@@ -319,17 +319,17 @@ void *Vertint(void *argument)
if ( zaxisIDh != -1 && ngp > 0 )
{
vert_index = malloc(ngp*nplev*sizeof(int));
ps_prog = malloc(ngp*sizeof(double));
full_press = malloc(ngp*nhlevf*sizeof(double));
half_press = malloc(ngp*nhlevh*sizeof(double));
vert_index = (int*) malloc(ngp*nplev*sizeof(int));
ps_prog = (double*) malloc(ngp*sizeof(double));
full_press = (double*) malloc(ngp*nhlevf*sizeof(double));
half_press = (double*) malloc(ngp*nhlevh*sizeof(double));
}
else
cdoWarning("No data on hybrid sigma pressure levels found!");
cdoWarning("No 3D variable with hybrid sigma pressure coordinate found!");
if ( operfunc == func_hl )
{
phlev = malloc(nplev*sizeof(double));
phlev = (double*) malloc(nplev*sizeof(double));
h2p(phlev, plev, nplev);
if ( cdoVerbose )
......@@ -447,17 +447,17 @@ void *Vertint(void *argument)
cdoAbort("Spectral data unsupported!");
if ( varID == gheightID )
vardata1[varID] = malloc(gridsize*(nlevel+1)*sizeof(double));
vardata1[varID] = (double*) malloc(gridsize*(nlevel+1)*sizeof(double));
else
vardata1[varID] = malloc(gridsize*nlevel*sizeof(double));
vardata1[varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
/* if ( zaxisInqType(zaxisID) == ZAXIS_HYBRID && zaxisIDh != -1 && nlevel == nhlev ) */
if ( zaxisID == zaxisIDh ||
(zaxisInqType(zaxisID) == ZAXIS_HYBRID && zaxisIDh != -1 && (nlevel == nhlevh || nlevel == nhlevf)) )
{
varinterp[varID] = TRUE;
vardata2[varID] = malloc(gridsize*nplev*sizeof(double));
varnmiss[varID] = malloc(maxlev*sizeof(int));
vardata2[varID] = (double*) malloc(gridsize*nplev*sizeof(double));
varnmiss[varID] = (int*) malloc(maxlev*sizeof(int));
memset(varnmiss[varID], 0, maxlev*sizeof(int));
}
else
......@@ -467,7 +467,7 @@ void *Vertint(void *argument)
varID+1, paramstr, nlevel);
varinterp[varID] = FALSE;
vardata2[varID] = vardata1[varID];
varnmiss[varID] = malloc(nlevel*sizeof(int));
varnmiss[varID] = (int*) malloc(nlevel*sizeof(int));
}
}
......@@ -484,7 +484,7 @@ void *Vertint(void *argument)
if ( zaxisIDh != -1 && geop_needed )
{
geop = malloc(ngp*sizeof(double));
geop = (double*) malloc(ngp*sizeof(double));
if ( geopID == -1 )
{
cdoWarning("%s not found - using zero %s!", var_stdname(surface_geopotential), var_stdname(surface_geopotential));
......
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