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

seltimestep: add support for negative timesteps [patch from: Etienne Tourigny]

parent 49e273d5
......@@ -3,6 +3,10 @@
* using CDI library version 1.6.4
* Version 1.6.4 released
2014-04-15 Uwe Schulzweida
* seltimestep: add support for negative timesteps [patch from: Etienne Tourigny]
2014-04-14 Uwe Schulzweida
* New operator: sealevelpressure - sea level pressure
......
......@@ -211,7 +211,7 @@ void *Seltime(void *argument)
LIST *ilist = listNew(INT_LIST);
LIST *flist = listNew(FLT_LIST);
int gridID;
int nvars, nlevel;
int nvars, nlevel, ntsteps;
int nconst, lconstout = FALSE;
int process_nts1 = FALSE, process_nts2 = FALSE;
int *vdate_list = NULL, *vtime_list = NULL;
......@@ -305,15 +305,6 @@ void *Seltime(void *argument)
for ( i = 0; i < nsel; i++ ) selfound[i] = FALSE;
}
if ( cdoVerbose )
{
for ( i = 0; i < nsel; i++ )
if ( operatorID == SELDATE )
cdoPrint("fltarr entry: %d %14.4f", i+1, fltarr[i]);
else
cdoPrint("intarr entry: %d %d", i+1, intarr[i]);
}
streamID1 = streamOpenRead(cdoStreamName(0));
vlistID1 = streamInqVlist(streamID1);
......@@ -333,6 +324,31 @@ void *Seltime(void *argument)
array = (double*) malloc(gridsize*sizeof(double));
}
ntsteps = vlistNtsteps(vlistID1);
/* add support for negative timestep values */
if ( operatorID == SELTIMESTEP && ntsteps > 0 )
{
for ( i = 0; i < nsel; i++ )
{
if ( intarr[i] < 0 )
{
if ( cdoVerbose )
cdoPrint("timestep %d changed to %d", intarr[i], ntsteps + 1 + intarr[i]);
intarr[i] = ntsteps + 1 + intarr[i];
}
}
}
if ( cdoVerbose )
{
for ( i = 0; i < nsel; i++ )
if ( operatorID == SELDATE )
cdoPrint("fltarr entry: %d %14.4f", i+1, fltarr[i]);
else
cdoPrint("intarr entry: %d %d", i+1, intarr[i]);
}
nvars = vlistNvars(vlistID1);
nconst = 0;
for ( varID = 0; varID < nvars; varID++ )
......
Supports Markdown
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