Commit a95a47ac authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

Merge branch 'develop' of git.mpimet.mpg.de:cdo into develop

parents 4d33e781 233d9cad
2017-08-14 Uwe Schulzweida
* eof, eof3d: set default of env. CDO_WEIGHT_MODE to off
* eof3d: preserve variable name on first output file [report: Frank Kauker]
2017-08-12 Uwe Schulzweida
* eof3d: weight was allocated for only one level (bug fix) [report: Frank Kauker]
2017-07-27 Uwe Schulzweida 2017-07-27 Uwe Schulzweida
* Using CDI library version 1.9.0 * Using CDI library version 1.9.0
......
CDO NEWS CDO NEWS
-------- --------
Version 1.9.1 (27 September 2017):
Changes operators:
* eof, eof3d: set default of environment variable CDO_WEIGHT_MODE to off
Fixed bugs:
* eof3d: weight array was allocated for only one level (bug fix)
Version 1.9.0 (27 July 2017): Version 1.9.0 (27 July 2017):
New features: New features:
......
...@@ -198,7 +198,7 @@ keepaspectratio]{cdo_libdep.pdf}}% ...@@ -198,7 +198,7 @@ keepaspectratio]{cdo_libdep.pdf}}%
\end{picture} \end{picture}
\begin{flushright} \begin{flushright}
\large \textbf{Climate Data Operators \\ Version 1.9.0 \\ August 2017} \large \textbf{Climate Data Operators \\ Version 1.9.1 \\ September 2017}
\end{flushright} \end{flushright}
\vfill \vfill
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
\put(0,0.0){\line(1,0){3.95}} \put(0,0.0){\line(1,0){3.95}}
\end{picture} \end{picture}
\begin{flushright} \begin{flushright}
{\small{Climate Data Operators \\ Version 1.9.0 \\ August 2017}} {\small{Climate Data Operators \\ Version 1.9.1 \\ September 2017}}
\end{flushright} \end{flushright}
\vspace*{0mm} \vspace*{0mm}
......
...@@ -73,7 +73,7 @@ Is used to choose the algorithm for eigenvalue calculation. Options are 'jacobi' ...@@ -73,7 +73,7 @@ Is used to choose the algorithm for eigenvalue calculation. Options are 'jacobi'
a one-sided parallel jacobi-algorithm (only executed in parallel if -P flag is set) a one-sided parallel jacobi-algorithm (only executed in parallel if -P flag is set)
and 'danielson_lanczos' for a non-parallel d/l algorithm. The default setting is 'jacobi'. and 'danielson_lanczos' for a non-parallel d/l algorithm. The default setting is 'jacobi'.
@Item = CDO_WEIGHT_MODE @Item = CDO_WEIGHT_MODE
It is used to set the weight mode. The default is 'on'. Set it to 'off' for a non weighted version. It is used to set the weight mode. The default is 'off'. Set it to 'on' for a weighted version.
@Item = MAX_JACOBI_ITER @Item = MAX_JACOBI_ITER
Is the maximum integer number of annihilation sweeps that is executed if the Is the maximum integer number of annihilation sweeps that is executed if the
jacobi-algorithm is used to compute the eigen values. The default value is 12. jacobi-algorithm is used to compute the eigen values. The default value is 12.
......
libcdi @ 405563ff
Subproject commit b6dd1e7488d2fe2c3d51f2858b73b848611d561b Subproject commit 405563ffb3cd44fc1abc148bac4f306f2ebc4ca8
...@@ -43,20 +43,20 @@ ...@@ -43,20 +43,20 @@
// NO MISSING VALUE SUPPORT ADDED SO FAR // NO MISSING VALUE SUPPORT ADDED SO FAR
static static
void scale_eigvec_grid(double *restrict out, int tsID, int npack, const int *restrict pack, const double *restrict weight, double **covar, double sum_w) void scale_eigvec_grid(double *restrict out, int tsID, size_t npack, const size_t *restrict pack, const double *restrict weight, double **covar, double sum_w)
{ {
for ( int i = 0; i < npack; ++i ) for ( size_t i = 0; i < npack; ++i )
out[pack[i]] = covar[tsID][i] / sqrt(weight[pack[i]]/sum_w); out[pack[i]] = covar[tsID][i] / sqrt(weight[pack[i]]/sum_w);
} }
static static
void scale_eigvec_time(double *restrict out, int tsID, int nts, int npack, const int *restrict pack, const double *restrict weight, void scale_eigvec_time(double *restrict out, int tsID, int nts, size_t npack, const size_t *restrict pack, const double *restrict weight,
double **covar, double **data, double missval, double sum_w) double **covar, double **data, double missval, double sum_w)
{ {
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel for default(none) shared(npack, nts, tsID, pack, data, covar, out) #pragma omp parallel for default(none) shared(npack, nts, tsID, pack, data, covar, out)
#endif #endif
for ( int i = 0; i < npack; ++i ) for ( size_t i = 0; i < npack; ++i )
{ {
double sum = 0; double sum = 0;
for ( int j = 0; j < nts; ++j ) for ( int j = 0; j < nts; ++j )
...@@ -65,9 +65,9 @@ void scale_eigvec_time(double *restrict out, int tsID, int nts, int npack, const ...@@ -65,9 +65,9 @@ void scale_eigvec_time(double *restrict out, int tsID, int nts, int npack, const
out[pack[i]] = sum; out[pack[i]] = sum;
} }
/* /*
for ( int j = 0; j < nts; ++j ) for ( size_t j = 0; j < nts; ++j )
{ {
for ( int i = 0; i < npack; ++i ) for ( size_t i = 0; i < npack; ++i )
out[pack[i]] += data[j][i] * covar[tsID][j]; out[pack[i]] += data[j][i] * covar[tsID][j];
} }
*/ */
...@@ -79,7 +79,7 @@ void scale_eigvec_time(double *restrict out, int tsID, int nts, int npack, const ...@@ -79,7 +79,7 @@ void scale_eigvec_time(double *restrict out, int tsID, int nts, int npack, const
#pragma omp parallel for default(none) reduction(+:sum) \ #pragma omp parallel for default(none) reduction(+:sum) \
shared(out,weight,pack,npack) shared(out,weight,pack,npack)
#endif #endif
for ( int i = 0; i < npack; ++i ) for ( size_t i = 0; i < npack; ++i )
{ {
// do not need to account for weights as eigenvectors are non-weighted // do not need to account for weights as eigenvectors are non-weighted
sum += weight[pack[i]] * out[pack[i]] * out[pack[i]]; sum += weight[pack[i]] * out[pack[i]] * out[pack[i]];
...@@ -91,14 +91,14 @@ void scale_eigvec_time(double *restrict out, int tsID, int nts, int npack, const ...@@ -91,14 +91,14 @@ void scale_eigvec_time(double *restrict out, int tsID, int nts, int npack, const
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel for default(none) shared(npack,pack,sum,out) #pragma omp parallel for default(none) shared(npack,pack,sum,out)
#endif #endif
for ( int i = 0; i < npack; ++i ) out[pack[i]] /= sum; for ( size_t i = 0; i < npack; ++i ) out[pack[i]] /= sum;
} }
else else
{ {
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel for default(none) shared(npack,pack,out,missval) #pragma omp parallel for default(none) shared(npack,pack,out,missval)
#endif #endif
for ( int i = 0; i < npack; ++i ) out[pack[i]] = missval; for ( size_t i = 0; i < npack; ++i ) out[pack[i]] = missval;
} }
} }
...@@ -141,7 +141,7 @@ enum T_EIGEN_MODE get_eigenmode(void) ...@@ -141,7 +141,7 @@ enum T_EIGEN_MODE get_eigenmode(void)
enum T_WEIGHT_MODE get_weightmode(void) enum T_WEIGHT_MODE get_weightmode(void)
{ {
enum T_WEIGHT_MODE weight_mode = WEIGHT_ON; enum T_WEIGHT_MODE weight_mode = WEIGHT_OFF;
char *envstr = getenv("CDO_WEIGHT_MODE"); char *envstr = getenv("CDO_WEIGHT_MODE");
if ( envstr ) if ( envstr )
...@@ -171,7 +171,7 @@ void *EOFs(void * argument) ...@@ -171,7 +171,7 @@ void *EOFs(void * argument)
int nmiss; int nmiss;
int varID, levelID; int varID, levelID;
int nts = 0; int nts = 0;
int n = 0; size_t n = 0;
int grid_space = 0, time_space = 0; int grid_space = 0, time_space = 0;
int timer_cov = 0, timer_eig = 0; int timer_cov = 0, timer_eig = 0;
...@@ -217,7 +217,7 @@ void *EOFs(void * argument) ...@@ -217,7 +217,7 @@ void *EOFs(void * argument)
int vlistID1 = pstreamInqVlist(streamID1); int vlistID1 = pstreamInqVlist(streamID1);
int taxisID1 = vlistInqTaxis(vlistID1); int taxisID1 = vlistInqTaxis(vlistID1);
int gridID1 = vlistInqVarGrid(vlistID1, 0); int gridID1 = vlistInqVarGrid(vlistID1, 0);
int gridsize = vlistGridsizeMax(vlistID1); size_t gridsize = vlistGridsizeMax(vlistID1);
int nvars = vlistNvars(vlistID1); int nvars = vlistNvars(vlistID1);
int nrecs; int nrecs;
...@@ -226,19 +226,6 @@ void *EOFs(void * argument) ...@@ -226,19 +226,6 @@ void *EOFs(void * argument)
if ( vlistGrid(vlistID1, 0) != vlistGrid(vlistID1, index)) if ( vlistGrid(vlistID1, 0) != vlistGrid(vlistID1, index))
cdoAbort("Too many different grids!"); cdoAbort("Too many different grids!");
double *weight = (double *) Malloc(gridsize*sizeof(double));
for ( int i = 0; i < gridsize; ++i ) weight[i] = 1.;
if ( weight_mode == WEIGHT_ON )
{
int wstatus = gridWeights(gridID1, weight);
if ( wstatus != 0 )
{
weight_mode = WEIGHT_OFF;
cdoWarning("Using constant grid cell area weights!");
}
}
/* eigenvalues */ /* eigenvalues */
/* COUNT NUMBER OF TIMESTEPS if EOF_ or EOF_TIME */ /* COUNT NUMBER OF TIMESTEPS if EOF_ or EOF_TIME */
...@@ -253,17 +240,17 @@ void *EOFs(void * argument) ...@@ -253,17 +240,17 @@ void *EOFs(void * argument)
while ( pstreamInqTimestep(streamID1, nts) ) nts++; while ( pstreamInqTimestep(streamID1, nts) ) nts++;
if ( cdoVerbose ) cdoPrint("Counted %i timeSteps", nts); if ( cdoVerbose ) cdoPrint("Counted %i timeSteps", nts);
pstreamClose(streamID1);
streamID1 = pstreamOpenRead(cdoStreamName(0));
vlistID1 = pstreamInqVlist(streamID1);
taxisID1 = vlistInqTaxis(vlistID1);
} }
else else
if ( cdoVerbose ) cdoPrint("Found %i timeSteps", nts); if ( cdoVerbose ) cdoPrint("Found %i timeSteps", nts);
pstreamClose(streamID1); if ( (size_t)nts < gridsize || operfunc == EOF_TIME )
streamID1 = pstreamOpenRead(cdoStreamName(0));
vlistID1 = pstreamInqVlist(streamID1);
taxisID1 = vlistInqTaxis(vlistID1);
if ( nts < gridsize || operfunc == EOF_TIME )
{ {
time_space = 1; time_space = 1;
grid_space = 0; grid_space = 0;
...@@ -297,11 +284,11 @@ void *EOFs(void * argument) ...@@ -297,11 +284,11 @@ void *EOFs(void * argument)
{ {
if ( ((double)gridsize)*gridsize > (double)LONG_MAX ) cdoAbort("Grid space too large!"); if ( ((double)gridsize)*gridsize > (double)LONG_MAX ) cdoAbort("Grid space too large!");
if ( n_eig > gridsize ) if ( (size_t)n_eig > gridsize )
{ {
cdoWarning("Solving in spatial space"); cdoWarning("Solving in spatial space");
cdoWarning("Number of eigen-functions to write out is bigger than grid size"); cdoWarning("Number of eigen-functions to write out is bigger than grid size");
cdoWarning("Setting n_eig to %d", gridsize); cdoWarning("Setting n_eig to %zu", gridsize);
cdoWarning("If You want to force a solution in time-space use operator eoftime"); cdoWarning("If You want to force a solution in time-space use operator eoftime");
n_eig = gridsize; n_eig = gridsize;
} }
...@@ -312,9 +299,22 @@ void *EOFs(void * argument) ...@@ -312,9 +299,22 @@ void *EOFs(void * argument)
cdoPrint("Calculating %d eigenvectors and %d eigenvalues in %s", cdoPrint("Calculating %d eigenvectors and %d eigenvalues in %s",
n_eig, n, grid_space==1?"grid_space" : "time_space"); n_eig, n, grid_space==1?"grid_space" : "time_space");
double *weight = (double *) Malloc(gridsize*sizeof(double));
for ( size_t i = 0; i < gridsize; ++i ) weight[i] = 1.;
if ( weight_mode == WEIGHT_ON )
{
int wstatus = gridWeights(gridID1, weight);
if ( wstatus != 0 )
{
weight_mode = WEIGHT_OFF;
cdoWarning("Using constant grid cell area weights!");
}
}
/* allocation of temporary fields and output structures */ /* allocation of temporary fields and output structures */
int npack = -1; size_t npack = ULONG_MAX;
int *pack = (int *) Malloc(gridsize*sizeof(int)); size_t *pack = (size_t *) Malloc(gridsize*sizeof(size_t));
double *in = (double *) Malloc(gridsize*sizeof(double)); double *in = (double *) Malloc(gridsize*sizeof(double));
eofdata_t **eofdata = (eofdata_t **) Malloc(nvars*sizeof(eofdata_t*)); eofdata_t **eofdata = (eofdata_t **) Malloc(nvars*sizeof(eofdata_t*));
...@@ -341,7 +341,7 @@ void *EOFs(void * argument) ...@@ -341,7 +341,7 @@ void *EOFs(void * argument)
} }
if ( cdoVerbose ) if ( cdoVerbose )
cdoPrint("Allocated eigenvalue/eigenvector structures with nts=%d gridsize=%d", nts, gridsize); cdoPrint("Allocated eigenvalue/eigenvector structures with nts=%d gridsize=%zu", nts, gridsize);
double *covar_array = NULL; double *covar_array = NULL;
double **covar = NULL; double **covar = NULL;
...@@ -362,10 +362,10 @@ void *EOFs(void * argument) ...@@ -362,10 +362,10 @@ void *EOFs(void * argument)
gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID)); gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
missval = vlistInqVarMissval(vlistID1, varID); missval = vlistInqVarMissval(vlistID1, varID);
if ( npack == -1 ) if ( npack == ULONG_MAX )
{ {
npack = 0; npack = 0;
for ( int i = 0; i < gridsize; ++i ) for ( size_t i = 0; i < gridsize; ++i )
{ {
if ( !DBL_IS_EQUAL(weight[i], 0.0) && !DBL_IS_EQUAL(weight[i], missval) && if ( !DBL_IS_EQUAL(weight[i], 0.0) && !DBL_IS_EQUAL(weight[i], missval) &&
!DBL_IS_EQUAL(in[i], missval) ) !DBL_IS_EQUAL(in[i], missval) )
...@@ -378,12 +378,12 @@ void *EOFs(void * argument) ...@@ -378,12 +378,12 @@ void *EOFs(void * argument)
if ( weight_mode == WEIGHT_ON ) if ( weight_mode == WEIGHT_ON )
{ {
sum_w = 0; sum_w = 0;
for ( int i = 0; i < npack; i++ ) sum_w += weight[pack[i]]; for ( size_t i = 0; i < npack; i++ ) sum_w += weight[pack[i]];
} }
} }
int ipack = 0; size_t ipack = 0;
for ( int i = 0; i < gridsize; ++i ) for ( size_t i = 0; i < gridsize; ++i )
{ {
if ( !DBL_IS_EQUAL(weight[i], 0.0) && !DBL_IS_EQUAL(weight[i], missval) && if ( !DBL_IS_EQUAL(weight[i], 0.0) && !DBL_IS_EQUAL(weight[i], missval) &&
!DBL_IS_EQUAL(in[i], missval) ) !DBL_IS_EQUAL(in[i], missval) )
...@@ -398,11 +398,11 @@ void *EOFs(void * argument) ...@@ -398,11 +398,11 @@ void *EOFs(void * argument)
if ( !eofdata[varID][levelID].init ) if ( !eofdata[varID][levelID].init )
{ {
n = npack; n = npack;
double *covar_array = (double *) Malloc(((size_t)npack)*npack*sizeof(double)); double *covar_array = (double *) Malloc(npack*npack*sizeof(double));
covar = (double **) Malloc(npack*sizeof(double *)); covar = (double **) Malloc(npack*sizeof(double *));
for ( int i = 0; i < npack; ++i ) covar[i] = covar_array + ((size_t)npack)*i; for ( size_t i = 0; i < npack; ++i ) covar[i] = covar_array + npack*i;
for ( int i = 0; i < npack; ++i ) for ( size_t i = 0; i < npack; ++i )
for ( int j = 0; j < npack; ++j ) covar[i][j] = 0; for ( size_t j = 0; j < npack; ++j ) covar[i][j] = 0;
eofdata[varID][levelID].covar_array = covar_array; eofdata[varID][levelID].covar_array = covar_array;
eofdata[varID][levelID].covar = covar; eofdata[varID][levelID].covar = covar;
...@@ -414,18 +414,16 @@ void *EOFs(void * argument) ...@@ -414,18 +414,16 @@ void *EOFs(void * argument)
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel for default(shared) #pragma omp parallel for default(shared)
#endif #endif
for ( int ipack = 0; ipack < npack; ++ipack ) for ( size_t ipack = 0; ipack < npack; ++ipack )
{ for ( size_t jpack = ipack; jpack < npack; ++jpack )
for ( int jpack = ipack; jpack < npack; ++jpack ) covar[ipack][jpack] += in[pack[ipack]] * in[pack[jpack]];
covar[ipack][jpack] += in[pack[ipack]] * in[pack[jpack]];
}
} }
else if ( time_space ) else if ( time_space )
{ {
double *data = (double *) Malloc(npack*sizeof(double)); double *data = (double *) Malloc(npack*sizeof(double));
eofdata[varID][levelID].data[tsID] = data; eofdata[varID][levelID].data[tsID] = data;
for ( int ipack = 0; ipack < npack; ipack++ ) for ( size_t ipack = 0; ipack < npack; ipack++ )
data[ipack] = in[pack[ipack]]; data[ipack] = in[pack[ipack]];
} }
...@@ -479,7 +477,7 @@ void *EOFs(void * argument) ...@@ -479,7 +477,7 @@ void *EOFs(void * argument)
double *eig_val = NULL; double *eig_val = NULL;
int nts_out = nts; int nts_out = nts;
if ( npack < nts ) nts_out = npack; if ( npack < (size_t)nts ) nts_out = npack;
for ( tsID = 0; tsID < nts_out; tsID++ ) for ( tsID = 0; tsID < nts_out; tsID++ )
{ {
...@@ -529,11 +527,11 @@ void *EOFs(void * argument) ...@@ -529,11 +527,11 @@ void *EOFs(void * argument)
covar = eofdata[varID][levelID].covar; covar = eofdata[varID][levelID].covar;
for ( int ipack = 0; ipack < npack; ++ipack ) for ( size_t ipack = 0; ipack < npack; ++ipack )
{ {
int j; size_t j;
int i = pack[ipack]; size_t i = pack[ipack];
for ( int jpack = 0; jpack < npack; ++jpack ) for ( size_t jpack = 0; jpack < npack; ++jpack )
{ {
if ( jpack < ipack ) if ( jpack < ipack )
{ {
...@@ -553,7 +551,7 @@ void *EOFs(void * argument) ...@@ -553,7 +551,7 @@ void *EOFs(void * argument)
else if ( time_space ) else if ( time_space )
{ {
if ( cdoVerbose ) if ( cdoVerbose )
cdoPrint("allocating covar with %i x %i elements | npack=%i", nts, nts, npack); cdoPrint("allocating covar with %i x %i elements | npack=%zu", nts, nts, npack);
covar_array = (double *) Malloc(nts*nts*sizeof(double)); covar_array = (double *) Malloc(nts*nts*sizeof(double));
covar = (double **) Malloc(nts*sizeof(double *)); covar = (double **) Malloc(nts*sizeof(double *));
...@@ -575,7 +573,7 @@ void *EOFs(void * argument) ...@@ -575,7 +573,7 @@ void *EOFs(void * argument)
{ {
double *df2p = data[j2]; double *df2p = data[j2];
double sum = 0; double sum = 0;
for ( int i = 0; i < npack; i++ ) for ( size_t i = 0; i < npack; i++ )
sum += weight[pack[i]]*df1p[i]*df2p[i]; sum += weight[pack[i]]*df1p[i]*df2p[i];
covar[j1][j2] = sum / sum_w / nts; covar[j1][j2] = sum / sum_w / nts;
} }
...@@ -599,7 +597,7 @@ void *EOFs(void * argument) ...@@ -599,7 +597,7 @@ void *EOFs(void * argument)
if ( cdoTimer ) timer_stop(timer_eig); if ( cdoTimer ) timer_stop(timer_eig);
/* NOW: covar contains the eigenvectors, eig_val the eigenvalues */ /* NOW: covar contains the eigenvectors, eig_val the eigenvalues */
for ( int i = 0; i < gridsize; ++i ) out[i] = missval; for ( size_t i = 0; i < gridsize; ++i ) out[i] = missval;
// for ( int i = 0; i < n; i++ ) eig_val[i] *= sum_w; // for ( int i = 0; i < n; i++ ) eig_val[i] *= sum_w;
} // first_call } // first_call
...@@ -615,7 +613,7 @@ void *EOFs(void * argument) ...@@ -615,7 +613,7 @@ void *EOFs(void * argument)
else if ( time_space ) scale_eigvec_time(out, tsID, nts, npack, pack, weight, covar, data, missval, sum_w); else if ( time_space ) scale_eigvec_time(out, tsID, nts, npack, pack, weight, covar, data, missval, sum_w);
nmiss = 0; nmiss = 0;
for ( int i = 0; i < gridsize; i++ ) if ( DBL_IS_EQUAL(out[i], missval) ) nmiss++; for ( size_t i = 0; i < gridsize; i++ ) if ( DBL_IS_EQUAL(out[i], missval) ) nmiss++;
pstreamDefRecord(streamID3, varID, levelID); pstreamDefRecord(streamID3, varID, levelID);
pstreamWriteRecord(streamID3, out, nmiss); pstreamWriteRecord(streamID3, out, nmiss);
......
...@@ -53,8 +53,10 @@ void *EOF3d(void * argument) ...@@ -53,8 +53,10 @@ void *EOF3d(void * argument)
size_t temp_size = 0, npack = 0; size_t temp_size = 0, npack = 0;
int varID, levelID; int varID, levelID;
int missval_warning = 0; int missval_warning = 0;
int nmiss, ngrids, n = 0, nlevs = 0; int nmiss, ngrids;
int offset; int n = 0;
size_t nlevs = 0;
size_t offset;
int timer_cov = 0, timer_eig = 0; int timer_cov = 0, timer_eig = 0;
int calendar = CALENDAR_STANDARD; int calendar = CALENDAR_STANDARD;
...@@ -88,31 +90,14 @@ void *EOF3d(void * argument) ...@@ -88,31 +90,14 @@ void *EOF3d(void * argument)
enum T_EIGEN_MODE eigen_mode = get_eigenmode(); enum T_EIGEN_MODE eigen_mode = get_eigenmode();
enum T_WEIGHT_MODE weight_mode = get_weightmode(); enum T_WEIGHT_MODE weight_mode = get_weightmode();
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int vlistID1 = pstreamInqVlist(streamID1);
int gridID1 = vlistInqVarGrid(vlistID1, 0);
long gridsize = vlistGridsizeMax(vlistID1);
int nvars = vlistNvars(vlistID1);
int nrecs;
double *weight = (double *) Malloc(gridsize*sizeof(double));
for ( int i = 0; i < gridsize; ++i ) weight[i] = 1.;
if ( weight_mode == WEIGHT_ON )
{
int wstatus = gridWeights(gridID1, weight);
if ( wstatus != 0 )
{
weight_mode = WEIGHT_OFF;
cdoWarning("Using constant grid cell area weights!");
}
}
/* eigenvalues */ /* eigenvalues */
if ( operfunc == EOF3D_SPATIAL ) if ( operfunc == EOF3D_SPATIAL )
cdoAbort("Operator not Implemented - use eof3d or eof3dtime instead"); cdoAbort("Operator not Implemented - use eof3d or eof3dtime instead");
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int vlistID1 = pstreamInqVlist(streamID1);
/* COUNT NUMBER OF TIMESTEPS if EOF3D_ or EOF3D_TIME */ /* COUNT NUMBER OF TIMESTEPS if EOF3D_ or EOF3D_TIME */
int nts = vlistNtsteps(vlistID1); int nts = vlistNtsteps(vlistID1);
if ( nts == -1 ) if ( nts == -1 )
...@@ -121,14 +106,15 @@ void *EOF3d(void * argument) ...@@ -121,14 +106,15 @@ void *EOF3d(void * argument)
while ( pstreamInqTimestep(streamID1, nts) ) nts++; while ( pstreamInqTimestep(streamID1, nts) ) nts++;
if ( cdoVerbose ) cdoPrint("Counted %i timeSteps", nts); if ( cdoVerbose ) cdoPrint("Counted %i timeSteps", nts);
pstreamClose(streamID1);
streamID1 = pstreamOpenRead(cdoStreamName(0));
vlistID1 = pstreamInqVlist(streamID1);
} }
else else
if ( cdoVerbose ) cdoPrint("Found %i timeSteps", nts); if ( cdoVerbose ) cdoPrint("Found %i timeSteps", nts);
pstreamClose(streamID1);
streamID1 = pstreamOpenRead(cdoStreamName(0));
vlistID1 = pstreamInqVlist(streamID1);
int taxisID1 = vlistInqTaxis(vlistID1); int taxisID1 = vlistInqTaxis(vlistID1);
/* reset the requested number of eigen-function to the maximum if neccessary */ /* reset the requested number of eigen-function to the maximum if neccessary */
...@@ -144,20 +130,29 @@ void *EOF3d(void * argument) ...@@ -144,20 +130,29 @@ void *EOF3d(void * argument)
if ( cdoVerbose ) cdoPrint("counted %i timesteps",n); if ( cdoVerbose ) cdoPrint("counted %i timesteps",n);
int nvars = vlistNvars(vlistID1);
int nrecs;
int gridID1 = vlistInqVarGrid(vlistID1, 0);
size_t gridsizemax = vlistGridsizeMax(vlistID1);
/* allocation of temporary fields and output structures */ /* allocation of temporary fields and output structures */
double *in = (double *) Malloc(gridsize*sizeof(double)); double *in = (double *) Malloc(gridsizemax*sizeof(double));
int **datacounts = (int **) Malloc<