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

Open stream after calling cdoDefineGrid.

parent f10beeb4
......@@ -36,15 +36,13 @@ void *Enlarge(void *argument)
operatorCheckArgc(1);
// open stream before calling cdoDefineGrid!!!
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int gridID2 = cdoDefineGrid(operatorArgv()[0]);
size_t xsize2 = gridInqXsize(gridID2);
size_t ysize2 = gridInqYsize(gridID2);
if ( cdoVerbose ) fprintf(stderr, "gridID2 %d, xsize2 %zu, ysize2 %zu\n", gridID2, xsize2, ysize2);
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int vlistID1 = pstreamInqVlist(streamID1);
int vlistID2 = vlistDuplicate(vlistID1);
......
......@@ -166,11 +166,10 @@ void *Enlargegrid(void *argument)
if ( operatorArgc() < 1 ) cdoAbort("Too few arguments!");
if ( operatorArgc() > 2 ) cdoAbort("Too many arguments!");
// open stream before calling cdoDefineGrid!!!
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int gridID2 = cdoDefineGrid(operatorArgv()[0]);
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int vlistID1 = pstreamInqVlist(streamID1);
int taxisID1 = vlistInqTaxis(vlistID1);
int taxisID2 = taxisDuplicate(taxisID1);
......
......@@ -304,9 +304,6 @@ void *Intgrid(void *argument)
int operatorID = cdoOperatorID();
// open stream before calling cdoDefineGrid!!!
int streamID1 = pstreamOpenRead(cdoStreamName(0));
if ( operatorID == INTGRIDBIL || operatorID == INTERPOLATE )
{
operatorInputArg("grid description file or name");
......@@ -332,6 +329,8 @@ void *Intgrid(void *argument)
yinc = parameter2int(operatorArgv()[1]);
}
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int vlistID1 = pstreamInqVlist(streamID1);
int vlistID2 = vlistDuplicate(vlistID1);
......
......@@ -55,9 +55,7 @@ void read_first_record(char *filename, double *field)
* */
int countMask(double *maskField, int gridSize, double falseVal)
{
int counter;
counter = 0;
int counter = 0;
for (int i = 0; i < gridSize; i++)
{
......@@ -81,9 +79,6 @@ void *MapReduce(void *argument)
cdoInitialize(argument);
// open stream before calling cdoDefineGrid!!!
int streamID1 = pstreamOpenRead(cdoStreamName(0));
/* check input grid type and size - this will be used for selecting relevant
* variables from the input file*/
int inputGridID = cdoDefineGrid(operatorArgv()[0]);
......@@ -126,6 +121,8 @@ void *MapReduce(void *argument)
/* create output vlist: Only variabes which have the same gridtype and
* gridsize as the input mask should be proessed. Everything else is ignoreds
* {{{ */
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int vlistID1 = pstreamInqVlist(streamID1);
int nvars = vlistNvars(vlistID1);
int *vars = (int*) Malloc(nvars*sizeof(int));
......
......@@ -140,16 +140,16 @@ void print_remap_info(int operfunc, bool remap_genweights, remapgrid_t *src_grid
strcat(line, gridNamePtr(gridInqType(src_grid->gridID)));
if ( src_grid->rank == 2 )
snprintf(tmpstr, sizeof(tmpstr), " (%dx%d)", src_grid->dims[0], src_grid->dims[1]);
snprintf(tmpstr, sizeof(tmpstr), " (%zux%zu)", src_grid->dims[0], src_grid->dims[1]);
else
snprintf(tmpstr, sizeof(tmpstr), " (%d)", src_grid->dims[0]);
snprintf(tmpstr, sizeof(tmpstr), " (%zu)", src_grid->dims[0]);
strcat(line, tmpstr);
strcat(line, " to ");
strcat(line, gridNamePtr(gridInqType(tgt_grid->gridID)));
if ( tgt_grid->rank == 2 )
snprintf(tmpstr, sizeof(tmpstr), " (%dx%d)", tgt_grid->dims[0], tgt_grid->dims[1]);
snprintf(tmpstr, sizeof(tmpstr), " (%zux%zu)", tgt_grid->dims[0], tgt_grid->dims[1]);
else
snprintf(tmpstr, sizeof(tmpstr), " (%d)", tgt_grid->dims[0]);
snprintf(tmpstr, sizeof(tmpstr), " (%zu)", tgt_grid->dims[0]);
strcat(line, tmpstr);
strcat(line, " grid");
......@@ -188,9 +188,9 @@ void print_remap_warning(const char *remap_file, int operfunc, remapgrid_t *src_
strcat(line, " not used, ");
strcat(line, gridNamePtr(gridInqType(src_grid->gridID)));
if ( src_grid->rank == 2 )
snprintf(tmpstr, sizeof(tmpstr), " (%dx%d)", src_grid->dims[0], src_grid->dims[1]);
snprintf(tmpstr, sizeof(tmpstr), " (%zux%zu)", src_grid->dims[0], src_grid->dims[1]);
else
snprintf(tmpstr, sizeof(tmpstr), " (%d)", src_grid->dims[0]);
snprintf(tmpstr, sizeof(tmpstr), " (%zu)", src_grid->dims[0]);
strcat(line, tmpstr);
strcat(line, " grid");
......@@ -829,16 +829,7 @@ void *Remap(void *argument)
get_remap_env();
if ( cdoVerbose )
{
if ( remap_extrapolate )
cdoPrint("Extrapolation enabled!");
else
cdoPrint("Extrapolation disabled!");
}
// open stream before calling cdoDefineGrid!!!
int streamID1 = pstreamOpenRead(cdoStreamName(0));
if ( cdoVerbose ) cdoPrint("Extrapolation %s!", remap_extrapolate?"enabled":"disables");
if ( lremapxxx )
{
......@@ -866,6 +857,8 @@ void *Remap(void *argument)
if ( gridInqType(gridID2) == GRID_GENERIC ) cdoAbort("Unsupported target grid type (generic)!");
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int filetype = pstreamInqFiletype(streamID1);
int vlistID1 = pstreamInqVlist(streamID1);
......
......@@ -67,9 +67,6 @@ void *Setgrid(void *argument)
int operatorID = cdoOperatorID();
// open stream before calling cdoDefineGrid!!!
int streamID1 = pstreamOpenRead(cdoStreamName(0));
if ( operatorID != UNSETGRIDMASK )
operatorInputArg(cdoOperatorEnter(operatorID));
......@@ -180,6 +177,8 @@ void *Setgrid(void *argument)
griduri = operatorArgv()[0];
}
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int vlistID1 = pstreamInqVlist(streamID1);
int vlistID2 = vlistDuplicate(vlistID1);
......
......@@ -714,11 +714,10 @@ void *YAR(void *argument)
field_init(&field1);
field_init(&field2);
// open stream before calling cdoDefineGrid!!!
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int gridID2 = cdoDefineGrid(operatorArgv()[0]);
int streamID1 = pstreamOpenRead(cdoStreamName(0));
int vlistID1 = pstreamInqVlist(streamID1);
int vlistID2 = vlistDuplicate(vlistID1);
......
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