3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-27 06:43:40 +01:00
dft_tools/doc/reference/arrays/examples_h5/h5_rw.cpp
tayral edd1ff4529 Restructuring documentation.
A first general restructuration of the doc according to the pattern [tour|tutorial|reference].
In the reference part, objects are documented per topic.
In each topic, [definition|c++|python|hdf5] (not yet implemented)
2014-10-18 12:21:08 +01:00

21 lines
738 B
C++

#include <triqs/arrays/array.hpp>
#include <triqs/arrays/h5/simple_read_write.hpp>
namespace tqa=triqs::arrays; namespace h5=tqa::h5;
int main() {
tqa::array<long,2> A(2,2),B; A() = 3; // declare some array and init it
h5::H5File file("ess.h5",H5F_ACC_TRUNC); // open the file ess.h5
h5::write(file,"A",A); // write A in the file as 'A'
file.createGroup("G"); // create a subgroup G (Cf hdf5 doc, C++ API)
h5::write(file,"G/A",A); // write A as G/A
h5::Group G = file.openGroup("G"); // another way to do it : open the group and write G/A2
h5::write(G, "A2",A);
h5::read (file, "A",B); // Read from the file. NB : B is automatically resized
}