Commit 885d419e authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Replaced arrayNumMV() by numMissUpdate().

parent 3ce0ee4d
......@@ -132,8 +132,8 @@ Arithc(void *process)
{
const int nwpv = vlistInqNWPV(vlistID1, varID);
const int gridID = vlistInqVarGrid(vlistID1, varID);
const size_t gridsize = nwpv * gridInqSize(gridID);
field.grid = gridID;
field.size = nwpv * gridInqSize(gridID);
field.missval = vlistInqVarMissval(vlistID1, varID);
if (nwpv == 2)
......@@ -142,7 +142,7 @@ Arithc(void *process)
vfarcfun(field, rconst, operfunc);
// recalculate number of missing values
field.nmiss = arrayNumMV(gridsize, field.vec.data(), field.missval);
field.numMissUpdate();
}
cdoDefRecord(streamID2, varID, levelID);
......
......@@ -25,7 +25,6 @@
#include "cdo_int.h"
#include "param_conversion.h"
#include "cdo_wtime.h"
#include <mpim_grid.h>
#include "gridreference.h"
#include "grid_point_search.h"
......@@ -603,15 +602,16 @@ Fillmiss(void *process)
cdoAbort("%s data unsupported!", gridNamePtr(gridInqType(gridID)));
field1.grid = gridID;
field1.size = gridInqSize(field1.grid);
field1.missval = vlistInqVarMissval(vlistID1, varID);
field2.grid = field1.grid;
field2.size = field1.size;
field2.missval = field1.missval;
fill_method(field1, field2, nfill);
const size_t gridsize = gridInqSize(field2.grid);
field2.nmiss = arrayNumMV(gridsize, field2.vec.data(), field2.missval);
field2.numMissUpdate();
cdoWriteRecord(streamID2, field2.vec.data(), field2.nmiss);
}
}
......
......@@ -456,7 +456,6 @@ gridboxstat(const Field &field1, Field &field2, const size_t xinc, const size_t
const int gridID1 = field1.grid;
const int gridID2 = field2.grid;
const double missval = field1.missval;
const size_t nlon1 = gridInqXsize(gridID1);
const size_t nlat1 = gridInqYsize(gridID1);
......@@ -496,7 +495,7 @@ gridboxstat(const Field &field1, Field &field2, const size_t xinc, const size_t
field2.vec[ig] = vfldfun(field[ompthID], statfunc);
}
field2.nmiss = arrayNumMV(nlat2 * nlon2, field2.vec.data(), missval);
field2.numMissUpdate();
}
void *
......
......@@ -51,20 +51,16 @@ static void
farexpr(Field &field1, const Field &field2, const Field &field3, double (*expression)(double, double, double, double))
{
const int grid1 = field1.grid;
const size_t nmiss1 = field1.nmiss;
const double missval1 = field1.missval;
const int grid2 = field2.grid;
const size_t nmiss2 = field2.nmiss;
const double missval2 = field2.missval;
const int grid3 = field3.grid;
const size_t nmiss3 = field3.nmiss;
const double missval3 = field3.missval;
const size_t len = gridInqSize(grid1);
if (len != gridInqSize(grid2) || len != gridInqSize(grid3)) cdoAbort("Fields have different gridsize (%s)", __func__);
if (nmiss1 || nmiss2 || nmiss3)
if (field1.nmiss || field2.nmiss || field3.nmiss)
{
for (size_t i = 0; i < len; i++)
if (DBL_IS_EQUAL(field1.vec[i], missval1) || DBL_IS_EQUAL(field2.vec[i], missval2) || DBL_IS_EQUAL(field3.vec[i], missval3))
......@@ -77,7 +73,7 @@ farexpr(Field &field1, const Field &field2, const Field &field3, double (*expres
for (size_t i = 0; i < len; i++) field1.vec[i] = expression(field1.vec[i], field2.vec[i], field3.vec[i], missval1);
}
field1.nmiss = arrayNumMV(len, field1.vec.data(), missval1);
field1.numMissUpdate();
}
void *
......
......@@ -121,6 +121,10 @@ Regres(void *process)
const double missval = varList[varID].missval;
const double missval1 = missval;
const double missval2 = missval;
field1.size = gridsize;
field1.missval = missval;
field2.size = gridsize;
field2.missval = missval;
double temp1, temp2;
for (size_t i = 0; i < gridsize; i++)
......@@ -135,9 +139,9 @@ Regres(void *process)
MULMN(DIVMN(work[0][varID][levelID].vec[i], work[4][varID][levelID].vec[i]), field2.vec[i]));
}
nmiss = arrayNumMV(gridsize, field2.vec.data(), missval);
field2.numMissUpdate();
cdoDefRecord(streamID3, varID, levelID);
cdoWriteRecord(streamID3, field2.vec.data(), nmiss);
cdoWriteRecord(streamID3, field2.vec.data(), field2.nmiss);
}
cdoStreamClose(streamID3);
......
......@@ -157,7 +157,6 @@ Rhopot(void *process)
int nrecs;
int varID, levelID;
int zaxisID;
size_t nmiss;
int toID = -1, saoID = -1, thoID = -1;
char varname[CDI_MAX_NAME], stdname[CDI_MAX_NAME];
double pin = -1;
......@@ -287,9 +286,9 @@ Rhopot(void *process)
for (levelID = 0; levelID < nlevel; ++levelID)
{
nmiss = arrayNumMV(gridsize, rho[levelID].vec.data(), rho[levelID].missval);
rho[levelID].numMissUpdate();
cdoDefRecord(streamID2, 0, levelID);
cdoWriteRecord(streamID2, rho[levelID].vec.data(), nmiss);
cdoWriteRecord(streamID2, rho[levelID].vec.data(), rho[levelID].nmiss);
}
tsID++;
......
......@@ -159,10 +159,8 @@ Selyearidx(void *process)
varID = recList[recID].varID;
levelID = recList[recID].levelID;
cdoDefRecord(streamID3, varID, levelID);
const size_t gridsize = varList2[varID].gridsize;
const double missval = varList2[varID].missval;
nmiss = arrayNumMV(gridsize, vars2[varID][levelID].vec.data(), missval);
cdoWriteRecord(streamID3, vars2[varID][levelID].vec.data(), nmiss);
vars2[varID][levelID].numMissUpdate();
cdoWriteRecord(streamID3, vars2[varID][levelID].vec.data(), vars2[varID][levelID].nmiss);
}
tsID3++;
......
......@@ -25,9 +25,11 @@
#include "cdo_int.h"
void
subtrend(int tsID, size_t gridsize, double missval, const Field &field1, const Field &field2, const Field &field3, Field &field4)
static void
subtrend(int tsID, const Field &field1, const Field &field2, const Field &field3, Field &field4)
{
const size_t gridsize = field1.size;
const double missval = field1.missval;
const double missval1 = missval;
const double missval2 = missval;
for (size_t i = 0; i < gridsize; i++)
......@@ -38,7 +40,6 @@ void *
Subtrend(void *process)
{
int varID, levelID;
size_t nmiss;
cdoInitialize(process);
......@@ -79,7 +80,7 @@ Subtrend(void *process)
for (int recID = 0; recID < nrecs; recID++)
{
cdoInqRecord(streamID2, &varID, &levelID);
cdoReadRecord(streamID2, vars2[varID][levelID].vec.data(), &nmiss);
cdoReadRecord(streamID2, vars2[varID][levelID].vec.data(), &vars2[varID][levelID].nmiss);
}
tsID = 0;
......@@ -87,7 +88,7 @@ Subtrend(void *process)
for (int recID = 0; recID < nrecs; recID++)
{
cdoInqRecord(streamID3, &varID, &levelID);
cdoReadRecord(streamID3, vars3[varID][levelID].vec.data(), &nmiss);
cdoReadRecord(streamID3, vars3[varID][levelID].vec.data(), &vars3[varID][levelID].nmiss);
}
tsID = 0;
......@@ -99,16 +100,18 @@ Subtrend(void *process)
for (int recID = 0; recID < nrecs; recID++)
{
cdoInqRecord(streamID1, &varID, &levelID);
cdoReadRecord(streamID1, field1.vec.data(), &nmiss);
cdoReadRecord(streamID1, field1.vec.data(), &field1.nmiss);
const size_t gridsize = varList[varID].gridsize;
const double missval = varList[varID].missval;
field1.size = varList[varID].gridsize;
field1.missval = varList[varID].missval;
field4.size = varList[varID].gridsize;
field4.missval = varList[varID].missval;
subtrend(tsID, gridsize, missval, field1, vars2[varID][levelID], vars3[varID][levelID], field4);
subtrend(tsID, field1, vars2[varID][levelID], vars3[varID][levelID], field4);
nmiss = arrayNumMV(gridsize, field4.vec.data(), missval);
field4.numMissUpdate();
cdoDefRecord(streamID4, varID, levelID);
cdoWriteRecord(streamID4, field4.vec.data(), nmiss);
cdoWriteRecord(streamID4, field4.vec.data(), field4.nmiss);
}
tsID++;
......
......@@ -476,7 +476,7 @@ Timstat(void *argument)
}
}
if (irun) rvars1.nmiss = arrayNumMV(fieldsize, rvars1.vec.data(), missval);
if (irun) rvars1.numMissUpdate();
}
}
......
......@@ -44,7 +44,6 @@ Timstat3(void *process)
int nlevs;
int is;
int varID, levelID, gridID;
size_t nmiss;
double missval, missval1, missval2;
double fractil_1, fractil_2, statistic;
std::vector<std::vector<std::vector<int>>> iwork[NIWORK];
......@@ -273,9 +272,9 @@ Timstat3(void *process)
}
}
nmiss = arrayNumMV(gridsize, out[0].vec.data(), missval1);
out[0].numMissUpdate();
cdoDefRecord(streamID3, varID, levelID);
cdoWriteRecord(streamID3, out[0].vec.data(), nmiss);
cdoWriteRecord(streamID3, out[0].vec.data(), out[0].nmiss);
}
cdoStreamClose(streamID3);
......
......@@ -29,7 +29,6 @@ void *
Trend(void *process)
{
int varID, levelID;
size_t nmiss;
int nrecs;
cdoInitialize(process);
......@@ -92,7 +91,7 @@ Trend(void *process)
recList[recID].lconst = vlistInqVarTimetype(vlistID1, varID) == TIME_CONSTANT;
}
cdoReadRecord(streamID1, field1.vec.data(), &nmiss);
cdoReadRecord(streamID1, field1.vec.data(), &field1.nmiss);
const size_t gridsize = varList[varID].gridsize;
const double missval = varList[varID].missval;
......@@ -124,6 +123,10 @@ Trend(void *process)
const double missval = varList[varID].missval;
const double missval1 = missval;
const double missval2 = missval;
field1.size = gridsize;
field1.missval = missval;
field2.size = gridsize;
field2.missval = missval;
double temp1, temp2;
for (size_t i = 0; i < gridsize; i++)
......@@ -138,13 +141,13 @@ Trend(void *process)
MULMN(DIVMN(work[0][varID][levelID].vec[i], work[4][varID][levelID].vec[i]), field2.vec[i]));
}
nmiss = arrayNumMV(gridsize, field1.vec.data(), missval);
field1.numMissUpdate();
cdoDefRecord(streamID2, varID, levelID);
cdoWriteRecord(streamID2, field1.vec.data(), nmiss);
cdoWriteRecord(streamID2, field1.vec.data(), field1.nmiss);
nmiss = arrayNumMV(gridsize, field2.vec.data(), missval);
field2.numMissUpdate();
cdoDefRecord(streamID3, varID, levelID);
cdoWriteRecord(streamID3, field2.vec.data(), nmiss);
cdoWriteRecord(streamID3, field2.vec.data(), field2.nmiss);
}
cdoStreamClose(streamID3);
......
......@@ -140,15 +140,12 @@ Tstepcount(void *process)
for (varID = 0; varID < nvars; varID++)
{
gridID = vlistInqVarGrid(vlistID2, varID);
const double missval = vlistInqVarMissval(vlistID2, varID);
const size_t gridsize = gridInqSize(gridID);
const int nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
for (levelID = 0; levelID < nlevels; levelID++)
{
nmiss = arrayNumMV(gridsize, vars[0][varID][levelID].vec.data(), missval);
vars[0][varID][levelID].numMissUpdate();
cdoDefRecord(streamID2, varID, levelID);
cdoWriteRecord(streamID2, vars[0][varID][levelID].vec.data(), nmiss);
cdoWriteRecord(streamID2, vars[0][varID][levelID].vec.data(), vars[0][varID][levelID].nmiss);
}
}
......
......@@ -50,17 +50,13 @@ windchillTemperature(double t, double ff, double missval)
static void
farexpr(Field &field1, Field &field2, double (*expression)(double, double, double))
{
const int grid1 = field1.grid;
const size_t nmiss1 = field1.nmiss;
const double missval1 = field1.missval;
const int grid2 = field2.grid;
const size_t nmiss2 = field2.nmiss;
const double missval2 = field2.missval;
const size_t len = gridInqSize(grid1);
if (len != gridInqSize(grid2)) cdoAbort("Fields have different gridsize (%s)", __func__);
const size_t len = field1.size;
if (len != field2.size) cdoAbort("Fields have different size (%s)", __func__);
if (nmiss1 || nmiss2)
if (field1.nmiss || field2.nmiss)
{
for (size_t i = 0; i < len; i++)
if (DBL_IS_EQUAL(field1.vec[i], missval1) || DBL_IS_EQUAL(field2.vec[i], missval2))
......@@ -73,7 +69,7 @@ farexpr(Field &field1, Field &field2, double (*expression)(double, double, doubl
for (size_t i = 0; i < len; i++) field1.vec[i] = expression(field1.vec[i], field2.vec[i], missval1);
}
field1.nmiss = arrayNumMV(len, field1.vec.data(), missval1);
field1.numMissUpdate();
}
void *
......@@ -144,10 +140,7 @@ Wct(void *process)
if (varID1 != FIRST_VAR) continue;
field1.grid = vlistInqVarGrid(vlistID1, varID1);
field1.missval = vlistInqVarMissval(vlistID1, varID1);
field2.grid = vlistInqVarGrid(vlistID2, varID2);
field2.missval = vlistInqVarMissval(vlistID2, varID2);
farexpr(field1, field2, windchillTemperature);
......
......@@ -528,7 +528,7 @@ XTimstat(void *process)
}
}
if (irun) rvars1.nmiss = arrayNumMV(fieldsize, rvars1.vec.data(), missval);
if (irun) rvars1.numMissUpdate();
}
}
......
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