Skip to content
Snippets Groups Projects
Commit baa811c8 authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

Merge branch 'feature/hdf5-write-vector' into develop

parents 8aa7f4c3 24993778
No related branches found
No related tags found
No related merge requests found
Pipeline #94846 failed
......@@ -373,6 +373,41 @@ int hdf5_tools::write_particle_ID_pairs_with_single_rank(
return EXIT_SUCCESS;
}
template <class real_number>
int hdf5_tools::write_vector_with_single_rank(
const std::vector<real_number> v,
const hid_t group,
const std::string dset_name)
{
TIMEZONE("hdf5_tools::write_vector");
// file space creation
hid_t fspace;
hsize_t dim[1];
dim[0] = v.size();
fspace = H5Screate_simple(1, dim, NULL);
// create dataset
hsize_t dset_id = H5Dcreate(
group,
dset_name.c_str(),
hdf5_tools::hdf5_type_id<real_number>(),
fspace,
H5P_DEFAULT,
H5P_DEFAULT,
H5P_DEFAULT);
// write data
H5Dwrite(
dset_id,
hdf5_tools::hdf5_type_id<real_number>(),
H5S_ALL,
H5S_ALL,
H5P_DEFAULT,
&v.front());
// clean up
H5Dclose(dset_id);
H5Sclose(fspace);
return EXIT_SUCCESS;
}
template
std::vector<int> hdf5_tools::read_vector<int>(
const hid_t,
......@@ -427,3 +462,9 @@ int hdf5_tools::write_particle_ID_pairs_with_single_rank(
const hid_t group,
const std::string dset_name);
template
int hdf5_tools::write_vector_with_single_rank(
const std::vector<double> v,
const hid_t group,
const std::string dset_name);
......@@ -99,6 +99,12 @@ namespace hdf5_tools
const std::vector<partsize_t> v,
const hid_t group,
const std::string dset_name);
template <class real_number>
int write_vector_with_single_rank(
const std::vector<real_number> v,
const hid_t group,
const std::string dset_name);
}
#endif//HDF5_TOOLS_HPP
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment