Read 1D dataset into a 2D array

Hi All,

I am trying to convert a simple fortran read to a HDF read.
The fortran code is: read(17) amp(1:i1reach,k1)

I assume this means read the contents of unit 17 into the array 'amp', through
rows '1- i1reach' and column no. 'k1'(Please correct me if I am wrong, since I
am new to Fortran as well). But the thing is the contents in unit 17 are a 1D
array and it being read into a 2D array 'amp'

Now I have the contents of the file 17 in a HDF dataset as well in a 1D array,
from which I am trying to read the contents and store in the array 'amp' that is
2D. This is what I am doing:

C Open file containing dataset
      CALL h5fopen_f (filename,H5F_ACC_RDWR_F,file_id,error)

C Open Dataset containing the contents of file 17
      CALL h5dopen_f(file_id,dsetname,dset_id, error)

C Select a hyperslab.

      CALL h5dget_space_f(dset_id, filespace, error)
      CALL h5sget_simple_extent_dims_f(filespace,
     & dimsw, maxdimsw, error)

      offset(1) = 0
      dims(1) = i1reach

C Select the 1D array of length 'i1reach'

      CALL h5sselect_hyperslab_f(filespace,
     & H5S_SELECT_SET_F,offset,dims,error)

C create memory dataspace(2D) corresponding to array 'amp'.
C Note: dims of amp are stored in dims_mem

      CALL h5screate_simple_f(2,dims_mem,memspace,error)

C select memory hyperslab from memspace, through rows '1-i1reach'
C and column k1

      offset_out(1) = 0
      offset_out(2) = k1

      count_out(1) = i1reach
      count_out(2) = 1
      CALL h5sselect_hyperslab_f(memspace, H5S_SELECT_SET_F,
     & offset_out, count_out, error)

      CALL h5dread_f(dset_id,H5T_NATIVE_REAL,amp,
     & dims_mem,error,memspace,filespace)

But I am getting an error in Hdfread operation. It says that "selection+offset
not within extent". Can anyone tell me where I am going wrong, since I can't
spot where is the discrepancy.

Thanks a lot.



This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to
To unsubscribe, send a message to