Skip to content

Problem reading string scalar value from hierarchy dataset #26

@gekowa

Description

@gekowa

I have an HDF5 file that structured like below:

sample.h5
|-- 1
    |-- a
|-- 2
    |-- a
|-- 3
    |-- a
...

where "/1/a", "/2/a", "/3/a" and so on contain string scalar values, like "MA", "blk"... no more than 3 chars.

When reading these values with h5fortran, it crashes at 3rd or 4th read. Here is the code:

program test_my
    use h5fortran, only: hdf5_file, h5write, h5read

    implicit none

    type(hdf5_file) :: rstFile
    character(len=5) :: buffer1

    call rstFile % open("/root/Desktop/h5fortran_example.h5", action='r')

    call rstFile % read('/1/a', buffer1)
    print *,buffer1
    call rstFile % read('/2/a', buffer1)
    call rstFile % read('/3/a', buffer1)
    call rstFile % read('/4/a', buffer1)    ! throws exception
    call rstFile % read('/5/a', buffer1)
    call rstFile % read('/6/a', buffer1)
end program

I'm using Intel oneAPI Fortran compiler version 2021.5, Ubuntu 20.04.

Attached the file I created for reproducing the issue.
h5fortran_example.zip

And, here is the call stack snapshot.
image

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions