Commit 571d4ebe authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

EOF: added function get_eigenmode()

parent 877ccef2
......@@ -31,6 +31,10 @@
//#define OLD_IMPLEMENTATION
#define WEIGHTS 1
#if defined(_OPENMP)
#include <omp.h>
#endif
#include <limits.h> // LONG_MAX
#include <cdi.h>
#include "cdo.h"
......@@ -39,8 +43,6 @@
#include "grid.h"
#include "statistic.h"
enum T_EIGEN_MODE {JACOBI, DANIELSON_LANCZOS};
// NO MISSING VALUE SUPPORT ADDED SO FAR
static
......@@ -114,6 +116,37 @@ void scale_eigvec_time(double *restrict out, int tsID, int nts, int npack, const
}
enum T_EIGEN_MODE get_eigenmode(void)
{
char *envstr = getenv("CDO_SVD_MODE");
enum T_EIGEN_MODE eigen_mode = JACOBI;
if ( envstr && !strncmp(envstr, "danielson_lanczos", 17) )
eigen_mode = DANIELSON_LANCZOS;
else if ( envstr && ! strncmp(envstr, "jacobi", 6) )
eigen_mode = JACOBI;
else if ( envstr ) {
cdoWarning("Unknown environmental setting %s for CDO_SVD_MODE. Available options are",envstr);
cdoWarning(" - 'jacobi' for a one-sided parallelized jacobi algorithm");
cdoWarning(" - 'danielson_lanzcos' for the D/L algorithm");
}
if ( cdoVerbose )
cdoPrint("Using CDO_SVD_MODE '%s' from %s",
eigen_mode==JACOBI?"jacobi":"danielson_lanczos",
envstr?"Environment":" default");
#if defined(_OPENMP)
if ( omp_get_max_threads() > 1 && eigen_mode == DANIELSON_LANCZOS ) {
cdoWarning("Requested parallel computation with %i Threads ",omp_get_max_threads());
cdoWarning(" but environmental setting CDO_SVD_MODE causes sequential ");
cdoWarning(" Singular value decomposition");
}
#endif
return eigen_mode;
}
void *EOFs(void * argument)
{
enum {EOF_, EOF_TIME, EOF_SPATIAL};
......@@ -162,25 +195,8 @@ void *EOFs(void * argument)
operatorInputArg("Number of eigen functions to write out");
int n_eig = parameter2int(operatorArgv()[0]);
char *envstr = getenv("CDO_SVD_MODE");
enum T_EIGEN_MODE eigen_mode = JACOBI;
if ( envstr && !strncmp(envstr, "danielson_lanczos", 17) )
eigen_mode = DANIELSON_LANCZOS;
else if ( envstr && ! strncmp(envstr, "jacobi", 6) )
eigen_mode = JACOBI;
else if ( envstr ) {
cdoWarning("Unknown environmental setting %s for CDO_SVD_MODE. Available options are",envstr);
cdoWarning(" - 'jacobi' for a one-sided parallelized jacobi algorithm");
cdoWarning(" - 'danielson_lanzcos' for the D/L algorithm");
envstr = NULL;
}
if ( cdoVerbose )
cdoPrint("Using CDO_SVD_MODE '%s' from %s",
eigen_mode==JACOBI?"jacobi":"danielson_lanczos",
envstr?"Environment":" default");
enum T_EIGEN_MODE eigen_mode = get_eigenmode();
int streamID1 = streamOpenRead(cdoStreamName(0));
int vlistID1 = streamInqVlist(streamID1);
......@@ -228,9 +244,9 @@ void *EOFs(void * argument)
streamClose(streamID1);
streamID1 = streamOpenRead(cdoStreamName(0));
vlistID1 = streamInqVlist(streamID1);
taxisID1 = vlistInqTaxis(vlistID1);
streamID1 = streamOpenRead(cdoStreamName(0));
vlistID1 = streamInqVlist(streamID1);
taxisID1 = vlistInqTaxis(vlistID1);
if ( nts < gridsize || operfunc == EOF_TIME )
{
......@@ -264,8 +280,7 @@ void *EOFs(void * argument)
}
else if ( grid_space )
{
if ( ((double)gridsize)*gridsize > (double)LONG_MAX )
cdoAbort("Grid space to large!");
if ( ((double)gridsize)*gridsize > (double)LONG_MAX ) cdoAbort("Grid space too large!");
if ( n_eig > gridsize )
{
......
......@@ -40,7 +40,7 @@
#include "statistic.h"
enum T_EIGEN_MODE {JACOBI, DANIELSON_LANCZOS};
enum T_EIGEN_MODE get_eigenmode(void);
#define WEIGHTS 1
......@@ -48,8 +48,6 @@ enum T_EIGEN_MODE {JACOBI, DANIELSON_LANCZOS};
void *EOF3d(void * argument)
{
char *envstr;
enum {EOF3D_, EOF3D_TIME, EOF3D_SPATIAL};
int temp_size = 0;
......@@ -71,8 +69,6 @@ void *EOF3d(void * argument)
double *xvals, *yvals, *zvals;
double *df1p, *df2p;
enum T_EIGEN_MODE eigen_mode = JACOBI;
if ( cdoTimer )
{
......@@ -91,28 +87,7 @@ void *EOF3d(void * argument)
operatorInputArg("Number of eigen functions to write out");
int n_eig = parameter2int(operatorArgv()[0]);
envstr = getenv("CDO_SVD_MODE");
if ( envstr &&! strncmp(envstr,"danielson_lanczos",17) )
eigen_mode = DANIELSON_LANCZOS;
else if ( envstr && ! strncmp(envstr,"jacobi",6) )
eigen_mode = JACOBI;
else if ( envstr ) {
cdoWarning("Unknown environmental setting %s for CDO_SVD_MODE. Available options are",envstr);
cdoWarning(" - 'jacobi' for a one-sided parallelized jacobi algorithm");
cdoWarning(" - 'danielson_lanzcos' for the D/L algorithm");
}
if ( cdoVerbose )
cdoPrint("Set eigen_mode to %s",eigen_mode == JACOBI? "jacobi" : "danielson_lanczos");
#if defined(_OPENMP)
if ( omp_get_max_threads() > 1 && eigen_mode == DANIELSON_LANCZOS ) {
cdoWarning("Requested parallel computation with %i Threads ",omp_get_max_threads());
cdoWarning(" but environmental setting CDO_SVD_MODE causes sequential ");
cdoWarning(" Singular value decomposition");
}
#endif
enum T_EIGEN_MODE eigen_mode = get_eigenmode();
int streamID1 = streamOpenRead(cdoStreamName(0));
int vlistID1 = streamInqVlist(streamID1);
......
......@@ -263,7 +263,7 @@ void *Specinfo(void *argument)
len = strlen(operatorArgv()[0]);
if ( (len+1) >= 128 ) cdoAbort("Parameter string to large!");
if ( (len+1) >= 128 ) cdoAbort("Parameter string too large!");
for ( i = 0; i < len; i++ ) arg[i] = toupper(operatorArgv()[0][i]);
arg[len] = 0;
......
......@@ -69,6 +69,7 @@ char *strdup(const char *s);
#define SET_DATE(dtstr, date, time) (sprintf(dtstr, "%*d%*d", DATE_LEN-6, date, 6, time))
#define DATE_IS_NEQ(dtstr1, dtstr2, len) (memcmp(dtstr1, dtstr2, len) != 0)
enum T_EIGEN_MODE {JACOBI, DANIELSON_LANCZOS};
#if defined(__xlC__) /* performance problems on IBM */
#ifndef DBL_IS_NAN
......
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