Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDF5 Archive support #428

Open
alvarovm opened this issue Jun 7, 2022 · 2 comments
Open

HDF5 Archive support #428

alvarovm opened this issue Jun 7, 2022 · 2 comments

Comments

@alvarovm
Copy link
Contributor

alvarovm commented Jun 7, 2022

Hello,

I wrote subroutines to support HDF5 files, see:
https://github.com/alvarovm/madness/blob/h5files/src/madness/world/h5_archive.h

For now, I am just saving one dataset per file. See example below.

It would be great if you could give feedback. I could clean up and send a PR to the main branch if this is useful.

Thanks

#include <madness/world/info.h>
#include <cstdio>
#include <vector>
#include <iostream>

using namespace madness;

#include <madness/world/h5_archive.h>
using madness::archive::H5OutputArchive;
using madness::archive::H5InputArchive;
template <class OutputArchive>
void test_out(const OutputArchive& oar) {
    constexpr const int n = 3;
    oar & n;
}
int main(int argc, char** argv) {

	std::cout << "git revision " << info::git_commit() << std::endl;
	std::string name = "dsetmad.h5";
	std::vector<int> v = { 7, 5, 16, 8 ,9  };
	std::vector<int> vi = { 0, 0, 0, 0 ,0  };



	    // Print out the vector
        std::cout << "v = { ";
        for (int n : v) {
           std::cout << n << ", ";
        }
        std::cout << "}; \n";
        std::cout << "v is size "<< v.size() <<  std::endl;
        


	{
#Write H5 FILE
	const char *f = "test.h5";
        std::cout << std::endl << "testing h5 archive" << std::endl;
        H5OutputArchive oar(f);
	oar & v;

        oar.flush();
        oar.close();

# Read H5 FILE
        H5InputArchive iar(f);
	iar & vi;
        iar.close();

	    // Print out the vector
        std::cout << "vi = { ";
        for (int n : vi) {
           std::cout << n << ", ";
        }
        std::cout << "}; \n";

	}
	
	return 0;
}
@robertjharrison
Copy link
Contributor

Alvaro ... sorry ... did not see this until now. Is this the same as you just merged into the main tree?

@alvarovm
Copy link
Contributor Author

alvarovm commented Sep 6, 2022

Yes. It is the same, just updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants