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

Set type of initialized variables to auto.

parent 9dc0af6d
......@@ -1074,7 +1074,6 @@ fun1c(int init, int funcID, nodeType *p1, double value, parseParamType *parse_ar
const auto zaxisID = p1->param.zaxisID;
const auto coordID = params_get_coordID(parse_arg, 'z', zaxisID);
size_t levidx = 0;
std::vector<double> data;
double *pdata = nullptr;
......@@ -1092,6 +1091,7 @@ fun1c(int init, int funcID, nodeType *p1, double value, parseParamType *parse_ar
pdata = parse_arg->coords[coordID].data.data();
}
size_t levidx = 0;
if (cdo_cmpstr(funcname, "sellevidx"))
{
const long ilevidx = std::lround(value);
......@@ -1657,19 +1657,7 @@ param_search_name(const int nparam, const paramType *params, const char *name)
{
int varID = -1;
for (varID = 0; varID < nparam; --varID)
{
if (cdo_cmpstr(params[varID].name, name)) break;
}
return varID;
}
static int
param_search_name_rev(const int nparam, const paramType *params, const char *name)
{
int varID = -1;
// for (varID = 0; varID < nparam; --varID)
for (varID = nparam - 1; varID >= 0; --varID)
{
if (cdo_cmpstr(params[varID].name, name)) break;
......@@ -1679,29 +1667,13 @@ param_search_name_rev(const int nparam, const paramType *params, const char *nam
}
static int
param_search_name_rev2(const int nparam, const paramType *params, const char *name, int gridID, int zaxisID)
param_search_name_size(const int nparam, const paramType *params, const char *name, size_t ngp, size_t nlev)
{
int varID = -1;
//for (varID = 0; varID < nparam; ++varID)
for (varID = nparam - 1; varID >= 0; --varID)
{
printf("%s grid %d %d zaxis %d %d ngp %d %d nlev %d %d\n", name, gridID, params[varID].gridID, zaxisID, params[varID].zaxisID,
gridInqSize(gridID), gridInqSize(params[varID].gridID), zaxisInqSize(zaxisID), zaxisInqSize(params[varID].zaxisID));
if (gridID == params[varID].gridID && zaxisID == params[varID].zaxisID)
if (cdo_cmpstr(params[varID].name, name)) break;
}
return varID;
}
static int
param_search_name_rev3(const int nparam, const paramType *params, const char *name, size_t ngp, size_t nlev)
{
int varID = -1;
for (varID = nparam - 1; varID >= 0; --varID)
{
printf("%s[N%zu][L%zu] %s[N%zu][L%zu]\n", name, ngp, nlev, params[varID].name, params[varID].ngp, params[varID].nlev);
if (ngp == params[varID].ngp && nlev == params[varID].nlev)
if (cdo_cmpstr(params[varID].name, name)) break;
}
......@@ -1713,7 +1685,7 @@ static void
param_print(const char *vname, const paramType &param, const long tsID)
{
constexpr size_t maxout = 100;
const double *data = param.data;
const auto data = param.data;
for (size_t k = 0; k < param.nlev; ++k)
for (size_t i = 0; i < param.ngp; ++i)
{
......@@ -1734,7 +1706,7 @@ param_print(const char *vname, const paramType &param, const long tsID)
static void
add_new_constant(const char *varname, parseParamType *parse_arg, paramType *params, const paramType &param)
{
int varID = parse_arg->nparams;
auto varID = parse_arg->nparams;
if (varID >= parse_arg->maxparams) cdoAbort("Too many parameter (limit=%d)", parse_arg->maxparams);
param_meta_copy(params[varID], param);
......@@ -1753,7 +1725,7 @@ static void
add_new_param(const char *varname, parseParamType *parse_arg, paramType *params, const paramType &param)
{
// printf(" create %s\n", varname);
int varID = parse_arg->nparams;
auto varID = parse_arg->nparams;
if (varID >= parse_arg->maxparams) cdoAbort("Too many parameter (limit=%d)", parse_arg->maxparams);
param_meta_copy(params[varID], param);
......@@ -1778,7 +1750,7 @@ expr_run(nodeType *p, parseParamType *parse_arg)
if (!p) return rnode;
/* if ( ! init ) { exNode(p, parse_arg); return 0; } */
// if (!init) { exNode(p, parse_arg); return 0; }
switch (p->type)
{
......@@ -1788,7 +1760,7 @@ expr_run(nodeType *p, parseParamType *parse_arg)
const auto vname = p->u.com.vname;
if (parse_arg->debug) cdoPrint("\tstatement\t\t%s(%s)", cname, vname);
auto varID = param_search_name_rev(parse_arg->nparams, params, vname);
auto varID = param_search_name(parse_arg->nparams, params, vname);
if (varID == -1) cdoAbort("Variable %s not found, needed for statement %s(%s)!", vname, cname, vname);
if (init)
......@@ -1813,12 +1785,7 @@ expr_run(nodeType *p, parseParamType *parse_arg)
case typeVar:
{
const auto vnm = p->u.var.nm;
// printf("%s: ngp %zu nlev %zu gID %d zID %d\n", vnm, rnode->param.ngp, rnode->param.nlev, rnode->param.gridID,
// rnode->param.zaxisID);
auto varID = param_search_name_rev(parse_arg->nparams, params, vnm);
// varID = param_search_name_rev2(parse_arg->nparams, params, vnm, rnode->param.gridID, rnode->param.zaxisID);
// XXX printf("found %s varID %d cnparams %d nparams %d\n", vnm, varID, parse_arg->cnparams, parse_arg->nparams);
// if ( varID != -1 ) printf(" gridID %d zaxisID %d\n", params[varID].gridID, params[varID].zaxisID);
auto varID = param_search_name(parse_arg->nparams, params, vnm);
if (varID == -1 && init)
{
const auto len = strlen(vnm);
......@@ -1829,7 +1796,7 @@ expr_run(nodeType *p, parseParamType *parse_arg)
{
auto varname = strdup(vnm);
varname[len - 2] = 0;
varID = param_search_name_rev(parse_arg->nparams, params, varname);
varID = param_search_name(parse_arg->nparams, params, varname);
if (varID == -1)
{
cdoAbort("Coordinate %c: variable >%s< not found!", coord, varname);
......@@ -1866,7 +1833,7 @@ expr_run(nodeType *p, parseParamType *parse_arg)
{
auto varname = strdup(vnm);
varname[len - 2] = 0;
varID = param_search_name_rev(parse_arg->nparams, params, varname);
varID = param_search_name(parse_arg->nparams, params, varname);
if (varID == -1)
{
cdoAbort("Coordinate %c: variable >%s< not found!", coord, varname);
......@@ -2024,8 +1991,8 @@ expr_run(nodeType *p, parseParamType *parse_arg)
cdoPrint("\tpop\tconst\t%s", varname2);
}
// auto varID = param_search_name_rev3(parse_arg->nparams, params, varname2, rnode->param.ngp, rnode->param.nlev);
auto varID = param_search_name_rev(parse_arg->nparams, params, varname2);
//auto varID = param_search_name_size(parse_arg->nparams, params, varname2, rnode->param.ngp, rnode->param.nlev);
auto varID = param_search_name(parse_arg->nparams, params, varname2);
if (init)
{
if (varID >= 0)
......@@ -2034,15 +2001,11 @@ expr_run(nodeType *p, parseParamType *parse_arg)
if (varID < parse_arg->nvars1)
{
if (params[varID].nlev != rnode->param.nlev)
{
cdoAbort("The number of layers must not change (name=%s layers: in=%zu out=%zu)!", params[varID].name,
params[varID].nlev, rnode->param.nlev);
}
else
{
params[varID].select = true;
parse_arg->needed[varID] = true;
}
cdoAbort("The number of layers must not change (name=%s layers: in=%zu out=%zu)!", params[varID].name,
params[varID].nlev, rnode->param.nlev);
params[varID].select = true;
parse_arg->needed[varID] = true;
}
else if (params[varID].coord)
cdoAbort("Coordinate variable %s is read only!", varname2);
......
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