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

Select: added function has_selected_params().

parent 8daaed79
Pipeline #5347 passed with stages
in 15 minutes and 37 seconds
......@@ -129,6 +129,23 @@ steptypeName(const int tsteptype)
return "unknown";
}
static bool
has_selected_params(int nvars, const VarList &varList, int vlistID)
{
bool hasSelectedParams = false;
for (int varID = 0; varID < nvars; ++varID)
{
for (int levID = 0; levID < varList[varID].nlevels; ++levID)
if (vlistInqFlag(vlistID, varID, levID) == true)
{
hasSelectedParams = true;
break;
}
}
return hasSelectedParams;
}
void *
Select(void *process)
{
......@@ -148,8 +165,8 @@ Select(void *process)
std::vector<bool> vars;
Varray2D<double> vardata2;
Varray<double> array;
double fstartdate = -99999999999.;
double fenddate = -99999999999.;
double fstartdate = -99999999999.0;
double fenddate = -99999999999.0;
cdoInitialize(process);
......@@ -255,8 +272,7 @@ Select(void *process)
xresult = false;
for (varID = 0; varID < nvars; ++varID)
{
const auto nlevels = varList1[varID].nlevels;
for (int levID = 0; levID < nlevels; ++levID) vlistDefFlag(vlistID1, varID, levID, true);
for (int levID = 0; levID < varList1[varID].nlevels; ++levID) vlistDefFlag(vlistID1, varID, levID, true);
}
}
......@@ -282,19 +298,15 @@ Select(void *process)
// stdname = varList1[varID].stdname;
param = paramstr;
const auto gridID = varList1[varID].gridID;
const auto zaxisID = varList1[varID].zaxisID;
const auto nlevels = varList1[varID].nlevels;
ltype = zaxis2ltype(zaxisID);
zaxisnum = vlistZaxisIndex(vlistID1, zaxisID) + 1;
const auto zaxistype = zaxisInqType(zaxisID);
zaxisName(zaxistype, zname);
zaxisName(zaxisInqType(zaxisID), zname);
zaxisname = zname;
gridnum = vlistGridIndex(vlistID1, gridID) + 1;
const auto gridtype = gridInqType(gridID);
gridName(gridtype, gname);
gridnum = vlistGridIndex(vlistID1, varList1[varID].gridID) + 1;
gridName(gridInqType(varList1[varID].gridID), gname);
gridname = gname;
steptype = steptypeName(varList1[varID].tsteptype);
......@@ -330,7 +342,7 @@ Select(void *process)
vars[varID] = true;
else if (!lvarsel && (SELINFO_NVAL(levidx) || SELINFO_NVAL(level)))
{
for (int levID = 0; levID < nlevels; ++levID)
for (int levID = 0; levID < varList1[varID].nlevels; ++levID)
{
levidx = levID + 1;
level = cdoZaxisInqLevel(zaxisID, levID);
......@@ -401,19 +413,21 @@ Select(void *process)
SELINFO_CHECK_FLAG(gridname);
SELINFO_CHECK_FLAG(steptype);
int npar = 0;
for (varID = 0; varID < nvars; ++varID)
if (has_selected_params(nvars, varList1, vlistID1))
{
const auto nlevels = varList1[varID].nlevels;
for (int levID = 0; levID < nlevels; ++levID)
if (vlistInqFlag(vlistID1, varID, levID) == true)
{
npar++;
break;
}
if (lvarsel && ltimsel)
{
for (varID = 0; varID < nvars; ++varID)
{
if (vars[varID] == true && varList1[varID].timetype == TIME_CONSTANT)
{
lcopy_const = true;
break;
}
}
}
}
if (npar == 0)
else
{
if ((!lvarsel) && (!llevsel) && ltimsel)
{
......@@ -431,28 +445,13 @@ Select(void *process)
cdoAbort("No variable selected!");
}
}
else
{
if (lvarsel && ltimsel)
{
for (varID = 0; varID < nvars; ++varID)
{
if (vars[varID] == true && varList1[varID].timetype == TIME_CONSTANT)
{
lcopy_const = true;
break;
}
}
}
}
// if ( Options::cdoVerbose ) vlistPrint(vlistID1);
vlistID0 = vlistDuplicate(vlistID1);
for (varID = 0; varID < nvars; ++varID)
{
const auto nlevels = varList1[varID].nlevels;
for (int levID = 0; levID < nlevels; ++levID)
for (int levID = 0; levID < varList1[varID].nlevels; ++levID)
vlistDefFlag(vlistID0, varID, levID, vlistInqFlag(vlistID1, varID, levID));
}
......
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