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

New operator: int and nint (Math)

parent 47cc9f6f
......@@ -4,6 +4,7 @@
* using CDI library version 1.0.2
* set alias gradsdes to gradsdes2
* rename gradsdes to gradsdes1
* New operator: int and nint (Math) [request: Joerg Wegner]
* add option -e exp to test DRMAA
* add option -z szip to compress GRIB records with SZIP
* use DBL_IS_EQUAL to compare floating point
......
No preview for this file type
......@@ -10,8 +10,9 @@
Creates a GrADS data descriptor file. Supported file formats are GRIB,
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
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.
"gradsdes" is an alias for @oper{gradsdes2}.
@EndDescription
@EndModule
......
......@@ -5,7 +5,7 @@
@Section = Arithmetic
@Class = Arithmetic
@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
This module contains some standard mathematical functions.
......@@ -31,6 +31,40 @@ o(t,x) = \mbox{abs}(i(t,x))
@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
@Title = Square
......
......@@ -42,7 +42,7 @@
void *Math(void *argument)
{
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 operfunc;
int streamID1, streamID2;
......@@ -60,6 +60,8 @@ void *Math(void *argument)
cdoInitialize(argument);
cdoOperatorAdd("abs", ABS, 0, NULL);
cdoOperatorAdd("int", FINT, 0, NULL);
cdoOperatorAdd("nint", FNINT, 0, NULL);
cdoOperatorAdd("sqr", SQR, 0, NULL);
cdoOperatorAdd("sqrt", SQRT, 0, NULL);
cdoOperatorAdd("exp", EXP, 0, NULL);
......@@ -119,6 +121,14 @@ void *Math(void *argument)
for ( i = 0; i < gridsize; i++ )
array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : fabs(array1[i]);
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:
for ( i = 0; i < gridsize; i++ )
array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : MUL(array1[i], array1[i]);
......
......@@ -166,7 +166,7 @@ void *Zonstat(void *argument);
"invertlatdata", "invertlondata"}
#define MaskboxOperators {"masklonlatbox", "maskindexbox"}
#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 MergegridOperators {"mergegrid"}
#define MergetimeOperators {"mergetime"}
......
......@@ -996,7 +996,7 @@ static char *ExprHelp[] = {
static char *MathHelp[] = {
"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",
"",
"SYNOPSIS",
......@@ -1009,6 +1009,10 @@ static char *MathHelp[] = {
"OPERATORS",
" abs Absolute value",
" 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",
" o(t,x) = i(t,x)**2",
" sqrt Square root",
......@@ -2222,7 +2226,7 @@ static char *VardupHelp[] = {
static char *GradsdesHelp[] = {
"NAME",
" gradsdes, gradsdes2 - GrADS data descriptor file",
" gradsdes1, gradsdes2 - GrADS data descriptor file",
"",
"SYNOPSIS",
" <operator> ifile",
......@@ -2231,14 +2235,15 @@ static char *GradsdesHelp[] = {
" Creates a GrADS data descriptor file. Supported file formats are GRIB,",
" 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",
" 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.",
" \"gradsdes\" is an alias for gradsdes2.",
"",
"OPERATORS",
" gradsdes GrADS data descriptor file",
" gradsdes1 GrADS data descriptor file (version 1 GRIB map)",
" Creates a GrADS data descriptor file. Generated a machine",
" 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 ",
" independent version 2 GrADS map file for GRIB datasets.",
" 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