	PROGRAM LNSRPT
C
C	COUNTERS INSTALLED IN THE MONITOR ARE SAMPLED
C	ONCE PER MINUTE BY THE LINES.MAC PROGRAM AND
C	PUT INTO REPORT FORM BY THIS PROGRAM.
C
	IMPLICIT INTEGER(A-Y)
	IMPLICIT REAL (Z)
	REAL SQRT,PRTK
	LOGICAL XOR,OPTION
	REAL TOT(70),X2(70),TOTS(70),X2S(70)
	DOUBLE PRECISION DK(2),DKTT(2),DKTTS(2)
	DOUBLE PRECISION HD(70),FIL,FILEX
	DIMENSION MAX(70),MIN(70),MAXS(70),MINS(70),K(100),ZK(100),
     #IPRI(70),NPR(10),BITS(10),OPTNAM(10),TITLE(3),FILI(2)
	DIMENSION KD1(2),KD2(2),KD3(2),KD4(2),ZKD2(2),ZMN(2),ZSTD(2),
     #KD1TT(2),KD1TTS(2),ZD2TT(2),ZD2TTS(2),Z2MIN(2),Z2MINS(2),
     #Z2MAX(2),Z2MAXS(2)
	DIMENSION OPT(10),IUN(10),LINCNT(10)
	DIMENSION FILEY(2),PRTK(16)
	EQUIVALENCE(FILI,FIL)
	EQUIVALENCE (FILEX,FILEY(1))
C	OPTION BITS
	DATA OPT/1,2,4,8,16,32,4*0/
C	# OF GROUPS, 1ST ELEMENT OF EACH GROUP(PLUS 1 IMAGINARY GROUP)
	DATA NOPTS,NPR/5,1,10,21,36,38,54,4*0/
C	OPTION NAMES
	DATA OPTNAM/'RPTA','RPTB','RPTC','RPTBC','ALL','RPTD',
     1'RPTS','RPTE',2*0/
C	# OF OPTION NAMES, BIT COMB. FOR EACH
	DATA JOPTS,BITS/8,1,2,4,6,"77,"10,"40,"20,2*0/
	DATA IPRI/4,3,6,11,7,9,12,13,14,
     #16,17,18,19,20,21,22,23,24,25,26,
     #27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,1,1,
     #42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,17*0/
C	HEADERS
	DATA (HD(I),I=1,9)/'Lines ','Jobs  ','CPU-Min(%)',
     #'Ovrhead(%)','DSK-Min','SWP-Min','TTY-Buf(%)','C.B.(%)',
     #'Swap-K(%)'/
	DATA (HD(I),I=10,20)/'DTASL ','MTASL ','EWCNT ',
     #'TISJB ','TOSJB ','PISJB ','POSJB ','REQSS ','REQWK ','REQJSD',
     #'REQPQ1 '/
	DATA (HD(I),I=21,35)/'XPQRP1','XPQRP2','XPQRHP','XPICP1',
     #'XPICP2','XPICHP','SWPKP1','SWPKP2','SWPKHP','SWPJP1','SWPJP2',
     #'SWPJHP','RNTPQ1','RNTPQ2','RNTHPQ'/
	DATA (HD(I),I=36,37)/'Swap Times','Waste Pags'/
	DATA(HD(I),I=38,53)/'CLAS 0','CLAS 1','CLAS 2','CLAS 3',
     1'CLAS 4','CLAS 5','CLAS 6','CLAS 7','CLAS 8',
     2'CLAS 9','CLAS10','CLAS11','CLAS12','CLAS13',
     3'CLAS14','CLAS15'/
C
C	STATEMENT FUNCTION DEFINITIONS
C
	XOR(A,B)=A.AND..NOT.B.OR.B.AND..NOT.A
	OPTION(A)=-(OPTBIT.AND.A)
C
C	VERSION NUMBERS
	VMAJOR=5		!VERSION NUMBER OF LNSRPT
	VLINES=4		!DEFAULT VERSION NUMBER OF LINES DATA FILE
C
C	INITIALIZATION
C
C	NUSED=TOTAL # OF VARIABLES USED
C	NREG=TOTAL # OF REGULAR ITEMS TO READ
C	NCLS=FIRST CLASS RUNTIME ITEM
C	NALL=TOTAL # OF LINES DATA ITEMS TO READ
	NUSED=53
	NREG=41
	NCLS=NREG+1
	NALL=NREG+16
	NSPC=2
	NSUM=NOPTS+1
	IEVERY=60
	ISUM=0
	IPUM=0
	ISAVE=NCLS
	LF=' '
	FORM='1'
	DO 1104 I=1,NUSED
	TOT(I)=0
	TOTS(I)=0
	X2(I)=0
	X2S(I)=0
	MAXS(I)=0
	MAX(I)=0
	MINS(I)=10000000
1104	MIN(I)=10000000
	DO 1108 I=1,NSUM
1108	LINCNT(I)=99999
C
C	DIALOGUE
C
C	TYPE IN DAY AS MMMDD    -   FOR EXAMPLE JAN09
	TYPE 1112
1112	FORMAT (' Day (mmmdd): '$)
	ACCEPT 1116, FILI(1),TITLE
1116	FORMAT (A5,1X,3A5)
	OPEN(UNIT=20,DEVICE='DSK',ACCESS='SEQIN',MODE='ASCII',FILE=FIL)
C	TYPE IN TIME LIMITS AS HH,MM      -  FOR EXAMPLE 13,2 FOR 13:02
	TYPE 1120
1120	FORMAT ('+From (hr,min): '$)
	ACCEPT 1124,IF1,IF2
1124	FORMAT (2I)
	IF(IF1.LT.100)GO TO 1128
	IF2=MOD(IF1,100)
	IF1=IF1/100
1128	TYPE 1132
1132	FORMAT ('+To (hr,min):  '$)
	ACCEPT 1124,IT1,IT2
	IF(IT1.LE.100)GO TO 1136
	IT2=MOD(IT1,100)
	IT1=IT1/100
1136	IF (IT1.EQ.0 .AND. IT2.EQ.0) IT1=25
C
C	OPTION READIN LOOP
C
1140	TYPE 1144
1144	FORMAT ('+Option? (RPTA,RPTB,RPTC,RPTBC,RPTD,RPTE,RPTS,ALL) ',$)
	ACCEPT 1148,ANS
1148	FORMAT (A5)
	IF(ANS.EQ.'     ')GO TO 1180
	IF(ANS.NE.'HELP'.AND.ANS.NE.'HEL'.AND.ANS.NE.'HE'
     # .AND.ANS.NE.'H')GO TO 1168
	TYPE 1152
1152	FORMAT(' Options available:',//,' RPTA - Yields the followi',
     #'ng counters:',/)
	TYPE 1380
	TYPE 1156
1156	FORMAT(/,' RPTB - Yields the following counters:',/)
	TYPE 1384
	TYPE 1160
1160	FORMAT(/,' RPTC - Yields the following counters:',/)
	TYPE 1388
	TYPE 1162
1162	FORMAT(/,' RPTD - Yields the following counters:',/)
	TYPE 1392
	TYPE 1163
1163	FORMAT(/,' RPTE - Yields the following counters:',/)
	TYPE 1410
	TYPE 1164
1164	FORMAT(/,' RPTS - In response to the question: "Summary',
     #' every:",',/,' Enter the number of minutes to be included in',
     #' each summary.',
     #//,' ALL - Yields all reports descibed above.',//,
     #' Note: you may enter any or all of the options',/,
     #' described above, one per line. after the last put an extra',/,
     #' carraige return.',//)
	GO TO 1140
1168	DO 1172 I=1,JOPTS
	IF(ANS.NE.OPTNAM(I))GO TO 1172
	OPTBIT=OPTBIT.OR.BITS(I)
	GO TO 1140
1172	CONTINUE
	TYPE 1176,ANS
1176	FORMAT(' ? ',A5,' is not an option',/)
	GO TO 1140
1180	IF(OPTBIT.EQ.0)GO TO 1140
	IF((OPTBIT.AND.OPT(NSUM)).EQ.0)GO TO 1188
	TYPE 1184
1184	FORMAT ('+Summary every: '$)
	ACCEPT 1124,IEVERY
	IF (IEVERY.EQ.0) IEVERY=60
	IF(IEVERY.LT.0)IEVERY=1450
1188	TYPE 1192
1192	FORMAT(/,' Output files:',$)
	FILEX='SCHED@.DAT'
	DO 1240 I=0,NSUM-1
C	INCREMENT ALPHAMERIC FILENAME
	FILEY(2)=FILEY(2)+"4000000000
	IF(FILEY(2).EQ.'F.DAT') FILEY(2)='S.DAT'
	IF((OPTBIT.AND.2**I).EQ.0)GO TO 1240
	TYPE 1196,FILEX
1196	FORMAT('+ ',A10,$)
	IP1=I+1
	OPEN(UNIT=IP1,DEVICE='DSK',
     #FILE=FILEX,ACCESS='SEQOUT',MODE='ASCII')
	GO TO (1200,1208,1216,1224,1230,1232),IP1
1200	WRITE(IP1,1204)FILI(1),TITLE
1204	FORMAT('1',37X,'RPTA - Resource utilization for ',A5,
     #T115,3A5)
	GO TO 1240
1208	WRITE(IP1,1212)FILI(1),TITLE
1212	FORMAT('1',33X,'RPTB - PQ1 requeue data for ',A5,
     #T115,3A5)
	GO TO 1240
1216	WRITE(IP1,1220)FILI(1),TITLE
1220	FORMAT('1',41X,'RPTC - Processor queue data for ',A5,
     #T115,3A5)
	GO TO 1240
1224	WRITE(IP1,1228)FILI(1),TITLE
1228	FORMAT('1',25X,'RPTD - Special queue data for ',A5,T115,3A5)
	GO TO 1240
1230	WRITE(IP1,1231)FILI(1),TITLE
1231	FORMAT('1',25X,'RPTE - Class percentages
     1 FOR ',A5,T115,3A5)
	GO TO 1240
1232	WRITE(IP1,1236)FILI(1),TITLE
1236	FORMAT('1',25X,'RPTS - Summary for ',A5,
     #T115,3A5)
1240	CONTINUE
	TYPE 1324
	IF(OPTBIT.EQ.0)GO TO 1140
C
C	MAIN LOOP
C
	NMINS=0
	NMIN=0
1248	READ (20,1252,END=1316) (K(I),I=1,NREG),(KD1(I),KD2(I),KD3(I),
     #KD4(I),I=1,NSPC),(K(I),I=NCLS,NALL)
1252	FORMAT(100I)
	KX=K(1)
	KY=K(2)
	IF (KX.NE.25) GOTO 1249
	VLINES=KY
	GOTO 1248
1249	IF (KX.LT.IF1) GOTO 1248
	IF (KX.EQ.IF1 .AND. KY.LT.IF2) GOTO 1248
	IF (KX.EQ.IT1 .AND. KY.GT.IT2) GOTO 1316
	IF (KX.GT.IT1) GOTO 1316
	K1=KX
	K2=KY
	KB=MOD(K2,10)
	KA=K2/10
	IF (VMAJOR.NE.VLINES) GOTO 1900
	DO 1251 I=1,NUSED
1251	ZK(I)=K(IPRI(I))
	KSTOP=NPR(4)-1
	DO 1250 I=KSTOP-2,KSTOP
	ZK(I)=ZK(I)/60.0
1250	K(IPRI(I))=ZK(I)+0.5
	ZK(3)=100.0-ZK(3)
	K(IPRI(3))=100-K(IPRI(3))
	ISAVE=NCLS
	DO 1253 I=NCLS,NALL
	IF(K(I).EQ.0)GO TO 1253
	IF(I.GT.ISAVE) ISAVE=I
1253	CONTINUE
	DO 1254 I=1,NSPC
	DK(I)=DFLOAT(KD3(I))*34359738368.D0+DFLOAT(KD4(I))
	ZKD2(I)=KD2(I)
	IF(I.GT.1)GO TO 1255
	ZKD2(I)=KD2(I)/60.
	DK(I)=DK(I)/3600.D0
1255	ZMN(I)=0
	ZSTD(I)=0
	IF(KD1(I).EQ.0)GO TO 1254
	ZMN(I)=ZKD2(I)/KD1(I)
	IF(KD1(I).GT.1)ZSTD(I)=(DK(I)-(ZKD2(I)*ZKD2(I))/KD1(I))/
     #(KD1(I)-1)
	IF(ZSTD(I).LT.0)ZSTD(I)=0
	ZSTD(I)=SQRT(ZSTD(I))
1254	CONTINUE
C
C	OPTION HANDLING
C
1256	IDONE=ISAVE-NCLS+1
	INUM=IDONE+NPR(5)
	IF(INUM.GT.ISUM) ISUM=INUM
	IF(INUM.GT.IPUM) IPUM=INUM
	DO 1288 J=1,NOPTS
	IF(.NOT.OPTION(OPT(J)))GO TO 1288
	IF(LINCNT(J).LE.55)GO TO 1272
	IF(LINCNT(J).NE.99999)WRITE(J,1372)TITLE
	LINCNT(J)=0
	IF(J.NE.1.AND.J.NE.4)WRITE(J,1260)(HD(I),I=NPR(J),NPR(J+1)-1)
	IF(J.EQ.1)WRITE(J,1264)(HD(I),I=NPR(J),NPR(J+1)-1)
	IF(J.EQ.4)WRITE(4,1268)(HD(I),
     #I=NPR(J),NPR(J+1)-1)
1260	FORMAT(' Time',3X,18(A6,1X))
1264	FORMAT(' Time',6X,18(A10,1X))
1268	FORMAT(23X,A10,23X,A10,/,
     #' TIME',1X,2(6X,'Number',7X,'Mean',7X,'STDV'))
C	PRINT DATA LINE
1272	IF(J.EQ.5)GO TO 1290
	IF(J.NE.1.AND.J.NE.4)WRITE(J,1276)K1,KA,KB,
     #(K(IPRI(I)),I=NPR(J),NPR(J+1)-1)
	IF(J.EQ.1)WRITE(J,1280)K1,KA,KB,
     #(K(IPRI(I)),I=NPR(J),NPR(J+1)-1)
	IF(J.EQ.4)WRITE(J,1284)K1,KA,KB,(KD1(I),ZMN(I),
     #ZSTD(I),I=1,NSPC)
1276	FORMAT(I3,':',2I1,18(I6,1X))
1280	FORMAT(I3,':',2I1,18(2X,I7,2X))
1284	FORMAT(I3,':',2I1,2(I10,2X,2F11.2))
	GOTO 1287
1290	II=0
	DO 1291 I=NPR(J),INUM-1
	II=II+1
	PRTK(II)=ZK(I)/36.0
1291	CONTINUE
	WRITE(J,1292)K1,KA,KB,
     1(PRTK(I),I=1,IDONE)
1292	FORMAT(I3,':',2I1,1X,16F7.1)
1287	LINCNT(J)=LINCNT(J)+1
1288	CONTINUE
C
C	GATHER STATS
C
	NMIN=NMIN+1
	NMINS=NMINS+1
	DO 1294 I=1,NUSED
	ZKI=ZK(I)
	KI=K(IPRI(I))
	TOT(I)=TOT(I)+ZKI
	TOTS(I)=TOTS(I)+ZKI
	X2(I)=X2(I)+ZKI*ZKI
	X2S(I)=X2S(I)+ZKI*ZKI
	IF(MIN(I).GT.KI)MIN(I)=KI
	IF(MINS(I).GT.KI)MINS(I)=KI
	IF(MAX(I).LT.KI)MAX(I)=KI
	IF(MAXS(I).LT.KI)MAXS(I)=KI
1294	CONTINUE
	IF(.NOT.OPTION(OPT(4).OR.OPT(NSUM)))GO TO 1297
	DO 1295 I=1,NSPC
	KD1TT(I)=KD1TT(I)+KD1(I)
	KD1TTS(I)=KD1TTS(I)+KD1(I)
	ZD2TT(I)=ZD2TT(I)+ZKD2(I)
	ZD2TTS(I)=ZD2TTS(I)+ZKD2(I)
	DKTT(I)=DKTT(I)+DK(I)
	DKTTS(I)=DKTTS(I)+DK(I)
	IF(Z2MIN(I).GT.ZMN(I))Z2MIN(I)=ZMN(I)
	IF(Z2MINS(I).GT.ZMN(I))Z2MINS(I)=ZMN(I)
	IF(Z2MAX(I).LT.ZMN(I))Z2MAX(I)=ZMN(I)
	IF(Z2MAXS(I).LT.ZMN(I))Z2MAXS(I)=ZMN(I)
1295	CONTINUE
C
C	SUMMARY
C
1297	NPR(6)=IPUM
	IF(.NOT.OPTION(OPT(NSUM)))GO TO 1248
	IF(NMIN.LT.1)GO TO 1248
	IF (MOD(60*K1+K2,IEVERY).NE.0)GO TO 1248
	DO 1298 I=NPR(5),IPUM-1
	MIN(I)=MIN(I)/36
	MAX(I)=MAX(I)/36
	X2(I)=X2(I)/1296.0
1298	TOT(I)=TOT(I)/36.0
	IF(LINCNT(NSUM)+NPR(NSUM)+10.LE.55)GO TO 1300
	CHR=' '
	IF(LINCNT(NSUM).NE.99999)WRITE(NSUM,1372)TITLE
	LINCNT(NSUM)=0
	WRITE(NSUM,1299)CHR,K1,KA,KB,FILI(1),NMIN
1299	FORMAT(A1,' Time',T24,'Mean',T32,'Std. Dev.',T45,'Min',T55,
     #'Max',T61,'Total N',//,I3,':',2I1,1X,A5,'  NMIN=',I4,/)
1300	CALL SUMARY(NSUM,1,NPR(4)-1,NMIN,TOT,
     #X2,MAX,MIN,K1,KA,KB,FILI(1),HD)
	CALL ZSUMRY(NSUM,NSPC,NMIN,KD1TT,ZD2TT,DKTT,Z2MIN,
     #Z2MAX,K1,KA,KB,FILI(1),HD)
	CALL SUMARY(NSUM,NPR(5),NPR(6)-1,NMIN,TOT,
     #X2,MAX,MIN,K1,KA,KB,FILI(1),HD)
	LINCNT(NSUM)=LINCNT(NSUM)+NPR(NSUM)+9
	NMIN=0
	IPUM=0
	DO 1304 I=1,NUSED
	TOT(I)=0
	X2(I)=0
	MAX(I)=0
	MIN(I)=1000000
1304	CONTINUE
	DO 1306 I=1,NSPC
	KD1TT(I)=0
	ZD2TT(I)=0
	DKTT(I)=0
	Z2MIN(I)=0
1306	Z2MAX(I)=0
	GO TO 1248
C
C	WRAP UP FOR INDIVIDUAL OPTIONS
C
1316	NPR(6)=ISUM
	DO 1315 I=NPR(5),ISUM-1
	MINS(I)=MINS(I)/36
	MAXS(I)=MAXS(I)/36
	X2S(I)=X2S(I)/1296.0
1315	TOTS(I)=TOTS(I)/36.0
	IF(NMINS.LT.1)GO TO 1360
	DO 1340 I=1,NOPTS
	IF(.NOT.OPTION(OPT(I)))GO TO 1340
	IF(LINCNT(I)+NPR(I+1)-NPR(I)+6.LE.55)GO TO 1320
C	PRINT HEADER
	IF(LINCNT(I).NE.99999)WRITE(I,1372)TITLE
	LINCNT(I)=0
C	PRINT SUMARY
1320	WRITE(I,1324)
1324	FORMAT(//)
	LINCNT(I)=LINCNT(I)+5
	IF(I.EQ.4)GO TO 1332
	WRITE(I,1328)LF,K1,KA,KB,FILI(1),NMINS
1328	FORMAT(A1,'Totalized summary',/,'  Time',T23,'Mean',T32,
     #'Std. Dev.',T45,'Min',T55,'Max',//,
     #I3,':',2I1,1X,A5,'  NMIN=',I4,/)
	II=I
	CALL SUMARY(II,NPR(I),NPR(I+1)-1,NMINS,TOTS,X2S,MAXS,MINS,
     #K1,KA,KB,FILI(1),HD)
	LINCNT(I)=LINCNT(I)+NPR(I+1)-NPR(I)
	GO TO 1340
1332	WRITE(I,1329)LF,K1,KA,KB,FILI(1),NMINS
1329	FORMAT(A1,'Totalized summary',/,'  Time',T23,'Mean',T32,
     #'Std. Dev.',T45,'Min',T55,'Max',T61,'Total N',//,
     #I3,':',2I1,1X,A5,'  NMIN=',I4,/)
	CALL ZSUMRY(4,NSPC,NMINS,KD1TTS,ZD2TTS,DKTTS,Z2MINS,
     #Z2MAXS,K1,KA,KB,FILI(1),HD)
	LINCNT(4)=LINCNT(4)+7
1340	CONTINUE
C
C	WRAP UP FOR SUMMARY
C
1344	IF(.NOT.OPTION(OPT(NSUM)))GO TO 1360
	IF(MOD(60*K1+K2,IEVERY).EQ.0)GO TO 1352
	IF(NMIN.LT.1)GO TO 1352
	DO 1343 I=NPR(5),IPUM-1
	MIN(I)=MIN(I)/36
	MAX(I)=MAX(I)/36
	X2(I)=X2(I)/1296.0
1343	TOT(I)=TOT(I)/36.0
	IF(LINCNT(NSUM)+NPR(NSUM)+9.LE.55)GO TO 1348
C	PRINT HEADER
	IF(LINCNT(NSUM).NE.99999)WRITE(NSUM,1372)TITLE
	LINCNT(NSUM)=0
	WRITE(NSUM,1324)
	LINCNT(NSUM)=LINCNT(NSUM)+2
1348	WRITE(NSUM,1299)LF,K1,KA,KB,FILI(1),NMIN
	CALL SUMARY(NSUM,1,NPR(4)-1,NMIN,TOT,X2,
     #MAX,MIN,K1,KA,KB,FILI(1),HD)
	LINCNT(NSUM)=LINCNT(NSUM)+NPR(NSUM)+10
	CALL ZSUMRY(NSUM,NSPC,NMIN,KD1TT,ZD2TT,DKTT,Z2MIN,
     #Z2MAX,K1,KA,KB,FILI(1),HD)
	LINCNT(NSUM)=LINCNT(NSUM)+9
	CALL SUMARY(NSUM,NPR(5),IPUM-1,NMIN,TOT,X2,
     1MAX,MIN,K1,KA,KB,FILI(1),HD)
1352	IF(LINCNT(NSUM)+NPR(NSUM)+9.LE.55)GO TO 1356
C	PRINT HEADER
	IF(LINCNT(NSUM).NE.99999)WRITE(NSUM,1372)TITLE
	LINCNT(NSUM)=0
	WRITE(NSUM,1324)
	LINCNT(NSUM)=LINCNT(NSUM)+2
1356	WRITE(NSUM,1329)LF,K1,KA,KB,FILI(1),NMINS
	CALL SUMARY(NSUM,1,NPR(4)-1,NMINS,TOTS,X2S,
     #MAXS,MINS,K1,KA,KB,FILI(1),HD)
	LINCNT(NSUM)=LINCNT(NSUM)+NPR(NSUM)
	CALL ZSUMRY(NSUM,NSPC,NMINS,KD1TTS,ZD2TTS,DKTTS,Z2MINS,
     #Z2MAXS,K1,KA,KB,FILI(1),HD)
	LINCNT(NSUM)=LINCNT(NSUM)+9
	CALL SUMARY(NSUM,NPR(5),NPR(6)-1,NMINS,TOTS,X2S,
     1MAXS,MINS,K1,KA,KB,FILI(1),HD)
C
C	INSURE ENOUGH SPACE FOR KEY
C
1360	DO 1364 I=1,NSUM-1
	IF(OPTION(OPT(I)).AND.(LINCNT(I)+NPR(I+1)-NPR(I)+2).GT.55)
     #WRITE(I,1372)TITLE
1364	CONTINUE
	IF(OPTION(OPT(NSUM)).AND.LINCNT(NSUM)+NPR(NSUM)+2.GT.55)
     #WRITE(NSUM,1372)TITLE
1368	FORMAT('1')
1372	FORMAT('1',T115,3A5)
	DO 1376 I=1,NSUM
1376	IF(OPTION(OPT(I)))WRITE(I,1324)
	IF(OPTION(OPT(1)))WRITE(1,1380)
	IF(OPTION(OPT(NSUM)))WRITE(NSUM,1380)
1380	FORMAT(
     #' Lines       - Number of dial up lines active',/,
     #' Jobs        - Total of all jobs',/,
     #' CPU-Min(%)  - Percent CPU utilized in last minute',/,
     #' Ovrhead(%)  - Monitor overhead',/,
     #' DSK-Min     - # of 128 word blocks read & written on',
     #1X,'public F.S. in last min',/,
     #' SWP-Min     - # of 128 word blocks swapped to and from',
     #1x,'core in the last min',/,
     #' TTY-Buf(%)  - Percent of teletype buffer space in use',/,
     #' C.B.(%)     - Percent of 4 word core blocks used',/,
     #' SWAP-K(%)   - Percent of available swapping space used')
	IF(OPTION(OPT(2)))WRITE(2,1384)
	IF(OPTION(OPT(NSUM)))WRITE(NSUM,1384)
1384	FORMAT(
     #' DTASL       - DTA generated sleeps',/,
     #' MTASL       - MTA generated sleeps',/,
     #' EWCNT       - EW satisfied',/,
     #' TISJB       - TTY input satisfied',/,
     #' TOSJB       - TTY output satisfied',/,
     #' PISJB       - PTY input satisfied',/,
     #' POSJB       - PTY output satisfied',/,
     #' REQSS       - Requeues from SS into PQ1',/,
     #' REQWK       - Requeues from wake into PQ1',/,
     #' REQJSD      - Requeues from DAEMON satisfied into PQ1',/,
     #' REQPQ1      - Total requeues into PQ1')
	IF(OPTION(OPT(3)))WRITE(3,1388)
	IF(OPTION(OPT(NSUM)))WRITE(NSUM,1388)
1388	FORMAT(
     #' XPQRP1      - Jobs in PQ1 which expired quantum run time',/,
     #' XPQRP2      - Jobs in PQ2 which expired quantum run time',/,
     #' XPQRHP      - Jobs in HPQ which expired quantum run time',/,
     #' XPICP1      - Jobs in PQ1 which expired incore protect',/,
     #' XPICP2      - Jobs in PQ2 which expired incore protect',/,
     #' XPICHP      - Jobs in HPQ which expired incore protect',/,
     #' SWPKP1      - Number of K swapped in for PQ1 jobs',/,
     #' SWPKP2      - Number of K swapped in for PQ2 jobs',/,
     #' SWPKHP      - Number of K swapped in for HPQ jobs',/,
     #' SWPJP1      - Number of PQ1 jobs swapped in',/,
     #' SWPJP2      - Number of PQ2 jobs swapped in',/,
     #' SWPJHP      - Number of HPQ jobs swapped in',/,
     #' RNTPQ1      - Seconds charged to PQ1',/,
     #' RNTPQ2      - Seconds charged to PQ2',/,
     #' RNTHPQ      - Seconds charged to HPQS')
	IF(OPTION(OPT(4)))WRITE(4,1392)
	IF(OPTION(OPT(NSUM)))WRITE(NSUM,1392)
1392	FORMAT(
     #' Swap times  - Number of seconds for swapping in jobs in PQ1 an',
     #'d CMQ'/,
     #' Waste pags  - pages of swapable jobs not in processor queue')
1400	IF(OPTION(OPT(5)))WRITE(5,1410)
	IF(OPTION(OPT(NSUM)))WRITE(NSUM,1410)
1410	FORMAT( ' CLAS N      - Percent runtime for class N')
	CALL EXIT
C
C	HERE IF VERSION NUMBERS DO NOT MATCH
C
1900	TYPE 1901,VLINES,VMAJOR,K1,KA,KB
1901	FORMAT (' ? Version number of data file ('I2,
	2  ') does not match LNSRPT ('I2,') at time 'I3,':'2I1)
	CALL EXIT
	END


	SUBROUTINE SUMARY(IUNIT,NPRA,NPRB,NMIN,TOT,X2,MAX,MIN,K1,KA,KB,
     #DATE,HD)
	DOUBLE PRECISION HD
	DIMENSION HD(1),TOT(1),X2(1),MAX(1),MIN(1)
	DO 2108 I=NPRA,NPRB
	AMEAN=TOT(I)/NMIN
	STDV=0
	IF(NMIN.GT.1)STDV=(X2(I)-(TOT(I)*TOT(I))/NMIN)/(NMIN-1)
	IF(STDV.LT.0)STDV=0
	STDV=SQRT(STDV)
	MINP=MIN(I)
	MAXP=MAX(I)
2107	WRITE(IUNIT,2112)HD(I),AMEAN,STDV,MINP,MAXP
2108	CONTINUE
2112	FORMAT(7X,A10,2F10.2,2I10)
	RETURN
	END
	SUBROUTINE ZSUMRY(IUNIT,NSPC,NMIN,KD1TT,ZD2TT,DKTT,Z2MIN,
     #Z2MAX,K1,KA,KB,DATE,HD)
	DOUBLE PRECISION HD,DKTT
	DIMENSION HD(1),DKTT(1)
	DIMENSION KD1TT(1),ZD2TT(1),Z2MIN(1),Z2MAX(1)
	DO 3104 I=1,NSPC
	AMEAN=0
	STDV=0
	IF (KD1TT(I).NE.0) AMEAN=ZD2TT(I)/KD1TT(I)
	IF(KD1TT(I).GT.1)STDV=(DKTT(I)-(ZD2TT(I)*DBLE(ZD2TT(I)))/
     #KD1TT(I))/(KD1TT(I)-1)
	IF(STDV.LT.0)STDV=0
	STDV=SQRT(STDV)
	WRITE(IUNIT,3108)HD(35+I),AMEAN,STDV,Z2MIN(I),Z2MAX(I),KD1TT(I)
3104	CONTINUE
3108	FORMAT(7X,A10,2F10.2,2F10.2,I10)
	RETURN
	END
