Commit 276c2604 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

New operator: int and nint (Math)

parent 47cc9f6f
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* using CDI library version 1.0.2 * using CDI library version 1.0.2
* set alias gradsdes to gradsdes2 * set alias gradsdes to gradsdes2
* rename gradsdes to gradsdes1 * rename gradsdes to gradsdes1
* New operator: int and nint (Math) [request: Joerg Wegner]
* add option -e exp to test DRMAA * add option -e exp to test DRMAA
* add option -z szip to compress GRIB records with SZIP * add option -z szip to compress GRIB records with SZIP
* use DBL_IS_EQUAL to compare floating point * use DBL_IS_EQUAL to compare floating point
......
No preview for this file type
...@@ -10,8 +10,9 @@ ...@@ -10,8 +10,9 @@
Creates a GrADS data descriptor file. Supported file formats are GRIB, Creates a GrADS data descriptor file. Supported file formats are GRIB,
SERVICE, EXTRA and IEG. For GRIB files the GrADS map file is also SERVICE, EXTRA and IEG. For GRIB files the GrADS map file is also
generated. For SERVICE and EXTRA files the grid must be specified with generated. For SERVICE and EXTRA files the grid must be specified with
the CDO option '-g <grid>'. This operator takes @file{ifile} in order to create the CDO option '-g <grid>'. This module takes @file{ifile} in order to create
filenames for the descriptor (@file{ifile.ctl}) and the map (@file{ifile.gmp}) file. filenames for the descriptor (@file{ifile.ctl}) and the map (@file{ifile.gmp}) file.
"gradsdes" is an alias for @oper{gradsdes2}.
@EndDescription @EndDescription
@EndModule @EndModule
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
@Section = Arithmetic @Section = Arithmetic
@Class = Arithmetic @Class = Arithmetic
@Arguments = ifile ofile @Arguments = ifile ofile
@Operators = abs sqr sqrt exp ln log10 sin cos tan asin acos atan @Operators = abs int nint sqr sqrt exp ln log10 sin cos tan asin acos atan
@BeginDescription @BeginDescription
This module contains some standard mathematical functions. This module contains some standard mathematical functions.
...@@ -31,6 +31,40 @@ o(t,x) = \mbox{abs}(i(t,x)) ...@@ -31,6 +31,40 @@ o(t,x) = \mbox{abs}(i(t,x))
@EndOperator @EndOperator
@BeginOperator_int
@Title = Integer value
@BeginDescription
@IfMan
o(t,x) = int(i(t,x))
@EndifMan
@IfDoc
@BeginMath
o(t,x) = \mbox{int}(i(t,x))
@EndMath
@EndifDoc
@C Convert to integer value of i(t,x).
@EndDescription
@EndOperator
@BeginOperator_nint
@Title = Nearest integer value
@BeginDescription
@IfMan
o(t,x) = nint(i(t,x))
@EndifMan
@IfDoc
@BeginMath
o(t,x) = \mbox{nint}(i(t,x))
@EndMath
@EndifDoc
@C Evaluate the nearest integer value of i(t,x).
@EndDescription
@EndOperator
@BeginOperator_sqr @BeginOperator_sqr
@Title = Square @Title = Square
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
void *Math(void *argument) void *Math(void *argument)
{ {
static char func[] = "Math"; static char func[] = "Math";
enum {ABS, SQR, SQRT, EXP, LN, LOG10, SIN, COS, TAN, ASIN, ACOS, ATAN}; enum {ABS, FINT, FNINT, SQR, SQRT, EXP, LN, LOG10, SIN, COS, TAN, ASIN, ACOS, ATAN};
int operatorID; int operatorID;
int operfunc; int operfunc;
int streamID1, streamID2; int streamID1, streamID2;
...@@ -60,10 +60,12 @@ void *Math(void *argument) ...@@ -60,10 +60,12 @@ void *Math(void *argument)
cdoInitialize(argument); cdoInitialize(argument);
cdoOperatorAdd("abs", ABS, 0, NULL); cdoOperatorAdd("abs", ABS, 0, NULL);
cdoOperatorAdd("int", FINT, 0, NULL);
cdoOperatorAdd("nint", FNINT, 0, NULL);
cdoOperatorAdd("sqr", SQR, 0, NULL); cdoOperatorAdd("sqr", SQR, 0, NULL);
cdoOperatorAdd("sqrt", SQRT, 0, NULL); cdoOperatorAdd("sqrt", SQRT, 0, NULL);
cdoOperatorAdd("exp", EXP, 0, NULL); cdoOperatorAdd("exp", EXP, 0, NULL);
cdoOperatorAdd("ln", LN, 0, NULL); cdoOperatorAdd("ln", LN, 0, NULL);
cdoOperatorAdd("log10", LOG10, 0, NULL); cdoOperatorAdd("log10", LOG10, 0, NULL);
cdoOperatorAdd("sin", SIN, 0, NULL); cdoOperatorAdd("sin", SIN, 0, NULL);
cdoOperatorAdd("cos", COS, 0, NULL); cdoOperatorAdd("cos", COS, 0, NULL);
...@@ -119,6 +121,14 @@ void *Math(void *argument) ...@@ -119,6 +121,14 @@ void *Math(void *argument)
for ( i = 0; i < gridsize; i++ ) for ( i = 0; i < gridsize; i++ )
array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : fabs(array1[i]); array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : fabs(array1[i]);
break; break;
case FINT:
for ( i = 0; i < gridsize; i++ )
array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : (int)(array1[i]);
break;
case FNINT:
for ( i = 0; i < gridsize; i++ )
array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : NINT(array1[i]);
break;
case SQR: case SQR:
for ( i = 0; i < gridsize; i++ ) for ( i = 0; i < gridsize; i++ )
array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : MUL(array1[i], array1[i]); array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : MUL(array1[i], array1[i]);
......
...@@ -166,7 +166,7 @@ void *Zonstat(void *argument); ...@@ -166,7 +166,7 @@ void *Zonstat(void *argument);
"invertlatdata", "invertlondata"} "invertlatdata", "invertlondata"}
#define MaskboxOperators {"masklonlatbox", "maskindexbox"} #define MaskboxOperators {"masklonlatbox", "maskindexbox"}
#define MastrfuOperators {"mastrfu"} #define MastrfuOperators {"mastrfu"}
#define MathOperators {"abs", "sqr", "sqrt", "exp", "ln", "log10", "sin", "cos", "tan", "asin", "acos", "atan"} #define MathOperators {"abs", "int", "nint", "sqr", "sqrt", "exp", "ln", "log10", "sin", "cos", "tan", "asin", "acos", "atan"}
#define MergeOperators {"merge"} #define MergeOperators {"merge"}
#define MergegridOperators {"mergegrid"} #define MergegridOperators {"mergegrid"}
#define MergetimeOperators {"mergetime"} #define MergetimeOperators {"mergetime"}
......
...@@ -685,11 +685,11 @@ static char *SettimeHelp[] = { ...@@ -685,11 +685,11 @@ static char *SettimeHelp[] = {
" day INTEGER Value of the new day", " day INTEGER Value of the new day",
" month INTEGER Value of the new month", " month INTEGER Value of the new month",
" year INTEGER Value of the new year", " year INTEGER Value of the new year",
" units STRING Base units of the time axis (minutes, hours, days, months, years).", " units STRING Base units of the time axis (minutes, hours, days, months, years).",
" date STRING Date (format YYYY-MM-DD)", " date STRING Date (format YYYY-MM-DD)",
" time STRING Time (format HH:MM)", " time STRING Time (format HH:MM)",
" inc STRING Optional increment (e.g. 12hour) [default: 0hour]", " inc STRING Optional increment (e.g. 12hour) [default: 0hour]",
" calendar STRING Calendar (standard, 360days, 365days, 366days)", " calendar STRING Calendar (standard, 360days, 365days, 366days)",
" sval STRING Shift value (e.g. -3hour)", " sval STRING Shift value (e.g. -3hour)",
NULL NULL
}; };
...@@ -996,7 +996,7 @@ static char *ExprHelp[] = { ...@@ -996,7 +996,7 @@ static char *ExprHelp[] = {
static char *MathHelp[] = { static char *MathHelp[] = {
"NAME", "NAME",
" abs, sqr, sqrt, exp, ln, log10, sin, cos, tan, asin, acos, atan - ", " abs, int, nint, sqr, sqrt, exp, ln, log10, sin, cos, tan, asin, acos, atan - ",
" Mathematical functions", " Mathematical functions",
"", "",
"SYNOPSIS", "SYNOPSIS",
...@@ -1009,6 +1009,10 @@ static char *MathHelp[] = { ...@@ -1009,6 +1009,10 @@ static char *MathHelp[] = {
"OPERATORS", "OPERATORS",
" abs Absolute value", " abs Absolute value",
" o(t,x) = abs(i(t,x))", " o(t,x) = abs(i(t,x))",
" int Integer value",
" o(t,x) = int(i(t,x))",
" nint Nearest integer value",
" o(t,x) = nint(i(t,x))",
" sqr Square", " sqr Square",
" o(t,x) = i(t,x)**2", " o(t,x) = i(t,x)**2",
" sqrt Square root", " sqrt Square root",
...@@ -2222,7 +2226,7 @@ static char *VardupHelp[] = { ...@@ -2222,7 +2226,7 @@ static char *VardupHelp[] = {
static char *GradsdesHelp[] = { static char *GradsdesHelp[] = {
"NAME", "NAME",
" gradsdes, gradsdes2 - GrADS data descriptor file", " gradsdes1, gradsdes2 - GrADS data descriptor file",
"", "",
"SYNOPSIS", "SYNOPSIS",
" <operator> ifile", " <operator> ifile",
...@@ -2231,14 +2235,15 @@ static char *GradsdesHelp[] = { ...@@ -2231,14 +2235,15 @@ static char *GradsdesHelp[] = {
" Creates a GrADS data descriptor file. Supported file formats are GRIB,", " Creates a GrADS data descriptor file. Supported file formats are GRIB,",
" SERVICE, EXTRA and IEG. For GRIB files the GrADS map file is also ", " SERVICE, EXTRA and IEG. For GRIB files the GrADS map file is also ",
" generated. For SERVICE and EXTRA files the grid must be specified with", " generated. For SERVICE and EXTRA files the grid must be specified with",
" the CDO option '-g <grid>'. This operator takes ifile in order to create ", " the CDO option '-g <grid>'. This module takes ifile in order to create ",
" filenames for the descriptor (ifile.ctl) and the map (ifile.gmp) file.", " filenames for the descriptor (ifile.ctl) and the map (ifile.gmp) file.",
" \"gradsdes\" is an alias for gradsdes2.",
"", "",
"OPERATORS", "OPERATORS",
" gradsdes GrADS data descriptor file", " gradsdes1 GrADS data descriptor file (version 1 GRIB map)",
" Creates a GrADS data descriptor file. Generated a machine", " Creates a GrADS data descriptor file. Generated a machine",
" specific version 1 GrADS map file for GRIB datasets.", " specific version 1 GrADS map file for GRIB datasets.",
" gradsdes2 GrADS data descriptor file (version 2 map)", " gradsdes2 GrADS data descriptor file (version 2 GRIB map)",
" Creates a GrADS data descriptor file. Generated a machine ", " Creates a GrADS data descriptor file. Generated a machine ",
" independent version 2 GrADS map file for GRIB datasets.", " independent version 2 GrADS map file for GRIB datasets.",
" This map file can be used only with GrADS version 1.8 or newer. ", " This map file can be used only with GrADS version 1.8 or newer. ",
......
Supports Markdown
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