Skip to content

Commit 201c9db

Browse files
committed
dito for hdf5
1 parent 33e7efb commit 201c9db

3 files changed

Lines changed: 19 additions & 16 deletions

File tree

include/openPMD/IO/AbstractIOHandlerImpl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ class AbstractIOHandlerImpl
238238
*
239239
* The operation should overwrite existing file positions, even when the Writable was already marked written.
240240
* The path parameters.path may contain multiple levels (e.g. first/second/third/). This path should be relative (i.e. it should not start with a slash "/").
241+
* The number of levels may be zero, i.e. parameters.path may be an empty string.
241242
* The Writables file position should correspond to the complete opened path (i.e. first/second/third/ should be assigned to the Writables file position).
242243
* The Writable should be marked written when the operation completes successfully.
243244
*/

src/IO/HDF5/HDF5IOHandler.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -518,19 +518,23 @@ HDF5IOHandlerImpl::openPath(
518518

519519
/* Sanitize path */
520520
std::string path = parameters.path;
521-
if( auxiliary::starts_with(path, '/') )
522-
path = auxiliary::replace_first(path, "/", "");
523-
if( !auxiliary::ends_with(path, '/') )
524-
path += '/';
521+
if( !path.empty() )
522+
{
523+
if( auxiliary::starts_with(path, '/') )
524+
path = auxiliary::replace_first(path, "/", "");
525+
if( !auxiliary::ends_with(path, '/') )
526+
path += '/';
527+
path_id = H5Gopen(node_id,
528+
path.c_str(),
529+
H5P_DEFAULT);
530+
VERIFY(path_id >= 0, "[HDF5] Internal error: Failed to open HDF5 group during path opening");
525531

526-
path_id = H5Gopen(node_id,
527-
path.c_str(),
528-
H5P_DEFAULT);
529-
VERIFY(path_id >= 0, "[HDF5] Internal error: Failed to open HDF5 group during path opening");
532+
herr_t status;
533+
status = H5Gclose(path_id);
534+
VERIFY(status == 0, "[HDF5] Internal error: Failed to close HDF5 group during path opening");
535+
}
530536

531537
herr_t status;
532-
status = H5Gclose(path_id);
533-
VERIFY(status == 0, "[HDF5] Internal error: Failed to close HDF5 group during path opening");
534538
status = H5Gclose(node_id);
535539
VERIFY(status == 0, "[HDF5] Internal error: Failed to close HDF5 group during path opening");
536540

test/SerialIOTest.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3188,12 +3188,10 @@ stepBasedSingleIteration( std::string const & file )
31883188

31893189
TEST_CASE( "stepBasedSingleIteration", "[serial][adios2]" )
31903190
{
3191-
stepBasedSingleIteration("../samples/stepBasedSingleIteration.bp");
3192-
stepBasedSingleIteration("../samples/stepBasedSingleIteration.json");
3193-
// for( auto const & t : getFileExtensions() )
3194-
// {
3195-
// stepBasedSingleIteration( "../samples/stepBasedSingleIteration." + t );
3196-
// }
3191+
for( auto const & t : getFileExtensions() )
3192+
{
3193+
stepBasedSingleIteration( "../samples/stepBasedSingleIteration." + t );
3194+
}
31973195
}
31983196

31993197
#if openPMD_HAVE_ADIOS2

0 commit comments

Comments
 (0)