Commit b0ba3aee authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

now compiles with gcc g++ and clang++

parents 2d7c1e3a ff9c822c
......@@ -3,6 +3,18 @@
* using CDI library version 1.7.0
* Version 1.7.0 released
2015-08-14 Uwe Schulzweida
* select: select also ps for variables on hybrid sigma pressure levels
2015-08-12 Uwe Schulzweida
* selmon: does not work with negative years (bug fix) [report: Tim Brcher]
2015-08-08 Uwe Schulzweida
* replaced farcmul(array, 1./nsets) by farcdiv(array, (double)nsets) to get exactly the same result with and without missvals
2015-08-05 Uwe Schulzweida
* ap2pl: changed to generalized height
......
......@@ -35,14 +35,22 @@ case "${HOSTNAME}" in
--with-netcdf=$HOME/local/netcdf-c-4.3.3.1-threadsafe \
--with-hdf5=$HOME/local/hdf5-1.8.15-threadsafe \
--with-udunits2=/opt/local \
--with-curl=/opt/local"
# --with-proj=/opt/local \
# --with-szlib=$HOME/local \
--with-curl=/opt/local \
--with-proj=/opt/local \
--with-szlib=$HOME/local"
if test "$COMP" = icc ; then
${CONFPATH}configure \
$CDOLIBS \
CC=icc CFLAGS="-g -Wall -O2 -qopt-report=5 -march=native" CXX=icpc
elif test "$COMP" = icpc ; then
${CONFPATH}configure \
$CDOLIBS \
CC=icpc CFLAGS="-g -Wall -O2 -Drestrict= -qopt-report=5 -march=native"
elif test "$COMP" = clang++ ; then
${CONFPATH}configure \
$CDOLIBS \
CC=clang++ CFLAGS="-g -Wall -O3 -Drestrict="
elif test "$COMP" = clang ; then
${CONFPATH}configure \
$CDOLIBS \
......
......@@ -28,7 +28,7 @@ FLOAT Pressure levels in pascal
@BeginNote
This is a specific implememtation for netCDF files from the ICON model, it may not work with data from other sources.
This is a specific implementation for netCDF files from the ICON model, it may not work with data from other sources.
@EndNote
......
......@@ -6,8 +6,10 @@ to belong to the sample with the side effect of a probably reduced sample
size. Computing the average is just adding the sample members and divide
the result by the sample size. For example, the mean of 1, 2, miss and 3
is (1+2+3)/3 = 2, whereas the average is (1+2+miss+3)/4 = miss/4 = miss.
If there are no missing values in the sample, the average and the mean are
identical.\\
If there are no missing values in the sample, the average and the mean are identical.\\
This program is using the verification time to identify the time range
for time-statistics. The time bounds are never used! \\
In this section the abbreviations as in the following table are used:
\vspace{3mm}
......
......@@ -68,7 +68,7 @@ void *Intlevel3d(void *argument)
cdoInitialize(argument);
int INTLEVEL3D = cdoOperatorAdd("intlevel3d", 0, 0, NULL);
int INTLEVELX3D = cdoOperatorAdd("intlevelx3d", 0, 0, NULL);
int INTLEVELX3D = cdoOperatorAdd("intlevelx3d", 0, 0, NULL);
int operatorID = cdoOperatorID();
......@@ -311,7 +311,7 @@ void *Intlevel3d(void *argument)
streamDefVlist(streamID3, vlistID3);
maxlev = nlevi > nlevo ? nlevi : nlevo;
maxlev = nlevi > nlevo ? nlevi : nlevo;
nvars = vlistNvars(vlistID1);
vars = (int*) malloc(nvars*sizeof(int));
vardata1 = (double**) malloc(nvars*sizeof(double*)); /* input */
......
......@@ -28,61 +28,56 @@
#include "error.h"
static
void invertLevDes(int vlistID)
{
int index, nzaxis;
int zaxisID1, zaxisID2;
int nlev;
int ilev;
int zaxistype;
double *yv1, *yv2;
double *yb1, *yb2;
nzaxis = vlistNzaxis(vlistID);
for ( index = 0; index < nzaxis; index++ )
int nzaxis = vlistNzaxis(vlistID);
for ( int index = 0; index < nzaxis; index++ )
{
zaxisID1 = vlistZaxis(vlistID, index);
zaxisID2 = zaxisDuplicate(zaxisID1);
zaxistype = zaxisInqType(zaxisID1);
nlev = zaxisInqSize(zaxisID1);
int zaxisID1 = vlistZaxis(vlistID, index);
int zaxisID2 = zaxisDuplicate(zaxisID1);
int zaxistype = zaxisInqType(zaxisID1);
if ( nlev < 2 || zaxistype == ZAXIS_HYBRID || zaxistype == ZAXIS_HYBRID_HALF ) continue;
int nlev = zaxisInqSize(zaxisID1);
if ( nlev <= 1 ) continue;
/* if ( zaxisInqLevels(zaxisID1, NULL) ) */
{
yv1 = (double*) malloc(nlev*sizeof(double));
yv2 = (double*) malloc(nlev*sizeof(double));
double yv1[nlev], yv2[nlev];
zaxisInqLevels(zaxisID1, yv1);
for ( ilev = 0; ilev < nlev; ++ilev ) yv2[nlev-ilev-1] = yv1[ilev];
for ( int ilev = 0; ilev < nlev; ++ilev ) yv2[nlev-ilev-1] = yv1[ilev];
zaxisDefLevels(zaxisID2, yv2);
if ( yv2 ) free(yv2);
if ( yv1 ) free(yv1);
}
if ( zaxisInqLbounds(zaxisID1, NULL) && zaxisInqUbounds(zaxisID1, NULL) )
{
yb1 = (double*) malloc(nlev*sizeof(double));
yb2 = (double*) malloc(nlev*sizeof(double));
double yb1[nlev], yb2[nlev];
zaxisInqLbounds(zaxisID1, yb1);
for ( ilev = 0; ilev < nlev; ++ilev ) yb2[nlev-ilev-1] = yb1[ilev];
for ( int ilev = 0; ilev < nlev; ++ilev ) yb2[nlev-ilev-1] = yb1[ilev];
zaxisDefLbounds(zaxisID2, yb2);
zaxisInqUbounds(zaxisID1, yb1);
for ( ilev = 0; ilev < nlev; ++ilev ) yb2[nlev-ilev-1] = yb1[ilev];
for ( int ilev = 0; ilev < nlev; ++ilev ) yb2[nlev-ilev-1] = yb1[ilev];
zaxisDefUbounds(zaxisID2, yb2);
if ( yb2 ) free(yb2);
if ( yb1 ) free(yb1);
}
if ( zaxistype == ZAXIS_HYBRID || zaxistype == ZAXIS_HYBRID_HALF )
{
int vctsize = zaxisInqVctSize(zaxisID1);
if ( vctsize && vctsize%2 == 0 )
{
double vct1[vctsize];
double vct2[vctsize];
zaxisInqVct(zaxisID1, vct1);
for ( int i = 0; i < vctsize/2; ++i )
{
vct2[vctsize/2-1-i] = vct1[i];
vct2[vctsize-1-i] = vct1[vctsize/2+i];
}
zaxisDefVct(zaxisID2, vctsize, vct2);
}
}
vlistChangeZaxis(vlistID, zaxisID1, zaxisID2);
}
}
......@@ -94,7 +89,7 @@ void *Invertlev(void *argument)
int recID, varID, levelID;
int nmiss;
int nlev, nlevel;
int gridID, zaxisID, zaxistype, offset;
int gridID, zaxisID, offset;
int lcopy = FALSE;
int linvert = FALSE;
......@@ -102,7 +97,7 @@ void *Invertlev(void *argument)
if ( UNCHANGED_RECORD ) lcopy = TRUE;
cdoOperatorAdd("invertlev", func_all, 0, NULL);
cdoOperatorAdd("invertlev", func_all, 0, NULL);
int operatorID = cdoOperatorID();
int operfunc = cdoOperatorF1(operatorID);
......@@ -136,10 +131,9 @@ void *Invertlev(void *argument)
gridID = vlistInqVarGrid(vlistID1, varID);
zaxisID = vlistInqVarZaxis(vlistID1, varID);
gridsize = gridInqSize(gridID);
zaxistype = zaxisInqType(zaxisID);
nlev = zaxisInqSize(zaxisID);
if ( nlev < 2 || zaxistype == ZAXIS_HYBRID || zaxistype == ZAXIS_HYBRID_HALF )
if ( nlev <= 1 )
{
vardata[varID] = NULL;
varnmiss[varID] = NULL;
......@@ -203,8 +197,7 @@ void *Invertlev(void *argument)
{
streamDefRecord(streamID2, varID, levelID);
offset = gridsize*(nlevel-levelID-1);
offset = gridsize*(nlevel-levelID-1);
nmiss = varnmiss[varID][nlevel-levelID-1];
streamWriteRecord(streamID2, vardata[varID]+offset, nmiss);
......@@ -234,5 +227,5 @@ void *Invertlev(void *argument)
cdoFinish();
return (0);
return 0;
}
......@@ -31,10 +31,10 @@
void *Mergetime(void *argument)
{
int streamID1, streamID2 = CDI_UNDEFID;
int streamID1;
int tsID2 = 0, recID, varID, levelID;
int vlistID1, vlistID2;
int nfiles, fileID;
int fileID;
int taxisID1, taxisID2 = CDI_UNDEFID;
int lcopy = FALSE;
int gridsize;
......@@ -44,7 +44,6 @@ void *Mergetime(void *argument)
int next_fileID;
int skip_same_time = FALSE;
int process_timestep;
const char *ofilename;
double *array = NULL;
typedef struct
{
......@@ -56,7 +55,6 @@ void *Mergetime(void *argument)
int vtime;
int nrecs;
} sfile_t;
sfile_t *sf = NULL;
cdoInitialize(argument);
......@@ -78,9 +76,9 @@ void *Mergetime(void *argument)
if ( UNCHANGED_RECORD ) lcopy = TRUE;
nfiles = cdoStreamCnt() - 1;
int nfiles = cdoStreamCnt() - 1;
sf = (sfile_t*) malloc(nfiles*sizeof(sfile_t));
sfile_t *sf = (sfile_t*) malloc(nfiles*sizeof(sfile_t));
for ( fileID = 0; fileID < nfiles; fileID++ )
{
......@@ -118,14 +116,14 @@ void *Mergetime(void *argument)
}
}
ofilename = cdoStreamName(nfiles)->args;
const char *ofilename = cdoStreamName(nfiles)->args;
if ( !cdoSilentMode && !cdoOverwriteMode )
if ( fileExists(ofilename) )
if ( !userFileOverwrite(ofilename) )
cdoAbort("Outputfile %s already exists!", ofilename);
streamID2 = streamOpenWrite(cdoStreamName(nfiles), cdoFiletype());
int streamID2 = streamOpenWrite(cdoStreamName(nfiles), cdoFiletype());
if ( ! lcopy )
{
......
......@@ -1041,8 +1041,11 @@ void *Remap(void *argument)
if ( gridID1 == remaps[r].gridID && nmiss1 == remaps[r].nmiss )
{
if ( memcmp(imask, remaps[r].src_grid.mask, remaps[r].src_grid.size*sizeof(int)) == 0 )
break;
}
{
remaps[r].nused++;
break;
}
}
}
if ( cdoVerbose && r >= 0 ) cdoPrint("Using remap %d", r);
......@@ -1056,10 +1059,20 @@ void *Remap(void *argument)
}
else
{
/*
r = nremaps - 1;
remapVarsFree(&remaps[r].vars);
remapGridFree(&remaps[r].src_grid);
remapGridFree(&remaps[r].tgt_grid);
*/
int n0 = 0;
if ( max_remaps > 1 && remaps[0].nused > remaps[1].nused ) n0 = 1;
remapVarsFree(&remaps[n0].vars);
remapGridFree(&remaps[n0].src_grid);
remapGridFree(&remaps[n0].tgt_grid);
for ( r = n0+1; r < nremaps; r++ ) memcpy(&remaps[r-1], &remaps[r], sizeof(remap_t));
r = nremaps - 1;
remaps[r].nused = 0;
remaps[r].gridID = -1;
remaps[r].gridsize = 0;
remaps[r].nmiss = 0;
......
......@@ -22,6 +22,7 @@
#include <ctype.h>
#include "hetaeta.h"
#include <cdi.h>
#include "cdo.h"
#include "cdo_int.h"
......@@ -29,7 +30,6 @@
#include "after_vertint.h"
#include "list.h"
#include "stdnametable.h"
#include "hetaeta.h"
static
......
......@@ -208,7 +208,7 @@ void *Runstat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( runstat_nomiss )
farcmul(&vars1[0][varID][levelID], 1.0/ndates);
farcdiv(&vars1[0][varID][levelID], (double)ndates);
else
fardiv(&vars1[0][varID][levelID], samp1[0][varID][levelID]);
}
......
......@@ -235,7 +235,7 @@ void *Seasstat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( samp1[varID][levelID].ptr == NULL )
farcmul(&vars1[varID][levelID], 1.0/nsets);
farcdiv(&vars1[varID][levelID], (double)nsets);
else
fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
}
......
......@@ -464,6 +464,31 @@ void par_check_word_flag(int npar, char **parlist, int *flaglist, const char *tx
}
int vlist_get_psvarid(int nvars, int vlistID, int zaxisID)
{
int psvarid = -1;
char name[CDI_MAX_NAME];
char psname[CDI_MAX_NAME];
psname[0] = 0;
zaxisInqPsName(zaxisID, psname);
if ( psname[0] )
{
for ( int varID = 0; varID < nvars; ++varID )
{
vlistInqVarName(vlistID, varID, name);
if ( strcmp(name, psname) == 0 )
{
psvarid = varID;
break;
}
}
}
return psvarid;
}
void *Select(void *argument)
{
int streamID2 = CDI_UNDEFID;
......@@ -473,13 +498,11 @@ void *Select(void *argument)
int varID2, levelID2;
int recID, varID, levelID;
int iparam;
int nsel;
int vdate, vtime;
int last_year = -999999999;
char paramstr[32];
char varname[CDI_MAX_NAME];
char stdname[CDI_MAX_NAME];
char **argnames = NULL;
int vlistID0 = -1, vlistID2 = -1;
int i;
int result = FALSE;
......@@ -541,8 +564,8 @@ void *Select(void *argument)
operatorInputArg(cdoOperatorEnter(operatorID));
nsel = operatorArgc();
argnames = operatorArgv();
int nsel = operatorArgc();
char **argnames = operatorArgv();
if ( cdoVerbose )
for ( i = 0; i < nsel; i++ )
......@@ -688,6 +711,19 @@ void *Select(void *argument)
}
}
for ( varID = 0; varID < nvars; varID++ )
{
if ( vars[varID] )
{
zaxisID = vlistInqVarZaxis(vlistID1, varID);
if ( zaxisInqType(zaxisID) == ZAXIS_HYBRID )
{
int psvarid = vlist_get_psvarid(nvars, vlistID1, zaxisID);
if ( psvarid != -1 && !vars[psvarid] ) vars[psvarid] = TRUE;
}
}
}
for ( varID = 0; varID < nvars; varID++ )
{
if ( vars[varID] )
......
......@@ -40,8 +40,6 @@
#include "list.h"
#define NOPERATORS 32
static
int seaslist(LIST *ilist)
{
......@@ -216,32 +214,19 @@ void *Seltime(void *argument)
cdoInitialize(argument);
int SELTIMESTEP = cdoOperatorAdd("seltimestep", func_step, 1, "timesteps");
int SELDATE = cdoOperatorAdd("seldate", func_datetime, 1, "start date and end date (format YYYY-MM-DDThh:mm:ss)");
int SELTIME = cdoOperatorAdd("seltime", func_time, 1, "times (format hh:mm:ss)");
int SELHOUR = cdoOperatorAdd("selhour", func_time, 10000, "hours");
int SELDAY = cdoOperatorAdd("selday", func_date, 1, "days");
int SELMON = cdoOperatorAdd("selmon", func_date, 100, "months");
int SELYEAR = cdoOperatorAdd("selyear", func_date, 10000, "years");
int SELSEAS = cdoOperatorAdd("selseas", func_date, 100, "seasons");
int SELSMON = cdoOperatorAdd("selsmon", func_date, 100, "month[,nts1[,nts2]]");
int moddat[NOPERATORS];
moddat[SELTIMESTEP] = 1;
/* moddat[SELDATE] = 1000000000; */
moddat[SELDATE] = 0;
moddat[SELTIME] = 1000000;
moddat[SELHOUR] = 10000;
moddat[SELDAY] = 100;
moddat[SELMON] = 100;
moddat[SELYEAR] = 1000000000;
moddat[SELSEAS] = 100;
moddat[SELSMON] = 100;
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)");
int SELHOUR = cdoOperatorAdd("selhour", func_time, 0, "hours");
int SELDAY = cdoOperatorAdd("selday", func_date, 0, "days");
int SELMON = cdoOperatorAdd("selmon", func_date, 0, "months");
int SELYEAR = cdoOperatorAdd("selyear", func_date, 0, "years");
int SELSEAS = cdoOperatorAdd("selseas", func_date, 0, "seasons");
int SELSMON = cdoOperatorAdd("selsmon", func_date, 0, "month[,nts1[,nts2]]");
int operatorID = cdoOperatorID();
int operfunc = cdoOperatorF1(operatorID);
int intval = cdoOperatorF2(operatorID);
int lcopy = FALSE;
if ( UNCHANGED_RECORD ) lcopy = TRUE;
......@@ -406,11 +391,18 @@ void *Seltime(void *argument)
}
else if ( operfunc == func_date )
{
selival = (vdate/intval)%moddat[operatorID];
int year, month, day;
cdiDecodeDate(vdate, &year, &month, &day);
if ( operatorID == SELYEAR ) selival = year;
else if ( operatorID == SELDAY ) selival = day;
else selival = month;
}
else if ( operfunc == func_time )
{
selival = (vtime/intval)%moddat[operatorID];
int hour, minute, second;
cdiDecodeTime(vtime, &hour, &minute, &second);
if ( operatorID == SELHOUR ) selival = hour;
else if ( operatorID == SELTIME ) selival = vtime;
}
else if ( operfunc == func_datetime )
{
......
......@@ -151,7 +151,7 @@ void *Settime(void *argument)
datestr = operatorArgv()[0];
timestr = operatorArgv()[1];
if ( strchr(datestr, '-') )
if ( strchr(datestr+1, '-') )
{
sscanf(datestr, "%d-%d-%d", &year, &month, &day);
sdate = cdiEncodeDate(year, month, day);
......
......@@ -268,12 +268,6 @@ void *Splittime(void *argument)
}
streamClose(streamID1);
for ( index = 0; index < MAX_STREAMS; index++ )
{
streamID2 = streamIDs[index];
if ( streamID2 >= 0 ) streamClose(streamID2);
}
if ( array ) free(array);
......@@ -295,6 +289,12 @@ void *Splittime(void *argument)
if ( vars ) free(vars);
}
for ( index = 0; index < MAX_STREAMS; index++ )
{
streamID2 = streamIDs[index];
if ( streamID2 >= 0 ) streamClose(streamID2);
}
vlistDestroy(vlistID2);
cdoFinish();
......
......@@ -228,7 +228,7 @@ void *Timselstat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( samp1[varID][levelID].ptr == NULL )
farcmul(&vars1[varID][levelID], 1.0/nsets);
farcdiv(&vars1[varID][levelID], (double)nsets);
else
fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
}
......
......@@ -206,6 +206,7 @@ void *Timstat(void *argument)
for ( varID = 0; varID < nvars; ++varID )
{
vlistDefVarDatatype(vlistID3, varID, DATATYPE_INT32);
vlistDefVarMissval(vlistID3, varID, -1);
vlistDefVarUnits(vlistID3, varID, "");
vlistDefVarAddoffset(vlistID3, varID, 0);
vlistDefVarScalefactor(vlistID3, varID, 1);
......@@ -339,10 +340,13 @@ void *Timstat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( samp1[varID][levelID].ptr == NULL )
farcmul(&vars1[varID][levelID], 1.0/nsets);
farcdiv(&vars1[varID][levelID], (double)nsets);
else
fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
}
{
// farround(&samp1[varID][levelID]); not necessary
fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
}
}
}
else if ( lvarstd )
for ( varID = 0; varID < nvars; varID++ )
......
......@@ -417,7 +417,7 @@ void *Vertstat(void *argument)
if ( lmean )
{
if ( samp1[varID].ptr == NULL )
farcmul(&vars1[varID], 1.0/vars1[varID].nsamp);
farcdiv(&vars1[varID], (double)vars1[varID].nsamp);
else
fardiv(&vars1[varID], samp1[varID]);
}
......
......@@ -240,7 +240,7 @@ void *Ydaystat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( samp1[dayoy][varID][levelID].ptr == NULL )
farcmul(&vars1[dayoy][varID][levelID], 1.0/nsets[dayoy]);
farcdiv(&vars1[dayoy][varID][levelID], (double)nsets[dayoy]);
else
fardiv(&vars1[dayoy][varID][levelID], samp1[dayoy][varID][levelID]);
}
......
......@@ -445,7 +445,7 @@ void ydstatFinalize(YDAY_STATS *stats, int operfunc)
if ( vlistInqVarTsteptype(stats->vlist, varID) == TSTEP_CONSTANT ) continue;
nlevels = zaxisInqSize(vlistInqVarZaxis(stats->vlist, varID));
for ( levelID = 0; levelID < nlevels; levelID++ )
farcmul(&stats->vars1[dayoy][varID][levelID], 1.0 / stats->nsets[dayoy]);
farcdiv(&stats->vars1[dayoy][varID][levelID], (double) stats->nsets[dayoy]);
}
break;
......
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