Commit 46f4b527 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

ifthen: bug fix for masks that varies not with time

parent c38962ed
2007-09-?? Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* using CDI library version 1.0.8
* ifthen: bug fix for masks that varies not with time [report: David Wang]
* cdotest: bug fix in eca_gsl/module.c -> 2 input streams [report: Harald Anlauf]
* use always decode_date and encode_date to decode/encode date
* splitname: bug fix [report: Daniel Klocke]
......
......@@ -93,20 +93,21 @@ case "${HOSTNAME}" in
--with-netcdf=/sw/solaris10/netcdf-3.6.1 \
CC=cc CFLAGS="-g -mt -fast -xarch=v9"
;;
# sparc-sun-solaris2.9
# sparc-sun-solaris2.9 chnaged to
# sparc-sun-solaris2.10
executor | yang | yin)
if [ "$SGE_MODE" = "off" ] ; then
${CONFPATH}configure --prefix=$HOME/local --exec_prefix=$HOME/local/solaris8 \
--with-netcdf=/sw/solaris8/netcdf-3.6.1 \
CPPFLAGS="-DHAVE_LIBSZ -I$HOME/local/solaris8/include" LIBS=$HOME/local/solaris8/lib/libsz.a \
CC=cc CFLAGS="-g -mt -fast -xtarget=ultra3"
${CONFPATH}configure --prefix=$HOME/local --exec_prefix=$HOME/local/solaris10 \
--with-netcdf=/sw/solaris10/netcdf-3.6.1 \
CPPFLAGS="-DHAVE_LIBSZ -I$HOME/local/solaris10/include" LIBS=$HOME/local/solaris10/lib/libsz.a \
CC=cc CFLAGS="-g -mt -fast -xarch=v9"
else
${CONFPATH}configure --prefix=$HOME/local --exec_prefix=$HOME/local/solaris8 \
${CONFPATH}configure --prefix=$HOME/local --exec_prefix=$HOME/local/solaris10 \
--program-suffix=_${SGE_SUFFIX} \
--with-netcdf=/sw/solaris8/netcdf-3.6.1 \
CPPFLAGS="-DHAVE_LIBSZ -I$HOME/local/solaris8/include -DHAVE_LIBDRMAA -I/opt/gridware/sge/include -DHAVE_LIBCURL -I/usr/local/include" \
LIBS="$HOME/local/solaris8/lib/libsz.a -L/opt/gridware/sge/lib/sol-sparc -ldrmaa -ldl -L/usr/local/lib -lcurl" \
CC=cc CFLAGS="-g -mt -fast -xtarget=ultra3"
--with-netcdf=/sw/solaris10/netcdf-3.6.1 \
CPPFLAGS="-DHAVE_LIBSZ -I$HOME/local/solaris10/include -DHAVE_LIBDRMAA -I/opt/gridware/sge/include -DHAVE_LIBCURL -I/usr/local/include" \
LIBS="$HOME/local/solaris10/lib/libsz.a -L/opt/gridware/sge/lib/sol-sparc64 -ldrmaa -ldl -L/sw/solaris10/curl-7.16.4-cc/lib -lcurl" \
CC=cc CFLAGS="-g -mt -fast -xarch=v9"
fi
;;
# sx6-nec-superux12.2
......
......@@ -41,17 +41,17 @@ void *Arith(void *argument)
static char func[] = "Arith";
int operatorID;
int operfunc;
enum {FILL_NONE, FILL_REC, FILL_TS};
int streamIDm, streamIDs, streamID1, streamID2, streamID3;
enum {FILL_NONE, FILL_TS, FILL_REC};
int filltype = FILL_NONE;
int streamIDx1, streamIDx2, streamID1, streamID2, streamID3;
int gridsize;
int nrecs, nrecs2, nvars = 0, nlev, recID;
int tsID;
int varID, levelID;
int offset;
int vlistIDm, vlistIDs, vlistID1, vlistID2, vlistID3;
int taxisIDm, taxisID1, taxisID2, taxisID3;
int filltype = FILL_NONE;
FIELD *fieldm, *fields, fieldtmp, field1, field2;
int vlistIDx1, vlistIDx2, vlistID1, vlistID2, vlistID3;
int taxisIDx1, taxisID1, taxisID2, taxisID3;
FIELD *fieldx1, *fieldx2, fieldrec, field1, field2;
int **varnmiss = NULL;
double **vardata = NULL;
......@@ -73,52 +73,55 @@ void *Arith(void *argument)
streamID2 = streamOpenRead(cdoStreamName(1));
if ( streamID2 < 0 ) cdiError(streamID2, "Open failed on %s", cdoStreamName(1));
streamIDm = streamID1;
streamIDs = streamID2;
fieldm = &field1;
fields = &field2;
streamIDx1 = streamID1;
streamIDx2 = streamID2;
fieldx1 = &field1;
fieldx2 = &field2;
vlistID1 = streamInqVlist(streamID1);
vlistID2 = streamInqVlist(streamID2);
vlistIDm = vlistID1;
vlistIDs = vlistID2;
vlistIDx1 = vlistID1;
vlistIDx2 = vlistID2;
taxisID1 = vlistInqTaxis(vlistID1);
taxisID2 = vlistInqTaxis(vlistID2);
taxisIDm = taxisID1;
taxisIDx1 = taxisID1;
if ( vlistNrecs(vlistID1) != 1 && vlistNrecs(vlistID2) == 1 )
{
filltype = FILL_TS;
filltype = FILL_REC;
cdoPrint("Filling up stream2 >%s< by copying the first record.", cdoStreamName(1));
}
else if ( vlistNrecs(vlistID1) == 1 && vlistNrecs(vlistID2) != 1 )
{
filltype = FILL_TS;
filltype = FILL_REC;
cdoPrint("Filling up stream1 >%s< by copying the first record.", cdoStreamName(0));
streamIDm = streamID2;
streamIDs = streamID1;
vlistIDm = vlistID2;
vlistIDs = vlistID1;
taxisIDm = taxisID2;
fieldm = &field2;
fields = &field1;
streamIDx1 = streamID2;
streamIDx2 = streamID1;
vlistIDx1 = vlistID2;
vlistIDx2 = vlistID1;
taxisIDx1 = taxisID2;
fieldx1 = &field2;
fieldx2 = &field1;
}
if ( filltype == FILL_NONE )
vlistCompare(vlistID1, vlistID2, func_sft);
if ( operfunc == func_mul || operfunc == func_div )
nospec(vlistID1);
{
nospec(vlistID1);
nospec(vlistID2);
}
gridsize = vlistGridsizeMax(vlistIDm);
gridsize = vlistGridsizeMax(vlistIDx1);
field1.ptr = (double *) malloc(gridsize*sizeof(double));
field2.ptr = (double *) malloc(gridsize*sizeof(double));
fieldtmp.ptr = NULL;
fieldtmp.nmiss = 0;
if ( filltype == FILL_TS )
fieldtmp.ptr = (double *) malloc(gridsize*sizeof(double));
fieldrec.ptr = NULL;
fieldrec.nmiss = 0;
if ( filltype == FILL_REC )
fieldrec.ptr = (double *) malloc(gridsize*sizeof(double));
if ( cdoVerbose )
cdoPrint("Number of timesteps: file1 %d, file2 %d",
......@@ -129,41 +132,41 @@ void *Arith(void *argument)
if ( vlistNtsteps(vlistID1) != 1 && vlistNtsteps(vlistID1) != 0 &&
(vlistNtsteps(vlistID2) == 1 || vlistNtsteps(vlistID2) == 0) )
{
filltype = FILL_REC;
filltype = FILL_TS;
cdoPrint("Filling up stream2 >%s< by copying the first timestep.", cdoStreamName(1));
}
else if ( (vlistNtsteps(vlistID1) == 1 || vlistNtsteps(vlistID1) == 0) &&
vlistNtsteps(vlistID2) != 1 && vlistNtsteps(vlistID2) != 0 )
{
filltype = FILL_REC;
filltype = FILL_TS;
cdoPrint("Filling up stream1 >%s< by copying the first timestep.", cdoStreamName(0));
streamIDm = streamID2;
streamIDs = streamID1;
vlistIDm = vlistID2;
vlistIDs = vlistID1;
taxisIDm = taxisID2;
fieldm = &field2;
fields = &field1;
streamIDx1 = streamID2;
streamIDx2 = streamID1;
vlistIDx1 = vlistID2;
vlistIDx2 = vlistID1;
taxisIDx1 = taxisID2;
fieldx1 = &field2;
fieldx2 = &field1;
}
if ( filltype == FILL_REC )
if ( filltype == FILL_TS )
{
nvars = vlistNvars(vlistIDs);
nvars = vlistNvars(vlistIDx2);
vardata = (double **) malloc(nvars*sizeof(double *));
varnmiss = (int **) malloc(nvars*sizeof(int *));
for ( varID = 0; varID < nvars; varID++ )
{
gridsize = gridInqSize(vlistInqVarGrid(vlistIDs, varID));
nlev = zaxisInqSize(vlistInqVarZaxis(vlistIDs, varID));
gridsize = gridInqSize(vlistInqVarGrid(vlistIDx2, varID));
nlev = zaxisInqSize(vlistInqVarZaxis(vlistIDx2, varID));
vardata[varID] = (double *) malloc(nlev*gridsize*sizeof(double));
varnmiss[varID] = (int *) malloc(nlev*sizeof(int));
}
}
}
vlistID3 = vlistDuplicate(vlistIDm);
vlistID3 = vlistDuplicate(vlistIDx1);
taxisID3 = taxisDuplicate(taxisIDm);
taxisID3 = taxisDuplicate(taxisIDx1);
vlistDefTaxis(vlistID3, taxisID3);
streamID3 = streamOpenWrite(cdoStreamName(2), cdoFiletype());
......@@ -172,69 +175,69 @@ void *Arith(void *argument)
streamDefVlist(streamID3, vlistID3);
tsID = 0;
while ( (nrecs = streamInqTimestep(streamIDm, tsID)) )
while ( (nrecs = streamInqTimestep(streamIDx1, tsID)) )
{
if ( tsID == 0 || filltype == FILL_NONE )
{
nrecs2 = streamInqTimestep(streamIDs, tsID);
nrecs2 = streamInqTimestep(streamIDx2, tsID);
if ( nrecs2 == 0 )
cdoAbort("Input streams have different number of timesteps!");
}
taxisCopyTimestep(taxisID3, taxisIDm);
taxisCopyTimestep(taxisID3, taxisIDx1);
streamDefTimestep(streamID3, tsID);
for ( recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamIDm, &varID, &levelID);
streamReadRecord(streamIDm, fieldm->ptr, &fieldm->nmiss);
streamInqRecord(streamIDx1, &varID, &levelID);
streamReadRecord(streamIDx1, fieldx1->ptr, &fieldx1->nmiss);
if ( tsID == 0 || filltype == FILL_NONE )
{
if ( recID == 0 || filltype != FILL_TS )
if ( recID == 0 || filltype != FILL_REC )
{
streamInqRecord(streamIDs, &varID, &levelID);
streamReadRecord(streamIDs, fields->ptr, &fields->nmiss);
streamInqRecord(streamIDx2, &varID, &levelID);
streamReadRecord(streamIDx2, fieldx2->ptr, &fieldx2->nmiss);
}
if ( filltype == FILL_REC )
if ( filltype == FILL_TS )
{
gridsize = gridInqSize(vlistInqVarGrid(vlistIDs, varID));
gridsize = gridInqSize(vlistInqVarGrid(vlistIDx2, varID));
offset = gridsize*levelID;
memcpy(vardata[varID]+offset, fields->ptr, gridsize*sizeof(double));
varnmiss[varID][levelID] = fields->nmiss;
memcpy(vardata[varID]+offset, fieldx2->ptr, gridsize*sizeof(double));
varnmiss[varID][levelID] = fieldx2->nmiss;
}
else if ( recID == 0 && filltype == FILL_TS )
else if ( recID == 0 && filltype == FILL_REC )
{
gridsize = gridInqSize(vlistInqVarGrid(vlistIDs, 0));
memcpy(fieldtmp.ptr, fields->ptr, gridsize*sizeof(double));
fieldtmp.nmiss = fields->nmiss;
gridsize = gridInqSize(vlistInqVarGrid(vlistIDx2, 0));
memcpy(fieldrec.ptr, fieldx2->ptr, gridsize*sizeof(double));
fieldrec.nmiss = fieldx2->nmiss;
}
}
else if ( filltype == FILL_REC )
else if ( filltype == FILL_TS )
{
gridsize = gridInqSize(vlistInqVarGrid(vlistIDs, varID));
gridsize = gridInqSize(vlistInqVarGrid(vlistIDx2, varID));
offset = gridsize*levelID;
memcpy(fields->ptr, vardata[varID]+offset, gridsize*sizeof(double));
fields->nmiss = varnmiss[varID][levelID];
memcpy(fieldx2->ptr, vardata[varID]+offset, gridsize*sizeof(double));
fieldx2->nmiss = varnmiss[varID][levelID];
}
fieldm->grid = vlistInqVarGrid(vlistIDm, varID);
fieldm->missval = vlistInqVarMissval(vlistIDm, varID);
fieldx1->grid = vlistInqVarGrid(vlistIDx1, varID);
fieldx1->missval = vlistInqVarMissval(vlistIDx1, varID);
if ( filltype == FILL_TS )
if ( filltype == FILL_REC )
{
gridsize = gridInqSize(vlistInqVarGrid(vlistIDs, 0));
memcpy(fields->ptr, fieldtmp.ptr, gridsize*sizeof(double));
fields->nmiss = fieldtmp.nmiss;
fields->grid = vlistInqVarGrid(vlistIDs, 0);
fields->missval = vlistInqVarMissval(vlistIDs, 0);
gridsize = gridInqSize(vlistInqVarGrid(vlistIDx2, 0));
memcpy(fieldx2->ptr, fieldrec.ptr, gridsize*sizeof(double));
fieldx2->nmiss = fieldrec.nmiss;
fieldx2->grid = vlistInqVarGrid(vlistIDx2, 0);
fieldx2->missval = vlistInqVarMissval(vlistIDx2, 0);
}
else
{
fields->grid = vlistInqVarGrid(vlistIDs, varID);
fields->missval = vlistInqVarMissval(vlistIDs, varID);
fieldx2->grid = vlistInqVarGrid(vlistIDx2, varID);
fieldx2->missval = vlistInqVarMissval(vlistIDx2, varID);
}
farfun(&field1, field2, operfunc);
......@@ -264,8 +267,8 @@ void *Arith(void *argument)
if ( field1.ptr ) free(field1.ptr);
if ( field2.ptr ) free(field2.ptr);
if ( filltype == FILL_TS )
if ( fieldtmp.ptr ) free(fieldtmp.ptr);
if ( filltype == FILL_REC )
if ( fieldrec.ptr ) free(fieldrec.ptr);
cdoFinish();
......
......@@ -40,21 +40,22 @@ void *Comp(void *argument)
static char func[] = "Comp";
int EQ, NE, LE, LT, GE, GT;
int operatorID;
int streamID1, streamID2, streamID3;
int gridsize;
enum {FILL_NONE, FILL_TS, FILL_REC};
int filltype = FILL_NONE;
int streamIDx1, streamIDx2, streamID1, streamID2, streamID3;
int gridsize, gridsize1, gridsize2;
int nrecs, nrecs2, nvars = 0, nlev, recID;
int tsID;
int varID, levelID;
int offset;
int vlistID1, vlistID2, vlistID3;
int nmiss, nmiss2, nmiss3;
int vlistIDx1, vlistIDx2, vlistID1, vlistID2, vlistID3;
int taxisIDx1, taxisID1, taxisID2, taxisID3;
int nmiss1, nmiss2, nmiss3;
int i;
int lptype = 0;
double missval1, missval2 = 0;
double *array1, *array2, *array3;
int **varnmiss2 = NULL;
double **vardata2 = NULL;
int taxisID1, taxisID3;
double *missvalx1, *missvalx2;
double *arrayx1, *arrayx2, *array1, *array2, *array3;
double **vardata = NULL;
cdoInitialize(argument);
......@@ -72,103 +73,166 @@ void *Comp(void *argument)
streamID2 = streamOpenRead(cdoStreamName(1));
if ( streamID2 < 0 ) cdiError(streamID2, "Open failed on %s", cdoStreamName(1));
streamIDx1 = streamID1;
streamIDx2 = streamID2;
missvalx1 = &missval1;
missvalx2 = &missval2;
vlistID1 = streamInqVlist(streamID1);
vlistID2 = streamInqVlist(streamID2);
vlistID3 = vlistDuplicate(vlistID1);
vlistIDx1 = vlistID1;
vlistIDx2 = vlistID2;
taxisID1 = vlistInqTaxis(vlistID1);
taxisID3 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID3, taxisID3);
taxisID2 = vlistInqTaxis(vlistID2);
taxisIDx1 = taxisID1;
if ( vlistNrecs(vlistID1) != 1 && vlistNrecs(vlistID2) == 1 )
{
filltype = FILL_REC;
cdoPrint("Filling up stream2 >%s< by copying the first record.", cdoStreamName(1));
}
else if ( vlistNrecs(vlistID1) == 1 && vlistNrecs(vlistID2) != 1 )
{
filltype = FILL_REC;
cdoPrint("Filling up stream1 >%s< by copying the first record.", cdoStreamName(0));
streamIDx1 = streamID2;
streamIDx2 = streamID1;
vlistIDx1 = vlistID2;
vlistIDx2 = vlistID1;
taxisIDx1 = taxisID2;
}
if ( vlistNrecs(vlistID2) == 1 && vlistNrecs(vlistID1) != 1 )
lptype = 2;
else
if ( filltype == FILL_NONE )
vlistCompare(vlistID1, vlistID2, func_sft);
nospec(vlistID1);
nospec(vlistID2);
streamID3 = streamOpenWrite(cdoStreamName(2), cdoFiletype());
if ( streamID3 < 0 ) cdiError(streamID3, "Open failed on %s", cdoStreamName(2));
streamDefVlist(streamID3, vlistID3);
gridsize = vlistGridsizeMax(vlistID1);
gridsize = vlistGridsizeMax(vlistIDx1);
array1 = (double *) malloc(gridsize*sizeof(double));
array2 = (double *) malloc(gridsize*sizeof(double));
array3 = (double *) malloc(gridsize*sizeof(double));
arrayx1 = array1;
arrayx2 = array2;
if ( cdoVerbose )
cdoPrint("Number of timesteps: file1 %d, file2 %d", vlistNtsteps(vlistID1), vlistNtsteps(vlistID2));
cdoPrint("Number of timesteps: file1 %d, file2 %d",
vlistNtsteps(vlistID1), vlistNtsteps(vlistID2));
if ( vlistNtsteps(vlistID2) == 1 && vlistNtsteps(vlistID1) != 1 && lptype == 0 )
if ( filltype == FILL_NONE )
{
lptype = 1;
nvars = vlistNvars(vlistID2);
vardata2 = (double **) malloc(nvars*sizeof(double *));
varnmiss2 = (int **) malloc(nvars*sizeof(int *));
for ( varID = 0; varID < nvars; varID++ )
if ( vlistNtsteps(vlistID1) != 1 && vlistNtsteps(vlistID1) != 0 &&
(vlistNtsteps(vlistID2) == 1 || vlistNtsteps(vlistID2) == 0) )
{
filltype = FILL_TS;
cdoPrint("Filling up stream2 >%s< by copying the first timestep.", cdoStreamName(1));
}
else if ( (vlistNtsteps(vlistID1) == 1 || vlistNtsteps(vlistID1) == 0) &&
vlistNtsteps(vlistID2) != 1 && vlistNtsteps(vlistID2) != 0 )
{
gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID));
nlev = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
vardata2[varID] = (double *) malloc(nlev*gridsize*sizeof(double));
varnmiss2[varID] = (int *) malloc(nlev*sizeof(int));
filltype = FILL_TS;
cdoPrint("Filling up stream1 >%s< by copying the first timestep.", cdoStreamName(0));
streamIDx1 = streamID2;
streamIDx2 = streamID1;
vlistIDx1 = vlistID2;
vlistIDx2 = vlistID1;
taxisIDx1 = taxisID2;
}
cdoPrint("Filling up stream >%s< by copying the first timestep.", cdoStreamName(1));
if ( filltype == FILL_TS )
{
nvars = vlistNvars(vlistIDx2);
vardata = (double **) malloc(nvars*sizeof(double *));
for ( varID = 0; varID < nvars; varID++ )
{
gridsize = gridInqSize(vlistInqVarGrid(vlistIDx2, varID));
nlev = zaxisInqSize(vlistInqVarZaxis(vlistIDx2, varID));
vardata[varID] = (double *) malloc(nlev*gridsize*sizeof(double));
}
}
}
if ( filltype != FILL_NONE && vlistNtsteps(vlistID1) == 1 )
{
arrayx1 = array2;
arrayx2 = array1;
missvalx1 = &missval2;
missvalx2 = &missval1;
}
vlistID3 = vlistDuplicate(vlistIDx1);
taxisID3 = taxisDuplicate(taxisIDx1);
vlistDefTaxis(vlistID3, taxisID3);
streamID3 = streamOpenWrite(cdoStreamName(2), cdoFiletype());
if ( streamID3 < 0 ) cdiError(streamID3, "Open failed on %s", cdoStreamName(2));
streamDefVlist(streamID3, vlistID3);
tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
while ( (nrecs = streamInqTimestep(streamIDx1, tsID)) )
{
if ( tsID == 0 || lptype == 0 )
if ( tsID == 0 || filltype == FILL_NONE )
{
nrecs2 = streamInqTimestep(streamID2, tsID);
nrecs2 = streamInqTimestep(streamIDx2, tsID);
if ( nrecs2 == 0 )
cdoAbort("Input streams have different number of timesteps!");
}
taxisCopyTimestep(taxisID3, taxisID1);
taxisCopyTimestep(taxisID3, taxisIDx1);
streamDefTimestep(streamID3, tsID);
for ( recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
streamReadRecord(streamID1, array1, &nmiss);
streamInqRecord(streamIDx1, &varID, &levelID);
streamReadRecord(streamIDx1, arrayx1, &nmiss1);
if ( tsID == 0 || lptype == 0 )
if ( tsID == 0 || filltype == FILL_NONE )
{
if ( recID == 0 || lptype != 2 )
if ( recID == 0 || filltype != FILL_REC )
{
streamInqRecord(streamID2, &varID, &levelID);
streamReadRecord(streamID2, array2, &nmiss2);
streamInqRecord(streamIDx2, &varID, &levelID);
streamReadRecord(streamIDx2, arrayx2, &nmiss2);
}
if ( lptype == 1 )
if ( filltype == FILL_TS )
{
gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID));
gridsize = gridInqSize(vlistInqVarGrid(vlistIDx2, varID));
offset = gridsize*levelID;
memcpy(vardata2[varID]+offset, array2, gridsize*sizeof(double));
varnmiss2[varID][levelID] = nmiss2;
memcpy(vardata[varID]+offset, arrayx2, gridsize*sizeof(double));
}
}
else if ( lptype == 1 )
else if ( filltype == FILL_TS )
{
gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID));
gridsize = gridInqSize(vlistInqVarGrid(vlistIDx2, varID));
offset = gridsize*levelID;
memcpy(array2, vardata2[varID]+offset, gridsize*sizeof(double));
nmiss2 = varnmiss2[varID][levelID];
memcpy(arrayx2, vardata[varID]+offset, gridsize*sizeof(double));
}
gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
missval1 = vlistInqVarMissval(vlistID1, varID);
gridsize1 = gridInqSize(vlistInqVarGrid(vlistIDx1, varID));
*missvalx1 = vlistInqVarMissval(vlistIDx1, varID);
if ( recID == 0 || lptype != 2 )
if ( filltype == FILL_REC )
{
/* gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID)); */
missval2 = vlistInqVarMissval(vlistID2, varID);
gridsize2 = gridInqSize(vlistInqVarGrid(vlistIDx2, 0));
*missvalx2 = vlistInqVarMissval(vlistIDx2, 0);
}
else
{
gridsize2 = gridInqSize(vlistInqVarGrid(vlistIDx2, varID));
*missvalx2 = vlistInqVarMissval(vlistIDx2, varID);
}
if ( gridsize1 != gridsize2 ) cdoAbort("Streams have different gridsize (gridsize1 = %d; gridsize2 = %d!",
gridsize1, gridsize2);
gridsize = gridsize1;
if ( operatorID == EQ )
{
......@@ -226,16 +290,10 @@ void *Comp(void *argument)
streamClose(streamID2);
streamClose(streamID1);
if ( vardata2 )
if ( vardata )
{
for ( varID = 0; varID < nvars; varID++ )
{
free(vardata2[varID]);
free(varnmiss2[varID]);
}
free(vardata2);
free(varnmiss2);
for ( varID = 0; varID < nvars; varID++ ) free(vardata[varID]);
free(vardata);
}
if ( array3 ) free(array3);
......
......@@ -2,7 +2,7 @@
This file is part of CDO. CDO is a collection of Operators to
manipulate and analyse Climate model Data.
Copyright (C) 2003-2006 Uwe Schulzweida, schulzweida@dkrz.de
Copyright (C) 2003-2007 Uwe Schulzweida, schulzweida@dkrz.de
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -36,6 +36,8 @@ void *Cond(void *argument)
static char func[] = "Cond";
int IFTHEN, IFNOTTHEN;
int operatorID;
enum {FILL_NONE, FILL_TS, FILL_REC};
int filltype = FILL_NONE;
int streamID1, streamID2, streamID3;
int gridsize;
int nrecs, nrecs2, nvars = 0, nlev, recID;
......@@ -45,7 +47,6 @@ void *Cond(void *argument)
int vlistID1, vlistID2, vlistID3;
int nmiss1, nmiss2, nmiss3;
int i;
int lptype = 0;
double missval1 = -9.E33;
double *array1, *array2, *array3;
int **varnmiss1 = NULL;
......@@ -72,19 +73,27 @@ void *Cond(void *argument)
taxisID3 = taxisDuplicate(taxisID2);
vlistDefTaxis(vlistID3, taxisID3);
if ( vlistNrecs(vlistID2) == 1 && vlistNrecs(vlistID1) != 1 )
lptype = 2;
else
vlistCompare(vlistID1, vlistID2, func_sft);
if ( vlistNrecs(vlistID1) == 1 && vlistNrecs(vlistID2) != 1 )
{
filltype = FILL_REC;
cdoPrint("Filling up stream1 >%s< by copying the first record.", cdoStreamName(0));