Skip to content

Commit

Permalink
removed C_INT32_T from Fortran APIs (HDFGroup#3537)
Browse files Browse the repository at this point in the history
  • Loading branch information
brtnfld authored and qkoziol committed Sep 30, 2023
1 parent cfedb5c commit 8d6e2e4
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 78 deletions.
14 changes: 11 additions & 3 deletions fortran/src/H5Dff.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2396,14 +2396,15 @@ SUBROUTINE h5dread_chunk_f(dset_id, offset, filters, buf, hdferr, dxpl_id)

INTEGER(HID_T) , INTENT(IN) :: dset_id
INTEGER(HSIZE_T) , INTENT(IN), DIMENSION(:) :: offset
INTEGER(C_INT32_T), INTENT(INOUT) :: filters
INTEGER , INTENT(INOUT) :: filters
TYPE(C_PTR) :: buf
INTEGER , INTENT(OUT) :: hdferr
INTEGER(HID_T) , INTENT(IN), OPTIONAL :: dxpl_id

INTEGER(HID_T) :: dxpl_id_default
INTEGER(HSIZE_T), DIMENSION(:), ALLOCATABLE :: offset_c
INTEGER(HSIZE_T) :: i, rank
INTEGER(C_INT32_T) :: c_filters

INTERFACE
INTEGER(C_INT) FUNCTION H5Dread_chunk(dset_id, dxpl_id, offset, filters, buf) &
Expand All @@ -2422,6 +2423,8 @@ END FUNCTION H5Dread_chunk
dxpl_id_default = H5P_DEFAULT_F
IF (PRESENT(dxpl_id)) dxpl_id_default = dxpl_id

c_filters = INT(filters, KIND=C_INT32_T)

rank = SIZE(offset, KIND=HSIZE_T)

ALLOCATE(offset_c(rank), STAT=hdferr)
Expand All @@ -2437,7 +2440,9 @@ END FUNCTION H5Dread_chunk
offset_c(i) = offset(rank - i + 1)
ENDDO

hdferr = INT(H5Dread_chunk(dset_id, dxpl_id_default, offset_c, filters, buf))
hdferr = INT(H5Dread_chunk(dset_id, dxpl_id_default, offset_c, c_filters, buf))

filters = INT(c_filters)

DEALLOCATE(offset_c)

Expand All @@ -2462,7 +2467,7 @@ SUBROUTINE h5dwrite_chunk_f(dset_id, filters, offset, data_size, buf, hdferr, dx
IMPLICIT NONE

INTEGER(HID_T) , INTENT(IN) :: dset_id
INTEGER(C_INT32_T), INTENT(IN) :: filters
INTEGER , INTENT(IN) :: filters
INTEGER(HSIZE_T) , INTENT(IN), DIMENSION(:) :: offset
INTEGER(SIZE_T) , INTENT(IN) :: data_size
TYPE(C_PTR) :: buf
Expand All @@ -2472,6 +2477,7 @@ SUBROUTINE h5dwrite_chunk_f(dset_id, filters, offset, data_size, buf, hdferr, dx
INTEGER(HID_T) :: dxpl_id_default
INTEGER(HSIZE_T), DIMENSION(:), ALLOCATABLE :: offset_c
INTEGER(HSIZE_T) :: i, rank
INTEGER(C_INT32_T) :: c_filters

INTERFACE
INTEGER(C_INT) FUNCTION H5Dwrite_chunk(dset_id, dxpl_id, filters, offset, data_size, buf) &
Expand Down Expand Up @@ -2506,6 +2512,8 @@ END FUNCTION H5Dwrite_chunk
offset_c(i) = offset(rank - i + 1)
ENDDO

c_filters = INT(filters, C_INT32_T)

hdferr = INT(H5Dwrite_chunk(dset_id, dxpl_id_default, filters, offset_c, data_size, buf))

DEALLOCATE(offset_c)
Expand Down
28 changes: 19 additions & 9 deletions fortran/src/H5Pff.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5346,10 +5346,13 @@ END SUBROUTINE h5pget_fapl_ioc_f
SUBROUTINE h5pget_mpio_no_collective_cause_f(plist_id, local_no_collective_cause, global_no_collective_cause, hdferr)
IMPLICIT NONE
INTEGER(HID_T) , INTENT(IN) :: plist_id
INTEGER(C_INT32_T), INTENT(OUT) :: local_no_collective_cause
INTEGER(C_INT32_T), INTENT(OUT) :: global_no_collective_cause
INTEGER, INTENT(OUT) :: local_no_collective_cause
INTEGER, INTENT(OUT) :: global_no_collective_cause
INTEGER , INTENT(OUT) :: hdferr

INTEGER(C_INT32_T) :: c_local_no_collective_cause
INTEGER(C_INT32_T) :: c_global_no_collective_cause

INTERFACE
INTEGER(C_INT) FUNCTION H5Pget_mpio_no_collective_cause(plist_id, local_no_collective_cause, global_no_collective_cause) &
BIND(C, NAME='H5Pget_mpio_no_collective_cause')
Expand All @@ -5361,7 +5364,10 @@ INTEGER(C_INT) FUNCTION H5Pget_mpio_no_collective_cause(plist_id, local_no_colle
END FUNCTION H5Pget_mpio_no_collective_cause
END INTERFACE

hdferr = INT(H5Pget_mpio_no_collective_cause(plist_id, local_no_collective_cause, global_no_collective_cause))
hdferr = INT(H5Pget_mpio_no_collective_cause(plist_id, c_local_no_collective_cause, c_global_no_collective_cause))

local_no_collective_cause = INT(c_local_no_collective_cause)
global_no_collective_cause = INT(c_global_no_collective_cause)

END SUBROUTINE h5pget_mpio_no_collective_cause_f

Expand Down Expand Up @@ -6328,9 +6334,11 @@ END SUBROUTINE h5pset_file_locking_f
!!
SUBROUTINE h5pget_no_selection_io_cause_f(plist_id, no_selection_io_cause, hdferr)
IMPLICIT NONE
INTEGER(HID_T) , INTENT(IN) :: plist_id
INTEGER(C_INT32_T), INTENT(OUT) :: no_selection_io_cause
INTEGER , INTENT(OUT) :: hdferr
INTEGER(HID_T), INTENT(IN) :: plist_id
INTEGER , INTENT(OUT) :: no_selection_io_cause
INTEGER , INTENT(OUT) :: hdferr

INTEGER(C_INT32_T) :: c_no_selection_io_cause

INTERFACE
INTEGER(C_INT) FUNCTION H5Pget_no_selection_io_cause(plist_id, no_selection_io_cause) &
Expand All @@ -6342,7 +6350,9 @@ INTEGER(C_INT) FUNCTION H5Pget_no_selection_io_cause(plist_id, no_selection_io_c
END FUNCTION H5Pget_no_selection_io_cause
END INTERFACE

hdferr = INT( H5Pget_no_selection_io_cause(plist_id, no_selection_io_cause))
hdferr = INT( H5Pget_no_selection_io_cause(plist_id, c_no_selection_io_cause))

no_selection_io_cause = INT(c_no_selection_io_cause)

END SUBROUTINE h5pget_no_selection_io_cause_f

Expand Down Expand Up @@ -6373,7 +6383,7 @@ SUBROUTINE H5Pset_file_space_strategy_f(plist_id, strategy, persist, threshold,
INTERFACE
INTEGER(C_INT) FUNCTION H5Pset_file_space_strategy(plist_id, strategy, persist, threshold) &
BIND(C, NAME='H5Pset_file_space_strategy')
IMPORT :: HID_T, HSIZE_T, C_INT, C_INT32_T, C_BOOL
IMPORT :: HID_T, HSIZE_T, C_INT, C_BOOL
IMPLICIT NONE
INTEGER(HID_T) , VALUE :: plist_id
INTEGER(C_INT) , VALUE :: strategy
Expand Down Expand Up @@ -6416,7 +6426,7 @@ SUBROUTINE h5pget_file_space_strategy_f(plist_id, strategy, persist, threshold,
INTERFACE
INTEGER(C_INT) FUNCTION H5Pget_file_space_strategy(plist_id, strategy, persist, threshold) &
BIND(C, NAME='H5Pget_file_space_strategy')
IMPORT :: HID_T, HSIZE_T, C_INT, C_INT32_T, C_BOOL
IMPORT :: HID_T, HSIZE_T, C_INT, C_BOOL
IMPLICIT NONE
INTEGER(HID_T), VALUE :: plist_id
INTEGER(C_INT) :: strategy
Expand Down
54 changes: 27 additions & 27 deletions fortran/src/H5_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,33 +449,33 @@ h5init_flags_c(int_f *h5d_flags, size_t_f *h5d_size_flags, int_f *h5e_flags, hid
h5d_flags[30] = (int_f)H5D_SELECTION_IO_MODE_OFF;
h5d_flags[31] = (int_f)H5D_SELECTION_IO_MODE_ON;

h5d_flags[32] = H5D_MPIO_COLLECTIVE;
h5d_flags[33] = H5D_MPIO_SET_INDEPENDENT;
h5d_flags[34] = H5D_MPIO_DATATYPE_CONVERSION;
h5d_flags[35] = H5D_MPIO_DATA_TRANSFORMS;
h5d_flags[36] = H5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED;
h5d_flags[37] = H5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES;
h5d_flags[38] = H5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET;
h5d_flags[39] = H5D_MPIO_PARALLEL_FILTERED_WRITES_DISABLED;
h5d_flags[40] = H5D_MPIO_ERROR_WHILE_CHECKING_COLLECTIVE_POSSIBLE;
h5d_flags[41] = H5D_MPIO_NO_SELECTION_IO;
h5d_flags[42] = H5D_MPIO_NO_COLLECTIVE_MAX_CAUSE;

h5d_flags[43] = H5D_SEL_IO_DISABLE_BY_API;
h5d_flags[44] = H5D_SEL_IO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET;
h5d_flags[45] = H5D_SEL_IO_CONTIGUOUS_SIEVE_BUFFER;
h5d_flags[46] = H5D_SEL_IO_NO_VECTOR_OR_SELECTION_IO_CB;
h5d_flags[47] = H5D_SEL_IO_PAGE_BUFFER;
h5d_flags[48] = H5D_SEL_IO_DATASET_FILTER;
h5d_flags[49] = H5D_SEL_IO_CHUNK_CACHE;
h5d_flags[50] = H5D_SEL_IO_TCONV_BUF_TOO_SMALL;
h5d_flags[51] = H5D_SEL_IO_BKG_BUF_TOO_SMALL;
h5d_flags[52] = H5D_SEL_IO_DEFAULT_OFF;
h5d_flags[53] = H5D_MPIO_NO_SELECTION_IO_CAUSES;

h5d_flags[54] = H5D_MPIO_NO_CHUNK_OPTIMIZATION;
h5d_flags[55] = H5D_MPIO_LINK_CHUNK;
h5d_flags[56] = H5D_MPIO_MULTI_CHUNK;
h5d_flags[32] = (int_f)H5D_MPIO_COLLECTIVE;
h5d_flags[33] = (int_f)H5D_MPIO_SET_INDEPENDENT;
h5d_flags[34] = (int_f)H5D_MPIO_DATATYPE_CONVERSION;
h5d_flags[35] = (int_f)H5D_MPIO_DATA_TRANSFORMS;
h5d_flags[36] = (int_f)H5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED;
h5d_flags[37] = (int_f)H5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES;
h5d_flags[38] = (int_f)H5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET;
h5d_flags[39] = (int_f)H5D_MPIO_PARALLEL_FILTERED_WRITES_DISABLED;
h5d_flags[40] = (int_f)H5D_MPIO_ERROR_WHILE_CHECKING_COLLECTIVE_POSSIBLE;
h5d_flags[41] = (int_f)H5D_MPIO_NO_SELECTION_IO;
h5d_flags[42] = (int_f)H5D_MPIO_NO_COLLECTIVE_MAX_CAUSE;

h5d_flags[43] = (int_f)H5D_SEL_IO_DISABLE_BY_API;
h5d_flags[44] = (int_f)H5D_SEL_IO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET;
h5d_flags[45] = (int_f)H5D_SEL_IO_CONTIGUOUS_SIEVE_BUFFER;
h5d_flags[46] = (int_f)H5D_SEL_IO_NO_VECTOR_OR_SELECTION_IO_CB;
h5d_flags[47] = (int_f)H5D_SEL_IO_PAGE_BUFFER;
h5d_flags[48] = (int_f)H5D_SEL_IO_DATASET_FILTER;
h5d_flags[49] = (int_f)H5D_SEL_IO_CHUNK_CACHE;
h5d_flags[50] = (int_f)H5D_SEL_IO_TCONV_BUF_TOO_SMALL;
h5d_flags[51] = (int_f)H5D_SEL_IO_BKG_BUF_TOO_SMALL;
h5d_flags[52] = (int_f)H5D_SEL_IO_DEFAULT_OFF;
h5d_flags[53] = (int_f)H5D_MPIO_NO_SELECTION_IO_CAUSES;

h5d_flags[54] = (int_f)H5D_MPIO_NO_CHUNK_OPTIMIZATION;
h5d_flags[55] = (int_f)H5D_MPIO_LINK_CHUNK;
h5d_flags[56] = (int_f)H5D_MPIO_MULTI_CHUNK;

/*
* H5E flags
Expand Down
10 changes: 5 additions & 5 deletions fortran/test/tH5D.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ SUBROUTINE test_direct_chunk_io(cleanup, total_error)
INTEGER :: i, j, n
INTEGER :: error
TYPE(C_PTR) :: f_ptr
INTEGER(C_int32_t) :: filters
INTEGER :: filters
INTEGER(SIZE_T) :: sizeINT
INTEGER(HID_T) :: dxpl

Expand Down Expand Up @@ -1081,12 +1081,12 @@ SUBROUTINE test_direct_chunk_io(cleanup, total_error)

f_ptr = C_LOC(wdata1)
offset(1:2) = (/0, 0/)
CALL H5Dwrite_chunk_f(dset_id, 0_C_INT32_T, offset, CHUNK0 * CHUNK1 * sizeINT, f_ptr, error)
CALL H5Dwrite_chunk_f(dset_id, 0, offset, CHUNK0 * CHUNK1 * sizeINT, f_ptr, error)
CALL check("h5dwrite_f",error,total_error)

f_ptr = C_LOC(wdata2)
offset(1:2) = (/0, 16/)
CALL H5Dwrite_chunk_f(dset_id, 0_C_INT32_T, offset, CHUNK0 * CHUNK1 * sizeINT, f_ptr, error, dxpl)
CALL H5Dwrite_chunk_f(dset_id, 0, offset, CHUNK0 * CHUNK1 * sizeINT, f_ptr, error, dxpl)
CALL check("h5dwrite_f",error,total_error)

CALL h5dclose_f(dset_id, error)
Expand Down Expand Up @@ -1126,7 +1126,7 @@ SUBROUTINE test_direct_chunk_io(cleanup, total_error)
ENDDO
ENDDO

CALL VERIFY("H5Dread_chunk_f",filters, 0_C_INT32_T, total_error)
CALL VERIFY("H5Dread_chunk_f",filters, 0, total_error)

f_ptr = C_LOC(rdata2)
offset(1:2) = (/0, 16/)
Expand All @@ -1141,7 +1141,7 @@ SUBROUTINE test_direct_chunk_io(cleanup, total_error)
ENDDO
ENDDO

CALL VERIFY("H5Dread_chunk_f",filters, 0_C_INT32_T, total_error)
CALL VERIFY("H5Dread_chunk_f",filters, 0, total_error)

CALL h5dclose_f(dset_id, error)
CALL check("h5dclose_f",error,total_error)
Expand Down
13 changes: 10 additions & 3 deletions fortran/testpar/hyper.F90
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors)
LOGICAL :: is_coll
LOGICAL :: is_coll_true = .TRUE.

INTEGER(C_INT32_T) :: local_no_collective_cause
INTEGER(C_INT32_T) :: global_no_collective_cause
INTEGER(C_INT32_T) :: no_selection_io_cause
INTEGER :: local_no_collective_cause
INTEGER :: global_no_collective_cause
INTEGER :: no_selection_io_cause

!
! initialize the array data between the processes (3)
Expand Down Expand Up @@ -275,6 +275,13 @@ 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)

! Verify bitwise operations are correct

IF( IOR(H5D_MPIO_DATATYPE_CONVERSION_F,H5D_MPIO_DATA_TRANSFORMS_F).NE.6)THEN
PRINT*, "Incorrect bitwise operations for Fortran defined constants"
nerrors = nerrors + 1
ENDIF

CALL h5pget_no_selection_io_cause_f(dxpl_id, no_selection_io_cause, hdferror)
CALL check("h5pget_no_selection_io_cause_f", hdferror, nerrors)

Expand Down
Loading

0 comments on commit 8d6e2e4

Please sign in to comment.