	PROGRAM GRAPH1
C	EDITED 15:15 10-30-73
C	SUBTTL T HAGADONE
C	THIS PROGRAM SIMPLIFIES DATA PRODUCED BY SIMP1.FOR AND
C	GRAPHS IT IN ONE OF SEVERAL FORMS
C	TYPE A 3 CHARACTER MONTH AND A DAY FOR A DAILY GRAPH
C	TYPE A 3 CHARACTER DAY OF THE WEEK FOR THE AVERAGE OF
C		ALL OF THOSE DAYS IN SIMP.DAT
C	TYPE A CARRIAGE RETURN FOR THE AVERAGE OF ALL OF SIMP.DAT

	INTEGER CNTBL(74,5),RAW(5),GRPT,DAY,TYPE,DIMOT(12),
	1DATE,DATE2
	DIMENSION ABSMAX(5),OUTLIN(72),SYMTAB(5),MJTBLE(74,5)
	1,MONTAB(12),IDAYS(7)
	DOUBLE PRECISION IDAYL(7)
	DATA(IDAYS(J),J=1,7)/'MON','TUE','WED','THU','FRI','SAT','SUN'/
	DATA(IDAYL(J),J=1,7)/'MONDAYS   ','TUESDAYS  ','WEDNESDAYS',
	1'THURSDAYS ','FRIDAYS   ','SATURDAYS ','SUNDAYS   '/
	DATA(MONTAB(J),J=1,12)/'JAN','FEB','MAR','APR','MAY','JUN',
	1'JUL','AUG','SEP','OCT','NOV','DEC'/
	DATA(ABSMAX(J),J=1,5)/64.,65.,100.,5000.,36000./
	DATA(SYMTAB(J),J=1,5)/'L','J','C','D','S'/
C	DATA(DIMOT(J),J=1,12)/31,29,31,30,31,30,31,31,30,31,30,31/
	DATA(DIMOT(J),J=1,12)/31,28,31,30,31,30,31,31,30,31,30,31/
C	MAXIMUM VALUES
	DATA MXLT,MXST,MXDT/64,36000,5000/

	WRITE(5,1)
1	FORMAT(1X,'DATE IS (MMM,DD) ',$)
	READ(5,10) MO1,ID1
10	FORMAT(A3,1X,I)
	OPEN(UNIT=1,ACCESS='RANDIN',RECORD SIZE=80,FILE='SIMP.DAT')
	OPEN(UNIT=20,ACCESS='SEQOUT',FILE='GRAPH.DAT')
	IF(ID1.EQ.0) ICODE=MO1
	IF(MO1.EQ.' ') ICODE=1
	DO 50 J=1,12
	IF(MO1.EQ.MONTAB(J)) MO1=J
50	IF(MO2.EQ.MONTAB(J)) MO2=J

C	CLEAR TABLES

	DO 100 J=1,5
	DO 100 K=1,74
	MJTBLE(K,J)=0
100	CNTBL(K,J)=0

C	LOOK FOR DATES BETWEEN THOSE SPECIFIED INCLUSIVE

	GRPT=-72
310	GRPT=GRPT+73
	READ(1#GRPT,300,END=400) DAY,MCOD,AMUN,DATE,YEAR,
     #MXL,MXD,MXS,MXT,MXC,MXK
300	FORMAT(1X,A3,3X,I2,1X,A3,I5,I6,6I9)
	IF(ICODE.EQ.1) GO TO 220
	IF(ICODE.EQ.DAY) GO TO 220
	IF(ICODE.NE.0) GO TO 310
	IF(MCOD.LT.MO1) GO TO 310
	IF((MCOD.EQ.MO1).AND.(DATE.LT.ID1)) GO TO 310
	IF((MCOD.EQ.MO1).AND.(DATE.EQ.ID1)) GO TO 220
	TYPE 320
320	FORMAT(' DATE NOT IN SIMP.DAT')
	CALL EXIT

C	ADD A DAY TO MJTBLE

220	DO 200 J=1,51
	READ(1#J+GRPT+21,210,END=400) RAW
210	FORMAT(5I)
	DO 200 K=1,5
	IF(RAW(K).EQ.0) GO TO 200
	CNTBL(J+1,K)=CNTBL(J+1,K)+1
	CNTBL(J+2,K)=CNTBL(J+2,K)+1
	CNTBL(J,K)=CNTBL(J,K)+1
	MJTBLE(J,K)=MJTBLE(J,K)+RAW(K)
	MJTBLE(J+1,K)=MJTBLE(J+1,K)+RAW(K)
	MJTBLE(J+2,K)=MJTBLE(J+2,K)+RAW(K)
200	CONTINUE
	READ(1#GRPT+73,300,END=400) DAY2,MCOD2,BLA1,DATE2,BLA2,
     #ILA1,ILA2,ILA3,ILA4,ILA5,ILA6
	IF((MCOD2.EQ.MCOD).AND.(DATE2.EQ.DATE+1)) GO TO 230
	IF((DATE.EQ.DIMOT(MCOD)).AND.(DATE2.EQ.1).AND.
	1(MCOD2.EQ.MCOD+1)) GO TO 230
	IF((MCOD.EQ.12).AND.(DATE.EQ.31).AND.(DATE2.EQ.1)
	1.AND.(MCOD2.EQ.1)) GO TO 230
	GO TO 250
230	DO 240 J=52,72
	READ(1#GRPT+22+J,210,END=400)  RAW
	DO 240 K=1,5
	IF(RAW(K).EQ.0) GO TO 249
	CNTBL(J,K)=CNTBL(J,K)+1
	CNTBL(J+1,K)=CNTBL(J+1,K)+1
	CNTBL(J+2,K)=CNTBL(J+2,K)+1
249	MJTBLE(J+1,K)=MJTBLE(J+1,K)+RAW(K)
	MJTBLE(J+2,K)=MJTBLE(J+2,K)+RAW(K)
	MJTBLE(J,K)=MJTBLE(J,K)+RAW(K)
240	CONTINUE
250	IF(ICODE.NE.0) GO TO 310

C	MAKE MJTLB GRAPHABLE
400	DO 410 J=1,5
	DO 410 K=1,74
	IF(MJTBLE(K,J).EQ.0) GO TO 410
	MJTBLE(K,J)=((MJTBLE(K,J)*50.)/CNTBL(K,J))/ABSMAX(J)
410	CONTINUE

C	GRAPH IT NOW? YES VIRGINIA.

	DO 930 I=1,7
	IF(ICODE.EQ.IDAYS(I)) GO TO 940
930	CONTINUE
940	IF(ICODE.EQ.0) WRITE(20,900) DAY,AMUN,DATE,YEAR
	IF(ICODE.EQ.1) WRITE(20,910)
	IF((ICODE.NE.0).AND.(ICODE.NE.1)) WRITE(20,920) IDAYL(I)
910	FORMAT('AVERAGE OF ALL DAYS FROM JANUARY 4 TO FEBRUARY 25'
     1	,', WINTER SEMESTER 1973')
920	FORMAT(' AVERAGE FOR ALL ',A10,' FROM JANUARY 4 TO'
     1	,' FEBRUARY 25, WINTER SEMESTER 1973')
900	FORMAT(1H+,'         RESOURCE UTILIZATION GRAPH FOR: ',
     #A3,3X,A3,1X,I2,','1X,I4)
	DO 500 J=1,50
	JT2=(51-J)*2
	DO 530 M=1,72
530	OUTLIN(M)=' '
	DO 510 K=2,73
	DO 510 L=1,5
	IF(L.EQ.2) GO TO 510
	IF(MJTBLE(K,L).EQ.51-J) GO TO 540
510	CONTINUE
	IF((JT2/10).NE.(JT2/10.)) WRITE(20,520) OUTLIN
500	IF((JT2/10).EQ.(JT2/10.)) WRITE(20,521) JT2,OUTLIN
520	FORMAT(1X,4X,'*',72A1)
521	FORMAT(1X,I3,'%*',72A1)
	WRITE(20,610)
610	FORMAT(1X,4X,73('*'))
	WRITE(20,560)
560	FORMAT(3X,'  0  0  0  1  1  N  0  0  0  0  0  0  0  0',
	1'  0  1  1  M  0  0  0  0  0  0  0')
	WRITE(20,570)
570	FORMAT(3X,'  7  8  9  0  1  O  1  2  3  4  5  6  7  8',
	1'  9  0  1  I  1  2  3  4  5  6  7')
	WRITE(20,580)
580	FORMAT(20X,'O',35X,'D')
	WRITE(20,590)
590	FORMAT(20X,'N',35X,'N')
	MXL=MXL/FLOAT(MXLT)*100.+.5
	MXS=MXS/FLOAT(MXST)*100.+.5
	MXD=MXD/FLOAT(MXDT)*100.+.5
	WRITE(20,600)MXL,MXLT,MXT
	WRITE(20,601)MXS,MXST,MXC
	WRITE(20,602)MXD,MXDT,MXK
600	FORMAT('0    MAXIMUM NUMBER OF LINES:',T31,2X,I3,'%/',I3,
     #' LINES',T57,'MAX TTY-BUFFERS:',T75,I3,'%')
601	FORMAT('     MAX RATE OF SWAPPING:',T31,I5,'%/',I6,' BLK/MIN',
     #T57,'MAX C.B.:'T75,I3,'%')
602	FORMAT('     MAX SPEED OF PUBLIC DSKS:',T31,I5,
     #'%/',I5,' BLK/MIN',T57,'MAX SWAP-K:',T75,I3,'%')
	CALL EXIT

540	IF(OUTLIN(K-1).NE.' ') GO TO 550
	OUTLIN(K-1)=SYMTAB(L)
	GO TO 510
550	OUTLIN(K-1)='O'
	GO TO 510

	END
