Skip to content

Commit

Permalink
H5R new APIs and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brtnfld committed Apr 26, 2024
1 parent b54eb81 commit 8ad0330
Show file tree
Hide file tree
Showing 10 changed files with 404 additions and 35 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
## ----------------------------------------------------------------------
## Initialize configure.
##
AC_PREREQ([2.71])
AC_PREREQ([2.69])

## AC_INIT takes the name of the package, the version number, and an
## email address to report bugs. AC_CONFIG_SRCDIR takes a unique file
Expand Down
198 changes: 197 additions & 1 deletion fortran/src/H5Rff.F90
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,49 @@ END FUNCTION H5Rcopy
hdferr = INT(H5Rcopy(src_ref_ptr, dst_ref_ptr))

END SUBROUTINE h5rcopy_f
!>
!! \ingroup FH5R
!!
!! \brief Determines whether two references are equal
!!
!! \param ref1_ptr Pointer to reference to compare, of TYPE(H5R_ref_t)
!! \param ref2_ptr Pointer to reference to compare, of TYPE(H5R_ref_t)
!! \param hdferr \fortran_error
!!
!! See C API: @ref H5Requal()
!!
SUBROUTINE h5requal_f(ref1_ptr, ref2_ptr, equal, hdferr)

IMPLICIT NONE

TYPE(C_PTR) :: ref1_ptr
TYPE(C_PTR) :: ref2_ptr
LOGICAL, INTENT(OUT) :: equal
INTEGER, INTENT(OUT) :: hdferr

INTEGER(C_INT) :: c_equal

INTERFACE
INTEGER(C_INT) FUNCTION H5Requal(ref1_ptr, ref2_ptr) &
BIND(C, NAME='H5Requal')
IMPORT :: C_PTR, C_INT
IMPLICIT NONE
TYPE(C_PTR), VALUE :: ref1_ptr
TYPE(C_PTR), VALUE :: ref2_ptr
END FUNCTION H5Requal
END INTERFACE

c_equal = INT(H5Requal(ref1_ptr, ref2_ptr))

hdferr = 0
equal = .FALSE.
IF(c_equal .EQ. 1)THEN
equal = .TRUE.
ELSE IF(c_equal .LT. 0)THEN
hdferr = -1
ENDIF

END SUBROUTINE h5requal_f

!>
!! \ingroup FH5R
Expand Down Expand Up @@ -1001,10 +1044,63 @@ END SUBROUTINE h5rcreate_region_f
!>
!! \ingroup FH5R
!!
!! \brief Creates an attribute reference.
!!
!! \attention \fortran_approved
!!
!! \param loc_id Location identifier
!! \param name Name of object
!! \param attr_name Name of attribute
!! \param ref_ptr Pointer to reference
!! \param hdferr \fortran_error
!! \param oapl_id Object access property list identifier
!!
!! See C API: @ref H5Rcreate_attr()
!!
SUBROUTINE h5rcreate_attr_f(loc_id, name, attr_name, ref_ptr, hdferr, oapl_id)
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T) , INTENT(IN) :: loc_id
CHARACTER(LEN=*), INTENT(IN) :: name
CHARACTER(LEN=*), INTENT(IN) :: attr_name
TYPE(C_PTR) :: ref_ptr
INTEGER , INTENT(OUT) :: hdferr
INTEGER(HID_T) , INTENT(IN), OPTIONAL :: oapl_id

INTEGER(HID_T) :: oapl_id_default
CHARACTER(LEN=LEN_TRIM(name)+1,KIND=C_CHAR) :: c_name
CHARACTER(LEN=LEN_TRIM(attr_name)+1,KIND=C_CHAR) :: c_attr_name

INTERFACE
INTEGER(C_INT) FUNCTION H5Rcreate_attr(loc_id, c_name, c_attr_name, oapl_id_default, ref_ptr) &
BIND(C, NAME='H5Rcreate_attr')
IMPORT :: C_PTR, C_INT, C_CHAR
IMPORT :: HID_T
IMPLICIT NONE
INTEGER(HID_T), VALUE :: loc_id
CHARACTER(KIND=C_CHAR), DIMENSION(*) :: c_name
CHARACTER(KIND=C_CHAR), DIMENSION(*) :: c_attr_name
INTEGER(HID_T), VALUE :: oapl_id_default
TYPE(C_PTR), VALUE :: ref_ptr
END FUNCTION H5Rcreate_attr
END INTERFACE

c_name = TRIM(name)//C_NULL_CHAR
c_attr_name = TRIM(attr_name)//C_NULL_CHAR

oapl_id_default = H5P_DEFAULT_F
IF(PRESENT(oapl_id)) oapl_id_default = oapl_id

hdferr = INT(H5Rcreate_attr(loc_id, c_name, c_attr_name, oapl_id_default, ref_ptr))

END SUBROUTINE h5rcreate_attr_f
!>
!! \ingroup FH5R
!!
!! \brief Retrieves the object name for a referenced object.
!!
!! \param name Buffer to place the file name of the reference
!! \param ref_ptr Pointer to reference to query
!! \param name Buffer to place the file name of the reference
!! \param hdferr \fortran_error
!! \param rapl_id Reference access property list identifier
!! \param name_len Maximum length of the name to retrieve
Expand Down Expand Up @@ -1054,5 +1150,105 @@ END FUNCTION H5Rget_obj_name
ENDIF

END SUBROUTINE h5rget_obj_name_f
!>
!! \ingroup FH5R
!!
!! \brief Retrieves the attribute name for a referenced object.
!!
!! \param ref_ptr Pointer to reference to query
!! \param name Buffer to place the attribute name of the reference
!! \param hdferr \fortran_error
!! \param name_len Maximum length of the name to retrieve
!!
SUBROUTINE h5rget_attr_name_f(ref_ptr, name, hdferr, name_len)

USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
TYPE(C_PTR) :: ref_ptr
CHARACTER(LEN=*) :: name
INTEGER , INTENT(OUT) :: hdferr
INTEGER(SIZE_T), INTENT(OUT), OPTIONAL :: name_len

CHARACTER(LEN=1,KIND=C_CHAR), DIMENSION(1:LEN(name)+1), TARGET :: c_name
INTEGER(SIZE_T) :: l

INTERFACE
INTEGER FUNCTION H5Rget_attr_name(ref_ptr, name, size_default) &
BIND(C, NAME='H5Rget_attr_name')
IMPORT :: c_char, c_ptr
IMPORT :: HID_T, SIZE_T
IMPLICIT NONE
TYPE(C_PTR), VALUE :: ref_ptr
CHARACTER(KIND=C_CHAR), DIMENSION(*) :: name
INTEGER(SIZE_T), VALUE :: size_default
END FUNCTION H5Rget_attr_name
END INTERFACE

hdferr = 0
IF(PRESENT(name_len))THEN
c_name(1:1)(1:1) = C_NULL_CHAR
name_len = H5Rget_attr_name(ref_ptr, c_name, 1_SIZE_T)
IF(name_len.LT.0_SIZE_T) hdferr = H5I_INVALID_HID_F
ELSE
l = INT(LEN(name)+1,SIZE_T)
IF(H5Rget_attr_name(ref_ptr, c_name, l) .LT. 0_SIZE_T)THEN
hdferr = H5I_INVALID_HID_F
ELSE
CALL HD5c2fstring(name, c_name, LEN(name,KIND=SIZE_T), LEN(name,KIND=SIZE_T)+1_SIZE_T )
ENDIF
ENDIF

END SUBROUTINE h5rget_attr_name_f
!>
!! \ingroup FH5R
!!
!! \brief Retrieves the file name for a referenced object.
!!
!! \param ref_ptr Pointer to reference to query
!! \param name Buffer to place the file name of the reference
!! \param hdferr \fortran_error
!! \param size The size of the name buffer
!!
!! See C API: @ref H5Rget_file_name()
!!
SUBROUTINE h5rget_file_name_f(ref_ptr, name, hdferr, name_len)

USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
TYPE(C_PTR) :: ref_ptr
CHARACTER(LEN=*) :: name
INTEGER , INTENT(OUT) :: hdferr
INTEGER(SIZE_T), INTENT(OUT), OPTIONAL :: name_len

CHARACTER(LEN=1,KIND=C_CHAR), DIMENSION(1:LEN(name)+1), TARGET :: c_name
INTEGER(SIZE_T) :: l

INTERFACE
INTEGER FUNCTION H5Rget_file_name(ref_ptr, name, size_default) &
BIND(C, NAME='H5Rget_file_name')
IMPORT :: c_char, c_ptr
IMPORT :: HID_T, SIZE_T
IMPLICIT NONE
TYPE(C_PTR), VALUE :: ref_ptr
CHARACTER(KIND=C_CHAR), DIMENSION(*) :: name
INTEGER(SIZE_T), VALUE :: size_default
END FUNCTION H5Rget_file_name
END INTERFACE

hdferr = 0
IF(PRESENT(name_len))THEN
c_name(1:1)(1:1) = C_NULL_CHAR
name_len = H5Rget_file_name(ref_ptr, c_name, 1_SIZE_T)
IF(name_len.LT.0_SIZE_T) hdferr = H5I_INVALID_HID_F
ELSE
l = INT(LEN(name)+1,SIZE_T)
IF(H5Rget_file_name(ref_ptr, c_name, l) .LT. 0_SIZE_T)THEN
hdferr = H5I_INVALID_HID_F
ELSE
CALL HD5c2fstring(name, c_name, LEN(name,KIND=SIZE_T), LEN(name,KIND=SIZE_T)+1_SIZE_T )
ENDIF
ENDIF

END SUBROUTINE h5rget_file_name_f

END MODULE H5R
2 changes: 1 addition & 1 deletion fortran/src/H5Sff.F90
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ END SUBROUTINE h5sget_select_elem_npoints_f
!! \brief Gets the list of element points currently selected.
!!
!! \param space_id Dataspace identifier.
!! \param startpoint Element point to start with.
!! \param startpoint Element point to start with, \Bold{0-based indices}.
!! \param num_points Number of element points to get.
!! \param buf Buffer with element points selected.
!! \param hdferr \fortran_error
Expand Down
6 changes: 5 additions & 1 deletion fortran/src/hdf5_fortrandll.def.in
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ H5R_mp_H5RCREATE_OBJECT_DEPREC_F
H5R_mp_H5RCREATE_REGION_DEPREC_F
H5R_mp_H5RCREATE_OBJECT_F
H5R_mp_H5RCREATE_REGION_F
H5R_mp_H5RCREATE_ATTR_F
H5R_mp_H5RDEREFERENCE_OBJECT_F
H5R_mp_H5RDEREFERENCE_REGION_F
H5R_mp_H5RGET_REGION_REGION_F
Expand All @@ -471,13 +472,16 @@ H5R_mp_H5RGET_NAME_REGION_F
H5R_mp_H5RGET_REGION_PTR_F
H5R_mp_H5RCREATE_PTR_F
H5R_mp_H5RDEREFERENCE_PTR_F
H5R_mp_H5RGET_OBJ_NAME_F
H5R_mp_H5RGET_NAME_PTR_F
H5R_mp_H5RGET_OBJ_TYPE_F
H5R_mp_H5ROPEN_ATTR_F
H5R_mp_H5ROPEN_OBJECT_F
H5R_mp_H5ROPEN_REGION_F
H5R_mp_H5RCOPY_F
H5R_mp_H5RGET_FILE_NAME_F
H5R_mp_H5RGET_ATTR_NAME_F
H5R_mp_H5RGET_OBJ_NAME_F
H5R_mp_H5REQUAL_F
H5R_mp_H5RDESTROY_F
H5R_mp_H5RGET_TYPE_F
; H5S
Expand Down
4 changes: 2 additions & 2 deletions fortran/test/fortranlib_test.F90
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ PROGRAM fortranlibtest
! '========================================='

ret_total_error = 0
CALL genreftest(cleanup, ret_total_error)
CALL write_test_status(ret_total_error, ' General References test', total_error)
CALL reftest3(cleanup, ret_total_error)
CALL write_test_status(ret_total_error, ' Version 3 References test', total_error)

ret_total_error = 0
CALL refobjtest(cleanup, ret_total_error)
Expand Down
Loading

0 comments on commit 8ad0330

Please sign in to comment.