Commit 9f9156b9 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

extRead: bug fix for complex numbers with missing values

parent 96e7f4bc
......@@ -183,9 +183,6 @@ void printInfo(int gridtype, int vdate, int vtime, char *varname, double level,
if ( datasize > 0 ) arrmean /= datasize;
fprintf(stdout, "%#12.5g%#12.5g%#12.5g\n", arrmin, arrmean, arrmax);
if ( imiss != nmiss && nmiss > 0 )
fprintf(stdout, "Found %d of %d missing values!\n", imiss, nmiss);
}
else
{
......@@ -208,10 +205,15 @@ void printInfo(int gridtype, int vdate, int vtime, char *varname, double level,
}
}
imiss = datasize - nvals_r;
if ( nvals_r > 0 ) arrmean_r = arrsum_r / nvals_r;
if ( nvals_i > 0 ) arrmean_i = arrsum_i / nvals_i;
fprintf(stdout, " - (%#12.5g,%#12.5g) -\n", arrmean_r, arrmean_i);
}
if ( imiss != nmiss && nmiss > 0 )
fprintf(stdout, "Found %d of %d missing values!\n", imiss, nmiss);
}
......
......@@ -155,12 +155,24 @@ int extReadRecord(int streamID, double *data, int *nmiss)
streamptr->numvals += size;
*nmiss = 0;
for ( i = 0; i < size; i++ )
if ( DBL_IS_EQUAL(data[i], missval) || DBL_IS_EQUAL(data[i], (float)missval) )
{
data[i] = missval;
(*nmiss)++;
}
if ( vlistInqVarNumber(vlistID, varID) == CDI_REAL )
{
for ( i = 0; i < size; i++ )
if ( DBL_IS_EQUAL(data[i], missval) || DBL_IS_EQUAL(data[i], (float)missval) )
{
data[i] = missval;
(*nmiss)++;
}
}
else
{
for ( i = 0; i < 2*size; i+=2 )
if ( DBL_IS_EQUAL(data[i], missval) || DBL_IS_EQUAL(data[i], (float)missval) )
{
data[i] = missval;
(*nmiss)++;
}
}
return (1);
}
......@@ -889,12 +901,24 @@ void extReadVarDP(int streamID, int varID, double *data, int *nmiss)
fileSetPos(fileID, currentfilepos, SEEK_SET);
*nmiss = 0;
for ( i = 0; i < nlevs*gridsize; i++ )
if ( DBL_IS_EQUAL(data[i], missval) || DBL_IS_EQUAL(data[i], (float)missval) )
{
data[i] = missval;
(*nmiss)++;
}
if ( vlistInqVarNumber(vlistID, varID) == CDI_REAL )
{
for ( i = 0; i < nlevs*gridsize; i++ )
if ( DBL_IS_EQUAL(data[i], missval) || DBL_IS_EQUAL(data[i], (float)missval) )
{
data[i] = missval;
(*nmiss)++;
}
}
else
{
for ( i = 0; i < 2*nlevs*gridsize; i+=2 )
if ( DBL_IS_EQUAL(data[i], missval) || DBL_IS_EQUAL(data[i], (float)missval) )
{
data[i] = missval;
(*nmiss)++;
}
}
}
......@@ -940,12 +964,24 @@ void extReadVarSliceDP(int streamID, int varID, int levID, double *data, int *nm
fileSetPos(fileID, currentfilepos, SEEK_SET);
*nmiss = 0;
for ( i = 0; i < gridsize; i++ )
if ( DBL_IS_EQUAL(data[i], missval) || DBL_IS_EQUAL(data[i], (float)missval) )
{
data[i] = missval;
(*nmiss)++;
}
if ( vlistInqVarNumber(vlistID, varID) == CDI_REAL )
{
for ( i = 0; i < gridsize; i++ )
if ( DBL_IS_EQUAL(data[i], missval) || DBL_IS_EQUAL(data[i], (float)missval) )
{
data[i] = missval;
(*nmiss)++;
}
}
else
{
for ( i = 0; i < 2*gridsize; i+=2 )
if ( DBL_IS_EQUAL(data[i], missval) || DBL_IS_EQUAL(data[i], (float)missval) )
{
data[i] = missval;
(*nmiss)++;
}
}
}
......
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