ESDM
Middleware for Earth System Data
h5-esdm.h
1 #ifndef H5_ESDM_H
2 #define H5_ESDM_H
3 
4 
5 #include <glib.h>
6 #include <glib/gi18n.h>
7 #include <stdlib.h>
8 #include <string.h>
9 
10 #define DEBUG 1
11 
12 #define VL_LOG(fmt) VL_LOG_FMT(VL_LOGLEVEL_DEBUG, "%s", fmt)
13 #define VL_LOG_FMT(loglevel, fmt, ...) esdm_log(loglevel, "%-30s:%d (%s): " #fmt "\n", __FILE__, __LINE__, __func__, __VA_ARGS__)
14 
15 #ifdef NDEBUG
16 // remove debug messages in total
17 # define VL_DEBUG(fmt)
18 # define VL_DEBUG_FMT(fmt, ...)
19 #else
20 # define VL_DEBUG(fmt) VL_LOG_FMT(VL_LOGLEVEL_DEBUG, "%s", fmt)
21 # define VL_DEBUG_FMT(fmt, ...) VL_LOG_FMT(VL_LOGLEVEL_DEBUG, fmt, __VA_ARGS__)
22 #endif
23 
24 #define VL_ERROR(fmt) VL_LOG_FMT(VL_LOGLEVEL_DEBUG, "%s", fmt)
25 #define VL_ERROR_FMT(fmt, ...) \
26  do { \
27  VL_LOG_FMT(VL_LOGLEVEL_DEBUG, fmt, __VA_ARGS__); \
28  exit(1); \
29  } while (0)
30 
31 #ifdef DEBUG
32 # define info(...) fprintf(stderr, "[H5 ESDM] Info: "__VA_ARGS__)
33 #else
34 # define info(...)
35 #endif
36 
37 #define warn(...) fprintf(stderr, "[H5 ESDM] Warning: "__VA_ARGS__)
38 #define fail(...) \
39  do { \
40  fprintf(stderr, "[H5 ESDM] Error: "__VA_ARGS__); \
41  exit(1); \
42  } while (0)
43 
44 /* HDF5 related integer defintions e.g. as required for herr_t */
45 
46 #define SUCCEED 0
47 
48 typedef enum type {
49  MEMVOL_FILE,
50  MEMVOL_GROUP,
51  MEMVOL_DATASET,
52  MEMVOL_ATTRIBUTE,
53  MEMVOL_DATASPACE,
54  MEMVOL_DATATYPE
55 } H5VL_esdm_object_type_t;
56 
57 typedef struct {
58  hid_t dscpl_id;
59  int dim;
61 
62 typedef struct H5VL_esdm_link_t {
63  hid_t dummy;
64  // TODO: consolidate with object?
66 
67 typedef struct H5VL_esdm_type_t {
68  hid_t lcpl_id;
69  hid_t tcpl_id;
70  hid_t tapl_id;
71  hid_t dxpl_id;
73 
74 typedef struct H5VL_esdm_attribute_t {
75  hid_t acpl_id;
76  hid_t aapl_id;
77  hid_t dxpl_id;
78  char *name;
80 
81 typedef struct H5VL_esdm_dataset_t {
82  hid_t dcpl_id;
83  hid_t dapl_id;
84  hid_t dxpl_id;
85  char *name;
86  //H5VL_loc_params_t loc_params;
87  hid_t dataspace;
88  hid_t type;
90 
91 typedef struct H5VL_esdm_groupt_t {
92  hid_t gcpl_id;
93  hid_t gapl_id;
94  hid_t dxpl_id;
95  char *name;
96  GHashTable *childs_tbl;
97  GArray *childs_ord_by_index_arr;
99 
100 typedef struct H5VL_esdm_file_t {
101  hid_t fcpl_id;
102  hid_t fapl_id;
103  hid_t dxpl_id;
104  char *name;
105  H5VL_esdm_group_t root_grp; // it must start with the root group, since in some cases we cast files to groups
106  int mode_flags; // RDWR etc.
108 
109 typedef struct H5VL_esdm_object_t {
110  H5VL_esdm_object_type_t type;
111  void *object;
112  /* union {
113  H5VL_esdm_group_t* group;
114  H5VL_esdm_dataset_t* dataset;
115  H5VL_esdm_type_t* type;
116  } object; */
118 
119 static void H5VL_esdm_group_init(H5VL_esdm_group_t *group);
120 
121 struct filt_t;
122 struct obj_t;
123 struct fapl_t;
124 struct dset_t;
125 
126 typedef struct fapl_t {
127  int mpi_size;
128  int mpi_rank;
129  char *fn;
130  char *db_fn;
131  char *data_fn;
132 } fapl_t;
133 
134 typedef struct obj_t {
135  char *location;
136  char *name;
137  //H5O_info_t info;
138  struct file_t *root;
139  //fapl_t* fapl;
140  fapl_t fapl;
141 } obj_t;
142 
143 typedef struct file_t {
144  obj_t object;
145  int fd;
146  off_t offset; // global offset
147  void *db;
148 } file_t; /* structure for file*/
149 
150 typedef struct dset_t {
151  obj_t object;
152  off_t offset; // position in file
153  size_t data_size;
154 } dset_t;
155 
156 #endif
Definition: h5-esdm.h:74
Definition: h5-esdm.h:81
Definition: h5-esdm.h:57
Definition: h5-esdm.h:100
Definition: h5-esdm.h:91
Definition: h5-esdm.h:109
Definition: h5-esdm.h:67
Definition: h5-esdm.h:150
Definition: h5-esdm.h:126
Definition: h5-esdm.h:143
Definition: h5-esdm.h:134