Commit 0244ea24 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Renamed streamXXX() to pstreamXXX().

parent cfd743e4
......@@ -58,9 +58,9 @@ void *FC(void *argument)
int operatorID = cdoOperatorID();
int streamID1 = streamOpenRead(cdoStreamName(0));
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int vlistID1 = streamInqVlist(streamID1);
int vlistID1 = pstreamInqVlist(streamID1);
int vlistID2 = vlistDuplicate(vlistID1);
int taxisID1 = vlistInqTaxis(vlistID1);
......@@ -232,9 +232,9 @@ void *FC(void *argument)
if ( gridID1 != -1 ) vlistChangeGrid(vlistID2, gridID1, gridID2);
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
int streamID2 = pstreamOpenWrite(cdoStreamName(1), cdoFiletype());
streamDefVlist(streamID2, vlistID2);
pstreamDefVlist(streamID2, vlistID2);
int gridsize = vlistGridsizeMax(vlistID1);
double *array1 = (double*) Malloc(gridsize*sizeof(double));
......@@ -246,19 +246,19 @@ void *FC(void *argument)
}
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
while ( (nrecs = pstreamInqTimestep(streamID1, tsID)) )
{
taxisCopyTimestep(taxisID2, taxisID1);
streamDefTimestep(streamID2, tsID);
pstreamDefTimestep(streamID2, tsID);
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
pstreamInqRecord(streamID1, &varID, &levelID);
if ( vars[varID] )
{
streamReadRecord(streamID1, array1, &nmiss);
pstreamReadRecord(streamID1, array1, &nmiss);
if ( nmiss ) cdoAbort("Missing values unsupported for spectral/fourier data!");
gridID1 = vlistInqVarGrid(vlistID1, varID);
......@@ -271,28 +271,29 @@ void *FC(void *argument)
else if ( operatorID == GP2FC )
grid2four(sptrans, gridID1, array1, gridID2, array2);
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, array2, nmiss);
pstreamDefRecord(streamID2, varID, levelID);
pstreamWriteRecord(streamID2, array2, nmiss);
}
else
{
streamDefRecord(streamID2, varID, levelID);
pstreamDefRecord(streamID2, varID, levelID);
if ( lcopy )
{
streamCopyRecord(streamID2, streamID1);
pstreamCopyRecord(streamID2, streamID1);
}
else
{
streamReadRecord(streamID1, array1, &nmiss);
streamWriteRecord(streamID2, array1, nmiss);
pstreamReadRecord(streamID1, array1, &nmiss);
pstreamWriteRecord(streamID2, array1, nmiss);
}
}
}
tsID++;
}
streamClose(streamID2);
streamClose(streamID1);
pstreamClose(streamID2);
pstreamClose(streamID1);
if ( array2 ) Free(array2);
if ( array1 ) Free(array1);
......
......@@ -28,7 +28,6 @@
#include "cdo_int.h"
#include "pstream.h"
#include "grid.h"
#include "util.h"
void cdo_print_zaxis(int zaxisID);
......@@ -121,7 +120,7 @@ void printSource(FILE *fp, int vlistID, int varID)
static
void partab(FILE *fp, int streamID, int option)
{
int vlistID = streamInqVlist(streamID);
int vlistID = pstreamInqVlist(streamID);
int varID, datatype = -1;
char pstr[32];
char paramstr[32];
......@@ -250,7 +249,7 @@ static
void filedes(int streamID)
{
printf("\n");
int filetype = streamInqFiletype(streamID);
int filetype = pstreamInqFiletype(streamID);
switch ( filetype )
{
case CDI_FILETYPE_GRB: printf(" GRIB data\n"); break;
......@@ -271,11 +270,12 @@ void filedes(int streamID)
case CDI_FILETYPE_EXT:
case CDI_FILETYPE_IEG:
{
switch ( streamInqByteorder(streamID) )
int byteorder = pstreamInqByteorder(streamID);
switch ( byteorder )
{
case CDI_BIGENDIAN: printf(" byteorder is BIGENDIAN\n"); break;
case CDI_LITTLEENDIAN: printf(" byteorder is LITTLEENDIAN\n"); break;
default: printf(" byteorder %d undefined\n", streamInqByteorder(streamID)); break;
default: printf(" byteorder %d undefined\n", byteorder); break;
}
}
}
......@@ -302,9 +302,9 @@ void *Filedes(void *argument)
int operatorID = cdoOperatorID();
int streamID = streamOpenRead(cdoStreamName(0));
int streamID = pstreamOpenRead(cdoStreamName(0));
int vlistID = streamInqVlist(streamID);
int vlistID = pstreamInqVlist(streamID);
int nvars = vlistNvars(vlistID);
int ngrids = vlistNgrids(vlistID);
......@@ -411,7 +411,7 @@ void *Filedes(void *argument)
filedes(streamID);
}
streamClose(streamID);
pstreamClose(streamID);
cdoFinish();
......
......@@ -467,18 +467,18 @@ void *Fillmiss(void *argument)
cdoAbort("Too many arguments!");
}
int streamID1 = streamOpenRead(cdoStreamName(0));
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int vlistID1 = streamInqVlist(streamID1);
int vlistID1 = pstreamInqVlist(streamID1);
int vlistID2 = vlistDuplicate(vlistID1);
int taxisID1 = vlistInqTaxis(vlistID1);
int taxisID2 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID2, taxisID2);
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
int streamID2 = pstreamOpenWrite(cdoStreamName(1), cdoFiletype());
streamDefVlist(streamID2, vlistID2);
pstreamDefVlist(streamID2, vlistID2);
int gridsize = vlistGridsizeMax(vlistID1);
......@@ -489,23 +489,23 @@ void *Fillmiss(void *argument)
field2.ptr = (double*) Malloc(gridsize*sizeof(double));
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
while ( (nrecs = pstreamInqTimestep(streamID1, tsID)) )
{
taxisCopyTimestep(taxisID2, taxisID1);
streamDefTimestep(streamID2, tsID);
pstreamDefTimestep(streamID2, tsID);
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
streamReadRecord(streamID1, field1.ptr, &nmiss);
pstreamInqRecord(streamID1, &varID, &levelID);
pstreamReadRecord(streamID1, field1.ptr, &nmiss);
field1.nmiss = (size_t) nmiss;
streamDefRecord(streamID2, varID, levelID);
pstreamDefRecord(streamID2, varID, levelID);
if ( field1.nmiss == 0 )
{
streamWriteRecord(streamID2, field1.ptr, 0);
pstreamWriteRecord(streamID2, field1.ptr, 0);
}
else
{
......@@ -529,14 +529,14 @@ void *Fillmiss(void *argument)
for ( int i = 0; i < gridsize; ++i )
if ( DBL_IS_EQUAL(field2.ptr[i], field2.missval) ) nmiss++;
streamWriteRecord(streamID2, field2.ptr, nmiss);
pstreamWriteRecord(streamID2, field2.ptr, nmiss);
}
}
tsID++;
}
streamClose(streamID2);
streamClose(streamID1);
pstreamClose(streamID2);
pstreamClose(streamID1);
if ( field2.ptr ) Free(field2.ptr);
if ( field1.ptr ) Free(field1.ptr);
......
......@@ -24,7 +24,7 @@
*/
#if defined(HAVE_CONFIG_H)
# include "config.h"
#include "config.h"
#endif
......@@ -166,9 +166,9 @@ void *Filter(void *argument)
if ( cdoVerbose && !use_fftw ) cdoPrint("Using intrinsic FFT function!");
int streamID1 = streamOpenRead(cdoStreamName(0));
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int vlistID1 = streamInqVlist(streamID1);
int vlistID1 = pstreamInqVlist(streamID1);
int vlistID2 = vlistDuplicate(vlistID1);
int taxisID1 = vlistInqTaxis(vlistID1);
......@@ -180,7 +180,7 @@ void *Filter(void *argument)
int nvars = vlistNvars(vlistID1);
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
while ( (nrecs = pstreamInqTimestep(streamID1, tsID)) )
{
if ( tsID >= nalloc )
{
......@@ -194,11 +194,11 @@ void *Filter(void *argument)
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
pstreamInqRecord(streamID1, &varID, &levelID);
int gridID = vlistInqVarGrid(vlistID1, varID);
int gridsize = gridInqSize(gridID);
vars[tsID][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
streamReadRecord(streamID1, vars[tsID][varID][levelID].ptr, &nmiss);
pstreamReadRecord(streamID1, vars[tsID][varID][levelID].ptr, &nmiss);
vars[tsID][varID][levelID].nmiss = nmiss;
if ( nmiss ) cdoAbort("Missing value support for operators in module Filter not added yet!");
}
......@@ -381,14 +381,14 @@ void *Filter(void *argument)
Free(ompmem);
}
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
int streamID2 = pstreamOpenWrite(cdoStreamName(1), cdoFiletype());
streamDefVlist(streamID2, vlistID2);
pstreamDefVlist(streamID2, vlistID2);
for ( int tsID = 0; tsID < nts; tsID++ )
{
dtlist_taxisDefTimestep(dtlist, taxisID2, tsID);
streamDefTimestep(streamID2, tsID);
pstreamDefTimestep(streamID2, tsID);
for ( int varID = 0; varID < nvars; varID++ )
{
......@@ -398,8 +398,8 @@ void *Filter(void *argument)
if ( vars[tsID][varID][levelID].ptr )
{
int nmiss = vars[tsID][varID][levelID].nmiss;
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, vars[tsID][varID][levelID].ptr, nmiss);
pstreamDefRecord(streamID2, varID, levelID);
pstreamWriteRecord(streamID2, vars[tsID][varID][levelID].ptr, nmiss);
Free(vars[tsID][varID][levelID].ptr);
vars[tsID][varID][levelID].ptr = NULL;
......@@ -414,8 +414,8 @@ void *Filter(void *argument)
dtlist_delete(dtlist);
streamClose(streamID2);
streamClose(streamID1);
pstreamClose(streamID2);
pstreamClose(streamID1);
cdoFinish();
......
......@@ -41,11 +41,11 @@ void *Fldrms(void *argument)
bool needWeights = true;
int streamID1 = streamOpenRead(cdoStreamName(0));
int streamID2 = streamOpenRead(cdoStreamName(1));
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int streamID2 = pstreamOpenRead(cdoStreamName(1));
int vlistID1 = streamInqVlist(streamID1);
int vlistID2 = streamInqVlist(streamID2);
int vlistID1 = pstreamInqVlist(streamID1);
int vlistID2 = pstreamInqVlist(streamID2);
int vlistID3 = vlistDuplicate(vlistID1);
int taxisID1 = vlistInqTaxis(vlistID1);
......@@ -83,9 +83,8 @@ void *Fldrms(void *argument)
if ( ndiffgrids > 0 ) cdoAbort("Too many different grids!");
int streamID3 = streamOpenWrite(cdoStreamName(2), cdoFiletype());
streamDefVlist(streamID3, vlistID3);
int streamID3 = pstreamOpenWrite(cdoStreamName(2), cdoFiletype());
pstreamDefVlist(streamID3, vlistID3);
field_type field1, field2, field3;
field_init(&field1);
......@@ -105,21 +104,21 @@ void *Fldrms(void *argument)
field3.grid = gridID3;
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
while ( (nrecs = pstreamInqTimestep(streamID1, tsID)) )
{
nrecs = streamInqTimestep(streamID2, tsID);
nrecs = pstreamInqTimestep(streamID2, tsID);
taxisCopyTimestep(taxisID3, taxisID1);
streamDefTimestep(streamID3, tsID);
pstreamDefTimestep(streamID3, tsID);
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
streamReadRecord(streamID1, field1.ptr, &nmiss);
pstreamInqRecord(streamID1, &varID, &levelID);
pstreamReadRecord(streamID1, field1.ptr, &nmiss);
field1.nmiss = (size_t) nmiss;
streamInqRecord(streamID2, &varID, &levelID);
streamReadRecord(streamID2, field2.ptr, &nmiss);
pstreamInqRecord(streamID2, &varID, &levelID);
pstreamReadRecord(streamID2, field2.ptr, &nmiss);
field2.nmiss = (size_t) nmiss;
field1.grid = vlistInqVarGrid(vlistID1, varID);
......@@ -147,15 +146,15 @@ void *Fldrms(void *argument)
fldrms(field1, field2, &field3);
streamDefRecord(streamID3, varID, levelID);
streamWriteRecord(streamID3, &sglval, (int)field3.nmiss);
pstreamDefRecord(streamID3, varID, levelID);
pstreamWriteRecord(streamID3, &sglval, (int)field3.nmiss);
}
tsID++;
}
streamClose(streamID3);
streamClose(streamID2);
streamClose(streamID1);
pstreamClose(streamID3);
pstreamClose(streamID2);
pstreamClose(streamID1);
if ( field1.ptr ) Free(field1.ptr);
if ( field1.weight ) Free(field1.weight);
......
......@@ -61,9 +61,8 @@ void print_location_LL(int operfunc, int vlistID, int varID, int levelID, int gr
{
if ( DBL_IS_EQUAL(fieldptr[j*nlon+i], sglval) )
{
double xval, yval;
xval = gridInqXval(gridID,i);
yval = gridInqYval(gridID,j);
double xval = gridInqXval(gridID,i);
double yval = gridInqYval(gridID,j);
if ( showHeader )
{
if ( operfunc == func_min )
......@@ -90,7 +89,6 @@ void *Fldstat(void *argument)
int varID, levelID;
int nmiss;
double sglval;
field_type field;
cdoInitialize(argument);
......@@ -136,9 +134,9 @@ void *Fldstat(void *argument)
}
}
int streamID1 = streamOpenRead(cdoStreamName(0));
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int vlistID1 = streamInqVlist(streamID1);
int vlistID1 = pstreamInqVlist(streamID1);
int vlistID2 = vlistDuplicate(vlistID1);
int taxisID1 = vlistInqTaxis(vlistID1);
......@@ -167,10 +165,11 @@ void *Fldstat(void *argument)
for ( index = 0; index < ngrids; index++ )
vlistChangeGridIndex(vlistID2, index, gridID2);
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
int streamID2 = pstreamOpenWrite(cdoStreamName(1), cdoFiletype());
streamDefVlist(streamID2, vlistID2);
pstreamDefVlist(streamID2, vlistID2);
field_type field;
field_init(&field);
int lim = vlistGridsizeMax(vlistID1);
......@@ -187,10 +186,10 @@ void *Fldstat(void *argument)
}
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
while ( (nrecs = pstreamInqTimestep(streamID1, tsID)) )
{
taxisCopyTimestep(taxisID2, taxisID1);
streamDefTimestep(streamID2, tsID);
pstreamDefTimestep(streamID2, tsID);
/* Precompute date + time for later representation in verbose mode */
int vdate = 0, vtime = 0;
......@@ -205,8 +204,8 @@ void *Fldstat(void *argument)
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
streamReadRecord(streamID1, field.ptr, &nmiss);
pstreamInqRecord(streamID1, &varID, &levelID);
pstreamReadRecord(streamID1, field.ptr, &nmiss);
field.nmiss = (size_t)nmiss;
field.grid = vlistInqVarGrid(vlistID1, varID);
......@@ -243,15 +242,15 @@ void *Fldstat(void *argument)
else
nmiss = 0;
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, &sglval, nmiss);
pstreamDefRecord(streamID2, varID, levelID);
pstreamWriteRecord(streamID2, &sglval, nmiss);
}
tsID++;
}
streamClose(streamID2);
streamClose(streamID1);
pstreamClose(streamID2);
pstreamClose(streamID1);
vlistDestroy(vlistID2);
......
......@@ -92,13 +92,11 @@ void *Fldstat2(void *argument)
{
int gridID, lastgridID = -1;
int gridID3;
int index;
int nrecs, nrecs2;
int varID, levelID;
int nmiss1, nmiss2, nmiss3;
int nmiss1, nmiss2;
bool wstatus = false;
bool needWeights = true;
double missval1, missval2;
double sglval = 0;
char varname[CDI_MAX_NAME];
......@@ -110,11 +108,11 @@ void *Fldstat2(void *argument)
int operatorID = cdoOperatorID();
int operfunc = cdoOperatorF1(operatorID);
int streamID1 = streamOpenRead(cdoStreamName(0));
int streamID2 = streamOpenRead(cdoStreamName(1));
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int streamID2 = pstreamOpenRead(cdoStreamName(1));
int vlistID1 = streamInqVlist(streamID1);
int vlistID2 = streamInqVlist(streamID2);
int vlistID1 = pstreamInqVlist(streamID1);
int vlistID2 = pstreamInqVlist(streamID2);
int vlistID3 = vlistDuplicate(vlistID1);
vlistCompare(vlistID1, vlistID2, CMP_ALL);
......@@ -142,25 +140,23 @@ void *Fldstat2(void *argument)
int ngrids = vlistNgrids(vlistID1);
for ( index = 0; index < ngrids; index++ )
for ( int index = 0; index < ngrids; index++ )
vlistChangeGridIndex(vlistID3, index, gridID3);
int streamID3 = streamOpenWrite(cdoStreamName(2), cdoFiletype());
int streamID3 = pstreamOpenWrite(cdoStreamName(2), cdoFiletype());
streamDefVlist(streamID3, vlistID3);
pstreamDefVlist(streamID3, vlistID3);
int gridsize = vlistGridsizeMax(vlistID1);
double *array1 = (double*) Malloc(gridsize*sizeof(double));
double *array2 = (double*) Malloc(gridsize*sizeof(double));
double *weight = NULL;
if ( needWeights )
weight = (double*) Malloc(gridsize*sizeof(double));
double *weight = needWeights ? (double*) Malloc(gridsize*sizeof(double)) : NULL;
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
while ( (nrecs = pstreamInqTimestep(streamID1, tsID)) )
{
nrecs2 = streamInqTimestep(streamID2, tsID);
nrecs2 = pstreamInqTimestep(streamID2, tsID);
if ( nrecs2 == 0 )
{
......@@ -170,14 +166,14 @@ void *Fldstat2(void *argument)
taxisCopyTimestep(taxisID3, taxisID1);
streamDefTimestep(streamID3, tsID);
pstreamDefTimestep(streamID3, tsID);
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
streamInqRecord(streamID2, &varID, &levelID);
streamReadRecord(streamID1, array1, &nmiss1);
streamReadRecord(streamID2, array2, &nmiss2);
pstreamInqRecord(streamID1, &varID, &levelID);
pstreamInqRecord(streamID2, &varID, &levelID);
pstreamReadRecord(streamID1, array1, &nmiss1);
pstreamReadRecord(streamID2, array2, &nmiss2);
gridID = vlistInqVarGrid(vlistID1, varID);
gridsize = gridInqSize(gridID);
......@@ -192,8 +188,8 @@ void *Fldstat2(void *argument)
cdoWarning("Using constant grid cell area weights for variable %s!", varname);
}
missval1 = vlistInqVarMissval(vlistID1, varID);
missval2 = vlistInqVarMissval(vlistID2, varID);
double missval1 = vlistInqVarMissval(vlistID1, varID);
double missval2 = vlistInqVarMissval(vlistID2, varID);
if ( operfunc == func_cor )
{
......@@ -204,20 +200,18 @@ void *Fldstat2(void *argument)
sglval = covariance_s(array1, array2, weight, missval1, missval2, gridsize);
}
if ( DBL_IS_EQUAL(sglval, missval1) )
nmiss3 = 1;
else
nmiss3 = 0;
int nmiss3 = DBL_IS_EQUAL(sglval, missval1) ? 1 : 0;
streamDefRecord(streamID3, varID, levelID);
streamWriteRecord(streamID3, &sglval, nmiss3);
pstreamDefRecord(streamID3, varID, levelID);
pstreamWriteRecord(streamID3, &sglval, nmiss3);
}
tsID++;
}
streamClose(streamID3);
streamClose(streamID2);
streamClose(streamID1);
pstreamClose(streamID3);
pstreamClose(streamID2);
pstreamClose(streamID1);
if ( array1 ) Free(array1);
if ( array2 ) Free(array2);
......
......@@ -52,23 +52,23 @@ void *Fourier(void *argument)
operatorInputArg("the sign of the exponent (-1 for normal or 1 for reverse transformation)!");
int sign = parameter2int(operatorArgv()[0]);
int streamID1 = streamOpenRead(cdoStreamName(0));
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int vlistID1 = streamInqVlist(streamID1);
int vlistID1 = pstreamInqVlist(streamID1);
int vlistID2 = vlistDuplicate(vlistID1);
int taxisID1 = vlistInqTaxis(vlistID1);
int taxisID2 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID2, taxisID2);
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
int streamID2 = pstreamOpenWrite(cdoStreamName(1), cdoFiletype());
streamDefVlist(streamID2, vlistID2);
pstreamDefVlist(streamID2, vlistID2);
int nvars = vlistNvars(vlistID1);
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
while ( (nrecs = pstreamInqTimestep(streamID1, tsID)) )
{
if ( tsID >= nalloc )
{
......@@ -85,11 +85,11 @@ void *Fourier(void *argument)
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
pstreamInqRecord(streamID1, &varID, &levelID);
gridID = vlistInqVarGrid(vlistID1, varID);
gridsize = gridInqSize(gridID);
vars[tsID][varID][levelID].ptr = (double*) Malloc(2*gridsize*sizeof(double));
streamReadRecord(streamID1, vars[tsID][varID][levelID].ptr, &nmiss);
pstreamReadRecord(streamID1, vars[tsID][varID][levelID].ptr, &nmiss);
vars[tsID][varID][levelID].nmiss = nmiss;
}
......@@ -177,7 +177,7 @@ void *Fourier(void *argument)
{