C
C SUBROUTINE 'TPROMP'
C ===================
C
C Output a text prompt to the terminal (and log file if required); if possible
C do not output a carriage return or linefeed after the prompt. If the
C given prompt string has trailing spaces then remove all but one of these
C when outputting the prompt to the terminal.
C
      SUBROUTINE TPROMP (STR)
C
C Parameters:
C
C      STR (I)   Character string to be output
C
C====== Specification statements
C
      CHARACTER*(*) STR
      LOGICAL LOG
      COMMON /TTCOMN/ LUNR, LUNW, LUNLR, LUNLW, MODETT, LOG
      SAVE /TTCOMN/
C
C====== Output string
C
      IF (MODETT.EQ.0) THEN
         LL = LEN(STR)
         DO 100 L=LL,1,-1
            IF (STR(L:L).NE.' ') GO TO 120
100      CONTINUE
         L=0
120      L = L + 1
         IF (L.GT.LL) L = LL
         IF (LUNW.GT.0) CALL TTSEND (LUNW, STR(1:L), 0)
      ENDIF
      IF (LOG.AND.LUNLW.GT.0) THEN
         LL = LEN(STR)
         DO 200 L=LL,1,-1
            IF (STR(L:L).NE.' ') GO TO 220
200      CONTINUE
         L=1
220      WRITE (LUNLW,1001) STR(1:L)
      ENDIF
      RETURN
C
C====== Format statements
C
1001  FORMAT (A)
      END
