Commit 0a78bd58 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Arith: print warning message if stream2 has more time steps than stream1.

parent e6090b86
Pipeline #11259 passed with stages
in 16 minutes and 41 seconds
......@@ -136,7 +136,7 @@ Arith(void *process)
const auto nvars1 = vlistNvars(vlistID1);
const auto nvars2 = vlistNvars(vlistID2);
bool lfill1 = false, lfill2 = false, lfill1x = false;
auto lfill1 = false, lfill2 = false, lfill1x = false;
if (nvars1 == 1 && nvars2 == 1)
{
lfill2 = vlistNrecs(vlistID1) != 1 && vlistNrecs(vlistID2) == 1;
......@@ -265,19 +265,21 @@ Arith(void *process)
varListInit(varList1, vlistID1x);
varListInit(varList2, vlistID2x);
int nrecs, nrecs2;
int tsID = 0;
int tsID2 = 0;
while (true)
{
const auto nrecs = cdo_stream_inq_timestep(streamID1, tsID);
if (nrecs == 0) break;
nrecs = cdo_stream_inq_timestep(streamID1, tsID);
int nrecs2 = 0;
nrecs2 = 0;
if (tsID == 0 || filltype == FILL_NONE || filltype == FILL_FILE || filltype == FILL_VARTS)
{
nrecs2 = cdo_stream_inq_timestep(streamID2, tsID2);
if (nrecs2 == 0)
{
if (nrecs == 0) break;
if (filltype == FILL_NONE && streamID2x == streamID2)
{
filltype = FILL_FILE;
......@@ -306,13 +308,15 @@ Arith(void *process)
}
}
if (nrecs == 0 || nrecs2 == 0) break;
cdo_taxis_copy_timestep(taxisID3, taxisID1);
cdo_def_timestep(streamID3, tsID);
const auto numrecs = lfill1x ? nrecs2 : nrecs;
for (int recID = 0; recID < numrecs; recID++)
{
bool lread1 = true;
auto lread1 = true;
if (lfill1x && recID > 0) lread1 = false;
int varID = -1, levelID;
if (lread1)
......@@ -334,7 +338,7 @@ Arith(void *process)
if (tsID == 0 || filltype == FILL_NONE || filltype == FILL_FILE || filltype == FILL_VARTS)
{
const bool lstatus = nlevels2 > 1 ? varID == 0 : recID == 0;
const auto lstatus = (nlevels2 > 1) ? varID == 0 : recID == 0;
if (lstatus || (filltype != FILL_VAR && filltype != FILL_VARTS))
{
cdo_inq_record(streamID2, &varID2, &levelID2);
......@@ -408,6 +412,9 @@ Arith(void *process)
tsID2++;
}
if (nrecs == 0 && nrecs2 > 0) cdo_warning("stream2 has more time steps than stream1!");
//if (nrecs > 0 && nrecs2 == 0) cdo_warning("stream1 has more time steps than stream2!");
cdo_stream_close(streamID3);
cdo_stream_close(streamID2);
cdo_stream_close(streamID1);
......
......@@ -140,8 +140,7 @@ diffGetParameter(double &abslim, double &abslim2, double &rellim, int &mapflag,
void *
Diff(void *process)
{
bool lhead = true;
int nrecs, nrecs2;
auto printHeader = true;
int varID1, varID2 = -1;
int levelID;
int ndrec = 0, nd2rec = 0, ngrec = 0;
......@@ -194,11 +193,12 @@ Diff(void *process)
const auto taxisID = vlistInqTaxis(vlistID1);
int nrecs, nrecs2;
int indg = 0;
int tsID = 0;
while (true)
{
bool lstop = false;
auto stopLoop = false;
nrecs = cdo_stream_inq_timestep(streamID1, tsID);
const auto vdateString = date_to_string(taxisInqVdate(taxisID));
......@@ -253,7 +253,7 @@ Diff(void *process)
const auto hasMissvals = (field1.nmiss || field2.nmiss);
size_t ndiff = 0;
bool dsgn = false, zero = false;
auto dsgn = false, zero = false;
double absm = 0.0, relm = 0.0;
for (size_t i = 0; i < gridsize; i++)
......@@ -265,9 +265,9 @@ Diff(void *process)
{
if (absm > abslim || (checkrel && relm >= rellim) || Options::cdoVerbose)
{
if (lhead)
if (printHeader)
{
lhead = false;
printHeader = false;
fprintf(stdout, " Date Time Level Gridsize Miss ");
fprintf(stdout, " Diff ");
......@@ -321,12 +321,12 @@ Diff(void *process)
if (maxcount > 0 && ndrec >= maxcount)
{
lstop = true;
stopLoop = true;
break;
}
}
if (lstop) break;
if (stopLoop) break;
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