Skip to content

Commit 6d5b3bf

Browse files
committed
dito for hdf5
1 parent a3f3ee2 commit 6d5b3bf

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

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
@@ -3263,12 +3263,10 @@ stepBasedSingleIteration( std::string const & file )
32633263

32643264
TEST_CASE( "stepBasedSingleIteration", "[serial][adios2]" )
32653265
{
3266-
stepBasedSingleIteration("../samples/stepBasedSingleIteration.bp");
3267-
stepBasedSingleIteration("../samples/stepBasedSingleIteration.json");
3268-
// for( auto const & t : getFileExtensions() )
3269-
// {
3270-
// stepBasedSingleIteration( "../samples/stepBasedSingleIteration." + t );
3271-
// }
3266+
for( auto const & t : getFileExtensions() )
3267+
{
3268+
stepBasedSingleIteration( "../samples/stepBasedSingleIteration." + t );
3269+
}
32723270
}
32733271

32743272
#if openPMD_HAVE_ADIOS2

0 commit comments

Comments
 (0)