Skip to content

Commit 51ec80c

Browse files
committed
Initialize MPI with requested threading support, maximizing support for client codes
1 parent a571e76 commit 51ec80c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/fortuno_mpi/mpienv.f90

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
!> Contains a type to deal with the mpi environment
66
module fortuno_mpi_mpienv
77
use mpi_f08, only : MPI_Allreduce, MPI_CHAR, MPI_Comm, MPI_Comm_rank, MPI_Comm_size,&
8-
& MPI_COMM_WORLD, MPI_IN_PLACE, MPI_Init, MPI_INTEGER, MPI_Finalize, MPI_PROD, MPI_Recv,&
9-
& MPI_Send, MPI_Status
8+
& MPI_COMM_WORLD, MPI_IN_PLACE, MPI_Init_thread, MPI_INTEGER, MPI_Finalize, MPI_PROD, MPI_Recv,&
9+
& MPI_Send, MPI_Status, MPI_THREAD_MULTIPLE
1010
implicit none
1111

1212
private
@@ -34,15 +34,18 @@ module fortuno_mpi_mpienv
3434
contains
3535

3636
!> Initializes the MPI environment
37+
!!
38+
!! Full threading support with MPI is requested to maximize support
39+
!! for client codes.
3740
subroutine init_mpi_env(this)
3841

3942
!> Instance
4043
type(mpi_env), intent(out) :: this
4144

42-
integer :: ierror
45+
integer :: ierror, provided
4346

44-
call MPI_Init(ierror)
45-
if (ierror /= 0) error stop "MPI_Init failed in init_mpi_env"
47+
call MPI_Init_thread(MPI_THREAD_MULTIPLE, provided)
48+
if (ierror /= 0) error stop "MPI_Init_thread failed in init_mpi_env"
4649
this%comm = MPI_COMM_WORLD
4750
call MPI_Comm_size(this%comm, this%nranks, ierror)
4851
if (ierror /= 0) error stop "MPI_Comm_size failed in init_mpi_env"

0 commit comments

Comments
 (0)