Commit 0bf9bea4 authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

Merge branch 'develop' of git.mpimet.mpg.de:cdo into develop

parents 879c636d 552f6581
......@@ -290,6 +290,7 @@ AC_CONFIG_FILES([
test/Copy_netcdf.test
test/Detrend.test
test/EOF.test
test/EOFcoeff.test
test/Enspctl.test
test/Ensstat.test
test/Expr.test
......
......@@ -67,8 +67,6 @@ ydstatUpdate(YDAY_STATS &stats, int64_t vdate, int vtime, const FieldVector2D &v
{
bool lvarstd = vars2.size();
const auto nvars = vlistNvars(stats.vlist);
const auto dayoy = decodeDayOfYear(vdate);
if (dayoy < 0 || dayoy >= MaxDays) cdoAbort("Day %d out of range!", dayoy);
......@@ -81,6 +79,7 @@ ydstatUpdate(YDAY_STATS &stats, int64_t vdate, int vtime, const FieldVector2D &v
if (lvarstd) fieldsFromVlist(stats.vlist, stats.vars2[dayoy], FIELD_VEC);
}
const auto nvars = vlistNvars(stats.vlist);
for (int varID = 0; varID < nvars; varID++)
{
if (vlistInqVarTimetype(stats.vlist, varID) == TIME_CONSTANT) continue;
......@@ -120,48 +119,38 @@ ydstatUpdate(YDAY_STATS &stats, int64_t vdate, int vtime, const FieldVector2D &v
static void
ydstatFinalize(YDAY_STATS &stats, int operfunc)
{
int varID, levelID, nlevels;
const bool lmean = operfunc == func_mean || operfunc == func_avg;
const bool lstd = operfunc == func_std || operfunc == func_std1;
const bool lvarstd = operfunc == func_std || operfunc == func_var || operfunc == func_std1 || operfunc == func_var1;
const int divisor = operfunc == func_std1 || operfunc == func_var1;
const auto nvars = vlistNvars(stats.vlist);
for (int dayoy = 0; dayoy < MaxDays; dayoy++)
if (stats.nsets[dayoy])
{
switch (operfunc)
const auto nvars = vlistNvars(stats.vlist);
for (int varID = 0; varID < nvars; varID++)
{
case func_avg:
case func_mean:
for (varID = 0; varID < nvars; varID++)
{
if (vlistInqVarTimetype(stats.vlist, varID) == TIME_CONSTANT) continue;
nlevels = zaxisInqSize(vlistInqVarZaxis(stats.vlist, varID));
for (levelID = 0; levelID < nlevels; levelID++)
vfarcdiv(stats.vars1[dayoy][varID][levelID], (double) stats.nsets[dayoy]);
}
break;
case func_std:
case func_std1:
for (varID = 0; varID < nvars; varID++)
{
if (vlistInqVarTimetype(stats.vlist, varID) == TIME_CONSTANT) continue;
nlevels = zaxisInqSize(vlistInqVarZaxis(stats.vlist, varID));
for (levelID = 0; levelID < nlevels; levelID++)
vfarcstd(stats.vars1[dayoy][varID][levelID], stats.vars2[dayoy][varID][levelID], stats.nsets[dayoy], divisor);
}
break;
if (vlistInqVarTimetype(stats.vlist, varID) == TIME_CONSTANT) continue;
case func_var:
case func_var1:
for (varID = 0; varID < nvars; varID++)
const auto nlevels = zaxisInqSize(vlistInqVarZaxis(stats.vlist, varID));
for (int levelID = 0; levelID < nlevels; levelID++)
{
if (vlistInqVarTimetype(stats.vlist, varID) == TIME_CONSTANT) continue;
nlevels = zaxisInqSize(vlistInqVarZaxis(stats.vlist, varID));
for (levelID = 0; levelID < nlevels; levelID++)
vfarcvar(stats.vars1[dayoy][varID][levelID], stats.vars2[dayoy][varID][levelID], stats.nsets[dayoy], divisor);
auto nsets = stats.nsets[dayoy];
auto &rvars1 = stats.vars1[dayoy][varID][levelID];
if (lmean)
{
vfarcdiv(rvars1, (double) nsets);
}
else if (lvarstd)
{
auto &rvars2 = stats.vars2[dayoy][varID][levelID];
if (lstd)
vfarcstd(rvars1, rvars2, nsets, divisor);
else
vfarcvar(rvars1, rvars2, nsets, divisor);
}
}
break;
}
}
}
......
......@@ -1029,23 +1029,12 @@ str_to_int(const char *intstring)
void
evaluateColorOptions(const std::string &optarg)
{
if ("all" == optarg)
{
mpmoColorSet(All);
}
else if ("auto" == optarg)
{
mpmoColorSet(Auto);
}
else if ("no" == optarg)
{
mpmoColorSet(No);
}
else
{
mpmoColorSet(All);
cdoAbort("Color option <%s> unknown. Known options: auto, all, no", Yellow(optarg.c_str()));
}
// clang-format off
if ("all" == optarg) mpmoColorSet(All);
else if ("auto" == optarg) mpmoColorSet(Auto);
else if ("no" == optarg) mpmoColorSet(No);
else cdoAbort("Color option <%s> unknown. Known options: auto, all, no", Yellow(optarg.c_str()));
// clang-format on
}
int
......@@ -1064,33 +1053,33 @@ evaluateExpectOptions(const std::string &optarg)
}
static int
parse_options_long(int argc, char *argv[])
parseOptionsLong(int argc, char *argv[])
{
// These variables must be initialized with each while loop run!
int lasync_worker;
int lnetcdf_hdr_pad;
int luse_fftw;
int leccodes;
int lcellsearchmethod;
int lpointsearchmethod;
int lcolor;
int lconfig;
int ldebLevel;
int leccodes;
int lenableexcept;
int lgridsearchradius;
int lremap_genweights;
int lprecision;
int lnetcdf_hdr_pad;
int lpedantic;
int lpercentile;
int lprintoperatorsno = 0;
int lprintoperators = 0;
int lpedantic = 0;
int lenableexcept;
int ltimestat_date;
int luse_time_bounds;
int lpointsearchmethod;
int lprecision;
int lprintoperators;
int lprintoperatorsno;
int lremap_genweights;
int lscmode;
int lseed;
int lsortname;
int lsortparam;
int ldebLevel;
int lseed = 0;
int lscmode;
int lconfig;
int ltimestat_date;
int luse_fftw;
int luse_time_bounds;
int verbose;
int lcolor;
char *token;
// clang-format off
const struct cdo_option opt_long[] =
......@@ -1147,24 +1136,28 @@ parse_options_long(int argc, char *argv[])
// IMPORTANT: BY EVERY OPTION that takes arguments you MUST set its trigger variable to ZERO;
// otherwise the parameters of other options get wrongly assigned.
lasync_worker = 0;
leccodes = 0;
lprecision = 0;
lpercentile = 0;
lnetcdf_hdr_pad = 0;
luse_fftw = 0;
lcellsearchmethod = 0;
lcolor = 0;
lconfig = 0;
lpointsearchmethod = 0;
ldebLevel = 0;
leccodes = 0;
lenableexcept = 0;
lgridsearchradius = 0;
lnetcdf_hdr_pad = 0;
lpedantic = 0;
lpercentile = 0;
lpointsearchmethod = 0;
lprecision = 0;
lprintoperators = 0;
lprintoperatorsno = 0;
lremap_genweights = 0;
lenableexcept = 0;
ltimestat_date = 0;
luse_time_bounds = 0;
lscmode = 0;
lseed = 0;
lsortname = 0;
lsortparam = 0;
ldebLevel = 0;
lscmode = 0;
lcolor = 0;
ltimestat_date = 0;
luse_fftw = 0;
luse_time_bounds = 0;
int c = cdo_getopt_long(argc, argv, "f:b:e:P:g:i:k:l:m:n:t:D:z:aC:cdhLMOpQRrsSTuVvWXZ", opt_long, nullptr);
if (c == -1) break;
......@@ -1307,16 +1300,15 @@ parse_options_long(int argc, char *argv[])
break;
case 'D':
Debug = 1;
token = std::strtok((char *) CDO_optarg, ",");
while (token != NULL)
{
int res = std::atoi(token);
if (res != 0)
{
DebugLevel = DebugLevel | (int) std::pow(2, res) / 2;
}
token = std::strtok(NULL, ",");
}
{
char *token = std::strtok((char *) CDO_optarg, ",");
while (token != NULL)
{
int res = std::atoi(token);
if (res != 0) DebugLevel = DebugLevel | (int) std::pow(2, res) / 2;
token = std::strtok(NULL, ",");
}
}
break;
case 'f': setDefaultFileType(CDO_optarg); break;
case 'g': cdo_set_grids(CDO_optarg); break;
......@@ -1796,7 +1788,7 @@ main(int argc, char *argv[])
get_env_vars();
init_modules();
status = parse_options_long(argc, argv);
status = parseOptionsLong(argc, argv);
if (status != 0) return 1;
cdo_set_options();
......
......@@ -6,19 +6,20 @@ test -n "$DATAPATH" || DATAPATH="@abs_top_srcdir@/test/data"
#
declare -a STATS
STATS=("detrend" "trend" "subtrend")
#
IFILE=$DATAPATH/detrend_data
NTEST=1
#
RSTAT=0
RFILE=$DATAPATH/detrend_ref
OFILE=detrend_res
#
# detrend
#
RSTAT=0
CDOCOMMAND="$CDO ${STATS[0]} $IFILE $OFILE"
CDOTEST="${STATS[0]}"
echo "Running test: $NTEST"
echo "$CDOCOMMAND"
......@@ -34,10 +35,13 @@ test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
let NTEST+=1
rm -f $OFILE
#
# trend
# trend/subtrend
#
RSTAT=0
CDOCOMMAND="$CDO ${STATS[1]} $IFILE ta tb"
CDOTEST="${STATS[1]}/${STATS[2]}"
echo "Running test: $NTEST"
echo "$CDOCOMMAND"
......@@ -55,15 +59,11 @@ test $? -eq 0 || let RSTAT+=1
$CDO diff $OFILE $RFILE
test $? -eq 0 || let RSTAT+=1
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
let NTEST+=1
rm -f $OFILE
rm -f ta tb
#
#
exit 0
#! @BASH@
#
echo 1..8 # Number of tests to be executed.
echo 1..4 # Number of tests to be executed.
#
test -n "$CDO" || CDO="@abs_top_builddir@/src/cdo $CDO_DEBUG"
test -n "$DATAPATH" || DATAPATH="@abs_top_srcdir@/test/data/"
#
export CDO_FILE_SUFFIX=NULL
export CDO_WEIGHT_MODE=off
#export CDO_SVD_MODE=danielson_lanczos
#
FORMAT="-f srv -b 32"
STATS="eof eof3d"
#
NTEST=1
######################################################
IFILE=$DATAPATH/psl_DJF_anom.grb
RFILE1=$DATAPATH/eval_ref
RFILE2=$DATAPATH/eof_ref
RFILE3=$DATAPATH/pcoeff00000
OFILE1=eval_res
OFILE2=eof_res
OFILE3=res_pcoeff
#
declare -a STATS
STATS=("eof" "eofcoeff" "eof3d" "eofcoeff3d")
#
RSTAT=0
#
for X in 0 1; do
for STAT in $STATS; do
for MODE in jacobi danielson_lanczos; do
RSTAT=0
export CDO_SVD_MODE=$MODE
#--------------------------------------------------------------
CDOTEST="eof${DIM} - $MODE"
CDOCOMMAND="$CDO $FORMAT ${STATS[$x]},1 $IFILE $OFILE1 $OFILE2"
CDOTEST="${STAT} - $MODE"
CDOCOMMAND="$CDO $FORMAT ${STAT},1 $IFILE $OFILE1 $OFILE2"
echo "$CDOCOMMAND"
#
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
#
$CDO diff,abslim=1e-8 $OFILE1 $RFILE1
test $? -eq 0 || let RSTAT+=1
#
$CDO diff,abslim=1e-7 -abs $OFILE2 -abs $RFILE2
test $? -eq 0 || let RSTAT+=1
#
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
#
let NTEST+=1
RSTAT=0
#--------------------------------------------------------------
CDOTEST="eofcoeff${DIM} - $MODE"
#
CDOCOMMAND="$CDO $FORMAT ${STATS[$x + 1]} $OFILE2 $IFILE $OFILE3"
echo "$CDOCOMMAND"
#
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
#
$CDO diff,abslim=0.02 -abs ${OFILE3}00000 -abs $RFILE3
test $? -eq 0 || let RSTAT+=1
#
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
#
let NTEST+=1
RSTAT=0
#--------------------------------------------------------------
rm -f $OFILE1 $OFILE2 ${OFILE3}00000
done
done
#
#
exit 0
#! @BASH@
echo 1..4 # Number of tests to be executed.
#
test -n "$CDO" || CDO="@abs_top_builddir@/src/cdo $CDO_DEBUG"
test -n "$DATAPATH" || DATAPATH="@abs_top_srcdir@/test/data/"
#
export CDO_FILE_SUFFIX=NULL
export CDO_WEIGHT_MODE=off
#
FORMAT="-f srv -b 32"
STATS="eofcoeff eofcoeff3d"
#
NTEST=1
IFILE=$DATAPATH/psl_DJF_anom.grb
RFILE=$DATAPATH/pcoeff00000
OFILE=res_pcoeff
#
for STAT in $STATS; do
for MODE in jacobi danielson_lanczos; do
RSTAT=0
export CDO_SVD_MODE=$MODE
CDOTEST="${STAT} - $MODE"
CDOCOMMAND="$CDO $FORMAT ${STAT} $DATAPATH/eof_ref $IFILE $OFILE"
echo "$CDOCOMMAND"
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
$CDO diff,abslim=0.02 -abs ${OFILE}00000 -abs $RFILE
test $? -eq 0 || let RSTAT+=1
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
let NTEST+=1
rm -f ${OFILE}00000
done
done
#
exit 0
......@@ -4,9 +4,8 @@ echo 1..3 # Number of tests to be executed.
test -n "$CDO" || CDO="@abs_top_builddir@/src/cdo $CDO_DEBUG"
test -n "$DATAPATH" || DATAPATH="@abs_top_srcdir@/test/data/"
#
FORMAT="-f srv -b 32"
STATS="expr aexpr"
ABSLIMMAX=0.001
#
IFILE=$DATAPATH/pl_data
......@@ -14,38 +13,33 @@ NTEST=1
#
FINSTR=finstr
#
#
function testfunc()
{
STATS="expr aexpr"
RSTAT=0
CDOTEST="instruction set $NTEST"
echo "Running test: $NTEST - $CDOTEST"
for EXPR in $STATS; do
RFILE=$DATAPATH/${EXPR}${NTEST}_ref
OFILE=${EXPR}${NTEST}_res
for STAT in $STATS; do
RFILE=$DATAPATH/${STAT}${NTEST}_ref
OFILE=${STAT}${NTEST}_res
for FILE in "" "f"; do
if [ "$STAT" = "exprf" ] ; then
echo $INSTR > $FINSTR
CDOCOMMAND="$CDO $FORMAT $STAT,$FINSTR $IFILE $OFILE"
else
CDOCOMMAND="$CDO $FORMAT $STAT,$INSTR $IFILE $OFILE"
fi
if [ "$FILE" = "f" ] ; then
echo $INSTR > $FINSTR
CDOCOMMAND="$CDO $FORMAT $EXPR${FILE},$FINSTR $IFILE $OFILE"
else
CDOCOMMAND="$CDO $FORMAT $EXPR,$INSTR $IFILE $OFILE"
fi
echo "$CDOCOMMAND"
echo "$CDOCOMMAND"
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
$CDO diff,abslim=$ABSLIMMAX $RFILE $OFILE
test $? -eq 0 || let RSTAT+=1
$CDO diff,abslim=$ABSLIMMAX $RFILE $OFILE
test $? -eq 0 || let RSTAT+=1
rm -f $OFILE $FINSTR
done
rm -f $OFILE $FINSTR
done
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
......@@ -62,7 +56,5 @@ testfunc
#
INSTR="C1=3+4;C2=C1-7;r1=C2+fldmean(var130);r2=vertmean(var130)+C2;"
testfunc
#
#
exit 0
......@@ -4,8 +4,6 @@ echo 1..16 # Number of tests to be executed.
test -n "$CDO" || CDO="@abs_top_builddir@/src/cdo $CDO_DEBUG"
test -n "$DATAPATH" || DATAPATH="@abs_top_srcdir@/test/data/"
#
FORMATS="srv ext ieg grb grb2 nc nc2 nc4"
#
NTEST=1
......@@ -55,11 +53,8 @@ for OPERATOR in $STATS; do
test $? -eq 0 || let RSTAT+=1
test -s $FILE || let RSTAT+=1
$CDO diff,abslim=0.0001 $FILE $RFILE
test $? -eq 0 || let RSTAT+=1
else
OFILE=file_${DATATYPE}_${FORMAT}_res
CDOCOMMAND="$CDO copy $FILE $OFILE"
......@@ -68,11 +63,9 @@ for OPERATOR in $STATS; do
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
$CDO diff,abslim=0.0001 $FILE $OFILE
test $? -eq 0 || let RSTAT+=1
rm -f $FILE $OFILE
fi
done
......@@ -83,11 +76,8 @@ for OPERATOR in $STATS; do
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST # SKIP $FILEFORMAT not enabled"
fi
fi
let NTEST+=1
done
done
#
#
exit 0
......@@ -12,7 +12,6 @@ ABSLIMMAX=0.001
ABSLIMDIS=0.2
ABSLIMSCON=0.25
FORMAT="-f srv -b 32"
GRIDS="n16 n32"
#
......@@ -38,7 +37,6 @@ for GRIDTYPE in "regular" "curvilinear" "unstructured"; do
OFILE=${GRID}_${RMOD}_$$
RFILE=$DATAPATH/${GRID}_${RMOD:3}_ref
CDOTEST="gen${RMOD} $GRID $GRIDTYPE"
CDOCOMMAND="$CDO $FORMAT $RMOD,$GRID $SETGRID $IFILE remapweights"
......@@ -58,8 +56,6 @@ for GRIDTYPE in "regular" "curvilinear" "unstructured"; do
$CDO diff,abslim=$ABSLIM $OFILE $RFILE
test $? -eq 0 || let RSTAT+=1
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
if [ $RMOD = dis ]; then
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST # TODO check depends on optimization"
......@@ -76,7 +72,5 @@ for GRIDTYPE in "regular" "curvilinear" "unstructured"; do
done
done
done
#
#
exit 0
......@@ -3,9 +3,6 @@ echo 1..1 # Number of tests to be executed.
#
test -n "$CDO" || CDO="@abs_top_builddir@/src/cdo $CDO_DEBUG"
test -n "$DATAPATH" || DATAPATH="@abs_top_srcdir@/test/data/"
#
#
IFILE=$DATAPATH/pl_data.grb
OFILE=pl_data.grb
......@@ -42,7 +39,5 @@ rm -f $OFILE $RFILE1 $RFILE2
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
#
#
exit 0
......@@ -23,11 +23,12 @@ TESTS =\
Copy_netcdf.test \
Detrend.test \
EOF.test \
EOFcoeff.test \
Enspctl.test \
Ensstat.test \
Expr.test \
File.test \
Filter.test \
Filter.test \
Fldpctl.test \
Fldstat.test \
Genweights.test \
......
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