Commit 4997da0e authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Set constant variables to const.

parent e7861e9d
......@@ -45,13 +45,13 @@ Cat(void *process)
cdoInitialize(process);
bool lcopy = UNCHANGED_RECORD;
const bool lcopy = UNCHANGED_RECORD;
int timer_cat = timer_new("cat");
const int timer_cat = timer_new("cat");
if (Options::Timer) timer_start(timer_cat);
int streamCnt = cdoStreamCnt();
int nfiles = streamCnt - 1;
const int streamCnt = cdoStreamCnt();
const int nfiles = streamCnt - 1;
Progress::init();
......@@ -60,15 +60,14 @@ Cat(void *process)
if (Options::cdoVerbose) cdoPrint("Process file: %s", cdoGetStreamName(indf));
if (Options::Timer) tw0 = timer_val(timer_cat);
int streamID1 = cdoStreamOpenRead(cdoStreamName(indf));
int vlistID1 = cdoStreamInqVlist(streamID1);
int taxisID1 = vlistInqTaxis(vlistID1);
const int streamID1 = cdoStreamOpenRead(cdoStreamName(indf));
const int vlistID1 = cdoStreamInqVlist(streamID1);
const int taxisID1 = vlistInqTaxis(vlistID1);
if (indf == 0)
{
int ntsteps = vlistNtsteps(vlistID1);
int nvars = vlistNvars(vlistID1);
const int nvars = vlistNvars(vlistID1);
if (ntsteps == 1)
{
for (varID = 0; varID < nvars; ++varID)
......@@ -77,7 +76,7 @@ Cat(void *process)
if (varID == nvars) ntsteps = 0;
}
bool file_exists = !Options::cdoOverwriteMode ? fileExists(cdoGetStreamName(nfiles)) : false;
const bool file_exists = !Options::cdoOverwriteMode ? fileExists(cdoGetStreamName(nfiles)) : false;
if (file_exists)
{
streamID2 = cdoStreamOpenAppend(cdoStreamName(nfiles));
......@@ -88,7 +87,7 @@ Cat(void *process)
vlistCompare(vlistID1, vlistID2, CMP_ALL);
tsID2 = vlistNtsteps(vlistID2);
if (tsID2 == 0) tsID2 = 1; /* bug fix for time constant data only */
if (tsID2 == 0) tsID2 = 1; // bug fix for time constant data only
if (ntsteps == 0) lconstvars = false;
}
......@@ -123,12 +122,12 @@ Cat(void *process)
vlistCompare(vlistID1, vlistID2, CMP_ALL);
}
int ntsteps = vlistNtsteps(vlistID1);
const int ntsteps = vlistNtsteps(vlistID1);
int tsID1 = 0;
while ((nrecs = cdoStreamInqTimestep(streamID1, tsID1)))
{
double fstatus = (ntsteps > 1) ? indf + (tsID1 + 1.) / ntsteps : indf + 1.;
const double fstatus = (ntsteps > 1) ? indf + (tsID1 + 1.) / ntsteps : indf + 1.;
if (!Options::cdoVerbose) Progress::update(0, 1, fstatus / nfiles);
taxisCopyTimestep(taxisID2, taxisID1);
......
......@@ -47,13 +47,13 @@ Copy(void *process)
cdoInitialize(process);
bool lcopy = UNCHANGED_RECORD;
const bool lcopy = UNCHANGED_RECORD;
// clang-format off
cdoOperatorAdd("copy", 0, 0, nullptr);
int SELALL = cdoOperatorAdd("selall", 0, 0, nullptr);
int SZIP = cdoOperatorAdd("szip", 0, 0, nullptr);
// clang-format on
cdoOperatorAdd("copy", 0, 0, nullptr);
const int SELALL = cdoOperatorAdd("selall", 0, 0, nullptr);
const int SZIP = cdoOperatorAdd("szip", 0, 0, nullptr);
// clang-format on
#ifdef HIRLAM_EXTENSIONS
// KEEP in mind the difference between copy and selall with respect to
......@@ -64,26 +64,24 @@ Copy(void *process)
printf("cdo copy/selall : cdiGribDataScanningMode=%d; lcopy=%d\n", streamGrbInqDataScanningMode(), lcopy);
#endif //#ifdef HIRLAM_EXTENSIONS
int operatorID = cdoOperatorID();
const int operatorID = cdoOperatorID();
if (operatorID == SZIP)
{
Options::cdoCompType = CDI_COMPRESS_SZIP;
Options::cdoCompLevel = 0;
}
int streamCnt = cdoStreamCnt();
int nfiles = streamCnt - 1;
const int streamCnt = cdoStreamCnt();
const int nfiles = streamCnt - 1;
int tsID2 = 0;
for (int indf = 0; indf < nfiles; indf++)
for (int indf = 0; indf < nfiles; ++indf)
{
if (Options::cdoVerbose) cdoPrint("Process file: %s", cdoGetStreamName(indf));
int streamID1 = cdoStreamOpenRead(cdoStreamName(indf));
int vlistID1 = cdoStreamInqVlist(streamID1);
int taxisID1 = vlistInqTaxis(vlistID1);
const int streamID1 = cdoStreamOpenRead(cdoStreamName(indf));
const int vlistID1 = cdoStreamInqVlist(streamID1);
const int taxisID1 = vlistInqTaxis(vlistID1);
if (indf == 0)
{
......@@ -92,7 +90,7 @@ Copy(void *process)
vlistDefTaxis(vlistID2, taxisID2);
int ntsteps = vlistNtsteps(vlistID1);
int nvars = vlistNvars(vlistID1);
const int nvars = vlistNvars(vlistID1);
if (ntsteps == 1)
{
......@@ -108,7 +106,7 @@ Copy(void *process)
for (varID = 0; varID < nvars; ++varID) vlistDefVarTimetype(vlistID2, varID, TIME_VARYING);
}
size_t gridsizemax = vlistGridsizeMax(vlistID1);
const size_t gridsizemax = vlistGridsizeMax(vlistID1);
if (Options::CDO_Memtype == MEMTYPE_FLOAT)
array = Malloc(gridsizemax * sizeof(float));
else
......
......@@ -12,7 +12,7 @@ cdoSetNAN(double missval, size_t gridsize, double *array)
{
if (DBL_IS_NAN(missval))
{
double newmissval = -9e33;
const double newmissval = -9e33;
for (size_t i = 0; i < gridsize; ++i)
if (DBL_IS_EQUAL(array[i], missval)) array[i] = newmissval;
}
......
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