Commit 10180f6b authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Using VarList.

parent faec6e97
......@@ -72,7 +72,7 @@ Ydaypctl(void *process)
const auto taxisID3 = vlistInqTaxis(vlistID3);
/* TODO - check that time axes 2 and 3 are equal */
const int taxisID4 = taxisDuplicate(taxisID1);
const auto taxisID4 = taxisDuplicate(taxisID1);
if (taxisHasBounds(taxisID4)) taxisDeleteBounds(taxisID4);
vlistDefTaxis(vlistID4, taxisID4);
......@@ -84,6 +84,9 @@ Ydaypctl(void *process)
const auto maxrecs = vlistNrecs(vlistID1);
std::vector<RecordInfo> recList(maxrecs);
VarList varList1;
varListInit(varList1, vlistID1);
const auto gridsizemax = vlistGridsizeMax(vlistID1);
Field field;
......@@ -114,11 +117,7 @@ Ydaypctl(void *process)
hsets[dayoy].create(nvars);
for (varID = 0; varID < nvars; varID++)
{
auto gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
auto nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
hsets[dayoy].createVarLevels(varID, nlevels, gridsize);
}
hsets[dayoy].createVarLevels(varID, varList1[varID].nlevels, varList1[varID].gridsize);
}
for (int recID = 0; recID < nrecs; recID++)
......@@ -165,7 +164,7 @@ Ydaypctl(void *process)
{
recList[recID].varID = varID;
recList[recID].levelID = levelID;
recList[recID].lconst = vlistInqVarTimetype(vlistID1, varID) == TIME_CONSTANT;
recList[recID].lconst = varList1[varID].timetype == TIME_CONSTANT;
}
cdoReadRecord(streamID1, vars1[dayoy][varID][levelID].vec.data(), &nmiss);
......@@ -190,7 +189,7 @@ Ydaypctl(void *process)
{
if (vlistInqVarTimetype(vlistID1, varID) == TIME_CONSTANT) continue;
const auto nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
const auto nlevels = varList1[varID].nlevels;
for (levelID = 0; levelID < nlevels; levelID++)
hsets[dayoy].getVarLevelPercentiles(vars1[dayoy][varID][levelID], varID, levelID, pn, FIELD_VEC);
}
......
......@@ -33,6 +33,7 @@
#include <cdi.h>
#include "cdo_options.h"
#include "cdo_vlist.h"
#include "datetime.h"
#include "functs.h"
#include "process_int.h"
......@@ -131,6 +132,9 @@ Ydaystat(void *process)
const auto maxrecs = vlistNrecs(vlistID1);
std::vector<RecordInfo> recList(maxrecs);
VarList varList1;
varListInit(varList1, vlistID1);
const auto gridsizemax = vlistGridsizeMax(vlistID1);
Field field;
......@@ -166,7 +170,7 @@ Ydaystat(void *process)
{
recList[recID].varID = varID;
recList[recID].levelID = levelID;
recList[recID].lconst = vlistInqVarTimetype(vlistID1, varID) == TIME_CONSTANT;
recList[recID].lconst = varList1[varID].timetype == TIME_CONSTANT;
}
auto &rsamp1 = samp1[dayoy][varID][levelID];
......@@ -252,8 +256,7 @@ Ydaystat(void *process)
{
cdiDecodeDate(vdates[dayoy], &year, &month, &day);
if (year > outyear) vdates[dayoy] = cdiEncodeDate(outyear, month, day);
// printf("vdates[%d] = %d nsets = %d\n", dayoy, vdates[dayoy],
// nsets[dayoy]);
// printf("vdates[%d] = %d nsets = %d\n", dayoy, vdates[dayoy], nsets[dayoy]);
}
}
......
......@@ -87,7 +87,8 @@ Ydrunpctl(void *process)
vlistCompare(vlistID1, vlistID2, CMP_ALL);
vlistCompare(vlistID1, vlistID3, CMP_ALL);
VarList varList2;
VarList varList1, varList2;
varListInit(varList1, vlistID1);
varListInit(varList2, vlistID2);
const auto taxisID1 = vlistInqTaxis(vlistID1);
......@@ -185,7 +186,7 @@ Ydrunpctl(void *process)
{
recList[recID].varID = varID;
recList[recID].levelID = levelID;
recList[recID].lconst = vlistInqVarTimetype(vlistID1, varID) == TIME_CONSTANT;
recList[recID].lconst = varList1[varID].timetype == TIME_CONSTANT;
}
cdoReadRecord(streamID1, vars1[tsID][varID][levelID].vec.data(), &nmiss);
......@@ -212,7 +213,7 @@ Ydrunpctl(void *process)
{
if (vlistInqVarTimetype(vlistID1, varID) == TIME_CONSTANT) continue;
const auto nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
const auto nlevels = varList1[varID].nlevels;
for (levelID = 0; levelID < nlevels; levelID++)
for (inp = 0; inp < ndates; inp++) hsets[dayoy].addSubVarLevelValues(varID, levelID, vars1[inp][varID][levelID], 1, FIELD_VEC);
}
......@@ -281,7 +282,7 @@ Ydrunpctl(void *process)
{
if (vlistInqVarTimetype(vlistID1, varID) == TIME_CONSTANT) continue;
const auto nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
const auto nlevels = varList1[varID].nlevels;
for (levelID = 0; levelID < nlevels; levelID++)
for (inp = 0; inp < ndates; inp++) hsets[dayoy].addSubVarLevelValues(varID, levelID, vars1[inp][varID][levelID], 1, FIELD_VEC);
}
......@@ -332,7 +333,7 @@ Ydrunpctl(void *process)
{
if (vlistInqVarTimetype(vlistID1, varID) == TIME_CONSTANT) continue;
const auto nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
const auto nlevels = varList1[varID].nlevels;
for (levelID = 0; levelID < nlevels; levelID++)
hsets[dayoy].getVarLevelPercentiles(vars2[dayoy][varID][levelID], varID, levelID, pn, FIELD_VEC);
}
......
......@@ -25,6 +25,7 @@
#include <cdi.h>
#include "cdo_options.h"
#include "cdo_vlist.h"
#include "functs.h"
#include "process_int.h"
#include "calendar.h"
......@@ -77,6 +78,9 @@ Yearmonstat(void *process)
dtlist.setStat(timestat_date);
dtlist.setCalendar(calendar);
VarList varList1;
varListInit(varList1, vlistID1);
const auto gridsizemax = vlistGridsizeMax(vlistID1);
Field field;
......@@ -120,7 +124,7 @@ Yearmonstat(void *process)
{
recList[recID].varID = varID;
recList[recID].levelID = levelID;
recList[recID].lconst = vlistInqVarTimetype(vlistID1, varID) == TIME_CONSTANT;
recList[recID].lconst = varList1[varID].timetype == TIME_CONSTANT;
}
auto &rsamp1 = samp1[varID][levelID];
......@@ -175,8 +179,8 @@ Yearmonstat(void *process)
for (varID = 0; varID < nvars; varID++)
{
if (vlistInqVarTimetype(vlistID1, varID) == TIME_CONSTANT) continue;
const auto nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
if (varList1[varID].timetype == TIME_CONSTANT) continue;
const auto nlevels = varList1[varID].nlevels;
for (levelID = 0; levelID < nlevels; levelID++)
{
if (samp1[varID][levelID].empty())
......
......@@ -34,6 +34,7 @@
#include <cdi.h>
#include "cdo_options.h"
#include "cdo_vlist.h"
#include "functs.h"
#include "process_int.h"
#include "param_conversion.h"
......@@ -153,6 +154,9 @@ Zonstat(void *process)
const auto streamID2 = cdoOpenWrite(1);
cdoDefVlist(streamID2, vlistID2);
VarList varList1;
varListInit(varList1, vlistID1);
gridID1 = vlistInqVarGrid(vlistID1, 0);
const auto nlatmax = gridInqYsize(gridID1); /* max nlat ? */
......@@ -174,9 +178,9 @@ Zonstat(void *process)
cdoInqRecord(streamID1, &varID, &levelID);
cdoReadRecord(streamID1, field1.vec.data(), &field1.nmiss);
field1.grid = vlistInqVarGrid(vlistID1, varID);
field1.missval = vlistInqVarMissval(vlistID1, varID);
field2.missval = vlistInqVarMissval(vlistID1, varID);
field1.grid = varList1[varID].gridID;
field1.missval = varList1[varID].missval;
field2.missval = varList1[varID].missval;
if (zongridID != -1 && zongridID == field1.grid)
{
......
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