Commit 172d6d96 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Fix cppcheck warnings.

parent 9a3aa1f7
Pipeline #4686 passed with stages
in 16 minutes and 45 seconds
......@@ -50,8 +50,8 @@
#include "cdi_lockedIO.h"
int scan_par_obsolete(char *namelist, const char *name, int def);
void scan_code(char *namelist, struct Variable *vars, int maxCodes, int *numCodes);
int scan_par(int verbose, char *namelist, const char *name, int def);
void scan_code(char *namelist, struct Variable *vars, int maxCodes, int *numCodes);
int scan_time(int verbose, char *namelist, int *hours, int max_hours);
void scan_darray(char *namelist, const char *name, double *values, int maxValues, int *numValues);
......@@ -1142,7 +1142,7 @@ after_checkNamelist(struct Control *globs)
{
if (globs->Mean && globs->Type < 20) afterAbort("Mean is only available for TYPE >= 20!");
if (globs->Extrapolate == false && globs->Type >= 30)
if (globs->extrapolate == false && globs->Type >= 30)
{
if (globs->Type > 30) afterAbort("EXTRAPOLATE = 0 is only available for TYPE = 30!");
if (globs->Mean) afterAbort("EXTRAPOLATE = 0 is only available with MEAN = 0!");
......@@ -1244,8 +1244,8 @@ after_parini(struct Control *globs, struct Variable *vars)
globs->unitsel = scan_par(globs->Verbose, namelist, "unitsel", 0);
globs->DayIn = scan_par(globs->Verbose, namelist, "dayinc", 30);
globs->Extrapolate = scan_par(globs->Verbose, namelist, "extrapolate", 1);
globs->Szip = scan_par(globs->Verbose, namelist, "szip", 0);
globs->extrapolate = (bool) scan_par(globs->Verbose, namelist, "extrapolate", 1);
globs->szip = (bool) scan_par(globs->Verbose, namelist, "szip", 0);
if (globs->Multi) --globs->Multi;
......@@ -1699,8 +1699,8 @@ after_control_init(struct Control *globs)
globs->AnalysisData = 0; // 0 = ECHAM Data, 1 = ECMWF Spectral Analyses
globs->DayIn = 0; // day increment of infiles if Multi = true
globs->Debug = false;
globs->Extrapolate = true;
globs->Szip = false;
globs->extrapolate = true;
globs->szip = false;
globs->istreamID = CDI_UNDEFID;
globs->ostreamID = CDO_STREAM_UNDEF;
......@@ -1742,7 +1742,7 @@ after_processing(struct Control *globs, struct Variable *vars)
{
globs->ostreamID = cdoOpenWrite(ofileidx, ofiletype);
if (globs->Szip) cdoDefCompType(globs->ostreamID, CDI_COMPRESS_SZIP);
if (globs->szip) cdoDefCompType(globs->ostreamID, CDI_COMPRESS_SZIP);
globs->ovlistID = vlistCreate();
}
......
......@@ -548,7 +548,6 @@ void *EcaCwfi(void *process)
request.var1.refdate = 18500101;
}
request.var1.units = CWFI_UNITS;
request.var1.f1 = nullptr;
request.var1.f2 = nullptr;
request.var1.f3 = vfarsellt;
......
......@@ -200,12 +200,12 @@ vert_gen_weights(int expol, int nlev1, const Varray<double> &lev1, int nlev2, co
if (i1 - 1 == 0) // destination levels is not covert by the first two input z levels
{
lev_idx[i2] = BottomLevel;
lev_wgt[i2] = (expol || IS_EQUAL(lev2[i2], val2));
lev_wgt[i2] = static_cast<float>(expol || IS_EQUAL(lev2[i2], val2));
}
else if (i1 == nlev1 - 1) // destination level is beyond the last value of the input z field
{
lev_idx[i2] = TopLevel;
lev_wgt[i2] = (expol || IS_EQUAL(lev2[i2], val2));
lev_wgt[i2] = static_cast<float>(expol || IS_EQUAL(lev2[i2], val2));
}
else // target z values has two bounday values in input z field
{
......
......@@ -46,7 +46,7 @@ bool levelDirDown(const int nlev, const double *const lev);
* 3d version of vert_gen_weights() (src/Intlevel.cc)
*/
static void
vert_gen_weights3d(bool expol, size_t gridsize, int nlev1, Varray<float> &xlev1, int nlev2, Varray<double> &xlev2,
vert_gen_weights3d(bool expol, size_t gridsize, int nlev1, const Varray<float> &xlev1, int nlev2, const Varray<double> &xlev2,
Varray<int> &xlev_idx, Varray<float> &xlev_wgt)
{
const auto nthreads = Threading::ompNumThreads;
......
......@@ -126,8 +126,8 @@ smooth(int gridID, double missval, const Varray<double> &array1, Varray<double>
// Compute weights based on inverse distance if mask is false, eliminate those points
const auto nadds = knnWeights[ompthID].computeWeights(mask, spoint.radius, spoint.weight0, spoint.weightR);
if (nadds < naddsMin) naddsMin = nadds;
if (nadds > naddsMax) naddsMax = nadds;
naddsMin = std::min(naddsMin, nadds);
naddsMax = std::max(naddsMax, nadds);
if (nadds)
{
array2[i] = knnWeights[ompthID].arrayWeightsSum(array1);
......
......@@ -60,11 +60,11 @@ struct Control
int OutputInterval;
int EndOfInterval;
int AnalysisData; /* 0 = ECHAM Data, 1 = ECMWF Spectral Analyses */
int DayIn; /* day increment of infiles if Multi = true */
int AnalysisData; // 0 = ECHAM Data, 1 = ECMWF Spectral Analyses
int DayIn; // day increment of infiles if Multi = true
int Debug;
int Extrapolate;
int Szip;
bool extrapolate;
bool szip;
int istreamID;
CdoStreamID ostreamID;
......
......@@ -1824,7 +1824,7 @@ after_processML(struct Control *globs, struct Variable *vars)
genind(globs->vert_index, pressureLevel, vars[FULL_PRESS].hybrid, globs->DimGP, globs->NumLevelRequest, globs->NumLevel);
nmiss = 0;
if (!globs->Extrapolate)
if (!globs->extrapolate)
{
if (globs->pnmiss == nullptr) globs->pnmiss = (size_t *) Malloc(globs->NumLevelRequest * sizeof(size_t));
genindmiss(globs->vert_index, pressureLevel, globs->DimGP, globs->NumLevelRequest, vars[PS_PROG].hybrid, globs->pnmiss);
......@@ -1873,7 +1873,7 @@ after_processML(struct Control *globs, struct Variable *vars)
globs->NumLevelRequest, globs->DimGP, numlevel, vars[code].missval);
}
if (!globs->Extrapolate) vars[code].nmiss = nmiss;
if (!globs->extrapolate) vars[code].nmiss = nmiss;
if (code != TEMPERATURE) vars[code].hybrid = (double *) FreeMemory(vars[code].hybrid);
}
......
......@@ -37,7 +37,7 @@ CheckVector
T *ptr;
size_t m_count;
CheckVector() : ptr(dummy) { }
CheckVector() : ptr(dummy), m_count(0) { }
CheckVector(size_t count) : ptr(dummy), m_count(count) { }
CheckVector(size_t count, const T& value) : ptr(dummy), m_count(count) { ptr[0] = value; }
......
......@@ -63,7 +63,7 @@ cdo_cmpstrLenRhs(const char *lhs, const char *rhs, size_t &len)
}
static inline bool
cdo_cmpstr(const std::string lhs, const std::string &rhs)
cdo_cmpstr(const std::string &lhs, const std::string &rhs)
{
return (lhs.compare(rhs) == 0);
}
......
......@@ -112,12 +112,12 @@ KVList::append(const char *key, const char *const *values, int nvalues)
this->push_back(kv);
}
/* Remove only one list item */
// Remove only one list item
void
KVList::remove(const std::string &inkey)
{
std::list<KeyValues>::iterator i;
for (i = this->begin(); i != this->end(); i++)
for (i = this->begin(); i != this->end(); ++i)
if (i->key == inkey) break;
if (i->key == inkey)
this->erase(i);
......
......@@ -29,29 +29,29 @@
static void
bicubicSetWeights(double iw, double jw, double (&weights)[4][4])
{
const auto iw1 = iw*iw*(iw-1.);
const auto iw2 = iw*(iw-1.)*(iw-1.);
const auto iw3 = iw*iw*(3.-2.*iw);
const auto jw1 = jw*jw*(jw-1.);
const auto jw2 = jw*(jw-1.)*(jw-1.);
const auto jw3 = jw*jw*(3.-2.*jw);
const auto iw1 = iw*iw*(iw-1.0);
const auto iw2 = iw*(iw-1.0)*(iw-1.0);
const auto iw3 = iw*iw*(3.0-2.0*iw);
const auto jw1 = jw*jw*(jw-1.0);
const auto jw2 = jw*(jw-1.0)*(jw-1.0);
const auto jw3 = jw*jw*(3.0-2.0*jw);
// clang-format off
weights[0][0] = (1.-jw3) * (1.-iw3);
weights[1][0] = (1.-jw3) * iw3;
weights[2][0] = jw3 * iw3;
weights[3][0] = jw3 * (1.-iw3);
weights[0][1] = (1.-jw3) * iw2;
weights[1][1] = (1.-jw3) * iw1;
weights[2][1] = jw3 * iw1;
weights[3][1] = jw3 * iw2;
weights[0][2] = jw2 * (1.-iw3);
weights[1][2] = jw2 * iw3;
weights[2][2] = jw1 * iw3;
weights[3][2] = jw1 * (1.-iw3);
weights[0][3] = jw2 * iw2;
weights[1][3] = jw2 * iw1;
weights[2][3] = jw1 * iw1;
weights[3][3] = jw1 * iw2;
weights[0][0] = (1.0-jw3) * (1.0-iw3);
weights[1][0] = (1.0-jw3) * iw3;
weights[2][0] = jw3 * iw3;
weights[3][0] = jw3 * (1.0-iw3);
weights[0][1] = (1.0-jw3) * iw2;
weights[1][1] = (1.0-jw3) * iw1;
weights[2][1] = jw3 * iw1;
weights[3][1] = jw3 * iw2;
weights[0][2] = jw2 * (1.0-iw3);
weights[1][2] = jw2 * iw3;
weights[2][2] = jw1 * iw3;
weights[3][2] = jw1 * (1.0-iw3);
weights[0][3] = jw2 * iw2;
weights[1][3] = jw2 * iw1;
weights[2][3] = jw1 * iw1;
weights[3][3] = jw1 * iw2;
// clang-format on
}
......@@ -145,10 +145,10 @@ remapBicubicWeights(RemapSearch &rsearch, RemapVars &rv)
const auto llpoint = remapgrid_get_lonlat(tgt_grid, tgt_cell_add);
size_t src_add[4]; // address for the four source points
double src_lats[4]; // latitudes of four bilinear corners
double src_lons[4]; // longitudes of four bilinear corners
double weights[4][4]; // bicubic weights for four corners
size_t src_add[4]; // address for the four source points
// Find nearest square of grid points on source grid
auto search_result = remapSearchSquare(rsearch, llpoint, src_add, src_lats, src_lons);
......@@ -163,7 +163,7 @@ remapBicubicWeights(RemapSearch &rsearch, RemapVars &rv)
// If point found, find local iw,jw coordinates for weights
if (search_result > 0)
{
tgt_grid->cell_frac[tgt_cell_add] = 1.;
tgt_grid->cell_frac[tgt_cell_add] = 1.0;
double iw = 0.0, jw = 0.0; // current guess for bilinear coordinate
if (remapFindWeights(llpoint, src_lons, src_lats, &iw, &jw))
......@@ -185,7 +185,7 @@ remapBicubicWeights(RemapSearch &rsearch, RemapVars &rv)
{
if (num_src_points(src_grid->mask, src_add, src_lats) > 0)
{
tgt_grid->cell_frac[tgt_cell_add] = 1.;
tgt_grid->cell_frac[tgt_cell_add] = 1.0;
renormalizeWeights(src_lats, weights);
store_weightlinks_bicubic(src_add, weights, tgt_cell_add, weightLinks);
}
......@@ -257,10 +257,10 @@ remapBicubic(RemapSearch &rsearch, const double *restrict src_array, double *res
const auto llpoint = remapgrid_get_lonlat(tgt_grid, tgt_cell_add);
size_t src_add[4]; // address for the four source points
double src_lats[4]; // latitudes of four bilinear corners
double src_lons[4]; // longitudes of four bilinear corners
double weights[4][4]; // bicubic weights for four corners
size_t src_add[4]; // address for the four source points
// Find nearest square of grid points on source grid
auto search_result = remapSearchSquare(rsearch, llpoint, src_add, src_lats, src_lons);
......@@ -275,7 +275,7 @@ remapBicubic(RemapSearch &rsearch, const double *restrict src_array, double *res
// If point found, find local iw,jw coordinates for weights
if (search_result > 0)
{
tgt_grid->cell_frac[tgt_cell_add] = 1.;
tgt_grid->cell_frac[tgt_cell_add] = 1.0;
double iw = 0.0, jw = 0.0; // current guess for bilinear coordinate
if (remapFindWeights(llpoint, src_lons, src_lats, &iw, &jw))
......@@ -298,7 +298,7 @@ remapBicubic(RemapSearch &rsearch, const double *restrict src_array, double *res
{
if (num_src_points(src_grid_mask, src_add, src_lats) > 0)
{
tgt_grid->cell_frac[tgt_cell_add] = 1.;
tgt_grid->cell_frac[tgt_cell_add] = 1.0;
renormalizeWeights(src_lats, weights);
sort_weights_bicubic(src_add, weights);
tgt_array[tgt_cell_add] = bicubicRemap(src_array, weights, src_add, gradients);
......
......@@ -96,10 +96,10 @@ static void
bilinearSetWeights(double iw, double jw, double (&weights)[4])
{
// clang-format off
weights[0] = (1.-iw) * (1.-jw);
weights[1] = iw * (1.-jw);
weights[2] = iw * jw;
weights[3] = (1.-iw) * jw;
weights[0] = (1.0-iw) * (1.0-jw);
weights[1] = iw * (1.0-jw);
weights[2] = iw * jw;
weights[3] = (1.0-iw) * jw;
// clang-format on
}
......@@ -196,10 +196,10 @@ remapBilinearWeights(RemapSearch &rsearch, RemapVars &rv)
const auto llpoint = remapgrid_get_lonlat(tgt_grid, tgt_cell_add);
size_t src_add[4]; // address for the four source points
double src_lats[4]; // latitudes of four bilinear corners
double src_lons[4]; // longitudes of four bilinear corners
double weights[4]; // bilinear weights for four corners
size_t src_add[4]; // address for the four source points
// Find nearest square of grid points on source grid
auto search_result = remapSearchSquare(rsearch, llpoint, src_add, src_lats, src_lons);
......@@ -214,7 +214,7 @@ remapBilinearWeights(RemapSearch &rsearch, RemapVars &rv)
// If point found, find local iw,jw coordinates for weights
if (search_result > 0)
{
tgt_grid->cell_frac[tgt_cell_add] = 1.;
tgt_grid->cell_frac[tgt_cell_add] = 1.0;
double iw = 0.0, jw = 0.0; // current guess for bilinear coordinate
if (remapFindWeights(llpoint, src_lons, src_lats, &iw, &jw))
......@@ -238,7 +238,7 @@ remapBilinearWeights(RemapSearch &rsearch, RemapVars &rv)
{
if (num_src_points(src_grid->mask, src_add, src_lats) > 0)
{
tgt_grid->cell_frac[tgt_cell_add] = 1.;
tgt_grid->cell_frac[tgt_cell_add] = 1.0;
renormalizeWeights(src_lats, weights);
store_weightlinks(0, 4, src_add, weights, tgt_cell_add, weightLinks);
}
......@@ -300,10 +300,10 @@ remapBilinear(RemapSearch &rsearch, const double *restrict src_array, double *re
const auto llpoint = remapgrid_get_lonlat(tgt_grid, tgt_cell_add);
size_t src_add[4]; // address for the four source points
double src_lats[4]; // latitudes of four bilinear corners
double src_lons[4]; // longitudes of four bilinear corners
double weights[4]; // bilinear weights for four corners
size_t src_add[4]; // address for the four source points
// Find nearest square of grid points on source grid
auto search_result = remapSearchSquare(rsearch, llpoint, src_add, src_lats, src_lons);
......@@ -318,7 +318,7 @@ remapBilinear(RemapSearch &rsearch, const double *restrict src_array, double *re
// If point found, find local iw,jw coordinates for weights
if (search_result > 0)
{
tgt_grid->cell_frac[tgt_cell_add] = 1.;
tgt_grid->cell_frac[tgt_cell_add] = 1.0;
double iw = 0.0, jw = 0.0; // current guess for bilinear coordinate
if (remapFindWeights(llpoint, src_lons, src_lats, &iw, &jw))
......@@ -343,7 +343,7 @@ remapBilinear(RemapSearch &rsearch, const double *restrict src_array, double *re
{
if (num_src_points(src_grid_mask, src_add, src_lats) > 0)
{
tgt_grid->cell_frac[tgt_cell_add] = 1.;
tgt_grid->cell_frac[tgt_cell_add] = 1.0;
renormalizeWeights(src_lats, weights);
sort_weights_n4(src_add, weights);
tgt_array[tgt_cell_add] = bilinearRemap(src_array, weights, src_add);
......
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