In order to streamline data exchange between my fortran90 programs and a.o. matlab I decided to use hdf5 as the designated file format.
Everything works so far, except for the following: When I try to read a string in fortran from an hdf5 file, only the first character is read.
I tried a lot and I am really stuck.
A snippet from my code:
filename = "foo.h5"
dsetname = "teststring"
stroutp = "abcdefghi"
dimstr = (/1/)
CALL h5fopen_f(filename, H5F_ACC_RDONLY_F, file, hdferr)
CALL h5dopen_f (file, dsetname, dset, hdferr)
CALL h5dget_create_plist_f(dset, dcpl, hdferr)
CALL h5pget_layout_f(dcpl, layout, hdferr)
CALL h5dread_f(dset, H5T_STRING_F, stroutp, dimreadtekst, hdferr)
CALL h5pclose_f(dcpl , hdferr)
CALL h5dclose_f(dset , hdferr)
CALL h5fclose_f(file , hdferr)
If the variable "teststring" contained "This is a text", stroutp will contain "Tbcdefghi"
HDFView states the properties as having one dimension of length 1, and a string of length 14
Writing strings, and both writing and reading arrays of integers and double precision floats works fine.
I use the 64 bits intel compiler under both Redhat and Ubuntu linux 10.4
What am I doing wrong?
Many thanks in advance and best regards,
The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.