Commit 954d3800 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Simplify iegReadVar*().

parent 856099eb
......@@ -1214,61 +1214,19 @@ int iegInqTimestep(stream_t *streamptr, int tsID)
}
void iegReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
{
void *iegp = streamptr->record->exsep;
int vlistID = streamptr->vlistID;
int fileID = streamptr->fileID;
/* NOTE: tiles are not supported here! */
size_t nlevs = (size_t)streamptr->vars[varID].recordTable[0].nlevs;
double missval = vlistInqVarMissval(vlistID, varID);
int gridID = vlistInqVarGrid(vlistID, varID);
size_t gridsize = (size_t)gridInqSize(gridID);
size_t tsid = streamptr->curTsID;
if ( CDI_Debug )
Message("nlevs = %d gridID = %d gridsize = %d", nlevs, gridID, (int)gridsize);
off_t currentfilepos = fileGetPos(fileID);
for ( size_t levID = 0; levID < nlevs; levID++ )
{
/* NOTE: tiles are not supported here! */
int recID = streamptr->vars[varID].recordTable[0].recordID[levID];
off_t recpos = streamptr->tsteps[tsid].records[recID].position;
fileSetPos(fileID, recpos, SEEK_SET);
iegRead(fileID, iegp);
iegInqDataDP(iegp, &data[levID*gridsize]);
}
fileSetPos(fileID, currentfilepos, SEEK_SET);
*nmiss = 0;
for ( size_t i = 0; i < nlevs*gridsize; i++ )
if ( DBL_IS_EQUAL(data[i], missval) || DBL_IS_EQUAL(data[i], (float)missval) )
{
data[i] = missval;
(*nmiss)++;
}
}
void iegReadVarSliceDP(stream_t *streamptr, int varID, int levID, double *data, int *nmiss)
{
if ( CDI_Debug ) Message("streamID = %d varID = %d levID = %d", streamptr->self, varID, levID);
void *iegp = streamptr->record->exsep;
int vlistID = streamptr->vlistID;
int fileID = streamptr->fileID;
/* NOTE: tiles are not supported here! */
int nlevs = streamptr->vars[varID].recordTable[0].nlevs;
double missval = vlistInqVarMissval(vlistID, varID);
int gridID = vlistInqVarGrid(vlistID, varID);
int gridsize = gridInqSize(gridID);
double missval = vlistInqVarMissval(vlistID, varID);
int gridsize = gridInqSize(vlistInqVarGrid(vlistID, varID));
int tsid = streamptr->curTsID;
if ( CDI_Debug )
Message("nlevs = %d gridID = %d gridsize = %d", nlevs, gridID, gridsize);
off_t currentfilepos = fileGetPos(fileID);
/* NOTE: tiles are not supported here! */
......@@ -1290,6 +1248,19 @@ void iegReadVarSliceDP(stream_t *streamptr, int varID, int levID, double *data,
}
void iegReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
{
if ( CDI_Debug ) Message("streamID = %d varID = %d", streamptr->self, varID);
int vlistID = streamptr->vlistID;
size_t gridsize = (size_t) gridInqSize(vlistInqVarGrid(vlistID, varID));
size_t nlevs = (size_t) streamptr->vars[varID].recordTable[0].nlevs;
for ( size_t levID = 0; levID < nlevs; levID++)
iegReadVarSliceDP(streamptr, varID, (int)levID, &data[levID*gridsize], nmiss);
}
void iegWriteVarSliceDP(stream_t *streamptr, int varID, int levID, const double *data)
{
if ( CDI_Debug ) Message("streamID = %d varID = %d levID = %d", streamptr->self, varID, levID);
......@@ -1335,12 +1306,12 @@ void iegWriteVarDP(stream_t *streamptr, int varID, const double *data)
{
if ( CDI_Debug ) Message("streamID = %d varID = %d", streamptr->self, varID);
int vlistID = streamptr->vlistID;
int gridsize = gridInqSize(vlistInqVarGrid(vlistID, varID));
int nlevs = zaxisInqSize(vlistInqVarZaxis(vlistID, varID));
int vlistID = streamptr->vlistID;
size_t gridsize = (size_t) gridInqSize(vlistInqVarGrid(vlistID, varID));
size_t nlevs = (size_t) zaxisInqSize(vlistInqVarZaxis(vlistID, varID));
for ( int levID = 0; levID < nlevs; levID++ )
iegWriteVarSliceDP(streamptr, varID, levID, &data[levID*gridsize]);
for ( size_t levID = 0; levID < nlevs; levID++ )
iegWriteVarSliceDP(streamptr, varID, (int)levID, &data[levID*gridsize]);
}
#endif /* HAVE_LIBIEG */
......
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