C---------------------------------------------------------------------
C  URWRDL  -- TRANSFER AN INPUT WORD; PROCESS DBL QUOTES
C
C  THERE ARE NO LEADING AND TRAILING BLANKS IN THE WORD, BUT THERE
C  MAY BE QUOTATION MARKS-- STRIP THESE OFF
C
      SUBROUTINE URWRDL(WORD1,WORD2,IW2)
C
      INCLUDE 'USERIO'
C
      CHARACTER*(*) WORD1,WORD2
C
C  WORD1  -- INPUT WORD **WITH NO LEADING OR TRAILING BLANKS**;
C            DBL QUOTE STRING IF FIRST CHARACTER IS '"'
C
C  WORD2  -- OUTPUT WORD, PAD WITH BLANKS
C  IW2    -- LAST NONBLANK CHAR IN WORD2 (OUTPUT)
C
C   TRUNCATION IS AN ERROR!
C
      ILW1=LEN(WORD1)
      ILW2=LEN(WORD2)
C
      IW1=0
      IW2=0
C
      ITRUNC=0
C
      IERR=0
C
      IF((WORD1(1:1).NE.'"').OR.(WORD1(ILW1:ILW1).NE.'"')) THEN
        IW1=MIN0(ILW1,ILW2)
        IW2=IW1
        WORD2(1:IW2)=WORD1(1:IW1)
        IF(IW2.LT.ILW1) ITRUNC=1
      ELSE
C  PROCESS QUOTE STRING; 2 CONSECUTIVE DBL QUOTES RETURNED AS ONE
        IW1=1
        IEVEN=0
C
 10     CONTINUE
        IW1=IW1+1
        ICOPY=0
        IF(WORD1(IW1:IW1).NE.'"') THEN
          IF(IW1.EQ.ILW1) IERR=1
          ICOPY=1
        ELSE
          IF(IW1.EQ.ILW1) GO TO 30
          IEVEN=1-IEVEN
          IF(IEVEN.EQ.1) THEN
            IWP1=IW1+1
            IF(WORD1(IWP1:IWP1).NE.'"') IERR=1
          ELSE
C  TRANSFER DBL QUOTE PAIR AS SINGLE DBL QUOTE
            ICOPY=1
          ENDIF
        ENDIF
C
        IF(ICOPY.EQ.1) THEN
          IW2=IW2+1
          IF(IW2.LE.ILW2) THEN
            WORD2(IW2:IW2)=WORD1(IW1:IW1)
          ELSE
            ITRUNC=1
          ENDIF
        ENDIF
C
        IF(IW1.LT.ILW1) GO TO 10
C
      ENDIF
C
 30   CONTINUE
C
      IF(IERR.EQ.1) THEN
        WRITE(LUNTRM,9999) WORD1
 9999 FORMAT(' %UREAD (URWRDL) ERROR PARSING QUOTE STRING:  '/1X,A)
        CALL UPAUST(0)
      ELSE IF(ITRUNC.EQ.1) THEN
        WRITE(LUNTRM,9901) WORD1,WORD2
 9901 FORMAT(' ?URWRDL(CDCOD/UREAD)-- WORD ["',A,'"]'/
     >       1X,'TRUNCATED TO ["',A,'"]')
        CALL UPAUST(0)
      ENDIF
C
C  PAD OUTPUT WORD WITH BLANKS
      IF(IW2.LT.ILW2) THEN
        DO 40 IC=IW2+1,ILW2
          WORD2(IC:IC)=' '
 40     CONTINUE
      ENDIF
C
      RETURN
C
      END
