Hi,
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:
http://www.hdfgroup.org/HDF5/doc/UG/12_Dataspaces.html
"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:
http://www.hdfgroup.org/ftp/HDF5/examples/examples-by-api/hdf5-examples/1_8/C/H5D/h5ex_d_rdwr.c
I modified it to include the following lines (fully modified program is
attached).
hid_t memspace = H5Screate_simple(2, rdims, NULL);
hid_t filespace = H5Dget_space(dset);
H5Dread(dset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT,
rdata[0]);
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.
jim
h5_ex_d_rdwr.c (3.18 KB)