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

Cleanup.

parent 847eb3eb
......@@ -31,8 +31,6 @@
#include "progress.h"
#include "cdo_options.h"
extern "C" int streamGrbInqDataScanningMode(void);
void *
Copy(void *process)
{
......@@ -56,15 +54,6 @@ Copy(void *process)
const auto SZIP = cdoOperatorAdd("szip", 0, 0, nullptr);
// clang-format on
#ifdef HIRLAM_EXTENSIONS
// KEEP in mind the difference between copy and selall with respect to
// unpacking and repacking the GRIB information! Especially when setting the
// DataScanningMode.
printf("cdo copy/selall : UNCHANGED_RECORD=%d\n", unchangedRecord());
// if (cdiGribDataScanningMode != -1) lcopy = false;
printf("cdo copy/selall : cdiGribDataScanningMode=%d; lcopy=%d\n", streamGrbInqDataScanningMode(), lcopy);
#endif //#ifdef HIRLAM_EXTENSIONS
const auto operatorID = cdoOperatorID();
if (operatorID == SZIP)
{
......@@ -164,11 +153,9 @@ Copy(void *process)
{
parIO.recID = recID;
parIO.nrecs = nrecs;
/* fprintf(stderr, "in1 streamID %d varID %d levelID
* %d\n", streamID1, varID, levelID);*/
// fprintf(stderr, "in1 streamID %d varID %d levelID %d\n", streamID1, varID, levelID);
parReadRecord(streamID1, &varID, &levelID, (double *) array, &nmiss, &parIO);
/* fprintf(stderr, "in2 streamID %d varID %d levelID
* %d\n", streamID1, varID, levelID);*/
// fprintf(stderr, "in2 streamID %d varID %d levelID %d\n", streamID1, varID, levelID);
}
else
{
......@@ -183,9 +170,8 @@ Copy(void *process)
cdoReadRecord(streamID1, (double *) array, &nmiss);
}
/*
if ( Options::cdoParIO )
fprintf(stderr, "out1 %d %d %d\n", streamID2, varID,
levelID);
if (Options::cdoParIO)
fprintf(stderr, "out1 %d %d %d\n", streamID2, varID, levelID);
*/
cdoDefRecord(streamID2, varID, levelID);
if (Options::CDO_Memtype == MemType::Float)
......@@ -193,9 +179,8 @@ Copy(void *process)
else
cdoWriteRecord(streamID2, (double *) array, nmiss);
/*
if ( Options::cdoParIO )
fprintf(stderr, "out2 %d %d %d\n", streamID2, varID,
levelID);
if (Options::cdoParIO)
fprintf(stderr, "out2 %d %d %d\n", streamID2, varID, levelID);
*/
}
}
......
......@@ -110,7 +110,6 @@ Merge(void *process)
{
int varID, levelID;
int nrecs = 0;
size_t nmiss;
cdoInitialize(process);
......@@ -121,7 +120,7 @@ Merge(void *process)
const auto streamCnt = cdoStreamCnt();
const auto nmerge = streamCnt - 1;
const char *ofilename = cdoGetStreamName(streamCnt - 1);
auto ofilename = cdoGetStreamName(streamCnt - 1);
if (!Options::cdoOverwriteMode && fileExists(ofilename) && !userFileOverwrite(ofilename))
cdoAbort("Outputfile %s already exists!", ofilename);
......@@ -261,6 +260,8 @@ Merge(void *process)
}
else
{
size_t nmiss;
if (Options::CDO_Memtype == MemType::Float)
cdoReadRecordF(streamID1, array_f.data(), &nmiss);
else
......
......@@ -64,13 +64,13 @@ CdoStream::getVlistID()
void
CdoStream::defVarList(int p_vlistID)
{
int filetype = m_filetype;
auto filetype = m_filetype;
if (m_vlistID != -1) cdoAbort("Internal problem, vlist already defined!");
if (m_varlist.size() != 0) cdoAbort("Internal problem, varlist already allocated!");
const int nvars = vlistNvars(p_vlistID);
const auto nvars = vlistNvars(p_vlistID);
assert(nvars > 0);
m_varlist.resize(nvars);
......@@ -88,7 +88,7 @@ CdoStream::defVarList(int p_vlistID)
const bool laddoffset = IS_NOT_EQUAL(m_varlist[varID].addoffset, 0);
const bool lscalefactor = IS_NOT_EQUAL(m_varlist[varID].scalefactor, 1);
int datatype = m_varlist[varID].datatype;
auto datatype = m_varlist[varID].datatype;
if (filetype == CDI_FILETYPE_NC || filetype == CDI_FILETYPE_NC2 || filetype == CDI_FILETYPE_NC4
|| filetype == CDI_FILETYPE_NC4C || filetype == CDI_FILETYPE_NC5)
......@@ -120,5 +120,5 @@ CdoStream::defVarList(int p_vlistID)
}
}
m_vlistID = p_vlistID; /* used for -r/-a */
m_vlistID = p_vlistID; // used for -r/-a
}
......@@ -51,13 +51,13 @@ public:
virtual void inqRecord(int *varID, int *levelID) = 0;
virtual void defRecord(int varID, int levelID) = 0;
virtual void readRecord(double *data, size_t *nmiss) = 0;
virtual void readRecord(float *p_data, size_t *nmiss) = 0;
virtual void readRecord(double *p_data, size_t *nmiss) = 0;
virtual void readRecord(Field *p_field, size_t *nmiss) = 0;
virtual void readRecord(float *data, size_t *nmiss) = 0;
virtual void writeRecord(double *data, size_t nmiss) = 0;
virtual void writeRecord(Field *data, size_t nmiss) = 0;
virtual void writeRecord(float *data, size_t nmiss) = 0;
virtual void writeRecord(float *p_data, size_t nmiss) = 0;
virtual void writeRecord(double *p_data, size_t nmiss) = 0;
virtual void writeRecord(Field *p_field, size_t nmiss) = 0;
virtual void copyRecord(CdoStreamID dest) = 0;
......@@ -86,7 +86,7 @@ public:
int m_vlistID;
int m_tsID;
int m_varID; /* next varID defined with streamDefVar */
int m_varID; // next varID defined with streamDefVar
// to be removed or to be moved to FileStream! // some operators need some refactoring for these to be able to be moved
int m_fileID;
......
......@@ -198,31 +198,39 @@ FileStream::defRecord(int varID, int levelID)
}
void
FileStream::readRecord(double *data, size_t *nmiss)
FileStream::readRecord(float *p_data, size_t *nmiss)
{
if (FileStream::timersEnabled()) timer_start(timer_read);
streamReadrecordDoubleLocked(m_fileID, data, nmiss);
streamReadrecordFloatLocked(m_fileID, p_data, nmiss);
if (FileStream::timersEnabled()) timer_stop(timer_read);
}
void
FileStream::readRecord(Field *data, size_t *nmiss)
FileStream::readRecord(double *p_data, size_t *nmiss)
{
readRecord(data->vec.data(), nmiss);
if (FileStream::timersEnabled()) timer_start(timer_read);
streamReadrecordDoubleLocked(m_fileID, p_data, nmiss);
if (FileStream::timersEnabled()) timer_stop(timer_read);
}
void
FileStream::readRecord(float *data, size_t *nmiss)
FileStream::readRecord(Field *p_field, size_t *nmiss)
{
if (FileStream::timersEnabled()) timer_start(timer_read);
streamReadrecordFloatLocked(m_fileID, data, nmiss);
if (FileStream::timersEnabled()) timer_stop(timer_read);
readRecord(p_field->vec.data(), nmiss);
}
void
FileStream::writeRecord(float *p_data, size_t p_nmiss)
{
if (FileStream::timersEnabled()) timer_start(timer_write);
streamWriteRecordFloatLocked(m_fileID, p_data, p_nmiss);
if (FileStream::timersEnabled()) timer_stop(timer_write);
}
void
FileStream::writeRecord(double *p_data, size_t p_nmiss)
{
int varID = m_varID;
auto varID = m_varID;
if (FileStream::timersEnabled()) timer_start(timer_write);
if (varID < (int) m_varlist.size())
......@@ -234,17 +242,9 @@ FileStream::writeRecord(double *p_data, size_t p_nmiss)
}
void
FileStream::writeRecord(Field *p_data, size_t p_nmiss)
{
writeRecord(p_data->vec.data(), p_nmiss);
}
void
FileStream::writeRecord(float *p_data, size_t p_nmiss)
FileStream::writeRecord(Field *p_field, size_t p_nmiss)
{
if (FileStream::timersEnabled()) timer_start(timer_write);
streamWriteRecordFloatLocked(m_fileID, p_data, p_nmiss);
if (FileStream::timersEnabled()) timer_stop(timer_write);
writeRecord(p_field->vec.data(), p_nmiss);
}
void
......
......@@ -39,13 +39,13 @@ public:
void inqRecord(int *varID, int *levelID) override;
void defRecord(int varID, int levelID) override;
void readRecord(double *data, size_t *nmiss) override;
void readRecord(Field *data, size_t *nmiss) override;
void readRecord(float *data, size_t *nmiss) override;
void readRecord(float *p_data, size_t *nmiss) override;
void readRecord(double *p_data, size_t *nmiss) override;
void readRecord(Field *p_field, size_t *nmiss) override;
void writeRecord(double *data, size_t nmiss) override;
void writeRecord(Field *data, size_t nmiss) override;
void writeRecord(float *data, size_t nmiss) override;
void writeRecord(float *p_data, size_t nmiss) override;
void writeRecord(double *p_data, size_t nmiss) override;
void writeRecord(Field *p_field, size_t nmiss) override;
void copyRecord(CdoStreamID p_fileStream) override;
......
......@@ -28,25 +28,19 @@
void *
readRecord(void *arg)
{
CdoStreamID streamID;
int *varID, *levelID;
size_t *nmiss;
double *array;
read_arg_t *read_arg = (read_arg_t *) arg;
streamID = read_arg->streamID;
varID = read_arg->varID;
levelID = read_arg->levelID;
nmiss = read_arg->nmiss;
array = read_arg->array;
/* fprintf(stderr, "cdoInqRecord: streamID = %d\n", streamID); */
cdoInqRecord(streamID, varID, levelID);
cdoReadRecord(streamID, array, nmiss);
/* fprintf(stderr, "cdoReadRecord: varID %d levelID %d\n", *varID,
* *levelID); */
return (nullptr);
auto *read_arg = (read_arg_t *) arg;
auto streamID = read_arg->streamID;
auto p_varID = read_arg->varID;
auto p_levelID = read_arg->levelID;
auto p_nmiss = read_arg->nmiss;
auto p_array = read_arg->array;
// fprintf(stderr, "readRecord: streamID = %d\n", streamID);
cdoInqRecord(streamID, p_varID, p_levelID);
cdoReadRecord(streamID, p_array, p_nmiss);
// fprintf(stderr, "readRecord: varID %d levelID %d\n", *p_varID, *p_levelID);
return nullptr;
}
void
......@@ -56,7 +50,7 @@ parReadRecord(CdoStreamID streamID, int *varID, int *levelID, double *array, siz
int recID = 0, nrecs = 0;
#ifdef HAVE_LIBPTHREAD
pthread_t thrID = 0;
/* pthread_attr_t attr; */
// pthread_attr_t attr;
int rval;
if (parIO)
......@@ -82,16 +76,14 @@ parReadRecord(CdoStreamID streamID, int *varID, int *levelID, double *array, siz
#ifdef HAVE_LIBPTHREAD
else
{
/* fprintf(stderr, "parIO1: %ld streamID %d %d %d\n", (long)thrID,
* streamID, recID, nrecs); */
// fprintf(stderr, "parIO1: %ld streamID %d %d %d\n", (long)thrID, streamID, recID, nrecs);
rval = pthread_join(thrID, nullptr);
if (rval != 0) cdoAbort("pthread_join failed!");
*varID = parIO->varID;
*levelID = parIO->levelID;
*nmiss = parIO->nmiss;
/* fprintf(stderr, "parIO2: %ld streamID %d %d %d\n", (long)thrID,
* streamID, *varID, *levelID); */
// fprintf(stderr, "parIO2: %ld streamID %d %d %d\n", (long)thrID, streamID, *varID, *levelID);
arrayCopy(parIO->array_size, parIO->array, array);
}
......@@ -112,12 +104,11 @@ parReadRecord(CdoStreamID streamID, int *varID, int *levelID, double *array, siz
read_arg->nmiss = &parIO->nmiss;
read_arg->array = parIO->array;
/* fprintf(stderr, "pthread_create: streamID %d %d\n",
* read_arg->streamID,streamID); */
// fprintf(stderr, "pthread_create: streamID %d %d\n", read_arg->streamID,streamID);
rval = pthread_create(&thrID, &parIO->attr, readRecord, read_arg);
if (rval != 0) cdoAbort("pthread_create failed!");
/* fprintf(stderr, "thrID = %ld\n", (long) thrID); */
// fprintf(stderr, "thrID = %ld\n", (long) thrID);
parIO->thrID = thrID;
}
else
......
......@@ -106,13 +106,13 @@ PipeStream::readRecord(Field *p_field, size_t *p_nmiss)
}
void
PipeStream::writeRecord(double *p_data, size_t p_nmiss)
PipeStream::writeRecord(float *p_data, size_t p_nmiss)
{
m_pipe->pipeWriteRecord(p_data, p_nmiss);
}
void
PipeStream::writeRecord(float *p_data, size_t p_nmiss)
PipeStream::writeRecord(double *p_data, size_t p_nmiss)
{
m_pipe->pipeWriteRecord(p_data, p_nmiss);
}
......
......@@ -45,13 +45,13 @@ public:
void inqRecord(int *varID, int *levelID);
void defRecord(int varID, int levelID);
void readRecord(double *data, size_t *nmiss);
void readRecord(float *data, size_t *nmiss);
void readRecord(Field *data, size_t *nmiss);
void readRecord(float *p_data, size_t *nmiss);
void readRecord(double *p_data, size_t *nmiss);
void readRecord(Field *p_field, size_t *nmiss);
void writeRecord(double *data, size_t nmiss);
void writeRecord(float *data, size_t nmiss);
void writeRecord(Field *data, size_t nmiss);
void writeRecord(float *p_data, size_t nmiss);
void writeRecord(double *p_data, size_t nmiss);
void writeRecord(Field *p_field, size_t nmiss);
void copyRecord(CdoStreamID p_fileStream);
......
......@@ -365,7 +365,7 @@ genind(int *nx, const double *restrict plev, const T *restrict fullp, long ngp,
}
}
// Explicit instantiation.
// Explicit instantiation
template void genind(int *nx, const double *plev, const float *fullp, long ngp, long nplev, long nhlev);
template void genind(int *nx, const double *plev, const double *fullp, long ngp, long nplev, long nhlev);
......@@ -393,6 +393,6 @@ genindmiss(int *nx, const double *restrict plev, int ngp, int nplev, const T *re
} /* genindmiss */
// Explicit instantiation.
// Explicit instantiation
template void genindmiss(int *nx, const double *plev, int ngp, int nplev, const float *ps_prog, size_t *pnmiss);
template void genindmiss(int *nx, const double *plev, int ngp, int nplev, const double *ps_prog, size_t *pnmiss);
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