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

Set type of initialized variables to auto.

parent 28554979
......@@ -17,7 +17,6 @@
#include <cdi.h>
#include "process_int.h"
#include "cdi_lockedIO.h"
#include <mpim_grid.h>
......
......@@ -23,11 +23,9 @@
#include <cdi.h>
#include "cdo_options.h"
#include "process_int.h"
#include "cdo_zaxis.h"
#include "util_files.h"
static void
......
......@@ -23,7 +23,6 @@
#include <cdi.h>
#include "cdo_options.h"
#include "functs.h"
#include "process_int.h"
......@@ -107,7 +106,7 @@ Mergetime(void *process)
const bool skipSameTime = getenvSkipSameTime();
const bool lcopy = unchangedRecord();
const auto lcopy = unchangedRecord();
const int nfiles = cdoStreamCnt() - 1;
std::vector<StreamFile> sf(nfiles);
......
......@@ -33,13 +33,13 @@
#include <cdi.h>
#include "functs.h"
#include "process_int.h"
#include "param_conversion.h"
#include <mpim_grid.h>
#include "percentiles.h"
void *
Merstat(void *process)
{
......
......@@ -26,12 +26,12 @@
#include <cdi.h>
#include "cdo_options.h"
#include "functs.h"
#include "process_int.h"
#include "cdo_vlist.h"
void *
Monarith(void *process)
{
......@@ -46,15 +46,15 @@ Monarith(void *process)
cdoOperatorAdd("monmul", func_mul, 0, nullptr);
cdoOperatorAdd("mondiv", func_div, 0, nullptr);
const int operatorID = cdoOperatorID();
const int operfunc = cdoOperatorF1(operatorID);
const auto operatorID = cdoOperatorID();
const auto operfunc = cdoOperatorF1(operatorID);
const auto streamID1 = cdoOpenRead(0);
const auto streamID2 = cdoOpenRead(1);
const int vlistID1 = cdoStreamInqVlist(streamID1);
const int vlistID2 = cdoStreamInqVlist(streamID2);
const int vlistID3 = vlistDuplicate(vlistID1);
const auto vlistID1 = cdoStreamInqVlist(streamID1);
const auto vlistID2 = cdoStreamInqVlist(streamID2);
const auto vlistID3 = vlistDuplicate(vlistID1);
vlistCompare(vlistID1, vlistID2, CMP_ALL);
......@@ -67,9 +67,9 @@ Monarith(void *process)
field1.resize(gridsizemax);
field2.resize(gridsizemax);
const int taxisID1 = vlistInqTaxis(vlistID1);
const int taxisID2 = vlistInqTaxis(vlistID2);
const int taxisID3 = taxisDuplicate(taxisID1);
const auto taxisID1 = vlistInqTaxis(vlistID1);
const auto taxisID2 = vlistInqTaxis(vlistID2);
const auto taxisID3 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID3, taxisID3);
const auto streamID3 = cdoOpenWrite(2);
......
......@@ -30,7 +30,6 @@
#include <cdi.h>
#include "process_int.h"
void *
......
......@@ -22,7 +22,6 @@
#include "cdi.h"
#include "cdo_options.h"
#include "process_int.h"
#include "parse_literals.h"
......
......@@ -56,18 +56,18 @@ Pressure(void *process)
cdoInitialize(process);
// clang-format off
int PRESSURE_FL = cdoOperatorAdd("pressure_fl", 0, 0, nullptr);
int PRESSURE_HL = cdoOperatorAdd("pressure_hl", 0, 0, nullptr);
int DELTAP = cdoOperatorAdd("deltap", 0, 0, nullptr);
const auto PRESSURE_FL = cdoOperatorAdd("pressure_fl", 0, 0, nullptr);
const auto PRESSURE_HL = cdoOperatorAdd("pressure_hl", 0, 0, nullptr);
const auto DELTAP = cdoOperatorAdd("deltap", 0, 0, nullptr);
// clang-format on
int operatorID = cdoOperatorID();
const auto operatorID = cdoOperatorID();
const auto streamID1 = cdoOpenRead(0);
int vlistID1 = cdoStreamInqVlist(streamID1);
const auto vlistID1 = cdoStreamInqVlist(streamID1);
size_t gridsize = vlist_check_gridsize(vlistID1);
const auto gridsize = vlist_check_gridsize(vlistID1);
int nhlev;
double *vct = vlist_read_vct(vlistID1, &zaxisIDh, &nvct, &nhlev, &nhlevf, &nhlevh);
......@@ -102,7 +102,7 @@ Pressure(void *process)
bool useTable = false;
for (varID = 0; varID < nvars; varID++)
{
int tableNum = tableInqNum(vlistInqVarTable(vlistID1, varID));
const auto tableNum = tableInqNum(vlistInqVarTable(vlistID1, varID));
if (tableNum > 0 && tableNum != 255)
{
useTable = true;
......@@ -114,13 +114,13 @@ Pressure(void *process)
for (varID = 0; varID < nvars; varID++)
{
int zaxisID = vlistInqVarZaxis(vlistID1, varID);
int nlevel = zaxisInqSize(zaxisID);
int instNum = institutInqCenter(vlistInqVarInstitut(vlistID1, varID));
int tableNum = tableInqNum(vlistInqVarTable(vlistID1, varID));
const auto zaxisID = vlistInqVarZaxis(vlistID1, varID);
const auto nlevel = zaxisInqSize(zaxisID);
const auto instNum = institutInqCenter(vlistInqVarInstitut(vlistID1, varID));
const auto tableNum = tableInqNum(vlistInqVarTable(vlistID1, varID));
int code = vlistInqVarCode(vlistID1, varID);
int param = vlistInqVarParam(vlistID1, varID);
auto code = vlistInqVarCode(vlistID1, varID);
auto param = vlistInqVarParam(vlistID1, varID);
cdiParamToString(param, paramstr, sizeof(paramstr));
......@@ -211,21 +211,21 @@ Pressure(void *process)
if (psID == -1) cdoAbort("%s not found!", var_stdname(surface_air_pressure));
}
int gridID = vlistInqVarGrid(vlistID1, pvarID);
const auto gridID = vlistInqVarGrid(vlistID1, pvarID);
if (gridInqType(gridID) == GRID_SPECTRAL)
cdoAbort("%s on spectral representation not supported!", var_stdname(surface_air_pressure));
Varray<double> array(gridsize);
int vlistID2 = vlistCreate();
const auto vlistID2 = vlistCreate();
varID = vlistDefVar(vlistID2, gridID, zaxisIDp, TIME_VARYING);
vlistDefVarParam(vlistID2, varID, cdiEncodeParam(1, 255, 255));
vlistDefVarName(vlistID2, varID, "pressure");
vlistDefVarStdname(vlistID2, varID, "air_pressure");
vlistDefVarUnits(vlistID2, varID, "Pa");
int taxisID1 = vlistInqTaxis(vlistID1);
int taxisID2 = taxisDuplicate(taxisID1);
const auto taxisID1 = vlistInqTaxis(vlistID1);
const auto taxisID2 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID2, taxisID2);
const auto streamID2 = cdoOpenWrite(1);
......@@ -289,7 +289,7 @@ Pressure(void *process)
for (levelID = 0; levelID < nlevel; levelID++)
{
cdoDefRecord(streamID2, varID, levelID);
size_t offset = levelID * gridsize;
const auto offset = levelID * gridsize;
cdoWriteRecord(streamID2, pout + offset, 0);
}
......
......@@ -17,9 +17,9 @@
#include <cdi.h>
#include "process_int.h"
void *
Recttocomplex(void *process)
{
......@@ -30,21 +30,21 @@ Recttocomplex(void *process)
cdoInitialize(process);
const auto streamID1 = cdoOpenRead(0);
const int vlistID1 = cdoStreamInqVlist(streamID1);
const auto vlistID1 = cdoStreamInqVlist(streamID1);
const auto streamID2 = cdoOpenRead(1);
const int vlistID2 = cdoStreamInqVlist(streamID2);
const auto vlistID2 = cdoStreamInqVlist(streamID2);
const int vlistID3 = vlistDuplicate(vlistID1);
const auto vlistID3 = vlistDuplicate(vlistID1);
const int taxisID1 = vlistInqTaxis(vlistID1);
const int taxisID3 = taxisDuplicate(taxisID1);
const auto taxisID1 = vlistInqTaxis(vlistID1);
const auto taxisID3 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID3, taxisID3);
const int nvars = vlistNvars(vlistID3);
const auto nvars = vlistNvars(vlistID3);
for (varID = 0; varID < nvars; ++varID)
{
int datatype = vlistInqVarDatatype(vlistID2, varID);
auto datatype = vlistInqVarDatatype(vlistID2, varID);
datatype = (datatype == CDI_DATATYPE_FLT64) ? CDI_DATATYPE_CPX64 : CDI_DATATYPE_CPX32;
vlistDefVarDatatype(vlistID3, varID, datatype);
}
......
......@@ -23,7 +23,6 @@
#include <cdi.h>
#include "process_int.h"
#include "cdo_vlist.h"
#include "cdo_options.h"
......
......@@ -535,9 +535,9 @@ Remapeta(void *process)
for (int recID = 0; recID < nrecs; recID++)
{
cdoInqRecord(streamID1, &varID, &levelID);
const int zaxisID = vlistInqVarZaxis(vlistID1, varID);
const int nlevel = zaxisInqSize(zaxisID);
const size_t offset = gridsize * levelID;
const auto zaxisID = vlistInqVarZaxis(vlistID1, varID);
const auto nlevel = zaxisInqSize(zaxisID);
const auto offset = gridsize * levelID;
cdoReadRecord(streamID1, array.data(), &nmiss);
if (zaxisIDh != -1)
......@@ -598,7 +598,7 @@ Remapeta(void *process)
int nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
for (levelID = 0; levelID < nlevel; levelID++)
{
const size_t offset = gridsize * levelID;
const auto offset = gridsize * levelID;
single2 = t1 + offset;
arrayMinMaxMask(gridsize, single2, imiss, minval, maxval);
......@@ -610,7 +610,7 @@ Remapeta(void *process)
nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
for (levelID = 0; levelID < nlevel; levelID++)
{
const size_t offset = gridsize * levelID;
const auto offset = gridsize * levelID;
single2 = q1 + offset;
corr_hum(gridsize, single2, MIN_Q);
......@@ -658,7 +658,7 @@ Remapeta(void *process)
int nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
for (levelID = 0; levelID < nlevel; levelID++)
{
const size_t offset = gridsize * levelID;
const auto offset = gridsize * levelID;
single2 = t2 + offset;
arrayMinMaxMask(gridsize, single2, imiss, minval, maxval);
......@@ -674,7 +674,7 @@ Remapeta(void *process)
nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
for (levelID = 0; levelID < nlevel; levelID++)
{
const size_t offset = gridsize * levelID;
const auto offset = gridsize * levelID;
single2 = q2 + offset;
corr_hum(gridsize, single2, MIN_Q);
......@@ -696,7 +696,7 @@ Remapeta(void *process)
{
varID = varids[iv];
const int nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
const auto nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
if (operatorID == REMAPETAS)
{
......
......@@ -23,7 +23,6 @@
#include "netcdf.h"
#endif
#include "cdo_options.h"
#include "process_int.h"
#include "griddes.h"
......
......@@ -23,7 +23,6 @@
#include <cdi.h>
#include "cdo_options.h"
#include "process_int.h"
#include "cdo_vlist.h"
......@@ -51,13 +50,13 @@ Replace(void *process)
const auto streamID1 = cdoOpenRead(0);
const int vlistID1 = cdoStreamInqVlist(streamID1);
const int taxisID1 = vlistInqTaxis(vlistID1);
const int taxisID3 = taxisDuplicate(taxisID1);
const auto vlistID1 = cdoStreamInqVlist(streamID1);
const auto taxisID1 = vlistInqTaxis(vlistID1);
const auto taxisID3 = taxisDuplicate(taxisID1);
const auto streamID2 = cdoOpenRead(1);
const int vlistID2 = cdoStreamInqVlist(streamID2);
const auto vlistID2 = cdoStreamInqVlist(streamID2);
VarList varList1, varList2;
varListInit(varList1, vlistID1);
......@@ -65,8 +64,8 @@ Replace(void *process)
// compare all variables in vlistID2
const int nvars1 = vlistNvars(vlistID1);
const int nvars2 = vlistNvars(vlistID2);
const auto nvars1 = vlistNvars(vlistID1);
const auto nvars2 = vlistNvars(vlistID2);
for (varID2 = 0; varID2 < nvars2; varID2++)
{
......@@ -80,11 +79,11 @@ Replace(void *process)
if (varID1 < nvars1)
{
const size_t gridsize1 = varList1[varID1].gridsize;
const int nlevel1 = varList1[varID1].nlevels;
const auto gridsize1 = varList1[varID1].gridsize;
const auto nlevel1 = varList1[varID1].nlevels;
const size_t gridsize2 = varList2[varID2].gridsize;
const int nlevel2 = varList2[varID2].nlevels;
const auto gridsize2 = varList2[varID2].gridsize;
const auto nlevel2 = varList2[varID2].nlevels;
if (gridsize1 != gridsize2) cdoAbort("Variables have different gridsize!");
......@@ -112,9 +111,9 @@ Replace(void *process)
{
varID1 = varlist1[idx];
varID2 = varlist2[idx];
const int nlevel1 = varList1[varID1].nlevels;
const int nlevel2 = varList2[varID2].nlevels;
const size_t gridsize = varList2[varID2].gridsize;
const auto nlevel1 = varList1[varID1].nlevels;
const auto nlevel2 = varList2[varID2].nlevels;
const auto gridsize = varList2[varID2].gridsize;
vardata2[idx].resize(nlevel2 * gridsize);
varnmiss2[idx].resize(nlevel2);
varlevel[idx].resize(nlevel1);
......@@ -147,14 +146,14 @@ Replace(void *process)
}
}
const int vlistID3 = vlistDuplicate(vlistID1);
const auto vlistID3 = vlistDuplicate(vlistID1);
const auto streamID3 = cdoOpenWrite(2);
vlistDefTaxis(vlistID3, taxisID3);
cdoDefVlist(streamID3, vlistID3);
size_t gridsize = vlistGridsizeMax(vlistID1);
auto gridsize = vlistGridsizeMax(vlistID1);
Varray<double> array(gridsize);
const int nts2 = vlistNtsteps(vlistID2);
......@@ -198,7 +197,7 @@ Replace(void *process)
levelID2 = varlevel[idx][levelID];
if (levelID2 != -1)
{
const size_t offset = varList1[varID].gridsize * levelID2;
const auto offset = varList1[varID].gridsize * levelID2;
parray = &vardata2[idx][offset];
nmiss = varnmiss2[idx][levelID2];
break;
......
......@@ -25,12 +25,11 @@
#include <cdi.h>
#include "process_int.h"
#include "param_conversion.h"
#include "listarray.h"
void *
Replacevalues(void *process)
{
......@@ -46,12 +45,12 @@ Replacevalues(void *process)
cdoInitialize(process);
// clang-format off
const int SETVALS = cdoOperatorAdd("setvals", 0, 0, "I1,O1,...,In,On");
const int SETRTOC = cdoOperatorAdd("setrtoc", 0, 0, "range (min, max), value");
const int SETRTOC2 = cdoOperatorAdd("setrtoc2", 0, 0, "range (min, max), value1, value2");
const auto SETVALS = cdoOperatorAdd("setvals", 0, 0, "I1,O1,...,In,On");
const auto SETRTOC = cdoOperatorAdd("setrtoc", 0, 0, "range (min, max), value");
const auto SETRTOC2 = cdoOperatorAdd("setrtoc2", 0, 0, "range (min, max), value1, value2");
// clang-format on
const int operatorID = cdoOperatorID();
const auto operatorID = cdoOperatorID();
operatorInputArg(cdoOperatorEnter(operatorID));
......@@ -81,11 +80,11 @@ Replacevalues(void *process)
const auto streamID1 = cdoOpenRead(0);
const int vlistID1 = cdoStreamInqVlist(streamID1);
const int vlistID2 = vlistDuplicate(vlistID1);
const auto vlistID1 = cdoStreamInqVlist(streamID1);
const auto vlistID2 = vlistDuplicate(vlistID1);
const int taxisID1 = vlistInqTaxis(vlistID1);
const int taxisID2 = taxisDuplicate(taxisID1);
const auto taxisID1 = vlistInqTaxis(vlistID1);
const auto taxisID2 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID2, taxisID2);
const auto streamID2 = cdoOpenWrite(1);
......@@ -107,7 +106,7 @@ Replacevalues(void *process)
cdoReadRecord(streamID1, array.data(), &nmiss);
const auto gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
const double missval = vlistInqVarMissval(vlistID1, varID);
const auto missval = vlistInqVarMissval(vlistID1, varID);
if (operatorID == SETVALS)
{
......
......@@ -23,7 +23,6 @@
#include <cdi.h>
#include "cdo_options.h"
#include "process_int.h"
#include "cdo_vlist.h"
......@@ -139,9 +138,9 @@ calc_rhopot(size_t gridsize, size_t nlevel, const Varray<double> &pressure, cons
const auto &tovec = to[levelID].vec;
const auto &saovec = sao[levelID].vec;
auto &rhovec = rho[levelID].vec;
const double to_missval = to[levelID].missval;
const double sao_missval = sao[levelID].missval;
const double rho_missval = rho[levelID].missval;
const auto to_missval = to[levelID].missval;
const auto sao_missval = sao[levelID].missval;
const auto rho_missval = rho[levelID].missval;
for (size_t i = 0; i < gridsize; ++i)
{
if (DBL_IS_EQUAL(tovec[i], to_missval) || DBL_IS_EQUAL(saovec[i], sao_missval))
......@@ -171,9 +170,9 @@ Rhopot(void *process)
if (operatorArgc() == 1) pin = parameter2double(cdoOperatorArgv(0));
const auto streamID1 = cdoOpenRead(0);
const int vlistID1 = cdoStreamInqVlist(streamID1);
const auto vlistID1 = cdoStreamInqVlist(streamID1);
const int nvars = vlistNvars(vlistID1);
const auto nvars = vlistNvars(vlistID1);
for (varID = 0; varID < nvars; varID++)
{
......@@ -217,16 +216,16 @@ Rhopot(void *process)
}
if (toID == -1) cdoAbort("In-situ temperature not found!");
const int gridID = vlistGrid(vlistID1, 0);
const size_t gridsize = vlist_check_gridsize(vlistID1);
const auto gridID = vlistGrid(vlistID1, 0);
const auto gridsize = vlist_check_gridsize(vlistID1);
zaxisID = vlistInqVarZaxis(vlistID1, saoID);
const int nlevel1 = zaxisInqSize(zaxisID);
const auto nlevel1 = zaxisInqSize(zaxisID);
zaxisID = vlistInqVarZaxis(vlistID1, toID);
const int nlevel2 = zaxisInqSize(zaxisID);
const auto nlevel2 = zaxisInqSize(zaxisID);
if (nlevel1 != nlevel2) cdoAbort("temperature and salinity have different number of levels!");
const int nlevel = nlevel1;
const auto nlevel = nlevel1;
Varray<double> pressure(nlevel);
cdoZaxisInqLevels(zaxisID, pressure.data());
......@@ -267,8 +266,8 @@ Rhopot(void *process)
vlistDefVarMissval(vlistID2, varID, rho[0].missval);
vlistDefVarDatatype(vlistID2, varID, datatype);
const int taxisID1 = vlistInqTaxis(vlistID1);
const int taxisID2 = taxisDuplicate(taxisID1);
const auto taxisID1 = vlistInqTaxis(vlistID1);
const auto taxisID2 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID2, taxisID2);
const auto streamID2 = cdoOpenWrite(1);
......
......@@ -23,14 +23,13 @@
#include <cdi.h>
#include "cdo_options.h"
#include "dmemory.h"
#include "process_int.h"
#include "param_conversion.h"
#include <mpim_grid.h>
static void
rot_uv_back(int gridID, double *us, double *vs)
{
......
......@@ -23,14 +23,13 @@
#include <cdi.h>
#include "functs.h"
#include "process_int.h"
#include "param_conversion.h"
#include "percentiles.h"
#include "datetime.h"
void *
Runpctl(void *process)
{
......@@ -45,26 +44,26 @@ Runpctl(void *process)
operatorInputArg("percentile number, number of timesteps");
operatorCheckArgc(2);
const double pn = parameter2double(cdoOperatorArgv(0));
const auto pn = parameter2double(cdoOperatorArgv(0));
percentile_check_number(pn);
const int ndates = parameter2int(cdoOperatorArgv(1));
const auto ndates = parameter2int(cdoOperatorArgv(1));
const auto streamID1 = cdoOpenRead(0);
const int vlistID1 = cdoStreamInqVlist(streamID1);
const int vlistID2 = vlistDuplicate(vlistID1);
const auto vlistID1 = cdoStreamInqVlist(streamID1);
const auto vlistID2 = vlistDuplicate(vlistID1);
const int taxisID1 = vlistInqTaxis(vlistID1);
const int taxisID2 = taxisDuplicate(taxisID1);
const auto taxisID1 = vlistInqTaxis(vlistID1);
const auto taxisID2 = taxisDuplicate(taxisID1);
taxisWithBounds(taxisID2);
vlistDefTaxis(vlistID2, taxisID2);
const auto streamID2 = cdoOpenWrite(1);
cdoDefVlist(streamID2, vlistID2);
const int nvars = vlistNvars(vlistID1);
const auto nvars = vlistNvars(vlistID1);
const int maxrecs = vlistNrecs(vlistID1);
const auto maxrecs = vlistNrecs(vlistID1);
std::vector<RecordInfo> recList(maxrecs);
DateTimeList dtlist;
......@@ -79,7 +78,7 @@ Runpctl(void *process)
int tsID;
for (tsID = 0; tsID < ndates; tsID++)
{
int nrecs = cdoStreamInqTimestep(streamID1, tsID);
auto nrecs = cdoStreamInqTimestep(streamID1, tsID);
if (nrecs == 0) cdoAbort("File has less than %d timesteps!", ndates);
dtlist.taxisInqTimestep(taxisID1, tsID);
......@@ -108,19 +107,19 @@ Runpctl(void *process)
if (vlistInqVarTimetype(vlistID1, varID) == TIME_CONSTANT) continue;
const auto gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
const int nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
const double missval = vlistInqVarMissval(vlistID1, varID);
const auto nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
const auto missval = vlistInqVarMissval(vlistID1, varID);
for (levelID = 0; levelID < nlevels; levelID++)
{
Field &rvars1_0 = vars1[0][varID][levelID];
auto &rvars1_0 = vars1[0][varID][levelID];
nmiss = 0;
for (size_t i = 0; i < gridsize; i++)
{