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

Removed MinMax varrayMinMaxMV(size_t len, const double *array, double missval, size_t &nvals);

parent b06e818d
......@@ -1316,8 +1316,8 @@ Importcmsaf(void *process)
int varID, levelID, tsID;
double *array;
double missval;
hid_t file_id; /* HDF5 File ID */
herr_t status; /* Generic return value */
hid_t file_id; // HDF5 File ID
herr_t status; // Generic return value
datasets_t dsets;
int64_t vdate;
int vtime;
......@@ -1333,11 +1333,11 @@ Importcmsaf(void *process)
#ifdef HAVE_LIBHDF5
dsets_init(&dsets);
/* Open an existing file. */
// Open an existing file.
file_id = H5Fopen(cdoGetStreamName(0), H5F_ACC_RDONLY, H5P_DEFAULT);
if (file_id < 0) cdoAbort("H5Fopen failed on %s", cdoGetStreamName(0));
/* cmsaf_type = get_cmsaf_type(file_id); */
// cmsaf_type = get_cmsaf_type(file_id);
H5Giterate(file_id, "/", nullptr, obj_info, (void *) &dsets);
......@@ -1472,9 +1472,8 @@ Importcmsaf(void *process)
if (nz == 1) offset = gridsize * tsID;
array = dsets.obj[ivar].array + offset;
size_t nvals;
const auto mm = varrayMinMaxMV(gridsize, array, missval, nvals);
nmiss = gridsize - nvals;
const auto mm = varrayMinMaxMV(gridsize, array, missval);
nmiss = gridsize - mm.n;
if (Options::cdoVerbose)
cdoPrint(" Write var %d, level %d, nmiss %zu, missval %g, minval %g, maxval %g", varID, levelID, nmiss, missval,
......@@ -1486,7 +1485,7 @@ Importcmsaf(void *process)
}
}
/* Close file */
// Close file
status = H5Fclose(file_id);
(void) (status); // CDO_UNUSED
......
......@@ -46,12 +46,12 @@ fpe_errstr(int fpeRaised)
}
MinMax
varrayMinMaxMV(const size_t len, const double *array, const double missval, size_t &nvals)
varrayMinMaxMV(const size_t len, const double *array, const double missval)
{
double vmin = DBL_MAX;
double vmax = -DBL_MAX;
nvals = 0;
size_t nvals = 0;
for (size_t i = 0; i < len; ++i)
{
if (!DBL_IS_EQUAL(array[i], missval))
......@@ -62,21 +62,13 @@ varrayMinMaxMV(const size_t len, const double *array, const double missval, size
}
}
return MinMax(vmin, vmax);
}
MinMax
varrayMinMaxMV(const size_t len, const double *array, const double missval)
{
size_t nvals;
return varrayMinMaxMV(len, array, missval, nvals);
return MinMax(vmin, vmax, nvals);
}
MinMax
varrayMinMaxMV(const size_t len, const Varray<double> &array, const double missval)
{
size_t nvals;
return varrayMinMaxMV(len, array.data(), missval, nvals);
return varrayMinMaxMV(len, array.data(), missval);
}
template <typename T>
......
......@@ -203,7 +203,6 @@ MinMax varrayMinMax(const Varray<T> &v);
MinMax varrayMinMaxMV(size_t len, const Varray<double> &array, double missval);
MinMax varrayMinMaxMV(size_t len, const double *array, double missval);
MinMax varrayMinMaxMV(size_t len, const double *array, double missval, size_t &nvals);
double varrayMin(size_t len, const Varray<double> &v);
double varrayMax(size_t len, const Varray<double> &v);
......
......@@ -31,12 +31,13 @@ struct Datarange
double addoffset;
double scalefactor;
Datarange() : check_datarange(false), gridsize(0), datatype(0), missval(0), addoffset(0), scalefactor(1) {};
void
checkDatarange(double *array, size_t nmiss)
{
size_t ivals = 0;
auto mm = nmiss ? varrayMinMaxMV(gridsize, array, missval, ivals) : varrayMinMax(gridsize, array);
if (nmiss == 0) ivals = gridsize;
auto mm = nmiss ? varrayMinMaxMV(gridsize, array, missval) : varrayMinMax(gridsize, array);
size_t ivals = (nmiss == 0) ? gridsize : mm.n;
if (ivals > 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