      function SECOND()
      double precision SECOND
      include 'MOP6FILE'
C******************************************************
C
C   SECOND, ON EXIT, CONTAINS THE NUMBER OF CPU SECONDS
C   SINCE THE START OF THE CALCULATION.
C
C******************************************************
      logical SETOK, alive
      character*1 X, GETNAM*80
      dimension A(2)
      save SETOK, SHUT
      data SETOK   /  .TRUE.    /, SHUT/0.D0/



      DOUBLE PRECISION CPU0,WALL0,CPU,WALL,TIM,ADDDAY
      LOGICAL FIRST
      CHARACTER *8 RTIME
      SAVE FIRST,CPU0,WALL0,IDAY,ADDDAY
      DATA FIRST/.TRUE./
      DATA ADDDAY /0.0d0/
      IF(FIRST) THEN
         FIRST=.FALSE.
         CALL TIME(RTIME)
         read(RTIME,'(i2,1x,i2,1x,i2)') IH,IM,IS
         WALL0 = IH*3600d0 + IM*60d0 + IS
         CPU0 =  WALL0
c
c         we have to remember the day when the clock started to tick
c
      CALL IDATE (MONTH,IDAY,IYEAR)
c
      END IF
C
      CALL TIME(RTIME)
      read(RTIME,'(i2,1x,i2,1x,i2)') IH,IM,IS
      WALL = IH*3600d0 + IM*60d0 + IS
C
C     WE HAVE TO CHECK WHETHER THE DATE DID NOT CHANGE
C
      CALL IDATE(MONTH,JDAY,IYEAR)
C
      IF ( JDAY.NE.IDAY) THEN
        IDAY = JDAY
        ADDDAY = ADDDAY+86400.0
      END IF
C
      WALL = WALL + ADDDAY
      WALL = WALL-WALL0
      CPU =  WALL



C
C   IF YOU ARE NOT USING A VAX OR A UNIX COMPUTER, UNCOMMENT THE
C   NEXT LINE
c
c     CPU = MCLOCK()*1.0d-2   ! let us be as accurate as we can
c                           ! under the circumstances
c    CPU=0.0
C
C   IF YOU ARE NOT USING A VAX OR A UNIX COMPUTER, REMOVE THE NEXT LINE
c      Y=ETIME(A)       I am running supposedly a UNIX computer
c      CPU=A(1)         but I will gladly kill this lines anyway (J/M)
***********************************************************************
*
*   NOW TO SEE IF A FILE LOGIcallY CALLED SHUTDOWN EXISTS, IF IT DOES
*   THEN INCREMENT CPU TIME BY 1,000,000 SECONDS.
*
************************************************************************
      inquire(file=GETNAM('SHUTDOWN'),exist=alive)  ! J/M Aug. 1991
c
*
*          FILE EXISTS, THEREFORE INCREMENT TIME
*
      if (alive) then
*
*      first some cover-up operation is to be performed
*
       open(UNIT=MIOL,file=GETNAM('SHUTDOWN'),status='OLD') ! grab SHUTDOWN
*
       close(UNIT=MIOL,status='DELETE') ! and kill it without mercy
*                                    ! Hey! any proofs ?
       SHUT=1.D6
        if ( SETOK) then
         write(MIOB,
     %     '(///10X,''****   JOB STOPPED BY OPERATOR   ****'')')
         SETOK=.FALSE.
        end if
      end if
c
      SECOND=CPU+SHUT
      close (unit=MIOL)
      return
      end
