Commit 933c21e6 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

taxis: changed type of date to int64_t-

parent 4200a8fe
2018-07-30 Uwe Schulzweida
* using CGRIBEX library version 1.9.1
* Version 1.9.5 released
2018-05-11 Uwe Schulzweida
* taxis: changed type of date to int64_t
* cdiDecodeDate: changed type of date to int64_t
* cdiEncodeDate: changed type of return value to int64_t
......
......@@ -4,7 +4,7 @@
# autoconf 2.68
# libtool 2.4.2
AC_INIT([cdi], [1.9.4], [http://mpimet.mpg.de/cdi])
AC_INIT([cdi], [1.9.5rc1], [http://mpimet.mpg.de/cdi])
AC_DEFINE_UNQUOTED(CDI, ["$PACKAGE_VERSION"], [CDI version])
......
......@@ -93,9 +93,9 @@ static void decode_day(int dpy, int days, int *year, int *month, int *day)
}
static int encode_day(int dpy, int year, int month, int day)
static int64_t encode_day(int dpy, int year, int month, int day)
{
long rval = (long)dpy * year + day;
int64_t rval = (int64_t)dpy * year + day;
const int *dpm = NULL;
if ( dpy == 360 ) dpm = month_360;
......@@ -103,15 +103,14 @@ static int encode_day(int dpy, int year, int month, int day)
else if ( dpy == 366 ) dpm = month_366;
if ( dpm ) for ( int i = 0; i < month-1; i++ ) rval += dpm[i];
if ( rval > INT_MAX || rval < INT_MIN )
Error("Unhandled date: %ld", rval);
if ( rval > LONG_MAX || rval < LONG_MIN ) Error("Unhandled date: %lld", rval);
return (int)rval;
return rval;
}
void encode_caldaysec(int calendar, int year, int month, int day, int hour, int minute, int second,
int *julday, int *secofday)
int64_t *julday, int *secofday)
{
int dpy = calendar_dpy(calendar);
......@@ -124,7 +123,7 @@ void encode_caldaysec(int calendar, int year, int month, int day, int hour, int
}
void decode_caldaysec(int calendar, int julday, int secofday,
void decode_caldaysec(int calendar, int64_t julday, int secofday,
int *year, int *month, int *day, int *hour, int *minute, int *second)
{
int dpy = calendar_dpy(calendar);
......
#ifndef _CALENDAR_H
#define _CALENDAR_H
#ifndef CALENDAR_H
#define CALENDAR_H
#include <inttypes.h>
#ifdef __cplusplus
extern "C" {
#endif
void encode_caldaysec(int calendar, int year, int month, int day, int hour, int minute, int second,
int *julday, int *secofday);
void decode_caldaysec(int calendar, int julday, int secofday,
int64_t *julday, int *secofday);
void decode_caldaysec(int calendar, int64_t julday, int secofday,
int *year, int *month, int *day, int *hour, int *minute, int *second);
int calendar_dpy(int calendar);
int days_per_year(int calendar, int year);
int days_per_month(int calendar, int year, int month);
#if defined (__cplusplus)
#ifdef __cplusplus
}
#endif
#endif /* _CALENDAR_H */
#endif /* CALENDAR_H */
/*
* Local Variables:
* c-file-style: "Java"
......
......@@ -52,7 +52,7 @@ bool str_is_equal(const char *vstr, const char *cstr);
#ifndef _BASETIME_H
# include "basetime.h"
#endif
#ifndef _TIMEBASE_H
#ifndef TIMEBASE_H
# include "timebase.h"
#endif
#ifndef TAXIS_H
......
/* Automatically generated by m214003 at 2018-01-22, do not edit */
/* Automatically generated by m214003 at 2018-05-11, do not edit */
/* CGRIBEXLIB_VERSION="1.9.0" */
/* CGRIBEXLIB_VERSION="1.9.1" */
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5) || defined (__clang__)
#pragma GCC diagnostic push
......@@ -1995,7 +1995,8 @@ bool gribTimeIsFC(int *isec1)
void gribDateTime(int *isec1, int *date, int *time)
{
static bool lprint = true;
int julday, secofday;
int64_t julday;
int secofday;
int64_t addsec = 0;
int64_t time_period = 0;
extern int grib_calendar;
......@@ -13161,7 +13162,7 @@ void encode_dummy(void)
(void) encode_array_unrolled_double(0, 0, 0, NULL, NULL, 0, 0, NULL);
(void) encode_array_unrolled_float(0, 0, 0, NULL, NULL, 0, 0, NULL);
}
static const char grb_libvers[] = "1.9.0";
static const char grb_libvers[] = "1.9.1";
const char *
cgribexLibraryVersion(void)
{
......
#if defined (HAVE_CONFIG_H)
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
......@@ -15,7 +15,7 @@
#include "stream_grb.h"
#include "stream_cgribex.h"
#if defined (HAVE_LIBCGRIBEX)
#ifdef HAVE_LIBCGRIBEX
# include "cgribex.h"
#endif
......@@ -1432,7 +1432,8 @@ int cgribexDefTimerange(int tsteptype, int factor, int calendar,
int rdate, int rtime, int vdate, int vtime, int *pip1, int *pip2)
{
int year, month, day, hour, minute, second;
int julday1, secofday1, julday2, secofday2, days, secs;
int64_t julday1, julday2, days;
int secofday1, secofday2, secs;
cdiDecodeDate(rdate, &year, &month, &day);
cdiDecodeTime(rtime, &hour, &minute, &second);
......
......@@ -195,7 +195,8 @@ int gribapiGetValidityDateTime(grib_handle *gh, int64_t *vdate, int *vtime)
{
static bool lprint = true;
extern int grib_calendar;
int julday, secofday;
int64_t julday;
int secofday;
encode_caldaysec(grib_calendar, ryear, rmonth, rday, rhour, rminute, rsecond, &julday, &secofday);
int64_t time_period = endStep;
......@@ -1802,7 +1803,8 @@ int gribapiDefDateTimeRel(int editionNumber, grib_handle *gh, int64_t rdate, int
{
int status = -1;
int year, month, day, hour, minute, second;
int julday1, secofday1, julday2, secofday2, days, secs;
int64_t julday1, julday2, days;
int secofday1, secofday2, secs;
cdiDecodeDate(rdate, &year, &month, &day);
cdiDecodeTime(rtime, &hour, &minute, &second);
......
#if defined (HAVE_CONFIG_H)
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
......@@ -938,7 +938,7 @@ void ptaxisDefUnits(taxis_t *taxisptr, const char *units)
static void
cdiDecodeTimevalue(int timeunit, double timevalue, int *days, int *secs)
cdiDecodeTimevalue(int timeunit, double timevalue, int64_t *days, int *secs)
{
*days = 0;
*secs = 0;
......@@ -1071,7 +1071,8 @@ void timeval2vtime(double timevalue, taxis_t *taxis, int64_t *vdate, int *vtime)
timevalue = fmon*dpm;
}
int julday, secofday, days, secs;
int64_t julday, days;
int secofday, secs;
encode_caldaysec(calendar, year, month, day, hour, minute, second, &julday, &secofday);
cdiDecodeTimevalue(timeunit, timevalue, &days, &secs);
......@@ -1088,7 +1089,8 @@ void timeval2vtime(double timevalue, taxis_t *taxis, int64_t *vdate, int *vtime)
double vtime2timeval(int64_t vdate, int vtime, taxis_t *taxis)
{
double value = 0;
int julday1, secofday1, julday2, secofday2, days, secs;
int64_t julday1, julday2, days;
int secofday1, secofday2, secs;
int timeunit = (*taxis).unit;
int calendar = (*taxis).calendar;
......@@ -1266,7 +1268,8 @@ void splitTimevalue(double timevalue, int timeunit, int64_t *date, int *time)
void cdiSetForecastPeriod(double timevalue, taxis_t *taxis)
{
int julday, secofday, days, secs;
int64_t julday, days;
int secofday, secs;
(*taxis).fc_period = timevalue;
......
......@@ -7,12 +7,12 @@
/* convert Julian date into year, months, day */
void decode_julday(int calendar,
int julday, /* Julian day number to convert */
int *year, /* Gregorian year (out) */
int *mon, /* Gregorian month (1-12) (out) */
int *day) /* Gregorian day (1-31) (out) */
int64_t julday, /* Julian day number to convert */
int *year, /* Gregorian year (out) */
int *mon, /* Gregorian month (1-12) (out) */
int *day) /* Gregorian day (1-31) (out) */
{
int a = julday;
int64_t a = julday;
double b = floor((a - 1867216.25)/36524.25);
double c = a + b - floor(b/4) + 1525;
......@@ -31,7 +31,7 @@ void decode_julday(int calendar,
/* convert year, month, day into Julian calendar day */
int encode_julday(int calendar, int year, int month, int day)
int64_t encode_julday(int calendar, int year, int month, int day)
{
int iy;
int im;
......@@ -71,29 +71,29 @@ int encode_julday(int calendar, int year, int month, int day)
}
}
int julday = (int) (floor(365.25*iy) + (int)(30.6001*(im+1)) + ib + 1720996.5 + day + 0.5);
int64_t julday = (int64_t) (floor(365.25*iy) + (int64_t)(30.6001*(im+1)) + ib + 1720996.5 + day + 0.5);
return julday;
}
int date_to_julday(int calendar, int date)
int64_t date_to_julday(int calendar, int64_t date)
{
int year, month, day;
cdiDecodeDate(date, &year, &month, &day);
int julday = encode_julday(calendar, year, month, day);
int64_t julday = encode_julday(calendar, year, month, day);
return julday;
}
int julday_to_date(int calendar, int julday)
int64_t julday_to_date(int calendar, int64_t julday)
{
int year, month, day;
decode_julday(calendar, julday, &year, &month, &day);
int date = cdiEncodeDate(year, month, day);
int64_t date = cdiEncodeDate(year, month, day);
return date;
}
......@@ -122,7 +122,7 @@ int sec_to_time(int secofday)
}
static
void adjust_seconds(int *julday, int64_t *secofday)
void adjust_seconds(int64_t *julday, int64_t *secofday)
{
int64_t secperday = 86400;
......@@ -140,7 +140,7 @@ void adjust_seconds(int *julday, int64_t *secofday)
}
void julday_add_seconds(int64_t seconds, int *julday, int *secofday)
void julday_add_seconds(int64_t seconds, int64_t *julday, int *secofday)
{
int64_t sec_of_day = *secofday;
......@@ -152,7 +152,7 @@ void julday_add_seconds(int64_t seconds, int *julday, int *secofday)
}
/* add days and secs to julday/secofday */
void julday_add(int days, int secs, int *julday, int *secofday)
void julday_add(int days, int secs, int64_t *julday, int *secofday)
{
int64_t sec_of_day = *secofday;
......@@ -165,7 +165,7 @@ void julday_add(int days, int secs, int *julday, int *secofday)
}
/* subtract julday1/secofday1 from julday2/secofday2 and returns the result in seconds */
double julday_sub(int julday1, int secofday1, int julday2, int secofday2, int *days, int *secs)
double julday_sub(int64_t julday1, int secofday1, int64_t julday2, int secofday2, int64_t *days, int *secs)
{
*days = julday2 - julday1;
*secs = secofday2 - secofday1;
......@@ -182,7 +182,7 @@ double julday_sub(int julday1, int secofday1, int julday2, int secofday2, int *d
}
void encode_juldaysec(int calendar, int year, int month, int day, int hour, int minute, int second, int *julday, int *secofday)
void encode_juldaysec(int calendar, int year, int month, int day, int hour, int minute, int second, int64_t *julday, int *secofday)
{
*julday = encode_julday(calendar, year, month, day);
......@@ -190,7 +190,7 @@ void encode_juldaysec(int calendar, int year, int month, int day, int hour, int
}
void decode_juldaysec(int calendar, int julday, int secofday, int *year, int *month, int *day, int *hour, int *minute, int *second)
void decode_juldaysec(int calendar, int64_t julday, int secofday, int *year, int *month, int *day, int *hour, int *minute, int *second)
{
decode_julday(calendar, julday, year, month, day);
......@@ -209,7 +209,8 @@ int main(void)
int ijulinc;
int i, j = 0;
int year, mon, day, hour, minute, second;
int julday, secofday;
int64_t julday;
int secofday;
int calendar = CALENDAR_STANDARD;
/* 1 - Check valid range of years */
......
#ifndef _TIMEBASE_H
#define _TIMEBASE_H
#ifndef TIMEBASE_H
#define TIMEBASE_H
#include <inttypes.h>
......@@ -10,27 +10,27 @@ extern "C" {
/* date format: YYYYMMDD */
/* time format: hhmmss */
void decode_julday(int calendar, int julday, int *year, int *mon, int *day);
int encode_julday(int calendar, int year, int month, int day);
void decode_julday(int calendar, int64_t julday, int *year, int *mon, int *day);
int64_t encode_julday(int calendar, int year, int month, int day);
int date_to_julday(int calendar, int date);
int julday_to_date(int calendar, int julday);
int64_t date_to_julday(int calendar, int64_t date);
int64_t julday_to_date(int calendar, int64_t julday);
int time_to_sec(int time);
int sec_to_time(int secofday);
void julday_add_seconds(int64_t seconds, int *julday, int *secofday);
void julday_add(int days, int secs, int *julday, int *secofday);
double julday_sub(int julday1, int secofday1, int julday2, int secofday2, int *days, int *secs);
void julday_add_seconds(int64_t seconds, int64_t *julday, int *secofday);
void julday_add(int days, int secs, int64_t *julday, int *secofday);
double julday_sub(int64_t julday1, int secofday1, int64_t julday2, int secofday2, int64_t *days, int *secs);
void encode_juldaysec(int calendar, int year, int month, int day, int hour, int minute, int second, int *julday, int *secofday);
void decode_juldaysec(int calendar, int julday, int secofday, int *year, int *month, int *day, int *hour, int *minute, int *second);
void encode_juldaysec(int calendar, int year, int month, int day, int hour, int minute, int second, int64_t *julday, int *secofday);
void decode_juldaysec(int calendar, int64_t julday, int secofday, int *year, int *month, int *day, int *hour, int *minute, int *second);
#if defined (__cplusplus)
#ifdef __cplusplus
}
#endif
#endif /* _TIMEBASE_H */
#endif /* TIMEBASE_H */
/*
* Local Variables:
......
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