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

runstat: add env RUNSTAT_DATE to set output date

parent 46f4b527
2007-09-?? Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* using CDI library version 1.0.8
* runstat: add env RUNSTAT_DATE to set output date [request: Claudia Wunram]
* ifthen: bug fix for masks that varies not with time [report: David Wang]
* cdotest: bug fix in eca_gsl/module.c -> 2 input streams [report: Harald Anlauf]
* use always decode_date and encode_date to decode/encode date
......
......@@ -170,7 +170,6 @@ void *Cond(void *argument)
if ( recID == 0 || filltype != FILL_REC )
{
/* gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID)); */
missval1 = vlistInqVarMissval(vlistID1, varID);
}
......
......@@ -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-2006 Uwe Schulzweida, schulzweida@dkrz.de
Copyright (C) 2003-2007 Uwe Schulzweida, schulzweida@dkrz.de
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -73,7 +73,7 @@ void *Remap(void *argument)
double *array1 = NULL, *array2 = NULL;
double *grad1_lat = NULL, *grad1_lon = NULL, *grad1_latlon = NULL;
REMAP *remaps;
char *envstring;
char *envstr;
char *remap_file = NULL;
int lwrite_remap;
......@@ -95,11 +95,11 @@ void *Remap(void *argument)
operfunc = cdoOperatorFunc(operatorID);
lwrite_remap = cdoOperatorIntval(operatorID);
envstring = getenv("MAX_REMAPS");
if ( envstring )
envstr = getenv("MAX_REMAPS");
if ( envstr )
{
int ival;
ival = atoi(envstring);
ival = atoi(envstr);
if ( ival > 0 )
{
max_remaps = ival;
......@@ -108,11 +108,11 @@ void *Remap(void *argument)
}
}
envstring = getenv("REMAP_TEST");
if ( envstring )
envstr = getenv("REMAP_TEST");
if ( envstr )
{
int ival;
ival = atoi(envstring);
ival = atoi(envstr);
if ( ival > 0 )
{
remap_test = ival;
......@@ -121,11 +121,11 @@ void *Remap(void *argument)
}
}
envstring = getenv("REMAP_NON_GLOBAL");
if ( envstring )
envstr = getenv("REMAP_NON_GLOBAL");
if ( envstr )
{
int ival;
ival = atoi(envstring);
ival = atoi(envstr);
if ( ival > 0 )
{
remap_non_global = ival;
......@@ -274,18 +274,18 @@ void *Remap(void *argument)
{
norm_opt = NORM_OPT_FRACAREA;
envstring = getenv("NORMALIZE_OPT");
envstr = getenv("NORMALIZE_OPT");
if ( envstring )
if ( envstr )
{
if ( strcmp(envstring, "fracarea") == 0 )
if ( strcmp(envstr, "fracarea") == 0 )
norm_opt = NORM_OPT_FRACAREA;
else if ( strcmp(envstring, "destarea") == 0 )
else if ( strcmp(envstr, "destarea") == 0 )
norm_opt = NORM_OPT_DESTAREA;
else if ( strcmp(envstring, "none") == 0 )
else if ( strcmp(envstr, "none") == 0 )
norm_opt = NORM_OPT_NONE;
else
cdoWarning("NORMALIZE_OPT=%s unsupported!\n", envstring);
cdoWarning("NORMALIZE_OPT=%s unsupported!\n", envstr);
}
if ( cdoVerbose )
......
......@@ -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-2006 Uwe Schulzweida, schulzweida@dkrz.de
Copyright (C) 2003-2007 Uwe Schulzweida, schulzweida@dkrz.de
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -30,6 +30,7 @@
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "cdi.h"
#include "cdo.h"
......@@ -102,9 +103,35 @@ void *Runstat(void *argument)
DATETIME *datetime;
int taxisID1, taxisID2;
int calendar, dpy;
int runstat_date = DATE_CENTER;
char *envstr;
cdoInitialize(argument);
envstr = getenv("RUNSTAT_DATE");
if ( envstr )
{
int env_date = -1;
if ( strncmp(envstr, "begin", 5) == 0 ||
strncmp(envstr, "BEGIN", 5) == 0 ||
strncmp(envstr, "Begin", 5) == 0 ) env_date = DATE_BEGIN;
else if ( strncmp(envstr, "end", 3) == 0 ||
strncmp(envstr, "END", 3) == 0 ||
strncmp(envstr, "End", 3) == 0 ) env_date = DATE_END;
else if ( strncmp(envstr, "center", 6) == 0 ||
strncmp(envstr, "CENTER", 6) == 0 ||
strncmp(envstr, "Center", 6) == 0 ) env_date = DATE_CENTER;
if ( env_date >= 0 )
{
runstat_date = env_date;
if ( cdoVerbose )
cdoPrint("Set RUNSTAT_DATE to %s", envstr);
}
}
cdoOperatorAdd("runmin", func_min, 0, NULL);
cdoOperatorAdd("runmax", func_max, 0, NULL);
cdoOperatorAdd("runsum", func_sum, 0, NULL);
......@@ -247,7 +274,20 @@ void *Runstat(void *argument)
farcvar(&vars1[0][varID][levelID], vars2[0][varID][levelID], 1.0/ndates);
}
datetime_avg(dpy, ndates, datetime);
if ( runstat_date == DATE_CENTER )
{
datetime_avg(dpy, ndates, datetime);
}
else if ( runstat_date == DATE_BEGIN )
{
datetime[ndates].date = datetime[0].date;
datetime[ndates].time = datetime[0].time;
}
else if ( runstat_date == DATE_END )
{
datetime[ndates].date = datetime[ndates-1].date;
datetime[ndates].time = datetime[ndates-1].time;
}
taxisDefVdate(taxisID2, datetime[ndates].date);
taxisDefVtime(taxisID2, datetime[ndates].time);
......
......@@ -65,7 +65,7 @@ void *Vertint(void *argument)
double *single1, *single2;
double **vardata1 = NULL, **vardata2 = NULL;
double *geop = NULL, *ps_prog = NULL, *full_press = NULL, *half_press = NULL;
char *envstring;
char *envstr;
int Extrapolate = 0;
int taxisID1, taxisID2;
int lhavevct;
......@@ -79,13 +79,13 @@ void *Vertint(void *argument)
operatorID = cdoOperatorID();
envstring = getenv("EXTRAPOLATE");
envstr = getenv("EXTRAPOLATE");
if ( envstring )
if ( envstr )
{
if ( isdigit((int) envstring[0]) )
if ( isdigit((int) envstr[0]) )
{
Extrapolate = atoi(envstring);
Extrapolate = atoi(envstr);
if ( Extrapolate == 1 )
cdoPrint("Extrapolation of missing values enabled!");
}
......
......@@ -75,6 +75,8 @@ char *strdup(const char *s);
#define CDO_EXP_LOCAL 1
#define CDO_EXP_REMOTE 2
enum {DATE_BEGIN, DATE_END, DATE_CENTER};
void strtolower(char *str);
void print_pthread_info(void);
......
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