!-----------------------------------------------------------------
!  trmpi module -- TRansp MPI -- support MPI version of TRANSP
!  This module contains (a) MPI PARAMETER definitions; (b) data elements
!  trmpi_comm, etc.
!
!  see trmpi_init.f90:
!  initialization includes use of PORTLIB routines to
!    (a) distribute value of PREACTDIR and perhaps other environment variables
!    (b) place all rank processes in the same current working directory
!
!   see also the free standing routines:
!      tr_listener.f90
!      tr_requestor.f90
!
!  NOTE: this module should remain private to the trmpi library.
!  access from TRANSP or TRANSP support software should be indirect
!  through free standing subroutine calls ONLY.
!-----------------------------------------------------------------

module trmpi

#ifdef __MPI
  use mpi
#endif

  implicit NONE

  public
  save

  integer :: trmpi_lunmsg = 0     ! LUN for messages

  logical :: trmpi_active = .FALSE. ! .TRUE. if MPI is present, i.e. linked in
  integer :: trmpi_comm = 0         ! communicator (0 if MPI NOT present)

  integer :: trmpi_myid = 0       ! ID of this processor (0 if MPI NOT present)
  integer :: trmpi_numprocs = 0   ! #processors (1 if MPI NOT present)
  !  trmpi_numprocs can be reset if MPI available for subprocesses
  integer :: trmpi_nnbi = 0       ! #processors in NUBEAM group
  integer :: trmpi_ntor = 0       ! #processors in TORIC group
  integer :: trmpi_ncql = 0       ! #processors in CQL3D group
 integer :: trmpi_genray = 0       ! #processors in GENRAY group

  character*16 :: trmpi_runID = ' '  ! shared RUNID
  character*16 :: trmpi_codeID = '?' ! identify program

  integer :: trmpi_barrier_tag = 0   ! tag for BARRIER service
end module trmpi
