tem_comm_env_init Subroutine

public subroutine tem_comm_env_init(proc, comm)

Initialize the environment. This routine is called by tem_start which should be the very first action in a program.

Arguments

Type IntentOptional Attributes Name
type(tem_comm_env_type) :: proc

The process communicator type

integer, intent(in), optional :: comm

mpi communicator if it is predefined as in apesmate


Calls

proc~~tem_comm_env_init~~CallsGraph proc~tem_comm_env_init tem_comm_env_init mpi_comm_rank mpi_comm_rank proc~tem_comm_env_init->mpi_comm_rank mpi_comm_size mpi_comm_size proc~tem_comm_env_init->mpi_comm_size

Called by

proc~~tem_comm_env_init~~CalledByGraph proc~tem_comm_env_init tem_comm_env_init proc~tem_start tem_start proc~tem_start->proc~tem_comm_env_init

Contents

Source Code


Source Code

  subroutine tem_comm_env_init( proc, comm )
    ! --------------------------------------------------------------------------=
    !> The process communicator type
    type( tem_comm_env_type ) :: proc
    !> mpi communicator if it is predefined as in apesmate
    integer, intent(in), optional :: comm
    ! ---------------------------------------------------------------------------
    !> Error flag
    integer :: iError
    ! --------------------------------------------------------------------------

    proc%nThreads = 1
    !$ proc%nThreads = omp_get_max_threads()

    ! Init MPI rank, size and root
    ! if communicator is predefiend and passed use that one
    ! else default to mpi_comm_world
    if(present(comm)) then
      proc%comm = comm
    else
      !KM: with this call proc%comm must be freed by mpi_comm_free
      !so directly setting proc%comm = MPI_COMM_WORLD
      !call mpi_comm_dup( mpi_comm_world, proc%comm, iError )
      proc%comm = mpi_comm_world
    endif

    call mpi_comm_rank( proc%comm, proc%rank, iError )
    call mpi_comm_size( proc%comm, proc%comm_size, iError )
    proc%root = 0

    if ( proc%rank == proc%root ) then
      proc%isRoot = .true.
    else
      proc%isRoot = .false.
    end if

  end subroutine tem_comm_env_init