Reading H5T_IEEE_F64LE/H5T_NATIVE_FLOAT


#1

Hello All,

I am working with the C++ HDF5 API, and I am attempting to read in some simulation data.

I am able to open my file and open the appropriate data-set, but my problem occurs with the datatype being used.

I can verify that I am opening the correct data-set, but trying to use H5T_IEEE_F64LE gives me a segfault. Using NATIVE_FLOAT I am able to print out my data, but it is incorrect as this was not the format it was stored in.

dataset.read(rdata, H5T_IEEE_F64LE); --> Does not load data segfault
dataset.read(rdata, H5T_NATIVE_FLOAT); --> Works, but data is not correct

Any help in resolving this is greatly appreciated!

Info: using h5++, hdf5 1.12


#2

In dataset.read, the DataType argument specifies the data type of the memory buffer, not the data type as stored in the file.

My guess is that you want to define rdata as double, not float, to avoid precision loss on an unwanted 64 to 32 bit automatic conversion. In that case, specify the DataType argument as H5T_NATIVE_DOUBLE, to match rdata.


#3

Thank you for the answer! Changing rdata to double fixed the bit conversion problems also.