	SUBROUTINE CSM2
C	PREPARE FOR SORT
	INTEGER TEST(9),DELAY(25),ORDER(76)
	DIMENSION MTRX(75,5),INTG(25)
	COMMON REALS(395),INTS(547)
	EQUIVALENCE (INTS(1),MTRX(1,1))
	EQUIVALENCE (INTS(396),INTG(1))
	EQUIVALENCE (INTS(424),DELAY(1))
	EQUIVALENCE (INTS(449),ORDER(1))
	EQUIVALENCE (INTS(525),TEST(1))
	EQUIVALENCE (INTS(540),NCON)
	EQUIVALENCE (INTS(541),NOD)
	EQUIVALENCE (INTS(542),NEQ)
	EQUIVALENCE (INTS(543),NFG)
C	RESET ERROR INDICATOR AND COUNTERS
	IERR=2
	NOD=0
	NEQ=0
	IFG=0
	NCON=2
	ORDER(1)=76
C
C	TEST FOR SELECTED ELEMENTS
	DO 80 I=1,75
	ITYPE=IABS(MTRX(I,1))
	IF (ITYPE.EQ.0) GO TO 80
	MTRX(I,1)=ITYPE
	IF (ITYPE.NE.21) GO TO 10
C	UNIT DELAY
	NOD=NOD+1
	DELAY(NOD)=I
	GO TO 40
10	IF (ITYPE.NE.9) GO TO 20
C	INTEGRATOR
	NEQ=NEQ+1
	INTG(NEQ)=I
	MTRX(I,5)=NEQ
	GO TO 40
20	IF (ITYPE.NE.11) GO TO 30
C	CONSTANT
	ORDER(NCON)=I
	NCON=NCON+1
	GO TO 50
C	FUNCTION GENERATOR
30	IF (ITYPE.EQ.6) IFG=IFG+1
C	NEGATE ELEMENT IDENTIFIER UNTIL AFTER SORTING
40	MTRX(I,1)=-ITYPE
50	DO 70 J=2,4
	LTEST=IABS(MTRX(I,J))
	IF (LTEST.LE.0.OR.LTEST.GT.75.OR.MTRX(LTEST,1).NE.0) GO TO 70
	WRITE(4,60) LTEST,I
60	FORMAT(6H BLOCK,I3,16H, INPUT TO BLOCK,I3,9H, MISSING)
	IERR=1
70	CONTINUE
80	CONTINUE
C
C	TEST ON PROPER NUMBER OF ELEMENTS
	IF (NEQ.GT.0) GO TO 100
	WRITE(4,90)
90	FORMAT(31H AT LEAST 1 INTEGRATOR REQUIRED)
	IERR=1
	GO TO 120
100	IF (NEQ.LE.25) GO TO 120
	WRITE(4,110)
110	FORMAT(48H THE MAXIMUM OF 25 INTEGRATORS HAS BEEN EXCEEDED)
	IERR=1
120	IF (NOD.LE.25) GO TO 140
	WRITE(4,130)
130	FORMAT(48H THE MAXIMUM OF 25 UNIT DELAYS HAS BEEN EXCEEDED)
	IERR=1
140	IF (IFG.LE.3) GO TO 170
	WRITE(4,150)
150   FORMAT(55H THE MAXIMUM OF 3 FUNCTION GENERATORS HAS BEEN EXCEEDED)
C	UNSUCCESSFUL PRE-SORT
160	TEST(1)=1
	RETURN
170	IF (IERR.EQ.1) GO TO 160
	IF (IFG.GT.0) GO TO 180
C	NO FUNCTION GENERATORS
	TEST(4)=1
	NFG=0
	GO TO 190
C	SOME FUNCTION GENERATORS
180	TEST(4)=2
	IF (IFG.GT.NFG) TEST(3)=1
C	TEST3=1 TO SIGNAL ADDITION OF FUNCTION GENERATOR BLOCK(S)
	NFG=IFG
C	SUCCESSFUL PRE-SORT
190	TEST(1)=2
	RETURN
	END
