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.


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


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


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
      !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

    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.
      proc%isRoot = .false.
    end if

  end subroutine tem_comm_env_init