source: XIOS/dev/branch_openmp/extern/src_netcdf4/nctime.h @ 1501

Last change on this file since 1501 was 409, checked in by ymipsl, 11 years ago

Add improved nectdf internal library src

YM

  • Property svn:eol-style set to native
File size: 5.9 KB
Line 
1/*********************************************************************
2 *   Copyright 2008, University Corporation for Atmospheric Research
3 *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
4 *   $Id: nctime.h,v 1.6 2010/03/18 19:24:26 russ Exp $
5 *********************************************************************/
6
7struct bounds_node{
8    int ncid;     /* group (or file) in which variable with associated
9                   * bounds variable resides */
10    int varid; /* has "bounds" attribute naming its bounds variable */
11    char *bounds_name; /* the named variable, which stores bounds for varid */
12    struct bounds_node *next; /* next node on list or NULL ifn last list node */
13};
14
15typedef struct bounds_node bounds_node_t;
16
17/*
18 * This code was extracted with permission from the CDMS time
19 * conversion and arithmetic routines developed by Bob Drach, Lawrence
20 * Livermore National Laboratory as part of the cdtime library.
21 * Changes and additions were made to support the "-t" option of the
22 * netCDF ncdump utility.
23 *
24 * For the complete time conversion and climate calendar facilities of
25 * the CDMS library, get the original sources from LLNL.
26 */
27
28#define CD_MAX_RELUNITS 64      /* Max characters in relative units */
29#define CD_MAX_CHARTIME 48      /* Max characters in character time */
30#define CD_NULL_DAY 1           /* Null day value */
31#define CD_NULL_HOUR 0.0        /* Null hour value */
32#define CD_NULL_ID 0            /* Reserved ID */
33#define CD_NULL_MONTH 1         /* Null month value */
34#define CD_NULL_YEAR 0          /* Null year value, component time */
35
36typedef enum CdTimeUnit {
37        CdBadTimeUnit = 0,
38        CdMinute = 1,
39        CdHour = 2,
40        CdDay = 3,
41        CdWeek = 4,             /* Always = 7 days */
42        CdMonth = 5,
43        CdSeason = 6,           /* Always = 3 months */
44        CdYear = 7,
45        CdSecond = 8
46} CdTimeUnit;
47
48typedef enum cdUnit {
49    cdBadUnit = CdBadTimeUnit,
50        cdMinute = CdMinute,
51        cdHour = CdHour,
52        cdDay = CdDay,
53        cdWeek = CdWeek,        /* Always = 7 days */
54        cdMonth = CdMonth,
55        cdSeason = CdSeason,    /* Always = 3 months */
56        cdYear = CdYear,
57        cdSecond = CdSecond,
58        cdFraction              /* Fractional part of absolute time */
59} cdUnitTime;
60
61#define CdChronCal    0x1
62#define CdClimCal     0x0
63#define CdBaseRel    0x00
64#define CdBase1970   0x10
65#define CdHasLeap   0x100
66#define CdNoLeap    0x000
67#define Cd366      0x2000
68#define Cd365      0x1000
69#define Cd360      0x0000
70#define CdJulianType 0x10000
71
72typedef enum CdTimeType {
73        CdChron       = ( CdChronCal | CdBase1970 | CdHasLeap | Cd365), /* 4369 */
74        CdJulianCal   = ( CdChronCal | CdBase1970 | CdHasLeap | Cd365 | CdJulianType),
75        CdChronNoLeap = ( CdChronCal | CdBase1970 | CdNoLeap  | Cd365), /* 4113 */
76        CdChron360    = ( CdChronCal | CdBase1970 | CdNoLeap  | Cd360), /*   17 */
77        CdRel         = ( CdChronCal | CdBaseRel  | CdHasLeap | Cd365), /* 4353 */
78        CdRelNoLeap   = ( CdChronCal | CdBaseRel  | CdNoLeap  | Cd365), /* 4097 */
79        CdClim        = ( CdClimCal  | CdBaseRel  | CdNoLeap  | Cd365), /* 4096 */
80        CdClimLeap    = ( CdClimCal  | CdBaseRel  | CdHasLeap | Cd365),
81        CdClim360     = ( CdClimCal  | CdBaseRel  | CdNoLeap  | Cd365),
82        CdChron366    = ( CdChronCal | CdBase1970 | CdNoLeap  | Cd366)
83}  CdTimeType;
84
85typedef struct {
86        long                    year;        /* e.g., 1979 */
87        short                   month;       /* e.g., CdDec */
88        short                   day;         /* e.g., 30 */
89        double                  hour;        /* hour and fractional hour */
90        long                    baseYear;    /* base year for relative, 1970 for CdChron */
91        CdTimeType              timeType;    /* e.g., CdChron */
92} CdTime;
93
94#define cdStandardCal   0x11
95#define cdClimCal        0x0
96#define cdHasLeap      0x100
97#define cdHasNoLeap    0x000
98#define cd366Days      0x2000
99#define cd365Days     0x1000
100#define cd360Days     0x0000
101#define cdJulianCal  0x10000
102#define cdMixedCal   0x20000
103
104typedef enum cdCalenType {
105        cdStandard    = ( cdStandardCal | cdHasLeap   | cd365Days),
106        cdJulian      = ( cdStandardCal | cdHasLeap   | cd365Days | cdJulianCal),
107        cdNoLeap      = ( cdStandardCal | cdHasNoLeap | cd365Days),
108        cd360         = ( cdStandardCal | cdHasNoLeap | cd360Days),
109        cd366         = ( cdStandardCal | cdHasNoLeap | cd366Days),
110        cdClim        = ( cdClimCal     | cdHasNoLeap | cd365Days),
111        cdClimLeap    = ( cdClimCal     | cdHasLeap   | cd365Days),
112        cdClim360     = ( cdClimCal     | cdHasNoLeap | cd360Days),
113        cdMixed       = ( cdStandardCal | cdHasLeap   | cd365Days | cdMixedCal)
114}  cdCalenType;
115
116/* Component time */
117typedef struct {
118        long            year;                /* Year */
119        short           month;               /* Numerical month (1..12) */
120        short           day;                 /* Day of month (1..31) */
121        double          hour;                /* Hour and fractional hours */
122} cdCompTime;
123
124typedef struct {
125        long                    count;       /* units count  */
126        CdTimeUnit              units;       /* time interval units */
127} CdDeltaTime;
128
129typedef struct timeinfo_t {
130    cdCalenType calendar;
131    cdUnitTime unit;
132    char *units;
133    cdCompTime origin;
134} timeinfo_t;
135
136
137
138#if defined(DLL_NETCDF) /* Defined when library is a DLL */
139# if defined(DLL_EXPORT) /* define when building the library. */
140#   define MSC_NCTIME_EXTRA __declspec(dllexport)
141# else
142#   define MSC_NCTIME_EXTRA __declspec(dllimport)
143# endif
144
145MSC_NCTIME_EXTRA extern void cdRel2Iso(cdCalenType timetype, char* relunits, int separator, double reltime, char* chartime);
146MSC_NCTIME_EXTRA extern void cdChar2Comp(cdCalenType timetype, char* chartime, cdCompTime* comptime);
147MSC_NCTIME_EXTRA extern void Cdh2e(CdTime *htime, double *etime);
148MSC_NCTIME_EXTRA extern void Cde2h(double etime, CdTimeType timeType, long baseYear, CdTime *htime);
149MSC_NCTIME_EXTRA extern int cdParseRelunits(cdCalenType timetype, char* relunits, cdUnitTime* unit, cdCompTime* base_comptime);
150#else
151extern void cdRel2Iso(cdCalenType timetype, char* relunits, int separator, double reltime, char* chartime);
152extern void cdChar2Comp(cdCalenType timetype, char* chartime, cdCompTime* comptime);
153extern void Cdh2e(CdTime *htime, double *etime);
154extern void Cde2h(double etime, CdTimeType timeType, long baseYear, CdTime *htime);
155extern int cdParseRelunits(cdCalenType timetype, char* relunits, cdUnitTime* unit, cdCompTime* base_comptime);
156#endif /* DLL Considerations. */
157
158
159
Note: See TracBrowser for help on using the repository browser.