Skip to content

Commit

Permalink
Suppress HDF5 stdout error logging to stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeilstenedmands committed Jan 31, 2025
1 parent cc5cff9 commit f044e29
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/dx2/h5/h5write.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ hid_t traverse_or_create_groups(hid_t parent, const std::string &path) {
(pos == std::string::npos) ? "" : cleaned_path.substr(pos + 1);

// Attempt to open the group. If it does not exist, create it.
H5Eset_auto2(H5E_DEFAULT, NULL, NULL); // Suppress errors to stdout when
// trying to open a file/group that may not exist.
hid_t next_group = H5Gopen(parent, group_name.c_str(), H5P_DEFAULT);
if (next_group < 0) {
next_group = H5Gcreate(parent, group_name.c_str(), H5P_DEFAULT, H5P_DEFAULT,
Expand Down Expand Up @@ -172,6 +174,8 @@ void write_data_to_h5_file(const std::string &filename,
const std::string &dataset_path,
const Container &data) {
// Open or create the HDF5 file
H5Eset_auto2(H5E_DEFAULT, NULL, NULL); // Suppress errors to stdout when
// trying to open a file/group that may not exist.
hid_t file = H5Fopen(filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
if (file < 0) {
file = H5Fcreate(filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
Expand Down

0 comments on commit f044e29

Please sign in to comment.