      SUBROUTINE ELPSTIME(START,TIME,DAYS)
C
C THIS ROUTINE COMPUTES A POSITIVE ELAPSED TIME BETWEEN TWO INTEGER
C ARRAYED TIME VALUES WHERE:
C
C   TIME ELEMENT 1 = YEAR
C   TIME ELEMENT 2 = DAY
C   TIME ELEMENT 3 = HOUR
C   TIME ELEMENT 4 = MINUTE
C   TIME ELEMENT 5 = SECOND
C   TIME ELEMENT 6 = MILLISECOND
C
      INTEGER*2 START(6),TIME(6)
      REAL*8 DAYS,REALTIME
C
C TEST FOR PROPER INPUT.  2 DIGIT YEAR EXPECTED (LESS THAN 77 ASSUMED 21ST
C CENTURY)
C
      IF ((MOD(START(1),4).EQ.0.AND.
     &     START(2).GT.366).OR.
     &    (MOD(START(1),4).NE.0.AND.
     &     START(2).GT.365).OR.
     &    START(1).GT.99.OR.
     &    START(3).GT.23.OR.
     &    START(4).GT.59.OR. 
     &    START(5).GT.59.OR.
     &    START(6).GT.999.OR.
     &    START(1).LT.0.OR.
     &    START(2).LT.1.OR.
     &    START(3).LT.0.OR.
     &    START(4).LT.0.OR.
     &    START(5).LT.0.OR.
     &    START(6).LT.0) THEN
       WRITE(6,'(1X,''*ELPSTIME*  INVALID START TIME: '',
     &       I2,''-'',I3.3,''/'',I2.2,'':'',I2.2,'':'',
     &       I2.2,''.'',I3.3)') START
       DAYS = -1.0D0
       RETURN
      END IF
C
      IF ((MOD(TIME(1),4).EQ.0.AND.
     &     TIME(2).GT.366).OR.
     &    (MOD(TIME(1),4).NE.0.AND.
     &     TIME(2).GT.365).OR.
     &    TIME(1).GT.99.OR.
     &    TIME(3).GT.23.OR.
     &    TIME(4).GT.59.OR. 
     &    TIME(5).GT.59.OR.
     &    TIME(6).GT.999.OR.
     &    TIME(1).LT.0.OR.
     &    TIME(2).LT.1.OR.
     &    TIME(3).LT.0.OR.
     &    TIME(4).LT.0.OR.
     &    TIME(5).LT.0.OR.
     &    TIME(6).LT.0) THEN
       WRITE(6,'(1X,''*ELPSTIME*  INVALID CURRENT TIME: '',
     &       I2,''-'',I3.3,''/'',I2.2,'':'',I2.2,'':'',
     &       I2.2,''.'',I3.3)') TIME
       DAYS = -1.0D0
       RETURN
      END IF
C
      DAYS = DBLE(START(2)) + 
     &       DBLE(START(3))/24.0D0 +
     &       DBLE(START(4))/24.0D0/60.0D0 +
     &       DBLE(START(5))/24.0D0/60.0D0/60.0D0 +
     &       DBLE(START(6))/24.0D0/60.0D0/60.0D0/1000.0D0
      DAYS = - DAYS
C
C CONVERT YEARS DIFFERENCE INTO DECIMAL DAYS
C
      IF (TIME(1).LT.77) THEN
       ICENT = 100
      ELSE
       ICENT = 0
      END IF
C
      DO I = START(1), TIME(1) - 1 + ICENT
C
       IF (MOD(I,4).EQ.0) THEN
        DAYS = DAYS + 366.0D0
       ELSE 
        DAYS = DAYS + 365.0D0
       END IF
C
      END DO
C
C ADD DECIMAL DAYS OF CURRENT YEAR TO SUM
C
      DAYS = DAYS +
     &       DBLE(TIME(2)) + 
     &       DBLE(TIME(3))/24.0D0 +
     &       DBLE(TIME(4))/24.0D0/60.0D0 +
     &       DBLE(TIME(5))/24.0D0/60.0D0/60.0D0 +
     &       DBLE(TIME(6))/24.0D0/60.0D0/60.0D0/1000.0D0
C
      RETURN
      END
