Commit f0fcfdcd authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

added file for cpp module integration

parent 49723c88
......@@ -71,6 +71,8 @@
#define MAX_NUM_VARNAMES 256
#include <string>
static int Debug = 0;
static int Version = 0;
static int Help = 0;
......@@ -324,50 +326,47 @@ void cdo_init_is_tty(void)
}
static
void cdoPrintHelp(const char *phelp[]/*, char *xoperator*/)
void cdoPrintHelp(std::vector<std::string> help/*, char *xoperator*/)
{
if ( phelp == NULL )
if (help.empty())
fprintf(stderr, "No help available for this operator!\n");
else
{
bool lprint;
while ( *phelp )
for(unsigned long i = 0; i < help.size(); i++)
{
lprint = !(*phelp[0] == '\0' && *(phelp+1) && *(phelp+1)[0] == ' ');
lprint = !(help[i][0] == '\0' && help[i+1][0] == ' ');
if ( lprint )
{
if ( COLOR_STDOUT )
{
if ( (strcmp(*phelp, "NAME") == 0) ||
(strcmp(*phelp, "SYNOPSIS") == 0) ||
(strcmp(*phelp, "DESCRIPTION") == 0) ||
(strcmp(*phelp, "OPERATORS") == 0) ||
(strcmp(*phelp, "NAMELIST") == 0) ||
(strcmp(*phelp, "PARAMETER") == 0) ||
(strcmp(*phelp, "ENVIRONMENT") == 0) ||
(strcmp(*phelp, "NOTE") == 0) ||
(strcmp(*phelp, "EXAMPLES") == 0) )
if ( (help[i].compare( "NAME") == 0) ||
(help[i].compare( "SYNOPSIS") == 0) ||
(help[i].compare( "DESCRIPTION") == 0) ||
(help[i].compare( "OPERATORS") == 0) ||
(help[i].compare( "NAMELIST") == 0) ||
(help[i].compare( "PARAMETER") == 0) ||
(help[i].compare( "ENVIRONMENT") == 0) ||
(help[i].compare( "NOTE") == 0) ||
(help[i].compare( "EXAMPLES") == 0) )
{
set_text_color(stdout, BRIGHT, BLACK);
fprintf(stdout, "%s", *phelp);
fprintf(stdout, "%s", help[i].c_str());
reset_text_color(stdout);
fprintf(stdout, "\n");
}
else
fprintf(stdout, "%s\n", *phelp);
fprintf(stdout, "%s\n", help[i].c_str());
}
else
{
fprintf(stdout, "%s\n", *phelp);
fprintf(stdout, "%s\n", help[i].c_str());
}
}
phelp++;
}
}
}
static
void cdoSetDebug(int level)
{
......@@ -1448,7 +1447,7 @@ int main(int argc, char *argv[])
int lstop = FALSE;
int noff = 0;
int status = 0;
char *operatorArg = NULL;
const char *operatorArg = NULL;
argument_t *argument = NULL;
cdo_init_is_tty();
......@@ -1469,7 +1468,7 @@ int main(int argc, char *argv[])
if ( noff ) setDefaultFileType(Progname+noff, 0);
get_env_vars();
init_modules();
status = parse_options_long(argc, argv);
if ( status != 0 ) return -1;
......@@ -1591,7 +1590,14 @@ int main(int argc, char *argv[])
timer_start(timer_total);
#ifdef CUSTOM_MODULES
load_custom_modules("custom_modules");
operatorModule(operatorName)(argument);
close_library_handles();
#else
operatorModule(operatorName)(argument);
#endif
timer_stop(timer_total);
......
......@@ -16,30 +16,28 @@
*/
#if defined(HAVE_CONFIG_H)
# include "config.h"
#include "config.h"
#endif
#include <cdi.h>
#include "cdo_int.h"
#include "operator_help.h"
#include "modules.h"
#include "error.h"
#include "modules.h"
#include "operator_help.h"
#include <cdi.h>
#include <dirent.h>
#include <dlfcn.h>
#include <regex>
#include <set>
#include <string>
#include <vector>
// for std::sort()
#include <algorithm>
#define MAX_MOD_OPERATORS 128 // maximum number of operators for a module
typedef struct {
void *(*func)(void *); // Module
const char **help; // Help
const char *operators[MAX_MOD_OPERATORS]; // Operator names
short mode; // Module mode: 0:intern 1:extern
short number; // Allowed number type
short streamInCnt; // Number of input streams
short streamOutCnt; // Number of output streams
}
modules_t;
int NumModules;
int NumAliases;
/* \cond */
void *Adisit(void *argument);
void *Afterburner(void *argument);
void *Arith(void *argument);
......@@ -156,7 +154,6 @@ void *Seloperator(void *argument);
void *Selrec(void *argument);
void *Seltime(void *argument);
void *Set(void *argument);
void *Setattribute(void *argument);
void *Setbox(void *argument);
void *Setgatt(void *argument);
void *Setgrid(void *argument);
......@@ -273,7 +270,7 @@ void *Strbre(void *argument);
void *Strgal(void *argument);
void *Hurr(void *argument);
//void *Hi(void *argument);
// void *Hi(void *argument);
void *Wct(void *argument);
void *Magplot(void *argument);
......@@ -286,6 +283,7 @@ void *WindTrans(void *argument); // "uvDestag", "rotuvN", "rotuvNorth", "projuv
void *Samplegrid(void *argument); // "samplegrid", "subgrid"
/* clang-format off */
#define AdisitOperators {"adisit", "adipot"}
#define AfterburnerOperators {"after"}
#define ArithOperators {"add", "sub", "mul", "div", "min", "max", "atan2"}
......@@ -336,7 +334,7 @@ void *Samplegrid(void *argument); // "samplegrid", "subgrid"
#define FillmissOperators {"fillmiss", "fillmiss2"}
#define FilterOperators {"bandpass", "highpass", "lowpass"}
#define FldrmsOperators {"fldrms"}
#define FldstatOperators {"fldrange", "fldmin", "fldmax", "fldsum", "fldmean", "fldavg", "fldstd", "fldstd1", "fldvar", "fldvar1", "fldpctl"}
#define FldstatOperators {"fldmin", "fldmax", "fldsum", "fldmean", "fldavg", "fldstd", "fldstd1", "fldvar", "fldvar1", "fldpctl"}
#define FldcorOperators {"fldcor"}
#define FldcovarOperators {"fldcovar"}
#define FourierOperators {"fourier"}
......@@ -377,7 +375,7 @@ void *Samplegrid(void *argument); // "samplegrid", "subgrid"
#define MonarithOperators {"monadd", "monsub", "monmul", "mondiv"}
#define MrotuvOperators {"mrotuv"}
#define MrotuvbOperators {"mrotuvb"}
#define NinfoOperators {"nyear", "nmon", "ndate", "ntime", "ncode", "npar", "nlevel", "ngridpoints", "ngrids"}
#define NinfoOperators {"nyear", "nmon", "ndate", "ntime", "npar", "nlevel", "ngridpoints", "ngrids"}
#define NmldumpOperators {"nmldump", "kvldump"}
#define OutputOperators {"output", "outputint", "outputsrv", "outputext", "outputf", "outputts", \
"outputfld", "outputarr", "outputxyz"}
......@@ -420,7 +418,6 @@ void *Samplegrid(void *argument); // "samplegrid", "subgrid"
#define SeltimeOperators {"seltimestep", "selyear", "selseason", "selmonth", "selday", "selhour", "seldate", \
"seltime", "selsmon"}
#define SetOperators {"setcode", "setparam", "setname", "setunit", "setlevel", "setltype", "settabnum"}
#define SetattributeOperators {"setattribute"}
#define SetboxOperators {"setclonlatbox", "setcindexbox"}
#define SetgattOperators {"setgatt", "setgatts"}
#define SetgridOperators {"setgrid", "setgridtype", "setgridarea", "setgridmask", "unsetgridmask", "setgridnumber", "setgriduri", "usegridnumber"}
......@@ -473,11 +470,11 @@ void *Samplegrid(void *argument); // "samplegrid", "subgrid"
#define XTimstatOperators {"xtimmin", "xtimmax", "xtimsum", "xtimmean", "xtimavg", "xtimvar", "xtimvar1", "xtimstd", "xtimstd1", \
"xyearmin", "xyearmax", "xyearsum", "xyearmean", "xyearavg", "xyearvar", "xyearvar1", "xyearstd", "xyearstd1", \
"xmonmin", "xmonmax", "xmonsum", "xmonmean", "xmonavg", "xmonvar", "xmonvar1", "xmonstd", "xmonstd1"}
#define TimstatOperators {"timrange", "timmin", "timmax", "timsum", "timmean", "timavg", "timvar", "timvar1", "timstd", "timstd1"}
#define YearstatOperators {"yearrange", "yearmin", "yearmax", "yearsum", "yearmean", "yearavg", "yearvar", "yearvar1", "yearstd", "yearstd1"}
#define MonstatOperators {"monrange", "monmin", "monmax", "monsum", "monmean", "monavg", "monvar", "monvar1", "monstd", "monstd1"}
#define DaystatOperators {"dayrange", "daymin", "daymax", "daysum", "daymean", "dayavg", "dayvar", "dayvar1", "daystd", "daystd1"}
#define HourstatOperators {"hourrange", "hourmin", "hourmax", "hoursum", "hourmean", "houravg", "hourvar", "hourvar1", "hourstd", "hourstd1"}
#define TimstatOperators {"timmin", "timmax", "timsum", "timmean", "timavg", "timvar", "timvar1", "timstd", "timstd1"}
#define YearstatOperators {"yearmin", "yearmax", "yearsum", "yearmean", "yearavg", "yearvar", "yearvar1", "yearstd", "yearstd1"}
#define MonstatOperators {"monmin", "monmax", "monsum", "monmean", "monavg", "monvar", "monvar1", "monstd", "monstd1"}
#define DaystatOperators {"daymin", "daymax", "daysum", "daymean", "dayavg", "dayvar", "dayvar1", "daystd", "daystd1"}
#define HourstatOperators {"hourmin", "hourmax", "hoursum", "hourmean", "houravg", "hourvar", "hourvar1", "hourstd", "hourstd1"}
#define TimcorOperators {"timcor"}
#define TimcovarOperators {"timcovar"}
#define Timstat3Operators {"meandiff2test", "varquot2test"}
......@@ -575,655 +572,876 @@ void *Samplegrid(void *argument); // "samplegrid", "subgrid"
#define SamplegridOperators {"samplegrid", "subgrid"}
static modules_t Modules[] =
{
// stream in -1 means: unlimited number of input streams
// stream out -1 means: usage of obase
/*
function help function operator names mode number num streams
type in out
*/
{ Adisit, AdisitHelp, AdisitOperators, 1, CDI_REAL, 1, 1 },
{ Afterburner, AfterburnerHelp, AfterburnerOperators, 1, CDI_REAL, -1, 1 },
{ Arith, ArithHelp, ArithOperators, 1, CDI_REAL, 2, 1 },
{ Arithc, ArithcHelp, ArithcOperators, 1, CDI_REAL, 1, 1 },
{ Arithdays, ArithdaysHelp, ArithdaysOperators, 1, CDI_REAL, 1, 1 },
{ Arithlat, NULL, ArithlatOperators, 1, CDI_REAL, 1, 1 },
{ Cat, CopyHelp, CatOperators, 1, CDI_REAL, -1, 1 },
{ CDItest, NULL, CDItestOperators, 1, CDI_REAL, 1, 1 },
{ CDIread, NULL, CDIreadOperators, 1, CDI_REAL, 1, 0 },
{ CDIwrite, NULL, CDIwriteOperators, 1, CDI_REAL, 0, 1 },
{ Change, ChangeHelp, ChangeOperators, 1, CDI_REAL, 1, 1 },
{ Change_e5slm, NULL, Change_e5slmOperators, 0, CDI_REAL, 1, 1 },
{ Cloudlayer, NULL, CloudlayerOperators, 1, CDI_REAL, 1, 1 },
{ CMOR, NULL, CMOROperators, 1, CDI_REAL, 1, 0 },
{ CMOR_lite, CMORliteHelp, CMORliteOperators, 1, CDI_REAL, 1, 1 },
{ CMOR_table, NULL, CMORtableOperators, 1, CDI_REAL, 0, 0 },
{ Collgrid, CollgridHelp, CollgridOperators, 1, CDI_REAL, -1, 1 },
{ Command, NULL, CommandOperators, 0, CDI_REAL, 1, 0 },
{ Comp, CompHelp, CompOperators, 1, CDI_REAL, 2, 1 },
{ Compc, CompcHelp, CompcOperators, 1, CDI_REAL, 1, 1 },
{ Complextorect, NULL, ComplextorectOperators, 1, CDI_COMP, 1, 2 },
{ Cond, CondHelp, CondOperators, 1, CDI_REAL, 2, 1 },
{ Cond2, Cond2Help, Cond2Operators, 1, CDI_REAL, 3, 1 },
{ Condc, CondcHelp, CondcOperators, 1, CDI_REAL, 1, 1 },
{ Consecstat, ConsecstatHelp, ConsecstatOperators, 1, CDI_REAL, 1, 1 },
{ Copy, CopyHelp, CopyOperators, 1, CDI_REAL, -1, 1 },
{ Deltat, NULL, DeltatOperators, 1, CDI_REAL, 1, 1 },
{ Deltime, NULL, DeltimeOperators, 1, CDI_REAL, 1, 1 },
{ Derivepar, DeriveparHelp, DeriveparOperators, 1, CDI_REAL, 1, 1 },
{ Detrend, DetrendHelp, DetrendOperators, 1, CDI_REAL, 1, 1 },
{ Diff, DiffHelp, DiffOperators, 1, CDI_REAL, 2, 0 },
{ Distgrid, DistgridHelp, DistgridOperators, 1, CDI_REAL, 1, 1 },
{ Duplicate, DuplicateHelp, DuplicateOperators, 1, CDI_REAL, 1, 1 },
{ Echam5ini, NULL, Echam5iniOperators, 1, CDI_REAL, 1, 1 },
{ Enlarge, EnlargeHelp, EnlargeOperators, 1, CDI_REAL, 1, 1 },
{ Enlargegrid, NULL, EnlargegridOperators, 0, CDI_REAL, 1, 1 },
{ Ensstat, EnsstatHelp, EnsstatOperators, 1, CDI_REAL, -1, 1 },
{ Ensstat3, Ensstat2Help, Ensstat3Operators, 1, CDI_REAL, -1, 1 },
{ Ensval, EnsvalHelp, EnsvalOperators, 1, CDI_REAL, -1, 1 },
{ Eofcoeff, EofcoeffHelp, EofcoeffOperators, 1, CDI_REAL, 2, -1 },
{ Eofcoeff3d, EofcoeffHelp, Eofcoeff3dOperators, 1, CDI_REAL, 2, -1 },
{ EOFs, EOFsHelp, EOFsOperators, 1, CDI_REAL, 1, 2 },
{ EOF3d, EOFsHelp, EOF3dOperators, 1, CDI_REAL, 1, 2 },
{ Expr, ExprHelp, ExprOperators, 1, CDI_REAL, 1, 1 },
{ FC, NULL, FCOperators, 1, CDI_REAL, 1, 1 },
{ Filedes, FiledesHelp, FiledesOperators, 1, CDI_BOTH, 1, 0 },
{ Fillmiss, NULL, FillmissOperators, 1, CDI_REAL, 1, 1 },
{ Filter, FilterHelp, FilterOperators, 1, CDI_REAL, 1, 1 },
{ Fldrms, NULL, FldrmsOperators, 1, CDI_REAL, 2, 1 },
{ Fldstat, FldstatHelp, FldstatOperators, 1, CDI_REAL, 1, 1 },
{ Fldstat2, FldcorHelp, FldcorOperators, 1, CDI_REAL, 2, 1 },
{ Fldstat2, FldcovarHelp, FldcovarOperators, 1, CDI_REAL, 2, 1 },
{ Fourier, NULL, FourierOperators, 1, CDI_COMP, 1, 1 },
{ Gengrid, NULL, GengridOperators, 1, CDI_REAL, 2, 1 },
{ Gradsdes, GradsdesHelp, GradsdesOperators, 1, CDI_REAL, 1, 0 },
{ Gridboxstat, GridboxstatHelp, GridboxstatOperators, 1, CDI_REAL, 1, 1 },
{ Gridcell, GridcellHelp, GridcellOperators, 1, CDI_REAL, 1, 1 },
{ Gridsearch, NULL, GridsearchOperators, 0, CDI_REAL, 0, 0 },
{ Harmonic, NULL, HarmonicOperators, 1, CDI_REAL, 1, 1 },
{ Histogram, HistogramHelp, HistogramOperators, 1, CDI_REAL, 1, 1 },
{ Importamsr, ImportamsrHelp, ImportamsrOperators, 1, CDI_REAL, 1, 1 },
{ Importbinary, ImportbinaryHelp, ImportbinaryOperators, 1, CDI_REAL, 1, 1 },
{ Importcmsaf, ImportcmsafHelp, ImportcmsafOperators, 1, CDI_REAL, 1, 1 },
{ Importobs, NULL, ImportobsOperators, 1, CDI_REAL, 1, 1 },
{ Info, InfoHelp, InfoOperators, 1, CDI_BOTH, -1, 0 },
{ Input, InputHelp, InputOperators, 1, CDI_REAL, 0, 1 },
{ Intgrid, NULL, IntgridOperators, 1, CDI_REAL, 1, 1 },
{ Intgridtraj, NULL, IntgridtrajOperators, 1, CDI_REAL, 1, 1 },
{ Intlevel, IntlevelHelp, IntlevelOperators, 1, CDI_REAL, 1, 1 },
{ Intlevel3d, Intlevel3dHelp, Intlevel3dOperators, 1, CDI_REAL, 2, 1 },
{ Inttime, InttimeHelp, InttimeOperators, 1, CDI_REAL, 1, 1 },
{ Intntime, InttimeHelp, IntntimeOperators, 1, CDI_REAL, 1, 1 },
{ Intyear, IntyearHelp, IntyearOperators, 1, CDI_REAL, 2, -1 },
{ Invert, InvertHelp, InvertOperators, 1, CDI_REAL, 1, 1 },
{ Invertlev, InvertlevHelp, InvertlevOperators, 1, CDI_REAL, 1, 1 },
{ Isosurface, NULL, IsosurfaceOperators, 1, CDI_REAL, 1, 1 },
{ Log, NULL, LogOperators, 0, CDI_REAL, 1, 0 },
{ MapReduce, MapReduceHelp, MapReduceOperators, 1, CDI_REAL, 1, 1 },
{ Maskbox, MaskboxHelp, MaskboxOperators, 1, CDI_REAL, 1, 1 },
{ Maskbox, MaskregionHelp, MaskregionOperators, 1, CDI_REAL, 1, 1 },
{ Mastrfu, MastrfuHelp, MastrfuOperators, 1, CDI_REAL, 1, 1 },
{ Math, MathHelp, MathOperators, 1, CDI_BOTH, 1, 1 },
{ Merge, MergeHelp, MergeOperators, 1, CDI_REAL, -1, 1 },
{ Mergetime, MergeHelp, MergetimeOperators, 1, CDI_REAL, -1, 1 },
{ Mergegrid, MergegridHelp, MergegridOperators, 1, CDI_REAL, 2, 1 },
{ Merstat, MerstatHelp, MerstatOperators, 1, CDI_REAL, 1, 1 },
{ Monarith, MonarithHelp, MonarithOperators, 1, CDI_REAL, 2, 1 },
{ Mrotuv, NULL, MrotuvOperators, 1, CDI_REAL, 1, 2 },
{ Mrotuvb, NULL, MrotuvbOperators, 1, CDI_REAL, 2, 1 },
{ Ninfo, NinfoHelp, NinfoOperators, 1, CDI_BOTH, 1, 0 },
{ Nmldump, NULL, NmldumpOperators, 0, CDI_REAL, 0, 0 },
{ Output, OutputHelp, OutputOperators, 1, CDI_REAL, -1, 0 },
{ Output, OutputtabHelp, OutputtabOperators, 1, CDI_REAL, -1, 0 },
{ Outputgmt, OutputgmtHelp, OutputgmtOperators, 1, CDI_REAL, 1, 0 },
{ Pack, NULL, PackOperators, 1, CDI_REAL, 1, 1 },
{ Pardup, NULL, PardupOperators, 1, CDI_REAL, 1, 1 },
{ Pinfo, NULL, PinfoOperators, 1, CDI_REAL, 1, 1 },
{ Pressure, NULL, PressureOperators, 1, CDI_REAL, 1, 1 },
{ Regres, RegresHelp, RegresOperators, 1, CDI_REAL, 1, 1 },
{ Remap, RemapHelp, RemapOperators, 1, CDI_REAL, 1, 1 },
{ Remap, RemapbilHelp, RemapbilOperators, 1, CDI_REAL, 1, 1 },
{ Remap, RemapbicHelp, RemapbicOperators, 1, CDI_REAL, 1, 1 },
{ Remap, RemapnnHelp, RemapnnOperators, 1, CDI_REAL, 1, 1 },
{ Remap, RemapdisHelp, RemapdisOperators, 1, CDI_REAL, 1, 1 },
{ Remap, RemapyconHelp, RemapyconOperators, 1, CDI_REAL, 1, 1 },
{ Remap, RemapconHelp, RemapconOperators, 1, CDI_REAL, 1, 1 },
{ Remap, Remapcon2Help, Remapcon2Operators, 1, CDI_REAL, 1, 1 },
{ Remap, RemaplafHelp, RemaplafOperators, 1, CDI_REAL, 1, 1 },
{ Remap, NULL, RemapgridOperators, 1, CDI_REAL, 1, 1 },
{ Remapeta, RemapetaHelp, RemapetaOperators, 1, CDI_REAL, 1, 1 },
{ Replace, ReplaceHelp, ReplaceOperators, 1, CDI_REAL, 2, 1 },
{ Replacevalues, ReplacevaluesHelp, ReplacevaluesOperators, 1, CDI_REAL, 1, 1 },
{ Rhopot, RhopotHelp, RhopotOperators, 1, CDI_REAL, 1, 1 },
{ Rotuv, RotuvbHelp, RotuvOperators, 1, CDI_REAL, 1, 1 },
{ Runpctl, RunpctlHelp, RunpctlOperators, 1, CDI_REAL, 1, 1 },
{ Runstat, RunstatHelp, RunstatOperators, 1, CDI_REAL, 1, 1 },
{ Samplegridicon, NULL, SamplegridiconOperators,1, CDI_REAL, 1, 2 },
{ Seascount, NULL, SeascountOperators, 1, CDI_BOTH, 1, 1 },
{ Seaspctl, SeaspctlHelp, SeaspctlOperators, 1, CDI_REAL, 3, 1 },
{ Seasstat, SeasstatHelp, SeasstatOperators, 1, CDI_REAL, 1, 1 },
{ Selbox, SelboxHelp, SelboxOperators, 1, CDI_BOTH, 1, 1 },
{ Selgridcell, SelgridcellHelp, SelgridcellOperators, 1, CDI_BOTH, 1, 1 },
{ Select, SelectHelp, SelectOperators, 1, CDI_BOTH, -1, 1 },
{ Selvar, SelvarHelp, SelvarOperators, 1, CDI_BOTH, 1, 1 },
{ Selrec, SelvarHelp, SelrecOperators, 1, CDI_BOTH, 1, 1 },
{ Seloperator, NULL, SeloperatorOperators, 1, CDI_REAL, 1, 1 },
{ Seltime, SeltimeHelp, SeltimeOperators, 1, CDI_BOTH, 1, 1 },
{ Set, SetHelp, SetOperators, 1, CDI_BOTH, 1, 1 },
{ Setattribute, SetattributeHelp, SetattributeOperators, 1, CDI_BOTH, 1, 1 },
{ Setbox, SetboxHelp, SetboxOperators, 1, CDI_REAL, 1, 1 },
{ Setgatt, NULL, SetgattOperators, 1, CDI_BOTH, 1, 1 },
{ Setgrid, SetgridHelp, SetgridOperators, 1, CDI_BOTH, 1, 1 },
{ Sethalo, SethaloHelp, SethaloOperators, 1, CDI_REAL, 1, 1 },
{ Setmiss, SetmissHelp, SetmissOperators, 1, CDI_REAL, 1, 1 },
{ Fillmiss, SetmissHelp, SetmisstonnOperators, 1, CDI_REAL, 1, 1 },
{ Setpartab, SetHelp, SetcodetabOperators, 1, CDI_REAL, 1, 1 },
{ Setpartab, SetpartabHelp, SetpartabOperators, 1, CDI_REAL, 1, 1 },
{ Setrcaname, NULL, SetrcanameOperators, 1, CDI_REAL, 1, 1 },
{ Settime, SettimeHelp, SettimeOperators, 1, CDI_BOTH, 1, 1 },
{ Setzaxis, SetzaxisHelp, SetzaxisOperators, 1, CDI_BOTH, 1, 1 },
{ Shiftxy, ShiftxyHelp, ShiftxyOperators, 1, CDI_REAL, 1, 1 },
{ Showinfo, ShowinfoHelp, ShowinfoOperators, 1, CDI_BOTH, 1, 0 },
{ Sinfo, SinfoHelp, SinfoOperators, 1, CDI_BOTH, -1, 0 },
{ Smooth, SmoothHelp, SmoothOperators, 1, CDI_REAL, 1, 1 },
{ Sort, NULL, SortOperators, 1, CDI_REAL, 1, 1 },
{ Sorttimestamp, NULL, SorttimestampOperators, 1, CDI_REAL, -1, 1 },
{ Specinfo, NULL, SpecinfoOperators, 1, CDI_REAL, 0, 0 },
{ Spectral, SpectralHelp, SpectralOperators, 1, CDI_REAL, 1, 1 },
{ Spectrum, NULL, SpectrumOperators, 1, CDI_REAL, 1, 1 },
{ Split, SplitHelp, SplitOperators, 1, CDI_BOTH, 1, -1 },
{ Splitrec, SplitHelp, SplitrecOperators, 1, CDI_BOTH, 1, -1 },
{ Splitsel, SplitselHelp, SplitselOperators, 1, CDI_BOTH, 1, -1 },
{ Splittime, SplittimeHelp, SplittimeOperators, 1, CDI_BOTH, 1, -1 },
{ Splityear, SplittimeHelp, SplityearOperators, 1, CDI_BOTH, 1, -1 },
{ Subtrend, SubtrendHelp, SubtrendOperators, 1, CDI_REAL, 3, 1 },
{ Tee, NULL, TeeOperators, 1, CDI_REAL, 2, 1 },
{ Template1, NULL, Template1Operators, 0, CDI_REAL, 1, 1 },
{ Template2, NULL, Template2Operators, 0, CDI_REAL, 1, 1 },
{ Test, NULL, TestOperators, 0, CDI_REAL, 1, 1 },
{ Test2, NULL, Test2Operators, 0, CDI_REAL, 2, 1 },
{ Testdata, NULL, TestdataOperators, 0, CDI_REAL, 1, 1 },
{ Tests, NULL, TestsOperators, 0, CDI_REAL, 1, 1 },
{ Timcount, NULL, TimcountOperators, 1, CDI_BOTH, 1, 1 },
{ Timcount, NULL, YearcountOperators, 1, CDI_BOTH, 1, 1 },
{ Timcount, NULL, MoncountOperators, 1, CDI_BOTH, 1, 1 },
{ Timcount, NULL, DaycountOperators, 1, CDI_BOTH, 1, 1 },
{ Timcount, NULL, HourcountOperators, 1, CDI_BOTH, 1, 1 },
{ Timcumsum, TimcumsumHelp, TimcumsumOperators, 1, CDI_BOTH, 1, 1 },
{ Timpctl, TimpctlHelp, TimpctlOperators, 1, CDI_REAL, 3, 1 },
{ Timpctl, YearpctlHelp, YearpctlOperators, 1, CDI_REAL, 3, 1 },
{ Timpctl, MonpctlHelp, MonpctlOperators, 1, CDI_REAL, 3, 1 },
{ Timpctl, DaypctlHelp, DaypctlOperators, 1, CDI_REAL, 3, 1 },
{ Timpctl, HourpctlHelp, HourpctlOperators, 1, CDI_REAL, 3, 1 },
{ Timselpctl, TimselpctlHelp, TimselpctlOperators, 1, CDI_REAL, 3, 1 },
{ Timsort, TimsortHelp, TimsortOperators, 1, CDI_REAL, 1, 1 },
{ Timselstat, TimselstatHelp, TimselstatOperators, 1, CDI_REAL, 1, 1 },
{ XTimstat, NULL, XTimstatOperators, 0, CDI_BOTH, 1, 1 },
{ Timstat, TimstatHelp, TimstatOperators, 1, CDI_BOTH, 1, 1 },
{ Timstat, YearstatHelp, YearstatOperators, 1, CDI_BOTH, 1, 1 },
{ Timstat, MonstatHelp, MonstatOperators, 1, CDI_BOTH, 1, 1 },
{ Timstat, DaystatHelp, DaystatOperators, 1, CDI_BOTH, 1, 1 },
{ Timstat, HourstatHelp, HourstatOperators, 1, CDI_BOTH, 1, 1 },
{ Timstat2, TimcorHelp, TimcorOperators, 1, CDI_REAL, 2, 1 },
{ Timstat2, TimcovarHelp, TimcovarOperators, 1, CDI_REAL, 2, 1 },
{ Timstat3, NULL, Timstat3Operators, 1, CDI_REAL, 2, 1 },
{ Tinfo, NULL, TinfoOperators, 1, CDI_BOTH, 1, 0 },
{ Tocomplex, NULL, TocomplexOperators, 1, CDI_REAL, 1, 1 },
{ Transpose, NULL, TransposeOperators, 1, CDI_REAL, 1, 1 },
{ Trend, TrendHelp, TrendOperators, 1, CDI_REAL, 1, 2 },
{ Trms, NULL, TrmsOperators, 0, CDI_REAL, 2, 1 },
{ Tstepcount, NULL, TstepcountOperators, 1, CDI_REAL, 1, 1 },
{ Vargen, VargenHelp, VargenOperators, 1, CDI_REAL, 0, 1 },
{ Varrms, NULL, VarrmsOperators, 0, CDI_REAL, 2, 1 },
{ Vertintml, VertintmlHelp, VertintmlOperators, 1, CDI_REAL, 1, 1 },
{ Vertintap, VertintapHelp, VertintapOperators, 1, CDI_REAL, 1, 1 },
{ Vertstat, VertstatHelp, VertstatOperators, 1, CDI_REAL, 1, 1 },
{ Vertcum, NULL, VertcumOperators, 1, CDI_REAL, 1, 1 },
{ Vertwind, NULL, VertwindOperators, 1, CDI_REAL, 1, 1 },
{ Verifygrid, NULL, VerifygridOperators, 1, CDI_REAL, 1, 0 },
{ Wind, WindHelp, WindOperators, 1, CDI_REAL, 1, 1 },
{ Writegrid, NULL, WritegridOperators, 1, CDI_REAL, 1, 1 }, /* no cdi output */
{ Writerandom, NULL, WriterandomOperators, 1, CDI_REAL, 1, 1 },
{ YAR, NULL, YAROperators, 0, CDI_REAL, 1, 1 },
{ Yearmonstat, YearmonstatHelp, YearmonstatOperators, 1, CDI_REAL, 1, 1 },
{ Ydayarith, YdayarithHelp, YdayarithOperators, 1, CDI_REAL, 2, 1 },
{ Ydaypctl, YdaypctlHelp, YdaypctlOperators, 1, CDI_REAL, 3, 1 },
{ Ydaystat, YdaystatHelp, YdaystatOperators, 1, CDI_REAL, 1, 1 },
{ Ydrunpctl, YdrunpctlHelp, YdrunpctlOperators, 1, CDI_REAL, 3, 1 },
{ Ydrunstat, YdrunstatHelp, YdrunstatOperators, 1, CDI_REAL, 1, 1 },
{ Yhourarith, YhourarithHelp, YhourarithOperators, 1, CDI_REAL, 2, 1 },
{ Yhourstat, YhourstatHelp, YhourstatOperators, 1, CDI_REAL, 1, 1 },
{ Ymonarith, YmonarithHelp, YmonarithOperators, 1, CDI_REAL, 2, 1 },
{ Ymonarith, YseasarithHelp, YseasarithOperators, 1, CDI_REAL, 2, 1 },
{ Ymonpctl, YmonpctlHelp, YmonpctlOperators, 1, CDI_REAL, 3, 1 },
{ Ymonstat, YmonstatHelp, YmonstatOperators, 1, CDI_REAL, 1, 1 },
{ Yseaspctl, YseaspctlHelp, YseaspctlOperators, 1, CDI_REAL, 3, 1 },
{ Yseasstat, YseasstatHelp, YseasstatOperators, 1, CDI_REAL, 1, 1 },
{ Zonstat, ZonstatHelp, ZonstatOperators, 1, CDI_REAL, 1, 1 },
{ EcaCfd, EcaCfdHelp, EcaCfdOperators, 1, CDI_REAL, 1, 1 },
{ EcaCsu, EcaCsuHelp, EcaCsuOperators, 1, CDI_REAL, 1, 1 },
{ EcaCwdi, EcaCwdiHelp, EcaCwdiOperators, 1, CDI_REAL, 2, 1 },
{ EcaCwfi, EcaCwfiHelp, EcaCwfiOperators, 1, CDI_REAL, 2, 1 },
{ EcaEtr, EcaEtrHelp, EcaEtrOperators, 1, CDI_REAL, 2, 1 },
{ EcaFd, EcaFdHelp, EcaFdOperators, 1, CDI_REAL, 1, 1 },
{ EcaGsl, EcaGslHelp, EcaGslOperators, 1, CDI_REAL, 2, 1 },
{ EcaHd, EcaHdHelp, EcaHdOperators, 1, CDI_REAL, 1, 1 },
{ EcaHwdi, EcaHwdiHelp, EcaHwdiOperators, 1, CDI_REAL, 2, 1 },
{ EcaHwfi, EcaHwfiHelp, EcaHwfiOperators, 1, CDI_REAL, 2, 1 },
{ EcaId, EcaIdHelp, EcaIdOperators, 1, CDI_REAL, 1, 1 },
{ EcaSu, EcaSuHelp, EcaSuOperators, 1, CDI_REAL, 1, 1 },
{ EcaTr, EcaTrHelp, EcaTrOperators, 1, CDI_REAL, 1, 1 },
{ EcaTg10p, EcaTg10pHelp, EcaTg10pOperators, 1, CDI_REAL, 2, 1 },
{ EcaTg90p, EcaTg90pHelp, EcaTg90pOperators, 1, CDI_REAL, 2, 1 },
{ EcaTn10p, EcaTn10pHelp, EcaTn10pOperators, 1, CDI_REAL, 2, 1 },
{ EcaTn90p, EcaTn90pHelp, EcaTn90pOperators, 1, CDI_REAL, 2, 1 },
{ EcaTx10p, EcaTx10pHelp, EcaTx10pOperators, 1, CDI_REAL, 2, 1 },
{ EcaTx90p, EcaTx90pHelp, EcaTx90pOperators, 1, CDI_REAL, 2, 1 },
{ EcaCdd, EcaCddHelp, EcaCddOperators, 1, CDI_REAL, 1, 1 },
{ EcaCwd, EcaCwdHelp, EcaCwdOperators, 1, CDI_REAL, 1, 1 },
{ EcaRr1, EcaRr1Help, EcaRr1Operators, 1, CDI_REAL, 1, 1 },
{ EcaPd, EcaPdHelp, EcaPdOperators, 1, CDI_REAL, 1, 1 },
{ EcaR75p, EcaR75pHelp, EcaR75pOperators, 1, CDI_REAL, 2, 1 },
{ EcaR75ptot, EcaR75ptotHelp, EcaR75ptotOperators, 1, CDI_REAL, 2, 1 },
{ EcaR90p, EcaR90pHelp, EcaR90pOperators, 1, CDI_REAL, 2, 1 },
{ EcaR90ptot, EcaR90ptotHelp, EcaR90ptotOperators, 1, CDI_REAL, 2, 1 },
{ EcaR95p, EcaR95pHelp, EcaR95pOperators, 1, CDI_REAL, 2, 1 },
{ EcaR95ptot, EcaR95ptotHelp, EcaR95ptotOperators, 1, CDI_REAL, 2, 1 },
{ EcaR99p, EcaR99pHelp, EcaR99pOperators, 1, CDI_REAL, 2, 1 },
{ EcaR99ptot, EcaR99ptotHelp, EcaR99ptotOperators, 1, CDI_REAL, 2, 1 },
{ EcaRx1day, EcaRx1dayHelp, EcaRx1dayOperators, 1, CDI_REAL, 1, 1 },
{ EcaRx5day, EcaRx5dayHelp, EcaRx5dayOperators, 1, CDI_REAL, 1, 1 },
{ EcaSdii, EcaSdiiHelp, EcaSdiiOperators, 1, CDI_REAL, 1, 1 },
{ Fdns, FdnsHelp, FdnsOperators, 1, CDI_REAL, 2, 1 },
{ Strwin, StrwinHelp, StrwinOperators, 1, CDI_REAL, 1, 1 },
{ Strbre, StrbreHelp, StrbreOperators, 1, CDI_REAL, 1, 1 },
{ Strgal, StrgalHelp, StrgalOperators, 1, CDI_REAL, 1, 1 },
{ Hurr, HurrHelp, HurrOperators, 1, CDI_REAL, 1, 1 },
/* { Hi, NULL, HiOperators, 1, CDI_REAL, 3, 1 }, */
{ Wct, WctHelp, WctOperators, 1, CDI_REAL, 2, 1 },
{ Magplot, MagplotHelp, MagplotOperators, 1, CDI_REAL, 1, 1 },
{ Magvector, MagvectorHelp, MagvectorOperators, 1, CDI_REAL, 1, 1 },
{ Maggraph, MaggraphHelp, MaggraphOperators, 1, CDI_REAL, -1, 1 },
// HIRLAM_EXTENSIONS
{ Samplegrid, SamplegridHelp, SamplegridOperators, 1, CDI_REAL, 1, 1 },
{ Selmulti, SelmultiHelp, SelmultiOperators, 1, CDI_REAL, 1, 1 },
{ WindTrans, WindTransHelp, WindTransOperators, 1, CDI_REAL, 1, 1 },
};
static int NumModules = sizeof(Modules) / sizeof(Modules[0]);
static const char *opalias[][2] =
{
{"afterburner", "after"},
{"anomaly", "ymonsub"},
{"deltap_fl", "deltap"},
{"diffv", "diffn"},
{"covar0", "timcovar"},
{"covar0r", "fldcovar"},
{"gather", "collgrid"},
{"geopotheight", "gheight"},
{"globavg", "fldavg"},
{"import_grads", "import_binary"},
{"infos", "sinfo"},
{"infov", "infon"},
{"intgrid", "intgridbil"},
{"log", "ln"},
{"lmean", "ymonmean"},
{"lmmean", "ymonmean"},
{"lmavg", "ymonavg"},
{"lmstd", "ymonstd"},
{"lsmean", "yseasmean"},
{"chvar", "chname"},
{"ncode", "npar"},
{"nvar", "npar"},
{"outputkey", "outputtab"},
{"vardes", "codetab"},
{"pardes", "codetab"},
{"selvar", "selname"},
{"delvar", "delname"},
{"remapcon1", "remaplaf"},
{"remapdis1", "remapnn"},
{"scatter", "distgrid"},
{"showvar", "showname"},
{"selgridname", "selgrid"},
{"setvar", "setname"},
{"setpartabv", "setpartabn"},
{"setpartab", "setcodetab"},
{"sinfov", "sinfon"},
{"sortvar", "sortname"},
{"splitvar", "splitname"},
{"sort", "timsort"},
{"eca_r1mm", "eca_rr1"},
{"fpressure", "pressure_fl"},
{"hpressure", "pressure_hl"},
{"ensrkhist_space", "ensrkhistspace"},
{"ensrkhist_time", "ensrkhisttime"},
{"gridverify", "verifygrid"},
{"outputcenter", "gmtxyz"},
{"outputbounds", "gmtcells"},
{"selseas", "selseason"},
{"selmon", "selmonth"},
{"selindex", "selgridcell"},
{"delindex", "delgridcell"},
};
static int nopalias = sizeof(opalias) / (2*sizeof(opalias[0][0]));
static
bool similar(const char *a, const char *b, int alen, int blen)
{
if ( alen > 2 && blen > 2 && strstr(b, a) )
return true;
while ( *a && *b && *a == *b )
{
a++;
b++;
/* clang-format on */
/* \endcond */