Commit 86ad8418 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Merge declaration and definition.

parent f3c52ac4
......@@ -169,46 +169,35 @@ void calc_adipot(long gridsize, long nlevel, double *pressure, field_t t, field_
void *Adisit(void *argument)
{
int operatorID, ADISIT, ADIPOT;
int streamID1, streamID2;
int nrecs;
int tsID, recID, varID, levelID;
int nlevel1, nlevel2;
int gridsize;
int nvars, code, gridID, zaxisID;
int vlistID1, vlistID2;
int varID, levelID;
int offset;
int nlevel;
int i;
int nmiss;
int thoID = -1, saoID = -1;
int tisID2, saoID2;
char varname[CDI_MAX_NAME], stdname[CDI_MAX_NAME];
int taxisID1, taxisID2;
double pin = -1;
double *pressure;
double *single;
field_t tho, sao, tis;
cdoInitialize(argument);
ADISIT = cdoOperatorAdd("adisit", 1, 1, "");
ADIPOT = cdoOperatorAdd("adipot", 1, 1, "");
int ADISIT = cdoOperatorAdd("adisit", 1, 1, "");
int ADIPOT = cdoOperatorAdd("adipot", 1, 1, "");
UNUSED(ADIPOT);
operatorID = cdoOperatorID();
int operatorID = cdoOperatorID();
if ( operatorArgc() == 1 ) pin = parameter2double(operatorArgv()[0]);
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);
int code = vlistInqVarCode(vlistID1, varID);
if ( code <= 0 )
{
......@@ -236,18 +225,18 @@ void *Adisit(void *argument)
if ( saoID == -1 ) cdoAbort("Sea water salinity not found!");
if ( thoID == -1 ) cdoAbort("Potential or Insitu temperature not found!");
gridID = vlistGrid(vlistID1, 0);
gridsize = vlist_check_gridsize(vlistID1);
int gridID = vlistGrid(vlistID1, 0);
int gridsize = vlist_check_gridsize(vlistID1);
zaxisID = vlistInqVarZaxis(vlistID1, saoID);
nlevel1 = zaxisInqSize(zaxisID);
zaxisID = vlistInqVarZaxis(vlistID1, thoID);
nlevel2 = zaxisInqSize(zaxisID);
int zaxisID = vlistInqVarZaxis(vlistID1, saoID);
int nlevel1 = zaxisInqSize(zaxisID);
zaxisID = vlistInqVarZaxis(vlistID1, thoID);
int nlevel2 = zaxisInqSize(zaxisID);
if ( nlevel1 != nlevel2 ) cdoAbort("temperature and salinity have different number of levels!");
nlevel = nlevel1;
int nlevel = nlevel1;
pressure = (double*) Malloc(nlevel*sizeof(double));
double *pressure = (double*) Malloc(nlevel*sizeof(double));
zaxisInqLevels(zaxisID, pressure);
if ( pin >= 0 )
......@@ -262,6 +251,7 @@ void *Adisit(void *argument)
cdoPrint("%5d %g", i+1, pressure[i]);
}
field_t tho, sao, tis;
field_init(&tho);
field_init(&sao);
field_init(&tis);
......@@ -278,9 +268,9 @@ void *Adisit(void *argument)
tis.missval = tho.missval;
vlistID2 = vlistCreate();
int vlistID2 = vlistCreate();
tisID2 = vlistDefVar(vlistID2, gridID, zaxisID, TIME_VARIABLE);
int tisID2 = vlistDefVar(vlistID2, gridID, zaxisID, TIME_VARIABLE);
if (operatorID == ADISIT)
{
vlistDefVarParam(vlistID2, tisID2, cdiEncodeParam(20, 255, 255));
......@@ -298,7 +288,7 @@ void *Adisit(void *argument)
vlistDefVarUnits(vlistID2, tisID2, "K");
vlistDefVarMissval(vlistID2, tisID2, tis.missval);
saoID2 = vlistDefVar(vlistID2, gridID, zaxisID, TIME_VARIABLE);
int saoID2 = vlistDefVar(vlistID2, gridID, zaxisID, TIME_VARIABLE);
vlistDefVarParam(vlistID2, saoID2, cdiEncodeParam(5, 255, 255));
vlistDefVarName(vlistID2, saoID2, "s");
vlistDefVarLongname(vlistID2, saoID2, "Sea water salinity");
......@@ -307,22 +297,22 @@ void *Adisit(void *argument)
vlistDefVarMissval(vlistID2, saoID2, sao.missval);
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);
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);
......@@ -340,7 +330,7 @@ void *Adisit(void *argument)
}
}
if (operatorID == ADISIT )
if ( operatorID == ADISIT )
{
calc_adisit(gridsize, nlevel, pressure, tho, sao, tis);
}
......
......@@ -64,7 +64,7 @@ int stdin_is_tty = 0; /* true if stdin is character device */
int stdout_is_tty = 0; /* true if stdout is character device */
#endif
static int lstdout = 1;
static bool lstdout = true;
static int Source = 0;
......@@ -89,11 +89,11 @@ static int oVertID = -1;
static int Lhybrid2pressure = FALSE;
int TsID;
static int TsID;
#if defined (HAVE_LIBPTHREAD)
int ParallelRead = TRUE;
static bool ParallelRead = true;
#else
int ParallelRead = FALSE;
static bool ParallelRead = false;
#endif
#define TIMESTEP_INTERVAL -1
......@@ -102,8 +102,8 @@ int ParallelRead = FALSE;
#define UNLIM_INTERVAL 2
#define MaxHours 24
int nrqh;
int hours[MaxHours+1];
static int nrqh;
static int hours[MaxHours+1];
static double *LevelFound;
......@@ -182,7 +182,7 @@ void after_PostProcess(struct Control *globs)
static
void after_SwitchFile(struct Control *globs)
{
int echam4 = FALSE;
bool echam4 = false;
int i, n;
char y3, y2, y1, y0;
char m1, m0;
......@@ -201,7 +201,7 @@ void after_SwitchFile(struct Control *globs)
if ( ifile[i-3] == '.' )
{
echam4 = TRUE;
echam4 = true;
y3 = ifile[i-9]; y2 = ifile[i-8];
y1 = ifile[i-7]; y0 = ifile[i-6];
m1 = ifile[i-5]; m0 = ifile[i-4];
......@@ -625,7 +625,7 @@ static
void after_control(struct Control *globs, struct Variable *vars)
{
int i;
int tsFirst, nrecs;
int nrecs;
int rdate, rtime;
int vdate, vtime;
int code;
......@@ -699,7 +699,7 @@ void after_control(struct Control *globs, struct Variable *vars)
globs->OldDate = globs->NewDate;
tsFirst = TRUE;
bool tsFirst = true;
while ( nrecs > 0 )
{
......@@ -708,9 +708,9 @@ void after_control(struct Control *globs, struct Variable *vars)
rarg.vars = vars;
rarg.globs = globs;
if ( tsFirst || ParallelRead == FALSE )
if ( tsFirst || ParallelRead == false )
{
if ( ParallelRead == FALSE )
if ( ParallelRead == false )
{
statusp = after_readTimestep(&rarg);
}
......@@ -735,7 +735,7 @@ void after_control(struct Control *globs, struct Variable *vars)
Error("after_readTimestep error! (status = %d)", *(int *)statusp);
}
#endif
tsFirst = FALSE;
tsFirst = false;
}
#if defined(HAVE_LIBPTHREAD)
else
......@@ -2285,7 +2285,7 @@ int afterburner(int argc, char *argv[])
fprintf(stderr, "byte size of type double %d\n", (int) sizeof(double));
fprintf(stderr, "byte size of type int %d\n", (int) sizeof(int));
fprintf(stderr, "byte size of type size_t %d\n", (int) sizeof(size_t));
return(1);
return 1;
}
fp = fopen("/pf/m/m214003/doc/afterburner.doc","r");
......@@ -2317,7 +2317,7 @@ int afterburner(int argc, char *argv[])
case 'b': Message( "option -b not longer needed!"); break;
case 'c': after_printCodes(); break;
case 'd': globs->Debug = 1; break;
case 'p': ParallelRead = TRUE; break;
case 'p': ParallelRead = true; break;
case 'P': numThreads = atoi(optarg); break;
case 'V': after_version(); break;
case 'v': Vctfile = optarg; break;
......@@ -2326,7 +2326,7 @@ int afterburner(int argc, char *argv[])
}
#if defined (_OPENMP)
/* ParallelRead = TRUE; */
/* ParallelRead = true; */
lprintf(stdout);
if ( numThreads <= 0 ) numThreads = 1;
......@@ -2338,7 +2338,7 @@ int afterburner(int argc, char *argv[])
if ( numThreads > 0 )
{
fprintf(stderr, "Option -P failed, OpenMP support not compiled in!\n");
return(-1);
return -1;
}
#endif
......@@ -2348,7 +2348,7 @@ int afterburner(int argc, char *argv[])
fprintf(stdout, " Parallel read enabled\n");
#else
fprintf(stdout, " Parallel read disabled\n");
ParallelRead = FALSE;
ParallelRead = false;
#endif
}
......@@ -2429,7 +2429,7 @@ int afterburner(int argc, char *argv[])
Free(globs);
return(0);
return 0;
}
#endif
......
......@@ -38,15 +38,12 @@ void *Arith(void *argument)
enum {FILL_NONE, FILL_TS, FILL_VAR, FILL_VARTS, FILL_FILE};
int filltype = FILL_NONE;
int nmiss;
int gridsize;
int nrecs, nrecs2, nvars = 0, nlev, recID;
int nrecs, nrecs2, nvars = 0, nlev;
int nlevels2 = 1;
int tsID, tsID2;
int varID, levelID;
int varID2, levelID2;
int offset;
int lfill1, lfill2;
int streamID3, vlistID3, taxisID3;
int *varnmiss2 = NULL;
int **varnmiss = NULL;
double *vardata2 = NULL;
......@@ -144,7 +141,7 @@ void *Arith(void *argument)
if ( filltype == FILL_NONE ) vlistCompare(vlistID1, vlistID2, CMP_ALL);
gridsize = vlistGridsizeMax(vlistIDx1);
int gridsize = vlistGridsizeMax(vlistIDx1);
field_init(&field1);
field_init(&field2);
......@@ -193,7 +190,7 @@ void *Arith(void *argument)
}
}
vlistID3 = vlistDuplicate(vlistIDx1);
int vlistID3 = vlistDuplicate(vlistIDx1);
if ( filltype == FILL_TS && vlistIDx1 != vlistID1 )
{
nvars = vlistNvars(vlistID1);
......@@ -201,15 +198,15 @@ void *Arith(void *argument)
vlistDefVarMissval(vlistID3, varID, vlistInqVarMissval(vlistID1, varID));
}
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;
tsID2 = 0;
int tsID = 0;
int tsID2 = 0;
while ( (nrecs = streamInqTimestep(streamIDx1, tsID)) )
{
if ( tsID == 0 || filltype == FILL_NONE || filltype == FILL_FILE || filltype == FILL_VARTS )
......@@ -248,7 +245,7 @@ void *Arith(void *argument)
streamDefTimestep(streamID3, tsID);
for ( recID = 0; recID < nrecs; recID++ )
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamIDx1, &varID, &levelID);
streamReadRecord(streamIDx1, fieldx1->ptr, &nmiss);
......
......@@ -66,14 +66,14 @@ int *fill_vars(int vlistID)
for ( varID = 0; varID < nvars; ++varID ) vars[varID] = 1;
}
return (vars);
return vars;
}
void *Arithc(void *argument)
{
int nmiss;
int nrecs, recID;
int nrecs;
int varID, levelID;
cdoInitialize(argument);
......@@ -120,7 +120,7 @@ void *Arithc(void *argument)
streamDefTimestep(streamID2, tsID);
for ( recID = 0; recID < nrecs; recID++ )
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
streamReadRecord(streamID1, field.ptr, &nmiss);
......
......@@ -40,7 +40,6 @@ double dayofyear(int calendar, int vdate, int vtime)
int month_365[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int month_366[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int *dpm;
int im, dpy;
int year, month, day;
int hour, minute, second;
double doy = 0;
......@@ -48,9 +47,9 @@ double dayofyear(int calendar, int vdate, int vtime)
cdiDecodeDate(vdate, &year, &month, &day);
cdiDecodeTime(vtime, &hour, &minute, &second);
dpy = days_per_year(calendar, year);
int dpy = days_per_year(calendar, year);
for ( im = 1; im < month; ++im )
for ( int im = 1; im < month; ++im )
{
if ( dpy == 360 ) dpm = month_360;
else if ( dpy == 365 ) dpm = month_365;
......@@ -71,61 +70,51 @@ double dayofyear(int calendar, int vdate, int vtime)
void *Arithdays(void *argument)
{
int MULDOY;
int operatorID;
int operfunc, operfunc2;
int streamID1, streamID2;
int gridsize;
int nrecs, recID;
int tsID;
int nrecs;
int varID, levelID;
int vlistID1, vlistID2;
int taxisID1, taxisID2;
int vdate, vtime;
int year, month, day;
int calendar;
int nmiss;
double rconst;
field_t field;
cdoInitialize(argument);
cdoOperatorAdd("muldpm", func_mul, func_month, NULL);
cdoOperatorAdd("divdpm", func_div, func_month, NULL);
cdoOperatorAdd("muldpy", func_mul, func_year, NULL);
cdoOperatorAdd("divdpy", func_div, func_year, NULL);
MULDOY = cdoOperatorAdd("muldoy", func_mul, 0, NULL);
cdoOperatorAdd("muldpm", func_mul, func_month, NULL);
cdoOperatorAdd("divdpm", func_div, func_month, NULL);
cdoOperatorAdd("muldpy", func_mul, func_year, NULL);
cdoOperatorAdd("divdpy", func_div, func_year, NULL);
int MULDOY = cdoOperatorAdd("muldoy", func_mul, 0, NULL);
operatorID = cdoOperatorID();
operfunc = cdoOperatorF1(operatorID);
operfunc2 = cdoOperatorF2(operatorID);
int operatorID = cdoOperatorID();
int operfunc = cdoOperatorF1(operatorID);
int operfunc2 = cdoOperatorF2(operatorID);
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);
calendar = taxisInqCalendar(taxisID1);
int calendar = taxisInqCalendar(taxisID1);
streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
streamDefVlist(streamID2, vlistID2);
gridsize = vlistGridsizeMax(vlistID1);
int gridsize = vlistGridsizeMax(vlistID1);
field_t field;
field_init(&field);
field.ptr = (double*) Malloc(gridsize*sizeof(double));
field.weight = NULL;
tsID = 0;
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
{
vdate = taxisInqVdate(taxisID1);
vtime = taxisInqVtime(taxisID1);
int vdate = taxisInqVdate(taxisID1);
int vtime = taxisInqVtime(taxisID1);
taxisCopyTimestep(taxisID2, taxisID1);
......@@ -148,7 +137,7 @@ void *Arithdays(void *argument)
if ( cdoVerbose )
cdoPrint("calendar %d year %d month %d result %g", calendar, year, month, rconst);
for ( recID = 0; recID < nrecs; recID++ )
for ( int recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
streamReadRecord(streamID1, field.ptr, &nmiss);
......
......@@ -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-2016 Uwe Schulzweida, <uwe.schulzweida AT mpimet.mpg.de>
Copyright (C) 2003-2016 Uwe Schulzweida, <uwe.schulzweida AT mpimet.m1pg.de>
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -32,60 +32,53 @@
void *Arithlat(void *argument)
{
int operatorID;
int operfunc;
int streamID1, streamID2;
int gridtype;
int gridID, gridID0 = -1;
int nrecs, recID;
int tsID;
int nrecs;
int varID, levelID;
int vlistID1, vlistID2;
int taxisID1, taxisID2;
int nmiss;
long gridsize, i;
long i;
char units[CDI_MAX_NAME];
double *scale = NULL;
double *array = NULL;
cdoInitialize(argument);
cdoOperatorAdd("mulcoslat", func_mul, 0, NULL);
cdoOperatorAdd("divcoslat", func_div, 0, NULL);
operatorID = cdoOperatorID();
operfunc = cdoOperatorF1(operatorID);
int operatorID = cdoOperatorID();
int operfunc = cdoOperatorF1(operatorID);
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);
streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
streamDefVlist(streamID2, vlistID2);
gridsize = vlistGridsizeMax(vlistID1);
long gridsize = vlistGridsizeMax(vlistID1);
array = (double*) Malloc(gridsize*sizeof(double));
double *array = (double*) Malloc(gridsize*sizeof(double));
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);
gridID = vlistInqVarGrid(vlistID1, varID);
int gridID = vlistInqVarGrid(vlistID1, varID);
if ( gridID != gridID0 )
{
......
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