ReleaseMPI Subroutine

public subroutine ReleaseMPI(ownsMpi, rankId, nRanks)

Retire one decomposition from the process-wide lifecycle bookkeeping and, if it was the last one and SELF initialized MPI, finalize.

Shared by the CPU and GPU DomainDecomposition Free implementations.

Arguments

TypeIntentOptionalAttributesName
logical, intent(inout) :: ownsMpi
integer, intent(in) :: rankId
integer, intent(in) :: nRanks

Calls

proc~~releasempi~~CallsGraph proc~releasempi ReleaseMPI mpi_finalized mpi_finalized proc~releasempi->mpi_finalized mpi_finalize mpi_finalize proc~releasempi->mpi_finalize

Called by

proc~~releasempi~~CalledByGraph proc~releasempi ReleaseMPI proc~free_domaindecomposition_t Free_DomainDecomposition_t proc~free_domaindecomposition_t->proc~releasempi proc~free_domaindecomposition Free_DomainDecomposition proc~free_domaindecomposition->proc~releasempi

Contents

Source Code


Source Code

  subroutine ReleaseMPI(ownsMpi,rankId,nRanks)
  !! Retire one decomposition from the process-wide lifecycle bookkeeping and,
  !! if it was the last one and SELF initialized MPI, finalize.
  !!
  !! Shared by the CPU and GPU DomainDecomposition Free implementations.
    implicit none
    logical,intent(inout) :: ownsMpi
    integer,intent(in) :: rankId
    integer,intent(in) :: nRanks
    ! Local
    integer :: ierror
    logical :: mpiIsFinalized

    ownsMpi = .false.
    nLiveDecomps = max(nLiveDecomps-1,0)

    ! Other meshes are still live; they need MPI to stay up.
    if(nLiveDecomps > 0) return

    call MPI_Finalized(mpiIsFinalized,ierror)
    if(selfInitializedMpi .and. .not. mpiIsFinalized) then
      print*,__FILE__," : Rank ",rankId+1,"/",nRanks," checking out."
      call MPI_FINALIZE(ierror)
    endif
    selfInitializedMpi = .false.

  endsubroutine ReleaseMPI