Commit 5c24e63c authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Exprf: changed type of params in parseParamType to std::vector.

parent 52c8dd68
Pipeline #5516 passed with stages
in 15 minutes and 28 seconds
......@@ -330,29 +330,26 @@ params_add_coordinates(int vlistID, parseParamType &parse_arg)
static int
params_add_ts(parseParamType &parse_arg)
{
int varID = -1;
auto params = parse_arg.params;
if (params)
{
varID = parse_arg.nparams;
if (varID >= parse_arg.maxparams) cdoAbort("Too many parameter (limit=%d)", parse_arg.maxparams);
params[varID].name = strdup("_ts");
params[varID].gridID = parse_arg.pointID;
params[varID].zaxisID = parse_arg.surfaceID;
params[varID].steptype = TIME_VARYING;
params[varID].ngp = CLEN;
params[varID].nlev = 1;
parse_arg.nparams++;
parse_arg.cnparams++;
}
auto &params = parse_arg.params;
auto varID = parse_arg.nparams;
if (varID >= parse_arg.maxparams) cdoAbort("Too many parameter (limit=%d)", parse_arg.maxparams);
params[varID].name = strdup("_ts");
params[varID].gridID = parse_arg.pointID;
params[varID].zaxisID = parse_arg.surfaceID;
params[varID].steptype = TIME_VARYING;
params[varID].ngp = CLEN;
params[varID].nlev = 1;
parse_arg.nparams++;
parse_arg.cnparams++;
return varID;
}
static void
parseParamInit(parseParamType &parse_arg, int vlistID, int pointID, int zonalID, int surfaceID, paramType *params)
parseParamInit(parseParamType &parse_arg, int vlistID, int pointID, int zonalID, int surfaceID)
{
const auto nvars = vlistNvars(vlistID);
const auto ngrids = vlistNgrids(vlistID);
......@@ -360,12 +357,12 @@ parseParamInit(parseParamType &parse_arg, int vlistID, int pointID, int zonalID,
const auto maxcoords = ngrids * 4 + nzaxis;
parse_arg.maxparams = MAX_PARAMS;
parse_arg.params.resize(MAX_PARAMS);
parse_arg.nparams = nvars;
parse_arg.cnparams = nvars;
parse_arg.nvars1 = nvars;
parse_arg.init = true;
parse_arg.debug = Options::cdoVerbose != 0;
parse_arg.params = params;
parse_arg.pointID = pointID;
parse_arg.zonalID = zonalID;
parse_arg.surfaceID = surfaceID;
......@@ -475,10 +472,10 @@ Expr(void *process)
const auto zonalID = genZonalID(vlistID1);
const auto surfaceID = getSurfaceID(vlistID1);
std::vector<paramType> params(MAX_PARAMS);
params_init(params, varList1, vlistID1);
parseParamInit(parse_arg, vlistID1, pointID, zonalID, surfaceID);
parseParamInit(parse_arg, vlistID1, pointID, zonalID, surfaceID, params.data());
auto &params = parse_arg.params;
params_init(params, varList1, vlistID1);
// Set all input variables to 'needed' if replacing is switched off
for (int varID = 0; varID < nvars1; varID++) parse_arg.needed[varID] = !replacesVariables;
......@@ -748,7 +745,7 @@ Expr(void *process)
const auto missval = vlistInqVarMissval(vlistID2, varID);
const auto ngp = params[pidx].ngp;
const int nlev = (int) params[pidx].nlev;
const auto nlev = (int) params[pidx].nlev;
for (int levelID = 0; levelID < nlev; levelID++)
{
const auto offset = ngp * levelID;
......
......@@ -1639,29 +1639,23 @@ ex_ifelse(const int init, nodeType *p1, nodeType *p2, nodeType *p3)
return p;
}
/*
static
int exNode(nodeType *p, parseParamType *parse_arg)
static int
exNode(nodeType *p, parseParamType *parse_arg)
{
if ( ! p ) return 0;
if (!p) return 0;
// node is leaf
if ( p->type == typeCon || p->type == typeVar || p->u.opr.nops == 0 )
{
return 0;
}
if (p->type == typeCon || p->type == typeVar || p->u.opr.nops == 0) return 0;
// node has children
for ( int k = 0; k < p->u.opr.nops; k++ )
{
exNode(p->u.opr.op[k], parse_arg);
}
for (int k = 0; k < p->u.opr.nops; k++) exNode(p->u.opr.op[k], parse_arg);
return 0;
}
*/
static int
param_search_name(const int nparam, const paramType *params, const char *name)
param_search_name(const int nparam, const std::vector<paramType> &params, const char *name)
{
for (int varID = 0; varID < nparam; ++varID)
{
......@@ -1672,7 +1666,7 @@ param_search_name(const int nparam, const paramType *params, const char *name)
}
static int
param_search_name_size(const int nparam, paramType *params, const char *name, size_t ngp, size_t nlev)
param_search_name_size(const int nparam, std::vector<paramType> &params, const char *name, size_t ngp, size_t nlev)
{
if (ngp == 0) ngp = 1;
if (nlev == 0) nlev = 1;
......@@ -1714,7 +1708,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)
add_new_constant(const char *varname, parseParamType *parse_arg, std::vector<paramType> &params, const paramType &param)
{
const auto varID = parse_arg->nparams;
if (varID >= parse_arg->maxparams) cdoAbort("Too many parameter (limit=%d)", parse_arg->maxparams);
......@@ -1733,7 +1727,7 @@ add_new_constant(const char *varname, parseParamType *parse_arg, paramType *para
}
static void
add_new_param(const char *varname, parseParamType *parse_arg, paramType *params, const paramType &param)
add_new_param(const char *varname, parseParamType *parse_arg, std::vector<paramType> &params, const paramType &param)
{
const auto varID = parse_arg->nparams;
if (varID >= parse_arg->maxparams) cdoAbort("Too many parameter (limit=%d)", parse_arg->maxparams);
......@@ -1753,7 +1747,7 @@ static nodeType *
expr_run_type_com(nodeType *p, parseParamType *parse_arg)
{
const auto init = parse_arg->init;
auto params = parse_arg->params;
auto &params = parse_arg->params;
const auto cname = p->u.com.cname;
const auto vname = p->u.com.vname;
......@@ -1784,7 +1778,7 @@ expr_run_type_con(nodeType *p, parseParamType *parse_arg)
static int
expr_run_type_var_grid(const char *vnm, int coord, parseParamType *parse_arg)
{
auto params = parse_arg->params;
auto &params = parse_arg->params;
const auto len = strlen(vnm);
auto varname = strdup(vnm);
......@@ -1824,7 +1818,7 @@ expr_run_type_var_grid(const char *vnm, int coord, parseParamType *parse_arg)
static int
expr_run_type_var_zaxis(const char *vnm, int coord, parseParamType *parse_arg)
{
auto params = parse_arg->params;
auto &params = parse_arg->params;
const auto len = strlen(vnm);
auto varname = strdup(vnm);
......@@ -1864,7 +1858,7 @@ static nodeType *
expr_run_type_var(nodeType *p, parseParamType *parse_arg)
{
const auto init = parse_arg->init;
auto params = parse_arg->params;
auto &params = parse_arg->params;
const auto vnm = p->u.var.nm;
auto varID = param_search_name(parse_arg->nparams, params, vnm);
......@@ -1962,7 +1956,7 @@ static nodeType *
expr_run_type_fun(nodeType *p, parseParamType *parse_arg)
{
const auto init = parse_arg->init;
auto params = parse_arg->params;
auto &params = parse_arg->params;
const auto funcID = get_funcID(p->u.fun.name);
auto functype = fun_sym_tbl[funcID].type;
......@@ -2003,7 +1997,7 @@ static nodeType *
expr_run_type_opr(nodeType *p, parseParamType *parse_arg)
{
const auto init = parse_arg->init;
auto params = parse_arg->params;
auto &params = parse_arg->params;
// clang-format off
switch (p->u.opr.oper)
......
......@@ -176,7 +176,7 @@ struct parseParamType
int zonalID;
int surfaceID;
std::vector<CoordType> coords;
paramType *params;
std::vector<paramType> params;
};
typedef union
......
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