summaryrefslogtreecommitdiffstats
path: root/fortran
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2020-08-14 19:35:07 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2020-08-14 19:35:07 (GMT)
commit039213d919c0bcb8f01805f34b9ff6889b06158f (patch)
treeb5c2158184ccb0c9556a4d1f89931d210d9576ca /fortran
parentb8b219d19d158d272cd6b1037bbc8d6e3d64fc73 (diff)
downloadhdf5-039213d919c0bcb8f01805f34b9ff6889b06158f.zip
hdf5-039213d919c0bcb8f01805f34b9ff6889b06158f.tar.gz
hdf5-039213d919c0bcb8f01805f34b9ff6889b06158f.tar.bz2
Brings file locking changes from develop
Diffstat (limited to 'fortran')
-rw-r--r--fortran/src/H5Pff.F90102
-rw-r--r--fortran/src/hdf5_fortrandll.def.in2
-rw-r--r--fortran/test/fortranlib_test.F904
-rw-r--r--fortran/test/tH5P.F9073
4 files changed, 181 insertions, 0 deletions
diff --git a/fortran/src/H5Pff.F90 b/fortran/src/H5Pff.F90
index aa9861d..c6f053f 100644
--- a/fortran/src/H5Pff.F90
+++ b/fortran/src/H5Pff.F90
@@ -8115,5 +8115,107 @@ END SUBROUTINE h5pget_virtual_dsetname_f
END SUBROUTINE h5pset_dset_no_attrs_hint_f
+!****s* H5P (F03)/h5pget_file_locking_f_F03
+!
+! NAME
+! h5pget_file_locking_f
+!
+! PURPOSE
+! Gets the file locking properties. File locking is mainly used to help
+! enforce SWMR semantics.
+!
+! INPUTS
+! fapl_id - Target file access property list identifier.
+!
+! OUTPUTS
+! use_file_locking - Whether or not to use file locks.
+! ignore_disabled_locks - Whether or not to ignore file locks when locking
+! is disabled on a file system.
+! hdferr - error code:
+! 0 on success and -1 on failure
+!
+! AUTHOR
+! Dana Robinson
+! Summer 2020
+!
+! Fortran2003 Interface:
+ SUBROUTINE h5pget_file_locking_f(fapl_id, use_file_locking, ignore_disabled_locks, hdferr)
+ IMPLICIT NONE
+ INTEGER(HID_T) , INTENT(IN) :: fapl_id
+ LOGICAL , INTENT(OUT) :: use_file_locking
+ LOGICAL , INTENT(OUT) :: ignore_disabled_locks
+ INTEGER , INTENT(OUT) :: hdferr
+!*****
+ LOGICAL(C_BOOL) :: c_use_flag
+ LOGICAL(C_BOOL) :: c_ignore_flag
+
+ INTERFACE
+ INTEGER FUNCTION h5pget_file_locking(fapl_id, use_file_locking, ignore_disabled_locks) BIND(C, NAME='H5Pget_file_locking')
+ IMPORT :: HID_T, C_BOOL
+ IMPLICIT NONE
+ INTEGER(HID_T), INTENT(IN), VALUE :: fapl_id
+ LOGICAL(C_BOOL), INTENT(OUT) :: use_file_locking
+ LOGICAL(C_BOOL), INTENT(OUT) :: ignore_disabled_locks
+ END FUNCTION h5pget_file_locking
+ END INTERFACE
+
+ hdferr = INT(h5pget_file_locking(fapl_id, c_use_flag, c_ignore_flag))
+
+ ! Transfer value of C C_BOOL type to Fortran LOGICAL
+ use_file_locking = c_use_flag
+ ignore_disabled_locks = c_ignore_flag
+
+ END SUBROUTINE h5pget_file_locking_f
+
+!****s* H5P (F03)/h5pset_file_locking_f_F03
+!
+! NAME
+! h5pset_file_locking_f
+!
+! PURPOSE
+! Sets the file locking properties. File locking is mainly used to help
+! enforce SWMR semantics.
+!
+! INPUTS
+! fapl_id - Target file access property list identifier.
+! use_file_locking - Whether or not to use file locks.
+! ignore_disabled_locks - Whether or not to ignore file locks when locking
+! is disabled on a file system.
+! hdferr - error code:
+! 0 on success and -1 on failure
+!
+! AUTHOR
+! Dana Robinson
+! Summer 2020
+!
+! Fortran2003 Interface:
+ SUBROUTINE h5pset_file_locking_f(fapl_id, use_file_locking, ignore_disabled_locks, hdferr)
+ IMPLICIT NONE
+ INTEGER(HID_T) , INTENT(IN) :: fapl_id
+ LOGICAL , INTENT(IN) :: use_file_locking
+ LOGICAL , INTENT(IN) :: ignore_disabled_locks
+ INTEGER , INTENT(OUT) :: hdferr
+!*****
+ LOGICAL(C_BOOL) :: c_use_flag
+ LOGICAL(C_BOOL) :: c_ignore_flag
+
+ INTERFACE
+ INTEGER FUNCTION h5pset_file_locking(fapl_id, use_file_locking, ignore_disabled_locks) BIND(C, NAME='H5Pset_file_locking')
+ IMPORT :: HID_T, C_BOOL
+ IMPLICIT NONE
+ INTEGER(HID_T), INTENT(IN), VALUE :: fapl_id
+ LOGICAL(C_BOOL), INTENT(IN), VALUE :: use_file_locking
+ LOGICAL(C_BOOL), INTENT(IN), VALUE :: ignore_disabled_locks
+ END FUNCTION h5pset_file_locking
+ END INTERFACE
+
+ ! Transfer value of Fortran LOGICAL to C C_BOOL type
+ c_use_flag = use_file_locking
+ c_ignore_flag = ignore_disabled_locks
+
+ hdferr = INT(h5pset_file_locking(fapl_id, c_use_flag, c_ignore_flag))
+
+ END SUBROUTINE h5pset_file_locking_f
+
END MODULE H5P
diff --git a/fortran/src/hdf5_fortrandll.def.in b/fortran/src/hdf5_fortrandll.def.in
index b9e2314..8438f2a 100644
--- a/fortran/src/hdf5_fortrandll.def.in
+++ b/fortran/src/hdf5_fortrandll.def.in
@@ -333,6 +333,8 @@ H5P_mp_H5PGET_VIRTUAL_FILENAME_F
H5P_mp_H5PGET_VIRTUAL_DSETNAME_F
H5P_mp_H5PGET_DSET_NO_ATTRS_HINT_F
H5P_mp_H5PSET_DSET_NO_ATTRS_HINT_F
+H5P_mp_H5PSET_FILE_LOCKING_F
+H5P_mp_H5PGET_FILE_LOCKING_F
; Parallel
@H5_NOPAREXP@H5P_mp_H5PSET_FAPL_MPIO_F
@H5_NOPAREXP@H5P_mp_H5PGET_FAPL_MPIO_F
diff --git a/fortran/test/fortranlib_test.F90 b/fortran/test/fortranlib_test.F90
index 92f9279..214f3c2 100644
--- a/fortran/test/fortranlib_test.F90
+++ b/fortran/test/fortranlib_test.F90
@@ -186,6 +186,10 @@ PROGRAM fortranlibtest
CALL test_chunk_cache (cleanup, ret_total_error)
CALL write_test_status(ret_total_error, ' Dataset chunk cache configuration', total_error)
+ ret_total_error = 0
+ CALL test_misc_properties(cleanup, ret_total_error)
+ CALL write_test_status(ret_total_error, ' Miscellaneous properties', total_error)
+
!
! '========================================='
! 'Testing ATTRIBUTE interface '
diff --git a/fortran/test/tH5P.F90 b/fortran/test/tH5P.F90
index 7fe3971..19bee75 100644
--- a/fortran/test/tH5P.F90
+++ b/fortran/test/tH5P.F90
@@ -724,4 +724,77 @@ SUBROUTINE test_chunk_cache(cleanup, total_error)
END SUBROUTINE test_chunk_cache
+!-------------------------------------------------------------------------
+! Function: test_misc_properties
+!
+! Purpose: Tests setting and getting of miscellaneous properties. Does
+! not test the underlying functionality as that is done in
+! the C library tests.
+!
+! Tests APIs:
+! H5P_GET/SET_FILE_LOCKING_F
+!
+! Return: Success: 0
+! Failure: -1
+!
+!-------------------------------------------------------------------------
+!
+SUBROUTINE test_misc_properties(cleanup, total_error)
+
+ IMPLICIT NONE
+ LOGICAL, INTENT(IN) :: cleanup
+ INTEGER, INTENT(INOUT) :: total_error
+
+ INTEGER(hid_t) :: fapl_id = -1 ! Local fapl
+ LOGICAL :: use_file_locking ! (H5Pset/get_file_locking_f)
+ LOGICAL :: ignore_disabled_locks ! (H5Pset/get_file_locking_f)
+ INTEGER :: error
+
+ ! Create a default fapl
+ CALL H5Pcreate_f(H5P_FILE_ACCESS_F, fapl_id, error)
+ CALL check("H5Pcreate_f", error, total_error)
+
+ ! Test H5Pset/get_file_locking_f
+ ! true values
+ use_file_locking = .TRUE.
+ ignore_disabled_locks = .TRUE.
+ CALL h5pset_file_locking_f(fapl_id, use_file_locking, ignore_disabled_locks, error)
+ CALL check("h5pset_set_file_locking_f", error, total_error)
+ use_file_locking = .FALSE.
+ ignore_disabled_locks = .FALSE.
+ CALL h5pget_file_locking_f(fapl_id, use_file_locking, ignore_disabled_locks, error)
+ CALL check("h5pget_set_file_locking_f", error, total_error)
+ if(use_file_locking .neqv. .TRUE.) then
+ total_error = total_error + 1
+ write(*,*) "Got wrong use_file_locking flag from h5pget_file_locking_f"
+ endif
+ if(ignore_disabled_locks .neqv. .TRUE.) then
+ total_error = total_error + 1
+ write(*,*) "Got wrong ignore_disabled_locks flag from h5pget_file_locking_f"
+ endif
+
+ ! false values
+ use_file_locking = .FALSE.
+ ignore_disabled_locks = .FALSE.
+ CALL h5pset_file_locking_f(fapl_id, use_file_locking, ignore_disabled_locks, error)
+ CALL check("h5pset_set_file_locking_f", error, total_error)
+ use_file_locking = .TRUE.
+ ignore_disabled_locks = .TRUE.
+ CALL h5pget_file_locking_f(fapl_id, use_file_locking, ignore_disabled_locks, error)
+ CALL check("h5pget_set_file_locking_f", error, total_error)
+ if(use_file_locking .neqv. .FALSE.) then
+ total_error = total_error + 1
+ write(*,*) "Got wrong use_file_locking flag from h5pget_file_locking_f"
+ endif
+ if(ignore_disabled_locks .neqv. .FALSE.) then
+ total_error = total_error + 1
+ write(*,*) "Got wrong ignore_disabled_locks flag from h5pget_file_locking_f"
+ endif
+
+ ! Close the fapl
+ CALL H5Pclose_f(fapl_id, error)
+ CALL check("H5Pclose_f", error, total_error)
+
+END SUBROUTINE test_misc_properties
+
END MODULE TH5P