From c52d04320b452e9132fa656c3bf52d6b5a89d353 Mon Sep 17 00:00:00 2001 From: "M. Scot Breitenfeld" Date: Fri, 8 Jun 2018 14:19:11 -0500 Subject: HDFFV-10405: Using h5fget_obj_count_f with a file id of H5F_OBJ_ALL_F does not work properly h5fget_obj_count_f with H5F_OBJ_ALL_F counted objects created in h5open_f, which should not be included in the count. The function now returns the correct number of objects (i.e., objects created in h5open are not included in the total). --- fortran/src/H5Fff.F90 | 10 ++++++- fortran/src/H5_ff.F90 | 6 ++++ fortran/test/tH5F.F90 | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 90 insertions(+), 2 deletions(-) diff --git a/fortran/src/H5Fff.F90 b/fortran/src/H5Fff.F90 index a3bef37..45d9f38 100644 --- a/fortran/src/H5Fff.F90 +++ b/fortran/src/H5Fff.F90 @@ -42,6 +42,9 @@ MODULE H5F USE H5GLOBAL IMPLICIT NONE + ! Number of objects opened in H5open_f + INTEGER(SIZE_T) :: H5OPEN_NUM_OPEN_OBJ + CONTAINS !****s* H5F/h5fcreate_f ! @@ -616,9 +619,14 @@ CONTAINS INTEGER(SIZE_T), INTENT(OUT) :: obj_count END FUNCTION h5fget_obj_count_c END INTERFACE - + hdferr = h5fget_obj_count_c(file_id, obj_type, obj_count) + ! Don't include objects created by H5open in the H5F_OBJ_ALL_F count + IF(file_id.EQ.INT(H5F_OBJ_ALL_F,HID_T))THEN + obj_count = obj_count - H5OPEN_NUM_OPEN_OBJ + ENDIF + END SUBROUTINE h5fget_obj_count_f !****s* H5F/h5fget_obj_ids_f diff --git a/fortran/src/H5_ff.F90 b/fortran/src/H5_ff.F90 index db57f03..15fe37a 100644 --- a/fortran/src/H5_ff.F90 +++ b/fortran/src/H5_ff.F90 @@ -169,8 +169,10 @@ CONTAINS ! October 13, 2011 ! Fortran90 Interface: SUBROUTINE h5open_f(error) + USE H5F, ONLY : h5fget_obj_count_f, H5OPEN_NUM_OPEN_OBJ IMPLICIT NONE INTEGER, INTENT(OUT) :: error + INTEGER(SIZE_T) :: H5OPEN_NUM_OPEN_OBJ_LOC = 0 !***** INTERFACE @@ -612,6 +614,10 @@ CONTAINS H5_SZIP_EC_OM_F = H5LIB_flags(1) H5_SZIP_NN_OM_F = H5LIB_flags(2) + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, H5OPEN_NUM_OPEN_OBJ_LOC, error) + + H5OPEN_NUM_OPEN_OBJ = H5OPEN_NUM_OPEN_OBJ_LOC + END SUBROUTINE h5open_f !****s* H5LIB/h5close_f diff --git a/fortran/test/tH5F.F90 b/fortran/test/tH5F.F90 index d91ee9c..72920f2 100644 --- a/fortran/test/tH5F.F90 +++ b/fortran/test/tH5F.F90 @@ -103,6 +103,10 @@ CONTAINS ! INTEGER :: i, j + !number of objects + INTEGER(SIZE_T) :: obj_count + INTEGER(HID_T) :: t1, t2, t3, t4 + ! !data buffers ! @@ -133,11 +137,51 @@ CONTAINS CALL h5_fixname_f(filename2, fix_filename2, H5P_DEFAULT_F, error) if(error .ne. 0) stop + ! Test object counts + CALL h5tcopy_f(H5T_NATIVE_CHARACTER, t1, error) + CALL check(" h5tcopy_f",error,total_error) + CALL h5tcopy_f(H5T_NATIVE_CHARACTER, t2, error) + CALL check(" h5tcopy_f",error,total_error) + CALL h5tcopy_f(H5T_NATIVE_CHARACTER, t3, error) + CALL check(" h5tcopy_f",error,total_error) + CALL h5tcopy_f(H5T_NATIVE_CHARACTER, t4, error) + CALL check(" h5tcopy_f",error,total_error) + + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error) + CALL check(" h5fget_obj_count_f",error,total_error) + + IF(obj_count.NE.4)THEN + total_error = total_error + 1 + ENDIF + ! !Create first file "mount1.h5" using default properties. ! CALL h5fcreate_f(fix_filename1, H5F_ACC_TRUNC_F, file1_id, error) - CALL check("h5fcreate_f",error,total_error) + CALL check("h5fcreate_f",error,total_error) + + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error) + CALL check(" h5fget_obj_count_f",error,total_error) + + IF(obj_count.NE.5)THEN + total_error = total_error + 1 + ENDIF + + CALL h5tclose_f(t1, error) + CALL check("h5tclose_f",error,total_error) + CALL h5tclose_f(t2, error) + CALL check("h5tclose_f",error,total_error) + CALL h5tclose_f(t3, error) + CALL check("h5tclose_f",error,total_error) + CALL h5tclose_f(t4, error) + CALL check("h5tclose_f",error,total_error) + + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error) + CALL check(" h5fget_obj_count_f",error,total_error) + + IF(obj_count.NE.1)THEN + total_error = total_error + 1 + ENDIF ! !Create group "/G" inside file "mount1.h5". @@ -211,9 +255,23 @@ CONTAINS ! CALL h5fopen_f (fix_filename1, H5F_ACC_RDWR_F, file1_id, error) CALL check("hfopen_f",error,total_error) + + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error) + CALL check(" h5fget_obj_count_f",error,total_error) + + IF(obj_count.NE.1)THEN + total_error = total_error + 1 + ENDIF + CALL h5fopen_f (fix_filename2, H5F_ACC_RDWR_F, file2_id, error) CALL check("h5fopen_f",error,total_error) + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error) + CALL check(" h5fget_obj_count_f",error,total_error) + + IF(obj_count.NE.2)THEN + total_error = total_error + 1 + ENDIF ! !mount the second file under the first file's "/G" group. ! @@ -245,6 +303,7 @@ CONTAINS do i = 1, NX do j = 1, NY IF (data_out(i,j) .NE. data_in(i, j)) THEN + total_error = total_error + 1 END IF end do end do @@ -267,11 +326,26 @@ CONTAINS ! !Close both files. ! + + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error) + CALL check(" h5fget_obj_count_f",error,total_error) + + IF(obj_count.NE.2)THEN + total_error = total_error + 1 + ENDIF + CALL h5fclose_f(file1_id, error) CALL check("h5fclose_f",error,total_error) CALL h5fclose_f(file2_id, error) CALL check("h5fclose_f",error,total_error) + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error) + CALL check(" h5fget_obj_count_f",error,total_error) + + IF(obj_count.NE.0)THEN + total_error = total_error + 1 + ENDIF + if(cleanup) CALL h5_cleanup_f(filename1, H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) if(cleanup) CALL h5_cleanup_f(filename2, H5P_DEFAULT_F, error) -- cgit v0.12 From e6aa306354b3b0f2fb707fd49351b7c08c1f49a2 Mon Sep 17 00:00:00 2001 From: "M. Scot Breitenfeld" Date: Fri, 8 Jun 2018 14:38:22 -0500 Subject: HDFFV-10405: Using h5fget_obj_count_f with a file id of H5F_OBJ_ALL_F does not work properly added dependency on H5ff.F90 for H5_ff.F90 --- fortran/src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran/src/Makefile.am b/fortran/src/Makefile.am index a863a67..666f6cb 100644 --- a/fortran/src/Makefile.am +++ b/fortran/src/Makefile.am @@ -142,7 +142,7 @@ FORTRAN_API=yes # modules they depend upon are actually made. *sigh* H5f90global.lo: $(srcdir)/H5f90global.F90 H5fortran_types.lo H5_buildiface.lo: $(srcdir)/H5_buildiface.F90 -H5_ff.lo: $(srcdir)/H5_ff.F90 H5f90global.lo +H5_ff.lo: $(srcdir)/H5_ff.F90 H5Fff.lo H5f90global.lo H5Aff.lo: $(srcdir)/H5Aff.F90 H5f90global.lo H5Dff.lo: $(srcdir)/H5Dff.F90 H5f90global.lo H5Eff.lo: $(srcdir)/H5Eff.F90 H5f90global.lo -- cgit v0.12 From fe325fb554eddceccfa1674d804d5c7aed846bde Mon Sep 17 00:00:00 2001 From: "M. Scot Breitenfeld" Date: Fri, 8 Jun 2018 14:45:23 -0500 Subject: HDFFV-10405: Using h5fget_obj_count_f with a file id of H5F_OBJ_ALL_F does not work properly misc. clean-up --- fortran/src/H5Fff.F90 | 4 ++-- fortran/src/H5_ff.F90 | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fortran/src/H5Fff.F90 b/fortran/src/H5Fff.F90 index 45d9f38..358e421 100644 --- a/fortran/src/H5Fff.F90 +++ b/fortran/src/H5Fff.F90 @@ -43,7 +43,7 @@ MODULE H5F IMPLICIT NONE ! Number of objects opened in H5open_f - INTEGER(SIZE_T) :: H5OPEN_NUM_OPEN_OBJ + INTEGER(SIZE_T) :: H5OPEN_NUM_OBJ CONTAINS !****s* H5F/h5fcreate_f @@ -624,7 +624,7 @@ CONTAINS ! Don't include objects created by H5open in the H5F_OBJ_ALL_F count IF(file_id.EQ.INT(H5F_OBJ_ALL_F,HID_T))THEN - obj_count = obj_count - H5OPEN_NUM_OPEN_OBJ + obj_count = obj_count - H5OPEN_NUM_OBJ ENDIF END SUBROUTINE h5fget_obj_count_f diff --git a/fortran/src/H5_ff.F90 b/fortran/src/H5_ff.F90 index 15fe37a..f63e734 100644 --- a/fortran/src/H5_ff.F90 +++ b/fortran/src/H5_ff.F90 @@ -169,10 +169,10 @@ CONTAINS ! October 13, 2011 ! Fortran90 Interface: SUBROUTINE h5open_f(error) - USE H5F, ONLY : h5fget_obj_count_f, H5OPEN_NUM_OPEN_OBJ + USE H5F, ONLY : h5fget_obj_count_f, H5OPEN_NUM_OBJ IMPLICIT NONE INTEGER, INTENT(OUT) :: error - INTEGER(SIZE_T) :: H5OPEN_NUM_OPEN_OBJ_LOC = 0 + INTEGER(SIZE_T) :: H5OPEN_NUM_OBJ_LOC = 0 !***** INTERFACE @@ -614,9 +614,9 @@ CONTAINS H5_SZIP_EC_OM_F = H5LIB_flags(1) H5_SZIP_NN_OM_F = H5LIB_flags(2) - CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, H5OPEN_NUM_OPEN_OBJ_LOC, error) + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, H5OPEN_NUM_OBJ_LOC, error) - H5OPEN_NUM_OPEN_OBJ = H5OPEN_NUM_OPEN_OBJ_LOC + H5OPEN_NUM_OBJ = H5OPEN_NUM_OBJ_LOC END SUBROUTINE h5open_f -- cgit v0.12