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


      SUBROUTINE DUMPY()
      PARAMETER(NEV=1200)
      PARAMETER(NDATA = 30)
      PARAMETER(NDEP = 20)
      PARAMETER(NPCODE = 13)

      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)
      
      CHARACTER*6 EVFILE(NPCODE)

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)

C     DEFINE THE FUNCTIONS TO BE CALLED 


C     CHAR ARRAY TO READ FILE EVNLST IN
      CHARACTER*(72) EVARR(NEV)
      INTEGER EVNUMS(NEV), NAMEV

      LOGICAL EX
      CHARACTER*(20) DATOUT, CH

      EVFILE(1) = 'APEVLS'
      EVFILE(2) = 'CSEVLS'
      EVFILE(3) = 'LGEVLS'
      EVFILE(4) = 'LWEVLS'
      EVFILE(5) = 'MTEVLS'
      EVFILE(6) = 'NAEVLS'
      EVFILE(7) = 'OCEVLS'
      EVFILE(8) = 'SDEVLS'
      EVFILE(9) = 'SMEVLS'
      EVFILE(10) = 'SREVLS'
      EVFILE(11) = 'TFEVLS'
      EVFILE(12) = 'TIEVLS'
      EVFILE(13) = 'WSEVLS'

      I=1
 10   CONTINUE
      WRITE(UNIT=DATOUT,FMT=15) I
 15   FORMAT('SMRY',I2.2)
      READ(UNIT=DATOUT,FMT=20) CH
 20   FORMAT (A)

C     IF FILE 'SMRYI' EXISTS THEN PUT IT IN SMRYI+1
      INQUIRE(FILE=CH,EXIST=EX,IOSTAT=IOSTAT,ERR=250)
C  .EQ. WAS NOT ALLOWED SO CHANGE IT 
      IF (EX) THEN
         I = I+1
         GOTO 10
      ENDIF

C     WRITE INSTRUMENTATION OVERHEAD
      OPEN(UNIT=1,FILE=CH)
      WRITE(1,170)  SB(1), SB(2)
      WRITE(1,171)  SBMIN(1), SBMIN(2)
      WRITE(1,172)  SBMAX(1), SBMAX(2)
      WRITE(1,175) DOV(1), DOV(2)
      WRITE(1,176) DOVMIN(1), DOVMIN(2)
      WRITE(1,177) DOVMAX(1), DOVMAX(2)
      WRITE(1,180) FTOV(1), FTOV(2)
      WRITE(1,181) FTOVMN(1), FTOVMN(2)
      WRITE(1,182) FTOVMX(1), FTOVMX(2)
      WRITE(1,140) '----------------------------------------------------
     $-------------------------------------------------------------'

      DO 999 I=1,NPCODE
      INQUIRE(FILE=EVFILE(I),EXIST=EX,IOSTAT=IOSTAT,ERR=260)
      IF (EX) THEN
      OPEN(UNIT=2,FILE=EVFILE(I),IOSTAT = IOSTAT)
      GOTO 991
      ENDIF
 999  CONTINUE
      GOTO 260
 991  I=1
 22   CONTINUE
      READ(2,23,ERR=270,END = 25) EVNUMS(I),EVARR(I)
      I = I+1
      GOTO 22
C     CHANGE THE FORMAT STATEMENT
 23   FORMAT(I4,A)
 25   CONTINUE


      DO 30 I=1,NEV,2
         IF (TIMAR(I,3) .NE. 0.) GOTO 36
         GOTO 30
 36      CONTINUE
         
         DO 400 IJ=1,NEV
            IF (EVNUMS(IJ) .EQ. I) THEN
               NAMEV=IJ
               GOTO 410
            ENDIF
 400     CONTINUE
         PRINT *, 'ERROR: COULD NOT FIND EVENTNUM FROM EVNLST'
 410     CONTINUE
         WRITE(1,100) 'EVENT',I,EVARR(IJ)
C         WRITE(1,100) 'EVENT',I

         WRITE(1,150)  INT(TIMAR(I,3))
C     CPU TIME
            WRITE(1,160) 'TIME','TIME_SQUARE'
            WRITE(1,110) 'SUM_INCL','SUM_EXCL','MIN_INCL',
     $        'MIN_EXCL','MAX_INCL','MAX_EXCL','SUM_INCL','SUM_EXCL'

            WRITE(1,120) TIMAR(I,10),TIMAR(I,12),TIMAR(I,14),
     $           TIMAR(I,16),TIMAR(I,18),TIMAR(I,20), 
     $           TIMAR(I,26), TIMAR(I,28)
C     WALL TIME
            WRITE(1,130) TIMAR(I,11),TIMAR(I,13),TIMAR(I,15),
     $           TIMAR(I,17),TIMAR(I,19),TIMAR(I,21),
     $           TIMAR(I,27), TIMAR(I,29)


         WRITE(1,140) '-------------------------------------------------
     $-------------------------------------------------------------'
 40      CONTINUE

         WRITE(1,140) '-------------------------------------------------
     $-------------------------------------------------------------'


 30   CONTINUE

 100  FORMAT(A,5X,I4,4X,A)
 110  FORMAT(6X,8(1X,A12))
 120  FORMAT('CPU',3X,8(1X,E12.4))
 130  FORMAT('WALL',2X,8(1X,E12.4))
 140  FORMAT(A)
 150  FORMAT('NUM_CALLS = ',I4)
 160  FORMAT(2X,A4,78X,'|',7X ,A,)
 170  FORMAT('SBIN/SBOUT-AVG: CPU_TIME = ',E12.6,4X,
     $     'WALL_TIME = ',E12.4)
 171  FORMAT('SBIN/SBOUT-MIN: CPU_TIME = ',E12.6,4X,
     $     'WALL_TIME = ',E12.4)
 172  FORMAT('SBIN/SBOUT-MAX: CPU_TIME = ',E12.6,4X,
     $     'WALL_TIME = ',E12.4)
 175  FORMAT('DOIN/DOOUT-AVG: CPU_TIME = ',E12.6,4X,
     $     'WALL_TIME = ',E12.4)
 176  FORMAT('DOIN/DOOUT-MIN: CPU_TIME = ',E12.6,4X,
     $     'WALL_TIME = ',E12.4)
 177  FORMAT('DOIN/DOOUT-MAX: CPU_TIME = ',E12.6,4X,
     $     'WALL_TIME = ',E12.4)
 180  FORMAT('FUNTIM-AVG:     CPU_TIME = ',E12.6,4X,
     $     'WALL_TIME = ',E12.4)
 181  FORMAT('FUNTIM-MIN:     CPU_TIME = ',E12.6,4X,
     $     'WALL_TIME = ',E12.4)
 182  FORMAT('FUNTIM-MAX:     CPU_TIME = ',E12.6,4X,
     $     'WALL_TIME = ',E12.4)

      GOTO 300
 250  IF (IOSTAT.NE.0) PRINT *, 'CAN NOT OPEN FILE;ERRNUM=',IOSTAT
 260  PRINT *, 'CAN NOT OPEN FILE EVNLST'
 270  PRINT *, 'ERROR IN READING FILE EVNLST'
C      PRINT *, 'I= ',I,' EVNUMS(I) ',EVNUMS(I),' EVARR(I) ',EVARR(I)
 300  RETURN
      END

