Commit 67511e93 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Merge declaration and definition

parent e0c8a360
......@@ -28,33 +28,22 @@
void *CDItest(void *argument)
{
int NCOPY;
int operatorID;
int streamID1, streamID2;
int n;
int nrecs;
int tsID1, tsID2, recID, varID, levelID;
int lcopy = FALSE;
int gridsize;
int vlistID1, vlistID2 = -1;
int recID, varID, levelID;
int nmiss;
int taxisID1, taxisID2 = CDI_UNDEFID;
int max_copy = 3;
double *array = NULL;
double s_utime, s_stime;
double e_utime, e_stime;
double c_cputime = 0, c_usertime = 0, c_systime = 0;
cdoInitialize(argument);
NCOPY = cdoOperatorAdd("ncopy", 0, 0, NULL);
bool lcopy = false;
//bool lcopy = UNCHANGED_RECORD;
int NCOPY = cdoOperatorAdd("ncopy", 0, 0, NULL);
UNUSED(NCOPY);
// if ( UNCHANGED_RECORD ) lcopy = TRUE;
operatorID = cdoOperatorID();
int operatorID = cdoOperatorID();
UNUSED(operatorID);
// operatorInputArg("Number of copies");
......@@ -62,27 +51,27 @@ void *CDItest(void *argument)
processStartTime(&s_utime, &s_stime);
n = 0;
int n = 0;
while ( TRUE )
{
streamID1 = streamOpenRead(cdoStreamName(0));
int streamID1 = streamOpenRead(cdoStreamName(0));
vlistID1 = streamInqVlist(streamID1);
taxisID1 = vlistInqTaxis(vlistID1);
int vlistID1 = streamInqVlist(streamID1);
int taxisID1 = vlistInqTaxis(vlistID1);
streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
vlistID2 = vlistDuplicate(vlistID1);
taxisID2 = taxisDuplicate(taxisID1);
int vlistID2 = vlistDuplicate(vlistID1);
int taxisID2 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID2, taxisID2);
streamDefVlist(streamID2, vlistID2);
gridsize = vlistGridsizeMax(vlistID1);
array = (double*) Malloc(gridsize*sizeof(double));
int gridsize = vlistGridsizeMax(vlistID1);
double *array = (double*) Malloc(gridsize*sizeof(double));
tsID1 = 0;
tsID2 = 0;
int tsID1 = 0;
int tsID2 = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID1)) )
{
taxisCopyTimestep(taxisID2, taxisID1);
......@@ -120,9 +109,9 @@ void *CDItest(void *argument)
cdoProcessTime(&e_utime, &e_stime);
c_usertime = e_utime - s_utime;
c_systime = e_stime - s_stime;
c_cputime = c_usertime + c_systime;
double c_usertime = e_utime - s_utime;
double c_systime = e_stime - s_stime;
double c_cputime = c_usertime + c_systime;
s_utime = e_utime;
s_stime = e_stime;
......
......@@ -42,8 +42,7 @@ void *Cat(void *argument)
cdoInitialize(argument);
bool lcopy = false;
if ( UNCHANGED_RECORD ) lcopy = true;
bool lcopy = UNCHANGED_RECORD;
int timer_cat = timer_new("cat");
if ( cdoTimer ) timer_start(timer_cat);
......
......@@ -43,13 +43,12 @@ void *Copy(void *argument)
cdoInitialize(argument);
bool lcopy = UNCHANGED_RECORD;
cdoOperatorAdd("copy", 0, 0, NULL);
int SELALL = cdoOperatorAdd("selall", 0, 0, NULL);
int SZIP = cdoOperatorAdd("szip", 0, 0, NULL);
bool lcopy = false;
if ( UNCHANGED_RECORD ) lcopy = true;
int operatorID = cdoOperatorID();
if ( operatorID == SZIP )
......
......@@ -25,19 +25,12 @@
void *Deltime(void *argument)
{
int DELDAY, DEL29FEB;
int operatorID;
int streamID1, streamID2;
int tsID, tsID2, nrecs;
int nrecs;
int recID, varID, levelID;
int vlistID1, vlistID2;
int taxisID1, taxisID2;
int vdate /*, vtime */;
int copytimestep;
int lcopy = FALSE;
int gridsize;
int nmiss;
int nfound;
int year, month, day;
int dday, dmon;
double *array = NULL;
......@@ -45,12 +38,14 @@ void *Deltime(void *argument)
cdoInitialize(argument);
DELDAY = cdoOperatorAdd("delday", 0, 0, NULL);
DEL29FEB = cdoOperatorAdd("del29feb", 0, 0, NULL);
bool lcopy = UNCHANGED_RECORD;
int DELDAY = cdoOperatorAdd("delday", 0, 0, NULL);
int DEL29FEB = cdoOperatorAdd("del29feb", 0, 0, NULL);
UNUSED(DELDAY);
operatorID = cdoOperatorID();
int operatorID = cdoOperatorID();
if ( operatorID == DEL29FEB )
{
......@@ -84,19 +79,17 @@ void *Deltime(void *argument)
if ( cdoVerbose ) cdoPrint("delete day %d%s", dday, cmons[dmon]);
if ( UNCHANGED_RECORD ) lcopy = TRUE;
streamID1 = streamOpenRead(cdoStreamName(0));
int streamID1 = streamOpenRead(cdoStreamName(0));
vlistID1 = streamInqVlist(streamID1);
vlistID2 = vlistDuplicate(vlistID1);
int vlistID1 = streamInqVlist(streamID1);
int vlistID2 = vlistDuplicate(vlistID1);
taxisID1 = vlistInqTaxis(vlistID1);
taxisID2 = taxisDuplicate(taxisID1);
int taxisID1 = vlistInqTaxis(vlistID1);
int taxisID2 = taxisDuplicate(taxisID1);
taxisDefCalendar(taxisID2, CALENDAR_365DAYS);
vlistDefTaxis(vlistID2, taxisID2);
streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
streamDefVlist(streamID2, vlistID2);
......@@ -106,9 +99,9 @@ void *Deltime(void *argument)
array = (double*) Malloc(gridsize*sizeof(double));
}
nfound = 0;
tsID = 0;
tsID2 = 0;
int nfound = 0;
int tsID = 0;
int tsID2 = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
{
vdate = taxisInqVdate(taxisID1);
......
......@@ -34,47 +34,40 @@
void *FC(void *argument)
{
int FC2SP, SP2FC, FC2GP, GP2FC;
int operatorID;
int streamID1, streamID2;
int nrecs, nvars;
int tsID, recID, varID, levelID;
int gridsize;
int index, ngrids;
int vlistID1, vlistID2;
int recID, varID, levelID;
int index;
int gridIDsp = -1, gridIDgp = -1, gridIDfc = -1;
int gridID1 = -1, gridID2 = -1;
int gridID;
int nmiss;
int *vars;
int lcopy = FALSE;
int taxisID1, taxisID2;
int nlon = 0, nlat = 0, ntr = 0;
int nsp = 0, nfc = 0;
double *array1 = NULL, *array2 = NULL;
double *array2 = NULL;
SPTRANS *sptrans = NULL;
cdoInitialize(argument);
FC2SP = cdoOperatorAdd("fc2sp", 0, 0, NULL);
SP2FC = cdoOperatorAdd("sp2fc", 0, 0, NULL);
FC2GP = cdoOperatorAdd("fc2gp", 0, 0, NULL);
GP2FC = cdoOperatorAdd("gp2fc", 0, 0, NULL);
bool lcopy = UNCHANGED_RECORD;
operatorID = cdoOperatorID();
int FC2SP = cdoOperatorAdd("fc2sp", 0, 0, NULL);
int SP2FC = cdoOperatorAdd("sp2fc", 0, 0, NULL);
int FC2GP = cdoOperatorAdd("fc2gp", 0, 0, NULL);
int GP2FC = cdoOperatorAdd("gp2fc", 0, 0, NULL);
if ( UNCHANGED_RECORD ) lcopy = TRUE;
int operatorID = cdoOperatorID();
streamID1 = streamOpenRead(cdoStreamName(0));
int streamID1 = streamOpenRead(cdoStreamName(0));
vlistID1 = streamInqVlist(streamID1);
vlistID2 = vlistDuplicate(vlistID1);
int vlistID1 = streamInqVlist(streamID1);
int vlistID2 = vlistDuplicate(vlistID1);
taxisID1 = vlistInqTaxis(vlistID1);
taxisID2 = taxisDuplicate(taxisID1);
int taxisID1 = vlistInqTaxis(vlistID1);
int taxisID2 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID2, taxisID2);
ngrids = vlistNgrids(vlistID1);
int ngrids = vlistNgrids(vlistID1);
/* find first spectral grid */
for ( index = 0; index < ngrids; index++ )
{
......@@ -239,12 +232,12 @@ void *FC(void *argument)
if ( gridID1 != -1 ) vlistChangeGrid(vlistID2, gridID1, gridID2);
streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
streamDefVlist(streamID2, vlistID2);
gridsize = vlistGridsizeMax(vlistID1);
array1 = (double*) Malloc(gridsize*sizeof(double));
int gridsize = vlistGridsizeMax(vlistID1);
double *array1 = (double*) Malloc(gridsize*sizeof(double));
if ( gridID2 != -1 )
{
......@@ -252,7 +245,7 @@ void *FC(void *argument)
array2 = (double*) Malloc(gridsize*sizeof(double));
}
tsID = 0;
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
{
taxisCopyTimestep(taxisID2, taxisID1);
......
......@@ -90,12 +90,11 @@ void *Invertlev(void *argument)
int nmiss;
int nlev, nlevel;
int gridID, zaxisID, offset;
int lcopy = FALSE;
int linvert = FALSE;
bool linvert = false;
cdoInitialize(argument);
if ( UNCHANGED_RECORD ) lcopy = TRUE;
bool lcopy = UNCHANGED_RECORD;
cdoOperatorAdd("invertlev", func_all, 0, NULL);
......@@ -140,13 +139,13 @@ void *Invertlev(void *argument)
}
else
{
linvert = TRUE;
linvert = true;
vardata[varID] = (double*) Malloc(gridsize*nlev*sizeof(double));
varnmiss[varID] = (int*) Malloc(nlev*sizeof(int));
}
}
if ( linvert == FALSE ) cdoWarning("No variables with invertable levels found!");
if ( linvert == false ) cdoWarning("No variables with invertable levels found!");
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
......
......@@ -133,14 +133,13 @@ void *Merge(void *argument)
int nrecs = 0;
int recID, levelID, levelID2;
int index;
int lcopy = FALSE;
int gridsize;
int nmiss;
//int skip_same_var = FALSE;
cdoInitialize(argument);
if ( UNCHANGED_RECORD ) lcopy = TRUE;
bool lcopy = UNCHANGED_RECORD;
/*
{
......
......@@ -36,12 +36,11 @@ void *Mergetime(void *argument)
int vlistID1, vlistID2;
int fileID;
int taxisID1, taxisID2 = CDI_UNDEFID;
int lcopy = FALSE;
int nmiss;
int vdate, vtime;
int last_vdate = -1, last_vtime = -1;
int next_fileID;
int skip_same_time = FALSE;
bool skip_same_time = false;
double *array = NULL;
typedef struct
{
......@@ -65,14 +64,14 @@ void *Mergetime(void *argument)
ival = atoi(envstr);
if ( ival == 1 )
{
skip_same_time = TRUE;
skip_same_time = true;
if ( cdoVerbose )
cdoPrint("Set SKIP_SAME_TIME to %d", ival);
}
}
}
if ( UNCHANGED_RECORD ) lcopy = TRUE;
bool lcopy = UNCHANGED_RECORD;
int nfiles = cdoStreamCnt() - 1;
......
......@@ -90,8 +90,7 @@ void *Select(void *argument)
int SELECT = cdoOperatorAdd("select", 0, 0, "parameter list");
int DELETE = cdoOperatorAdd("delete", 0, 0, "parameter list");
bool lcopy = false;
if ( UNCHANGED_RECORD ) lcopy = true;
bool lcopy = UNCHANGED_RECORD;
int operatorID = cdoOperatorID();
......
......@@ -23,38 +23,33 @@
void *Seloperator(void *argument)
{
int streamID1, streamID2 = CDI_UNDEFID;
int nrecs;
int tsID, recID, varID, levelID;
int vlistID1, vlistID2;
int taxisID1, taxisID2;
int scode, sltype;
int recID, varID, levelID;
double slevel = 0, level;
int nvars, nlevs, code, zaxisID, selfound = FALSE;
int nlevs, code, zaxisID, selfound = FALSE;
int levID, ltype = 0;
int varID2, levelID2;
int sellevel, selcode, selltype;
int lcopy = FALSE;
int gridsize, nmiss;
double *array = NULL;
cdoInitialize(argument);
if ( UNCHANGED_RECORD ) lcopy = TRUE;
bool lcopy = UNCHANGED_RECORD;
operatorInputArg("code, ltype, level");
scode = parameter2int(operatorArgv()[0]);
sltype = parameter2int(operatorArgv()[1]);
int scode = parameter2int(operatorArgv()[0]);
int sltype = parameter2int(operatorArgv()[1]);
if ( operatorArgc() == 3 )
slevel = parameter2double(operatorArgv()[2]);
streamID1 = streamOpenRead(cdoStreamName(0));
int streamID1 = streamOpenRead(cdoStreamName(0));
vlistID1 = streamInqVlist(streamID1);
int vlistID1 = streamInqVlist(streamID1);
nvars = vlistNvars(vlistID1);
int nvars = vlistNvars(vlistID1);
for ( varID = 0; varID < nvars; varID++ )
{
code = vlistInqVarCode(vlistID1, varID);
......@@ -93,14 +88,14 @@ void *Seloperator(void *argument)
if ( selfound == FALSE )
cdoWarning("Code %d, ltype %d, level %g not found!", scode, sltype, slevel);
vlistID2 = vlistCreate();
int vlistID2 = vlistCreate();
vlistCopyFlag(vlistID2, vlistID1);
taxisID1 = vlistInqTaxis(vlistID1);
taxisID2 = taxisDuplicate(taxisID1);
int taxisID1 = vlistInqTaxis(vlistID1);
int taxisID2 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID2, taxisID2);
streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
streamDefVlist(streamID2, vlistID2);
......@@ -110,7 +105,7 @@ void *Seloperator(void *argument)
array = (double*) Malloc(gridsize*sizeof(double));
}
tsID = 0;
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
{
taxisCopyTimestep(taxisID2, taxisID1);
......
......@@ -199,6 +199,8 @@ void *Seltime(void *argument)
cdoInitialize(argument);
bool lcopy = UNCHANGED_RECORD;
int SELTIMESTEP = cdoOperatorAdd("seltimestep", func_step, 0, "timesteps");
int SELDATE = cdoOperatorAdd("seldate", func_datetime, 0, "start date and end date (format YYYY-MM-DDThh:mm:ss)");
int SELTIME = cdoOperatorAdd("seltime", func_time, 0, "times (format hh:mm:ss)");
......@@ -213,9 +215,6 @@ void *Seltime(void *argument)
int operfunc = cdoOperatorF1(operatorID);
int lcopy = FALSE;
if ( UNCHANGED_RECORD ) lcopy = TRUE;
operatorInputArg(cdoOperatorEnter(operatorID));
if ( operatorID == SELSEASON )
......
......@@ -64,7 +64,6 @@ void *Selvar(void *argument)
char **argnames = NULL;
int isel;
int i;
int lcopy = FALSE;
int gridsize;
int nmiss;
int gridnum = 0;
......@@ -74,6 +73,8 @@ void *Selvar(void *argument)
cdoInitialize(argument);
bool lcopy = UNCHANGED_RECORD;
# define INVERTS_SELECTION(id) (cdoOperatorF2(id) & 1)
# define TAKES_STRINGS(id) (cdoOperatorF2(id) & 2)
# define TAKES_INTEGERS(id) (cdoOperatorF2(id) & 4)
......@@ -94,8 +95,6 @@ void *Selvar(void *argument)
int DELNAME = cdoOperatorAdd("delname", 0, 2|1, "variable names");
int SELLTYPE = cdoOperatorAdd("selltype", 0, 4, "GRIB level types");
if ( UNCHANGED_RECORD ) lcopy = TRUE;
int operatorID = cdoOperatorID();
operatorInputArg(cdoOperatorEnter(operatorID));
......
......@@ -24,38 +24,32 @@
void *Setrcaname(void *argument)
{
int streamID1, streamID2 = CDI_UNDEFID;
int nrecs;
int tsID, recID, varID, levelID;
int vlistID1, vlistID2;
int taxisID1, taxisID2;
int recID, varID, levelID;
char **rcsnames;
FILE *fp;
char line[MAX_LINE_LEN];
char sname[CDI_MAX_NAME], sdescription[CDI_MAX_NAME], sunits[CDI_MAX_NAME];
int scode, sltype, slevel;
int nvars;
int zaxisID, ltype, code, nlev;
int level;
int lcopy = FALSE;
int gridsize, nmiss;
double *array = NULL;
cdoInitialize(argument);
if ( UNCHANGED_RECORD ) lcopy = TRUE;
bool lcopy = UNCHANGED_RECORD;
operatorInputArg("file name with RCA names");
rcsnames = operatorArgv();
streamID1 = streamOpenRead(cdoStreamName(0));
int streamID1 = streamOpenRead(cdoStreamName(0));
vlistID1 = streamInqVlist(streamID1);
vlistID2 = vlistDuplicate(vlistID1);
int vlistID1 = streamInqVlist(streamID1);
int vlistID2 = vlistDuplicate(vlistID1);
nvars = vlistNvars(vlistID2);
int nvars = vlistNvars(vlistID2);
fp = fopen(rcsnames[0], "r");
FILE *fp = fopen(rcsnames[0], "r");
if ( fp != NULL )
{
while ( readline(fp, line, MAX_LINE_LEN) )
......@@ -110,11 +104,11 @@ void *Setrcaname(void *argument)
perror(rcsnames[0]);
}
taxisID1 = vlistInqTaxis(vlistID1);
taxisID2 = taxisDuplicate(taxisID1);
int taxisID1 = vlistInqTaxis(vlistID1);
int taxisID2 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID2, taxisID2);
streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
streamDefVlist(streamID2, vlistID2);
......@@ -124,7 +118,7 @@ void *Setrcaname(void *argument)
array = (double*) Malloc(gridsize*sizeof(double));
}
tsID = 0;
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
{
taxisCopyTimestep(taxisID2, taxisID1);
......
......@@ -38,14 +38,9 @@
void *Spectral(void *argument)
{
int GP2SP, GP2SPL, SP2GP, SP2GPL, SP2SP, SPCUT;
int operatorID;
int streamID1, streamID2;
int nrecs, nvars;
int tsID, recID, varID, levelID;
int gridsize;
int index, ngrids;
int vlistID1, vlistID2;
int varID, levelID;
int index;
int gridIDsp = -1, gridIDgp = -1;
int gridID1 = -1, gridID2 = -1;
int gridID;
......@@ -53,36 +48,34 @@ void *Spectral(void *argument)
int ncut = 0;
int *wnums = NULL, *waves = NULL;
int *vars;
int lcopy = FALSE;
double *array1 = NULL, *array2 = NULL;
int taxisID1, taxisID2;
double *array2 = NULL;
int nlon, nlat, ntr;
SPTRANS *sptrans = NULL;
LIST *ilist = listNew(INT_LIST);
cdoInitialize(argument);
GP2SP = cdoOperatorAdd("gp2sp", 0, 0, NULL);
GP2SPL = cdoOperatorAdd("gp2spl", 0, 0, NULL);
SP2GP = cdoOperatorAdd("sp2gp", 0, 0, NULL);
SP2GPL = cdoOperatorAdd("sp2gpl", 0, 0, NULL);
SP2SP = cdoOperatorAdd("sp2sp", 0, 0, NULL);
SPCUT = cdoOperatorAdd("spcut", 0, 0, NULL);
bool lcopy = UNCHANGED_RECORD;
operatorID = cdoOperatorID();
int GP2SP = cdoOperatorAdd("gp2sp", 0, 0, NULL);
int GP2SPL = cdoOperatorAdd("gp2spl", 0, 0, NULL);
int SP2GP = cdoOperatorAdd("sp2gp", 0, 0, NULL);
int SP2GPL = cdoOperatorAdd("sp2gpl", 0, 0, NULL);
int SP2SP = cdoOperatorAdd("sp2sp", 0, 0, NULL);
int SPCUT = cdoOperatorAdd("spcut", 0, 0, NULL);
if ( UNCHANGED_RECORD ) lcopy = TRUE;
int operatorID = cdoOperatorID();
streamID1 = streamOpenRead(cdoStreamName(0));
int streamID1 = streamOpenRead(cdoStreamName(0));
vlistID1 = streamInqVlist(streamID1);
vlistID2 = vlistDuplicate(vlistID1);
int vlistID1 = streamInqVlist(streamID1);
int vlistID2 = vlistDuplicate(vlistID1);
taxisID1 = vlistInqTaxis(vlistID1);
taxisID2 = taxisDuplicate(taxisID1);
int taxisID1 = vlistInqTaxis(vlistID1);
int taxisID2 = taxisDuplicate(taxisID1);