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

added farset()

parent b6cc819c
......@@ -850,7 +850,7 @@ void *Select(void *argument)
vlistDefVarTsteptype(vlistID2, varID, TSTEP_INSTANT);
}
/* add support for negative timestep values */
// support for negative timestep values
if ( npar_timestep > 0 && ntsteps > 0 && nfiles == 1 )
{
for ( i = 0; i < npar_timestep; i++ )
......@@ -985,7 +985,6 @@ void *Select(void *argument)
if ( streamID2 == CDI_UNDEFID )
{
streamID2 = streamOpenWrite(cdoStreamName(nfiles), cdoFiletype());
streamDefVlist(streamID2, vlistID2);
}
......
......@@ -96,7 +96,10 @@ void *cdoReadTimestep(void *rarg)
for ( int recID = 0; recID < nrecs; ++recID )
{
streamInqRecord(streamID, &varID, &levelID);
streamReadRecord(streamID, input_vars[varID][levelID].ptr2, &nmiss);
if ( CDO_Memtype == MEMTYPE_FLOAT )
streamReadRecordF(streamID, input_vars[varID][levelID].ptr2, &nmiss);
else
streamReadRecord(streamID, input_vars[varID][levelID].ptr2, &nmiss);
input_vars[varID][levelID].nmiss2 = nmiss;
}
......@@ -225,7 +228,6 @@ void *XTimstat(void *argument)
if ( cdoDiag )
{
char filename[8192];
strcpy(filename, cdoOperatorName(operatorID));
strcat(filename, "_");
strcat(filename, cdoStreamName(1)->args);
......@@ -345,7 +347,7 @@ void *XTimstat(void *argument)
if ( nsets == 0 )
{
memcpy(vars1[varID][levelID].ptr, input_vars[varID][levelID].ptr, nwpv*gridsize*sizeof(double));
farset(&vars1[varID][levelID], input_vars[varID][levelID]);
nmiss = input_vars[varID][levelID].nmiss;
vars1[varID][levelID].nmiss = nmiss;
if ( nmiss > 0 || samp1[varID][levelID].ptr )
......
......@@ -234,8 +234,6 @@ void vlistCompare(int vlistID1, int vlistID2, int flag)
int vlistCompareX(int vlistID1, int vlistID2, int flag)
{
int varID;
int nvars = vlistNvars(vlistID1);
int nvars2 = vlistNvars(vlistID2);
int nlevels2 = zaxisInqSize(vlistInqVarZaxis(vlistID2, 0));
......@@ -243,7 +241,7 @@ int vlistCompareX(int vlistID1, int vlistID2, int flag)
if ( nvars2 != 1 )
cdoAbort("Internal problem, vlistCompareX() called with unexpected vlistID2 argument!");
for ( varID = 0; varID < nvars; varID++ )
for ( int varID = 0; varID < nvars; varID++ )
{
if ( flag & CMP_GRIDSIZE )
{
......
......@@ -149,6 +149,7 @@ void farround(field_t *field);
void farfun(field_t *field1, field_t field2, const int function);
void farset(field_t *field1, field_t field2);
void faradd(field_t *field1, field_t field2);
void farsum(field_t *field1, field_t field2);
void farsumw(field_t *field1, field_t field2, double w);
......
......@@ -40,6 +40,31 @@ void farfun(field_t *field1, field_t field2, const int function)
else cdoAbort("%s: function %d not implemented!", __func__, function);
}
void farset(field_t *field1, field_t field2)
{
size_t i, len;
int nwpv = field1->nwpv;
const int grid1 = field1->grid;
const int nmiss1 = field1->nmiss;
const double missval1 = field1->missval;
double *array1 = field1->ptr;
const int grid2 = field2.grid;
const int nmiss2 = field2.nmiss;
const double missval2 = field2.missval;
double *array2 = field2.ptr;
if ( nwpv != 2 ) nwpv = 1;
len = (size_t) (nwpv*gridInqSize(grid1));
if ( len != (size_t) (nwpv*gridInqSize(grid2)) )
cdoAbort("Fields have different gridsize (%s)", __func__);
for ( i = 0; i < len; i++ )
array1[i] = array2[i];
}
static
void arradd(const size_t n, double * restrict a, const double * restrict b)
{
......
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