gribapi.h 3.64 KB
Newer Older
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1
2
3
#ifndef _GRIBAPI_H
#define _GRIBAPI_H

4
5
6
7
8
#ifdef HAVE_LIBGRIBAPI
#  include "error.h"
#  include <grib_api.h>
#endif

Uwe Schulzweida's avatar
Uwe Schulzweida committed
9
10
#define  GRIBAPI_MISSVAL  -9.E33

Uwe Schulzweida's avatar
Uwe Schulzweida committed
11
12
/* GRIB2 Level Types */
#define  GRIB2_LTYPE_SURFACE               1
13
14
#define  GRIB2_LTYPE_CLOUD_BASE            2
#define  GRIB2_LTYPE_CLOUD_TOP             3
15
#define  GRIB2_LTYPE_ISOTHERM0             4
16
#define  GRIB2_LTYPE_TOA                   8
17
18
#define  GRIB2_LTYPE_SEA_BOTTOM            9
#define  GRIB2_LTYPE_ATMOSPHERE           10
Uwe Schulzweida's avatar
Uwe Schulzweida committed
19
20
21
22
23
24
25
26
#define  GRIB2_LTYPE_ISOBARIC            100
#define  GRIB2_LTYPE_MEANSEA             101
#define  GRIB2_LTYPE_ALTITUDE            102
#define  GRIB2_LTYPE_HEIGHT              103
#define  GRIB2_LTYPE_SIGMA               104
#define  GRIB2_LTYPE_HYBRID              105
#define  GRIB2_LTYPE_LANDDEPTH           106
#define  GRIB2_LTYPE_ISENTROPIC          107
27
#define  GRIB2_LTYPE_SNOW                114
Uwe Schulzweida's avatar
Uwe Schulzweida committed
28
#define  GRIB2_LTYPE_REFERENCE           150
29
30
31
32
33
34
#define  GRIB2_LTYPE_SEADEPTH            160  /* Depth Below Sea Level                                 */
#define  GRIB2_LTYPE_LAKE_BOTTOM         162  /* Lake or River Bottom                                  */
#define  GRIB2_LTYPE_SEDIMENT_BOTTOM     163  /* Bottom Of Sediment Layer                              */
#define  GRIB2_LTYPE_SEDIMENT_BOTTOM_TA  164  /* Bottom Of Thermally Active Sediment Layer             */
#define  GRIB2_LTYPE_SEDIMENT_BOTTOM_TW  165  /* Bottom Of Sediment Layer Penetrated By Thermal Wave   */
#define  GRIB2_LTYPE_MIX_LAYER           166  /* Mixing Layer                                          */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
35

Uwe Schulzweida's avatar
Uwe Schulzweida committed
36
/* GRIB2 Data representation type (Grid Type) */
37
38
39
40
41
42
43
44
45
46
47
#define  GRIB2_GTYPE_LATLON                0  /*  latitude/longitude                                   */
#define  GRIB2_GTYPE_LATLON_ROT            1  /*  rotated latitude/longitude                           */
#define  GRIB2_GTYPE_LATLON_STR            2  /*  stretched latitude/longitude                         */
#define  GRIB2_GTYPE_LATLON_ROTSTR         3  /*  rotated and stretched latitude/longitude             */
#define  GRIB2_GTYPE_GAUSSIAN             40  /*  gaussian grid                                        */
#define  GRIB2_GTYPE_GAUSSIAN_ROT         41  /*  rotated gaussian grid                                */
#define  GRIB2_GTYPE_GAUSSIAN_STR         42  /*  stretched gaussian grid                              */
#define  GRIB2_GTYPE_GAUSSIAN_ROTSTR      43  /*  rotated and stretched gaussian grid                  */
#define  GRIB2_GTYPE_LCC                  30  /*  Lambert conformal                                    */
#define  GRIB2_GTYPE_SPECTRAL             50  /*  spherical harmonics                                  */
#define  GRIB2_GTYPE_GME                 100  /*  hexagonal GME grid                                   */
48
#define  GRIB2_GTYPE_UNSTRUCTURED        101  /*  General Unstructured Grid                            */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
49

50
const char *gribapiLibraryVersionString(void);
51
52
void gribContainersNew(stream_t * streamptr);
void gribContainersDelete(stream_t * streamptr);
53
54
55
#ifdef HAVE_LIBGRIBAPI
static inline void *gribHandleNew(int editionNumber)
{
56
57
  void *gh =
    (void *)grib_handle_new_from_samples(NULL, (editionNumber == 1) ? "GRIB1" : "GRIB2");
58
59
60
61
62
63
64
65
66
67
68
69
70

  if ( gh == NULL ) Error("grib_handle_new_from_samples failed!");
  return gh;
}

static inline void gribHandleDelete(void *gh)
{
  grib_handle_delete(gh);
}
#else
#define gribHandleNew(editionNumber) (NULL)
#define gribHandleDelete(gh)
#endif
Uwe Schulzweida's avatar
Uwe Schulzweida committed
71

Uwe Schulzweida's avatar
Uwe Schulzweida committed
72
73
74
75
76
77
typedef struct {
  int init;
  void *gribHandle;
}
gribContainer_t;

Uwe Schulzweida's avatar
Uwe Schulzweida committed
78
#endif  /* _GRIBAPI_H */
79
80
81
82
83
84
85
86
87
/*
 * Local Variables:
 * c-file-style: "Java"
 * c-basic-offset: 2
 * indent-tabs-mode: nil
 * show-trailing-whitespace: t
 * require-trailing-newline: t
 * End:
 */