* SUMMARY - COMPILE WITH ANSFORT: OPTIONS LS,BO,FS,X
*
*     TO RUN SUMMARY ON SMALL MEMORY CP-V SYSTEMS, RE-COMPILE
*     WITH ANSFORT: OPTIONS LS,BO,FS,Y,BUF(10)
*
C     REQUIRES METASYMBOL SUBROUTINES  AND FORTRAN LIBRARY
      DOUBLE COMPLEX IHDR,ISIDE,FIRSTH,LASTH
C     FIRSTH AND LASTH USED ONLY TO INITIALIZE ISIDE IN ANSFORT
      DIMENSION FIRSTH(75),LASTH(75)
      EQUIVALENCE (ISIDE(1),FIRSTH(1)),(ISIDE(76),LASTH(1))
      DOUBLE PRECISION XM,YCOV
      INTEGER BUFFER,SNTIME,SLEN,ABUF
      COMMON /BUFFER/BUFFER(400)
      COMMON /ABUF/ABUF(2)
      COMMON /ISTAT /ISTAT
      COMMON /IANS/IANS(30)
      COMMON /ALPHA/IHDR(14),ISIDE(150)
      DIMENSION KSIDE(20)
      COMMON /XLIMIT/XLIMIT(20,5)
      COMMON /XDATA/X(130),XM(130),XMIN(130),XMAX(130),NSIZE
      DIMENSION YCOV(8515)
X     GLOBAL YCOV
Y     VIRTUAL YCOV
      COMMON /IPLOT/IPLOT(12,0:14),ITOT(12),XPCM(12)
C     DIMENSION OF YCOV=NSIZE*NSIZE/2 + NSIZE/2
C     IF J>I ROW DISPLACEMENT = (I-1)*NSIZE-I*(I-1)/2
C     IF J>I COLUMN DISPLACEMENT = J-I+1
      COMMON /LINES/LINES
      COMMON /KDIM/KDIM(20),ILINE,IDTO
      DIMENSION XAVE(150),YM(150)
      DIMENSION INAME1(40),INAME2(40)
      DIMENSION INAME(20)
      DIMENSION SNTIME(4),JDIM(0:12),ISNAP(1),IHDIS(8,12)
      DATA IHDR /
     C'   0 - PARAM    ',
     C'   1 - SUMMARY  ',
     C'   2 - CPU      ',
     C'   3 - I/O      ',
     C'   4 - TASK     ',
     C'   5 - RAHD     ',
     C'   6 - SCPU     ',
     C'   7 - EVNT     ',
     C'   8 - BATCH    ',
     C'   9 - ONLINE   ',
     C'  10 - USERS    ',
     C'  11 - QUEUE    ',
     C'  12 - RESOURCE ',
     C'  13 - HISTOGRAM'/
      DATA KSIDE/1,17,31,43,55,61,70,79,87,99,111,123,133,
     C           0,0,0,0,0,0,0/
      DATA FIRSTH /
     C'HOUR:MINUTES    ','INTERVAL IN MIN ','MAX # BATCH     ',
     C'MAX # ONLINE    ','AVERAGE BATCH K ','AVERAGE ONLINE K',
     C'# SEC TERM BLK  ','# SEC TERM UBLK ','QMIN        MSEC',
     C'SQUAN       MSEC','AVE BATCH QUAN  ','MSEC ONLINE QUAN',
     C'CPU ACTIVE      ','AVE SCPU QUAN MS','RAHD TMOUT SEC  ',
     C'AIR TMOUT  SEC  ','BATCH STREAMS   ','ONLINE USERS    ',
     C'% CPU/BATCH USER','% CPU/ONLINE USE','BATCH EXEC/SERV ',
     C'ONLINE EXEC/USER','CPU MSEC PER I/O','ONLINE TIME MIX ',
     C'ONLINE INTENSITY','ONLINE TASKS/MIN','% INTERACTIVE   ',
     C'90% RESPONSE  MS','TURNAROUND   SEC','ETMF            ',
     C'BATCH EXEC      ','BATCH SERV      ','ONLINE EXEC     ',
     C'ONLINE SERV     ','GHOST EXEC      ','GHOST SERV      ',
     C'MONITOR SERV    ','IDLE            ','SWAP WAIT       ',
     C'I/O WAIT        ','I/O & SWAP WAIT ','TOTAL           ',
     C'SERVICE REQUESTS','INTERACTIONS    ','CHAR IN         ',
     C'CHAR OUT        ','TERM WRITES     ','I/O ACCESSES    ',
     C'# TRUNCS        ','AIR ATTEMPTS    ','AIR HITS        ',
     C'SYMBIONT        ','IN SWAPS        ','OUT SWAPS       ',
     C'INTERACT        ','THINK-TY        ','TURNARND        ',
     C'COMPLETE        ','RESPONSE    MSEC','CPU         MSEC',
     C'AIR ATTEMPTS    ','AIR HITS        ','AIR TIMEOUTS    ',
     C'RAHD ATTEMPTS   ','RAHD STARTS     ','RAHD USED       ',
     C'RAHD I/O WAIT   ','RAHD NOT USED   ','RAHD TIMEOUTS   ',
     C'SCPU 1 EXEC     ','SCPU 1 IDLE     ','SCPU 1 TOT      ',
     C'SCPU 2 EXEC     ','SCPU 2 IDLE     ','SCPU 2 TOT      '/
      DATA LASTH /
     C'SCPU 3 EXEC     ','SCPU 3 IDLE     ','SCPU 3 TOT      ',
     C'MASTER CALS     ','SCPU 1 CALS     ','SCPU 2 CALS     ',
     C'SCPU 3 CALS     ','MASTER SCHED    ','SCPU 1 SCHED    ',
     C'SCPU 2 SCHED    ','SCPU 3 SCHED    ','                ',
     C'                ','                ','                ',
     C'                ','                ','                ',
     C'                ','                ','                ',
     C'USER            ','SHARED          ','                ',
     C'                ','                ','                ',
     C'                ','                ','                ',
     C'                ','                ','                ',
     C'USER            ','SHARED          ','ANSFORT         ',
     C'AP              ','APL             ','BASIC           ',
     C'EDIT            ','FDP             ','FORTRAN         ',
     C'FORTLIB         ','METASYM         ','PCL             ',
     C'TEXT            ','IN CORE         ','LOGGED          ',
     C'LOGGING         ','BATCH           ','GHOST           ',
     C'TERM IN         ','TERM OUT        ','COMPUTE         ',
     C'COMP BND        ','I/O             ','SLEEP           ',
     C'MPOOLS          ','COCBUFS         ','IOQ ENTRIES     ',
     C'CFUS            ','GRAN PACK       ','GRAN SYMB       ',
     C'GRAN RAD        ',0,0,
     C0,0,0,0,0,0,0,0,0/
C     SNAPSHOT RECORD FORMAT
C
C   SNTIME       RES   4   TIME/DATE IN TEXT
C                RES   2   SITE ID IN TEXT
C   SLEN         RES   1   RECORD LENGTH
C                RES   1   NUMBER OF DISPLAY GROUPS
C                RES   1   DISPL TO DISTRIBUTION TABLES
C   JDIM         RES  13   DIMENSIONS OF DATA GROUPS
C                RES 139   DISPLAY GROUP DATA
C   IHDIS        RES  96   SYSTEM DISTRIBUTION TABLE DATA
C                RES  40   PROCESSOR DISTRIBUTION TABLE DATA
C   INAME        RES  20   BATCH/ONLINE PROC NAMES
C                RES   1   SYSVERS (LOC X'2B')
C                RES   2   EXTEND MONITORING PROC NAME
C                RES   1   EXTEND MONITORING PROC NUMBER
C
C
      EQUIVALENCE (BUFFER(1),SNTIME(1))
                        QUIVALENCE (BUFFER(7),SLEN),
     C            (BUFFER(10),JDIM(0)),
     C            (BUFFER(23),ISNAP),
     C            (BUFFER(162),IHDIS),
     C            (BUFFER(298),INAME)
      EQUIVALENCE (ISIDE(87),INAME1),(ISIDE(99),INAME2)
C
C     INITIALIZATION PORTION
      NSIZE=130
      CALL BUFFERIN(2,1,BUFFER,400,ISTAT)
10    GO TO(10,11,4000,4000),ISTAT
11    KDIM(1)=1
      DO 12 I=2,BUFFER(8)+1
12    KDIM(I)=KDIM(I-1)+JDIM(I-2)
      J=1
      DO 14 I=1,20,2
      INAME1(J)=INAME(I);INAME2(J)=INAME(I)
      INAME1(J+1)=INAME(I+1);INAME2(J+1)=INAME(I+1)
14    J=J+4
      REPEAT 16, FOR J=(0,JDIM(6)-1)
16    ISIDE(KDIM(7)+J)=ISIDE(KSIDE(7)+J)
      REPEAT 17, FOR J=(0,JDIM(6)/3)
      ISIDE(KDIM(8)+J)=ISIDE(KSIDE(8)+J)
17    ISIDE(KDIM(8)+J+JDIM(6)/3+1)=ISIDE(KSIDE(8)+J+4)
      REPEAT 13, FOR I=(9,BUFFER(8))
      REPEAT 13, FOR J=(0,JDIM(I-1)-1)
13    ISIDE(KDIM(I)+J)=ISIDE(KSIDE(I)+J)
      ENCODE (120,600,IANS)
      CALL PRTDO
600   FORMAT (' SUMMARY HERE')
709   DO 710 I=1,20
      DO 710 J=1,5
710   XLIMIT(I,J)=0
      ENCODE (120,585,IANS)
      CALL PRTDO
585   FORMAT (' SPECIFY FILTER ?')
      CALL CPROM
      CALL REPLY (IG,IALL,586S,780S,5000S,780S,780S,204S)
C     OTHER ASSUMED
      GO TO 780
C     HELP
204   CALL HELP(1)
      GO TO 709
586   CONTINUE
      ENCODE (120,700,IANS)
      CALL PRTDO
700   FORMAT (' ENTER ITEM#,LOW LIMIT,HIGH LIMIT')
      DO 750 I=1,20
      CALL SPROM
      CALL READT
C     DETECT 'END', 'X', OR NON-NUMERIC BEFORE DECODING FILTER
C     GO TO NEXT QUESTION IF 'END'
      IF(IAND(IANS(1),8ZFFFFFF00).EQ.8ZC5D5C400) GOTO 780
C     STOP IF 'X'
      IF(IAND(IANS(1),8ZFF000000).EQ.8ZE7000000) GOTO 780
C     IF FIRST CHAR NON-NUMERIC GO TO NEXT QUESTION
      IF(IAND(IANS(1),8ZF0000000).NE.8ZF0000000) GOTO 780
      DECODE (120,720,IANS) (XLIMIT(I,J),J=1,3)
720   FORMAT (3F.0)
      IF (XLIMIT(I,1).EQ.0) GO TO 780
      I1=XLIMIT(I,1)
      ENCODE (120,303,IANS) I1,ISIDE(I1),XLIMIT(I,2),XLIMIT(I,3)
      CALL PRTDO
303   FORMAT (1X,I4,1X,2A8,2(1X,F8.1))
750   CONTINUE
780   CONTINUE
100   NS = 0     ; NTOT = 0
      IALL = 0
      ENCODE (120,500,IANS)
      CALL PRTDO
500   FORMAT (' CHRONOLOGICAL SUMMARIES ?')
      CALL CPROM
      CALL REPLY (IG,IALL,210S,516S,5000S,205S,516S,202S)
C     OTHER ASSUMED
      GO TO 516
C     HELP
202
CALL HELP(1)
      GO TO 100
C     ALL
205   IALL = 1       ; IG = 0
C     YES
210   ICHRON=1; ICOMP=0
C     NEW PAGE
      ENCODE (120,212,IANS)
      CALL PRTLO
212   FORMAT ('1')
      GO TO 200
516   CONTINUE
587   CONTINUE
400   CONTINUE
616   CONTINUE
      IALL = 0
      ENCODE (120,602,IANS)
      CALL PRTDO
602   FORMAT (' CORRELATION ANALYSIS ?')
      CALL CPROM
      CALL REPLY (IG,IALL,610S,5000S,5000S,610S,5000S,606S)
C     OTHER ASSUMED
      GO TO 5000
C     HELP
606   CALL HELP(1)
      GO TO 616
610   ICHRON=0;ICOMP=1
900   ENCODE (120,1010,IANS)
      CALL PRTDO
1010  FORMAT (' ENTER CORRELATION THRESHOLD. (0.0 TO .99)')
      CALL SPROM
      CALL READT
C     DETECT 'END', 'X', OR NON-NUMERIC BEFORE DECODING
C     GO TO NEXT QUESTION IF 'END'
      IF(IAND(IANS(1),8ZFFFFFF00).EQ.8ZC5D5C400) GOTO 3150
C     STOP IF 'X'
      IF(IAND(IANS(1),8ZFF000000).EQ.8ZE7000000) GOTO 5000
C     IF FIRST CHAR NON-NUMERIC GO TO NEXT QUESTION.
      IF(IAND(IANS(1),8ZF0000000).EQ.8ZF0000000) GOTO 1015
      IF(IAND(IANS(1),8ZFF000000).EQ.8Z40000000) GOTO 1015
C     IF '.', '(NL)', OR '(CR)' PROCEED TO DEFAULT VALUES
      IF(IAND(IANS(1),8ZFF000000).EQ.8Z4B000000) GOTO 1015
      IF(IAND(IANS(1),8ZFF000000).EQ.8Z08000000) GOTO 1015
      IF(IAND(IANS(1),8ZFF000000).EQ.8Z15000000) GOTO 1015
      IF(IAND(IANS(1),8ZFF000000).EQ.8Z0D000000) GOTO 1015
      GOTO 3150
1015  CONTINUE
      DECODE (80,1020,IANS) THRESH
1020  FORMAT (F.0)
      IF ((THRESH.GE.1.0).OR.(THRESH.LT.0.0))  GO TO 900
      IF (THRESH.LT..1) THRESH=.1
      ENCODE (120,1030,IANS)THRESH; CALL PRTDO
1030  FORMAT (' THRESHOLD =',F5.2)
140   ENCODE (120,604,IANS)
      CALL PRTDO
604   FORMAT (' ENTER INTENSITY RANGE. (XLOW,XHIGH)')
      CALL READT
C     DETECT 'END', 'X', OR NON-NUMERIC BEFORE DECODING
C     GO TO NEXT QUESTION IF 'END'
      IF(IAND(IANS(1),8ZFFFFFF00).EQ.8ZC5D5C400) GOTO 3150
C     STOP IF 'X'
      IF(IAND(IANS(1),8ZFF000000).EQ.8ZE7000000) GOTO 5000
C     IF FIRST CHAR NON-NUMERIC GO TO NEXT QUESTION.
      IF(IAND(IANS(1),8ZF0000000).EQ.8ZF0000000) GOTO 145
      IF(IAND(IANS(1),8ZFF000000).EQ.8Z40000000) GOTO 145
C     IF '.', '(NL)', OR '(CR)' PROCEED TO DEFAULT VALUES
      IF(IAND(IANS(1),8ZFF000000).EQ.8Z4B000000) GOTO 145
      IF(IAND(IANS(1),8ZFF000000).EQ.8Z08000000) GOTO 145
      IF(IAND(IANS(1),8ZFF000000).EQ.8Z15000000) GOTO 145
      IF(IAND(IANS(1),8ZFF000000).EQ.8Z0D000000) GOTO 145
      GOTO 3150
145   CONTINUE
      DECODE (80,150,IANS) XLOW,XHIGH
150   FORMAT (2F.0)
      IF (XLOW.LT.0.0) GO TO 140
      IF (XHIGH.EQ.0) XHIGH=1000000000.
      IF (XHIGH.LE.XLOW) GO TO 140
      ITEMP = XLOW/200 ;  XLOW = ITEMP*200
      ITEMP = XHIGH/200 ; XHIGH = ITEMP*200
      ENCODE (120,160,IANS) XLOW,XHIGH
      CALL PRTDO
160   FORMAT (' INTENSITY RANGE FROM ',I,' TO ',I)
C - - - - - - - - BEGINNING OF FILE CYCLE LOOP- - - - - - - - -
200   IF( ICHRON.EQ.0 ) GO TO 207
      ENCODE (120,505,IANS); CALL PRTDO
505   FORMAT(' AVERAGES ONLY? ')
      CALL CPROM
      IAVG=0
      CALL REPLY(IG,IALL,206S,207S,5000S,100S,100S,202S)
C                        YES, NO,  END,  ALL, OTHER, HELP
      GO TO 100
206   IAVG=1
207   CONTINUE
      CALL SPROM
      DO 502 IW=1,12
      DO 502 JW=0,14
502   IPLOT (IW,JW) = 0
      IF (ICOMP.EQ.1) CALL ZERO
515   IF((ICHRON.EQ.1).AND.
     C (IALL.EQ.0)) ENCODE(120,520,IANS); CALL PRTDO
     C; CALL REPLY (IG,IALL,3020S,3020S,3020S,535S,3020S,504S)
520   FORMAT(' ENTER ALL, OR GROUP #0-13')
      GO TO 535
504   CALL HELP(1)
      GO TO 515
535   REWIND 2
      IF((IG.EQ.6).AND.(JDIM(6).EQ.0)) ENCODE(120,107,IANS)
     C; CALL PRTDO; GO TO 3004
107   FORMAT(' NO SLAVE PROCESSORS')
      INTEN = -400   ; XUSER = 0
      DO 110 I=1,150
      X(I) = 0.
      XAVE(I) = 0.
110   YM(I) = 0.
      IYN = 0        ; IXA = 0
      NS = 0         ; NTOT = 0
      IF(IAVG.EQ.1) ENCODE(120,105,IANS); CALL PRTLO; GO TO 106
      IF (ICHRON.EQ.1) ENCODE (120,104,IANS); CALL PRTLO
106   IDTO=0
      ILINE=-9999
104   FORMAT ('1 CHRONOLOGICAL SNAPSHOT SUMMARIES')
105   FORMAT ('1 CHRONOLOGICAL SNAPSHOT AVERAGES ')
260   DO 265 I=1,20
      XLIMIT(I,4)=0.
265   XLIMIT(I,5)=0.
C - - - - - - - - - - BEGINNING OF SNAPSHOT LOOP - - - - - -
C
C     PROCESSING PORTION
C
1     CALL BUFFERIN (2,1,BUFFER,400,ISTAT)
      NTOT = NTOT + 1
1000  GO TO (1000,2000,3000,4000),ISTAT
2000  CALL SCALE (X,K,IG,ICOMP)
      ISKIP = 0
      IF((ICOMP.EQ.1).AND.((X(25).LT.XLOW).OR.(X(25).GE.XHIGH)))
     C   ISKIP=1
C     TEST SNAPSHOT FOR ITEMS IN THE FILTER
      DO 800 I=1,20
      IF (XLIMIT(I,1).EQ.0) GO TO 820
      I1=XLIMIT(I,1)
      IF (X(I1).LT.XLIMIT(I,2)) XLIMIT(I,4)=XLIMIT(I,4)+1; ISKIP=1
      IF (X(I1).GT.XLIMIT(I,3)) XLIMIT(I,5)=XLIMIT(I,5)+1; ISKIP=1
800   CONTINUE
820   CONTINUE
      IF (ISKIP.EQ.1) GO TO 1
C     ALL FILTER LIMITS ARE PASSED
C     NS=COUNT OF SAMPLES
      IF (ICOMP.EQ.1) NS=NS+1
C     N IS THE LENGTH OF SAMPLE VECTOR
      N=K
      IF(N.GT.130) N=130
      IF (ICHRON.NE.1) GO TO 2400
      DO 2300 I=1,N
2300  YM(I)=YM(I)+X(I)
      IYN=IYN+1
2400  IF((IAVG.EQ.0).AND.(ICHRON.EQ.1)) CALL ALINE(X,IG)
130   CONTINUE
      IF (ICOMP.EQ.1) CALL COVAR (N)
      GO TO 1
C - - - - - - - - - - END OF SNAPSHOT LOOP - - - - - - - - - - -
C
C     END OF FILE ENCOUNTERED - SUMMARIZE
3000  CONTINUE
      NTOT=NTOT-1
      IF (ICOMP.EQ.1) GO TO 3020
      IF(IAVG.NE.0) GO TO 3003
      ENCODE (120,3001,IANS)
      CALL PRTLO
3001  FORMAT ('   AVERAGES')
3003  CALL AVERAGE (IG,N,YM,IYN)
3004  IF(IG.EQ.13) CALL APLOT
      IF (IALL.EQ.0) GO TO 3002
      IG = IG+1
      IF(IG.GT.13) GO TO 3020
      GO TO 535
3002  CONTINUE
      ENCODE (120,3010,IANS)
      CALL PRTDO
3010  FORMAT (' ANOTHER GROUP ?')
      CALL REPLY (IG,IALL,200S,3020S,3020S,3020S,3020S,3005S)
      GO TO 535
3005  CALL HELP(1)
      GO TO 3002
3020  CONTINUE
C     END OF LOOP
      IF (ICHRON.EQ.1) GO TO 516
      CALL COVAR1 (NS,N)
      CALL LIST (NS,NTOT,N,THRESH,XLOW,XHIGH)
      IF (NTOT.GT.0) ENCODE (120,3100,IANS) NS,NTOT; CALL PRTDO
3100  FORMAT (1X,I4,' SNAPSHOTS WERE SELECTED FROM ',I4)
C                ------    FINISHED   ------
3150  CONTINUE
5000  STOP
C     OPERATION COMPLETE WITH ERROR
4000  CONTINUE
      ENCODE (120,4100,IANS)
      CALL PRTDO
4100  FORMAT (' FILE ERROR - EOF ASSUMED.')
      GO TO 3020
510   FORMAT (2A4)
6000  CONTINUE
      END

