MRMD 0.4.0
Multi Resolution Molecular Dynamics
Loading...
Searching...
No Matches
hdf5.hpp
Go to the documentation of this file.
1// Copyright 2024 Sebastian Eibl
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#ifdef MRMD_ENABLE_HDF5
18#include <hdf5.h>
19#include <hdf5_hl.h>
20#endif
21
22#include "assert/assert.hpp"
23
24namespace mrmd
25{
26namespace io
27{
28#ifdef MRMD_ENABLE_HDF5
29template <typename T>
30hid_t typeToHDF5()
31{
32 MRMD_HOST_CHECK(false, "This type is not supported!");
33 exit(EXIT_FAILURE);
34}
35template <>
36inline hid_t typeToHDF5<int8_t>()
37{
38 return H5T_NATIVE_INT8;
39}
40template <>
41inline hid_t typeToHDF5<int16_t>()
42{
43 return H5T_NATIVE_INT16;
44}
45template <>
46inline hid_t typeToHDF5<int32_t>()
47{
48 return H5T_NATIVE_INT32;
49}
50template <>
51inline hid_t typeToHDF5<int64_t>()
52{
53 return H5T_NATIVE_INT64;
54}
55template <>
56inline hid_t typeToHDF5<double>()
57{
58 return H5T_NATIVE_DOUBLE;
59}
60
61template <typename T>
62auto CHECK_HDF5(const T& status)
63{
64 if (status < 0)
65 {
66 H5Eprint(H5E_DEFAULT, stderr);
68 }
69 return status;
70}
71#else
72using hid_t = int;
73#endif
74
75} // namespace io
76} // namespace mrmd
#define MRMD_HOST_CHECK_GREATEREQUAL(...)
Definition host.hpp:118
#define MRMD_HOST_CHECK(...)
Definition host.hpp:110
int hid_t
Definition hdf5.hpp:72
Definition BerendsenBarostat.cpp:18