Exemplo n.º 1
0
  template <typename T> void read_array_impl(h5::group g, std::string const& name, T* start, array_stride_info info) {
   static_assert(!std::is_base_of<std::string, T>::value, " Not implemented"); // 1d is below
   bool is_complex = triqs::is_complex<T>::value;
   h5::dataset ds = g.open_dataset(name);
   h5::dataspace d_space = H5Dget_space(ds);

   herr_t err =
       H5Dread(ds, h5::data_type_memory<T>(), data_space_impl(info, is_complex), d_space, H5P_DEFAULT, h5::get_data_ptr(start));
   if (err < 0) TRIQS_RUNTIME_ERROR << "Error reading the scalar dataset " << name << " in the group" << g.name();
  }
Exemplo n.º 2
0
  template <typename T> void write_array_impl(h5::group g, std::string const& name, const T* start, array_stride_info info) {
   static_assert(!std::is_base_of<std::string, T>::value, " Not implemented"); // 1d is below
   bool is_complex = triqs::is_complex<T>::value;
   h5::dataset ds = g.create_dataset(name, h5::data_type_file<T>(), data_space_impl(info, is_complex));

   auto err =
       H5Dwrite(ds, h5::data_type_memory<T>(), data_space_impl(info, is_complex), H5S_ALL, H5P_DEFAULT, h5::get_data_ptr(start));
   if (err < 0) TRIQS_RUNTIME_ERROR << "Error writing the scalar dataset " << name << " in the group" << g.name();

   // if complex, to be python compatible, we add the __complex__ attribute
   if (is_complex) h5::write_string_attribute(ds, "__complex__", "1");
  }