Hello,
I have a compound dataset where h5dump generates the following information:
DATASET "SUBCASE" {
DATATYPE H5T_COMPOUND { ... H5T_STRING {
STRSIZE 128;
STRPAD H5T_STR_NULLTERM;
CSET H5T_CSET_ASCII;
CTYPE H5T_C_S1;
} "TITLE";
The other entries in this COMPOUND dataset consists of arrays of integers and floats; I have no problem reading any of them.
But I am trying to read ONLY the "TITLE" entry. So I do the following:
hid_t memtype;hid_t native;
memtype = H5Tcreate (h5T_COMPOUND,128);native = H5Tcopy (H5T_C_S1);H5Tinsert (memtype,"TITLE",128,native);
My dataset is opened under hid_t did. I then do
hid_t space;char data[200];
space = H5Dget_space (did);H5Dread (did,memtype,H5S_ALL,H5S_ALL,H5P_DEFAULT,data);
The problem is that "data" comes back with all blanks. But h5dump and HDFView show that the title has a real, non-blank string there.
This is my first time reading H5T_STRINGs. Clearly, I'm doing something wrong. Can somebody point me towards the solution to this so that "data" will contain the string I'm looking for?
Thanks.
-Arthur
Arthur, how about this?
hid_t memtype;
hid_t native;
memtype = H5Tcreate (H5T_COMPOUND,128);
native = H5Tcopy (H5T_C_S1);
H5Tset_size(native, 128);
H5Tinsert(memtype,"TITLE",0,native);
You have to make sure that your string type has 128 bytes.
Also, the third parameter in H5Tinsert is the field offset not its size.
Does that work for you?
G.
ยทยทยท
From: Hdf-forum [mailto:hdf-forum-bounces@lists.hdfgroup.org] On Behalf Of muller@vki.com
Sent: Monday, November 28, 2016 2:06 PM
To: hdf-forum@lists.hdfgroup.org
Subject: [Hdf-forum] Reading only H5T_STRING entry from COMPOUND dataset
Hello,
I have a compound dataset where h5dump generates the following information:
DATASET "SUBCASE" \{
DATATYPE H5T\_COMPOUND \{
\.\.\.
H5T\_STRING \{
STRSIZE 128;
STRPAD H5T\_STR\_NULLTERM;
CSET H5T\_CSET\_ASCII;
CTYPE H5T\_C\_S1;
\} "TITLE";
The other entries in this COMPOUND dataset consists of arrays of integers and floats; I have no problem reading any of them.
But I am trying to read ONLY the "TITLE" entry. So I do the following:
hid_t memtype;
hid_t native;
memtype = H5Tcreate (h5T_COMPOUND,128);
native = H5Tcopy (H5T_C_S1);
H5Tinsert (memtype,"TITLE",128,native);
My dataset is opened under hid_t did. I then do
hid_t space;
char data[200];
space = H5Dget_space (did);
H5Dread (did,memtype,H5S_ALL,H5S_ALL,H5P_DEFAULT,data);
The problem is that "data" comes back with all blanks. But h5dump and HDFView show that the title has a real, non-blank string there.
This is my first time reading H5T_STRINGs. Clearly, I'm doing something wrong. Can somebody point me towards the solution to this so that "data" will contain the string I'm looking for?
Thanks.
-Arthur