Reputation: 1695
I currently try to read some data from a hdf5 dataset in C which looks like this.
dataset = H5Dopen(ic_group, 'vx', H5P_DEFAULT);
status = H5Dread(dataset, H5T_NATIVE_FLOAT, memspace,H5S_ALL,
H5P_DEFAULT, vx_ptr);
status = H5Dclose(dataset);
Here ic_group
is a group containing the dataset vx
, memspace is a hyperslab in memory and vx_ptr the data in memory. This approach works good, however since I want to work with different datatypes later, I want to read the type directly from the dataset:
hid_t datatype;
datatype = H5Dget_type(dataset);
status = H5Dread(dataset, datatype, memspace,H5S_ALL,
H5P_DEFAULT, vx_ptr);
Unfortunately this approach leads to a segfault in the function H5Dread
.
Maybe I am missing something? Thank you for any suggestions.
EDIT: I don't know if this is usefull but the backtrace of gdb goes down to
0x00007ffff5adbd1e in __memcpy_ssse3_back () from /lib64/libc.so.6
.
Upvotes: 2
Views: 2448
Reputation: 5471
You can check that the datatype returned from H5Dget_type(dataset)
is what you expect by using H5Tequal(datatype, H5T_<type>)
. It should match both the datatype used to write the dataset and also the equivalent type of vx_ptr
(this is probably what's actually caused the segfault).
Also, datatype
needs to be closed with H5Tclose(datatype)
.
Upvotes: 1