I am having trouble reading from a dataset into an allocatable array in
fortran. Here is an excerpt from my code:

SUBROUTINE read_r1(this,dsetname,data)
      CLASS(HDF5FileType),INTENT(INOUT) :: this
      CHARACTER(LEN=*),INTENT(IN) :: dsetname
      DOUBLE PRECISION,ALLOCATABLE,INTENT(INOUT) :: data(:)
      CHARACTER(LEN=MAX_PATH_LENGTH) :: path

      INTEGER(HSIZE_T),DIMENSION(1) :: dims,maxdims,len1
      INTEGER(HID_T),PARAMETER :: rank=1

      INTEGER(HID_T) :: error,mem
      INTEGER(HID_T) :: dspace_id,dset_id
      ! Get dataset dimensions for allocation
      CALL h5dget_space_f(dset_id,dspace_id,error)
      CALL h5sget_simple_extent_dims_f(dspace_id,dims,maxdims,error)
      ! Allocate to size
      ALLOCATE(data(dims(1)))


      ! Read the dataset
      mem=H5T_NATIVE_DOUBLE
      CALL h5dread_vl_f(dset_id,mem,data,dims,len1,error)
      IF(error /= 0)THEN
        CALL this%e%raiseError(myName//": Failed to read data from
dataset.")
      ENDIF
ENDSUBROUTINE

Compiling this gives me:


/home/youngmit/codes/mpact/MPACT_libs/Utils/src/FileType_HDF5.f90:480.57:

      CALL h5dread_vl_f(dset_id,mem,data,dims,len1,error)
                                                         1
Error: There is no specific subroutine for the generic 'h5dread_vl_f' at (1)

I havent found any examples of people using allocatable arrays, so is it
even possible? How else could I approach extracting variable-sized data in
fortran?

Thanks,

Mitch
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Reply via email to