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

datetime: added Function taxisSetNextTimestep().

parent 6c85a2a1
Pipeline #4872 passed with stages
in 23 minutes and 42 seconds
......@@ -603,7 +603,7 @@ after_control(AfterControl &globs, struct Variable *vars)
while (true)
{
nrecs = streamInqTimestep(globs.istreamID, TsID);
if (nrecs <= 0) break;
if (nrecs == 0) break;
const auto vdate = taxisInqVdate(globs.taxisID);
const auto vtime = taxisInqVtime(globs.taxisID);
......
......@@ -301,8 +301,11 @@ Timstat(void *argument)
while (true)
{
int nsets = 0;
while ((nrecs = cdoStreamInqTimestep(streamID1, tsID)))
while (true)
{
nrecs = cdoStreamInqTimestep(streamID1, tsID);
if (nrecs == 0) break;
if (!Options::cdoVerbose && ntsteps1 > 1) progress::update(0, 1, (tsID + 1.) / ntsteps1);
dtlist.taxisInqTimestep(taxisID1, nsets);
......
......@@ -58,11 +58,9 @@ addOperators(void)
void *
Ymonstat(void *process)
{
const TimeStat timestat_date = TimeStat::LAST;
constexpr int MaxMonths = 17;
int nrecs;
int month_nsets[MaxMonths] = { 0 };
int64_t vdates[MaxMonths] = { 0 };
int vtimes[MaxMonths] = { 0 };
int mon[MaxMonths] = { 0 };
int nmon = 0;
FieldVector2D vars1[MaxMonths], vars2[MaxMonths], samp1[MaxMonths];
......@@ -90,7 +88,8 @@ Ymonstat(void *process)
const auto taxisID1 = vlistInqTaxis(vlistID1);
const auto taxisID2 = taxisDuplicate(taxisID1);
if (taxisHasBounds(taxisID2)) taxisDeleteBounds(taxisID2);
taxisWithBounds(taxisID2);
if (taxisInqType(taxisID2) == TAXIS_FORECAST) taxisDefType(taxisID2, TAXIS_RELATIVE);
vlistDefTaxis(vlistID2, taxisID2);
const auto streamID2 = cdoOpenWrite(1);
......@@ -99,6 +98,13 @@ Ymonstat(void *process)
const auto maxrecs = vlistNrecs(vlistID1);
std::vector<RecordInfo> recList(maxrecs);
DateTimeList dtlists[MaxMonths];
for (int month = 0; month < MaxMonths; ++ month)
{
dtlists[month].setStat(timestat_date);
dtlists[month].setCalendar(taxisInqCalendar(taxisID1));
}
const auto gridsizemax = vlistGridsizeMax(vlistID1);
Field field;
......@@ -106,8 +112,11 @@ Ymonstat(void *process)
int tsID = 0;
int otsID = 0;
while ((nrecs = cdoStreamInqTimestep(streamID1, tsID)))
while (true)
{
const auto nrecs = cdoStreamInqTimestep(streamID1, tsID);
if (nrecs == 0) break;
const auto vdate = taxisInqVdate(taxisID1);
const auto vtime = taxisInqVtime(taxisID1);
......@@ -116,9 +125,7 @@ Ymonstat(void *process)
const auto month = decodeMonth(vdate);
if (month < 0 || month >= MaxMonths) cdoAbort("Month %d out of range!", month);
vdates[month] = vdate;
vtimes[month] = vtime;
// mon[month] = vdate;
dtlists[month].taxisSetNextTimestep(taxisID1);
if (!vars1[month].size())
{
......@@ -264,8 +271,7 @@ Ymonstat(void *process)
}
}
taxisDefVdate(taxisID2, vdates[month]);
taxisDefVtime(taxisID2, vtimes[month]);
dtlists[month].statTaxisDefTimestep(taxisID2);
cdoDefTimestep(streamID2, otsID);
for (int recID = 0; recID < maxrecs; recID++)
......
......@@ -169,6 +169,13 @@ DateTimeList::taxisInqTimestep(const int taxisID, const int tsID)
}
}
void
DateTimeList::taxisSetNextTimestep(const int taxisID)
{
const int tsID = this->size;
this->taxisInqTimestep(taxisID, tsID);
}
void
DateTimeList::taxisDefTimestep(const int taxisID, const int tsID)
{
......@@ -275,6 +282,13 @@ DateTimeList::statTaxisDefTimestep(const int taxisID, const int nsteps)
}
}
void
DateTimeList::statTaxisDefTimestep(const int taxisID)
{
const int nsteps = this->size;
this->statTaxisDefTimestep(taxisID, nsteps);
}
void
datetime_avg(const int calendar, const int ndates, CdoDateTime *const datetime)
{
......
......@@ -103,9 +103,11 @@ public:
int getVtime(int tsID);
void shift();
void taxisSetNextTimestep(int taxisID);
void taxisInqTimestep(int taxisID, int tsID);
void taxisDefTimestep(int taxisID, int tsID);
void statTaxisDefTimestep(int taxisID, int nsteps);
void statTaxisDefTimestep(int taxisID);
private:
size_t nalloc = 0;
......
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