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

Set constant pointer to const.

parent 78fb3551
......@@ -183,7 +183,7 @@ applyCmorList(PMList &pmlist, int nvars, int vlistID2, std::vector<CmorVar> &var
for (const auto &kv : *kvlist)
{
const char *key = kv.key.c_str();
const char *value = (kv.nvalues == 1) ? kv.values[0].c_str() : NULL;
const char *value = (kv.nvalues == 1) ? kv.values[0].c_str() : nullptr;
if (!value || (value && !*value)) continue;
if (cstrIsEqual(key, "missing_value"))
......@@ -225,7 +225,7 @@ applyCmorList(PMList &pmlist, int nvars, int vlistID2, std::vector<CmorVar> &var
for (const auto &kv : *kvlist)
{
const char *key = kv.key.c_str();
const char *value = (kv.nvalues == 1) ? kv.values[0].c_str() : NULL;
const char *value = (kv.nvalues == 1) ? kv.values[0].c_str() : nullptr;
if (!value || (value && !*value)) continue;
// printf("key=%s value=>%s<\n", key, value);
......@@ -367,7 +367,7 @@ CMOR_lite(void *process)
const char *filename = operatorArgv()[0];
FILE *fp = fopen(filename, "r");
if (fp == NULL) cdoAbort("Open failed on: %s\n", filename);
if (fp == nullptr) cdoAbort("Open failed on: %s\n", filename);
PMList pmlist;
pmlist.readCmortable(fp, filename);
......
......@@ -70,7 +70,7 @@ Regres(void *process)
field2.ptr = (double *) Malloc(gridsize * sizeof(double));
FieldVector2D work[nwork];
for (int w = 0; w < nwork; ++w) fieldsFromVlist(vlistID1, work[w], FIELD_PTR, 0);
for (auto &w : work) fieldsFromVlist(vlistID1, w, FIELD_PTR, 0);
int64_t vdate = 0;
int vtime = 0;
......@@ -150,7 +150,7 @@ Regres(void *process)
pstreamWriteRecord(streamID3, field2.ptr, nmiss);
}
for (int w = 0; w < nwork; ++w) fieldsFree(vlistID1, work[w]);
for (auto &w : work) fieldsFree(vlistID1, w);
if (field1.ptr) Free(field1.ptr);
if (field2.ptr) Free(field2.ptr);
......
......@@ -56,7 +56,7 @@ dv2ps(const double *restrict div, double *restrict pot, long nlev, long ntr)
}
void
dv2uv(double *d, double *o, double *u, double *v, double *f, double *g, long nt, long nsp, long nlev)
dv2uv(const double *d, const double *o, double *u, double *v, double *f, double *g, long nt, long nsp, long nlev)
{
/* d(nsp,nlev), o(nsp,nlev) ! divergence, vorticity */
/* u(nsp,nlev), v(nsp,nlev) ! zonal wind, meridional wind */
......
......@@ -47,7 +47,7 @@
#define D60 (S60 + S60)
long
get_nfft(void)
get_nfft()
{
return (long) NFFT;
}
......@@ -106,7 +106,7 @@ fft_set(double *trigs, long *ifax, long n)
}
static int
rpassc(double *a, double *b, double *c, double *d, double *trigs, long inc1, long inc2, long inc3, long inc4, long lot, long n,
rpassc(const double *a, const double *b, double *c, double *d, const double *trigs, long inc1, long inc2, long inc3, long inc4, long lot, long n,
long ifac, long la)
{
/*
......@@ -988,7 +988,7 @@ rpassc(double *a, double *b, double *c, double *d, double *trigs, long inc1, lon
}
static int
qpassc(double *a, double *b, double *c, double *d, double *trigs, long inc1, long inc2, long inc3, long inc4, long lot, long n,
qpassc(const double *a, const double *b, double *c, double *d, const double *trigs, long inc1, long inc2, long inc3, long inc4, long lot, long n,
long ifac, long la)
{
/*
......@@ -1912,7 +1912,7 @@ qpassc(double *a, double *b, double *c, double *d, double *trigs, long inc1, lon
/* Fast Fourier Transform */
/* ====================== */
void
fc2gp(double *restrict trig, long *restrict ifax, double *restrict fc, double *restrict gp, long nlat, long nlon, long nlev,
fc2gp(double *restrict trig, const long *restrict ifax, double *restrict fc, double *restrict gp, long nlat, long nlon, long nlev,
long nfc)
{
/* fc2gp performs fourier to gridpoint transforms using */
......@@ -2059,7 +2059,7 @@ fc2gp(double *restrict trig, long *restrict ifax, double *restrict fc, double *r
}
void
gp2fc(double *trig, long *ifax, const double *restrict gp, double *restrict fc, long nlat, long nlon, long nlev, long nfc)
gp2fc(double *trig, const long *ifax, const double *restrict gp, double *restrict fc, long nlat, long nlon, long nlev, long nfc)
{
long lot, fou, ia, ifac, jump, k, la;
long lat, lev, lon, nfax, rix, wix;
......
......@@ -502,7 +502,7 @@ sp2fc(const double *sa, double *fa, const double *poli, long nlev, long nlat, lo
}
void
fc2sp(double *fa, double *sa, double *poli, long nlev, long nlat, long nfc, long nt)
fc2sp(double *fa, double *sa, const double *poli, long nlev, long nlat, long nfc, long nt)
{
long nsp2 = (nt + 1) * (nt + 2);
......@@ -595,7 +595,7 @@ sp2sp(double *arrayIn, long truncIn, double *arrayOut, long truncOut)
/* ======================================== */
void
spcut(double *arrayIn, double *arrayOut, long trunc, int *waves)
spcut(double *arrayIn, double *arrayOut, long trunc, const int *waves)
{
long n, m;
......
......@@ -632,7 +632,7 @@ getMemAlignment()
for (int k = 0; k < 4; ++k)
if (iptr % ma_check[k]) ma_result[k] = 0;
}
for (int i = 0; i < NTESTS; ++i) free(ptr[i]);
for (auto &i : ptr) free(i);
for (int i = NTESTS - 1; i >= 0; i--)
{
......@@ -641,7 +641,7 @@ getMemAlignment()
for (int k = 0; k < 4; ++k)
if (iptr % ma_check[k]) ma_result[k] = 0;
}
for (int i = 0; i < NTESTS; ++i) free(ptr[i]);
for (auto &i : ptr) free(i);
for (int k = 0; k < 4; ++k)
if (ma_result[k]) ma = ma_check[k];
......
......@@ -4,7 +4,7 @@
#include <omp.h>
#endif
int
cdo_omp_get_thread_num(void)
cdo_omp_get_thread_num()
{
#ifdef _OPENMP
return omp_get_thread_num();
......
......@@ -62,7 +62,7 @@ renormalizeWeights(const double src_lats[4], double wgts[4][4])
}
static void
bicubicWarning(void)
bicubicWarning()
{
static bool lwarn = true;
......
......@@ -128,7 +128,7 @@ renormalizeWeights(const double src_lats[4], double wgts[4])
}
static void
bilinearWarning(void)
bilinearWarning()
{
static bool lwarn = true;
......
......@@ -188,8 +188,8 @@ gridSearchPoint(GridPointSearch *gps, double plon, double plat, knnWeightsType &
ndist *= 2;
if (ndist > gps->n) ndist = gps->n;
if (knnWeights.m_tmpaddr.size() == 0) knnWeights.m_tmpaddr.resize(ndist);
if (knnWeights.m_tmpdist.size() == 0) knnWeights.m_tmpdist.resize(ndist);
if (knnWeights.m_tmpaddr.empty()) knnWeights.m_tmpaddr.resize(ndist);
if (knnWeights.m_tmpdist.empty()) knnWeights.m_tmpdist.resize(ndist);
size_t *adds = knnWeights.m_tmpaddr.data();
double *dist = knnWeights.m_tmpdist.data();
......
Supports Markdown
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