Commit 846ddc83 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

bug fix for datasets with time constant fields

parent cf969384
......@@ -6,6 +6,8 @@ Version 1.4.7 (?? December 2010):
New operators:
* ydayadd, ydaysub, ydaymul, ydaydiv: Multi-year daily arithmetic
* dv2ps: Divergence and vorticity to velocity potential and stream function
Fixed bugs:
* Yseasstat: bug fix for datasets with time constant fields
Version 1.4.6 (17 September 2010):
......
......@@ -186,20 +186,21 @@ void *Runpctl(void *argument)
taxisDefVdate(taxisID2, datetime[ndates].date);
taxisDefVtime(taxisID2, datetime[ndates].time);
streamDefTimestep(streamID2, otsID++);
streamDefTimestep(streamID2, otsID);
for ( recID = 0; recID < nrecords; recID++ )
{
varID = recVarID[recID];
levelID = recLevelID[recID];
if ( otsID == 1 || vlistInqVarTime(vlistID1, varID) == TIME_VARIABLE )
{
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, vars1[0][varID][levelID].ptr, vars1[0][varID][levelID].nmiss);
}
if ( otsID && vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, vars1[0][varID][levelID].ptr, vars1[0][varID][levelID].nmiss);
}
otsID++;
datetime[ndates] = datetime[0];
vars1[ndates] = vars1[0];
......
......@@ -324,20 +324,21 @@ void *Runstat(void *argument)
taxisDefVdate(taxisID2, datetime[ndates].date);
taxisDefVtime(taxisID2, datetime[ndates].time);
streamDefTimestep(streamID2, otsID++);
streamDefTimestep(streamID2, otsID);
for ( recID = 0; recID < nrecords; recID++ )
{
varID = recVarID[recID];
levelID = recLevelID[recID];
if ( otsID == 1 || vlistInqVarTime(vlistID1, varID) == TIME_VARIABLE )
{
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, vars1[0][varID][levelID].ptr, vars1[0][varID][levelID].nmiss);
}
if ( otsID && vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, vars1[0][varID][levelID].ptr, vars1[0][varID][levelID].nmiss);
}
otsID++;
datetime[ndates] = datetime[0];
vars1[ndates] = vars1[0];
samp1[ndates] = samp1[0];
......
......@@ -192,21 +192,21 @@ void *Seascount(void *argument)
taxisDefVdate(taxisID2, vdate0);
taxisDefVtime(taxisID2, vtime0);
streamDefTimestep(streamID2, otsID++);
streamDefTimestep(streamID2, otsID);
for ( recID = 0; recID < nrecords; recID++ )
{
varID = recVarID[recID];
levelID = recLevelID[recID];
if ( otsID == 1 || vlistInqVarTime(vlistID1, varID) == TIME_VARIABLE )
{
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, vars1[varID][levelID].ptr, vars1[varID][levelID].nmiss);
}
if ( otsID && vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, vars1[varID][levelID].ptr, vars1[varID][levelID].nmiss);
}
if ( nrecs == 0 ) break;
otsID++;
}
for ( varID = 0; varID < nvars; varID++ )
......
......@@ -244,21 +244,21 @@ void *Seaspctl(void *argument)
taxisDefVdate(taxisID4, vdate4);
taxisDefVtime(taxisID4, vtime4);
streamDefTimestep(streamID4, otsID++);
streamDefTimestep(streamID4, otsID);
for ( recID = 0; recID < nrecords; recID++ )
{
varID = recVarID[recID];
levelID = recLevelID[recID];
if ( otsID == 1 || vlistInqVarTime(vlistID1, varID) == TIME_VARIABLE )
{
streamDefRecord(streamID4, varID, levelID);
streamWriteRecord(streamID4, vars1[varID][levelID].ptr, vars1[varID][levelID].nmiss);
}
if ( otsID && vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
streamDefRecord(streamID4, varID, levelID);
streamWriteRecord(streamID4, vars1[varID][levelID].ptr, vars1[varID][levelID].nmiss);
}
if ( nrecs == 0 ) break;
otsID++;
}
for ( varID = 0; varID < nvars; varID++ )
......
......@@ -117,7 +117,7 @@ void *Splitsel(void *argument)
}
if ( tsID < noffset )
{
cdoWarning("noffset larger than number of timesteps!");
cdoWarning("noffset is larger than number of timesteps!");
goto LABEL_END;
}
......
......@@ -167,21 +167,21 @@ void *Timcount(void *argument)
taxisDefVdate(taxisID2, vdate0);
taxisDefVtime(taxisID2, vtime0);
streamDefTimestep(streamID2, otsID++);
streamDefTimestep(streamID2, otsID);
for ( recID = 0; recID < nrecords; recID++ )
{
varID = recVarID[recID];
levelID = recLevelID[recID];
if ( otsID == 1 || vlistInqVarTime(vlistID1, varID) == TIME_VARIABLE )
{
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, vars1[varID][levelID].ptr, vars1[varID][levelID].nmiss);
}
if ( otsID && vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, vars1[varID][levelID].ptr, vars1[varID][levelID].nmiss);
}
if ( nrecs == 0 ) break;
otsID++;
}
for ( varID = 0; varID < nvars; varID++ )
......
......@@ -212,21 +212,21 @@ static void timpctl(int operatorID)
taxisDefVdate(taxisID4, vdate4);
taxisDefVtime(taxisID4, vtime4);
streamDefTimestep(streamID4, otsID++);
streamDefTimestep(streamID4, otsID);
for ( recID = 0; recID < nrecords; recID++ )
{
varID = recVarID[recID];
levelID = recLevelID[recID];
if ( otsID == 1 || vlistInqVarTime(vlistID1, varID) == TIME_VARIABLE )
{
streamDefRecord(streamID4, varID, levelID);
streamWriteRecord(streamID4, vars1[varID][levelID].ptr, vars1[varID][levelID].nmiss);
}
if ( otsID && vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
streamDefRecord(streamID4, varID, levelID);
streamWriteRecord(streamID4, vars1[varID][levelID].ptr, vars1[varID][levelID].nmiss);
}
if ( nrecs == 0 ) break;
otsID++;
}
for ( varID = 0; varID < nvars; varID++ )
......
......@@ -139,12 +139,22 @@ void *Timselpctl(void *argument)
{
nrecs = streamInqTimestep(streamID1, tsID);
if ( nrecs == 0 ) break;
tsID++;
for ( recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
if ( tsID == 0 )
{
recVarID[recID] = varID;
recLevelID[recID] = levelID;
}
}
}
if ( tsID < noffset )
{
cdoWarning("noffset larger than number of timesteps!");
cdoWarning("noffset is larger than number of timesteps!");
goto LABEL_END;
}
......@@ -153,14 +163,16 @@ void *Timselpctl(void *argument)
{
nrecs = streamInqTimestep(streamID2, otsID);
if ( nrecs != streamInqTimestep(streamID3, otsID) )
cdoAbort("Number of records in time step %d of %s and %s are different!", otsID+1, cdoStreamName(1), cdoStreamName(2));
cdoAbort("Number of records in time step %d of %s and %s are different!",
otsID+1, cdoStreamName(1), cdoStreamName(2));
vdate2 = taxisInqVdate(taxisID2);
vtime2 = taxisInqVtime(taxisID2);
vdate3 = taxisInqVdate(taxisID3);
vtime3 = taxisInqVtime(taxisID3);
if ( vdate2 != vdate3 || vtime2 != vtime3 )
cdoAbort("Verification dates for time step %d of %s and %s are different!", otsID+1, cdoStreamName(1), cdoStreamName(2));
cdoAbort("Verification dates for time step %d of %s and %s are different!",
otsID+1, cdoStreamName(1), cdoStreamName(2));
for ( recID = 0; recID < nrecs; recID++ )
{
......@@ -192,8 +204,11 @@ void *Timselpctl(void *argument)
{
streamInqRecord(streamID1, &varID, &levelID);
recVarID[recID] = varID;
recLevelID[recID] = levelID;
if ( tsID == 0 )
{
recVarID[recID] = varID;
recLevelID[recID] = levelID;
}
streamReadRecord(streamID1, vars1[varID][levelID].ptr, &nmiss);
vars1[varID][levelID].nmiss = nmiss;
......@@ -209,9 +224,11 @@ void *Timselpctl(void *argument)
if ( nrecs == 0 && nsets == 0 ) break;
if ( vdate2 != vdate4 )
cdoAbort("Verification dates for time step %d of %s, %s and %s are different!", otsID+1, cdoStreamName(1), cdoStreamName(2), cdoStreamName(3));
cdoAbort("Verification dates for time step %d of %s, %s and %s are different!",
otsID+1, cdoStreamName(1), cdoStreamName(2), cdoStreamName(3));
if ( vtime2 != vtime4 )
cdoAbort("Verification times for time step %d of %s, %s and %s are different!", otsID+1, cdoStreamName(1), cdoStreamName(2), cdoStreamName(3));
cdoAbort("Verification times for time step %d of %s, %s and %s are different!",
otsID+1, cdoStreamName(1), cdoStreamName(2), cdoStreamName(3));
for ( varID = 0; varID < nvars; varID++ )
{
......@@ -224,21 +241,21 @@ void *Timselpctl(void *argument)
taxisDefVdate(taxisID4, vdate4);
taxisDefVtime(taxisID4, vtime4);
streamDefTimestep(streamID4, otsID++);
streamDefTimestep(streamID4, otsID);
for ( recID = 0; recID < nrecords; recID++ )
{
varID = recVarID[recID];
levelID = recLevelID[recID];
if ( otsID == 1 || vlistInqVarTime(vlistID1, varID) == TIME_VARIABLE )
{
streamDefRecord(streamID4, varID, levelID);
streamWriteRecord(streamID4, vars1[varID][levelID].ptr, vars1[varID][levelID].nmiss);
}
if ( otsID && vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
streamDefRecord(streamID4, varID, levelID);
streamWriteRecord(streamID4, vars1[varID][levelID].ptr, vars1[varID][levelID].nmiss);
}
if ( nrecs == 0 ) break;
otsID++;
for ( i = 0; i < nskip; i++ )
{
......
......@@ -147,11 +147,22 @@ void *Timselstat(void *argument)
{
nrecs = streamInqTimestep(streamID1, tsID);
if ( nrecs == 0 ) break;
for ( recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
if ( tsID == 0 )
{
recVarID[recID] = varID;
recLevelID[recID] = levelID;
}
}
}
if ( tsID < noffset )
{
cdoWarning("noffset larger than number of timesteps!");
cdoWarning("noffset is larger than number of timesteps!");
goto LABEL_END;
}
......@@ -170,8 +181,11 @@ void *Timselstat(void *argument)
{
streamInqRecord(streamID1, &varID, &levelID);
recVarID[recID] = varID;
recLevelID[recID] = levelID;
if ( tsID == 0 )
{
recVarID[recID] = varID;
recLevelID[recID] = levelID;
}
gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
......@@ -281,21 +295,21 @@ void *Timselstat(void *argument)
taxisDefVdate(taxisID2, vdate0);
taxisDefVtime(taxisID2, vtime0);
streamDefTimestep(streamID2, otsID++);
streamDefTimestep(streamID2, otsID);
for ( recID = 0; recID < nrecords; recID++ )
{
varID = recVarID[recID];
levelID = recLevelID[recID];
if ( otsID == 1 || vlistInqVarTime(vlistID1, varID) == TIME_VARIABLE )
{
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, vars1[varID][levelID].ptr, vars1[varID][levelID].nmiss);
}
if ( otsID && vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, vars1[varID][levelID].ptr, vars1[varID][levelID].nmiss);
}
if ( nrecs == 0 ) break;
otsID++;
for ( i = 0; i < nskip; i++ )
{
......
......@@ -215,8 +215,11 @@ void *Ydaypctl(void *argument)
{
streamInqRecord(streamID1, &varID, &levelID);
recVarID[recID] = varID;
recLevelID[recID] = levelID;
if ( tsID == 0 )
{
recVarID[recID] = varID;
recLevelID[recID] = levelID;
}
streamReadRecord(streamID1, vars1[dayoy][varID][levelID].ptr, &nmiss);
vars1[dayoy][varID][levelID].nmiss = nmiss;
......@@ -248,19 +251,20 @@ void *Ydaypctl(void *argument)
taxisDefVdate(taxisID4, vdates1[dayoy]);
taxisDefVtime(taxisID4, vtimes1[dayoy]);
streamDefTimestep(streamID4, otsID++);
streamDefTimestep(streamID4, otsID);
for ( recID = 0; recID < nrecords; recID++ )
{
varID = recVarID[recID];
levelID = recLevelID[recID];
if ( otsID == 1 || vlistInqVarTime(vlistID1, varID) == TIME_VARIABLE )
{
streamDefRecord(streamID4, varID, levelID);
streamWriteRecord(streamID4, vars1[dayoy][varID][levelID].ptr, vars1[dayoy][varID][levelID].nmiss);
}
if ( otsID && vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
streamDefRecord(streamID4, varID, levelID);
streamWriteRecord(streamID4, vars1[dayoy][varID][levelID].ptr, vars1[dayoy][varID][levelID].nmiss);
}
otsID++;
}
for ( dayoy = 0; dayoy < NDAY; dayoy++ )
......
......@@ -179,8 +179,11 @@ void *Ydaystat(void *argument)
{
streamInqRecord(streamID1, &varID, &levelID);
recVarID[recID] = varID;
recLevelID[recID] = levelID;
if ( tsID == 0 )
{
recVarID[recID] = varID;
recLevelID[recID] = levelID;
}
gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
......@@ -291,20 +294,21 @@ void *Ydaystat(void *argument)
taxisDefVdate(taxisID2, vdates[dayoy]);
taxisDefVtime(taxisID2, vtimes[dayoy]);
streamDefTimestep(streamID2, otsID++);
streamDefTimestep(streamID2, otsID);
for ( recID = 0; recID < nrecords; recID++ )
{
varID = recVarID[recID];
levelID = recLevelID[recID];
if ( otsID == 1 || vlistInqVarTime(vlistID1, varID) == TIME_VARIABLE )
{
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, vars1[dayoy][varID][levelID].ptr,
vars1[dayoy][varID][levelID].nmiss);
}
if ( otsID && vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, vars1[dayoy][varID][levelID].ptr,
vars1[dayoy][varID][levelID].nmiss);
}
otsID++;
}
for ( dayoy = 0; dayoy < NDAY; dayoy++ )
......
......@@ -325,20 +325,21 @@ void *Ydrunpctl(void *argument)
taxisDefVdate(taxisID4, vdates1[dayoy]);
taxisDefVtime(taxisID4, vtimes1[dayoy]);
streamDefTimestep(streamID4, otsID++);
streamDefTimestep(streamID4, otsID);
for ( recID = 0; recID < nrecords; recID++ )
{
varID = recVarID[recID];
levelID = recLevelID[recID];
if ( otsID == 1 || vlistInqVarTime(vlistID1, varID) == TIME_VARIABLE )
{
streamDefRecord(streamID4, varID, levelID);
streamWriteRecord(streamID4, vars2[dayoy][varID][levelID].ptr,
vars2[dayoy][varID][levelID].nmiss);
}
if ( otsID && vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
streamDefRecord(streamID4, varID, levelID);
streamWriteRecord(streamID4, vars2[dayoy][varID][levelID].ptr,
vars2[dayoy][varID][levelID].nmiss);
}
otsID++;
}
for ( its = 0; its < ndates; its++ )
......
......@@ -275,20 +275,21 @@ void *Ydrunstat(void *argument)
{
taxisDefVdate(taxisID2, stats->vdate[dayoy]);
taxisDefVtime(taxisID2, stats->vtime[dayoy]);
streamDefTimestep(streamID2, otsID++);
streamDefTimestep(streamID2, otsID);
for ( recID = 0; recID < nrecords; recID++ )
{
varID = recVarID[recID];
levelID = recLevelID[recID];
if ( otsID == 1 || vlistInqVarTime(vlistID1, varID) == TIME_VARIABLE )
{
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, stats->vars1[dayoy][varID][levelID].ptr,
stats->vars1[dayoy][varID][levelID].nmiss);
}
if ( otsID && vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, stats->vars1[dayoy][varID][levelID].ptr,
stats->vars1[dayoy][varID][levelID].nmiss);
}
otsID++;
}
for ( its = 0; its < ndates; its++ )
......
......@@ -181,8 +181,11 @@ void *Yhourstat(void *argument)
{
streamInqRecord(streamID1, &varID, &levelID);
recVarID[recID] = varID;
recLevelID[recID] = levelID;
if ( tsID == 0 )
{
recVarID[recID] = varID;
recLevelID[recID] = levelID;
}
gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
......@@ -293,20 +296,21 @@ void *Yhourstat(void *argument)
taxisDefVdate(taxisID2, vdates[houroy]);
taxisDefVtime(taxisID2, vtimes[houroy]);
streamDefTimestep(streamID2, otsID++);
streamDefTimestep(streamID2, otsID);
for ( recID = 0; recID < nrecords; recID++ )
{
varID = recVarID[recID];
levelID = recLevelID[recID];
if ( otsID == 1 || vlistInqVarTime(vlistID1, varID) == TIME_VARIABLE )
{
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, vars1[houroy][varID][levelID].ptr,
vars1[houroy][varID][levelID].nmiss);
}
if ( otsID && vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, vars1[houroy][varID][levelID].ptr,
vars1[houroy][varID][levelID].nmiss);
}
otsID++;
}
for ( houroy = 0; houroy < NHOUR; houroy++ )
......
......@@ -202,8 +202,11 @@ void *Ymonpctl(void *argument)
{
streamInqRecord(streamID1, &varID, &levelID);
recVarID[recID] = varID;
recLevelID[recID] = levelID;
if ( tsID == 0 )
{
recVarID[recID] = varID;
recLevelID[recID] = levelID;
}
streamReadRecord(streamID1, vars1[month][varID][levelID].ptr, &nmiss);
vars1[month][varID][levelID].nmiss = nmiss;
......@@ -235,19 +238,20 @@ void *Ymonpctl(void *argument)
taxisDefVdate(taxisID4, vdates1[month]);
taxisDefVtime(taxisID4, vtimes1[month]);
streamDefTimestep(streamID4, otsID++);
streamDefTimestep(streamID4, otsID);
for ( recID = 0; recID < nrecords; recID++ )
{
varID = recVarID[recID];
levelID = recLevelID[recID];
if ( otsID == 1 || vlistInqVarTime(vlistID1, varID) == TIME_VARIABLE )
{
streamDefRecord(streamID4, varID, levelID);
streamWriteRecord(streamID4, vars1[month][varID][levelID].ptr, vars1[month][varID][levelID].nmiss);
}
if ( otsID && vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
streamDefRecord(streamID4, varID, levelID);
streamWriteRecord(streamID4, vars1[month][varID][levelID].ptr, vars1[month][varID][levelID].nmiss);
}
otsID++;
}
for ( month = 0; month < NMONTH; month++ )
......
......@@ -228,8 +228,11 @@ void *Yseaspctl(void *argument)
{
streamInqRecord(streamID1, &varID, &levelID);
recVarID[recID] = varID;
recLevelID[recID] = levelID;
if ( tsID == 0 )
{
recVarID[recID] = varID;
recLevelID[recID] = levelID;
}
streamReadRecord(streamID1, vars1[seas][varID][levelID].ptr, &nmiss);
vars1[seas][varID][levelID].nmiss = nmiss;
......@@ -261,19 +264,20 @@ void *Yseaspctl(void *argument)
taxisDefVdate(taxisID4, vdates1[seas]);
taxisDefVtime(taxisID4, vtimes1[seas]);
streamDefTimestep(streamID4, otsID++);
streamDefTimestep(streamID4, otsID);
for ( recID = 0; recID < nrecords; recID++ )
{
varID = recVarID[recID];
levelID = recLevelID[recID];
if ( otsID == 1 || vlistInqVarTime(vlistID1, varID) == TIME_VARIABLE )
{
streamDefRecord(streamID4, varID, levelID);
streamWriteRecord(streamID4, vars1[seas][varID][levelID].ptr, vars1[seas][varID][levelID].