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

Replace recVarID by recinfo.

parent 2a3c0180
......@@ -59,10 +59,9 @@ void *Runpctl(void *argument)
pstreamDefVlist(streamID2, vlistID2);
int nvars = vlistNvars(vlistID1);
int nrecords = vlistNrecs(vlistID1);
int *recVarID = (int*) Malloc(nrecords*sizeof(int));
int *recLevelID = (int*) Malloc(nrecords*sizeof(int));
int maxrecs = vlistNrecs(vlistID1);
std::vector<recinfo_type> recinfo(maxrecs);
dtlist_type *dtlist = dtlist_new();
dtlist_set_stat(dtlist, timestat_date);
......@@ -88,8 +87,9 @@ void *Runpctl(void *argument)
if ( tsID == 0 )
{
recVarID[recID] = varID;
recLevelID[recID] = levelID;
recinfo[recID].varID = varID;
recinfo[recID].levelID = levelID;
recinfo[recID].lconst = vlistInqVarTimetype(vlistID1, varID) == TIME_CONSTANT;
}
pstreamReadRecord(streamID1, vars1[tsID][varID][levelID].ptr, &nmiss);
......@@ -105,8 +105,8 @@ void *Runpctl(void *argument)
if ( vlistInqVarTimetype(vlistID1, varID) == TIME_CONSTANT ) continue;
int gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
double missval = vlistInqVarMissval(vlistID1, varID);
int nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
int nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
double missval = vlistInqVarMissval(vlistID1, varID);
for ( levelID = 0; levelID < nlevels; levelID++ )
{
......@@ -137,12 +137,12 @@ void *Runpctl(void *argument)
dtlist_stat_taxisDefTimestep(dtlist, taxisID2, ndates);
pstreamDefTimestep(streamID2, otsID);
for ( int recID = 0; recID < nrecords; recID++ )
for ( int recID = 0; recID < maxrecs; recID++ )
{
varID = recVarID[recID];
levelID = recLevelID[recID];
if ( otsID && recinfo[recID].lconst ) continue;
if ( otsID && vlistInqVarTimetype(vlistID1, varID) == TIME_CONSTANT ) continue;
int varID = recinfo[recID].varID;
int levelID = recinfo[recID].levelID;
pstreamDefRecord(streamID2, varID, levelID);
pstreamWriteRecord(streamID2, vars1[0][varID][levelID].ptr, vars1[0][varID][levelID].nmiss);
......@@ -175,9 +175,6 @@ void *Runpctl(void *argument)
Free(vars1);
Free(array);
if ( recVarID ) Free(recVarID);
if ( recLevelID ) Free(recLevelID);
dtlist_delete(dtlist);
......
......@@ -41,7 +41,7 @@ void *Runstat(void *argument)
int varID;
int levelID;
size_t nmiss;
int runstat_nomiss = 0;
bool runstat_nomiss = false;
cdoInitialize(argument);
......@@ -50,7 +50,7 @@ void *Runstat(void *argument)
{
char *endptr;
int envval = (int) strtol(envstr, &endptr, 10);
if ( envval == 1 ) runstat_nomiss = 1;
if ( envval == 1 ) runstat_nomiss = true;
}
// clang-format off
......@@ -277,18 +277,14 @@ void *Runstat(void *argument)
dtlist_shift(dtlist);
vars1[ndates] = vars1[0];
if ( !runstat_nomiss )
samp1[ndates] = samp1[0];
if ( lvarstd || lrange )
vars2[ndates] = vars2[0];
if ( !runstat_nomiss ) samp1[ndates] = samp1[0];
if ( lvarstd || lrange ) vars2[ndates] = vars2[0];
for ( int inp = 0; inp < ndates; inp++ )
{
vars1[inp] = vars1[inp+1];
if ( !runstat_nomiss )
samp1[inp] = samp1[inp+1];
if ( lvarstd || lrange )
vars2[inp] = vars2[inp+1];
if ( !runstat_nomiss ) samp1[inp] = samp1[inp+1];
if ( lvarstd || lrange ) vars2[inp] = vars2[inp+1];
}
int nrecs = pstreamInqTimestep(streamID1, tsID);
......
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