Skip to content

Commit d25db1d

Browse files
committed
use mpi: in mpi.F90
1 parent a4828a4 commit d25db1d

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

src/interface.f90

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module h5fortran
33
use, intrinsic :: iso_c_binding, only : c_ptr, c_loc
44
use, intrinsic :: iso_fortran_env, only : real32, real64, int32, int64, stderr=>error_unit
55

6-
use mpi, only : MPI_COMM_WORLD, MPI_INFO_NULL, mpi_comm_rank
76
use hdf5, only : HID_T, SIZE_T, HSIZE_T, &
87
H5S_ALL_F, H5S_SELECT_SET_F, &
98
H5T_NATIVE_DOUBLE, H5T_NATIVE_REAL, H5T_NATIVE_INTEGER, H5T_NATIVE_CHARACTER, H5T_STD_I64LE, &
@@ -14,8 +13,6 @@ module h5fortran
1413

1514
private
1615

17-
integer, parameter :: mpi_h5comm = MPI_COMM_WORLD, mpi_h5info = MPI_INFO_NULL
18-
1916
!> main type
2017
type :: hdf5_file
2118

@@ -84,15 +81,7 @@ module h5fortran
8481

8582
end type hdf5_file
8683

87-
88-
type :: mpi_tags
89-
90-
integer :: a2=102, a3=103
91-
92-
end type mpi_tags
93-
94-
95-
public :: mpi_h5comm, mpi_tags, has_parallel_compression
84+
public :: has_parallel_compression
9685
public :: hdf5_file, is_hdf5
9786
public :: hdf_rank_check, hdf_shape_check, hdf5version, h5exist, hdf5_close
9887
public :: mpi_collective, mpi_hyperslab
@@ -583,11 +572,12 @@ module integer(HID_T) function mpi_collective(dname, use_mpi) result(xfer_id)
583572
logical, intent(in) :: use_mpi
584573
end function
585574

586-
module integer(HID_T) function mpi_opener(filename, use_mpi, mpi_id) result(fapl)
575+
module subroutine mpi_opener(filename, use_mpi, mpi_id, fapl)
587576
character(*), intent(in) :: filename !< just for error messages
588577
logical, intent(in) :: use_mpi
589-
integer, intent(in) :: mpi_id
590-
end function
578+
integer, intent(out) :: mpi_id
579+
integer(HID_T), intent(out) :: fapl
580+
end subroutine
591581

592582
end interface
593583

src/mpi.F90

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
use hdf5, only : h5pcreate_f, h5pset_dxpl_mpio_f, h5pset_fapl_mpio_f, &
77
H5FD_MPIO_COLLECTIVE_F, &
88
H5P_DATASET_XFER_F
9+
10+
use mpi, only : MPI_COMM_WORLD, MPI_INFO_NULL, mpi_comm_rank
911
#endif
1012

1113
use hdf5, only : H5P_FILE_ACCESS_F
@@ -45,19 +47,20 @@
4547
integer :: ier
4648

4749
fapl = H5P_DEFAULT_F
50+
mpi_id = -1
4851

4952
if (.not. use_mpi) return
5053

5154
#ifdef h5fortran_HAVE_PARALLEL
5255

53-
call mpi_comm_rank(mpi_h5comm, mpi_id, ier)
56+
call mpi_comm_rank(MPI_COMM_WORLD, mpi_id, ier)
5457
if(ier /= 0) error stop "ERROR:h5fortran:opener: could not get MPI ID"
5558

5659
!! collective: setup for MPI access
5760
call H5Pcreate_f(H5P_FILE_ACCESS_F, fapl, ier)
5861
if(ier /= 0) error stop "ERROR:h5fortran:opener:h5pcreate could not collective open property for " // filename
5962

60-
call H5Pset_fapl_mpio_f(fapl, mpi_h5comm, mpi_h5info, ier)
63+
call H5Pset_fapl_mpio_f(fapl, MPI_COMM_WORLD, MPI_INFO_NULL, ier)
6164
if(ier /= 0) error stop "ERROR:h5fortran:opener:h5pset_fapl_mpio could not collective open file for " // filename
6265

6366
#endif

src/utils.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
error stop 'ERROR:h5fortran:open Unsupported action ' // laction // ' for ' // filename
113113
end select
114114

115-
fapl = mpi_opener(filename, self%use_mpi, self%mpi_id)
115+
call mpi_opener(filename, self%use_mpi, self%mpi_id, fapl)
116116

117117
if (file_mode == H5F_ACC_RDONLY_F .or. file_mode == H5F_ACC_RDWR_F) then
118118
if(.not. is_hdf5(filename)) error stop "ERROR:h5fortran:open: not an HDF5 file: "//filename

0 commit comments

Comments
 (0)