Help reading am attribute from a file in Fortran

Hi,

I want to read an attribute from an HDF5 file in Fortran. I have the following code:

      SUBROUTINE HDF5_RES_READ_ATTR(filename,attr,attr_name)
c      
      USE HDF5 ! This module contains all necessary modules

      IMPLICIT NONE
c
c... Input/Output arrays
      REAL    :: attr
      CHARACTER*(*) filename,attr_name
c
c... Local arrays
      INTEGER(HID_T) :: file_id       ! File identifier
      INTEGER(HID_T) :: group_id     ! Attribute space identifier
      INTEGER(HID_T) :: aspace_id      ! Memory space identifier
      INTEGER(HID_T) :: attr_id     ! Attribute space identifier

      INTEGER*4     ::   arank = 1             ! Attribute rank
      INTEGER(HSIZE_T), DIMENSION(1) :: adim=1 ! Attribute dimensions
      INTEGER     ::   error

      ! Open the HDF5 interface
      CALL h5open_f(error)

      ! Open the HDF5 file
      CALL H5Fopen_f(trim(filename), H5F_ACC_RDONLY_F, file_id, error)

      ! Open the group containing the attribute
      call h5gopen_f(file_id, '/', group_id, error)

      ! Open the attribute
      CALL h5aopen_f(group_id, trim(attr_name), attr_id, error)

      CALL h5screate_simple_f(arank, adim, aspace_id, error)
      
      ! Read the attrubute
      CALL h5aread_f(attr_id, aspace_id, attr, error)

      ! Close the attribute
      call H5Aclose_f(attr_id, error)

      call h5sclose_f(aspace_id, error)
      
      ! Close the group
      call H5Gclose_f(group_id, error)
      ! Close the file.
      CALL h5fclose_f(file_id, error)

      ! Close FORTRAN interface.
      CALL h5close_f(error)
      


      END SUBROUTINE

During compilation I get the following error:

 3767 |       CALL h5aread_f(attr_id, aspace_id, attr, error)
      |                                                     1
Error: There is no specific subroutine for the generic 'h5aread_f' at (1)

It seems that the subroutine h5aread_f is not recognized. What I am doing wrong?

Here is general advice for this “no specific subroutine” error. Check each argument carefully for exact match of type and dimensionality, between your call and the documented calling signature. With generics, there is sometimes more than one possible match for each argument. Also check for correct order of arguments.

Thank you for the reply. I checked each argument and I was able to resolve it. The arguments were not correct. The correct way is

call h5aread_f(attr_id, H5T_NATIVE_INTEGER, n, adim, error)

where adim(1)=1, and n is the variable that the attribute is read into.