3
0
mirror of https://github.com/triqs/dft_tools synced 2024-11-01 19:53:45 +01:00
dft_tools/test/triqs/gfs/array_gf.cpp
Olivier Parcollet 4af1afbdaf hdf5 : clean up
- For users : only change is :
   H5::H5File in apps. to be replaced by triqs::h5::file, same API.

- using only the C API because :
   - it is cleaner, better documented, more examples.
   - it is the native hdf5 interface.
   - simplify the installation e.g. on mac. Indeed, hdf5 is
     usually installed without C++ interface, which is optional.
     E.g. EPD et al., brew by default.
     Also the infamous mpi+ hdf5_cpp bug, for which we have no clean solution.

- clean the notion of parent of a group. Not needed, better iterate function in C LT API.
- modified doc : no need for C++ bindings any more.
- modified cmake to avoid requiring CPP bindings.
2014-06-22 13:57:47 +02:00

42 lines
986 B
C++

#include <triqs/gfs.hpp>
#define TEST(X) std::cout << BOOST_PP_STRINGIZE((X)) << " ---> " << (X) << std::endl << std::endl;
namespace h5 = triqs::h5;
using namespace triqs::gfs;
using namespace triqs::arrays;
int main(int argc, char* argv[]) {
try {
triqs::clef::placeholder<0> w_;
auto agf = array<gf<imfreq>, 2>{2, 3};
auto bgf = array<gf<imfreq>, 2>{2, 3};
agf() = gf<imfreq>{{10.0, Fermion}, {1, 1}};
agf(0, 0)(w_) << 1 / (w_ + 2);
array<double,2> A(2,2); A()=0;A(0,0) = 1.3; A(1,1) = -8.2;
array<array<double,2>, 1> aa(2), bb;
aa(0) = A;
aa(1) = 2 * A;
bb = aa;
{
h5::file file("ess_array_gf.h5", H5F_ACC_TRUNC);
h5_write(file, "Agf", agf);
h5_write(file, "aa", aa);
}
{
h5::file file("ess_array_gf.h5", H5F_ACC_RDONLY);
h5_read(file, "Agf", bgf);
h5_read(file, "aa", bb);
}
{
h5::file file("ess_array_gf2.h5", H5F_ACC_TRUNC);
h5_write(file, "Agf", bgf);
h5_write(file, "aa", bb);
}
}
TRIQS_CATCH_AND_ABORT;
}