C LAST UPDATE: 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C**************************
C**    LDM_OPFUN         **
C**************************
C
C
      SUBROUTINE LDM_OPFUN
C
      INCLUDE 'implicit_none.finc'
C
C Purpose: Output string for LDM extended (KDM) parameters
C
C Author:  John W. Campbell, December 1995
C
C **** LDM SERVICE ROUTINE ONLY ****
C
C
C Arguments:
C
C      None
C
C====== Parameter statements
C 

C
C====== GLOBALS:
C
      INCLUDE 'ldm_data.finc'
      INCLUDE 'ldm_extended.finc'
      EXTERNAL LDM_BDAT
C
C====== FUNCTION TYPES:
C
      INTEGER LENSTR
      INTEGER NXTTOK
C
C====== LOCALS:
C
      LOGICAL TERM
      INTEGER IUN
      INTEGER I
      INTEGER IL
      INTEGER M1
      INTEGER M2
      INTEGER MFIRST
      INTEGER MFINAL
      INTEGER LEN
      INTEGER LL
      INTEGER LOK
      CHARACTER*1 ICH
C
C-------------------------------------------------------------------------------
C
      IF (KUNIT.GT.0) THEN
         IUN = KUNIT
         TERM = .FALSE.
      ELSE
         IUN = -KUNIT
         TERM = .TRUE.
      END IF
C
C====== All on one line
C
      IF (LENSTR(OUTSTR).LE.80) THEN
         IF (TERM) THEN
            CALL TTSEND (IUN, OUTSTR(1:LENSTR(OUTSTR)), 1)
         ELSE
            WRITE(IUN,1000) OUTSTR(1:LENSTR(OUTSTR))
         END IF
      ELSE
C
C====== Split up line with continuations
C
         IL = 0
         MFIRST = 0
         MFINAL = 0 
         LEN = LENSTR(OUTSTR)
 100     I = NXTTOK (OUTSTR, ' ', IL, M1, M2)
         IF (I.LE.0) THEN
            IF (MFINAL.GT.0) THEN
               IF (TERM) THEN
                  CALL TTSEND (IUN,OUTSTR(MFIRST:MFINAL),1)
               ELSE
                   WRITE(IUN,1000) OUTSTR(MFIRST:MFINAL)
               END IF
            END IF
            RETURN
         END IF
         IF (MFIRST.EQ.0) MFIRST = M1
         LL = M2 - MFIRST + 1
         LOK = 79
         IF (M2.EQ.LEN) LOK = 80
         IF (LL.GT.LOK) THEN
            IF (MFINAL.EQ.0) THEN
               MFINAL = M2
            ELSE
               ICH = OUTSTR(MFINAL+1:MFINAL+1)
               OUTSTR(MFINAL+1:MFINAL+1) = '-'
               OUTSTR(MFINAL+1:MFINAL+1) = ICH
               MFIRST = M1
               MFINAL = M2
            END IF
         ELSE
            MFINAL = M2
         END IF
         GO TO 100
      END IF

      RETURN
C
C====== Format statements
C
1000  FORMAT (A)
      END
