13 #ifndef QMCPLUSPLUS_HDF_DOUBLE_HYPERSLAB_IO_H 14 #define QMCPLUSPLUS_HDF_DOUBLE_HYPERSLAB_IO_H 25 template<
typename CT,
unsigned MAXDIM>
63 const IC& mem_dims_in,
64 const IC& mem_dims_loc,
65 const IC& mem_offsets_in)
69 for (
int i = 0; i < dims_in.size(); ++i)
70 slab_dims[i] = static_cast<hsize_t>(dims_in[i]);
71 for (
int i = 0; i < dims_loc.size(); ++i)
73 for (
int i = 0; i < dims_in.size(); ++i)
74 slab_offset[i] = static_cast<hsize_t>(offsets_in[i]);
77 for (
int i = 0; i < mem_dims_in.size(); ++i)
78 mem_dims[i] = static_cast<hsize_t>(mem_dims_in[i]);
79 for (
int i = 0; i < mem_dims_loc.size(); ++i)
81 for (
int i = 0; i < mem_dims_in.size(); ++i)
82 mem_offset[i] = static_cast<hsize_t>(mem_offsets_in[i]);
101 inline hsize_t
size(
int i)
const {
return (i > MAXDIM) ? 0 :
slab_dims[i]; }
106 template<
typename CT,
unsigned MAXDIM>
111 inline bool read(
data_type& ref, hid_t grp,
const std::string& aname, hid_t xfer_plist = H5P_DEFAULT)
115 return h5d_read(grp, aname.c_str(), ref.slab_rank, ref.slab_dims.data(), ref.slab_dims_local.data(),
116 ref.slab_offset.data(), ref.mem_rank, ref.mem_dims.data(), ref.mem_dims_local.data(),
117 ref.mem_offset.data(), ref.data(), xfer_plist);
121 int rank = ref.slab_rank;
122 if (!get_space(grp, aname,
rank, ref.slab_dims.data(),
true))
126 return h5d_read(grp, aname, ref.data(), xfer_plist);
129 inline bool write(
const data_type& ref, hid_t grp,
const std::string& aname, hid_t xfer_plist = H5P_DEFAULT)
133 return h5d_write(grp, aname.c_str(), ref.slab_rank, ref.slab_dims.data(), ref.slab_dims_local.data(),
134 ref.slab_offset.data(), ref.mem_rank, ref.mem_dims.data(), ref.mem_dims_local.data(),
135 ref.mem_offset.data(), ref.data(), xfer_plist);
139 return h5d_write(grp, aname.c_str(), ref.slab_rank, ref.slab_dims.data(), ref.data(), xfer_plist);
define h5_space_type to handle basic datatype for hdf5
TinyVector< hsize_t, MAXDIM+1 > slab_dims
global dimension of the hyperslab
helper functions for EinsplineSetBuilder
int slab_rank
rank of hyperslab
bool use_slab
true, if hyperslab is used
double_hyperslab_proxy(CT &a, const IC &dims_in, const IC &dims_loc, const IC &offsets_in, const IC &mem_dims_in, const IC &mem_dims_loc, const IC &mem_offsets_in)
class to use hyperslabs in both file and memory spaces
h5data_proxy(double_hyperslab_proxy< CT, MAXDIM > &a)
TinyVector< hsize_t, MAXDIM+1 > slab_dims_local
local dimension of the hyperslab
TinyVector< hsize_t, MAXDIM+1 > mem_dims
global dimension of the hyperslab
TinyVector< hsize_t, MAXDIM+1 > mem_offset
offset of the hyperslab
hsize_t size(int i) const
return the size of the i-th dimension
double_hyperslab_proxy(CT &a)
1D
static constexpr hsize_t rank
rank of the multidimensional dataspace
bool read(data_type &ref, hid_t grp, const std::string &aname, hid_t xfer_plist=H5P_DEFAULT)
bool write(const data_type &ref, hid_t grp, const std::string &aname, hid_t xfer_plist=H5P_DEFAULT)
double_hyperslab_proxy< CT, MAXDIM > & ref
bool h5d_read(hid_t grp, const std::string &aname, T *first, hid_t xfer_plist)
return true, if successful
TinyVector< hsize_t, MAXDIM+1 > slab_offset
offset of the hyperslab
bool h5d_write(hid_t grp, const std::string &aname, hsize_t ndims, const hsize_t *dims, const T *first, hid_t xfer_plist)
generic h5data_proxy<T> for scalar basic datatypes defined in hdf_dataspace.h Note if the dataset to ...
TinyVector< hsize_t, MAXDIM+1 > mem_dims_local
local dimension of the hyperslab