I am clearly misunderstanding something about reading datasets and
converting their write order in a buffer using dataspaces. I am
attempting to convert between a row-major memory layout to a column
major memory layout and am incapable. In the documentation here:
"Figure 4a shows a simple example of a read operation in which the data
is stored as a 3 by 4 array in the file (Figure 4b), but the program
wants it to be a 4 by 3 array in memory. This is accomplished by setting
the memory dataspace to describe the desired memory layout, as in Figure
4c. The HDF5 Library will transform the data to the correct arrangement
during the read operation"
As an example, I took the program: h5ex_d_rdwr.c from:
I modified it to include the following lines (fully modified program is
hid_t memspace = H5Screate_simple(2, rdims, NULL);
hid_t filespace = H5Dget_space(dset);
H5Dread(dset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT,
Here rdims is simply the original dims in reverse. When I do this,
nothing changes in the way that the matrix is printed. I feel I must be
missing something, but I can't find any examples doing this
transposition. I am using hdf 1.8.4 on linux.
Full program attached, Thanks again.
h5_ex_d_rdwr.c (3.18 KB)