From 2232514c90f9900004d7d869c8de3cdc9b19eabc Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Tue, 26 Dec 2023 13:07:27 -0600 Subject: [PATCH] debugging --- HDF5Examples/FORTRAN/H5G/h5ex_g_traverse.F90 | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/HDF5Examples/FORTRAN/H5G/h5ex_g_traverse.F90 b/HDF5Examples/FORTRAN/H5G/h5ex_g_traverse.F90 index 198d437003a..35ac4abacdf 100644 --- a/HDF5Examples/FORTRAN/H5G/h5ex_g_traverse.F90 +++ b/HDF5Examples/FORTRAN/H5G/h5ex_g_traverse.F90 @@ -76,7 +76,7 @@ RECURSIVE INTEGER(KIND=C_INT) FUNCTION op_func(loc_id, name, info, operator_data INTEGER :: i TYPE(opdata), POINTER :: od TYPE(opdata), TARGET :: nextod - INTEGER(HSIZE_T) :: idx + INTEGER(HSIZE_T), SAVE :: idx TYPE(C_PTR) :: ptr2 TYPE(C_FUNPTR) :: funptr @@ -84,7 +84,7 @@ RECURSIVE INTEGER(KIND=C_INT) FUNCTION op_func(loc_id, name, info, operator_data CHARACTER(LEN=10) :: space INTEGER :: spaces ! Number of whitespaces to prepend to output INTEGER :: len - + PRINT*,"START op_func" ret_val = 0 name_string(1:10) = " " @@ -104,13 +104,12 @@ RECURSIVE INTEGER(KIND=C_INT) FUNCTION op_func(loc_id, name, info, operator_data ! The name of the object is passed to this function by ! the Library. ! + CALL H5Oget_info_by_name_f(loc_id, name_string, infobuf, status) - spaces = 2*(od%recurs+1) WRITE(*,'(A)', ADVANCE='NO') space(1:spaces) ! Format output - IF(infobuf%type.EQ.H5O_TYPE_GROUP_F)THEN WRITE(*,'("Group: ",A," {")') name_string(1:len) @@ -134,14 +133,17 @@ RECURSIVE INTEGER(KIND=C_INT) FUNCTION op_func(loc_id, name, info, operator_data ELSE nextod%recurs = od%recurs + 1 - nextod%prev => od + nextod%prev => od%prev nextod%token = infobuf%token idx = 0 - ptr2 = C_LOC(nextod%recurs) + ptr2 = C_LOC(nextod) !C_LOC(nextod%recurs) funptr = C_FUNLOC(op_func) - CALL h5literate_by_name_f(loc_id, name_string, H5_INDEX_NAME_F, H5_ITER_NATIVE_F, idx, & + print*,"before" + CALL h5literate_f(loc_id, H5_INDEX_NAME_F, H5_ITER_NATIVE_F, idx, & funptr, ptr2, ret_val, status) - + print*,"end" + !CALL h5literate_by_name_f(loc_id, name_string, H5_INDEX_NAME_F, H5_ITER_NATIVE_F, idx, & + ! funptr, ptr2, ret_val, status) ENDIF WRITE(*,'(A)') space(1:spaces)//"}" RETURN @@ -213,6 +215,7 @@ PROGRAM main INTEGER(hsize_t) :: idx INTEGER :: ret_value TYPE(C_FUNPTR) :: funptr + TYPE(opdata), POINTER :: cptr ! ! Initialize FORTRAN interface. ! @@ -225,7 +228,8 @@ PROGRAM main CALL h5oget_info_by_name_f(file, "/", infobuf, status) od%recurs = 0 - od%prev => NULL() + call C_F_POINTER(C_NULL_PTR, cptr) + od%prev => cptr ! C_LOC(C_NULL_PTR) !> NULL() od%token = infobuf%token ! ! Print the root group and formatting, begin iteration.