C
C Terminal read/write routines.
C
C The following external routines are currently used:
C
C                       TTSEND (Machine dependent)
C
C
C SUBROUTINE 'TRWSET'
C ===================
C
C Set options for the remaining routines in 'tsubs'.
C
C Should be called before any of the other routines are used especially
C for portability.
C
      SUBROUTINE TRWSET (IN, IOUT, LOGR, LOGW, MODE)
C
C Parameters:
C
C         IN (I)    Unit number for terminal reads (normally standard input
C                   stream) (0 if none)
C       IOUT (I)    Unit number for terminal writes (normally standard
C                   output stream) (0 if none)
C      LOGR  (I)    Echo input to logfile on unit LOGR (0 if no logging)
C      LOGW  (I)    Echo output to logfile on unit LOGW (0 if no logging)
C      MODE  (I)    Mode flag  = 0, Normal terminal input and output
C                              Other values reserved for future use e.g.
C                              for X-windows perhaps
C
C====== Specification statements
C
      LOGICAL LOG
      COMMON /TTCOMN/ LUNR, LUNW, LUNLR, LUNLW, MODETT, LOG
      SAVE /TTCOMN/
C
C====== Set units
C
      IF (MODE.EQ.0) THEN
         LUNR = IN
         LUNW = IOUT
      ENDIF
      LUNLR = LOGR
      LUNLW = LOGW
      MODETT = MODE
      LOG = .TRUE.
      RETURN
      END
