        SUBROUTINE CTOD2(S,N,I,R)
C
C               T.J. PEARSON 1979 JUN 4  VAX/VMS FORTRAN 4
C               MODIFIED 1989 MAY 26  CONVERT FR. FUNC. TO SUBROUTINE
C               EVALUATE INTEGER AT S(I); INCREMENT I
C               RETURN AS REAL*8
C
        INTEGER*4 N,I
        REAL*8    R
        INTEGER*2 S(N),DIGITS(10)
        CHARACTER*2 CDIGIT(10)
        EQUIVALENCE (CDIGIT(1),DIGITS(1))
        DATA      CDIGIT/'0','1','2','3','4','5','6','7','8','9'/
C
        R=0D0
   10   IF(I.GT.N) RETURN
        DO 20 K=1,10
        IF(S(I).EQ.DIGITS(K)) GOTO 30
   20   CONTINUE
        RETURN
   30   R=R*10D0 + (K-1)
        I=I+1
        GOTO 10
        END

