Commit 0916fba1 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added operator setmiss.

parent 9fca3f4f
2017-10-27 Uwe Schulzweida
2017-10-05 Uwe Schulzweida
* Using CDI library version 1.9.1
* Version 1.9.1 release
2017-10-04 Uwe Schulzweida
* Added operator setmiss
2017-09-30 Uwe Schulzweida
* sinfo: Added time type
......
......@@ -50,13 +50,14 @@ void *Arith(void *argument)
cdoInitialize(argument);
// clang-format off
cdoOperatorAdd("add", func_add, 0, NULL);
cdoOperatorAdd("sub", func_sub, 0, NULL);
cdoOperatorAdd("mul", func_mul, 0, NULL);
cdoOperatorAdd("div", func_div, 0, NULL);
cdoOperatorAdd("min", func_min, 0, NULL);
cdoOperatorAdd("max", func_max, 0, NULL);
cdoOperatorAdd("atan2", func_atan2, 0, NULL);
cdoOperatorAdd("add", func_add, 0, NULL);
cdoOperatorAdd("sub", func_sub, 0, NULL);
cdoOperatorAdd("mul", func_mul, 0, NULL);
cdoOperatorAdd("div", func_div, 0, NULL);
cdoOperatorAdd("min", func_min, 0, NULL);
cdoOperatorAdd("max", func_max, 0, NULL);
cdoOperatorAdd("atan2", func_atan2, 0, NULL);
cdoOperatorAdd("setmiss", func_setmiss, 0, NULL);
// clang-format on
int operatorID = cdoOperatorID();
......
......@@ -963,7 +963,6 @@ void *Gradsdes(void *argument)
int idmn, idhh, idmm, idyy, iddd;
int dt=1, iik=0, mdt = 0;
int gridsize = 0;
long checksize = 0;
int nmiss;
int prec;
int map_version = 2;
......@@ -1321,7 +1320,7 @@ void *Gradsdes(void *argument)
if ( map_version != 4 )
{
checksize = (long)bignum[index*2] + (long)gridsize*intnum[index]/8;
long checksize = (long)bignum[index*2] + (long)gridsize*intnum[index]/8;
if ( checksize < 0L || checksize > 2147483647L )
{
nrecords -= nrecsout;
......
......@@ -212,6 +212,7 @@ void farcstd(field_type *field1, field_type field2, int nsets, int divisor);
void farmoq(field_type *field1, field_type field2);
void farmoqw(field_type *field1, field_type field2, double w);
void faratan2(field_type *field1, field_type field2);
void farsetmiss(field_type *field1, field_type field2);
void farcount(field_type *field1, field_type field2);
......
......@@ -22,20 +22,23 @@
void farfun(field_type *field1, field_type field2, int function)
{
// clang-format off
switch (function)
{
case func_add: faradd(field1, field2); break;
case func_min: farmin(field1, field2); break;
case func_max: farmax(field1, field2); break;
case func_sum: farsum(field1, field2); break;
case func_mean: farsum(field1, field2); break;
case func_avg: faradd(field1, field2); break;
case func_sub: farsub(field1, field2); break;
case func_mul: farmul(field1, field2); break;
case func_div: fardiv(field1, field2); break;
case func_atan2: faratan2(field1, field2); break;
case func_add: faradd(field1, field2); break;
case func_min: farmin(field1, field2); break;
case func_max: farmax(field1, field2); break;
case func_sum: farsum(field1, field2); break;
case func_mean: farsum(field1, field2); break;
case func_avg: faradd(field1, field2); break;
case func_sub: farsub(field1, field2); break;
case func_mul: farmul(field1, field2); break;
case func_div: fardiv(field1, field2); break;
case func_atan2: faratan2(field1, field2); break;
case func_setmiss: farsetmiss(field1, field2); break;
default: cdoAbort("%s: function %d not implemented!", __func__, function);
}
// clang-format on
}
static
......@@ -426,7 +429,6 @@ void farmul(field_type *field1, field_type field2)
if ( nwpv != 2 ) nwpv = 1;
int len = nwpv*gridInqSize(grid1);
if ( len != (nwpv*gridInqSize(grid2)) )
cdoAbort("Fields have different gridsize (%s)", __func__);
......@@ -460,7 +462,6 @@ void fardiv(field_type *field1, field_type field2)
if ( nwpv != 2 ) nwpv = 1;
int len = nwpv*gridInqSize(grid1);
if ( len != (nwpv*gridInqSize(grid2)) )
cdoAbort("Fields have different gridsize (%s)", __func__);
......@@ -499,6 +500,35 @@ void faratan2(field_type *field1, field_type field2)
}
void farsetmiss(field_type *field1, field_type field2)
{
int nwpv = field1->nwpv;
int grid1 = field1->grid;
int grid2 = field2.grid;
int nmiss1 = field1->nmiss;
double missval1 = field1->missval;
double missval2 = field2.missval;
double *restrict array1 = field1->ptr;
const double *restrict array2 = field2.ptr;
if ( nwpv != 2 ) nwpv = 1;
int len = nwpv*gridInqSize(grid1);
if ( len != (nwpv*gridInqSize(grid2)) )
cdoAbort("Fields have different gridsize (%s)", __func__);
if ( nmiss1 )
{
for ( int i = 0; i < len; i++ )
array1[i] = DBL_IS_EQUAL(array1[i],missval1) ? array2[i] : array1[i];
field1->nmiss = 0;
for ( int i = 0; i < len; i++ )
if ( DBL_IS_EQUAL(array1[i], missval1) ) field1->nmiss++;
}
}
void farmin(field_type *field1, field_type field2)
{
int nwpv = field1->nwpv;
......
......@@ -37,6 +37,7 @@
#define func_mod 45
#define func_atan2 50
#define func_setmiss 51
#define func_read 60
#define func_write 61
......
......@@ -286,7 +286,7 @@ 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"}
#define ArithOperators {"add", "sub", "mul", "div", "min", "max", "atan2", "setmiss"}
#define ArithcOperators {"addc", "subc", "mulc", "divc", "mod"}
#define ArithdaysOperators {"muldpm", "divdpm", "muldpy", "divdpy", "muldoy"}
#define ArithlatOperators {"mulcoslat", "divcoslat"}
......
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