Commit 1861f3b1 authored by Lukas Riedel's avatar Lukas Riedel 📝

Fix bug in H5File

Already opened groups were not closed when calling 'open_group'
again.
parent 568a1a24
......@@ -30,7 +30,9 @@ public:
* \param verbose Verbosity of the output
*/
explicit H5File(const std::string& file_path, const int verbose):
_verbose(verbose)
_verbose(verbose),
_file_id(-1),
_group_id(-1)
{
// set up property list for collective I/O
hid_t h5_plist_id = H5Pcreate(H5P_FILE_ACCESS);
......@@ -72,7 +74,13 @@ public:
*/
void open_group(const std::string& group_path="./")
{
// open the group
// close the group if we already opened it
if (_group_id >= 0) {
herr_t status = H5Gclose(_group_id);
assert(status > -1);
}
// open the new group
_group_id = H5Gopen(_file_id, group_path.c_str(), H5P_DEFAULT);
if (_group_id < 0) {
throw std::runtime_error("Cannot open H5 group " + group_path);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment