votca 2024-dev
Loading...
Searching...
No Matches
checkpoint_utils.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 *
7 * http://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 */
16
17#pragma once
18#ifndef VOTCA_XTP_CHECKPOINT_UTILS_H
19#define VOTCA_XTP_CHECKPOINT_UTILS_H
20
21// Standard includes
22#include <cstddef>
23#include <cstring>
24#include <string>
25
26// Third party includes
27#include <H5Cpp.h>
28
29// VOTCA includes
30#include <votca/tools/types.h>
31
32namespace votca {
33namespace xtp {
34
35using CptLoc = H5::Group;
36
37namespace checkpoint_utils {
38
39H5::DataSpace str_scalar(H5::DataSpace(H5S_SCALAR));
40
41inline H5::DataSpace StrScalar() { return H5::DataSpace(H5S_SCALAR); }
42
43// Declare some HDF5 data type inference stuff:
44// Adapted from
45// https://github.com/garrison/eigen3-hdf5/blob/2c782414251e75a2de9b0441c349f5f18fe929a2/eigen3-hdf5.hpp#L18
46
47template <typename T>
49
50template <>
51struct InferDataType<float> {
52 static const H5::DataType* get(void) { return &H5::PredType::NATIVE_FLOAT; }
53};
54
55template <>
56struct InferDataType<double> {
57 static const H5::DataType* get(void) { return &H5::PredType::NATIVE_DOUBLE; }
58};
59
60template <>
61struct InferDataType<int> {
62 static const H5::DataType* get(void) { return &H5::PredType::NATIVE_INT; }
63};
64
65template <>
66struct InferDataType<long int> {
67 static const H5::DataType* get(void) { return &H5::PredType::NATIVE_LONG; }
68};
69
70template <>
71struct InferDataType<unsigned> {
72 static const H5::DataType* get(void) { return &H5::PredType::NATIVE_UINT; }
73};
74
75template <>
76struct InferDataType<std::string> {
77 static const H5::DataType* get(void) {
78
79#if (defined(__GNUC__) && defined(__clang__))
80#pragma clang diagnostic push
81#pragma clang diagnostic ignored "-Wconversion"
82#elif (defined(__GNUC__) && !defined(__INTEL_COMPILER))
83#pragma GCC diagnostic push
84#pragma GCC diagnostic ignored "-Wconversion"
85#elif (defined(__INTEL_COMPILER))
86#pragma warning push
87#pragma warning(disable : 1682) // implicit conversion of a 64-bit integral
88 // type to a smaller integral type
89#endif
90 static const H5::StrType strtype(H5T_C_S1, H5T_VARIABLE);
91#if (defined(__GNUC__) && defined(__clang__))
92#pragma clang diagnostic pop
93#elif (defined(__GNUC__) && !defined(__INTEL_COMPILER))
94#pragma GCC diagnostic pop
95#elif (defined(__INTEL_COMPILER))
96#pragma warning pop
97#endif
98
99 return &strtype;
100 }
101};
102
103H5::DataSpace str_scalar(H5::DataSpace(H5S_SCALAR));
104
105} // namespace checkpoint_utils
106} // namespace xtp
107} // namespace votca
108#endif // VOTCA_XTP_CHECKPOINT_UTILS_H
STL namespace.
H5::DataSpace str_scalar(H5::DataSpace(H5S_SCALAR))
H5::Group CptLoc
base class for all analysis tools
Definition basebead.h:33