Reading character string attribute in Fortran

I am newish to HDF5 and am trying to read a group attribute ("Info") that is
a character string (a description of the dataset in the group). I tried the
following and got all blanks. I was wondering if there was an example
somewhere or someone could push me in the right direction.

integer(hid_t) :: stringType !create a string memory type from H5T_C_S1

call H5Tcopy_f (H5T_C_S1, stringType, error)

call H5Gopen_f (id, trim(adjustl(subGroupName)), subgroup_id, error)

call H5Aopen_name_f (subgroup_id, 'Info', attr_id, error )

call H5Aread_f (attr_id, stringType, info, attr_dims, error) !info is a
character(len=500) string

print*,' info=',trim(adjustl(info)) ! comes out blank

(I left out opens up until this subgroup and error checking for clarity
here, all ids are integer(hid_t), attr_dims is integer (hsize_t),
dimension(1))

Thank you!

Naomi Greenberg

Principal Member of the Research Staff

Electromagnetics Lab

<http://www.riversideresearch.org/&gt; www.riversideresearch.org

T: 212.502.1718 | F: 212.502.1729 |

line

Riverside Research | 156 William Street | New York, N.Y. 10038

<http://www.riversideresearch.org/rss.xml&gt;
cid:image010.png@01D05BEF.9ED90B00 <https://twitter.com/RiversideRsch&gt;
cid:image011.png@01D05BEF.9ED90B00
<Facebook;
cid:image012.png@01D05BEF.9ED90B00
<https://www.linkedin.com/company/riverside-research&gt; linkedin-new

This e-mail message, including any attachments, is for the sole use of the
intended recipient(s) and may contain proprietary, confidential or
privileged information or otherwise be protected by law. Any unauthorized
review, use, disclosure or distribution is prohibited. If you are not the
intended recipient, please notify the sender and destroy all copies and the
original message.

Hi,

Take a look at the examples in the “Datatypes” section at:

https://support.hdfgroup.org/HDF5/examples/api-fortran.html

namely (for fixed sized string), h5ex_t_stringCatt_F03.f90.

Scot

···

On May 16, 2017, at 9:55 AM, Greenberg, Naomi <ngreenberg@RiversideResearch.org> wrote:

I am newish to HDF5 and am trying to read a group attribute (“Info”) that is a character string (a description of the dataset in the group). I tried the following and got all blanks. I was wondering if there was an example somewhere or someone could push me in the right direction.

integer(hid_t) :: stringType !create a string memory type from H5T_C_S1
call H5Tcopy_f (H5T_C_S1, stringType, error)
call H5Gopen_f (id, trim(adjustl(subGroupName)), subgroup_id, error)
call H5Aopen_name_f (subgroup_id, 'Info', attr_id, error )
call H5Aread_f (attr_id, stringType, info, attr_dims, error) !info is a character(len=500) string
print*,' info=',trim(adjustl(info)) ! comes out blank

(I left out opens up until this subgroup and error checking for clarity here, all ids are integer(hid_t), attr_dims is integer (hsize_t), dimension(1))
Thank you!

Naomi Greenberg
Principal Member of the Research Staff
Electromagnetics Lab
www.riversideresearch.org
T: 212.502.1718 | F: 212.502.1729 |
<image001.jpg>
Riverside Research | 156 William Street | New York, N.Y. 10038

<image002.png><image003.png><image004.png><image005.png>
This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain proprietary, confidential or privileged information or otherwise be protected by law. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please notify the sender and destroy all copies and the original message.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5