pic_mpi_init Subroutine

public subroutine pic_mpi_init(requested_thread_level, provided_thread_level)

Initialize MPI environment with optional threading support

If no thread level is requested, uses MPI_THREAD_FUNNELED by default to allow OpenMP threading in compute_mbe_energy and similar functions.

Thread levels: MPI_THREAD_SINGLE: No threading support MPI_THREAD_FUNNELED: Only main thread makes MPI calls (good for OpenMP) MPI_THREAD_SERIALIZED: Multiple threads can make MPI calls, but not simultaneously MPI_THREAD_MULTIPLE: Full thread safety

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in), optional :: requested_thread_level
integer(kind=int32), intent(out), optional :: provided_thread_level

Variables

Type Visibility Attributes Name Initial
integer(kind=int32), private :: ierr
integer(kind=int32), private :: provided
integer(kind=int32), private :: requested

Source Code

   subroutine pic_mpi_init(requested_thread_level, provided_thread_level)
      !! Initialize MPI environment with optional threading support
      !!
      !! If no thread level is requested, uses MPI_THREAD_FUNNELED by default
      !! to allow OpenMP threading in compute_mbe_energy and similar functions.
      !!
      !! Thread levels:
      !!   MPI_THREAD_SINGLE: No threading support
      !!   MPI_THREAD_FUNNELED: Only main thread makes MPI calls (good for OpenMP)
      !!   MPI_THREAD_SERIALIZED: Multiple threads can make MPI calls, but not simultaneously
      !!   MPI_THREAD_MULTIPLE: Full thread safety
      integer(int32), intent(in), optional :: requested_thread_level
      integer(int32), intent(out), optional :: provided_thread_level
      integer(int32) :: ierr, requested, provided

      ! Default to FUNNELED for OpenMP compatibility
      ! No MPI to start. A serial build is always as
      ! thread-safe as it is ever going to be.
      if (present(provided_thread_level)) provided_thread_level = MPI_THREAD_MULTIPLE
   end subroutine pic_mpi_init