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

arrayMinMaxMask: changed interface.

parent 0baa31f3
......@@ -231,7 +231,6 @@ Remapeta(void *process)
Varray<int> imiss;
int timer_hetaeta = 0;
double **vars1 = nullptr, **vars2 = nullptr;
double minval, maxval;
double missval = 0;
double cconst = 1.E-6;
double cptop = 0; /* min. pressure level for cond. */
......@@ -301,11 +300,11 @@ Remapeta(void *process)
}
// check range of surface_geopotential
arrayMinMaxMask(nfis2gp, fis2.data(), imiss, minval, maxval);
if (minval < MIN_FIS || maxval > MAX_FIS)
cdoWarning("%s out of range (min=%g max=%g)!", var_stdname(surface_geopotential), minval, maxval);
auto mm = arrayMinMaxMask(nfis2gp, fis2.data(), imiss);
if (mm.min < MIN_FIS || mm.max > MAX_FIS)
cdoWarning("%s out of range (min=%g max=%g)!", var_stdname(surface_geopotential), mm.min, mm.max);
if (minval < -1.e10 || maxval > 1.e10) cdoAbort("%s out of range!", var_stdname(surface_geopotential));
if (mm.min < -1.e10 || mm.max > 1.e10) cdoAbort("%s out of range!", var_stdname(surface_geopotential));
streamClose(streamID);
}
......@@ -580,12 +579,12 @@ Remapeta(void *process)
if (zaxisIDh != -1)
{
// check range of ps_prog
arrayMinMaxMask(gridsize, ps1.data(), imiss, minval, maxval);
if (minval < MIN_PS || maxval > MAX_PS) cdoWarning("Surface pressure out of range (min=%g max=%g)!", minval, maxval);
auto mm = arrayMinMaxMask(gridsize, ps1.data(), imiss);
if (mm.min < MIN_PS || mm.max > MAX_PS) cdoWarning("Surface pressure out of range (min=%g max=%g)!", mm.min, mm.max);
// check range of geop
arrayMinMaxMask(gridsize, fis1.data(), imiss, minval, maxval);
if (minval < MIN_FIS || maxval > MAX_FIS) cdoWarning("Orography out of range (min=%g max=%g)!", minval, maxval);
mm = arrayMinMaxMask(gridsize, fis1.data(), imiss);
if (mm.min < MIN_FIS || mm.max > MAX_FIS) cdoWarning("Orography out of range (min=%g max=%g)!", mm.min, mm.max);
}
if (!lfis2)
......@@ -600,9 +599,9 @@ Remapeta(void *process)
const auto offset = gridsize * levelID;
single2 = t1 + offset;
arrayMinMaxMask(gridsize, single2, imiss, minval, maxval);
if (minval < MIN_T || maxval > MAX_T)
cdoWarning("Input temperature at level %d out of range (min=%g max=%g)!", levelID + 1, minval, maxval);
auto mm = arrayMinMaxMask(gridsize, single2, imiss);
if (mm.min < MIN_T || mm.max > MAX_T)
cdoWarning("Input temperature at level %d out of range (min=%g max=%g)!", levelID + 1, mm.min, mm.max);
}
varID = sqID;
......@@ -614,9 +613,9 @@ Remapeta(void *process)
corr_hum(gridsize, single2, MIN_Q);
arrayMinMaxMask(gridsize, single2, imiss, minval, maxval);
if (minval < MIN_Q || maxval > MAX_Q)
cdoWarning("Input humidity at level %d out of range (min=%g max=%g)!", levelID + 1, minval, maxval);
auto mm = arrayMinMaxMask(gridsize, single2, imiss);
if (mm.min < MIN_Q || mm.max > MAX_Q)
cdoWarning("Input humidity at level %d out of range (min=%g max=%g)!", levelID + 1, mm.min, mm.max);
}
}
......@@ -660,9 +659,9 @@ Remapeta(void *process)
const auto offset = gridsize * levelID;
single2 = t2 + offset;
arrayMinMaxMask(gridsize, single2, imiss, minval, maxval);
if (minval < MIN_T || maxval > MAX_T)
cdoWarning("Output temperature at level %d out of range (min=%g max=%g)!", levelID + 1, minval, maxval);
auto mm = arrayMinMaxMask(gridsize, single2, imiss);
if (mm.min < MIN_T || mm.max > MAX_T)
cdoWarning("Output temperature at level %d out of range (min=%g max=%g)!", levelID + 1, mm.min, mm.max);
setmissval(gridsize, imiss, missval, single2);
cdoDefRecord(streamID2, varID, levelID);
......@@ -681,9 +680,9 @@ Remapeta(void *process)
if (levelID < nctop)
for (size_t i = 0; i < gridsize; ++i) single2[i] = cconst;
arrayMinMaxMask(gridsize, single2, imiss, minval, maxval);
if (minval < MIN_Q || maxval > MAX_Q)
cdoWarning("Output humidity at level %d out of range (min=%g max=%g)!", levelID + 1, minval, maxval);
auto mm = arrayMinMaxMask(gridsize, single2, imiss);
if (mm.min < MIN_Q || mm.max > MAX_Q)
cdoWarning("Output humidity at level %d out of range (min=%g max=%g)!", levelID + 1, mm.min, mm.max);
setmissval(gridsize, imiss, missval, single2);
cdoDefRecord(streamID2, varID, levelID);
......
......@@ -161,8 +161,8 @@ varrayMinMaxMeanMV(const size_t len, const Varray<double> &array, const double m
return MinMaxMean(mms.min, mms.max, rmean, mms.n);
}
void
arrayMinMaxMask(const size_t len, const double *array, const Varray<int> &mask, double &rmin, double &rmax)
MinMax
arrayMinMaxMask(const size_t len, const double *array, const Varray<int> &mask)
{
double zmin = DBL_MAX;
double zmax = -DBL_MAX;
......@@ -187,8 +187,7 @@ arrayMinMaxMask(const size_t len, const double *array, const Varray<int> &mask,
}
}
rmin = zmin;
rmax = zmax;
return MinMax(zmin, zmax);
}
void
......
......@@ -150,7 +150,7 @@ MinMaxSum varrayMinMaxSumMV(size_t len, const Varray<T> &array, T missval, MinMa
MinMaxMean varrayMinMaxMean(size_t len, const Varray<double> &array);
MinMaxMean varrayMinMaxMeanMV(size_t len, const Varray<double> &array, double missval);
void arrayMinMaxMask(size_t len, const double *array, const Varray<int> &mask, double &rmin, double &rmax);
MinMax arrayMinMaxMask(size_t len, const double *array, const Varray<int> &mask);
void arrayAddArray(size_t len, double *array1, const double *array2);
void arrayAddArrayMV(size_t len, double *array1, const double *array2, double missval);
......
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