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

added option --float

parent 872dfb34
# Process this file with automake to produce Makefile.in
SUBDIRS = libcdi src contrib test/data test
#
EXTRA_DIST=config/default OPERATORS doc/cdo.pdf doc/cdo_refcard.pdf cdo.spec README
EXTRA_DIST=config/default OPERATORS doc/cdo.pdf doc/cdo_eca.pdf doc/cdo_refcard.pdf cdo.spec README
#
ACLOCAL_AMFLAGS = -I m4
#
......
......@@ -379,7 +379,7 @@ top_srcdir = @top_srcdir@
# Process this file with automake to produce Makefile.in
SUBDIRS = libcdi src contrib test/data test
#
EXTRA_DIST = config/default OPERATORS doc/cdo.pdf doc/cdo_refcard.pdf cdo.spec README
EXTRA_DIST = config/default OPERATORS doc/cdo.pdf doc/cdo_eca.pdf doc/cdo_refcard.pdf cdo.spec README
#
ACLOCAL_AMFLAGS = -I m4
#
......
......@@ -80,10 +80,10 @@ void print_stat(const char *sinfo, int memtype, int datatype, int filetype, off_
void *CDIread(void *argument)
{
int memtype = MEMTYPE_DOUBLE;
int memtype = CDO_Memtype;
int streamID;
int tsID, varID, levelID;
int gridsize, i, nmiss;
int gridsize, nmiss;
int recID, nrecs;
int vlistID;
int filetype = -1, datatype = -1;
......@@ -99,13 +99,6 @@ void *CDIread(void *argument)
cdoInitialize(argument);
char *envstr = getenv("MEMTYPE");
if ( envstr )
{
if ( strcmp(envstr, "float") == 0 ) memtype = MEMTYPE_FLOAT;
else if ( strcmp(envstr, "double") == 0 ) memtype = MEMTYPE_DOUBLE;
}
if ( cdoVerbose ) cdoPrint("parameter: <nruns>");
if ( operatorArgc() > 1 ) cdoAbort("Too many arguments!");
......@@ -152,9 +145,8 @@ void *CDIread(void *argument)
if ( memtype == MEMTYPE_FLOAT )
{
cdoAbort("streamReadRecordF not implemented!");
// streamReadRecordF(streamID, farray, &nmiss);
for ( i = 0; i < gridsize; ++i ) darray[i] = farray[i];
streamReadRecordF(streamID, farray, &nmiss);
// for ( int i = 0; i < gridsize; ++i ) darray[i] = farray[i];
data_size += gridsize*4;
}
else
......
......@@ -91,7 +91,7 @@ void print_stat(const char *sinfo, int memtype, int datatype, int filetype, off_
void *CDIwrite(void *argument)
{
int memtype = MEMTYPE_DOUBLE;
int memtype = CDO_Memtype;
int nvars = 10, nlevs = 0, ntimesteps = 30;
const char *defaultgrid = "global_.2";
int streamID;
......@@ -116,13 +116,6 @@ void *CDIwrite(void *argument)
cdoInitialize(argument);
char *envstr = getenv("MEMTYPE");
if ( envstr )
{
if ( strcmp(envstr, "float") == 0 ) memtype = MEMTYPE_FLOAT;
else if ( strcmp(envstr, "double") == 0 ) memtype = MEMTYPE_DOUBLE;
}
if ( cdoVerbose ) cdoPrint("parameter: <nruns, <grid, <nlevs, <ntimesteps, <nvars>>>>>");
if ( operatorArgc() > 5 ) cdoAbort("Too many arguments!");
......
......@@ -1031,6 +1031,7 @@ int parse_options_long(int argc, char *argv[])
{ "remap_genweights", required_argument, &lremap_genweights, 1 },
{ "cmor", no_argument, &CDO_CMOR_Mode, 1 },
{ "reduce_dim", no_argument, &CDO_Reduce_Dim, 1 },
{ "float", no_argument, &CDO_Memtype, MEMTYPE_FLOAT },
{ "rusage", no_argument, &CDO_Rusage, 1 },
{ "no_warnings", no_argument, &_Verbose, 0 },
{ "format", required_argument, NULL, 'f' },
......
......@@ -1157,6 +1157,34 @@ void pstreamReadRecord(int pstreamID, double *data, int *nmiss)
}
void pstreamReadRecordF(int pstreamID, float *data, int *nmiss)
{
if ( data == NULL ) cdoAbort("Data pointer not allocated (pstreamReadRecord)!");
pstream_t *pstreamptr = pstream_to_pointer(pstreamID);
#if defined(HAVE_LIBPTHREAD)
if ( pstreamptr->ispipe )
{
cdoAbort("pipeReadRecord not implemented for memtype float!");
// pipeReadRecord(pstreamptr, data, nmiss);
}
else
#endif
{
if ( processNums() == 1 && ompNumThreads == 1 ) timer_start(timer_read);
#if defined(HAVE_LIBPTHREAD)
if ( cdoLockIO ) pthread_mutex_lock(&streamMutex);
#endif
streamReadRecordF(pstreamptr->fileID, data, nmiss);
#if defined(HAVE_LIBPTHREAD)
if ( cdoLockIO ) pthread_mutex_unlock(&streamMutex);
#endif
if ( processNums() == 1 && ompNumThreads == 1 ) timer_stop(timer_read);
}
}
void pstreamCheckDatarange(pstream_t *pstreamptr, int varID, double *array, int nmiss)
{
long i;
......
......@@ -36,6 +36,7 @@
#define streamInqRecord pstreamInqRecord
#define streamReadRecord pstreamReadRecord
#define streamReadRecordF pstreamReadRecordF
#define streamCopyRecord pstreamCopyRecord
......@@ -58,6 +59,7 @@ int pstreamInqTimestep(int pstreamID, int tsID);
int pstreamInqRecord(int pstreamID, int *varID, int *levelID);
void pstreamReadRecord(int pstreamID, double *data, int *nmiss);
void pstreamReadRecordF(int pstreamID, float *data, int *nmiss);
void pstreamCopyRecord(int pstreamIDdest, int pstreamIDsrc);
void pstreamInqGRIBinfo(int pstreamID, int *intnum, float *fltnum, off_t *bignum);
......
......@@ -85,6 +85,8 @@ int CDO_CMOR_Mode = FALSE;
int cdoDiag = FALSE;
int CDO_Memtype = MEMTYPE_DOUBLE;
int CDO_Reduce_Dim = FALSE;
int CDO_Append_History = TRUE;
int CDO_Reset_History = FALSE;
......
......@@ -45,6 +45,7 @@
extern char *Progname;
extern char *cdoGridSearchDir;
extern int CDO_Reduce_Dim;
extern int CDO_Memtype;
extern int CDO_Append_History;
extern int CDO_Reset_History;
extern int timer_read, timer_write; // refactor: both pstream.c and CDIread.c CDIwrite.c defined in cdo.c
......
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