C (c) 1991 The Board of Trustees of the University of Illinois
C          "All Rights Reserved Under the Copyright Laws".


      SUBROUTINE OVTIM()
      PARAMETER(NEV=1200)
      PARAMETER(NDATA = 30)
      PARAMETER(NDEP = 20)

      REAL MXREAL,MNREAL
      PARAMETER(MXREAL = 3.4E+38,MNREAL = 0.)
C     NEV = NUMBER  OF EVENTS
C     NDATA = NUMBER OF DATA RECORDED FOR EACH  EVENT.
C     NDEP = DEPTH OF CALL NESTING
      COMMON/PTRAR/PTARR
      INTEGER  PTARR

      COMMON/TIMEAR/TIMAR
      REAL TIMAR(NEV, NDATA)

      COMMON/STACKS/STK
      INTEGER STK(NDEP)

C     TIMING INFO ABOUT SBIN,SBOUT,DOOT,DOIN SUBS,EMPTY CALL OVERHEAD

      COMMON/OVHEAD/SB(3),SBMIN(3),SBMAX(3),SBDIF(3),DOV(3), DOVMIN(3),
     $     DOVMAX(3),DOVDIF(3),COV(3),COVMIN(3),COVMAX(3),COVDIF(3),
     $     FTOV(3),FTOVMN(3),FTOVMX(3),FTOVDF(3)
      REAL SUM1,SUM2,SUM3,DELTA1(1000),DELTA2(1000),DELTA3(1000)
      REAL TIM1(3),TIM2(3)
C      DATA SBMIN,DOVMIN,COVMIN,FTOVMN /12*MXREAL/
C      DATA SBMAX,DOVMAX,COVMAX,FTOVMX /12*MNREAL/
      DATA SUM1,SUM2,SUM3 /3*0./

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C     THE THIRD ELEMENT OF SB,DOV,COV,TIM,TIM1,TIM2 (I.E. SB(3) ...
C     IS NOT USED UNDER THE PRESENT DEFINITION OF FUNTIM. IF FUNTIM
C     IS MOFIFIED THEN THIS ROUTINE SHOULD BE CHECKED TOO!!!
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
       DO 999 ISBMIN =1,3
       SBMIN(ISBMIN) = MXREAL  
       DOVMIN(ISBMIN) = MXREAL  
       COVMIN(ISBMIN) = MXREAL  
       FTOVMN (ISBMIN) = MXREAL  
       SBMAX(ISBMIN) = MNREAL  
       DOVMAX(ISBMIN) = MNREAL  
       COVMAX(ISBMIN) = MNREAL  
       FTOVMX (ISBMIN) = MNREAL  

 999      CONTINUE

         PTARR=0

       DO 2 I=1,NEV
          DO 400 K=1,13
             TIMAR(I,K)=0.
 400      CONTINUE
          DO 410 K=18,29
             TIMAR(I,K) = 0.
 410      CONTINUE
          DO 430 K=14,17
             TIMAR(I,K) = MXREAL
 430      CONTINUE
 2     CONTINUE

       DO 6 J=1,NDEP
          STK(J) = 0
 6     CONTINUE

       CALL FUNTIM(TIM1)
       CALL FUNTIM(TIM1)
       CALL FUNTIM(TIM1)

C     FUNTIM SUBROUTINE CALL OVERHEAD
      DO 10 I=1,1000
         CALL FUNTIM(TIM1)
         CALL FUNTIM(TIM2)
C     CPU
         DELTA1(I) = TIM2(1) - TIM1(1)
         FTOVMN(1) = MIN(FTOVMN(1),DELTA1(I))
         FTOVMX(1) = MAX(FTOVMX(1),DELTA1(I))
         SUM1 =SUM1 + DELTA1(I)

C     TOTAL = USER+SYSTEM FOR THIS DEFINITION OF FUNTIM
         DELTA2(I) = TIM2(2) - TIM1(2)
         FTOVMN(2) = MIN(FTOVMN(2),DELTA2(I))
         FTOVMX(2) = MAX(FTOVMX(2),DELTA2(I))
         SUM2 =SUM2 + DELTA2(I)

C     TOTAL = USER+SYSTEM
         DELTA3(I) = TIM2(3) - TIM1(3)
         FTOVMN(3) = MIN(FTOVMN(3),DELTA3(I))
         FTOVMX(3) = MAX(FTOVMX(3),DELTA3(I))
         SUM3 =SUM3 + DELTA3(I)

 10   CONTINUE

      FTOV(1) = SUM1/1000.
      FTOV(2) = SUM2/1000.
      FTOV(3) = SUM3/1000.

      SUM1=0.
      SUM2=0.
      SUM3=0.

      CALL EMPTY(98)
      CALL EMPTY(98)
      CALL EMPTY(98)

C     EMPTY CALL OVHEAD
      DO 20 I=1,1000
         CALL FUNTIM(TIM1)
         CALL EMPTY(98)
         CALL FUNTIM(TIM2)
C     CPU
         DELTA1(I) = TIM2(1) - TIM1(1) - FTOV(1)
         COVMIN(1) = MIN(COVMIN(1),DELTA1(I))
         COVMAX(1) = MAX(COVMAX(1),DELTA1(I))
         SUM1 =SUM1 + DELTA1(I)

C     TOTAL = USER+SYSTEM FOR THIS DEFINITION OF FUNTIM
         DELTA2(I) = TIM2(2) - TIM1(2) - FTOV(2)
         COVMIN(2) = MIN(COVMIN(2),DELTA2(I))
         COVMAX(2) = MAX(COVMAX(2),DELTA2(I))
         SUM2 =SUM2 + DELTA2(I)

C     TOTAL = USER+SYSTEM
         DELTA3(I) = TIM2(3) - TIM1(3) - FTOV(3)
         COVMIN(3) = MIN(COVMIN(3),DELTA3(I))
         COVMAX(3) = MAX(COVMAX(3),DELTA3(I))
         SUM3 =SUM3 + DELTA3(I)

 20   CONTINUE

      COV(1) = SUM1/1000.
      COV(2) = SUM2/1000.
      COV(3) = SUM3/1000.

      SUM1=0.
      SUM2=0.
      SUM3=0.

      DO 30 I=1,10
         CALL SBINY(97)
         CALL SBOUTY(98)
 30   CONTINUE


C     ACTUAL TIMING OF INSTRUMENTATION
C     FOR SBIN/SBOUT PAIR 
      CALL SBINY(3)

      DO 40 I=1,1000
         CALL FUNTIM(TIM1)
         CALL SBINY(97)
         CALL SBOUTY(98)
         CALL FUNTIM(TIM2)
C     CPU
         DELTA1(I) = TIM2(1) - TIM1(1) - FTOV(1)
         SBMIN(1) = MIN(SBMIN(1),DELTA1(I))
         SBMAX(1) = MAX(SBMAX(1),DELTA1(I))
         SUM1 =SUM1 + DELTA1(I)

C     TOTAL = USER+SYSTEM FOR THIS DEFINITION OF FUNTIM
         DELTA2(I) = TIM2(2) - TIM1(2) - FTOV(2)
         SBMIN(2) = MIN(SBMIN(2),DELTA2(I))
         SBMAX(2) = MAX(SBMAX(2),DELTA2(I))
         SUM2 =SUM2 + DELTA2(I)

C     TOTAL = USER+SYSTEM
         DELTA3(I) = TIM2(3) - TIM1(3) - FTOV(3)
         SBMIN(3) = MIN(SBMIN(3),DELTA3(I))
         SBMAX(3) = MAX(SBMAX(3),DELTA3(I))
         SUM3 =SUM3 + DELTA3(I)

 40   CONTINUE

      SB(1) = SUM1/1000.
      SB(2) = SUM2/1000.
      SB(3) = SUM3/1000.

C
      SUM1=0.
      SUM2=0.
      SUM3=0.

C     FOR DOENTRY/EXIT
      DO 50 I=1,10
         CALL DOINY(97)
         CALL DOOUTY(98)
 50   CONTINUE


      DO 60 I=1,1000
         CALL FUNTIM(TIM1)
         CALL DOINY(97)
         CALL DOOUTY(98)
         CALL FUNTIM(TIM2)
C     CPU
         DELTA1(I) = TIM2(1) - TIM1(1) - FTOV(1)
         DOVMIN(1) = MIN(DOVMIN(1),DELTA1(I))
         DOVMAX(1) = MAX(DOVMAX(1),DELTA1(I))
         SUM1 =SUM1 + DELTA1(I)

C     TOTAL = USER+SYSTEM FOR THIS DEFINITION OF FUNTIM
         DELTA2(I) = TIM2(2) - TIM1(2) - FTOV(2)
         DOVMIN(2) = MIN(DOVMIN(2),DELTA2(I))
         DOVMAX(2) = MAX(DOVMAX(2),DELTA2(I))
         SUM2 =SUM2 + DELTA2(I)

C     TOTAL = USER+SYSTEM
         DELTA3(I) = TIM2(3) - TIM1(3) - FTOV(3)
         DOVMIN(3) = MIN(DOVMIN(3),DELTA3(I))
         DOVMAX(3) = MAX(DOVMAX(3),DELTA3(I))
         SUM3 =SUM3 + DELTA3(I)

 60   CONTINUE

      DOV(1) = SUM1/1000.
      DOV(2) = SUM2/1000.
      DOV(3) = SUM3/1000.

C

      RETURN
      END

      SUBROUTINE EMPTY(INT)
      INTEGER INT
      RETURN
      END


