Commit 8eaee7a4 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

expr: added function param_print().

parent e0caf12e
......@@ -1692,6 +1692,28 @@ param_search_name_rev2(const int nparam, const paramType *params, const char *na
return varID;
}
static void
param_print(const char *vname, const paramType &param, const long tsID)
{
constexpr size_t maxout = 100;
const double *data = param.data;
for (size_t k = 0; k < param.nlev; ++k)
for (size_t i = 0; i < param.ngp; ++i)
{
if (i < maxout || (param.ngp > maxout && i >= (param.ngp - maxout)))
{
if (param.steptype == TIME_CONSTANT)
fprintf(stdout, " %s[lev=%zu:gp=%zu] = %g\n", vname, k + 1, i + 1, data[k * param.ngp + i]);
else
fprintf(stdout, " %s[ts=%ld:lev=%zu:gp=%zu] = %g\n", vname, tsID, k + 1, i + 1, data[k * param.ngp + i]);
}
else if (i == maxout)
{
fprintf(stdout, " .......\n");
}
}
}
static void
add_new_constant(const char *varname, parseParamType *parse_arg, paramType *params, const paramType &param)
{
......@@ -1759,31 +1781,7 @@ expr_run(nodeType *p, parseParamType *parse_arg)
}
else
{
if (cdo_cmpstr(cname, "print"))
{
const size_t maxout = 100;
const int vartsID = parse_arg->tsID;
const int steptype = params[varID].steptype;
const size_t ngp = params[varID].ngp;
const size_t nlev = params[varID].nlev;
const double *data = params[varID].data;
const long tsID = std::lround(params[vartsID].data[0]);
for (size_t k = 0; k < nlev; ++k)
for (size_t i = 0; i < ngp; ++i)
{
if (i < maxout || (ngp > maxout && i >= (ngp - maxout)))
{
if (steptype == TIME_CONSTANT)
fprintf(stdout, " %s[lev=%zu:gp=%zu] = %g\n", vname, k + 1, i + 1, data[k * ngp + i]);
else
fprintf(stdout, " %s[ts=%ld:lev=%zu:gp=%zu] = %g\n", vname, tsID, k + 1, i + 1, data[k * ngp + i]);
}
else if (i == maxout)
{
fprintf(stdout, " .......\n");
}
}
}
if (cdo_cmpstr(cname, "print")) param_print(vname, params[varID], std::lround(params[parse_arg->tsID].data[0]));
}
break;
......@@ -2022,11 +2020,16 @@ expr_run(nodeType *p, parseParamType *parse_arg)
// printf(" found %s\n", varname2);
if (varID < parse_arg->nvars1)
{
params[varID].select = true;
parse_arg->needed[varID] = true;
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);
{
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;
}
}
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