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