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

Added function streamScanInitRecords().

parent 57b83191
......@@ -867,7 +867,7 @@ int cgribexScanTimestep1(stream_t *streamptr)
int vlistID = streamptr->vlistID;
vlistDefTaxis(vlistID, taxisID);
streamScanResizeRecords(streamptr);
streamScanResizeRecords1(streamptr);
streamptr->record->buffer = gribbuffer;
streamptr->record->buffersize = buffersize;
......@@ -1106,14 +1106,9 @@ int cgribexScanTimestep(stream_t * streamptr)
cdi_create_records(streamptr, tsID);
nrecs = streamptr->tsteps[1].nrecs;
nrecs = streamScanInitRecords(streamptr, tsID);
streamptr->tsteps[tsID].nrecs = nrecs;
streamptr->tsteps[tsID].recIDs = (int *) Malloc((size_t)nrecs * sizeof (int));
for ( recID = 0; recID < nrecs; recID++ )
streamptr->tsteps[tsID].recIDs[recID] = streamptr->tsteps[1].recIDs[recID];
int fileID = streamptr->fileID;
const int fileID = streamptr->fileID;
fileSetPos(fileID, streamptr->tsteps[tsID].position, SEEK_SET);
......@@ -1202,7 +1197,7 @@ int cgribexScanTimestep(stream_t * streamptr)
for ( vrecID = 0; vrecID < nrecs; vrecID++ )
{
recID = streamptr->tsteps[1].recIDs[vrecID];
recID = streamptr->tsteps[1].recIDs[vrecID];
if ( cgribexVarCompare(compVar, streamptr->tsteps[tsID].records[recID], 0) == 0 ) break;
}
......@@ -1261,7 +1256,7 @@ int cgribexScanTimestep(stream_t * streamptr)
for ( vrecID = 0; vrecID < nrecs; vrecID++ )
{
recID = streamptr->tsteps[tsID].recIDs[vrecID];
recID = streamptr->tsteps[tsID].recIDs[vrecID];
if ( ! streamptr->tsteps[tsID].records[recID].used ) break;
}
......
......@@ -296,7 +296,7 @@ void extScanTimestep1(stream_t *streamptr)
vlist_check_contents(vlistID);
streamScanResizeRecords(streamptr);
streamScanResizeRecords1(streamptr);
streamScanTsFixNtsteps(streamptr, recpos);
streamScanTimeConstAdjust(streamptr, taxis);
......@@ -446,26 +446,20 @@ long extScanTimestep(stream_t *streamptr)
{
int header[4];
off_t recpos = 0;
int recID;
int nrecs = 0;
extcompvar_t compVar, compVar0;
void *extp = streamptr->record->exsep;
int tsID = streamptr->rtsteps;
int tsID = streamptr->rtsteps;
taxis_t *taxis = &streamptr->tsteps[tsID].taxis;
if ( streamptr->tsteps[tsID].recordSize == 0 )
{
cdi_create_records(streamptr, tsID);
nrecs = streamptr->tsteps[1].nrecs;
streamptr->tsteps[tsID].nrecs = nrecs;
streamptr->tsteps[tsID].recIDs = (int *) Malloc((size_t)nrecs * sizeof (int));
for ( recID = 0; recID < nrecs; recID++ )
streamptr->tsteps[tsID].recIDs[recID] = streamptr->tsteps[1].recIDs[recID];
nrecs = streamScanInitRecords(streamptr, tsID);
int fileID = streamptr->fileID;
const int fileID = streamptr->fileID;
fileSetPos(fileID, streamptr->tsteps[tsID].position, SEEK_SET);
......@@ -492,7 +486,7 @@ long extScanTimestep(stream_t *streamptr)
// if ( rindex == nrecs ) break; gcc-4.5 internal compiler error
if ( rindex == nrecs ) continue;
recID = streamptr->tsteps[tsID].recIDs[rindex];
const int recID = streamptr->tsteps[tsID].recIDs[rindex];
if ( rindex == 0 )
{
......@@ -582,7 +576,7 @@ void extReadVarSliceDP(stream_t *streamptr, int varID, int levID, double *data,
/* NOTE: tiles are not supported here! */
double missval = vlistInqVarMissval(vlistID, varID);
size_t gridsize = gridInqSize(vlistInqVarGrid(vlistID, varID));
int tsid = streamptr->curTsID;
int tsid = streamptr->curTsID;
off_t currentfilepos = fileGetPos(fileID);
......
......@@ -1050,7 +1050,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
int vlistID = streamptr->vlistID;
vlistDefTaxis(vlistID, taxisID);
streamScanResizeRecords(streamptr);
streamScanResizeRecords1(streamptr);
streamptr->record->buffer = gribbuffer;
streamptr->record->buffersize = buffersize;
......@@ -1270,7 +1270,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
int gribapiScanTimestep(stream_t * streamptr)
{
int vrecID, recID;
int vrecID, recID = -1;
//bool warn_numavg = true;
int nrecs = 0;
int vlistID = streamptr->vlistID;
......@@ -1285,14 +1285,9 @@ int gribapiScanTimestep(stream_t * streamptr)
cdi_create_records(streamptr, tsID);
nrecs = streamptr->tsteps[1].nrecs;
nrecs = streamScanInitRecords(streamptr, tsID);
streamptr->tsteps[tsID].nrecs = nrecs;
streamptr->tsteps[tsID].recIDs = (int *) Malloc((size_t)nrecs*sizeof(int));
for ( recID = 0; recID < nrecs; recID++ )
streamptr->tsteps[tsID].recIDs[recID] = streamptr->tsteps[1].recIDs[recID];
int fileID = streamptr->fileID;
const int fileID = streamptr->fileID;
fileSetPos(fileID, streamptr->tsteps[tsID].position, SEEK_SET);
......@@ -1394,7 +1389,7 @@ int gribapiScanTimestep(stream_t * streamptr)
for ( vrecID = 0; vrecID < nrecs; vrecID++ )
{
recID = streamptr->tsteps[1].recIDs[vrecID];
recID = streamptr->tsteps[1].recIDs[vrecID];
if ( gribapiVarCompare(compVar, streamptr->tsteps[tsID].records[recID], 0) == 0 ) break;
}
......
......@@ -763,7 +763,7 @@ void iegScanTimestep1(stream_t *streamptr)
vlist_check_contents(vlistID);
streamScanResizeRecords(streamptr);
streamScanResizeRecords1(streamptr);
streamScanTsFixNtsteps(streamptr, recpos);
streamScanTimeConstAdjust(streamptr, taxis);
......@@ -937,14 +937,9 @@ long iegScanTimestep(stream_t *streamptr)
{
cdi_create_records(streamptr, tsID);
nrecs = streamptr->tsteps[1].nrecs;
nrecs = streamScanInitRecords(streamptr, tsID);
streamptr->tsteps[tsID].nrecs = nrecs;
streamptr->tsteps[tsID].recIDs = (int *) Malloc((size_t)nrecs * sizeof (int));
for ( int recID = 0; recID < nrecs; recID++ )
streamptr->tsteps[tsID].recIDs[recID] = streamptr->tsteps[1].recIDs[recID];
int fileID = streamptr->fileID;
const int fileID = streamptr->fileID;
fileSetPos(fileID, streamptr->tsteps[tsID].position, SEEK_SET);
......@@ -972,7 +967,7 @@ long iegScanTimestep(stream_t *streamptr)
// if ( rindex == nrecs ) break; gcc-4.5 internal compiler error
if ( rindex == nrecs ) continue;
int recID = streamptr->tsteps[tsID].recIDs[rindex];
const int recID = streamptr->tsteps[tsID].recIDs[rindex];
if ( rindex == 0 )
{
......
......@@ -2,6 +2,23 @@
#include "stream_scan.h"
void streamScanResizeRecords1(stream_t *streamptr)
{
const int nrecords = streamptr->tsteps[0].nallrecs;
if (nrecords < streamptr->tsteps[0].recordSize)
{
streamptr->tsteps[0].recordSize = nrecords;
streamptr->tsteps[0].records =
(record_t *) Realloc(streamptr->tsteps[0].records, (size_t)nrecords*sizeof(record_t));
}
streamptr->tsteps[0].recIDs = (int *) Malloc((size_t)nrecords*sizeof(int));
streamptr->tsteps[0].nrecs = nrecords;
for (int recID = 0; recID < nrecords; ++recID)
streamptr->tsteps[0].recIDs[recID] = recID;
}
int streamScanInitRecords2(stream_t *streamptr)
{
const int nrecords = streamptr->tsteps[1].nallrecs;
......@@ -21,20 +38,15 @@ int streamScanInitRecords2(stream_t *streamptr)
}
void streamScanResizeRecords(stream_t *streamptr)
int streamScanInitRecords(stream_t *streamptr, int tsID)
{
const int nrecords = streamptr->tsteps[0].nallrecs;
if (nrecords < streamptr->tsteps[0].recordSize)
{
streamptr->tsteps[0].recordSize = nrecords;
streamptr->tsteps[0].records =
(record_t *) Realloc(streamptr->tsteps[0].records, (size_t)nrecords*sizeof(record_t));
}
const nrecs = streamptr->tsteps[1].nrecs;
streamptr->tsteps[0].recIDs = (int *) Malloc((size_t)nrecords*sizeof(int));
streamptr->tsteps[0].nrecs = nrecords;
for (int recID = 0; recID < nrecords; ++recID)
streamptr->tsteps[0].recIDs[recID] = recID;
streamptr->tsteps[tsID].nrecs = nrecs;
streamptr->tsteps[tsID].recIDs = (int *) Malloc((size_t)nrecs*sizeof(int));
for (int recID = 0; recID < nrecs; ++recID)
streamptr->tsteps[tsID].recIDs[recID] = streamptr->tsteps[1].recIDs[recID];
}
......
......@@ -3,8 +3,9 @@
#include "cdi_int.h"
void streamScanResizeRecords1(stream_t *streamptr);
int streamScanInitRecords2(stream_t *streamptr);
void streamScanResizeRecords(stream_t *streamptr);
int streamScanInitRecords(stream_t *streamptr, int tsID);
void streamScanTimeConstAdjust(stream_t *streamptr, const taxis_t *taxis);
void streamScanTsFixNtsteps(stream_t *streamptr, off_t recpos);
......
......@@ -291,7 +291,7 @@ void srvScanTimestep1(stream_t *streamptr)
vlist_check_contents(vlistID);
streamScanResizeRecords(streamptr);
streamScanResizeRecords1(streamptr);
streamScanTsFixNtsteps(streamptr, recpos);
streamScanTimeConstAdjust(streamptr, taxis);
......@@ -441,7 +441,6 @@ long srvScanTimestep(stream_t *streamptr)
{
int header[8];
off_t recpos = 0;
int recID;
int nrecs = 0;
void *srvp = streamptr->record->exsep;
......@@ -452,14 +451,9 @@ long srvScanTimestep(stream_t *streamptr)
{
cdi_create_records(streamptr, tsID);
nrecs = streamptr->tsteps[1].nrecs;
nrecs = streamScanInitRecords(streamptr, tsID);
streamptr->tsteps[tsID].nrecs = nrecs;
streamptr->tsteps[tsID].recIDs = (int *) Malloc((size_t)nrecs * sizeof (int));
for ( recID = 0; recID < nrecs; recID++ )
streamptr->tsteps[tsID].recIDs[recID] = streamptr->tsteps[1].recIDs[recID];
int fileID = streamptr->fileID;
const int fileID = streamptr->fileID;
fileSetPos(fileID, streamptr->tsteps[tsID].position, SEEK_SET);
......@@ -487,7 +481,7 @@ long srvScanTimestep(stream_t *streamptr)
// if ( rindex == nrecs ) break; gcc-4.5 internal compiler error
if ( rindex == nrecs ) continue;
recID = streamptr->tsteps[tsID].recIDs[rindex];
const int recID = streamptr->tsteps[tsID].recIDs[rindex];
if ( rindex == 0 )
{
......
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