      SUBROUTINE GETDATE(IO,ILINE,EXT,DATE)
      CHARACTER*(*) ILINE,EXT,IO
      CHARACTER*40 LINE
D     CHARACTER*40 TIME
      DOUBLE PRECISION DATE
      PARAMETER LMAX=200
      PARAMETER LOMAX=10
      COMMON/USEI/LSAVE(LMAX),SDATE(LMAX),LASTS,IOUTS(LOMAX)
      COMMON/USEL/LOUTS
      COMMON/USEC/FSAVE(LMAX)
      CHARACTER*40 FSAVE
      DOUBLE PRECISION SDATE
      L = LEN(ILINE)
      LINE = ILINE
      CALL CUPPER(LINE)
C     get true end of name
      DO 5 I = L , 1 , -1
         LL = I
         IF(LINE(LL:LL).NE.' ')GOTO 7
5     CONTINUE
7     L = LL
D     TYPE 100,' ORIGINAL LINE & EXT ',LINE(1:L),EXT
100   FORMAT(10A)
      LL = INDEX(LINE(L-3:L),'.')
D     TYPE *,'LL CAME OUT AS',LL
      IF(LL.EQ.0)THEN
         LINE = LINE(1:L)//EXT
         L = L + LEN(EXT)
      END IF
D     TYPE *,' FINAL LINE & EXT ',LINE(1:L),L
C     prepare to save output file name in case we execute
C     this line.
      DATE = 0.0
C     first, look it up in table
      IF(LASTS.EQ.0)GOTO 15
C     handle look up in LIFO order. it should be a bit faster.
      DO 10 I = LASTS,1,-1
         IS = I
         IF(LINE(1:L).EQ.FSAVE(I)(1:LSAVE(I)))GOTO 20
10    CONTINUE
15    CONTINUE
D     TYPE *,'THIS IS NOT A PREVIOUSLY SAVED FILE'
      CALL D_DATE(LINE(1:L),DATE)
      LASTS = LASTS + 1
D     TYPE *,'LASTS = ',LASTS
      IS = LASTS
      IF(IS.GT.LMAX)STOP 'FILENAME OVERFLOW IN USE'
      FSAVE(IS) = LINE(1:L)
      LSAVE(IS) = L
      SDATE(IS) = DATE
      GOTO 25
20    CONTINUE
C        we found the file in our table.
C        use date from table unless this is an output spec
C        this makes multiple LIBRs work right.
      IF(IO.EQ.'O')THEN
         CALL D_DATE(LINE(1:L),DATE)
      ELSE
         DATE = SDATE(IS)
      END IF
D     TYPE *,'THIS IS A PREVIOUSLY REFERENCED FILE'
25    CONTINUE
      IF(IO.EQ.'O')THEN
         LOUTS = LOUTS + 1
         IF(LOUTS.GT.LOMAX)STOP 'OUTFILE OVERFLOW IN USE'
         IOUTS(LOUTS) = IS
      END IF
D     CALL SYS$ASCTIM(,TIME,DATE,)
D     TYPE *,'DATE IS ',TIME,' OR ',DATE
      RETURN
      END
      SUBROUTINE UPDATE
      IMPLICIT INTEGER*4 (S)
      PARAMETER LMAX=200
      PARAMETER LOMAX=10
      COMMON/USEI/LSAVE(LMAX),SDATE(LMAX),LASTS,IOUTS(LOMAX)
      COMMON/USEL/LOUTS
      COMMON/USEC/FSAVE(LMAX)
      CHARACTER*40 FSAVE
      DOUBLE PRECISION SDATE
      CHARACTER*40 TIME
C     change date of recently saved output files to present.
D     TYPE *,'CALL TO CLRDATE'
      IF(LOUTS.LE.0)RETURN
D     TYPE *,'THERE WERE SOME OUTPUT FILES TO CHANGE'
      I = SYS$BINTIM('-- ::.',SDATE(LASTS))
D     TYPE *,'RESULT OF CALL TO BINTIM'
D     CALL ERRMES(I)
      K = IOUTS(1)
      CALL SYS$ASCTIM(,TIME,SDATE(K),)
D     TYPE *,'THE CURRENT ASCII TIME IS ',TIME
      DO 20 J = 1 , LOUTS
         I = IOUTS(J)
         SDATE(I) = SDATE(K)
D        TYPE *,'CHANGED DATE OF ',FSAVE(I)(1:LSAVE(I)),' TO ',TIME
20    CONTINUE
      RETURN
      END
