Commit 9d4441c3 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

added support for non integer time units MONTH

parent eaa89ea9
2010-03-19 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* added support for non integer time units MONTH
2010-03-12 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* gauaw: bug fix for allocation of zfnlat for odd number of nlat
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for cdi 1.4.3.2.
# Generated by GNU Autoconf 2.61 for cdi 1.4.3.3.
#
# Report bugs to <http://code.zmaw.de/projects/cdi>.
#
......@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='cdi'
PACKAGE_TARNAME='cdi'
PACKAGE_VERSION='1.4.3.2'
PACKAGE_STRING='cdi 1.4.3.2'
PACKAGE_VERSION='1.4.3.3'
PACKAGE_STRING='cdi 1.4.3.3'
PACKAGE_BUGREPORT='http://code.zmaw.de/projects/cdi'
# Factoring default headers for most tests.
......@@ -1258,7 +1258,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures cdi 1.4.3.2 to adapt to many kinds of systems.
\`configure' configures cdi 1.4.3.3 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1329,7 +1329,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of cdi 1.4.3.2:";;
short | recursive ) echo "Configuration of cdi 1.4.3.3:";;
esac
cat <<\_ACEOF
......@@ -1463,7 +1463,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
cdi configure 1.4.3.2
cdi configure 1.4.3.3
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
......@@ -1477,7 +1477,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by cdi $as_me 1.4.3.2, which was
It was created by cdi $as_me 1.4.3.3, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
......@@ -2304,7 +2304,7 @@ fi
# Define the identity of the package.
PACKAGE='cdi'
VERSION='1.4.3.2'
VERSION='1.4.3.3'
cat >>confdefs.h <<_ACEOF
......@@ -9275,7 +9275,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by cdi $as_me 1.4.3.2, which was
This file was extended by cdi $as_me 1.4.3.3, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -9328,7 +9328,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
cdi config.status 1.4.3.2
cdi config.status 1.4.3.3
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
......
# Process this file with autoconf to produce a configure script.
AC_INIT([cdi], [1.4.3.2], [http://code.zmaw.de/projects/cdi])
AC_INIT([cdi], [1.4.3.3], [http://code.zmaw.de/projects/cdi])
echo "configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}"
......
......@@ -1004,6 +1004,7 @@ void cdiEncodeTimevalue(int days, int secs, int timeunit, double *timevalue)
}
}
int days_per_month(int calendar, int year, int month);
void timeval2vtime(double timevalue, TAXIS *taxis, int *vdate, int *vtime)
{
......@@ -1034,8 +1035,7 @@ void timeval2vtime(double timevalue, TAXIS *taxis, int *vdate, int *vtime)
if ( timeunit == TUNIT_MONTH || timeunit == TUNIT_YEAR )
{
int nmon/*, nday */;
/* double fmon; */
static int lold = FALSE;
if ( timeunit == TUNIT_YEAR )
{
......@@ -1043,30 +1043,44 @@ void timeval2vtime(double timevalue, TAXIS *taxis, int *vdate, int *vtime)
timevalue *= 12;
}
if ( (NINT(timevalue*10))%10 && lwarn )
if ( lold )
{
Warning(func, "Possible wrong calculation of date/time!\n"
"Time offset have to be integer for time unit MONTH and YEAR!");
lwarn = FALSE;
}
nmon = (int) (timevalue+0.001);
/*
nmon = (int) timevalue;
fmon = timevalue - nmon;
printf("timevalue %g, nmon %d, fmon %g\n", timevalue, nmon, fmon);
*/
month += nmon;
int nmon;
while ( month > 12 ) { month -= 12; year++; }
while ( month < 1 ) { month += 12; year--; }
/*
nday = days_per_month(calendar, year, month);
printf(" year %d, month %d, nday %d\n", year, month, nday);
timeunit = TUNIT_DAY;
*/
if ( (NINT(timevalue*10))%10 && lwarn )
{
Warning(func, "Possible wrong calculation of date/time!\n"
"Non integer time offset unsupported for time unit MONTH and YEAR!");
lwarn = FALSE;
}
nmon = (int) (timevalue+0.001);
month += nmon;
while ( month > 12 ) { month -= 12; year++; }
while ( month < 1 ) { month += 12; year--; }
}
else
{
int nmon, dpm;
double fmon;
nmon = (int) timevalue;
fmon = timevalue - nmon;
month += nmon;
while ( month > 12 ) { month -= 12; year++; }
while ( month < 1 ) { month += 12; year--; }
dpm = days_per_month(calendar, year, month);
timeunit = TUNIT_DAY;
timevalue = fmon*dpm;
}
}
else
if ( timeunit != TUNIT_MONTH && timeunit != TUNIT_YEAR )
{
encode_caldaysec(calendar, year, month, day, hour, minute, second, &julday, &secofday);
......@@ -1121,7 +1135,24 @@ double vtime2timeval(int vdate, int vtime, TAXIS *taxis)
if ( timeunit == TUNIT_MONTH || timeunit == TUNIT_YEAR )
{
int nmonth, dpm;
dpm = days_per_month(calendar, year, month);
value = (year-ryear)*12 - rmonth + month;
nmonth = (int) value;
month -= nmonth;
while ( month > 12 ) { month -= 12; year++; }
while ( month < 1 ) { month += 12; year--; }
encode_caldaysec(calendar, year, month, day, hour, minute, second, &julday2, &secofday2);
julday_sub(julday1, secofday1, julday2, secofday2, &days, &secs);
value += (days+secs/86400.)/dpm;
if ( timeunit == TUNIT_YEAR ) value = NINT(value/12);
}
else
......
Markdown is supported
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