Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add h5pget_actual_selection_io_mode fortran wrapper #3746

Merged
merged 13 commits into from
Oct 23, 2023
38 changes: 37 additions & 1 deletion fortran/src/H5Pff.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6405,7 +6405,7 @@ END SUBROUTINE H5Pset_file_space_strategy_f
!! \brief Gets the file space handling strategy and persisting free-space values for a file creation property list.
!!
!! \param plist_id File creation property list identifier
!! \param strategy The file space handling strategy to be used.
!! \param strategy The file space handling strategy to be used
!! \param persist Indicate whether free space should be persistent or not
!! \param threshold The free-space section size threshold value
!! \param hdferr \fortran_error
Expand Down Expand Up @@ -6507,6 +6507,42 @@ END FUNCTION H5Pget_file_space_page_size
hdferr = INT(h5pget_file_space_page_size(prp_id, fsp_size))

END SUBROUTINE h5pget_file_space_page_size_f
!>
!! \ingroup FH5P
!!
!! \brief Retrieves the type(s) of I/O that HDF5 actually performed on raw data
!! during the last I/O call.
!!
!! \param plist_id File creation property list identifier
!! \param actual_selection_io_mode A bitwise set value indicating the type(s) of I/O performed
!! \param hdferr \fortran_error
!!
!! See C API: @ref H5Pget_actual_selection_io_mode()
!!
SUBROUTINE h5pget_actual_selection_io_mode_f(plist_id, actual_selection_io_mode, hdferr)

IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: plist_id
INTEGER , INTENT(OUT) :: actual_selection_io_mode
INTEGER , INTENT(OUT) :: hdferr

INTEGER(C_INT32_T) :: c_actual_selection_io_mode

INTERFACE
INTEGER(C_INT) FUNCTION H5Pget_actual_selection_io_mode(plist_id, actual_selection_io_mode) &
BIND(C, NAME='H5Pget_actual_selection_io_mode')
IMPORT :: HID_T, C_INT32_T, C_INT
IMPLICIT NONE
INTEGER(HID_T), VALUE :: plist_id
INTEGER(C_INT32_T) :: actual_selection_io_mode
END FUNCTION H5Pget_actual_selection_io_mode
END INTERFACE

hdferr = INT(H5Pget_actual_selection_io_mode(plist_id, c_actual_selection_io_mode))

actual_selection_io_mode = INT(c_actual_selection_io_mode)

END SUBROUTINE h5pget_actual_selection_io_mode_f

END MODULE H5P

4 changes: 4 additions & 0 deletions fortran/src/H5_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,10 @@ h5init_flags_c(int_f *h5d_flags, size_t_f *h5d_size_flags, int_f *h5e_flags, hid
h5d_flags[55] = (int_f)H5D_MPIO_LINK_CHUNK;
h5d_flags[56] = (int_f)H5D_MPIO_MULTI_CHUNK;

h5d_flags[57] = (int_f)H5D_SCALAR_IO;
h5d_flags[58] = (int_f)H5D_VECTOR_IO;
h5d_flags[59] = (int_f)H5D_SELECTION_IO;

/*
* H5E flags
*/
Expand Down
5 changes: 4 additions & 1 deletion fortran/src/H5_ff.F90
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ MODULE H5LIB
!
! H5D flags declaration
!
INTEGER, PARAMETER :: H5D_FLAGS_LEN = 57
INTEGER, PARAMETER :: H5D_FLAGS_LEN = 60
INTEGER, DIMENSION(1:H5D_FLAGS_LEN) :: H5D_flags
INTEGER, PARAMETER :: H5D_SIZE_FLAGS_LEN = 2
INTEGER(SIZE_T), DIMENSION(1:H5D_SIZE_FLAGS_LEN) :: H5D_size_flags
Expand Down Expand Up @@ -467,6 +467,9 @@ END FUNCTION h5init1_flags_c
H5D_MPIO_NO_CHUNK_OPTIMIZATION_F = H5D_flags(55)
H5D_MPIO_LINK_CHUNK_F = H5D_flags(56)
H5D_MPIO_MULTI_CHUNK_F = H5D_flags(57)
H5D_SCALAR_IO_F = H5D_flags(58)
H5D_VECTOR_IO_F = H5D_flags(59)
H5D_SELECTION_IO_F = H5D_flags(60)

H5D_CHUNK_CACHE_NSLOTS_DFLT_F = H5D_size_flags(1)
H5D_CHUNK_CACHE_NBYTES_DFLT_F = H5D_size_flags(2)
Expand Down
10 changes: 10 additions & 0 deletions fortran/src/H5f90global.F90
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,12 @@ MODULE H5GLOBAL
!DEC$ATTRIBUTES DLLEXPORT :: H5D_MPIO_NO_CHUNK_OPTIMIZATION_F
!DEC$ATTRIBUTES DLLEXPORT :: H5D_MPIO_LINK_CHUNK_F
!DEC$ATTRIBUTES DLLEXPORT :: H5D_MPIO_MULTI_CHUNK_F

!DEC$ATTRIBUTES DLLEXPORT :: H5D_SCALAR_IO_F
!DEC$ATTRIBUTES DLLEXPORT :: H5D_VECTOR_IO_F
!DEC$ATTRIBUTES DLLEXPORT :: H5D_SELECTION_IO_F


!DEC$endif
!> \addtogroup FH5D
!> @{
Expand Down Expand Up @@ -444,6 +450,10 @@ MODULE H5GLOBAL
INTEGER :: H5D_MPIO_NO_CHUNK_OPTIMIZATION_F !< H5D_MPIO_NO_CHUNK_OPTIMIZATION
INTEGER :: H5D_MPIO_LINK_CHUNK_F !< H5D_MPIO_LINK_CHUNK
INTEGER :: H5D_MPIO_MULTI_CHUNK_F !< H5D_MPIO_MULTI_CHUNK

INTEGER :: H5D_SCALAR_IO_F !< Scalar (or legacy MPIO) I/O was performed
INTEGER :: H5D_VECTOR_IO_F !< Vector I/O was performed
INTEGER :: H5D_SELECTION_IO_F !< Selection I/O was performed
!
! H5E flags declaration
!
Expand Down
5 changes: 5 additions & 0 deletions fortran/test/tH5P.F90
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ SUBROUTINE test_in_place_conversion(cleanup, total_error)
REAL(KIND=C_DOUBLE), DIMENSION(1:array_len) :: wbuf_d_org
REAL(KIND=C_FLOAT), DIMENSION(1:array_len), TARGET :: rbuf
INTEGER :: i
INTEGER :: actual_selection_io_mode
TYPE(C_PTR) :: f_ptr

! create the data
Expand Down Expand Up @@ -919,6 +920,10 @@ SUBROUTINE test_in_place_conversion(cleanup, total_error)
! Should not be equal for in-place buffer use
CALL VERIFY("h5dwrite_f -- in-place", wbuf_d(1), wbuf_d_org(1), total_error, .FALSE.)

CALL h5pget_actual_selection_io_mode_f(plist_id, actual_selection_io_mode, error)
CALL check("h5pget_actual_selection_io_mode_f", error, total_error)
CALL VERIFY("h5pget_actual_selection_io_mode_f", actual_selection_io_mode, H5D_SCALAR_IO_F, total_error)

f_ptr = C_LOC(rbuf)
CALL h5dread_f(dset_id, h5kind_to_type(KIND(rbuf(1)), H5_REAL_KIND), f_ptr, error)
CALL check("h5dread_f", error, total_error)
Expand Down
15 changes: 15 additions & 0 deletions fortran/testpar/hyper.F90
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors)
INTEGER :: local_no_collective_cause
INTEGER :: global_no_collective_cause
INTEGER :: no_selection_io_cause
INTEGER :: actual_selection_io_mode

!
! initialize the array data between the processes (3)
Expand Down Expand Up @@ -236,6 +237,20 @@ SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors)
CALL h5dwrite_f(dset_id,H5T_NATIVE_INTEGER,wbuf,dims,hdferror,file_space_id=fspace_id,mem_space_id=mspace_id,xfer_prp=dxpl_id)
CALL check("h5dwrite_f", hdferror, nerrors)

CALL h5pget_actual_selection_io_mode_f(dxpl_id, actual_selection_io_mode, hdferror)
CALL check("h5pget_actual_selection_io_mode_f", hdferror, nerrors)
IF(do_collective)THEN
IF(actual_selection_io_mode .NE. H5D_SELECTION_IO_F)THEN
PRINT*, "Incorrect actual selection io mode"
nerrors = nerrors + 1
ENDIF
ELSE
IF(actual_selection_io_mode .NE. IOR(H5D_SELECTION_IO_F, H5D_SCALAR_IO_F))THEN
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So independent does both selection IO and scalar IO, is that correct?

PRINT*, "Incorrect actual selection io mode"
nerrors = nerrors + 1
ENDIF
ENDIF

! Check h5pget_mpio_actual_io_mode_f function
CALL h5pget_mpio_actual_io_mode_f(dxpl_id, actual_io_mode, hdferror)
CALL check("h5pget_mpio_actual_io_mode_f", hdferror, nerrors)
Expand Down
3 changes: 2 additions & 1 deletion release_docs/RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ New Features
- Fortran async APIs H5A, H5D, H5ES, H5G, H5F, H5L and H5O were added.

- Added Fortran APIs:
h5pset_selection_io_f, h5pget_selection_io_f
h5pset_selection_io_f, h5pget_selection_io_f,
h5pget_actual_selection_io_mode_f,
h5pset_modify_write_buf_f, h5pget_modify_write_buf_f

- Added Fortran APIs:
Expand Down