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

Added option --timestat_date

parent be6c5091
......@@ -90,8 +90,8 @@ CDO\_RESET\_HISTORY & 0 & Set to 1 to reset the NetCDF {\it histo
CDO\_REMAP\_NORM & fracarea & Choose the normalization for the conservative interpolation \\ \hline
CDO\_GRIDSEARCH\_RADIUS & 180 & Grid search radius in degree. Used by the operators \\
& & setmisstonn, remapdis and remapnn. \\ \hline
CDO\_TIMESTAT\_DATE & None & Set the date information of a time statistic operator to \\
& & the "first", "middle" or "last" contributing timestep.\\ \hline
CDO\_TIMESTAT\_DATE & None & Set target timestamp of a time statistic operator to the "first", \\
& & "middle", "midhigh" or "last" contributing source timestep.\\ \hline
CDO\_USE\_FFTW & 1 & Set to 0 to switch off usage of FFTW. Used in the Filter module.\\ \hline
CDO\_VERSION\_INFO & 1 & Set to 0 to disable NetCDF global attribute CDO \\ \hline
\end{tabular}
......
......@@ -104,6 +104,10 @@ The following options are available for all operators:
\makebox[1.5in][l]{\hspace*{1cm}\sl -t $<$partab$>$}
\> Set the GRIB1 (cgribex) default parameter table name or file (see chapter 1.6 on page \pageref{PARAMETER_TABLE}).\\
\> Predefined tables are: {\tt echam4 echam5 echam6 mpiom1 ecmwf remo}\\
\makebox[1.5in][l]{\hspace*{1cm}\sl -\,-timestat\_date $<$srcdate$>$}
\> \\
\makebox[1.5in][l]{\hspace*{1cm}}
\> Target timestamp (time statistics): {\tt first, middle, midhigh} or {\tt last} source timestep. \\
\makebox[1.5in][l]{\hspace*{1cm}\sl -V, -\,-version}
\> Print the version number. \\
\makebox[1.5in][l]{\hspace*{1cm}\sl -v, -\,-verbose}
......
......@@ -252,6 +252,8 @@ void cdo_usage(void)
fprintf(stderr, " %s", name);
fprintf(stderr, "\n");
fprintf(stderr, " --timestat_date <srcdate>\n");
fprintf(stderr, " Target timestamp (time statistics): first, middle, midhigh or last source timestep.\n");
fprintf(stderr, " -V, --version Print the version number\n");
fprintf(stderr, " -v, --verbose Print extra details for some operators\n");
fprintf(stderr, " -W Print extra warning messages\n");
......@@ -706,8 +708,6 @@ void defineVarnames(const char *arg)
static
void get_env_vars(void)
{
char *envstr;
username = getenv("LOGNAME");
if ( username == NULL )
{
......@@ -715,7 +715,7 @@ void get_env_vars(void)
if ( username == NULL ) username = "unknown";
}
envstr = getenv("CDO_GRID_SEARCH_DIR");
char *envstr = getenv("CDO_GRID_SEARCH_DIR");
if ( envstr )
{
size_t len = strlen(envstr);
......@@ -987,15 +987,13 @@ void check_stacksize()
#if defined(HAVE_GETRLIMIT)
#if defined(RLIMIT_STACK)
{
#define MIN_STACK_SIZE 67108864L /* 64MB */
int status;
struct rlimit rlim;
RLIM_T min_stack_size = MIN_STACK_SIZE;
status = getrlimit(RLIMIT_STACK, &rlim);
int status = getrlimit(RLIMIT_STACK, &rlim);
if ( status == 0 )
{
#define MIN_STACK_SIZE 67108864L /* 64MB */
RLIM_T min_stack_size = MIN_STACK_SIZE;
if ( min_stack_size > rlim.rlim_max ) min_stack_size = rlim.rlim_max;
if ( rlim.rlim_cur < min_stack_size )
{
......@@ -1038,14 +1036,12 @@ static
long str_to_int(const char *intstring)
{
long intval = -1;
long fact = 1;
if ( intstring )
{
int loop, len;
len = (int) strlen(intstring);
for ( loop = 0; loop < len; loop++ )
long fact = 1;
int len = (int) strlen(intstring);
for ( int loop = 0; loop < len; loop++ )
{
if ( ! isdigit((int) intstring[loop]) )
{
......@@ -1078,6 +1074,7 @@ int parse_options_long(int argc, char *argv[])
int lpercentile;
int lprintoperators = 0;
int lenableexcept;
int ltimestat_date;
struct cdo_option opt_long[] =
{
......@@ -1090,6 +1087,7 @@ int parse_options_long(int argc, char *argv[])
{ "gridsearchradius", required_argument, &lgridsearchradius, 1 },
{ "remap_genweights", required_argument, &lremap_genweights, 1 },
{ "enableexcept", required_argument, &lenableexcept, 1 },
{ "timestat_date", required_argument, &ltimestat_date, 1 },
{ "cmor", no_argument, &CDO_CMOR_Mode, 1 },
{ "reduce_dim", no_argument, &CDO_Reduce_Dim, 1 },
{ "float", no_argument, &CDO_Memtype, MEMTYPE_FLOAT },
......@@ -1119,6 +1117,7 @@ int parse_options_long(int argc, char *argv[])
lgridsearchradius = 0;
lremap_genweights = 0;
lenableexcept = 0;
ltimestat_date = 0;
c = cdo_getopt_long(argc, argv, "f:b:e:P:g:i:k:l:m:n:t:D:z:aBCcdhLMOpQRrsSTuVvWXZ", opt_long, NULL);
if ( c == -1 ) break;
......@@ -1158,6 +1157,17 @@ int parse_options_long(int argc, char *argv[])
cdo_feenableexcept((unsigned)except);
if ( signal(SIGFPE, cdo_sig_handler) == SIG_ERR ) cdoWarning("can't catch SIGFPE!");
}
else if ( ltimestat_date )
{
int timestatdate = -1;
if ( strcmp(CDO_optarg, "first") == 0 ) timestatdate = TIMESTAT_FIRST;
else if ( strcmp(CDO_optarg, "last") == 0 ) timestatdate = TIMESTAT_LAST;
else if ( strcmp(CDO_optarg, "middle") == 0 ) timestatdate = TIMESTAT_MEAN;
else if ( strcmp(CDO_optarg, "midhigh") == 0 ) timestatdate = TIMESTAT_MIDHIGH;
if ( timestatdate < 0 ) cdoAbort("option --%s: unsupported argument: %s", "timestat_date", CDO_optarg);
extern int CDO_Timestat_Date;
CDO_Timestat_Date = timestatdate;
}
else if ( luse_fftw )
{
int intarg = parameter2int(CDO_optarg);
......
......@@ -2,7 +2,7 @@
#include "cdo_int.h"
#include "datetime.h"
static int timestat_date = -1;
int CDO_Timestat_Date = -1;
static
void get_timestat_date(int *tstat_date)
......@@ -42,10 +42,10 @@ void dtlist_init(dtlist_type *dtlist)
dtlist->stat = TIMESTAT_LAST;
dtlist->dtinfo = NULL;
if ( timestat_date == -1 )
if ( CDO_Timestat_Date == -1 )
{
timestat_date = 0;
get_timestat_date(&timestat_date);
CDO_Timestat_Date = 0;
get_timestat_date(&CDO_Timestat_Date);
}
}
......@@ -224,7 +224,7 @@ void dtlist_stat_taxisDefTimestep(dtlist_type *dtlist, int taxisID, int nsteps)
cdoAbort("Internal error; unexpected nsteps=%d (limit=%ld)!", nsteps, dtlist->size);
int stat = dtlist->stat;
if ( timestat_date > 0 ) stat = timestat_date;
if ( CDO_Timestat_Date > 0 ) stat = CDO_Timestat_Date;
if ( stat == TIMESTAT_MEAN ) dtlist_mean(dtlist, nsteps);
else if ( stat == TIMESTAT_MIDHIGH ) dtlist_midhigh(dtlist, nsteps);
......
......@@ -4090,7 +4090,7 @@ static const char *WindHelp[] = {
"DESCRIPTION",
" This module converts relative divergence and vorticity to U and V wind and vice versa.",
" Divergence and vorticity are spherical harmonic coefficients in spectral space and",
" U and V are on a regular Gaussian grid. The Gaussian latitudes needs to be ordered from",
" U and V are on a regular Gaussian grid. The Gaussian latitudes need to be ordered from",
" north to south.",
"",
"OPERATORS",
......
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