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

Renamed streamXXX() to pstreamXXX().

parent 6c400ef5
......@@ -35,11 +35,11 @@ void *Gengrid(void *argument)
cdoInitialize(argument);
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 gridID1 = vlistGrid(vlistID1, 0);
int gridID2 = vlistGrid(vlistID2, 0);
......@@ -55,15 +55,15 @@ void *Gengrid(void *argument)
double *array2 = (double*) Malloc(gridsize*sizeof(double));
double *array3 = (double*) Malloc(gridsize*sizeof(double));
streamInqRecord(streamID1, &varID, &levelID);
streamReadRecord(streamID1, array1, &nmiss1);
streamInqRecord(streamID2, &varID, &levelID);
streamReadRecord(streamID2, array2, &nmiss2);
pstreamInqRecord(streamID1, &varID, &levelID);
pstreamReadRecord(streamID1, array1, &nmiss1);
pstreamInqRecord(streamID2, &varID, &levelID);
pstreamReadRecord(streamID2, array2, &nmiss2);
int datatype = vlistInqVarDatatype(vlistID1, 0);
streamClose(streamID2);
streamClose(streamID1);
pstreamClose(streamID2);
pstreamClose(streamID1);
if ( nmiss1 || nmiss2 ) cdoAbort("Missing values unsupported!");
......@@ -126,19 +126,19 @@ void *Gengrid(void *argument)
vlistDefTaxis(vlistID3, taxisID3);
int streamID3 = streamOpenWrite(cdoStreamName(2), cdoFiletype());
int streamID3 = pstreamOpenWrite(cdoStreamName(2), cdoFiletype());
streamDefVlist(streamID3, vlistID3);
pstreamDefVlist(streamID3, vlistID3);
int tsID = 0;
streamDefTimestep(streamID3, tsID);
pstreamDefTimestep(streamID3, tsID);
for ( int i = 0; i < gridsize; ++i ) array3[i] = missval;
streamDefRecord(streamID3, 0, 0);
streamWriteRecord(streamID3, array3, gridsize);
pstreamDefRecord(streamID3, 0, 0);
pstreamWriteRecord(streamID3, array3, gridsize);
streamClose(streamID3);
pstreamClose(streamID3);
if ( array1 ) Free(array1);
if ( array2 ) Free(array2);
......
......@@ -23,7 +23,7 @@
#if defined(HAVE_CONFIG_H)
# include "config.h" /* VERSION */
#include "config.h" /* VERSION */
#endif
#include <cdi.h>
......@@ -946,7 +946,6 @@ void *Gradsdes(void *argument)
int varID;
int levelID;
int nrecs;
int vdate, vtime;
char *idxfile = NULL;
char varname[CDI_MAX_NAME];
bool yrev = false;
......@@ -1019,16 +1018,16 @@ void *Gradsdes(void *argument)
cdoAbort("GrADS GRIB map version %d requires size of off_t to be 8! The size of off_t is %ld.",
map_version, sizeof(off_t));
int streamID = streamOpenRead(cdoStreamName(0));
int streamID = pstreamOpenRead(cdoStreamName(0));
int vlistID = streamInqVlist(streamID);
int vlistID = pstreamInqVlist(streamID);
int nvars = vlistNvars(vlistID);
int ntsteps = vlistNtsteps(vlistID);
int ngrids = vlistNgrids(vlistID);
int filetype = streamInqFiletype(streamID);
int byteorder = streamInqByteorder(streamID);
int filetype = pstreamInqFiletype(streamID);
int byteorder = pstreamInqByteorder(streamID);
if ( filetype == CDI_FILETYPE_NC2 || filetype == CDI_FILETYPE_NC4 ) filetype = CDI_FILETYPE_NC;
......@@ -1202,10 +1201,10 @@ void *Gradsdes(void *argument)
bool cal365day = (taxisInqCalendar(taxisID) == CALENDAR_365DAYS);
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID, tsID)) )
while ( (nrecs = pstreamInqTimestep(streamID, tsID)) )
{
vdate = taxisInqVdate(taxisID);
vtime = taxisInqVtime(taxisID);
int vdate = taxisInqVdate(taxisID);
int vtime = taxisInqVtime(taxisID);
if ( tsID == 0 )
{
......@@ -1308,14 +1307,14 @@ void *Gradsdes(void *argument)
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID, &varID, &levelID);
pstreamInqRecord(streamID, &varID, &levelID);
if ( vars[varID] == TRUE )
{
streamReadRecord(streamID, array, &nmiss);
pstreamReadRecord(streamID, array, &nmiss);
index = (tsID*nrecsout + recoffset[varID] + levelID);
streamInqGRIBinfo(streamID, &intnum[index], &fltnum[index*3], &bignum[index*2]);
pstreamInqGRIBinfo(streamID, &intnum[index], &fltnum[index*3], &bignum[index*2]);
if ( map_version != 4 )
{
......@@ -1397,7 +1396,7 @@ void *Gradsdes(void *argument)
// write_map_grib2(idxfile, map_version, nrecords, intnum, fltnum, bignum);
}
streamClose(streamID);
pstreamClose(streamID);
if ( ctlfile ) Free(ctlfile);
if ( idxfile ) Free(idxfile);
......
......@@ -567,9 +567,9 @@ void *Gridboxstat(void *argument)
int operfunc = cdoOperatorF1(operatorID);
bool needWeights = cdoOperatorF2(operatorID) != 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);
......@@ -587,9 +587,8 @@ void *Gridboxstat(void *argument)
for ( int index = 0; index < ngrids; index++ )
vlistChangeGridIndex(vlistID2, index, gridID2);
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
streamDefVlist(streamID2, vlistID2);
int streamID2 = pstreamOpenWrite(cdoStreamName(1), cdoFiletype());
pstreamDefVlist(streamID2, vlistID2);
field_type field1, field2;
field_init(&field1);
......@@ -604,17 +603,17 @@ void *Gridboxstat(void *argument)
field2.weight = NULL;
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++ )
{
int nmiss;
streamInqRecord(streamID1, &varID, &levelID);
streamReadRecord(streamID1, field1.ptr, &nmiss);
pstreamInqRecord(streamID1, &varID, &levelID);
pstreamReadRecord(streamID1, field1.ptr, &nmiss);
field1.nmiss = (size_t) nmiss;
field1.grid = vlistInqVarGrid(vlistID1, varID);
......@@ -638,14 +637,14 @@ void *Gridboxstat(void *argument)
gridboxstat(&field1, &field2, xinc, yinc, operfunc);
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, field2.ptr, (int)field2.nmiss);
pstreamDefRecord(streamID2, varID, levelID);
pstreamWriteRecord(streamID2, field2.ptr, (int)field2.nmiss);
}
tsID++;
}
streamClose(streamID2);
streamClose(streamID1);
pstreamClose(streamID2);
pstreamClose(streamID1);
if ( field1.ptr ) Free(field1.ptr);
if ( field1.weight ) Free(field1.weight);
......
......@@ -81,6 +81,7 @@ void grid_cell_area(int gridID, double *array)
}
}
void *Gridcell(void *argument)
{
int status;
......@@ -108,9 +109,9 @@ void *Gridcell(void *argument)
if ( cdoVerbose ) cdoPrint("PlanetRadius: %g", PlanetRadius);
int streamID1 = streamOpenRead(cdoStreamName(0));
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int vlistID1 = streamInqVlist(streamID1);
int vlistID1 = pstreamInqVlist(streamID1);
int ngrids = vlistNgrids(vlistID1);
......@@ -175,8 +176,7 @@ void *Gridcell(void *argument)
}
else if ( operatorID == GRIDMASK )
{
int *mask;
mask = (int*) Malloc(gridsize*sizeof(int));
int *mask = (int*) Malloc(gridsize*sizeof(int));
if ( gridInqMask(gridID, NULL) )
{
gridInqMask(gridID, mask);
......@@ -284,20 +284,20 @@ void *Gridcell(void *argument)
}
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
int streamID2 = pstreamOpenWrite(cdoStreamName(1), cdoFiletype());
streamDefVlist(streamID2, vlistID2);
pstreamDefVlist(streamID2, vlistID2);
int tsID = 0;
streamDefTimestep(streamID2, tsID);
pstreamDefTimestep(streamID2, tsID);
varID = 0;
int levelID = 0;
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, array, 0);
pstreamDefRecord(streamID2, varID, levelID);
pstreamWriteRecord(streamID2, array, 0);
streamClose(streamID2);
streamClose(streamID1);
pstreamClose(streamID2);
pstreamClose(streamID1);
if ( array ) Free(array);
......
#include <cdi.h>
#include "cdo.h"
#include "cdo_int.h"
#include "pstream.h"
#include "grid.h"
void check_lon_range(long nlons, double *lons);
......
......@@ -56,9 +56,9 @@ void *Harmonic(void *argument)
cdoAbort("The wave length must be positive and smaller than "
"2 times the number of requested harmonics (=%d)!", n_out);
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);
......@@ -67,7 +67,7 @@ void *Harmonic(void *argument)
refname = cdoStreamName(0)->argv[cdoStreamName(0)->argc-1];
filesuffix[0] = 0;
cdoGenFileSuffix(filesuffix, sizeof(filesuffix), streamInqFiletype(streamID1), vlistID1, refname);
cdoGenFileSuffix(filesuffix, sizeof(filesuffix), pstreamInqFiletype(streamID1), vlistID1, refname);
int *streamIDs = (int*) Malloc(n_out*sizeof(int));
......@@ -81,12 +81,12 @@ void *Harmonic(void *argument)
sprintf(filename+nchars+1, "%s", filesuffix);
argument_t *fileargument = file_argument_new(filename);
int streamID2 = streamOpenWrite(fileargument, cdoFiletype());
int streamID2 = pstreamOpenWrite(fileargument, cdoFiletype());
file_argument_free(fileargument);
streamIDs[j] = streamID2;
streamDefVlist(streamID2, vlistID2);
pstreamDefVlist(streamID2, vlistID2);
}
int nvars = vlistNvars(vlistID1);
......@@ -122,7 +122,7 @@ void *Harmonic(void *argument)
double *array = (double*) Malloc(gridsize*sizeof(double));
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
while ( (nrecs = pstreamInqTimestep(streamID1, tsID)) )
{
if ( tsID == 0 )
{
......@@ -132,18 +132,18 @@ void *Harmonic(void *argument)
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
offset = gridsize*levelID;
streamReadRecord(streamID1, array, &nmiss);
pstreamInqRecord(streamID1, &varID, &levelID);
pstreamReadRecord(streamID1, array, &nmiss);
if ( nmiss > 0 ) cdoAbort("Missing values are not allowed!");
gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
offset = gridsize*levelID;
for ( int j = 0; j < n_out; ++j )
{
double sine = sin (2 * M_PI * (((j + 1) * (tsID+1)) % n) / n);
double cosine = cos (2 * M_PI * (((j + 1) * (tsID+1)) % n) / n);
double sine = sin(2 * M_PI * (((j + 1) * (tsID+1)) % n) / n);
double cosine = cos(2 * M_PI * (((j + 1) * (tsID+1)) % n) / n);
for ( int i = 0; i < gridsize; i++ )
{
work[j][varID][i+offset] += array[i] * sine;
......@@ -159,8 +159,7 @@ void *Harmonic(void *argument)
if ( array ) Free(array);
streamClose(streamID1);
pstreamClose(streamID1);
if ( nts%n )
{
......@@ -206,7 +205,7 @@ void *Harmonic(void *argument)
for ( int j = 0; j < nout; j++ )
{
int streamID2 = streamIDs[j];
streamDefTimestep(streamID2, 0);
pstreamDefTimestep(streamID2, 0);
for ( varID = 0; varID < nvars; varID++ )
{
......@@ -215,8 +214,8 @@ void *Harmonic(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
offset = gridsize*levelID;
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, out[j][varID]+offset, 0);
pstreamDefRecord(streamID2, varID, levelID);
pstreamWriteRecord(streamID2, out[j][varID]+offset, 0);
}
}
}
......@@ -252,7 +251,7 @@ void *Harmonic(void *argument)
for ( int j = 0; j < nout; j++ )
{
int streamID2 = streamIDs[j];
streamDefTimestep(streamID2, 1);
pstreamDefTimestep(streamID2, 1);
for ( varID = 0; varID < nvars; varID++ )
{
......@@ -262,11 +261,11 @@ void *Harmonic(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
offset = gridsize*levelID;
streamDefRecord(streamID2, varID, levelID);
pstreamDefRecord(streamID2, varID, levelID);
nmiss = 0;
for ( int i = 0; i < gridsize; i++ )
if ( DBL_IS_EQUAL(out[j][varID][i+offset], missval) ) nmiss++;
streamWriteRecord(streamID2, out[j][varID]+offset, nmiss);
pstreamWriteRecord(streamID2, out[j][varID]+offset, nmiss);
}
}
}
......@@ -274,7 +273,7 @@ void *Harmonic(void *argument)
for ( int j = 0; j < n_out; j++ )
{
int streamID2 = streamIDs[j];
streamClose(streamID2);
pstreamClose(streamID2);
}
Free(streamIDs);
......
......@@ -96,13 +96,13 @@ void *Hi(void *argument)
cdoInitialize(argument);
cdoOperatorAdd("hi", 0, 0, NULL);
int streamID1 = streamOpenRead(cdoStreamName(0));
int streamID2 = streamOpenRead(cdoStreamName(1));
int streamID3 = streamOpenRead(cdoStreamName(2));
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int streamID2 = pstreamOpenRead(cdoStreamName(1));
int streamID3 = pstreamOpenRead(cdoStreamName(2));
int vlistID1 = streamInqVlist(streamID1);
int vlistID2 = streamInqVlist(streamID2);
int vlistID3 = streamInqVlist(streamID3);
int vlistID1 = pstreamInqVlist(streamID1);
int vlistID2 = pstreamInqVlist(streamID2);
int vlistID3 = pstreamInqVlist(streamID3);
int taxisID1 = vlistInqTaxis(vlistID1);
//taxisID2 = vlistInqTaxis(vlistID2);
......@@ -141,33 +141,33 @@ void *Hi(void *argument)
vlistDefVarLongname(vlistID4, varID4, HI_LONGNAME);
vlistDefVarUnits(vlistID4, varID4, HI_UNITS);
int streamID4 = streamOpenWrite(cdoStreamName(3), cdoFiletype());
int streamID4 = pstreamOpenWrite(cdoStreamName(3), cdoFiletype());
streamDefVlist(streamID4, vlistID4);
pstreamDefVlist(streamID4, vlistID4);
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
while ( (nrecs = pstreamInqTimestep(streamID1, tsID)) )
{
int nrecs2 = streamInqTimestep(streamID2, tsID);
int nrecs3 = streamInqTimestep(streamID3, tsID);
int nrecs2 = pstreamInqTimestep(streamID2, tsID);
int nrecs3 = pstreamInqTimestep(streamID3, tsID);
if ( nrecs2 == 0 || nrecs3 == 0 )
cdoAbort("Input streams have different number of timesteps!");
taxisCopyTimestep(taxisID4, taxisID1);
streamDefTimestep(streamID4, tsID);
pstreamDefTimestep(streamID4, tsID);
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID1, &levelID1);
streamReadRecord(streamID1, field1.ptr, &nmiss);
pstreamInqRecord(streamID1, &varID1, &levelID1);
pstreamReadRecord(streamID1, field1.ptr, &nmiss);
field1.nmiss = (size_t) nmiss;
streamInqRecord(streamID2, &varID2, &levelID2);
streamReadRecord(streamID2, field2.ptr, &nmiss);
pstreamInqRecord(streamID2, &varID2, &levelID2);
pstreamReadRecord(streamID2, field2.ptr, &nmiss);
field2.nmiss = (size_t) nmiss;
streamInqRecord(streamID3, &varID3, &levelID3);
streamReadRecord(streamID3, field3.ptr, &nmiss);
pstreamInqRecord(streamID3, &varID3, &levelID3);
pstreamReadRecord(streamID3, field3.ptr, &nmiss);
field3.nmiss = (size_t) nmiss;
if ( varID1 != varID2 || varID1 != varID3 || levelID1 != levelID2 || levelID1 != levelID3 )
......@@ -186,17 +186,17 @@ void *Hi(void *argument)
farexpr(&field1, field2, field3, humidityIndex);
streamDefRecord(streamID4, varID4, levelID1);
streamWriteRecord(streamID4, field1.ptr, (int)field1.nmiss);
pstreamDefRecord(streamID4, varID4, levelID1);
pstreamWriteRecord(streamID4, field1.ptr, (int)field1.nmiss);
}
tsID++;
}
streamClose(streamID4);
streamClose(streamID3);
streamClose(streamID2);
streamClose(streamID1);
pstreamClose(streamID4);
pstreamClose(streamID3);
pstreamClose(streamID2);
pstreamClose(streamID1);
if ( field1.ptr ) Free(field1.ptr);
if ( field2.ptr ) Free(field2.ptr);
......
......@@ -60,9 +60,9 @@ void *Histogram(void *argument)
printf("flt %d = %g\n", i+1, fltarr[i]);
}
int streamID1 = streamOpenRead(cdoStreamName(0));
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int vlistID1 = streamInqVlist(streamID1);
int vlistID1 = pstreamInqVlist(streamID1);
int taxisID1 = vlistInqTaxis(vlistID1);
int vlistID2 = vlistDuplicate(vlistID1);
......@@ -91,12 +91,12 @@ void *Histogram(void *argument)
vlistChangeZaxisIndex(vlistID2, index, zaxisID2);
}
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
int streamID2 = pstreamOpenWrite(cdoStreamName(1), cdoFiletype());
int taxisID2 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID2, taxisID2);
streamDefVlist(streamID2, vlistID2);
pstreamDefVlist(streamID2, vlistID2);
int nvars = vlistNvars(vlistID2);
double **vardata = (double **) Malloc(nvars*sizeof(double *));
......@@ -117,14 +117,14 @@ void *Histogram(void *argument)
double *array = (double*) Malloc(gridsize*sizeof(double));
int tsID1 = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID1)) )
while ( (nrecs = pstreamInqTimestep(streamID1, tsID1)) )
{
taxisCopyTimestep(taxisID2, taxisID1);
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
streamReadRecord(streamID1, array, &nmiss);
pstreamInqRecord(streamID1, &varID, &levelID);
pstreamReadRecord(streamID1, array, &nmiss);
missval = vlistInqVarMissval(vlistID1, varID);
gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
......@@ -158,7 +158,7 @@ void *Histogram(void *argument)
}
streamDefTimestep(streamID2, 0);
pstreamDefTimestep(streamID2, 0);
for ( varID = 0; varID < nvars; varID++ )
{
......@@ -195,17 +195,17 @@ void *Histogram(void *argument)
}
}
streamDefRecord(streamID2, varID, index);
pstreamDefRecord(streamID2, varID, index);
if ( operatorID == HISTCOUNT )
streamWriteRecord(streamID2, varcount[varID]+offset, nmiss);
pstreamWriteRecord(streamID2, varcount[varID]+offset, nmiss);
else
streamWriteRecord(streamID2, vardata[varID]+offset, nmiss);
pstreamWriteRecord(streamID2, vardata[varID]+offset, nmiss);
}
}
streamClose(streamID1);
streamClose(streamID2);
pstreamClose(streamID1);
pstreamClose(streamID2);
if ( vardata )
{
......
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