	SUBROUTINE CSM8
C	PRINT CONTROLLER
	INTEGER OU,PRINT,PRTNUM
	COMMON/FLAGS/KEY7
	COMMON/NUMS/IDUM(1201),DUM(600),C(201)
	EQUIVALENCE(C(201),T)
	COMMON/PRNT/NK,PRINT(20),LEN,PRTNUM,K
	COMMON/PRT2/PRTDAT(1000)
	COMMON/ODEVIM/OU
	COMMON/NOPRNT/NOPRNT
	K=K+1
	IF(K.LE.LEN)GOTO 5
	WRITE(5,1)K,LEN,T
1	FORMAT(' PROCESSING ERROR IN CSM8',2I4,G10.6)
	STOP
5	IF(KEY7.NE.1)GOTO 15
C	IF PRINTING, PRINT AS MANY BLOCKS AS DEVICE PERMITS.
	WRITE(OU,10)T,(C(PRINT(I)),I=1,PRTNUM)
10	FORMAT(1X,G11.5,9G13.6)
	IF(NK.LE.PRTNUM)GOTO 30
C	IF PLOTTING, SAVE ALL BLOCKS. IF PRINTING, SAVE THOSE NOT PRINTED
15	DO 20 I=PRTNUM+1,NK
	IADDR=LEN*(I-(PRTNUM+1))+K
20	PRTDAT(IADDR)=C(PRINT(I))
30	IF((OU.NE.5.OR.KEY7.NE.1).AND.NOPRNT.NE.1)WRITE(5,10)T
	RETURN
	END
	SUBROUTINE CSM9
C	POST RUN PRINT PROCESSOR
	INTEGER OU,PRINT,BLANK,DASH,PLUS,IPLOT(101),PRTNUM
	COMMON/FLAGS/KEY7
	COMMON/DATA/DT,DTS2,TTOT,DUM(33),TSAMP
	COMMON/PRNT/NK,PRINT(20),LEN,PRTNUM,J
	COMMON/PRT2/PRTDAT(1000)
	COMMON/ODEVIM/OU
	DATA BLANK,DASH,PLUS,II/' ','-','+','I'/
	I=PRTNUM+1
	IF(KEY7.NE.1)GOTO 50
	L=4
	IF(OU.NE.5)L=9
10	IF(NK.LT.I)GOTO 160
	J=NK-I+1
	J=MIN0(L,J)
	I1=I-PRTNUM-1
	I=I+J
	I3=I-PRTNUM-2
	T=0.
	M=1
	WRITE(OU,15)(PRINT(I2),I2=PRTNUM+1,I-1)
15	FORMAT('1'/5X,'TIME ',9(4X,'BLOCK',I4:))
20	N=(T+DT/4.)/TSAMP
	IF(N.LT.M-1)GOTO 40
	WRITE(OU,30)T,(PRTDAT(LEN*I2+M),I2=I1,I3)
30	FORMAT(1X,G11.5,9G13.6)
	M=M+1
40	T=T+DT
	IF(T.GT.TTOT+DT/4.)GOTO 10
	GOTO 20
50	L=50
	IF(OU.NE.5)L=100
	DO 150 I=0,NK-1
	DO 70 K=1,J
	IADDR=LEN*I+K
	X=PRTDAT(IADDR)
	IF(K.NE.1)GOTO 60
	VMIN=X
	VMAX=X
60	IF(X.GT.VMAX)VMAX=X
	IF(X.LT.VMIN)VMIN=X
70	CONTINUE
	VDEL=VMAX-VMIN
	IF(VDEL.EQ.0.)VDEL=1.
	T=0.
	M=1
	IF(OU.EQ.5)WRITE(OU,71)PRINT(I+1),VMIN,VMAX
	IF(OU.NE.5)WRITE(OU,72)PRINT(I+1),VMIN,VMAX
71	FORMAT('1 TIME     BLOCK',I4,1X,G13.6,26X,G13.6)
72	FORMAT('1 TIME     BLOCK',I4,1X,G13.6,76X,G13.6)
75	K=(T+DT/4.)/TSAMP
	IF(K.LT.M-1)GOTO 140
	IADDR=LEN*I+M
	X=PRTDAT(IADDR)
	M=M+1
	N=.5+L*(X-VMIN)/VDEL
	IF(N.LE.0)N=0
	IF(N.GE.L)N=L-1
C	DASHES TO LEFT OF POINT
	DO 80 I1=2,N
80	IPLOT(I1)=DASH
C	INDICATE POINT BY A PLUS SIGN
100	IPLOT(N+1)=PLUS
	N=N+2
	IF(N.GT.L)GOTO 120
C	BLANKS TO RIGHT OF POINT
	DO 110 I1=N,L
110	IPLOT(I1)=BLANK
C	INDICATE MARGINS BY I'S
120	IPLOT(1)=II
	IPLOT(L+1)=II
	WRITE(OU,130)T,X,(IPLOT(I1),I1=1,L+1)
130	FORMAT(1X,G10.3,G11.4,101A1)
140	T=T+DT
	IF(T.LE.TTOT+DT/4.)GOTO 75
150	CONTINUE
160	RETURN
	END
	SUBROUTINE CSM10
C	CONTROLS THE COMPUTATION AND OUTPUT
	INTEGER TEST5,ORDER
	DIMENSION Y(25),DY0(25),DY1(25),DY2(25)
	COMMON/FLAGS/IDUM(5),TEST5
	COMMON/COUNTS/NLIST,NCON,NEQ
	COMMON/DATA/DT,DTS2,TTOT,DUM(33),TSAMP,IR
	COMMON/INTGS/INTG(25),DYDT(25)
	COMMON/NUMS/ORDER(201),MTRX(200,5),PAR1(200),DUM2(200,2),C(201)
	EQUIVALENCE(C(201),T)
	INTEGER OU
	COMMON /ODEVIM/OU
C	NORMAL SETUP
	DO 10 NEXT=2,NLIST
	I=ORDER(NEXT)
10	C(I)=PAR1(I)
	T=0.0
	TZERO=0.0
	IR=7243
	EPSLN=DTS2/(TSAMP*2.0)
	TEST5=1
	N=1
	NN=T/TSAMP+1.0
	CALL CSM11
C
C	START EXECUTION
30	CONTINUE
40	GO TO (50,80,100,110,110,110),TEST5
50	CALL CSM8
C	FIRST HALF-STEP
60	TEST5=2
	DO 70 NEXT=1,NEQ
	Y(NEXT)=C(INTG(NEXT))
	DY0(NEXT)=DYDT(NEXT)
70	C(INTG(NEXT))=C(INTG(NEXT))+DTS2*DYDT(NEXT)
	AXX=N
	TNEXT=AXX*DT+TZERO
	T=TNEXT-DTS2
	CALL CSM11
	DO 90 NEXT=1,NEQ
80	DY1(NEXT)=DYDT(NEXT)
90	C(INTG(NEXT))=Y(NEXT)+DTS2*DYDT(NEXT)
	CALL CSM11
C	SECOND HALF STEP
	TEST5=3
	DO 95 NEXT=1,NEQ
	DY2(NEXT)=DYDT(NEXT)
95	C(INTG(NEXT))=Y(NEXT)+DT*DYDT(NEXT)
	T=TNEXT
	N=N+1
	CALL CSM11
	DO 97 NEXT=1,NEQ
97	C(INTG(NEXT))=Y(NEXT)+DT*((DY1(NEXT)+DY2(NEXT))/3.+
	1 (DY0(NEXT)+DYDT(NEXT))/6.)
	CALL CSM11
	GO TO 30
C	TIME TO PRINT
100	M=T/TSAMP+EPSLN
	IF (M.LT.NN) GO TO 120
110	CALL CSM8
	NN=M+1
C	IS RUN FINISHED
120	IF (TEST5.GT.3) GO TO 150
130	IF (T-TTOT+DTS2) 60,150,150
140	TEST5=5
150	CALL CSM9
	RETURN
	END
	SUBROUTINE CSM11
C	DOES THE COMPUTATION REQUIRED
C	   TO EVALUATE THE DERIVATIVE VECTOR
C	   FOR ONE-HALF TIME STEP
	INTEGER TEST5,ORDER
	COMMON/FLAGS/IDUM(5),TEST5
	COMMON/COUNTS/NLIST,NCON,NEQ
	COMMON/DATA/DT,DTS2,DUM,F(3,11),DUM2,IR
	COMMON/INTGS/INTG(25),DYDT(25)
	COMMON/NUMS/ORDER(201),MTRX1(200),MTRX2(200),MTRX3(200),
	1 MTRX4(200),MTRX5(200),PAR1(200),PAR2(200),PAR3(200),C(201)
	EQUIVALENCE(C(201),T)
C
	NEXT=NCON
20	I=ORDER(NEXT)
	P1=PAR1(I)
	P2=PAR2(I)
	P3=PAR3(I)
	J=MTRX2(I)
	K=MTRX3(I)
	L=MTRX4(I)
	IF (J.GE.0.AND.J.LE.201) CJ=C(J)
	IF (K.GE.0.AND.K.LE.201) CK=C(K)
	IF (L.GE.0.AND.L.LE.201) CL=C(L)
	M=MTRX1(I)
	IF (M.LE.10) GO TO (25,30,35,40,75,80,110,120,130,140),M
	M=M-10
	IF (M.LE.10) GO TO (650,150,180,190,210,220,230,240,270,290),M
	M=M-10
	GO TO (340,350,360,370,380,390,410,510,520),M
C	A - POWER
25	CI=CJ**P1
	GOTO 600
C	B - BANG-BANG
30	CI=SIGN(1.0,CJ)
	GO TO 600
C	C - COSINE
35	CI=COS(CJ)
	GOTO 600
C	D - DEAD SPACE
40	IF (CJ) 50,200,60
50	DIFF=CJ-P2
	IF (DIFF) 70,200,200
60	DIFF=CJ-P1
	IF (DIFF) 200,200,70
70	CI=DIFF
	GO TO 600
C	E - SINE
75	CI=SIN(CJ)
	GOTO 600
C	F - FUNCTION GENERATOR
80	NF=MTRX5(I)
	P3=P1-P2
	IF (P3.LE.0.0) GO TO 750
	P1=10.0*(CJ-P2)/P3
	IF (P1.GT.0.0) GO TO 90
	CI=F(NF,1)
	GO TO 600
90	NSECT=P1
	IF (NSECT.LT.10) GO TO 100
	CI=F(NF,11)
	GO TO 600
100	P2=NSECT
	P3=P1-P2
	P1=F(NF,NSECT+1)
	P2=F(NF,NSECT+2)
	CI=P1+P3*(P2-P1)
	GO TO 600
C	G - GAIN
110	CI=P1*CJ
	GO TO 600
C	H - HALF POWER (SQUARE ROOT)
120	IF (CJ.LT.0.0) GO TO 750
	CI=SQRT(CJ)
	GO TO 600
C	I - INTEGRATOR (MAXIMUM 25 ELEMENTS)
130	M=MTRX5(I)
	DYDT(M)=CJ+P2*CK+P3*CL
	GO TO 650
C	J - JITTER (RANDOM NUMBER GENERATOR BETWEEN + AND - 1)
140	IR=259*IR
	CI=FLOAT(IR)/131072.0
	GO TO 600
C	K - CONSTANT
C	L - LIMITER
150	IF (CJ.LT.P1) GO TO 160
	CI=P1
	GO TO 600
160	IF (CJ.GT.P2) GO TO 280
170	CI=P2
	GO TO 600
C	M - MAGNITUDE
180	CI=ABS(CJ)
	GO TO 600
C	N - NEGATIVE CLIPPER
190	IF (CJ.GT.0.0) GO TO 280
200	CI=0.0
	GO TO 600
C	O - OFFSET
210	CI=CJ+P1
	GO TO 600
C	P - POSITIVE CLIPPER
220	IF (CJ) 280,200,200
C	Q - QUIT
230	IF (CJ-CK) 650,650,850
C	R - RELAY
240	IF (CJ.LE.P1) GO TO 260
250	CI=CK
	GO TO 600
260	CI=CL
	GO TO 600
C	S - SWITCH
270	IF (CJ.LT.P1) GO TO 260
	GO TO 250
280	CI=CJ
	GO TO 600
C	T -TIME PULSE GENERATOR
290	IF (TEST5-2) 300,200,330
300	MTRX5(I)=0
310	IF (CJ.LT.0.0) GO TO 200
	MTRX5(I)=1
320	PAR2(I)=-P1+DTS2+DT
	CI=1.0
	GO TO 600
330	IF (MTRX5(I).EQ.0) GO TO 310
	IF (P2.GE.0.0) GO TO 320
	PAR2(I)=P2+DT
	GO TO 200
C	U - UNIT DELAY
340	IF (TEST5.NE.1) C(I)=P2
	PAR2(I)=CJ
	GO TO 650
C	V - VACUOUS (USED IN CONJUNCTION WITH WYE ELEMENT)
350	IF (TEST5.EQ.1) MTRX5(I)=NEXT
	GO TO 650
C	W - WEIGHTED SUMMER
360	CI=CJ*P1+CK*P2+CL*P3
	GO TO 600
C	X - MULTIPLIER
370	CI=CJ*CK
	GO TO 600
C	Y - WYE(USED IN CONJUNCTION WITH VACUOUS ELEMENT)
380	IF (ABS(1.0-CK/CJ).LE.P1) GO TO 280
	C(K)=(1.0-P2)*CJ+P2*CK
	NEXT=MTRX5(K)
	GO TO 20
C	Z - ZERO ORDER HOLD
390	IF (TEST5.NE.1) GO TO 400
	PAR2(I)=C(I)
	P2=C(I)
400	IF (CK.LE.0.0) GO TO 170
	PAR2(I)=CJ
	GO TO 280
C	+ - SUMMER
410	IF (J) 420,430,440
420	J=-J
	CI=-C(J)
	GO TO 450
430	CI=0.0
	GO TO 450
440	CI=CJ
450	IF (K) 460,480,470
460	K=-K
	CI=CI-C(K)
	GO TO 480
470	CI=CI+CK
480	IF (L) 490,600,500
490	L=-L
	CI=CI-C(L)
	GO TO 600
500	CI=CI+CL
	GO TO 600
C	- - SIGN INVERTER
510	CI=-CJ
	GO TO 600
C	/ - DIVIDER
520	IF (CK.EQ.0.0) GO TO 750
	CI=CJ/CK
C	1 - SPECIAL ELEMENT NUMBER 1
C	2 - SPECIAL ELEMENT NUMBER 2
C	3 - SPECIAL ELEMENT NUMBER 3
C	4 - SPECIAL ELEMENT NUMBER 4
C	5 - SPECIAL ELEMENT NUMBER 5
C	HAVE ALL BEEN DELETED
600	C(I)=CI
650	IF (NEXT-NLIST) 700,900,750
700	NEXT=NEXT+1
	GO TO 20
C	PROCESSING ERROR
750	TEST5=4
	RETURN
C	RUN TERMINATED BY SWITCH 0
800	TEST5=5
	RETURN
C	RUN TERMINATED BY QUIT ELEMENT
850	TEST5=6
900	RETURN
	END
