*/
template <typename T>
T
- attr(const std::string attr_name) const;
+ attr(const std::string attr_name);
/**
* Writes an attribute. T can be float, double, std::complex<float>,
*/
template <typename T>
void
- write_attr(const std::string attr_name, const T value) const;
+ write_attr(const std::string attr_name, const T value);
const std::string name;
protected:
+ /**
+ * HDF5 identifier for the objects File, Group and Dataset
+ */
std::shared_ptr<hid_t> hdf5_reference;
- // If true use mpi hdf5. If false use serial hdf5.
+
+ /**
+ * If true use parallel HDF5, if false use serial HDF5.
+ */
const bool mpi;
+
+ /**
+ * Returned value of the last HDF5 C library call.
+ *
+ * The HDF5 calls return a non-negative value if successful; otherwise they
+ * return a negative value.
+ *
+ * Calls such as
+ * [H5DWrite](https://support.hdfgroup.org/HDF5/doc/RM/RM_H5D.html#Dataset-Write)
+ * use this variable to store the returned value. Other calls such as
+ * [H5Pcreate](https://support.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-Create)
+ * don't use this variable to store the returned value.
+ */
+ herr_t ret;
};
/**
template <typename T>
T
- HDF5Object::attr(const std::string attr_name) const
+ HDF5Object::attr(const std::string attr_name)
{
std::shared_ptr<hid_t> t_type = internal::get_hdf5_datatype<T>();
T value;
template <>
bool
- HDF5Object::attr(const std::string attr_name) const
+ HDF5Object::attr(const std::string attr_name)
{
// The enum field generated by h5py can be casted to int
int int_value;
template <>
std::string
- HDF5Object::attr(const std::string attr_name) const
+ HDF5Object::attr(const std::string attr_name)
{
// Reads a UTF8 variable string
//
// Todo:
// - Use H5Dvlen_reclaim instead of free
- char * string_out;
- hid_t attr;
- hid_t type;
- herr_t ret;
+ char *string_out;
+ hid_t attr;
+ hid_t type;
/* Create a datatype to refer to. */
type = H5Tcopy(H5T_C_S1);
template <typename T>
void
- HDF5Object::write_attr(const std::string attr_name, const T value) const
+ HDF5Object::write_attr(const std::string attr_name, const T value)
{
hid_t attr;
hid_t aid;
template <>
void
- HDF5Object::write_attr(const std::string attr_name,
- const std::string value) const
+ HDF5Object::write_attr(const std::string attr_name, const std::string value)
{
// Writes a UTF8 variable string
//
// (char *). For this reason the std::string value has been copied to a C
// string.
- hid_t attr;
- hid_t aid;
- hid_t t_type;
- herr_t ret;
+ hid_t attr;
+ hid_t aid;
+ hid_t t_type;
// Reserve space for the string and the null terminator
char *c_string_value = (char *)malloc(sizeof(char) * (value.size() + 1));
{
std::shared_ptr<hid_t> t_type = internal::get_hdf5_datatype<number>();
hid_t plist;
- herr_t ret;
Container<number> data =
internal::initialize_container<Container, number>(_dimensions);
std::shared_ptr<hid_t> t_type = internal::get_hdf5_datatype<number>();
hid_t plist;
hid_t memory_dataspace;
- herr_t ret;
std::vector<hsize_t> data_dimensions{
static_cast<hsize_t>(coordinates.size() / _rank)};
std::shared_ptr<hid_t> t_type = internal::get_hdf5_datatype<number>();
hid_t plist;
hid_t memory_dataspace;
- herr_t ret;
// In this particular overload of read_hyperslab the data_dimensions are
// the same as count
std::shared_ptr<hid_t> t_type = internal::get_hdf5_datatype<number>();
std::vector<hsize_t> data_dimensions = {0};
- hid_t memory_dataspace;
- hid_t plist;
- herr_t ret;
+ hid_t memory_dataspace;
+ hid_t plist;
memory_dataspace = H5Screate_simple(1, data_dimensions.data(), NULL);
Assert(memory_dataspace >= 0, ExcMessage("Error at H5Screate_simple"));
AssertDimension(_size, internal::get_container_size(data));
std::shared_ptr<hid_t> t_type = internal::get_hdf5_datatype<number>();
hid_t plist;
- herr_t ret;
if (mpi)
{
std::shared_ptr<hid_t> t_type = internal::get_hdf5_datatype<number>();
std::vector<hsize_t> data_dimensions = {data.size()};
- hid_t memory_dataspace;
- hid_t plist;
- herr_t ret;
+ hid_t memory_dataspace;
+ hid_t plist;
memory_dataspace = H5Screate_simple(1, data_dimensions.data(), NULL);
// the same as count
std::vector<hsize_t> data_dimensions = count;
- hid_t memory_dataspace;
- hid_t plist;
- herr_t ret;
+ hid_t memory_dataspace;
+ hid_t plist;
memory_dataspace =
H5Screate_simple(data_dimensions.size(), data_dimensions.data(), NULL);
{
std::shared_ptr<hid_t> t_type = internal::get_hdf5_datatype<number>();
- hid_t memory_dataspace;
- hid_t plist;
- herr_t ret;
+ hid_t memory_dataspace;
+ hid_t plist;
memory_dataspace =
H5Screate_simple(data_dimensions.size(), data_dimensions.data(), NULL);
std::shared_ptr<hid_t> t_type = internal::get_hdf5_datatype<number>();
std::vector<hsize_t> data_dimensions = {0};
- hid_t memory_dataspace;
- hid_t plist;
- herr_t ret;
+ hid_t memory_dataspace;
+ hid_t plist;
memory_dataspace = H5Screate_simple(1, data_dimensions.data(), NULL);
H5Sselect_none(*dataspace);
break;
default:
Assert(false, ExcInternalError());
+ return std::string("Internal error");
break;
}
+ // The function should not reach this line.
+ Assert(false, ExcInternalError());
+ return std::string("Internal error");
}
template <>
// std::complex<float> and std::complex<double> in hdf5.inst
template int
- HDF5Object::attr<int>(const std::string attr_name) const;
+ HDF5Object::attr<int>(const std::string attr_name);
template unsigned int
- HDF5Object::attr<unsigned int>(const std::string attr_name) const;
+ HDF5Object::attr<unsigned int>(const std::string attr_name);
// The specializations of HDF5Object::attr<std::string>
// and HDF5Object::attr<bool> have been defined above
template void
- HDF5Object::write_attr<int>(const std::string attr_name, int value) const;
+ HDF5Object::write_attr<int>(const std::string attr_name, int value);
template void
HDF5Object::write_attr<unsigned int>(const std::string attr_name,
- unsigned int value) const;
+ unsigned int value);
template std::vector<int>
DataSet::read<std::vector, int>();