initializes the system default communicator
should only be called once
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(out) | :: | mp_comm |
[output] : handle of the default communicator |
SUBROUTINE mp_world_init(mp_comm)
!! initializes the system default communicator
!! @note
!! should only be called once
INTEGER, INTENT(OUT) :: mp_comm
!! [output] : handle of the default communicator
#if defined(__parallel)
INTEGER :: ierr
!$ INTEGER :: provided_tsl
!$ LOGICAL :: no_threading_support
#if defined(__NO_MPI_THREAD_SUPPORT_CHECK)
! Hack that does not request or check MPI thread support level.
! User asserts that the MPI library will work correctly with
! threads.
!
!$ no_threading_support = .TRUE.
#else
! Does the right thing when using OpenMP: requests that the MPI
! library supports funneled mode and verifies that the MPI library
! provides that support.
!
! Developers: Only the master thread will ever make calls to the
! MPI library.
!
!$ no_threading_support = .FALSE.
#endif
!$ IF (no_threading_support) THEN
CALL mpi_init(ierr)
IF (ierr /= 0) CALL mp_stop(ierr, "mpi_init @ mp_world_init")
!$ ELSE
!$OMP MASTER
!$ CALL mpi_init_thread(MPI_THREAD_FUNNELED, provided_tsl, ierr)
!$ IF (ierr /= 0) CALL mp_stop(ierr, "mpi_init_thread @ mp_world_init")
!$ IF (provided_tsl .LT. MPI_THREAD_FUNNELED) THEN
!$ CALL mp_stop(0, "MPI library does not support the requested level of threading (MPI_THREAD_FUNNELED).")
!$ END IF
!$OMP END MASTER
!$ END IF
CALL mpi_comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN, ierr)
IF (ierr /= 0) CALL mp_stop(ierr, "mpi_comm_set_errhandler @ mp_world_init")
mp_comm = MPI_COMM_WORLD
debug_comm_count = 1
#else
mp_comm = 0
#endif
CALL add_mp_perf_env()
END SUBROUTINE mp_world_init