Commit a8e8b649 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Unify process structure.

parent eae69c50
...@@ -256,8 +256,8 @@ void *Timstat(void *argument) ...@@ -256,8 +256,8 @@ void *Timstat(void *argument)
else else
field.ptr = (double*) Malloc(gridsizemax*sizeof(double)); field.ptr = (double*) Malloc(gridsizemax*sizeof(double));
field_type **vars1 = field_malloc(vlistID1, FIELD_PTR);
field_type **samp1 = field_malloc(vlistID1, FIELD_NONE); field_type **samp1 = field_malloc(vlistID1, FIELD_NONE);
field_type **vars1 = field_malloc(vlistID1, FIELD_PTR);
field_type **vars2 = NULL; field_type **vars2 = NULL;
if ( lvarstd || lrange ) vars2 = field_malloc(vlistID1, FIELD_PTR); if ( lvarstd || lrange ) vars2 = field_malloc(vlistID1, FIELD_PTR);
...@@ -287,6 +287,7 @@ void *Timstat(void *argument) ...@@ -287,6 +287,7 @@ void *Timstat(void *argument)
recinfo[recID].levelID = levelID; recinfo[recID].levelID = levelID;
} }
field_type *psamp1 = &samp1[varID][levelID];
field_type *pvars1 = &vars1[varID][levelID]; field_type *pvars1 = &vars1[varID][levelID];
field_type *pvars2 = vars2 ? &vars2[varID][levelID] : NULL; field_type *pvars2 = vars2 ? &vars2[varID][levelID] : NULL;
...@@ -304,13 +305,13 @@ void *Timstat(void *argument) ...@@ -304,13 +305,13 @@ void *Timstat(void *argument)
pvars2->ptr[i] = pvars1->ptr[i]; pvars2->ptr[i] = pvars1->ptr[i];
} }
if ( nmiss > 0 || samp1[varID][levelID].ptr ) if ( nmiss > 0 || psamp1->ptr )
{ {
if ( samp1[varID][levelID].ptr == NULL ) if ( psamp1->ptr == NULL )
samp1[varID][levelID].ptr = (double*) Malloc(nwpv*gridsize*sizeof(double)); psamp1->ptr = (double*) Malloc(nwpv*gridsize*sizeof(double));
for ( int i = 0; i < nwpv*gridsize; i++ ) for ( int i = 0; i < nwpv*gridsize; i++ )
samp1[varID][levelID].ptr[i] = !DBL_IS_EQUAL(pvars1->ptr[i], pvars1->missval); psamp1->ptr[i] = !DBL_IS_EQUAL(pvars1->ptr[i], pvars1->missval);
} }
} }
else else
...@@ -323,18 +324,18 @@ void *Timstat(void *argument) ...@@ -323,18 +324,18 @@ void *Timstat(void *argument)
field.size = gridsize; field.size = gridsize;
field.grid = pvars1->grid; field.grid = pvars1->grid;
field.missval = pvars1->missval; field.missval = pvars1->missval;
if ( field.nmiss > 0 || samp1[varID][levelID].ptr ) if ( field.nmiss > 0 || psamp1->ptr )
{ {
if ( samp1[varID][levelID].ptr == NULL ) if ( psamp1->ptr == NULL )
{ {
samp1[varID][levelID].ptr = (double*) Malloc(nwpv*gridsize*sizeof(double)); psamp1->ptr = (double*) Malloc(nwpv*gridsize*sizeof(double));
for ( int i = 0; i < nwpv*gridsize; i++ ) for ( int i = 0; i < nwpv*gridsize; i++ )
samp1[varID][levelID].ptr[i] = nsets; psamp1->ptr[i] = nsets;
} }
for ( int i = 0; i < nwpv*gridsize; i++ ) for ( int i = 0; i < nwpv*gridsize; i++ )
if ( !DBL_IS_EQUAL(field.ptr[i], pvars1->missval) ) if ( !DBL_IS_EQUAL(field.ptr[i], pvars1->missval) )
samp1[varID][levelID].ptr[i]++; psamp1->ptr[i]++;
} }
if ( lvarstd ) if ( lvarstd )
...@@ -375,53 +376,39 @@ void *Timstat(void *argument) ...@@ -375,53 +376,39 @@ void *Timstat(void *argument)
if ( nrecs == 0 && nsets == 0 ) break; if ( nrecs == 0 && nsets == 0 ) break;
if ( lmean ) for ( int recID = 0; recID < maxrecs; recID++ )
for ( int recID = 0; recID < maxrecs; recID++ ) {
{ int varID = recinfo[recID].varID;
int varID = recinfo[recID].varID; int levelID = recinfo[recID].levelID;
int levelID = recinfo[recID].levelID; field_type *psamp1 = &samp1[varID][levelID];
field_type *pvars1 = &vars1[varID][levelID]; field_type *pvars1 = &vars1[varID][levelID];
field_type *pvars2 = vars2 ? &vars2[varID][levelID] : NULL;
if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
if ( samp1[varID][levelID].ptr == NULL )
farcdiv(pvars1, (double)nsets); if ( lmean )
else {
fardiv(pvars1, samp1[varID][levelID]); if ( psamp1->ptr ) fardiv(pvars1, *psamp1);
} else farcdiv(pvars1, (double)nsets);
else if ( lvarstd ) }
for ( int recID = 0; recID < maxrecs; recID++ ) else if ( lvarstd )
{ {
int varID = recinfo[recID].varID; if ( psamp1->ptr )
int levelID = recinfo[recID].levelID; {
field_type *pvars1 = &vars1[varID][levelID]; if ( lstd ) farstd(pvars1, *pvars2, *psamp1, divisor);
field_type *pvars2 = &vars2[varID][levelID]; else farvar(pvars1, *pvars2, *psamp1, divisor);
}
if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue; else
{
if ( samp1[varID][levelID].ptr == NULL ) if ( lstd ) farcstd(pvars1, *pvars2, nsets, divisor);
{ else farcvar(pvars1, *pvars2, nsets, divisor);
if ( lstd ) farcstd(pvars1, *pvars2, nsets, divisor); }
else farcvar(pvars1, *pvars2, nsets, divisor); }
} else if ( lrange )
else {
{ farsub(pvars1, *pvars2);
if ( lstd ) farstd(pvars1, *pvars2, samp1[varID][levelID], divisor); }
else farvar(pvars1, *pvars2, samp1[varID][levelID], divisor); }
}
}
else if ( lrange )
for ( int recID = 0; recID < maxrecs; recID++ )
{
int varID = recinfo[recID].varID;
int levelID = recinfo[recID].levelID;
field_type *pvars1 = &vars1[varID][levelID];
field_type *pvars2 = &vars2[varID][levelID];
if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
farsub(pvars1, *pvars2);
}
if ( cdoVerbose ) if ( cdoVerbose )
{ {
...@@ -436,6 +423,7 @@ void *Timstat(void *argument) ...@@ -436,6 +423,7 @@ void *Timstat(void *argument)
{ {
int varID = recinfo[recID].varID; int varID = recinfo[recID].varID;
int levelID = recinfo[recID].levelID; int levelID = recinfo[recID].levelID;
field_type *psamp1 = &samp1[varID][levelID];
field_type *pvars1 = &vars1[varID][levelID]; field_type *pvars1 = &vars1[varID][levelID];
if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue; if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
...@@ -443,12 +431,12 @@ void *Timstat(void *argument) ...@@ -443,12 +431,12 @@ void *Timstat(void *argument)
int nwpv = pvars1->nwpv; int nwpv = pvars1->nwpv;
int gridsize = gridInqSize(pvars1->grid); int gridsize = gridInqSize(pvars1->grid);
double missval = pvars1->missval; double missval = pvars1->missval;
if ( samp1[varID][levelID].ptr ) if ( psamp1->ptr )
{ {
int irun = 0; int irun = 0;
for ( int i = 0; i < nwpv*gridsize; ++i ) for ( int i = 0; i < nwpv*gridsize; ++i )
{ {
if ( (samp1[varID][levelID].ptr[i] / nsets) < vfrac ) if ( (psamp1->ptr[i] / nsets) < vfrac )
{ {
pvars1->ptr[i] = missval; pvars1->ptr[i] = missval;
irun++; irun++;
...@@ -478,6 +466,7 @@ void *Timstat(void *argument) ...@@ -478,6 +466,7 @@ void *Timstat(void *argument)
{ {
int varID = recinfo[recID].varID; int varID = recinfo[recID].varID;
int levelID = recinfo[recID].levelID; int levelID = recinfo[recID].levelID;
field_type *psamp1 = &samp1[varID][levelID];
field_type *pvars1 = &vars1[varID][levelID]; field_type *pvars1 = &vars1[varID][levelID];
if ( otsID && vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue; if ( otsID && vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
...@@ -488,7 +477,7 @@ void *Timstat(void *argument) ...@@ -488,7 +477,7 @@ void *Timstat(void *argument)
if ( cdoDiag ) if ( cdoDiag )
{ {
double *sampptr = field.ptr; double *sampptr = field.ptr;
if ( samp1[varID][levelID].ptr ) sampptr = samp1[varID][levelID].ptr; if ( psamp1->ptr ) sampptr = psamp1->ptr;
else else
{ {
int gridsize = pvars1->size; int gridsize = pvars1->size;
......
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