Commit 0236f406 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Merge declaration and initialization.

parent f83f19ec
......@@ -64,7 +64,7 @@ void *Vertintap(void *argument)
enum {func_pl, func_hl};
enum {type_lin, type_log};
int nrecs;
int i, k, offset;
int i;
int varID, levelID;
int zaxisIDp, zaxisIDh = -1;
int nhlev = 0, nhlevf = 0, nhlevh = 0, nlevel;
......@@ -72,15 +72,13 @@ void *Vertintap(void *argument)
int apressID = -1, dpressID = -1;
int psID = -1, tempID = -1;
//int sortlevels = TRUE;
int *pnmiss = NULL;
char paramstr[32];
char stdname[CDI_MAX_NAME];
char varname[CDI_MAX_NAME];
double *vct = NULL;
double *single1, *single2;
double *ps_prog = NULL, *full_press = NULL, *dpress = NULL;
double *hyb_press = NULL;
int Extrapolate = 0;
bool extrapolate = false;
lista_t *flista = lista_new(FLT_LISTA);
cdoInitialize(argument);
......@@ -104,14 +102,14 @@ void *Vertintap(void *argument)
if ( envstr && isdigit((int) envstr[0]) )
{
Extrapolate = atoi(envstr);
if ( Extrapolate == 1 )
if ( atoi(envstr) == 1 ) extrapolate = true;
if ( extrapolate )
cdoPrint("Extrapolation of missing values enabled!");
}
}
else if ( operatorID == AP2PLX || operatorID == AP2HLX || operatorID == AP2PLX_LP )
{
Extrapolate = 1;
extrapolate = true;
}
operatorInputArg(cdoOperatorEnter(operatorID));
......@@ -231,8 +229,7 @@ void *Vertintap(void *argument)
int maxlev = nhlevh > nplev ? nhlevh : nplev;
if ( Extrapolate == 0 )
pnmiss = (int *) Malloc(nplev*sizeof(int));
int *pnmiss = extrapolate ? (int *) Malloc(nplev*sizeof(int)) : NULL;
// check levels
if ( zaxisIDh != -1 )
......@@ -266,7 +263,7 @@ void *Vertintap(void *argument)
if ( operfunc == func_hl )
{
double *phlev =(double*) Malloc(nplev*sizeof(double));
double *phlev = (double*) Malloc(nplev*sizeof(double));
height2pressure(phlev, plev, nplev);
if ( cdoVerbose )
......@@ -278,7 +275,7 @@ void *Vertintap(void *argument)
}
if ( opertype == type_log )
for ( k = 0; k < nplev; k++ ) plev[k] = log(plev[k]);
for ( int k = 0; k < nplev; k++ ) plev[k] = log(plev[k]);
for ( varID = 0; varID < nvars; varID++ )
{
......@@ -351,8 +348,8 @@ void *Vertintap(void *argument)
printf("levelID %d\n", levelID);
}
*/
offset = gridsize*levelID;
single1 = vardata1[varID] + offset;
size_t offset = gridsize*levelID;
double *single1 = vardata1[varID] + offset;
pstreamReadRecord(streamID1, single1, &varnmiss[varID][levelID]);
......@@ -372,7 +369,7 @@ void *Vertintap(void *argument)
{
memcpy(dpress, vardata1[dpressID], gridsize*nhlevf*sizeof(double));
for ( i = 0; i < gridsize; i++ ) ps_prog[i] = 0;
for ( k = 0; k < nhlevf; ++k )
for ( int k = 0; k < nhlevf; ++k )
for ( i = 0; i < gridsize; i++ )
ps_prog[i] += dpress[k*gridsize+i];
}
......@@ -394,15 +391,14 @@ void *Vertintap(void *argument)
{
for ( i = 0; i < gridsize; i++ ) ps_prog[i] = log(ps_prog[i]);
for ( k = 0; k < nhlevf; k++ )
for ( int k = 0; k < nhlevf; k++ )
for ( i = 0; i < gridsize; i++ )
full_press[k*gridsize+i] = log(full_press[k*gridsize+i]);
}
genind(vert_index, plev, full_press, gridsize, nplev, nhlevf);
if ( Extrapolate == 0 )
genindmiss(vert_index, plev, gridsize, nplev, ps_prog, pnmiss);
if ( !extrapolate ) genindmiss(vert_index, plev, gridsize, nplev, ps_prog, pnmiss);
}
for ( varID = 0; varID < nvars; varID++ )
......@@ -434,8 +430,7 @@ void *Vertintap(void *argument)
interp_X(vardata1[varID], vardata2[varID], hyb_press,
vert_index, plev, nplev, gridsize, nlevel, missval);
if ( Extrapolate == 0 )
memcpy(varnmiss[varID], pnmiss, nplev*sizeof(int));
if ( !extrapolate ) memcpy(varnmiss[varID], pnmiss, nplev*sizeof(int));
}
}
}
......@@ -447,8 +442,8 @@ void *Vertintap(void *argument)
int nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
for ( levelID = 0; levelID < nlevel; levelID++ )
{
offset = gridsize*levelID;
single2 = vardata2[varID] + offset;
size_t offset = gridsize*levelID;
double *single2 = vardata2[varID] + offset;
pstreamDefRecord(streamID2, varID, levelID);
pstreamWriteRecord(streamID2, single2, varnmiss[varID][levelID]);
}
......
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