Commit 3074abf1 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Merge declaration and definition.

parent 86ad8418
......@@ -81,13 +81,11 @@ void print_stat(const char *sinfo, int memtype, int datatype, int filetype, off_
void *CDIread(void *argument)
{
int memtype = CDO_Memtype;
int streamID;
int tsID, varID, levelID;
int gridsize, nmiss;
int recID, nrecs;
int vlistID;
int varID, levelID;
int nmiss;
int nrecs;
int filetype = -1, datatype = -1;
int irun, nruns = 1;
int nruns = 1;
char sinfo[64];
off_t nvalues = 0;
double file_size = 0, data_size = 0;
......@@ -112,31 +110,31 @@ void *CDIread(void *argument)
// vlistDefNtsteps(vlistID, 1);
for ( irun = 0; irun < nruns; ++irun )
for ( int irun = 0; irun < nruns; ++irun )
{
tw0 = timer_val(timer_read);
data_size = 0;
nvalues = 0;
streamID = streamOpenRead(cdoStreamName(0));
int streamID = streamOpenRead(cdoStreamName(0));
vlistID = streamInqVlist(streamID);
int vlistID = streamInqVlist(streamID);
filetype = streamInqFiletype(streamID);
datatype = vlistInqVarDatatype(vlistID, 0);
gridsize = vlistGridsizeMax(vlistID);
int gridsize = vlistGridsizeMax(vlistID);
if ( darray == NULL ) darray = (double*) Malloc(gridsize*sizeof(double));
if ( farray == NULL && memtype == MEMTYPE_FLOAT ) farray = (float*) Malloc(gridsize*sizeof(float));
t0 = timer_val(timer_read);
tsID = 0;
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID, tsID)) )
{
for ( recID = 0; recID < nrecs; recID++ )
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID, &varID, &levelID);
......
......@@ -39,14 +39,9 @@ int stringToParam(const char *paramstr);
void *Change(void *argument)
{
int CHCODE, CHTABNUM, CHPARAM, CHNAME, CHUNIT, CHLEVEL, CHLEVELC, CHLEVELV, CHLTYPE;
int operatorID;
int streamID1, streamID2 = CDI_UNDEFID;
int nrecs, nvars;
int tsID1, recID, varID = 0, levelID;
int vlistID1, vlistID2;
int taxisID1, taxisID2;
int chints[MAXARG], nch = 0;
int varID = 0, levelID;
int chints[MAXARG];
char *chnames[MAXARG];
char varname[CDI_MAX_NAME];
char *chname = NULL;
......@@ -54,32 +49,30 @@ void *Change(void *argument)
int param;
int code, tabnum, i;
int nmiss;
int gridsize;
int nfound;
int nzaxis, zaxisID1, zaxisID2, k, nlevs, index;
double chlevels[MAXARG];
int chltypes[MAXARG];
double *levels = NULL;
double *newlevels = NULL;
double *array = NULL;
cdoInitialize(argument);
CHCODE = cdoOperatorAdd("chcode", 0, 0, "pairs of old and new code numbers");
CHTABNUM = cdoOperatorAdd("chtabnum", 0, 0, "pairs of old and new GRIB1 table numbers");
CHPARAM = cdoOperatorAdd("chparam", 0, 0, "pairs of old and new parameter identifiers");
CHNAME = cdoOperatorAdd("chname", 0, 0, "pairs of old and new variable names");
CHUNIT = cdoOperatorAdd("chunit", 0, 0, "pairs of old and new variable units");
CHLEVEL = cdoOperatorAdd("chlevel", 0, 0, "pairs of old and new levels");
CHLEVELC = cdoOperatorAdd("chlevelc", 0, 0, "code number, old and new level");
CHLEVELV = cdoOperatorAdd("chlevelv", 0, 0, "variable name, old and new level");
CHLTYPE = cdoOperatorAdd("chltype", 0, 0, "pairs of old and new type");
int CHCODE = cdoOperatorAdd("chcode", 0, 0, "pairs of old and new code numbers");
int CHTABNUM = cdoOperatorAdd("chtabnum", 0, 0, "pairs of old and new GRIB1 table numbers");
int CHPARAM = cdoOperatorAdd("chparam", 0, 0, "pairs of old and new parameter identifiers");
int CHNAME = cdoOperatorAdd("chname", 0, 0, "pairs of old and new variable names");
int CHUNIT = cdoOperatorAdd("chunit", 0, 0, "pairs of old and new variable units");
int CHLEVEL = cdoOperatorAdd("chlevel", 0, 0, "pairs of old and new levels");
int CHLEVELC = cdoOperatorAdd("chlevelc", 0, 0, "code number, old and new level");
int CHLEVELV = cdoOperatorAdd("chlevelv", 0, 0, "variable name, old and new level");
int CHLTYPE = cdoOperatorAdd("chltype", 0, 0, "pairs of old and new type");
operatorID = cdoOperatorID();
int operatorID = cdoOperatorID();
operatorInputArg(cdoOperatorEnter(operatorID));
nch = operatorArgc();
int nch = operatorArgc();
if ( operatorID == CHCODE || operatorID == CHTABNUM )
{
......@@ -122,13 +115,13 @@ void *Change(void *argument)
chltypes[i] = parameter2int(operatorArgv()[i]);
}
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);
if ( operatorID == CHCODE )
......@@ -303,21 +296,21 @@ void *Change(void *argument)
}
}
streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
streamDefVlist(streamID2, vlistID2);
gridsize = vlistGridsizeMax(vlistID2);
array = (double*) Malloc(gridsize*sizeof(double));
int gridsize = vlistGridsizeMax(vlistID2);
double *array = (double*) Malloc(gridsize*sizeof(double));
tsID1 = 0;
int tsID1 = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID1)) )
{
taxisCopyTimestep(taxisID2, taxisID1);
streamDefTimestep(streamID2, tsID1);
for ( recID = 0; recID < nrecs; recID++ )
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
streamDefRecord(streamID2, varID, levelID);
......
......@@ -29,33 +29,24 @@
void *Change_e5slm(void *argument)
{
int streamIDslm, streamID1, streamID2;
const char *fn_slm;
char name[CDI_MAX_NAME];
int nrecs, code;
int tsID, recID, varID, levelID;
int gridsize;
int vlistIDslm, vlistID1, vlistID2 = -1;
int nmiss, nvars;
int taxisID1, taxisID2;
short *codes = NULL;
short *lsea = NULL;
int varID, levelID;
int nmiss;
long i;
double minval, maxval;
double *array = NULL;
double *cland = NULL;
cdoInitialize(argument);
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);
......@@ -64,20 +55,20 @@ void *Change_e5slm(void *argument)
/* get filename of SLM */
operatorInputArg("filename of the sea land mask");
operatorCheckArgc(1);
fn_slm = operatorArgv()[0];
const char *fn_slm = operatorArgv()[0];
/* read SLM */
argument_t *fileargument = file_argument_new(fn_slm);
streamIDslm = streamOpenRead(fileargument);
int streamIDslm = streamOpenRead(fileargument);
file_argument_free(fileargument);
vlistIDslm = streamInqVlist(streamIDslm);
int vlistIDslm = streamInqVlist(streamIDslm);
gridsize = gridInqSize(vlistInqVarGrid(vlistIDslm, 0));
int gridsize = gridInqSize(vlistInqVarGrid(vlistIDslm, 0));
array = (double*) Malloc(gridsize*sizeof(double));
cland = (double*) Malloc(gridsize*sizeof(double));
lsea = (short*) Malloc(gridsize*sizeof(short));
double *array = (double*) Malloc(gridsize*sizeof(double));
double *cland = (double*) Malloc(gridsize*sizeof(double));
bool *lsea = (bool*) Malloc(gridsize*sizeof(bool));
streamInqTimestep(streamIDslm, 0);
......@@ -95,14 +86,14 @@ void *Change_e5slm(void *argument)
for ( i = 0; i < gridsize; ++i )
{
if ( cland[i] > 0 )
lsea[i] = FALSE;
lsea[i] = false;
else
lsea[i] = TRUE;
lsea[i] = true;
}
nvars = vlistNvars(vlistID1);
codes = (short*) Malloc(nvars*sizeof(short));
int nvars = vlistNvars(vlistID1);
short *codes = (short*) Malloc(nvars*sizeof(short));
for ( varID = 0; varID < nvars; ++varID )
{
......@@ -132,14 +123,14 @@ void *Change_e5slm(void *argument)
}
tsID = 0;
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
{
taxisCopyTimestep(taxisID2, taxisID1);
streamDefTimestep(streamID2, tsID);
for ( recID = 0; recID < nrecs; recID++ )
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
streamReadRecord(streamID1, array, &nmiss);
......
......@@ -123,7 +123,7 @@ void pl_index(int *kmax, int *kmin, double pmax, double pmin, long nlevs, double
void *Cloudlayer(void *argument)
{
int gridID, zaxisID;
int nlevel, nlevs, nrecs, recID, code;
int nlevel, nlevs, nrecs, code;
int varID, levelID;
int zrev = FALSE;
int i;
......@@ -135,7 +135,6 @@ void *Cloudlayer(void *argument)
int kmin[NVARS], kmax[NVARS];
char varname[CDI_MAX_NAME];
double sfclevel = 0;
double *plevs = NULL;
double *cloud[NVARS];
double pmin = 0, pmax = 0;
......@@ -206,7 +205,7 @@ void *Cloudlayer(void *argument)
if ( zaxisInqType(zaxisID) == ZAXIS_PRESSURE )
{
plevs = (double*) Malloc(nlevel*sizeof(double));
double *plevs = (double*) Malloc(nlevel*sizeof(double));
zaxisInqLevels(zaxisID, plevs);
if ( plevs[0] > plevs[nlevel-1] )
{
......@@ -240,18 +239,14 @@ void *Cloudlayer(void *argument)
}
else if ( zaxisInqType(zaxisID) == ZAXIS_HYBRID )
{
int nvct;
nvct = zaxisInqVctSize(zaxisID);
int nvct = zaxisInqVctSize(zaxisID);
if ( nlevel == (nvct/2 - 1) )
{
double *vct;
vct = (double*) Malloc(nvct*sizeof(double));
double *vct = (double*) Malloc(nvct*sizeof(double));
zaxisInqVct(zaxisID, vct);
nlevs = nlevel + 1;
plevs = (double*) Malloc(nlevs*sizeof(double));
double *plevs = (double*) Malloc(nlevs*sizeof(double));
vct2plev(vct, plevs, nlevs);
Free(vct);
......@@ -324,7 +319,7 @@ void *Cloudlayer(void *argument)
streamDefTimestep(streamID2, tsID);
for ( recID = 0; recID < nrecs; recID++ )
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
......
......@@ -312,7 +312,7 @@ int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid, int nxblocks
void *Collgrid(void *argument)
{
int nxblocks = -1;
int varID, recID;
int varID;
int nrecs, nrecs0;
int levelID;
int nmiss;
......@@ -512,7 +512,7 @@ void *Collgrid(void *argument)
if ( nrecs0 > 0 ) streamDefTimestep(streamID2, tsID);
for ( recID = 0; recID < nrecs0; recID++ )
for ( int recID = 0; recID < nrecs0; recID++ )
{
streamInqRecord(ef[0].streamID, &varID, &levelID);
if ( cdoVerbose && tsID == 0 ) printf(" tsID, recID, varID, levelID %d %d %d %d\n", tsID, recID, varID, levelID);
......
......@@ -298,16 +298,14 @@ void readcmd(const char *prompt, char *line, int size)
void command_init()
{
int gridsize;
int taxisID;
int varID;
gl_vlistID = streamInqVlist(gl_streamID);
taxisID = vlistInqTaxis(gl_vlistID);
int taxisID = vlistInqTaxis(gl_vlistID);
UNUSED(taxisID);
gridsize = vlistGridsizeMax(gl_vlistID);
int gridsize = vlistGridsizeMax(gl_vlistID);
gl_data = (double*) Malloc(gridsize*sizeof(double));
gl_nvars = vlistNvars(gl_vlistID);
......
......@@ -34,57 +34,49 @@
void *Comp(void *argument)
{
int EQ, NE, LE, LT, GE, GT;
int operatorID;
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 gridsize1, gridsize2;
int nrecs, nrecs2, nvars = 0, nlev;
int varID, levelID;
int offset;
int ntsteps1, ntsteps2;
int vlistIDx1, vlistIDx2, vlistID1, vlistID2, vlistID3;
int taxisIDx1, taxisID1, taxisID2, taxisID3;
int nmiss1, nmiss2, nmiss3;
int i;
double missval1, missval2 = 0;
double *missvalx1, *missvalx2;
double *arrayx1, *arrayx2, *array1, *array2, *array3;
double **vardata = NULL;
cdoInitialize(argument);
EQ = cdoOperatorAdd("eq", 0, 0, NULL);
NE = cdoOperatorAdd("ne", 0, 0, NULL);
LE = cdoOperatorAdd("le", 0, 0, NULL);
LT = cdoOperatorAdd("lt", 0, 0, NULL);
GE = cdoOperatorAdd("ge", 0, 0, NULL);
GT = cdoOperatorAdd("gt", 0, 0, NULL);
int EQ = cdoOperatorAdd("eq", 0, 0, NULL);
int NE = cdoOperatorAdd("ne", 0, 0, NULL);
int LE = cdoOperatorAdd("le", 0, 0, NULL);
int LT = cdoOperatorAdd("lt", 0, 0, NULL);
int GE = cdoOperatorAdd("ge", 0, 0, NULL);
int GT = cdoOperatorAdd("gt", 0, 0, NULL);
operatorID = cdoOperatorID();
int operatorID = cdoOperatorID();
streamID1 = streamOpenRead(cdoStreamName(0));
streamID2 = streamOpenRead(cdoStreamName(1));
int streamID1 = streamOpenRead(cdoStreamName(0));
int streamID2 = streamOpenRead(cdoStreamName(1));
streamIDx1 = streamID1;
streamIDx2 = streamID2;
int streamIDx1 = streamID1;
int streamIDx2 = streamID2;
missvalx1 = &missval1;
missvalx2 = &missval2;
vlistID1 = streamInqVlist(streamID1);
vlistID2 = streamInqVlist(streamID2);
vlistIDx1 = vlistID1;
vlistIDx2 = vlistID2;
int vlistID1 = streamInqVlist(streamID1);
int vlistID2 = streamInqVlist(streamID2);
int vlistIDx1 = vlistID1;
int vlistIDx2 = vlistID2;
taxisID1 = vlistInqTaxis(vlistID1);
taxisID2 = vlistInqTaxis(vlistID2);
taxisIDx1 = taxisID1;
int taxisID1 = vlistInqTaxis(vlistID1);
int taxisID2 = vlistInqTaxis(vlistID2);
int taxisIDx1 = taxisID1;
ntsteps1 = vlistNtsteps(vlistID1);
ntsteps2 = vlistNtsteps(vlistID2);
int ntsteps1 = vlistNtsteps(vlistID1);
int ntsteps2 = vlistNtsteps(vlistID2);
if ( ntsteps1 == 0 ) ntsteps1 = 1;
if ( ntsteps2 == 0 ) ntsteps2 = 1;
......@@ -110,14 +102,14 @@ void *Comp(void *argument)
nospec(vlistID1);
nospec(vlistID2);
gridsize = vlistGridsizeMax(vlistIDx1);
int gridsize = vlistGridsizeMax(vlistIDx1);
array1 = (double*) Malloc(gridsize*sizeof(double));
array2 = (double*) Malloc(gridsize*sizeof(double));
array3 = (double*) Malloc(gridsize*sizeof(double));
double *array1 = (double*) Malloc(gridsize*sizeof(double));
double *array2 = (double*) Malloc(gridsize*sizeof(double));
double *array3 = (double*) Malloc(gridsize*sizeof(double));
arrayx1 = array1;
arrayx2 = array2;
double *arrayx1 = array1;
double *arrayx2 = array2;
if ( cdoVerbose )
cdoPrint("Number of timesteps: file1 %d, file2 %d", ntsteps1, ntsteps2);
......@@ -161,16 +153,16 @@ void *Comp(void *argument)
missvalx2 = &missval1;
}
vlistID3 = vlistDuplicate(vlistIDx1);
int vlistID3 = vlistDuplicate(vlistIDx1);
taxisID3 = taxisDuplicate(taxisIDx1);
int taxisID3 = taxisDuplicate(taxisIDx1);
vlistDefTaxis(vlistID3, taxisID3);
streamID3 = streamOpenWrite(cdoStreamName(2), cdoFiletype());
int streamID3 = streamOpenWrite(cdoStreamName(2), cdoFiletype());
streamDefVlist(streamID3, vlistID3);
tsID = 0;
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamIDx1, tsID)) )
{
if ( tsID == 0 || filltype == FILL_NONE )
......@@ -184,7 +176,7 @@ void *Comp(void *argument)
streamDefTimestep(streamID3, tsID);
for ( recID = 0; recID < nrecs; recID++ )
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamIDx1, &varID, &levelID);
streamReadRecord(streamIDx1, arrayx1, &nmiss1);
......
......@@ -35,64 +35,55 @@
void *Compc(void *argument)
{
int EQC, NEC, LEC, LTC, GEC, GTC;
int operatorID;
int streamID1, streamID2;
int gridsize;
int nrecs, recID;
int tsID;
int nrecs;
int varID, levelID;
int vlistID1, vlistID2;
int nmiss, nmiss2;
int i;
double missval;
double rc;
double *array1, *array2;
int taxisID1, taxisID2;
int rc_is_missval;
cdoInitialize(argument);
EQC = cdoOperatorAdd("eqc", 0, 0, NULL);
NEC = cdoOperatorAdd("nec", 0, 0, NULL);
LEC = cdoOperatorAdd("lec", 0, 0, NULL);
LTC = cdoOperatorAdd("ltc", 0, 0, NULL);
GEC = cdoOperatorAdd("gec", 0, 0, NULL);
GTC = cdoOperatorAdd("gtc", 0, 0, NULL);
int EQC = cdoOperatorAdd("eqc", 0, 0, NULL);
int NEC = cdoOperatorAdd("nec", 0, 0, NULL);
int LEC = cdoOperatorAdd("lec", 0, 0, NULL);
int LTC = cdoOperatorAdd("ltc", 0, 0, NULL);
int GEC = cdoOperatorAdd("gec", 0, 0, NULL);
int GTC = cdoOperatorAdd("gtc", 0, 0, NULL);
operatorID = cdoOperatorID();
int operatorID = cdoOperatorID();
operatorInputArg("constant value");
rc = parameter2double(operatorArgv()[0]);
double rc = parameter2double(operatorArgv()[0]);
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);
nospec(vlistID1);
gridsize = vlistGridsizeMax(vlistID1);
int gridsize = vlistGridsizeMax(vlistID1);
array1 = (double*) Malloc(gridsize*sizeof(double));
array2 = (double*) Malloc(gridsize*sizeof(double));
double *array1 = (double*) Malloc(gridsize*sizeof(double));
double *array2 = (double*) Malloc(gridsize*sizeof(double));
streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
streamDefVlist(streamID2, vlistID2);
tsID = 0;
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
{
taxisCopyTimestep(taxisID2, taxisID1);
streamDefTimestep(streamID2, tsID);
for ( recID = 0; recID < nrecs; recID++ )
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
streamReadRecord(streamID1, array1, &nmiss);
......
......@@ -24,31 +24,25 @@
void *Complextorect(void *argument)
{
// int COMPLEXTORECT;
// int operatorID;
int streamID1, streamID2, streamID3;
int tsID, nrecs;
int recID, varID, levelID;
int vlistID1, vlistID2, vlistID3;
int taxisID1, taxisID2, taxisID3;
int i, gridsize;
int nrecs;
int varID, levelID;
int i;
int datatype;
int nmiss, nvars;
double *array1 = NULL, *array2 = NULL, *array3 = NULL;
int nmiss;
cdoInitialize(argument);
// COMPLEXTORECT = cdoOperatorAdd("complextorect", 0, 0, NULL);
// int COMPLEXTORECT = cdoOperatorAdd("complextorect", 0, 0, NULL);
// operatorID = cdoOperatorID();
// int operatorID = cdoOperatorID();
streamID1 = streamOpenRead(cdoStreamName(0));
int streamID1 = streamOpenRead(cdoStreamName(0));
vlistID1 = streamInqVlist(streamID1);
vlistID2 = vlistDuplicate(vlistID1);
vlistID3 = vlistDuplicate(vlistID1);
int vlistID1 = streamInqVlist(streamID1);
int vlistID2 = vlistDuplicate(vlistID1);
int vlistID3 = vlistDuplicate(vlistID1);
nvars = vlistNvars(</