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

cdiDecodeDate: changed type of date to int64_t.

parent 11520af9
2018-05-11 Uwe Schulzweida
* cdiDecodeDate: changed type of date to int64_t
* cdiEncodeDate: changed type of return value to int64_t
2018-04-30 Uwe Schulzweida
* Version 1.9.4 released
......
......@@ -8,6 +8,7 @@
#define CDI_H_
#include <stdio.h>
#include <stdint.h> // int64_t
#include <sys/types.h>
#ifdef __cplusplus
......@@ -322,8 +323,8 @@ int cdiEncodeParam(int pnum, int pcat, int pdis);
/* date format: YYYYMMDD */
/* time format: hhmmss */
void cdiDecodeDate(int date, int *year, int *month, int *day);
int cdiEncodeDate(int year, int month, int day);
void cdiDecodeDate(int64_t date, int *year, int *month, int *day);
int64_t cdiEncodeDate(int year, int month, int day);
void cdiDecodeTime(int time, int *hour, int *minute, int *second);
int cdiEncodeTime(int hour, int minute, int second);
......
! This file was automatically generated, don't edit!
!
! Fortran interface for CDI library version 1.9.4rc1
! Fortran interface for CDI library version 1.9.5rc1
!
! Author:
! -------
! Uwe Schulzweida, MPI-MET, Hamburg, February 2018
! Uwe Schulzweida, MPI-MET, Hamburg, May 2018
!
INTEGER CDI_MAX_NAME
......@@ -536,19 +536,6 @@
!
! time format: hhmmss
!
! cdiDecodeDate
! (INTEGER date,
! INTEGER year,
! INTEGER month,
! INTEGER day)
EXTERNAL cdiDecodeDate
INTEGER cdiEncodeDate
! (INTEGER year,
! INTEGER month,
! INTEGER day)
EXTERNAL cdiEncodeDate
! cdiDecodeTime
! (INTEGER time,
! INTEGER hour,
......@@ -1587,6 +1574,12 @@
PARAMETER (CDI_KEY_REVSTATUS = 816)
INTEGER CDI_KEY_REVNUMBER
PARAMETER (CDI_KEY_REVNUMBER = 817)
INTEGER CDI_KEY_GRIB2LOCALSECTIONNUMBER
PARAMETER (CDI_KEY_GRIB2LOCALSECTIONNUMBER = 818)
INTEGER CDI_KEY_SECTION2PADDINGLENGTH
PARAMETER (CDI_KEY_SECTION2PADDINGLENGTH = 819)
INTEGER CDI_KEY_SECTION2PADDING
PARAMETER (CDI_KEY_SECTION2PADDING = 820)
INTEGER cdiDefKeyInt
! (INTEGER cdiID,
! INTEGER varID,
......@@ -1601,22 +1594,6 @@
! INTEGER value)
EXTERNAL cdiInqKeyInt
INTEGER cdiDefKeyBytes
! (INTEGER cdiID,
! INTEGER varID,
! INTEGER key,
! INTEGER*1(*) bytes,
! INTEGER length)
EXTERNAL cdiDefKeyBytes
INTEGER cdiInqKeyBytes
! (INTEGER cdiID,
! INTEGER varID,
! INTEGER key,
! INTEGER*1(*) bytes,
! INTEGER length)
EXTERNAL cdiInqKeyBytes
INTEGER cdiDefKeyString
! (INTEGER cdiID,
! INTEGER varID,
......@@ -1624,20 +1601,20 @@
! CHARACTER*(*) string)
EXTERNAL cdiDefKeyString
INTEGER cdiInqKeyLen
INTEGER cdiInqKeyString
! (INTEGER cdiID,
! INTEGER varID,
! INTEGER key,
! CHARACTER*(*) string,
! INTEGER length)
EXTERNAL cdiInqKeyLen
EXTERNAL cdiInqKeyString
INTEGER cdiInqKeyString
INTEGER cdiInqKeyLen
! (INTEGER cdiID,
! INTEGER varID,
! INTEGER key,
! CHARACTER*(*) string,
! INTEGER length)
EXTERNAL cdiInqKeyString
EXTERNAL cdiInqKeyLen
INTEGER cdiCopyKeys
! (INTEGER cdiID1,
......@@ -1975,6 +1952,13 @@
! DOUBLEPRECISION xbounds(*))
EXTERNAL gridInqXbounds
INTEGER gridInqXboundsPart
! (INTEGER gridID,
! INTEGER start,
! INTEGER size,
! DOUBLEPRECISION xbounds(*))
EXTERNAL gridInqXboundsPart
! gridDefYbounds
! (INTEGER gridID,
! DOUBLEPRECISION ybounds(*))
......@@ -1985,6 +1969,13 @@
! DOUBLEPRECISION ybounds(*))
EXTERNAL gridInqYbounds
INTEGER gridInqYboundsPart
! (INTEGER gridID,
! INTEGER start,
! INTEGER size,
! DOUBLEPRECISION ybounds(*))
EXTERNAL gridInqYboundsPart
! gridDefRowlon
! (INTEGER gridID,
! INTEGER nrowlon,
......
......@@ -127,8 +127,6 @@ FCALLSCFUN3 (INT, cdiEncodeParam, CDIENCODEPARAM, cdiencodeparam, INT, INT, INT)
/* time format: hhmmss */
FCALLSCSUB4 (cdiDecodeDate, CDIDECODEDATE, cdidecodedate, INT, PINT, PINT, PINT)
FCALLSCFUN3 (INT, cdiEncodeDate, CDIENCODEDATE, cdiencodedate, INT, INT, INT)
FCALLSCSUB4 (cdiDecodeTime, CDIDECODETIME, cdidecodetime, INT, PINT, PINT, PINT)
FCALLSCFUN3 (INT, cdiEncodeTime, CDIENCODETIME, cdiencodetime, INT, INT, INT)
......@@ -472,11 +470,9 @@ FCALLSCFUN2 (INT, gridInqYvals_fwrap, GRIDINQYVALS, gridinqyvals, INT, DOUBLEV)
FCALLSCFUN1 (INT, gridInqYIsc, GRIDINQYISC, gridinqyisc, INT)
FCALLSCFUN4 (INT, cdiDefKeyInt, CDIDEFKEYINT, cdidefkeyint, INT, INT, INT, INT)
FCALLSCFUN4 (INT, cdiInqKeyInt, CDIINQKEYINT, cdiinqkeyint, INT, INT, INT, PINT)
FCALLSCFUN5 (INT, cdiDefKeyBytes, CDIDEFKEYBYTES, cdidefkeybytes, INT, INT, INT, PVOID, INT)
FCALLSCFUN5 (INT, cdiInqKeyBytes, CDIINQKEYBYTES, cdiinqkeybytes, INT, INT, INT, PVOID, PINT)
FCALLSCFUN4 (INT, cdiDefKeyString, CDIDEFKEYSTRING, cdidefkeystring, INT, INT, INT, STRING)
FCALLSCFUN4 (INT, cdiInqKeyLen, CDIINQKEYLEN, cdiinqkeylen, INT, INT, INT, PINT)
FCALLSCFUN5 (INT, cdiInqKeyString, CDIINQKEYSTRING, cdiinqkeystring, INT, INT, INT, PSTRING, PINT)
FCALLSCFUN4 (INT, cdiInqKeyLen, CDIINQKEYLEN, cdiinqkeylen, INT, INT, INT, PINT)
FCALLSCFUN4 (INT, cdiCopyKeys, CDICOPYKEYS, cdicopykeys, INT, INT, INT, INT)
FCALLSCFUN4 (INT, cdiGridDefKeyStr, CDIGRIDDEFKEYSTR, cdigriddefkeystr, INT, INT, INT, STRING)
FCALLSCFUN4 (INT, cdiGridInqKeyStr, CDIGRIDINQKEYSTR, cdigridinqkeystr, INT, INT, INT, PSTRING)
......@@ -558,6 +554,13 @@ static int gridInqXbounds_fwrap(int gridID, double xbounds[])
return size_t_c2f(v);
}
FCALLSCFUN2 (INT, gridInqXbounds_fwrap, GRIDINQXBOUNDS, gridinqxbounds, INT, DOUBLEV)
static int gridInqXboundsPart_fwrap(int gridID, int start, int size, double xbounds[])
{
size_t v;
v = gridInqXboundsPart(gridID, start, (size_t)size, xbounds);
return size_t_c2f(v);
}
FCALLSCFUN4 (INT, gridInqXboundsPart_fwrap, GRIDINQXBOUNDSPART, gridinqxboundspart, INT, INT, INT, DOUBLEV)
FCALLSCSUB2 (gridDefYbounds, GRIDDEFYBOUNDS, griddefybounds, INT, DOUBLEV)
static int gridInqYbounds_fwrap(int gridID, double ybounds[])
{
......@@ -566,6 +569,13 @@ static int gridInqYbounds_fwrap(int gridID, double ybounds[])
return size_t_c2f(v);
}
FCALLSCFUN2 (INT, gridInqYbounds_fwrap, GRIDINQYBOUNDS, gridinqybounds, INT, DOUBLEV)
static int gridInqYboundsPart_fwrap(int gridID, int start, int size, double ybounds[])
{
size_t v;
v = gridInqYboundsPart(gridID, start, (size_t)size, ybounds);
return size_t_c2f(v);
}
FCALLSCFUN4 (INT, gridInqYboundsPart_fwrap, GRIDINQYBOUNDSPART, gridinqyboundspart, INT, INT, INT, DOUBLEV)
FCALLSCSUB3 (gridDefRowlon, GRIDDEFROWLON, griddefrowlon, INT, INT, INTV)
FCALLSCSUB2 (gridInqRowlon, GRIDINQROWLON, gridinqrowlon, INT, INTV)
FCALLSCSUB2 (gridChangeType, GRIDCHANGETYPE, gridchangetype, INT, INT)
......
......@@ -25,38 +25,37 @@ void cdiDecodeParam(int param, int *pnum, int *pcat, int *pdis)
int cdiEncodeParam(int pnum, int pcat, int pdis)
{
unsigned uparam, upnum;
if ( pcat < 0 || pcat > 255 ) pcat = 255;
if ( pdis < 0 || pdis > 255 ) pdis = 255;
upnum = (unsigned)pnum;
unsigned upnum = (unsigned)pnum;
if ( pnum < 0 ) upnum = (unsigned)(0x8000 - pnum);
uparam = upnum << 16 | (unsigned)(pcat << 8) | (unsigned)pdis;
unsigned uparam = upnum << 16 | (unsigned)(pcat << 8) | (unsigned)pdis;
return ((int)uparam);
return (int)uparam;
}
void cdiDecodeDate(int date, int *year, int *month, int *day)
void cdiDecodeDate(int64_t date, int *year, int *month, int *day)
{
int iyear = date / 10000;
*year = iyear;
int idate = abs(date - iyear * 10000),
imonth = idate / 100;
*month = imonth;
*day = idate - imonth * 100;
int64_t iyear = (int)(date / 10000);
*year = (int)iyear;
int64_t idate = date - iyear * 10000;
if ( idate < 0 ) idate = -idate;
int64_t imonth = idate / 100;
*month = (int)imonth;
*day = (int)(idate - imonth * 100);
}
int cdiEncodeDate(int year, int month, int day)
int64_t cdiEncodeDate(int year, int month, int day)
{
int iyear = abs(year),
date = iyear * 10000 + month * 100 + day;
int64_t iyear = abs(year);
int64_t date = iyear * 10000 + month * 100 + day;
if ( year < 0 ) date = -date;
return (date);
return date;
}
......@@ -73,20 +72,17 @@ void cdiDecodeTime(int time, int *hour, int *minute, int *second)
int cdiEncodeTime(int hour, int minute, int second)
{
int time = hour*10000 + minute*100 + second;
return time;
return hour*10000 + minute*100 + second;
}
void cdiParamToString(int param, char *paramstr, int maxlen)
{
int dis, cat, num;
int len;
cdiDecodeParam(param, &num, &cat, &dis);
size_t umaxlen = maxlen >= 0 ? (unsigned)maxlen : 0U;
int len;
if ( dis == 255 && (cat == 255 || cat == 0 ) )
len = snprintf(paramstr, umaxlen, "%d", num);
else if ( dis == 255 )
......@@ -113,6 +109,7 @@ const char *cdiUnitNamePtr(int cdi_unit)
enum { numUnits = (int) (sizeof(cdiUnits)/sizeof(char *)) };
const char *name = ( cdi_unit > 0 && cdi_unit < numUnits ) ?
cdiUnits[cdi_unit] : NULL;
return name;
}
......
......@@ -15,7 +15,7 @@
#endif
//#include "config.h"
#define VERSION "1.9.4rc1"
#define VERSION "1.9.5rc1"
typedef struct
{
size_t naline;
......
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