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


      SUBROUTINE MAINIY (IEID)
      PARAMETER(NEV = 1200)
      PARAMETER(NDATA = 30)
      PARAMETER(NDEP = 20)

      REAL MXREAL, MNREAL
      PARAMETER(MXREAL = 3E38,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
C     PTARR=POINTER IN THE DATA ARRAY

      COMMON/TIMEAR/TIMAR
      REAL TIMAR(NEV,NDATA)
C     INDEX IN THE PTARR THAT GIVES THE POSITION IN THE DATA
C     ARRAY TIMAR AND ALSO  IN THE STACK ARRAY
C     STACKS FOR NONINCLUSIVE DURATIONS 
C     THE STACKPOINTER IS IN PTAR AT THE CORRESPONDING LOCATION
C     AT EACH LEVEL WE HAVE THE STORED THE EVENT_ID
      COMMON/STACKS/STK
      INTEGER STK(NDEP)
C
C     TIMING INFO ABOUT SBIN,SBOUT,DOOT,DOIN SUBS 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 TIM(3)

      INTEGER IEID

C     GET OVERHEAD TIMING DATA OF INSTRUMENTATION
      CALL OVTIM()

C     INITIALIZE ALL DATA STRUCTURES
      PTARR = 0

       DO 2 I=1,NEV
          DO 400 K=1,13
             TIMAR(I,K)=0.
 400      CONTINUE
          DO 410 K=18,30
             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
      
      TIMAR( IEID, 3) = TIMAR( IEID, 3) + 1.


C     UPDATE STACK:
C     INCREASE CALLING DEPTH COUNTER IN PTARR
      PTARR = PTARR + 1
C     PUSH IEID  ON STACK 
      STK(PTARR) = IEID

C     RECORD THE ENTRY TIME IN THE DATA ARRAY TIMAR

      CALL FUNTIM(TIM)

      TIMAR( IEID, 1) = TIM(1)
      TIMAR( IEID, 2) = TIM(2)

      RETURN
      END
