Reading string array


#1

I’m trying to read an array of strings from an HDF5 file. Basically my issue is that I don’t know what to use for the memspace argument to h5dread_f. h5dump gives the following:
DATASET “elem_name” {
DATATYPE H5T_STRING {
STRSIZE 2;
STRPAD H5T_STR_NULLPAD;
CSET H5T_CSET_ASCII;
CTYPE H5T_C_S1;
}
DATASPACE SIMPLE { ( 5 ) / ( 5 ) }
DATA {
}
I tried H5T_STRING, but that didn’t work. Neither did H5T_STR_NULLPAD. I was able to read the data by using H5T_FORTRAN_S1, but I got incorrect answers.
Maybe I have to define a compound data type?

Jon


#2

Answer to my own question:
Yes I needed to create a datatype via:
CALL H5Tcopy_f(H5T_FORTRAN_S1, dtype, error)
CALL H5Tset_size_f(dtype, sdim, error)
and then use the dtype as the memtype argument to h5dread_f

Jon