Commit 14f3ef20 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Set constant variables to const.

parent 8fe91dae
......@@ -46,35 +46,35 @@ Ydayarith(void *process)
cdoOperatorAdd("ydaymul", func_mul, 0, nullptr);
cdoOperatorAdd("ydaydiv", func_div, 0, nullptr);
int operatorID = cdoOperatorID();
int operfunc = cdoOperatorF1(operatorID);
const int operatorID = cdoOperatorID();
const int operfunc = cdoOperatorF1(operatorID);
int streamID1 = cdoStreamOpenRead(cdoStreamName(0));
int streamID2 = cdoStreamOpenRead(cdoStreamName(1));
const int streamID1 = cdoStreamOpenRead(cdoStreamName(0));
const int streamID2 = cdoStreamOpenRead(cdoStreamName(1));
int vlistID1 = cdoStreamInqVlist(streamID1);
int vlistID2 = cdoStreamInqVlist(streamID2);
int vlistID3 = vlistDuplicate(vlistID1);
const int vlistID1 = cdoStreamInqVlist(streamID1);
const int vlistID2 = cdoStreamInqVlist(streamID2);
const int vlistID3 = vlistDuplicate(vlistID1);
vlistCompare(vlistID1, vlistID2, CMP_ALL);
size_t gridsize = vlistGridsizeMax(vlistID1);
const size_t gridsizemax = vlistGridsizeMax(vlistID1);
Field field1, field2;
fieldInit(field1);
fieldInit(field2);
field1.ptr = (double *) Malloc(gridsize * sizeof(double));
field2.ptr = (double *) Malloc(gridsize * sizeof(double));
field1.ptr = (double *) Malloc(gridsizemax * sizeof(double));
field2.ptr = (double *) Malloc(gridsizemax * sizeof(double));
int taxisID1 = vlistInqTaxis(vlistID1);
int taxisID2 = vlistInqTaxis(vlistID2);
int taxisID3 = taxisDuplicate(taxisID1);
const int taxisID1 = vlistInqTaxis(vlistID1);
const int taxisID2 = vlistInqTaxis(vlistID2);
const int taxisID3 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID3, taxisID3);
int streamID3 = cdoStreamOpenWrite(cdoStreamName(2));
const int streamID3 = cdoStreamOpenWrite(cdoStreamName(2));
pstreamDefVlist(streamID3, vlistID3);
int nvars = vlistNvars(vlistID2);
const int nvars = vlistNvars(vlistID2);
std::vector<std::vector<std::vector<double>>> vardata2(MAX_DOY);
std::vector<std::vector<std::vector<size_t>>> varnmiss2(MAX_DOY);
......@@ -82,13 +82,11 @@ Ydayarith(void *process)
int tsID = 0;
while ((nrecs = cdoStreamInqTimestep(streamID2, tsID)))
{
int64_t vdate = taxisInqVdate(taxisID2);
const int64_t vdate = taxisInqVdate(taxisID2);
cdiDecodeDate(vdate, &year, &month, &day);
int dayoy = 0;
if (month >= 1 && month <= 12) dayoy = (month - 1) * 31 + day;
const int dayoy = (month >= 1 && month <= 12) ? (month - 1) * 31 + day : 0;
if (dayoy < 0 || dayoy >= MAX_DOY) cdoAbort("Day of year %d out of range (date=%d)!", dayoy, vdate);
if (vardata2[dayoy].size() > 0) cdoAbort("Day of year %d already allocatd (date=%d)!", dayoy, vdate);
......@@ -98,8 +96,8 @@ Ydayarith(void *process)
for (varID = 0; varID < nvars; varID++)
{
size_t gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID));
size_t nlev = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
const size_t gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID));
const size_t nlev = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
vardata2[dayoy][varID].resize(nlev * gridsize);
varnmiss2[dayoy][varID].resize(nlev);
}
......@@ -107,8 +105,8 @@ Ydayarith(void *process)
for (int recID = 0; recID < nrecs; recID++)
{
pstreamInqRecord(streamID2, &varID, &levelID);
size_t gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID));
size_t offset = gridsize * levelID;
const size_t gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID));
const size_t offset = gridsize * levelID;
pstreamReadRecord(streamID2, &vardata2[dayoy][varID][offset], &nmiss);
varnmiss2[dayoy][varID][levelID] = nmiss;
}
......@@ -119,13 +117,11 @@ Ydayarith(void *process)
tsID = 0;
while ((nrecs = cdoStreamInqTimestep(streamID1, tsID)))
{
int64_t vdate = taxisInqVdate(taxisID1);
const int64_t vdate = taxisInqVdate(taxisID1);
cdiDecodeDate(vdate, &year, &month, &day);
int dayoy = 0;
if (month >= 1 && month <= 12) dayoy = (month - 1) * 31 + day;
const int dayoy = (month >= 1 && month <= 12) ? (month - 1) * 31 + day : 0;
if (dayoy < 0 || dayoy >= MAX_DOY) cdoAbort("Day of year %d out of range (date=%d)!", dayoy, vdate);
taxisCopyTimestep(taxisID3, taxisID1);
......@@ -137,8 +133,8 @@ Ydayarith(void *process)
pstreamReadRecord(streamID1, field1.ptr, &nmiss);
field1.nmiss = nmiss;
size_t gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID));
size_t offset = gridsize * levelID;
const size_t gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID));
const size_t offset = gridsize * levelID;
if (vardata2[dayoy].size() == 0) cdoAbort("Day of year %d not found (date=%d)!", dayoy, vdate);
arrayCopy(gridsize, &vardata2[dayoy][varID][offset], field2.ptr);
field2.nmiss = varnmiss2[dayoy][varID][levelID];
......
......@@ -38,9 +38,7 @@ Ydaypctl(void *process)
{
int varID;
int gridID;
int64_t vdate;
int vtime;
int year, month, day, dayoy;
int year, month, day;
int nrecs;
int levelID;
size_t nmiss;
......@@ -55,49 +53,49 @@ Ydaypctl(void *process)
cdoOperatorAdd("ydaypctl", func_pctl, 0, nullptr);
operatorInputArg("percentile number");
double pn = parameter2double(operatorArgv()[0]);
const double pn = parameter2double(operatorArgv()[0]);
percentile_check_number(pn);
for (dayoy = 0; dayoy < NDAY; dayoy++)
for (int dayoy = 0; dayoy < NDAY; dayoy++)
{
hsets[dayoy] = nullptr;
nsets[dayoy] = 0;
}
int streamID1 = cdoStreamOpenRead(cdoStreamName(0));
int streamID2 = cdoStreamOpenRead(cdoStreamName(1));
int streamID3 = cdoStreamOpenRead(cdoStreamName(2));
const int streamID1 = cdoStreamOpenRead(cdoStreamName(0));
const int streamID2 = cdoStreamOpenRead(cdoStreamName(1));
const int streamID3 = cdoStreamOpenRead(cdoStreamName(2));
int vlistID1 = cdoStreamInqVlist(streamID1);
int vlistID2 = cdoStreamInqVlist(streamID2);
int vlistID3 = cdoStreamInqVlist(streamID3);
int vlistID4 = vlistDuplicate(vlistID1);
const int vlistID1 = cdoStreamInqVlist(streamID1);
const int vlistID2 = cdoStreamInqVlist(streamID2);
const int vlistID3 = cdoStreamInqVlist(streamID3);
const int vlistID4 = vlistDuplicate(vlistID1);
vlistCompare(vlistID1, vlistID2, CMP_ALL);
vlistCompare(vlistID1, vlistID3, CMP_ALL);
int taxisID1 = vlistInqTaxis(vlistID1);
int taxisID2 = vlistInqTaxis(vlistID2);
int taxisID3 = vlistInqTaxis(vlistID3);
const int taxisID1 = vlistInqTaxis(vlistID1);
const int taxisID2 = vlistInqTaxis(vlistID2);
const int taxisID3 = vlistInqTaxis(vlistID3);
/* TODO - check that time axes 2 and 3 are equal */
int taxisID4 = taxisDuplicate(taxisID1);
const int taxisID4 = taxisDuplicate(taxisID1);
if (taxisHasBounds(taxisID4)) taxisDeleteBounds(taxisID4);
vlistDefTaxis(vlistID4, taxisID4);
int streamID4 = cdoStreamOpenWrite(cdoStreamName(3));
const int streamID4 = cdoStreamOpenWrite(cdoStreamName(3));
pstreamDefVlist(streamID4, vlistID4);
int nvars = vlistNvars(vlistID1);
const int nvars = vlistNvars(vlistID1);
int maxrecs = vlistNrecs(vlistID1);
const int maxrecs = vlistNrecs(vlistID1);
std::vector<RecordInfo> recinfo(maxrecs);
size_t gridsize = vlistGridsizeMax(vlistID1);
const size_t gridsizemax = vlistGridsizeMax(vlistID1);
Field field;
fieldInit(field);
field.ptr = (double *) Malloc(gridsize * sizeof(double));
field.ptr = (double *) Malloc(gridsizemax * sizeof(double));
int tsID = 0;
while ((nrecs = cdoStreamInqTimestep(streamID2, tsID)))
......@@ -106,8 +104,8 @@ Ydaypctl(void *process)
cdoAbort("Number of records at time step %d of %s and %s differ!", tsID + 1, cdoGetStreamName(1),
cdoGetStreamName(2));
vdate = taxisInqVdate(taxisID2);
vtime = taxisInqVtime(taxisID2);
const int64_t vdate = taxisInqVdate(taxisID2);
const int vtime = taxisInqVtime(taxisID2);
if (vdate != taxisInqVdate(taxisID3))
cdoAbort("Verification dates at time step %d of %s and %s differ!", tsID + 1, cdoGetStreamName(1),
......@@ -117,11 +115,7 @@ Ydaypctl(void *process)
cdiDecodeDate(vdate, &year, &month, &day);
if (month >= 1 && month <= 12)
dayoy = (month - 1) * 31 + day;
else
dayoy = 0;
const int dayoy = (month >= 1 && month <= 12) ? (month - 1) * 31 + day : 0;
if (dayoy < 0 || dayoy >= NDAY) cdoAbort("Day %d out of range!", dayoy);
vdates2[dayoy] = vdate;
......@@ -146,6 +140,7 @@ Ydaypctl(void *process)
pstreamReadRecord(streamID2, vars1[dayoy][varID][levelID].ptr, &nmiss);
vars1[dayoy][varID][levelID].nmiss = nmiss;
}
for (int recID = 0; recID < nrecs; recID++)
{
pstreamInqRecord(streamID3, &varID, &levelID);
......@@ -163,18 +158,14 @@ Ydaypctl(void *process)
tsID = 0;
while ((nrecs = cdoStreamInqTimestep(streamID1, tsID)))
{
vdate = taxisInqVdate(taxisID1);
vtime = taxisInqVtime(taxisID1);
const int64_t vdate = taxisInqVdate(taxisID1);
const int vtime = taxisInqVtime(taxisID1);
if (Options::cdoVerbose) cdoPrint("process timestep: %d %d %d", tsID + 1, vdate, vtime);
cdiDecodeDate(vdate, &year, &month, &day);
if (month >= 1 && month <= 12)
dayoy = (month - 1) * 31 + day;
else
dayoy = 0;
const int dayoy = (month >= 1 && month <= 12) ? (month - 1) * 31 + day : 0;
if (dayoy < 0 || dayoy >= NDAY) cdoAbort("Day %d out of range!", dayoy);
vdates1[dayoy] = vdate;
......@@ -205,7 +196,7 @@ Ydaypctl(void *process)
}
int otsID = 0;
for (dayoy = 0; dayoy < NDAY; dayoy++)
for (int dayoy = 0; dayoy < NDAY; dayoy++)
if (nsets[dayoy])
{
if (getmonthday(vdates1[dayoy]) != getmonthday(vdates2[dayoy]))
......@@ -229,8 +220,8 @@ Ydaypctl(void *process)
{
if (otsID && recinfo[recID].lconst) continue;
int varID = recinfo[recID].varID;
int levelID = recinfo[recID].levelID;
const int varID = recinfo[recID].varID;
const int levelID = recinfo[recID].levelID;
pstreamDefRecord(streamID4, varID, levelID);
pstreamWriteRecord(streamID4, vars1[dayoy][varID][levelID].ptr, vars1[dayoy][varID][levelID].nmiss);
}
......@@ -238,7 +229,7 @@ Ydaypctl(void *process)
otsID++;
}
for (dayoy = 0; dayoy < NDAY; dayoy++)
for (int dayoy = 0; dayoy < NDAY; dayoy++)
{
if (vars1[dayoy].size())
{
......
......@@ -97,36 +97,36 @@ Ydaystat(void *process)
cdoOperatorAdd("ydaystd", func_std, 0, nullptr);
cdoOperatorAdd("ydaystd1", func_std1, 0, nullptr);
int operatorID = cdoOperatorID();
int operfunc = cdoOperatorF1(operatorID);
bool lrange = operfunc == func_range;
bool lmean = operfunc == func_mean || operfunc == func_avg;
bool lstd = operfunc == func_std || operfunc == func_std1;
bool lvarstd = operfunc == func_std || operfunc == func_var || operfunc == func_std1 || operfunc == func_var1;
int divisor = operfunc == func_std1 || operfunc == func_var1;
const int operatorID = cdoOperatorID();
const int operfunc = cdoOperatorF1(operatorID);
const bool lrange = operfunc == func_range;
const bool lmean = operfunc == func_mean || operfunc == func_avg;
const bool lstd = operfunc == func_std || operfunc == func_std1;
const bool lvarstd = operfunc == func_std || operfunc == func_var || operfunc == func_std1 || operfunc == func_var1;
const int divisor = operfunc == func_std1 || operfunc == func_var1;
// clang-format on
bool lvars2 = lvarstd || lrange;
const bool lvars2 = lvarstd || lrange;
for (int dayoy = 0; dayoy < MAX_DOY; ++dayoy) dayoy_nsets[dayoy] = 0;
int streamID1 = cdoStreamOpenRead(cdoStreamName(0));
const int streamID1 = cdoStreamOpenRead(cdoStreamName(0));
int vlistID1 = cdoStreamInqVlist(streamID1);
int vlistID2 = vlistDuplicate(vlistID1);
const int vlistID1 = cdoStreamInqVlist(streamID1);
const int vlistID2 = vlistDuplicate(vlistID1);
int taxisID1 = vlistInqTaxis(vlistID1);
int taxisID2 = taxisDuplicate(taxisID1);
const int taxisID1 = vlistInqTaxis(vlistID1);
const int taxisID2 = taxisDuplicate(taxisID1);
if (taxisHasBounds(taxisID2)) taxisDeleteBounds(taxisID2);
vlistDefTaxis(vlistID2, taxisID2);
int streamID2 = cdoStreamOpenWrite(cdoStreamName(1));
const int streamID2 = cdoStreamOpenWrite(cdoStreamName(1));
pstreamDefVlist(streamID2, vlistID2);
int maxrecs = vlistNrecs(vlistID1);
const int maxrecs = vlistNrecs(vlistID1);
std::vector<RecordInfo> recinfo(maxrecs);
size_t gridsizemax = vlistGridsizeMax(vlistID1);
const size_t gridsizemax = vlistGridsizeMax(vlistID1);
Field field;
fieldInit(field);
......@@ -136,16 +136,14 @@ Ydaystat(void *process)
int otsID = 0;
while ((nrecs = cdoStreamInqTimestep(streamID1, tsID)))
{
int64_t vdate = taxisInqVdate(taxisID1);
int vtime = taxisInqVtime(taxisID1);
const int64_t vdate = taxisInqVdate(taxisID1);
const int vtime = taxisInqVtime(taxisID1);
if (Options::cdoVerbose) cdoPrint("process timestep: %d %d %d", tsID + 1, vdate, vtime);
cdiDecodeDate(vdate, &year, &month, &day);
int dayoy = 0;
if (month >= 1 && month <= 12) dayoy = (month - 1) * 31 + day;
const int dayoy = (month >= 1 && month <= 12) ? (month - 1) * 31 + day : 0;
if (dayoy < 0 || dayoy >= MAX_DOY) cdoAbort("Day of year %d out of range (date=%d)!", dayoy, vdate);
vdates[dayoy] = vdate;
......@@ -171,9 +169,9 @@ Ydaystat(void *process)
Field &rsamp1 = samp1[dayoy][varID][levelID];
Field &rvars1 = vars1[dayoy][varID][levelID];
int nsets = dayoy_nsets[dayoy];
const int nsets = dayoy_nsets[dayoy];
size_t gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
const size_t gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
if (nsets == 0)
{
......@@ -233,9 +231,8 @@ Ydaystat(void *process)
{
if (recinfo[recID].lconst) continue;
int varID = recinfo[recID].varID;
int levelID = recinfo[recID].levelID;
const int varID = recinfo[recID].varID;
const int levelID = recinfo[recID].levelID;
farmoq(vars2[dayoy][varID][levelID], vars1[dayoy][varID][levelID]);
}
......@@ -266,13 +263,13 @@ Ydaystat(void *process)
for (int dayoy = 0; dayoy < MAX_DOY; dayoy++)
if (dayoy_nsets[dayoy])
{
int nsets = dayoy_nsets[dayoy];
const int nsets = dayoy_nsets[dayoy];
for (int recID = 0; recID < maxrecs; recID++)
{
if (recinfo[recID].lconst) continue;
int varID = recinfo[recID].varID;
int levelID = recinfo[recID].levelID;
const int varID = recinfo[recID].varID;
const int levelID = recinfo[recID].levelID;
Field &rsamp1 = samp1[dayoy][varID][levelID];
Field &rvars1 = vars1[dayoy][varID][levelID];
......@@ -316,8 +313,8 @@ Ydaystat(void *process)
{
if (otsID && recinfo[recID].lconst) continue;
int varID = recinfo[recID].varID;
int levelID = recinfo[recID].levelID;
const int varID = recinfo[recID].varID;
const int levelID = recinfo[recID].levelID;
Field &rvars1 = vars1[dayoy][varID][levelID];
pstreamDefRecord(streamID2, varID, levelID);
......
......@@ -51,9 +51,7 @@ Ydrunpctl(void *process)
int inp, its;
size_t nmiss;
int nlevels;
int year, month, day, dayoy;
int64_t vdate;
int vtime;
int year, month, day;
int64_t vdates1[NDAY], vdates2[NDAY];
int vtimes1[NDAY] /*, vtimes2[NDAY]*/;
int nsets[NDAY];
......@@ -65,52 +63,49 @@ Ydrunpctl(void *process)
operatorInputArg("percentile number, number of timesteps");
operatorCheckArgc(2);
double pn = parameter2double(operatorArgv()[0]);
const double pn = parameter2double(operatorArgv()[0]);
percentile_check_number(pn);
int ndates = parameter2int(operatorArgv()[1]);
const int ndates = parameter2int(operatorArgv()[1]);
for (dayoy = 0; dayoy < NDAY; dayoy++)
{
nsets[dayoy] = 0;
}
for (int dayoy = 0; dayoy < NDAY; dayoy++) nsets[dayoy] = 0;
int streamID1 = cdoStreamOpenRead(cdoStreamName(0));
int streamID2 = cdoStreamOpenRead(cdoStreamName(1));
int streamID3 = cdoStreamOpenRead(cdoStreamName(2));
const int streamID1 = cdoStreamOpenRead(cdoStreamName(0));
const int streamID2 = cdoStreamOpenRead(cdoStreamName(1));
const int streamID3 = cdoStreamOpenRead(cdoStreamName(2));
int vlistID1 = cdoStreamInqVlist(streamID1);
int vlistID2 = cdoStreamInqVlist(streamID2);
int vlistID3 = cdoStreamInqVlist(streamID3);
int vlistID4 = vlistDuplicate(vlistID1);
const int vlistID1 = cdoStreamInqVlist(streamID1);
const int vlistID2 = cdoStreamInqVlist(streamID2);
const int vlistID3 = cdoStreamInqVlist(streamID3);
const int vlistID4 = vlistDuplicate(vlistID1);
vlistCompare(vlistID1, vlistID2, CMP_ALL);
vlistCompare(vlistID1, vlistID3, CMP_ALL);
int taxisID1 = vlistInqTaxis(vlistID1);
int taxisID2 = vlistInqTaxis(vlistID2);
int taxisID3 = vlistInqTaxis(vlistID3);
const int taxisID1 = vlistInqTaxis(vlistID1);
const int taxisID2 = vlistInqTaxis(vlistID2);
const int taxisID3 = vlistInqTaxis(vlistID3);
/* TODO - check that time axes 2 and 3 are equal */
int taxisID4 = taxisDuplicate(taxisID1);
const int taxisID4 = taxisDuplicate(taxisID1);
if (taxisHasBounds(taxisID4)) taxisDeleteBounds(taxisID4);
vlistDefTaxis(vlistID4, taxisID4);
int calendar = taxisInqCalendar(taxisID1);
int dpy = calendar_dpy(calendar);
const int calendar = taxisInqCalendar(taxisID1);
const int dpy = calendar_dpy(calendar);
int streamID4 = cdoStreamOpenWrite(cdoStreamName(3));
const int streamID4 = cdoStreamOpenWrite(cdoStreamName(3));
pstreamDefVlist(streamID4, vlistID4);
int nvars = vlistNvars(vlistID1);
const int nvars = vlistNvars(vlistID1);
int maxrecs = vlistNrecs(vlistID1);
const int maxrecs = vlistNrecs(vlistID1);
std::vector<RecordInfo> recinfo(maxrecs);
size_t gridsize = vlistGridsizeMax(vlistID1);
const size_t gridsizemax = vlistGridsizeMax(vlistID1);
Field field;
fieldInit(field);
field.ptr = (double *) Malloc(gridsize * sizeof(double));
field.ptr = (double *) Malloc(gridsizemax * sizeof(double));
std::vector<CdoDateTime> datetime(ndates + 1);
......@@ -121,25 +116,19 @@ Ydrunpctl(void *process)
while ((nrecs = cdoStreamInqTimestep(streamID2, tsID)))
{
if (nrecs != cdoStreamInqTimestep(streamID3, tsID))
cdoAbort("Number of records at time step %d of %s and %s differ!", tsID + 1, cdoGetStreamName(1),
cdoGetStreamName(2));
cdoAbort("Number of records at time step %d of %s and %s differ!", tsID + 1, cdoGetStreamName(1), cdoGetStreamName(2));
vdate = taxisInqVdate(taxisID2);
vtime = taxisInqVtime(taxisID2);
const int64_t vdate = taxisInqVdate(taxisID2);
const int vtime = taxisInqVtime(taxisID2);
if (vdate != taxisInqVdate(taxisID3))
cdoAbort("Verification dates at time step %d of %s and %s differ!", tsID + 1, cdoGetStreamName(1),
cdoGetStreamName(2));
cdoAbort("Verification dates at time step %d of %s and %s differ!", tsID + 1, cdoGetStreamName(1), cdoGetStreamName(2));
if (Options::cdoVerbose) cdoPrint("process timestep: %d %d %d", tsID + 1, vdate, vtime);
cdiDecodeDate(vdate, &year, &month, &day);
if (month >= 1 && month <= 12)
dayoy = (month - 1) * 31 + day;
else
dayoy = 0;
const int dayoy = (month >= 1 && month <= 12) ? (month - 1) * 31 + day : 0;
if (dayoy < 0 || dayoy >= NDAY) cdoAbort("Day %d out of range!", dayoy);
vdates2[dayoy] = vdate;
......@@ -165,6 +154,7 @@ Ydrunpctl(void *process)
pstreamReadRecord(streamID2, vars2[dayoy][varID][levelID].ptr, &nmiss);
vars2[dayoy][varID][levelID].nmiss = nmiss;
}
for (int recID = 0; recID < nrecs; recID++)
{
pstreamInqRecord(streamID3, &varID, &levelID);
......@@ -207,12 +197,12 @@ Ydrunpctl(void *process)
{
datetime_avg(dpy, ndates, datetime.data());
vdate = datetime[ndates].date;
vtime = datetime[ndates].time;
const int64_t vdate = datetime[ndates].date;
const int vtime = datetime[ndates].time;
cdiDecodeDate(vdate, &year, &month, &day);
dayoy = (month >= 1 && month <= 12) ? (month - 1) * 31 + day : 0;
const int dayoy = (month >= 1 && month <= 12) ? (month - 1) * 31 + day : 0;
if (dayoy < 0 || dayoy >= NDAY) cdoAbort("Day %d out of range!", dayoy);
vdates1[dayoy] = vdate;
......@@ -275,7 +265,7 @@ Ydrunpctl(void *process)
}
*/
int otsID = 0;
for (dayoy = 0; dayoy < NDAY; dayoy++)
for (int dayoy = 0; dayoy < NDAY; dayoy++)
if (nsets[dayoy])
{
if (getmonthday(vdates1[dayoy]) != getmonthday(vdates2[dayoy]))
......@@ -299,8 +289,8 @@ Ydrunpctl(void *process)
{
if (otsID && recinfo[recID].lconst) continue;
int varID = recinfo[recID].varID;
int levelID = recinfo[recID].levelID;
const int varID = recinfo[recID].varID;
const int levelID = recinfo[recID].levelID;
pstreamDefRecord(streamID4, varID, levelID);
pstreamWriteRecord(streamID4, vars2[dayoy][varID][levelID].ptr, vars2[dayoy][varID][levelID].nmiss);
}
......@@ -312,12 +302,12 @@ Ydrunpctl(void *process)
{
for (varID = 0; varID < nvars; varID++)
{
nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
const int nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
for (levelID = 0; levelID < nlevels; levelID++) Free(vars1[its][varID][levelID].ptr);
}
}
for (dayoy = 0; dayoy < NDAY; dayoy++)
for (int dayoy = 0; dayoy < NDAY; dayoy++)
{
if (vars2[dayoy].size())
{
......
......@@ -109,7 +109,7 @@ ydstatUpdate(YDAY_STATS *stats, int64_t vdate, int vtime, const FieldVector2D &v
int year, month, day;
cdiDecodeDate(vdate, &year, &month, &day);
int dayoy = (month >= 1 && month <= 12) ? (month - 1) * 31 + day : 0;
const int dayoy = (month >= 1 && month <= 12) ? (month - 1) * 31 + day : 0;
if (dayoy < 0 || dayoy >= NDAY) cdoAbort("day %d out of range!", dayoy);
stats->vdate[dayoy] = vdate;
......@@ -125,8 +125,8 @@ ydstatUpdate(YDAY_STATS *stats, int64_t vdate, int vtime, const FieldVector2D &v
{
if (vlistInqVarTimetype(stats->vlist, varID) == TIME_CONSTANT) continue;
size_t gridsize = gridInqSize(vlistInqVarGrid(stats->vlist, varID));
int nlevels = zaxisInqSize(vlistInqVarZaxis(stats->vlist, varID));
const size_t gridsize = gridInqSize(vlistInqVarGrid(stats->vlist, varID));
const int nlevels = zaxisInqSize(vlistInqVarZaxis(stats->vlist, varID));
for (int levelID = 0; levelID < nlevels; levelID++)
{
......@@ -163,9 +163,9 @@ static void
ydstatFinalize(YDAY_STATS *stats, int operfunc)
{
int varID, levelID, nlevels;
int divisor = operfunc == func_std1 || operfunc == func_var1;
const int divisor = operfunc == func_std1 || operfunc == func_var1;
int nvars = vlistNvars(stats->vlist);
const int nvars = vlistNvars(stats->vlist);
for (int dayoy = 0; dayoy < NDAY; dayoy++)
if (stats->nsets[dayoy])
......@@ -232,31 +232,31 @@ Ydrunstat(void *process)
cdoOperatorAdd("ydrunstd1", func_std1, 0, nullptr);
// clang-format on
int operatorID = cdoOperatorID();