16 #include "mpi3/communicator.hpp" 27 #if defined(ENABLE_PHDF5) 55 lcpl_id = H5Pcreate(H5P_LINK_CREATE);
56 H5Pset_create_intermediate_group(
lcpl_id,
true);
65 lcpl_id = H5Pcreate(H5P_LINK_CREATE);
66 H5Pset_create_intermediate_group(
lcpl_id,
true);
69 bool use_phdf5 =
false;
70 #if defined(ENABLE_PHDF5) 74 MPI_Info info = MPI_INFO_NULL;
76 H5Pset_all_coll_metadata_ops(
access_id,
true);
77 H5Pset_coll_metadata_write(
access_id,
true);
81 H5Pset_dxpl_mpio(
xfer_plist, H5FD_MPIO_COLLECTIVE);
87 if (request_pio && !use_phdf5)
104 lcpl_id = H5Pcreate(H5P_LINK_CREATE);
105 H5Pset_create_intermediate_group(
lcpl_id,
true);
108 bool use_phdf5 =
false;
111 #if defined(ENABLE_PHDF5) 113 MPI_Info info = MPI_INFO_NULL;
115 H5Pset_all_coll_metadata_ops(
access_id,
true);
116 H5Pset_coll_metadata_write(
access_id,
true);
120 H5Pset_dxpl_mpio(
xfer_plist, H5FD_MPIO_COLLECTIVE);
128 if (request_pio && !use_phdf5)
149 throw std::runtime_error(
"Only create file in parallel or by master but not every rank!");
172 p = (aname[0] ==
'/') ?
file_id : p;
174 if (H5Lexists(p, aname.c_str(), H5P_DEFAULT) > 0)
176 #if H5_VERSION_GE(1, 12, 0) 181 oinfo.type = H5O_TYPE_UNKNOWN;
182 #if H5_VERSION_GE(1, 12, 0) 183 H5Oget_info_by_name3(p, aname.c_str(), &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
185 H5Oget_info_by_name(p, aname.c_str(), &oinfo, H5P_DEFAULT);
188 if (oinfo.type != H5O_TYPE_GROUP)
205 throw std::runtime_error(
"Failed to open group \"" + gname +
210 #if H5_VERSION_GE(1, 12, 0) 215 oinfo.type = H5O_TYPE_UNKNOWN;
216 if (H5Lexists(p, gname.c_str(), H5P_DEFAULT) > 0)
218 #if H5_VERSION_GE(1, 12, 0) 219 H5Oget_info_by_name3(p, gname.c_str(), &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
221 H5Oget_info_by_name(p, gname.c_str(), &oinfo, H5P_DEFAULT);
225 if ((oinfo.type != H5O_TYPE_GROUP) && createit)
227 g = H5Gcreate2(p, gname.c_str(),
lcpl_id, H5P_DEFAULT, H5P_DEFAULT);
231 g = H5Gopen2(p, gname.c_str(), H5P_DEFAULT);
239 if (!createit && g < 0)
240 throw std::runtime_error(
"Group \"" + gname +
"\" not found in file " +
possible_filename_ +
248 std::string group_path;
bool open(const std::filesystem::path &fname, unsigned flags=H5F_ACC_RDWR)
open a file
const std::string & string() const
Return std::string for use with HDF5.
helper functions for EinsplineSetBuilder
int rank() const
return the rank
hid_t lcpl_id
Link creation property list identifier.
void close()
close all the open groups and file
std::stack< hid_t > group_id
FILO to handle H5Group.
std::string possible_filename_
Name of file that hdf_archive thinks is open.
std::bitset< 4 > Mode
bitset of the io mode Mode[IS_PARALLEL] : true, if parallel Mode[IS_MASTER] : true, if the node is master Mode[NOIO] : true, if I/O is not performed
int size() const
return the number of tasks
Wrapping information on parallelism.
class suppressing warnings from the HDF5 library
hdf_error_suppression hide_hdf_errors
Suppress HDF5 warning and error messages.
static const hid_t is_closed
void push(const std::string &gname, bool createit=true)
push a group to the group stack
bool create(const std::filesystem::path &fname, unsigned flags=H5F_ACC_TRUNC)
create a file
std::string group_path_as_string() const
Return a string representation of the current group stack.
hid_t xfer_plist
transfer property
bool is_group(const std::string &aname)
check if aname is a group
mpi_comm_type getMPI() const
return the Communicator ID (typically MPI_WORLD_COMM)
std::vector< std::string > group_names
Track group names corresponding to group_id.