Commit 58eb2e4e authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Replaced recinfo_t by recinfo_type.

parent 4eabe06b
......@@ -39,11 +39,6 @@
#define NMONTH 17
typedef struct {
short varID;
short levelID;
} recinfo_t;
/*
static
......@@ -120,8 +115,7 @@ void *Ymonstat(void *argument)
pstreamDefVlist(streamID2, vlistID2);
int maxrecs = vlistNrecs(vlistID1);
recinfo_t *recinfo = (recinfo_t *) Malloc(maxrecs*sizeof(recinfo_t));
std::vector<recinfo_type> recinfo(maxrecs);
int gridsizemax = vlistGridsizeMax(vlistID1);
field_init(&field);
......@@ -161,6 +155,7 @@ void *Ymonstat(void *argument)
{
recinfo[recID].varID = varID;
recinfo[recID].levelID = levelID;
recinfo[recID].lconst = vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT;
}
field_type *psamp1 = &samp1[month][varID][levelID];
......@@ -231,13 +226,13 @@ void *Ymonstat(void *argument)
if ( month_nsets[month] == 0 && lvarstd )
for ( int recID = 0; recID < maxrecs; recID++ )
{
if ( recinfo[recID].lconst ) continue;
int varID = recinfo[recID].varID;
int levelID = recinfo[recID].levelID;
field_type *pvars1 = &vars1[month][varID][levelID];
field_type *pvars2 = &vars2[month][varID][levelID];
if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
farmoq(pvars2, *pvars1);
}
......@@ -274,19 +269,19 @@ void *Ymonstat(void *argument)
for ( int i = 0; i < nmon; i++ )
{
month = mon[i];
if ( month_nsets[month] == 0 ) cdoAbort("Internal problem, nsets[%d] not defined!", month);
int nsets = month_nsets[month];
if ( nsets == 0 ) cdoAbort("Internal problem, nsets[%d] not defined!", month);
for ( int recID = 0; recID < maxrecs; recID++ )
{
if ( recinfo[recID].lconst ) continue;
int varID = recinfo[recID].varID;
int levelID = recinfo[recID].levelID;
field_type *psamp1 = &samp1[month][varID][levelID];
field_type *pvars1 = &vars1[month][varID][levelID];
field_type *pvars2 = vars2[month] ? &vars2[month][varID][levelID] : NULL;
if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
if ( lmean )
{
if ( psamp1->ptr ) fardiv(pvars1, *psamp1);
......@@ -317,11 +312,11 @@ void *Ymonstat(void *argument)
for ( int recID = 0; recID < maxrecs; recID++ )
{
if ( otsID && recinfo[recID].lconst ) continue;
int varID = recinfo[recID].varID;
int levelID = recinfo[recID].levelID;
field_type *pvars1 = &vars1[month][varID][levelID];
if ( otsID && vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
pstreamDefRecord(streamID2, varID, levelID);
pstreamWriteRecord(streamID2, pvars1->ptr, (int)pvars1->nmiss);
......@@ -342,8 +337,6 @@ void *Ymonstat(void *argument)
if ( field.ptr ) Free(field.ptr);
Free(recinfo);
pstreamClose(streamID2);
pstreamClose(streamID1);
......
......@@ -45,11 +45,6 @@ typedef struct {
}
date_time_t;
typedef struct {
short varID;
short levelID;
} recinfo_t;
void set_date(int vdate_new, int vtime_new, date_time_t *datetime)
{
......@@ -124,8 +119,7 @@ void *Yseasstat(void *argument)
pstreamDefVlist(streamID2, vlistID2);
int maxrecs = vlistNrecs(vlistID1);
recinfo_t *recinfo = (recinfo_t *) Malloc(maxrecs*sizeof(recinfo_t));
std::vector<recinfo_type> recinfo(maxrecs);
int gridsizemax = vlistGridsizeMax(vlistID1);
......@@ -161,6 +155,7 @@ void *Yseasstat(void *argument)
{
recinfo[recID].varID = varID;
recinfo[recID].levelID = levelID;
recinfo[recID].lconst = vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT;
}
field_type *psamp1 = &samp1[seas][varID][levelID];
......@@ -231,13 +226,13 @@ void *Yseasstat(void *argument)
if ( seas_nsets[seas] == 0 && lvarstd )
for ( int recID = 0; recID < maxrecs; recID++ )
{
if ( recinfo[recID].lconst ) continue;
int varID = recinfo[recID].varID;
int levelID = recinfo[recID].levelID;
field_type *pvars1 = &vars1[seas][varID][levelID];
field_type *pvars2 = &vars2[seas][varID][levelID];
if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
farmoq(pvars2, *pvars1);
}
......@@ -251,14 +246,14 @@ void *Yseasstat(void *argument)
int nsets = seas_nsets[seas];
for ( int recID = 0; recID < maxrecs; recID++ )
{
if ( recinfo[recID].lconst ) continue;
int varID = recinfo[recID].varID;
int levelID = recinfo[recID].levelID;
field_type *psamp1 = &samp1[seas][varID][levelID];
field_type *pvars1 = &vars1[seas][varID][levelID];
field_type *pvars2 = vars2[seas] ? &vars2[seas][varID][levelID] : NULL;
if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
if ( lmean )
{
if ( psamp1->ptr ) fardiv(pvars1, *psamp1);
......@@ -289,12 +284,12 @@ void *Yseasstat(void *argument)
for ( int recID = 0; recID < maxrecs; recID++ )
{
if ( otsID && recinfo[recID].lconst ) continue;
int varID = recinfo[recID].varID;
int levelID = recinfo[recID].levelID;
field_type *pvars1 = &vars1[seas][varID][levelID];
if ( otsID && vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
pstreamDefRecord(streamID2, varID, levelID);
pstreamWriteRecord(streamID2, pvars1->ptr, (int)pvars1->nmiss);
}
......@@ -314,8 +309,6 @@ void *Yseasstat(void *argument)
if ( field.ptr ) Free(field.ptr);
Free(recinfo);
pstreamClose(streamID2);
pstreamClose(streamID1);
......
......@@ -97,6 +97,14 @@ typedef struct {
field_type;
typedef struct {
short varID;
short levelID;
bool lconst;
}
recinfo_type;
/* fieldmem.cc */
void field_init(field_type *field);
......
......@@ -28,7 +28,7 @@ field_type **field_allocate(int vlistID, int ptype, int init)
int gridsize = gridInqSize(gridID);
int zaxisID = vlistInqVarZaxis(vlistID, varID);
int nlevel = zaxisInqSize(zaxisID);
double missval = vlistInqVarMissval(vlistID, varID);
double missval = vlistInqVarMissval(vlistID, varID);
field[varID] = (field_type*) Malloc(nlevel*sizeof(field_type));
......@@ -36,17 +36,17 @@ field_type **field_allocate(int vlistID, int ptype, int init)
{
field_init(&field[varID][levelID]);
field[varID][levelID].nwpv = nwpv;
field[varID][levelID].grid = gridID;
field[varID][levelID].size = gridsize;
field[varID][levelID].nsamp = 0;
field[varID][levelID].nmiss = 0;
field[varID][levelID].nmiss2 = 0;
field[varID][levelID].nwpv = nwpv;
field[varID][levelID].grid = gridID;
field[varID][levelID].size = gridsize;
field[varID][levelID].nsamp = 0;
field[varID][levelID].nmiss = 0;
field[varID][levelID].nmiss2 = 0;
if ( ptype & FIELD_FLT ) field[varID][levelID].memtype = MEMTYPE_FLOAT;
field[varID][levelID].missval = missval;
field[varID][levelID].ptr = NULL;
field[varID][levelID].ptr2 = NULL;
field[varID][levelID].weight = NULL;
field[varID][levelID].missval = missval;
field[varID][levelID].ptr = NULL;
field[varID][levelID].ptr2 = NULL;
field[varID][levelID].weight = NULL;
if ( ptype & FIELD_PTR )
{
......
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