SIRIUS 7.5.0
Electronic structure library and applications
hdf5_tree.hpp
Go to the documentation of this file.
1// Copyright (c) 2013-2023 Anton Kozhevnikov, Thomas Schulthess
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without modification, are permitted provided that
5// the following conditions are met:
6//
7// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
8// following disclaimer.
9// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
10// and the following disclaimer in the documentation and/or other materials provided with the distribution.
11//
12// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
13// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
14// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
15// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
17// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
18// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
20/** \file hdf5_tree.hpp
21 *
22 * \brief Contains definition and implementation of sirius::HDF5_tree class.
23 */
24
25#ifndef __HDF5_TREE_HPP__
26#define __HDF5_TREE_HPP__
27
28#include <fstream>
29#include <hdf5.h>
30#include <vector>
31#include <string>
32#include <initializer_list>
33#include "SDDK/memory.hpp"
34#include "core/rte/rte.hpp"
35
36namespace sirius {
37
38enum class hdf5_access_t
39{
40 truncate,
41 read_write,
42 read_only
43};
44
45template <typename T>
47
48template <>
49struct hdf5_type_wrapper<float>
50{
51 operator hid_t() const noexcept
52 {
53 return H5T_NATIVE_FLOAT;
54 };
55};
56
57template <>
58struct hdf5_type_wrapper<double>
59{
60 operator hid_t() const noexcept
61 {
62 return H5T_NATIVE_DOUBLE;
63 };
64};
65
66template <>
68{
69 operator hid_t() const noexcept
70 {
71 return H5T_NATIVE_INT;
72 };
73};
74
75template <>
76struct hdf5_type_wrapper<uint8_t>
77{
78 operator hid_t() const noexcept
79 {
80 return H5T_NATIVE_UCHAR;
81 };
82};
83
84/// Interface to the HDF5 library.
86{
87 private:
88 /// HDF5 file name
89 std::string file_name_;
90
91 /// path inside HDF5 file
92 std::string path_;
93
94 /// HDF5 file handler
95 hid_t file_id_{-1};
96
97 /// True if this is a root node
98 bool root_node_{true};
99
100 /// Auxiliary class to handle HDF5 Group object
102 {
103 private:
104 /// HDF5 id of the current object
105 hid_t id_;
106
107 public:
108 /// Constructor which openes the existing group.
109 HDF5_group(hid_t file_id, const std::string& path)
110 {
111 if ((id_ = H5Gopen(file_id, path.c_str(), H5P_DEFAULT)) < 0) {
112 std::stringstream s;
113 s << "error in H5Gopen()" << std::endl << "path : " << path;
114 RTE_THROW(s);
115 }
116 }
117
118 /// Constructor which creates the new group.
119 HDF5_group(HDF5_group const& g, const std::string& name)
120 {
121 if ((id_ = H5Gcreate(g.id(), name.c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
122 std::stringstream s;
123 s << "error in H5Gcreate()" << std::endl << "name : " << name;
124 RTE_THROW(s);
125 }
126 }
127
128 /// Destructor.
130 {
131 if (H5Gclose(id_) < 0) {
132 RTE_THROW("error in H5Gclose()");
133 }
134 }
135
136 /// Return HDF5 id of the current object.
137 inline hid_t id() const
138 {
139 return id_;
140 }
141 };
142
143 /// Auxiliary class to handle HDF5 Dataspace object
145 {
146 private:
147 /// HDF5 id of the current object
148 hid_t id_;
149
150 public:
151 /// Constructor which creates the new dataspace object.
152 HDF5_dataspace(const std::vector<int> dims)
153 {
154 std::vector<hsize_t> current_dims(dims.size());
155 for (int i = 0; i < (int)dims.size(); i++) {
156 current_dims[dims.size() - i - 1] = dims[i];
157 }
158
159 if ((id_ = H5Screate_simple((int)dims.size(), &current_dims[0], NULL)) < 0) {
160 RTE_THROW("error in H5Screate_simple()");
161 }
162 }
163
164 /// Destructor.
166 {
167 if (H5Sclose(id_) < 0) {
168 RTE_THROW("error in H5Sclose()");
169 }
170 }
171
172 /// Return HDF5 id of the current object.
173 inline hid_t id() const
174 {
175 return id_;
176 }
177 };
178
179 /// Auxiliary class to handle HDF5 Dataset object
181 {
182 private:
183 /// HDF5 id of the current object
184 hid_t id_;
185
186 public:
187 /// Constructor which openes the existing dataset object.
188 HDF5_dataset(hid_t group_id, const std::string& name)
189 {
190 if ((id_ = H5Dopen(group_id, name.c_str(), H5P_DEFAULT)) < 0) {
191 RTE_THROW("error in H5Dopen()");
192 }
193 }
194
195 /// Constructor which creates the new dataset object.
196 HDF5_dataset(HDF5_group& group, HDF5_dataspace& dataspace, const std::string& name, hid_t type_id)
197 {
198 if ((id_ = H5Dcreate(group.id(), name.c_str(), type_id, dataspace.id(), H5P_DEFAULT, H5P_DEFAULT,
199 H5P_DEFAULT)) < 0) {
200 RTE_THROW("error in H5Dcreate()");
201 }
202 }
203
204 /// Destructor.
206 {
207 if (H5Dclose(id_) < 0) {
208 RTE_THROW("error in H5Dclose()");
209 }
210 }
211
212 /// Return HDF5 id of the current object.
213 inline hid_t id() const
214 {
215 return id_;
216 }
217 };
218
219 /// Auxiliary class to handle HDF5 Attribute object
220 ///
221 /// @remark The Attribute's Dataspace is assumed to be SCALAR.
223 {
224 private:
225 /// HDF5 id of the current object
226 hid_t id_;
227
228 public:
229 /// Constructor which opens the existing attribute object
230 HDF5_attribute(hid_t attribute_id, const std::string& name)
231 {
232 if ((id_ = H5Aopen(attribute_id, name.c_str(), H5P_DEFAULT)) < 0)
233 RTE_THROW("error in H5Aopen()");
234 }
235
236 /// Constructor creating the new attribute object
237 ///
238 /// @remark The Attribute's DATASPACE is assumed to be SCALAR
239 ///
240 /// @param parent_id GROUP or DATASET ID to which the attribute is attached
241 /// @param name Name of the attribute
242 /// @param type_id Type ID for the attribute
243 HDF5_attribute(hid_t parent_id, const std::string& name, hid_t type_id)
244 {
245 hid_t dataspace_id;
246
247 // Create SCALAR Dataspace
248 if ((dataspace_id = H5Screate(H5S_SCALAR)) < 0) {
249 RTE_THROW("error in H5Screate()");
250 }
251
252 if ((id_ = H5Acreate(parent_id, name.c_str(), type_id, dataspace_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
253 RTE_THROW("error in H5Acreate()");
254 }
255 }
256
257 /// Destructor
259 {
260 if (H5Aclose(id_) < 0) {
261 RTE_THROW("error in H5Aclose()");
262 }
263 }
264
265 /// Return HDF5 id of the current object
266 inline hid_t id() const
267 {
268 return id_;
269 }
270 };
271
272 /// Constructor to create branches of the HDF5 tree.
273 HDF5_tree(hid_t file_id__, const std::string& path__)
274 : path_(path__)
275 , file_id_(file_id__)
276 , root_node_(false)
277 {
278 }
279
280 /// Create HDF5 string type from std::string
281 hid_t string_type(const std::string& data, hid_t base_string_type) const
282 {
283 // Create string type
284 hid_t string_type = H5Tcopy(base_string_type);
285 if (H5Tset_size(string_type, std::size(data)) < 0) {
286 RTE_THROW("error in H5Tset_size()");
287 }
288 return string_type;
289 }
290
291 /// Create HDF5 array type from std::vector
292 template <typename T>
293 hid_t array_type(const std::vector<T>& data) const
294 {
295 hsize_t data_size = std::size(data);
296 return H5Tarray_create(hdf5_type_wrapper<T>(), 1, &data_size);
297 }
298
299 /// Write a multidimensional array.
300 template <typename T>
301 void write(const std::string& name, T const* data, std::vector<int> const& dims)
302 {
303 /* open group */
304 HDF5_group group(file_id_, path_);
305
306 /* make dataspace */
307 HDF5_dataspace dataspace(dims);
308
309 /* create new dataset */
310 HDF5_dataset dataset(group, dataspace, name, hdf5_type_wrapper<T>());
311
312 /* write data */
313 if (H5Dwrite(dataset.id(), hdf5_type_wrapper<T>(), dataspace.id(), H5S_ALL, H5P_DEFAULT, data) < 0) {
314 RTE_THROW("error in H5Dwrite()");
315 }
316 }
317
318 /// Write attribure to current GROUP
319 ///
320 /// @param name Name of the attribute
321 /// @param data Attribute data
322 /// @param type_id Attribute type ID
323 template <typename T>
324 void write_attribute(const std::string& name, const T* const data, hid_t type_id) const
325 {
326 HDF5_group group(file_id_, path_);
327
328 HDF5_attribute attribute(group.id(), name, type_id);
329
330 if (H5Awrite(attribute.id(), type_id, data) < 0) {
331 RTE_THROW("error in H5Awrite()");
332 }
333 }
334
335 /// Write attribure to DATASET within the GROUP
336 ///
337 /// @param name Name of the attribute
338 /// @param data Attribute data
339 /// @param type_id Attribute type ID
340 /// @param dataset_name Dataset in current group to wich attach the attribute
341 template <typename T>
342 void write_attribute(const std::string& name, const T* const data, hid_t type_id,
343 const std::string& dataset_name) const
344 {
345 HDF5_group group(file_id_, path_);
346
347 HDF5_dataset dataset(group.id(), dataset_name);
348
349 HDF5_attribute attribute(dataset.id(), name, type_id);
350
351 if (H5Awrite(attribute.id(), type_id, data) < 0) {
352 RTE_THROW("error in H5Awrite()");
353 }
354 }
355
356 /// Read a multidimensional array.
357 template <typename T>
358 void read(const std::string& name, T* data, std::vector<int> const& dims)
359 {
360 HDF5_group group(file_id_, path_);
361
362 HDF5_dataspace dataspace(dims);
363
364 HDF5_dataset dataset(group.id(), name);
365
366 if (H5Dread(dataset.id(), hdf5_type_wrapper<T>(), dataspace.id(), H5S_ALL, H5P_DEFAULT, data) < 0) {
367 RTE_THROW("error in H5Dread()");
368 }
369 }
370
371 // HDF5_tree(HDF5_tree const& src) = delete;
372
373 // HDF5_tree& operator=(HDF5_tree const& src) = delete;
374
375 public:
376 /// Constructor to create the HDF5 tree.
377 HDF5_tree(const std::string& file_name__, hdf5_access_t access__)
378 : file_name_(file_name__)
379 {
380 if (H5open() < 0) {
381 RTE_THROW("error in H5open()");
382 }
383
384 if (false) {
385 H5Eset_auto(H5E_DEFAULT, NULL, NULL);
386 }
387
388 switch (access__) {
389 case hdf5_access_t::truncate: {
390 file_id_ = H5Fcreate(file_name_.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
391 if (file_id_ < 0) {
392 RTE_THROW("error in H5Fcreate()");
393 }
394 break;
395 }
396 case hdf5_access_t::read_write: {
397 file_id_ = H5Fopen(file_name_.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
398 break;
399 }
400 case hdf5_access_t::read_only: {
401 file_id_ = H5Fopen(file_name_.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
402 break;
403 }
404 }
405 if (file_id_ < 0) {
406 RTE_THROW("H5Fopen() failed");
407 }
408
409 path_ = "/";
410 }
411
412 /// Destructor.
414 {
415 if (root_node_) {
416 if (H5Fclose(file_id_) < 0) {
417 RTE_THROW("error in H5Fclose()");
418 }
419 }
420 }
421
422 /// Create node by integer index.
423 /** Create node at the current location using integer index as a name. */
425 {
426 return create_node(std::to_string(idx));
427 }
428
429 /// Create node by name.
430 /** Create node with the given name at the current location.*/
431 HDF5_tree create_node(std::string const& name)
432 {
433 /* try to open a group */
434 HDF5_group group(file_id_, path_);
435 /* try to create a new group */
436 HDF5_group(group, name);
437
438 return (*this)[name];
439 }
440
441 template <typename T, int N>
442 void write(const std::string& name, sddk::mdarray<std::complex<T>, N> const& data)
443 {
444 std::vector<int> dims(N + 1);
445 dims[0] = 2;
446 for (int i = 0; i < N; i++) {
447 dims[i + 1] = (int)data.size(i);
448 }
449 write(name, (T*)data.at(sddk::memory_t::host), dims);
450 }
451
452 /// Write a multidimensional array by name.
453 template <typename T, int N>
454 void write(std::string const& name__, sddk::mdarray<T, N> const& data__)
455 {
456 std::vector<int> dims(N);
457 for (int i = 0; i < N; i++) {
458 dims[i] = static_cast<int>(data__.size(i));
459 }
460 write(name__, data__.at(sddk::memory_t::host), dims);
461 }
462
463 /// Write a multidimensional array by integer index.
464 template <typename T, int N>
465 void write(int name_id, sddk::mdarray<T, N> const& data)
466 {
467 std::string name = std::to_string(name_id);
468 write(name, data);
469 }
470
471 /// Write a buffer.
472 template <typename T>
473 void write(const std::string& name, T const* data, int size)
474 {
475 std::vector<int> dims(1);
476 dims[0] = size;
477 write(name, data, dims);
478 }
479
480 /// Write a scalar.
481 template <typename T>
482 void write(const std::string& name, T data)
483 {
484 std::vector<int> dims(1);
485 dims[0] = 1;
486 write(name, &data, dims);
487 }
488
489 /// Write a vector by id.
490 template <typename T>
491 void write(int name_id, std::vector<T> const& vec)
492 {
493 std::string name = std::to_string(name_id);
494 write(name, &vec[0], (int)vec.size());
495 }
496
497 /// Write a vector by name.
498 template <typename T>
499 void write(const std::string& name, std::vector<T> const& vec)
500 {
501 write(name, &vec[0], (int)vec.size());
502 }
503
504 /// Write attribute
505 template <typename T>
506 void write_attribute(const std::string& name, const T& data) const
507 {
509 }
510
511 /// Write attribute
512 template <typename T>
513 void write_attribute(const std::string& name, const T& data, const std::string& dataset_name) const
514 {
515 write_attribute(name, &data, hdf5_type_wrapper<T>(), dataset_name);
516 }
517
518 /// Write string attribute
519 void write_attribute(const std::string& name, const std::string& data,
520 hid_t base_string_type = H5T_FORTRAN_S1) const
521 {
522 write_attribute(name, data.c_str(), string_type(data, base_string_type));
523 }
524
525 /// Write string attribute
526 void write_attribute(const std::string& name, const std::string& data, const std::string& dataset_name,
527 hid_t base_string_type = H5T_FORTRAN_S1) const
528 {
529 write_attribute(name, data.c_str(), string_type(data, base_string_type), dataset_name);
530 }
531
532 /// Write string attribute
533 template <std::size_t N>
534 void write_attribute(const std::string& name, const char (&data)[N], hid_t base_string_type = H5T_FORTRAN_S1) const
535 {
536 write_attribute(name, std::string(data), base_string_type);
537 }
538
539 /// Write string attribute
540 template <std::size_t N>
541 void write_attribute(const std::string& name, const char (&data)[N], const std::string& dataset_name,
542 hid_t base_string_type = H5T_FORTRAN_S1) const
543 {
544 write_attribute(name, std::string(data), dataset_name, base_string_type);
545 }
546
547 /// Write array attribute
548 template <typename T>
549 void write_attribute(const std::string& name, const std::vector<T>& data) const
550 {
551 write_attribute(name, data.data(), array_type(data));
552 }
553
554 /// Write array attribute
555 template <typename T>
556 void write_attribute(const std::string& name, const std::vector<T>& data, const std::string& dataset_name) const
557 {
558 write_attribute(name, data.data(), array_type(data), dataset_name);
559 }
560
561 /// Write array attribute
562 template <typename T>
563 void write_attribute(const std::string& name, const std::initializer_list<T>& data) const
564 {
565 write_attribute(name, std::vector<T>(data));
566 }
567
568 /// Write array attribute
569 template <typename T>
570 void write_attribute(const std::string& name, const std::initializer_list<T>& data,
571 const std::string& dataset_name) const
572 {
573 write_attribute(name, std::vector<T>(data), dataset_name);
574 }
575
576 template <int N>
577 void read(const std::string& name, sddk::mdarray<std::complex<double>, N>& data)
578 {
579 std::vector<int> dims(N + 1);
580 dims[0] = 2;
581 for (int i = 0; i < N; i++) {
582 dims[i + 1] = (int)data.size(i);
583 }
584 read(name, (double*)data.at(sddk::memory_t::host), dims);
585 }
586
587 template <typename T, int N>
588 void read(const std::string& name, sddk::mdarray<T, N>& data)
589 {
590 std::vector<int> dims(N);
591 for (int i = 0; i < N; i++) {
592 dims[i] = (int)data.size(i);
593 }
594 read(name, data.at(sddk::memory_t::host), dims);
595 }
596
597 template <typename T, int N>
598 void read(int name_id, sddk::mdarray<T, N>& data)
599 {
600 std::string name = std::to_string(name_id);
601 read(name, data);
602 }
603
604 /// Read a vector or a scalar.
605 template <typename T>
606 void read(std::string const& name, T* data, int size)
607 {
608 std::vector<int> dims(1);
609 dims[0] = size;
610 read(name, data, dims);
611 }
612
613 template <typename T>
614 void read(int name_id, std::vector<T>& vec)
615 {
616 read(std::to_string(name_id), &vec[0], (int)vec.size());
617 }
618
619 template <typename T>
620 void read(std::string const& name, std::vector<T>& vec)
621 {
622 read(name, &vec[0], (int)vec.size());
623 }
624
625 HDF5_tree operator[](std::string const& path__)
626 {
627 auto new_path = path_ + path__ + "/";
628 return HDF5_tree(file_id_, new_path);
629 }
630
631 HDF5_tree operator[](int idx__)
632 {
633 auto new_path = path_ + std::to_string(idx__) + "/";
634 return HDF5_tree(file_id_, new_path);
635 }
636};
637
638}; // namespace
639
640#endif // __HDF5_TREE_HPP__
HDF5_attribute(hid_t parent_id, const std::string &name, hid_t type_id)
Definition: hdf5_tree.hpp:243
hid_t id_
HDF5 id of the current object.
Definition: hdf5_tree.hpp:226
hid_t id() const
Return HDF5 id of the current object.
Definition: hdf5_tree.hpp:266
HDF5_attribute(hid_t attribute_id, const std::string &name)
Constructor which opens the existing attribute object.
Definition: hdf5_tree.hpp:230
Auxiliary class to handle HDF5 Dataset object.
Definition: hdf5_tree.hpp:181
HDF5_dataset(HDF5_group &group, HDF5_dataspace &dataspace, const std::string &name, hid_t type_id)
Constructor which creates the new dataset object.
Definition: hdf5_tree.hpp:196
HDF5_dataset(hid_t group_id, const std::string &name)
Constructor which openes the existing dataset object.
Definition: hdf5_tree.hpp:188
hid_t id_
HDF5 id of the current object.
Definition: hdf5_tree.hpp:184
hid_t id() const
Return HDF5 id of the current object.
Definition: hdf5_tree.hpp:213
Auxiliary class to handle HDF5 Dataspace object.
Definition: hdf5_tree.hpp:145
HDF5_dataspace(const std::vector< int > dims)
Constructor which creates the new dataspace object.
Definition: hdf5_tree.hpp:152
hid_t id_
HDF5 id of the current object.
Definition: hdf5_tree.hpp:148
hid_t id() const
Return HDF5 id of the current object.
Definition: hdf5_tree.hpp:173
Auxiliary class to handle HDF5 Group object.
Definition: hdf5_tree.hpp:102
hid_t id() const
Return HDF5 id of the current object.
Definition: hdf5_tree.hpp:137
HDF5_group(hid_t file_id, const std::string &path)
Constructor which openes the existing group.
Definition: hdf5_tree.hpp:109
hid_t id_
HDF5 id of the current object.
Definition: hdf5_tree.hpp:105
HDF5_group(HDF5_group const &g, const std::string &name)
Constructor which creates the new group.
Definition: hdf5_tree.hpp:119
Interface to the HDF5 library.
Definition: hdf5_tree.hpp:86
void write(const std::string &name, T data)
Write a scalar.
Definition: hdf5_tree.hpp:482
hid_t file_id_
HDF5 file handler.
Definition: hdf5_tree.hpp:95
void write_attribute(const std::string &name, const std::string &data, const std::string &dataset_name, hid_t base_string_type=H5T_FORTRAN_S1) const
Write string attribute.
Definition: hdf5_tree.hpp:526
void write_attribute(const std::string &name, const char(&data)[N], hid_t base_string_type=H5T_FORTRAN_S1) const
Write string attribute.
Definition: hdf5_tree.hpp:534
void write_attribute(const std::string &name, const char(&data)[N], const std::string &dataset_name, hid_t base_string_type=H5T_FORTRAN_S1) const
Write string attribute.
Definition: hdf5_tree.hpp:541
std::string file_name_
HDF5 file name.
Definition: hdf5_tree.hpp:89
HDF5_tree(const std::string &file_name__, hdf5_access_t access__)
Constructor to create the HDF5 tree.
Definition: hdf5_tree.hpp:377
void write_attribute(const std::string &name, const std::vector< T > &data) const
Write array attribute.
Definition: hdf5_tree.hpp:549
HDF5_tree create_node(int idx)
Create node by integer index.
Definition: hdf5_tree.hpp:424
void read(const std::string &name, T *data, std::vector< int > const &dims)
Read a multidimensional array.
Definition: hdf5_tree.hpp:358
void write(int name_id, sddk::mdarray< T, N > const &data)
Write a multidimensional array by integer index.
Definition: hdf5_tree.hpp:465
bool root_node_
True if this is a root node.
Definition: hdf5_tree.hpp:98
hid_t string_type(const std::string &data, hid_t base_string_type) const
Create HDF5 string type from std::string.
Definition: hdf5_tree.hpp:281
void read(std::string const &name, T *data, int size)
Read a vector or a scalar.
Definition: hdf5_tree.hpp:606
hid_t array_type(const std::vector< T > &data) const
Create HDF5 array type from std::vector.
Definition: hdf5_tree.hpp:293
HDF5_tree(hid_t file_id__, const std::string &path__)
Constructor to create branches of the HDF5 tree.
Definition: hdf5_tree.hpp:273
void write(const std::string &name, T const *data, std::vector< int > const &dims)
Write a multidimensional array.
Definition: hdf5_tree.hpp:301
void write_attribute(const std::string &name, const std::initializer_list< T > &data, const std::string &dataset_name) const
Write array attribute.
Definition: hdf5_tree.hpp:570
void write_attribute(const std::string &name, const std::initializer_list< T > &data) const
Write array attribute.
Definition: hdf5_tree.hpp:563
void write(int name_id, std::vector< T > const &vec)
Write a vector by id.
Definition: hdf5_tree.hpp:491
HDF5_tree create_node(std::string const &name)
Create node by name.
Definition: hdf5_tree.hpp:431
void write_attribute(const std::string &name, const T &data, const std::string &dataset_name) const
Write attribute.
Definition: hdf5_tree.hpp:513
void write(std::string const &name__, sddk::mdarray< T, N > const &data__)
Write a multidimensional array by name.
Definition: hdf5_tree.hpp:454
void write_attribute(const std::string &name, const T *const data, hid_t type_id) const
Definition: hdf5_tree.hpp:324
~HDF5_tree()
Destructor.
Definition: hdf5_tree.hpp:413
void write(const std::string &name, T const *data, int size)
Write a buffer.
Definition: hdf5_tree.hpp:473
std::string path_
path inside HDF5 file
Definition: hdf5_tree.hpp:92
void write_attribute(const std::string &name, const T &data) const
Write attribute.
Definition: hdf5_tree.hpp:506
void write_attribute(const std::string &name, const std::vector< T > &data, const std::string &dataset_name) const
Write array attribute.
Definition: hdf5_tree.hpp:556
void write_attribute(const std::string &name, const std::string &data, hid_t base_string_type=H5T_FORTRAN_S1) const
Write string attribute.
Definition: hdf5_tree.hpp:519
void write(const std::string &name, std::vector< T > const &vec)
Write a vector by name.
Definition: hdf5_tree.hpp:499
void write_attribute(const std::string &name, const T *const data, hid_t type_id, const std::string &dataset_name) const
Definition: hdf5_tree.hpp:342
Multidimensional array with the column-major (Fortran) order.
Definition: memory.hpp:660
size_t size() const
Return total size (number of elements) of the array.
Definition: memory.hpp:1207
Memory management functions and classes.
Namespace of the SIRIUS library.
Definition: sirius.f90:5
Eror and warning handling during run-time execution.