MUQ  0.4.3
HDF5Types.h
Go to the documentation of this file.
1 #ifndef HDF5TYPES_H_
2 #define HDF5TYPES_H_
3 
4 #include <iostream>
5 
6 #include <hdf5.h>
7 #include <hdf5_hl.h>
8 
9 namespace muq
10 {
11 
12 namespace Utilities
13 {
14  herr_t H5LTset_attribute(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t mem_type_id, void *buffer, size_t size);
15 
16 #if MUQ_MPI==1
17  template<typename scalarType>
18  struct MPI_Type {
19  static MPI_Datatype GetFlag() { return MPI_DATATYPE_NULL; }
20  };
21 
22  template<>
23  struct MPI_Type<double> {
24  static MPI_Datatype GetFlag() { return MPI_DOUBLE; }
25  };
26 
27  template<>
28  struct MPI_Type<char> {
29  static MPI_Datatype GetFlag() { return MPI_CHAR; }
30  };
31 
32  template<>
33  struct MPI_Type<short> {
34  static MPI_Datatype GetFlag() { return MPI_SHORT; }
35  };
36 
37  template<>
38  struct MPI_Type<int> {
39  static MPI_Datatype GetFlag() { return MPI_INT; }
40  };
41 
42  template<>
43  struct MPI_Type<long> {
44  static MPI_Datatype GetFlag() { return MPI_LONG; }
45  };
46 
47  template<>
48  struct MPI_Type<float> {
49  static MPI_Datatype GetFlag() { return MPI_FLOAT; }
50  };
51 
52  template<>
53  struct MPI_Type<unsigned short> {
54  static MPI_Datatype GetFlag() { return MPI_UNSIGNED_SHORT; }
55  };
56 
57  template<>
58  struct MPI_Type<unsigned int> {
59  static MPI_Datatype GetFlag() { return MPI_UNSIGNED; }
60  };
61 
62  template<>
63  struct MPI_Type<unsigned long> {
64  static MPI_Datatype GetFlag() { return MPI_UNSIGNED_LONG; }
65  };
66 #endif
67 
68  std::string H5TypeToString(hid_t type);
69 
70  template<typename scalarType>
71  struct HDF5_Type{
72  static hid_t GetFlag() { return -1; }
73  };
74 
75  template<>
76  struct HDF5_Type<double>{
77  static hid_t GetFlag(){return H5T_NATIVE_DOUBLE;};
78  };
79  template<>
80  struct HDF5_Type<long double>{
81  static hid_t GetFlag(){return H5T_NATIVE_LDOUBLE;};
82  };
83  template<>
84  struct HDF5_Type<int>{
85  static hid_t GetFlag(){return H5T_NATIVE_INT;};
86  };
87  template<>
88  struct HDF5_Type<long>{
89  static hid_t GetFlag(){return H5T_NATIVE_LONG;};
90  };
91  template<>
92  struct HDF5_Type<unsigned long>{
93  static hid_t GetFlag(){return H5T_NATIVE_ULONG;};
94  };
95  template<>
96  struct HDF5_Type<unsigned int>{
97  static hid_t GetFlag(){return H5T_NATIVE_UINT;};
98  };
99 
100  template<>
101  struct HDF5_Type<float>{
102  static hid_t GetFlag(){return H5T_NATIVE_FLOAT;};
103  };
104 
105  template<>
106  struct HDF5_Type<unsigned short>{
107  static hid_t GetFlag(){return H5T_NATIVE_USHORT;};
108  };
109  template<>
110  struct HDF5_Type<short>{
111  static hid_t GetFlag(){return H5T_NATIVE_SHORT;};
112  };
113 
114  template<>
115  struct HDF5_Type<char>{
116  static hid_t GetFlag(){return H5T_NATIVE_CHAR;};
117  };
118 
119  template<>
120  struct HDF5_Type<bool>{
121 
122  static hid_t GetFlag();
123  };
124 
125 } // namespace Utilities
126 } // namespace muq
127 
128 #endif // HDF5TYPES_H_
herr_t H5LTset_attribute(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t mem_type_id, void *buffer, size_t size)
Definition: HDF5Types.cpp:19
std::string H5TypeToString(hid_t type)
Definition: HDF5Types.cpp:45
static hid_t GetFlag()
Definition: HDF5Types.h:72
static MPI_Datatype GetFlag()
Definition: HDF5Types.h:29
static MPI_Datatype GetFlag()
Definition: HDF5Types.h:24
static MPI_Datatype GetFlag()
Definition: HDF5Types.h:49
static MPI_Datatype GetFlag()
Definition: HDF5Types.h:39
static MPI_Datatype GetFlag()
Definition: HDF5Types.h:44
static MPI_Datatype GetFlag()
Definition: HDF5Types.h:34
static MPI_Datatype GetFlag()
Definition: HDF5Types.h:19