Commit 1a6e2bab authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

Added STATS variable to Collgrid.test.in and introduced selective reruns for tests

parent b5a7f9ff
......@@ -287,7 +287,13 @@ AC_CONFIG_FILES([test/Afterburner.test test/Detrend.test test/Arithc.test test/A
AC_CONFIG_FILES([test/Gradsdes.test test/Collgrid.test test/threads.test test/tsformat.test test/wildcard.test],[chmod a+x "$ac_file"])
AC_CONFIG_FILES([test/Setmiss.test test/Smooth.test test/MapReduce.test test/Ninfo.test],[chmod a+x "$ac_file"])
AC_CONFIG_FILES([test/Filter.test ],[chmod a+x "$ac_file"])
AC_CONFIG_FILES([test/Change.test ],[chmod a+x "$ac_file"])
AC_CONFIG_FILES([Makefile src/lib/ncl/Makefile src/lib/yac/Makefile src/lib/gradsdes/Makefile src/Makefile contrib/Makefile test/Makefile test/data/Makefile test/bandit_tests/Makefile cdo.spec cdo.settings])
#AC_CONFIG_FILES([test/cdoTest.py ],[chmod a+x "$ac_file"])
#AC_CONFIG_FILES([test/Diff.py.test ],[chmod a+x "$ac_file"])
#AC_CONFIG_FILES([test/Arith.py.test ],[chmod a+x "$ac_file"])
AC_OUTPUT
# ----------------------------------------------------------------------
......
......@@ -166,7 +166,7 @@ Adisit(void *process)
const auto operatorID = cdoOperatorID();
const double pin = (operatorArgc() == 1) ? parameter2double(operatorArgv()[0]) : -1;
const double pin = (operatorArgc() == 1) ? parameter2double(cdoOperatorArgv(0)) : -1;
const auto streamID1 = cdoOpenRead(0);
const auto vlistID1 = cdoStreamInqVlist(streamID1);
......
......@@ -1925,7 +1925,7 @@ Afterburner(void *process)
if (operatorArgc() == 1)
{
const char *vctfile = operatorArgv()[0];
const char *vctfile = cdoOperatorArgv(0).c_str();
after_readVct(globs, vctfile);
}
......
......@@ -93,11 +93,11 @@ Arithc(void *process)
operatorInputArg(cdoOperatorEnter(operatorID));
if (operatorArgc() < 1) cdoAbort("Too few arguments!");
if (operatorArgc() > 2) cdoAbort("Too many arguments!");
const auto rconst = parameter2double(operatorArgv()[0]);
const auto rconst = parameter2double(cdoOperatorArgv(0));
double rconstcplx[2];
rconstcplx[0] = rconst;
rconstcplx[1] = 0;
if (operatorArgc() == 2) rconstcplx[1] = parameter2double(operatorArgv()[1]);
if (operatorArgc() == 2) rconstcplx[1] = parameter2double(cdoOperatorArgv(1));
const auto streamID1 = cdoOpenRead(0);
......
......@@ -103,7 +103,7 @@ CDIread(void *process)
if (operatorArgc() > 1) cdoAbort("Too many arguments!");
auto nruns = (operatorArgc() == 1) ? parameter2int(operatorArgv()[0]) : 1;
auto nruns = (operatorArgc() == 1) ? parameter2int(cdoOperatorArgv(0)) : 1;
if (nruns < 0) nruns = 0;
if (nruns > 99) nruns = 99;
......
......@@ -47,7 +47,7 @@ CDItest(void *process)
(void)(operatorID); //CDO_UNUSED
// operatorInputArg("Number of copies");
if (operatorArgc() == 1) max_copy = parameter2int(operatorArgv()[0]);
if (operatorArgc() == 1) max_copy = parameter2int(cdoOperatorArgv(0));
const auto startTime = cdo_get_wtime();
......
......@@ -74,11 +74,11 @@ CDIwrite(void *process)
if (operatorArgc() > 5) cdoAbort("Too many arguments!");
const char *gridfile = defaultgrid;
if (operatorArgc() >= 1) nruns = parameter2int(operatorArgv()[0]);
if (operatorArgc() >= 2) gridfile = operatorArgv()[1];
if (operatorArgc() >= 3) nlevs = parameter2int(operatorArgv()[2]);
if (operatorArgc() >= 4) ntimesteps = parameter2int(operatorArgv()[3]);
if (operatorArgc() >= 5) nvars = parameter2int(operatorArgv()[4]);
if (operatorArgc() >= 1) nruns = parameter2int(cdoOperatorArgv(0));
if (operatorArgc() >= 2) gridfile = cdoOperatorArgv(1).c_str();
if (operatorArgc() >= 3) nlevs = parameter2int(cdoOperatorArgv(2));
if (operatorArgc() >= 4) ntimesteps = parameter2int(cdoOperatorArgv(3));
if (operatorArgc() >= 5) nvars = parameter2int(cdoOperatorArgv(4));
if (nruns < 0) nruns = 0;
if (nruns > 9999) nruns = 9999;
......
......@@ -33,8 +33,6 @@
#include "cdo_cdiWrapper.h"
#include "cdi_lockedIO.h"
int stringToParam(const char *paramstr);
void
cdo_define_var_units(CmorVar &var, int vlistID2, int varID, const char *units)
{
......@@ -338,10 +336,10 @@ CMOR_lite(void *process)
bool convert_data = false;
if (operatorArgc() == 2)
{
if (strcmp("convert", operatorArgv()[1]) == 0)
if ( cdoOperatorArgv(1).compare("convert") == 0)
convert_data = true;
else
cdoAbort("Unknown parameter: >%s<", operatorArgv()[1]);
cdoAbort("Unknown parameter: >%s<", cdoOperatorArgv(1));
}
if (operatorArgc() > 2) cdoAbort("Too many arguments!");
......@@ -359,7 +357,7 @@ CMOR_lite(void *process)
if (convert_data)
for (varID = 0; varID < nvars; ++varID) vars[varID].convert = true;
const auto filename = operatorArgv()[0];
const auto filename = cdoOperatorArgv(0).c_str();
auto fp = fopen(filename, "r");
if (fp == nullptr) cdoAbort("Open failed on: %s\n", filename);
......
......@@ -133,7 +133,7 @@ CMOR_table(void *process)
int operatorID = cdoOperatorID();
if (operatorArgc() != 1) cdoAbort("Too few arguments!");
const char *filename = operatorArgv()[0];
const char *filename = cdoOperatorArgv(0).c_str();
if (Options::cdoVerbose) cdoPrint("Parse file: %s", filename);
......
......@@ -35,16 +35,14 @@
#include "process_int.h"
#include "param_conversion.h"
int stringToParam(const char *paramstr);
#define MAXARG 16384
static void
changeName(const int vlistID1, const int vlistID2, const int nch, char *chnames[MAXARG])
changeName(const int vlistID1, const int vlistID2, const int nch, const char *chnames[MAXARG])
{
char varname[CDI_MAX_NAME], varname2[CDI_MAX_NAME];
const auto npairs = nch / 2;
std::vector<std::pair<char *, char *>> vpairs(npairs);
std::vector<std::pair<const char *,const char *>> vpairs(npairs);
for (int i = 0; i < npairs; ++i) vpairs[i].first = chnames[i * 2];
for (int i = 0; i < npairs; ++i) vpairs[i].second = chnames[i * 2 + 1];
......@@ -152,9 +150,9 @@ Change(void *process)
int nrecs;
int varID = 0, levelID;
int chints[MAXARG];
char *chnames[MAXARG];
const char *chnames[MAXARG];
char varname[CDI_MAX_NAME];
char *chname = nullptr;
const char *chname = nullptr;
int chcode = 0;
int i;
size_t nmiss;
......@@ -185,38 +183,38 @@ Change(void *process)
if (operatorID == CHCODE || operatorID == CHTABNUM)
{
if (nch % 2) cdoAbort("Odd number of input arguments!");
for (i = 0; i < nch; i++) chints[i] = parameter2int(operatorArgv()[i]);
for (i = 0; i < nch; i++) chints[i] = parameter2int(cdoOperatorArgv(i));
}
else if (operatorID == CHPARAM || operatorID == CHNAME || operatorID == CHUNIT)
{
if (nch % 2) cdoAbort("Odd number of input arguments!");
for (i = 0; i < nch; i++) chnames[i] = operatorArgv()[i];
for (i = 0; i < nch; i++) chnames[i] = &cdoOperatorArgv(i)[0];
}
else if (operatorID == CHLEVEL)
{
if (nch % 2) cdoAbort("Odd number of input arguments!");
for (i = 0; i < nch; i++) chlevels[i] = parameter2double(operatorArgv()[i]);
for (i = 0; i < nch; i++) chlevels[i] = parameter2double(cdoOperatorArgv(i));
}
else if (operatorID == CHLEVELC)
{
operatorCheckArgc(3);
chcode = parameter2int(operatorArgv()[0]);
chlevels[0] = parameter2double(operatorArgv()[1]);
chlevels[1] = parameter2double(operatorArgv()[2]);
chcode = parameter2int(cdoOperatorArgv(0));
chlevels[0] = parameter2double(cdoOperatorArgv(1));
chlevels[1] = parameter2double(cdoOperatorArgv(2));
}
else if (operatorID == CHLEVELV)
{
operatorCheckArgc(3);
chname = operatorArgv()[0];
chlevels[0] = parameter2double(operatorArgv()[1]);
chlevels[1] = parameter2double(operatorArgv()[2]);
chname = cdoOperatorArgv(0).c_str();
chlevels[0] = parameter2double(cdoOperatorArgv(1));
chlevels[1] = parameter2double(cdoOperatorArgv(2));
}
else if (operatorID == CHLTYPE)
{
if (nch % 2) cdoAbort("Odd number of input arguments!");
for (i = 0; i < nch; i++) chltypes[i] = parameter2int(operatorArgv()[i]);
for (i = 0; i < nch; i++) chltypes[i] = parameter2int(cdoOperatorArgv(i));
}
const auto streamID1 = cdoOpenRead(0);
......
......@@ -52,7 +52,7 @@ Change_e5slm(void *process)
/* get filename of SLM */
operatorInputArg("filename of the sea land mask");
operatorCheckArgc(1);
const char *fn_slm = operatorArgv()[0];
const char *fn_slm = cdoOperatorArgv(0).c_str();
/* read SLM */
const auto streamIDslm = streamOpenReadLocked(fn_slm);
......
......@@ -133,8 +133,8 @@ Cloudlayer(void *process)
{
operatorCheckArgc(2);
nvars2 = 1;
pmin = parameter2double(operatorArgv()[0]);
pmax = parameter2double(operatorArgv()[1]);
pmin = parameter2double(cdoOperatorArgv(0));
pmax = parameter2double(cdoOperatorArgv(1));
}
else
{
......
......@@ -17,7 +17,6 @@
#include <cdi.h>
#include "dmemory.h"
#include "functs.h"
#include "process_int.h"
......@@ -397,7 +396,8 @@ Collgrid(void *process)
if (nsel > 0)
{
if (strcmp(operatorArgv()[0], "gridtype=unstructured") == 0)
const char *argument = cdoOperatorArgv(0).c_str();
if (strcmp(argument, "gridtype=unstructured") == 0)
{
nsel--;
noff++;
......@@ -405,15 +405,15 @@ Collgrid(void *process)
}
else
{
int len = (int) strlen(operatorArgv()[0]);
while (--len >= 0 && isdigit(operatorArgv()[0][len]))
int len = (int) strlen(argument);
while (--len >= 0 && isdigit(argument[len]))
;
if (len == -1)
{
nsel--;
noff++;
nxblocks = parameter2int(operatorArgv()[0]);
nxblocks = parameter2int(argument);
}
}
}
......@@ -424,10 +424,8 @@ Collgrid(void *process)
}
else
{
char **argnames = operatorArgv() + noff;
if (Options::cdoVerbose)
for (int i = 0; i < nsel; i++) fprintf(stderr, "name %d = %s\n", i + 1, argnames[i]);
for (int i = 0; i < nsel; i++) cdoPrint("name %d = %s\n", i + 1, cdoOperatorArgv(noff + i));
std::vector<bool> selfound(nsel);
for (int i = 0; i < nsel; i++) selfound[i] = false;
......@@ -439,7 +437,7 @@ Collgrid(void *process)
for (int isel = 0; isel < nsel; isel++)
{
if (strcmp(argnames[isel], varname) == 0)
if (cdoOperatorArgv(noff + isel).compare(varname) == 0)
{
selfound[isel] = true;
vars1[varID] = true;
......@@ -447,8 +445,19 @@ Collgrid(void *process)
}
}
int err = 0;
for (int isel = 0; isel < nsel; isel++)
if (selfound[isel] == false) cdoAbort("Variable name %s not found!", argnames[isel]);
{
if (selfound[isel] == false)
{
err++;
cdoWarning("Variable name %s not found!", cdoOperatorArgv(noff + isel));
}
}
if (err)
{
cdoAbort("Could not find all requested variables: (%d/%d)", nsel - err, nsel);
}
}
for (varID = 0; varID < nvars; varID++)
......
......@@ -52,7 +52,7 @@ Compc(void *process)
const auto operatorID = cdoOperatorID();
operatorInputArg("constant value");
const auto rc = parameter2double(operatorArgv()[0]);
const auto rc = parameter2double(cdoOperatorArgv(0));
const auto streamID1 = cdoOpenRead(0);
......
......@@ -46,7 +46,7 @@ Condc(void *process)
const auto operatorID = cdoOperatorID();
operatorInputArg("constant value");
const auto rc = parameter2double(operatorArgv()[0]);
const auto rc = parameter2double(cdoOperatorArgv(0));
const auto streamID1 = cdoOpenRead(0);
......
......@@ -138,7 +138,7 @@ Consecstat(void *process)
const int operatorID = cdoOperatorID();
if (operatorID == CONSECSUM)
if (operatorArgc() > 0) refval = parameter2double(operatorArgv()[0]);
if (operatorArgc() > 0) refval = parameter2double(cdoOperatorArgv(0));
const auto istreamID = cdoOpenRead(0);
......
......@@ -57,7 +57,7 @@ Deltime(void *process)
int nsel = operatorArgc();
if (nsel < 1) cdoAbort("Too few arguments!");
if (nsel > 1) cdoAbort("Too many arguments!");
char *sarg = operatorArgv()[0];
const char *sarg = cdoOperatorArgv(0).c_str();
dday = atoi(sarg);
dmon = 0;
while (isdigit(*sarg)) sarg++;
......
......@@ -81,7 +81,7 @@ detrendGetParameter(bool &tstepIsEqual)
const auto pargc = operatorArgc();
if (pargc)
{
const auto pargv = operatorArgv();
const auto pargv = cdoGetOperArgv();
KVList kvlist;
kvlist.name = "TREND";
......
......@@ -42,7 +42,7 @@ diffGetParameter(double &abslim, double &abslim2, double &rellim, int &mapflag)
const auto pargc = operatorArgc();
if (pargc)
{
const auto pargv = operatorArgv();
const auto pargv = cdoGetOperArgv();
KVList kvlist;
kvlist.name = "DIFF";
......
......@@ -243,9 +243,9 @@ Distgrid(void *process)
operatorInputArg("nxblocks, [nyblocks]");
if (operatorArgc() < 1) cdoAbort("Too few arguments!");
if (operatorArgc() > 2) cdoAbort("Too many arguments!");
size_t nxblocks = parameter2int(operatorArgv()[0]);
size_t nxblocks = parameter2int(cdoOperatorArgv(0));
size_t nyblocks = 1;
if (operatorArgc() == 2) nyblocks = parameter2int(operatorArgv()[1]);
if (operatorArgc() == 2) nyblocks = parameter2int(cdoOperatorArgv(1));
if (nxblocks == 0) cdoAbort("nxblocks has to be greater than 0!");
if (nyblocks == 0) cdoAbort("nyblocks has to be greater than 0!");
......
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