logical function flag_trmpi(ictrl)

  use trmpi
  implicit NONE

  ! return MPI status:
  !   if(ictrl.eq.0) -- return:  trmpi_active
  !   if(ictrl.eq.1) -- return:  trmpi_active.OR.(trmpi_numprocs.gt.1)

  !      flag_trmpi(0) .TRUE. denotes a run that uses MPI directly.
  !      flag_trmpi(1) .TRUE. denotes a run that uses MPI either directly
  !            or through subprocess initiation.


  integer, intent(in) :: ictrl

  call trmpi_check('flag_trmpi')

  if(ictrl.eq.1) then

     flag_trmpi = trmpi_active .OR. (trmpi_numprocs.gt.1)

  else

     flag_trmpi = trmpi_active

  endif

end function flag_trmpi
