	SUBROUTINE DCD(SS,L,ARRAY,NIN)
C
C		Version 2, D. Gudehus, April 3, 1999
C		Eliminated 43 GO TO statements, added DCD_INITIALIZE,
C		and changed "0 to '0'O.
C		Version 2UM, D. Gudehus, January 31, 2005
C		Modified variable format statement for Absoft compiler
C		on Mac OS.
C
	DIMENSION SS(L)
	BYTE SS
	CHARACTER*1 FMT(300)
	CHARACTER*40 VFORMAT
	LOGICAL REAL,CHAR,SIGN,EPOW,SEP
	REAL*8 ARRAY(NIN),ENDLN
	EQUIVALENCE(ENDLN,ENDL)
C
 100	FORMAT('A',I1,',')
C 101	FORMAT(I<NPOS>,'X,')
C 102	FORMAT('F',I<NPOS>,'.',I<NPOSD>,',')
 101	FORMAT('(I',I1,' ''X,'')') !  For the Absoft compiler
 102	FORMAT('(''F'',I',I1,',''.'',I',I1,','','')')
	CALL DCD_INITIALIZE(REAL,EPOW,SIGN,CHAR,SEP,IPOINT,IEPOW,ISIGN)
	I=1
	NOUT=0
	FMT(1)='('
	IFMT=2
	N1=1
	J=SETEND(ENDL)  ! Initializes the end-of-array indicator
	DO IARR=1,NIN
	  ARRAY(IARR)=ENDLN
	END DO
C
	DO WHILE(SS(I).NE.'0'O.AND.I.LE.L.AND.NOUT.LT.NIN)
	  IF (SS(I).EQ.' '.OR.SS(I).EQ.',') THEN
	    IF (.NOT.SEP) THEN
	      LF=I-N1
	      IF (CHAR) THEN
	        LF=MIN(((NIN-NOUT)*8),LF)
	        DO WHILE (LF.GT.0)
	          ENCODE(3,100,FMT(IFMT)) MIN(8,LF)
	          LF=LF-8
	          IFMT=IFMT+3
	          NOUT=NOUT+1
	        END DO
	      ELSE
	        IF (IEPOW.EQ.0) IEPOW=I
	        IF (IPOINT.EQ.0) IPOINT=I
	        LD=MAX((IEPOW-IPOINT-1),0)
	        NPOS=IFIX(LOG10(FLOAT(LF)))+1
	        NPOSD=IFIX(LOG10(FLOAT(MAX(LD,1))))+1
	        WRITE(VFORMAT,102) NPOS,NPOSD
	        ENCODE(NPOS+NPOSD+3,VFORMAT,FMT(IFMT)) LF,LD
	        IFMT=IFMT+NPOS+NPOSD+3
	        NOUT=NOUT+1
	      END IF
	      N1=I
	      CALL DCD_INITIALIZE(REAL,EPOW,SIGN,CHAR,SEP,IPOINT,IEPOW,ISIGN)
	    END IF
	    GO TO 12001
	  END IF
C
	  IF (SEP) THEN
	    LF=I-N1
	    IF (LF.GT.0) THEN
	      NPOS=IFIX(LOG10(FLOAT(LF)))+1
	      WRITE(VFORMAT,101) NPOS
	      ENCODE(NPOS+2,VFORMAT,FMT(IFMT)) LF
	      IFMT=IFMT+NPOS+2
	    END IF
	    N1=I
	    IF ((SS(I).GE.'0'.AND.SS(I).LE.'9')
	1   .OR.SS(I).EQ.'+'.OR.SS(I).EQ.'-') THEN
	      REAL=.TRUE.
	    ELSE
	      IF (SS(I).EQ.'.') THEN
	        REAL=.TRUE.
	        IPOINT=I
	      ELSE
	        CHAR=.TRUE.
	      END IF
	    END IF
	    SEP=.FALSE.
	  ELSE
	    IF (.NOT.CHAR) THEN
	      IF (EPOW) THEN
	        IF (.NOT.SIGN) THEN
	          IF (SS(I).EQ.'+'.OR.SS(I).EQ.'-') THEN
	            ISIGN=1
	            SIGN=.TRUE.
	          ELSE
	            IF (SS(I).GE.'0'.AND.SS(I).LE.'9') THEN
	              SIGN=.TRUE.
	            ELSE
	              CHAR=.TRUE.
	            END IF
	          END IF
	        ELSE 
	          IF (SS(I).LT.'0'.OR.SS(I).GT.'9'.OR.((IEPOW+ISIGN+2).LT.I))
	1         CHAR=.TRUE.
	        END IF
	      ELSE
	        IF (SS(I).EQ.'E') THEN
	          EPOW=.TRUE.
	          IEPOW=I
	        ELSE
	          IF (SS(I).EQ.'.') THEN
	            IF (IPOINT.GT.0) THEN
	              CHAR=.TRUE.
	            ELSE
	              IPOINT=I
	            END IF
	          ELSE
	            IF (SS(I).LT.'0'.OR.SS(I).GT.'9') CHAR=.TRUE.
	          END IF
	        END IF
	      END IF
	    END IF
	  END IF
12001	  CONTINUE
	  I=I+1
	END DO
C
	IF (I.GT.N1) THEN
	  IF (.NOT.SEP) THEN
	    LF=I-N1
	    IF (CHAR) THEN
	      LF=MIN(((NIN-NOUT)*8),LF)
	      DO WHILE (LF.GT.0)
	        ENCODE(3,100,FMT(IFMT)) MIN(8,LF)
	        LF=LF-8
	        IFMT=IFMT+3
	        NOUT=NOUT+1
	      END DO
	    ELSE
	      IF (IEPOW.EQ.0) IEPOW=I
	      IF (IPOINT.EQ.0) IPOINT=I
	      LD=MAX((IEPOW-IPOINT-1),0)
	      NPOS=IFIX(LOG10(FLOAT(LF)))+1
	      NPOSD=IFIX(LOG10(FLOAT(MAX(LD,1))))+1
	      WRITE(VFORMAT,102) NPOS,NPOSD
	      ENCODE(NPOS+NPOSD+3,VFORMAT,FMT(IFMT)) LF,LD
	      IFMT=IFMT+NPOS+NPOSD+3
	      NOUT=NOUT+1
	    END IF
	    N1=I
	    CALL DCD_INITIALIZE(REAL,EPOW,SIGN,CHAR,SEP,IPOINT,IEPOW,ISIGN)
	  END IF
	END IF
	FMT(IFMT-1)=')'
	IF (NOUT.GT.0) DECODE(L,FMT,SS) (ARRAY(J),J=1,NOUT)
	RETURN
C
	END
C
C
	SUBROUTINE DCD_INITIALIZE(REAL,EPOW,SIGN,CHAR,SEP,IPOINT,
	1IEPOW,ISIGN)
C
	LOGICAL REAL,CHAR,SIGN,EPOW,SEP
C
	REAL=.FALSE.
	EPOW=.FALSE.
	SIGN=.FALSE.
	CHAR=.FALSE.
	SEP=.TRUE.
	IPOINT=0
	IEPOW=0
	ISIGN=0
C
	RETURN
	END	
