	SUBROUTINE CSM3
C	SORT
	INTEGER TEST1,DELAY(25),ORDER(76)
	DIMENSION MTRX(75,5),INTG(25)
	COMMON REALS(395),INTS(547)
	EQUIVALENCE (INTS(1),MTRX(1,1)),(INTS(396),INTG(1))
	EQUIVALENCE (INTS(424),DELAY(1)),(INTS(449),ORDER(1))
	EQUIVALENCE (INTS(525),TEST1),(INTS(534),NLIST)
	EQUIVALENCE (INTS(540),NCON),(INTS(541),NOD),(INTS(542),NEQ)
C	RESET ERROR INDICATOR
	IERR=2
	DO 10 N=NCON,76
10	ORDER(N)=0
C
C	SORT OPERATION
	NLIST=NCON-1
20	DO 80 I=1,75
	IF (MTRX(I,1).GE.0) GO TO 80
	DO 70 J=2,4
	LTEST=IABS(MTRX(I,J))
	IF (LTEST.EQ.0) GO TO 70
	IF (NOD.EQ.0) GO TO 40
	DO 30 K=1,NOD
	IF (LTEST.EQ.DELAY(K)) GO TO 70
30	CONTINUE
40	DO 50 K=1,NEQ
	IF (LTEST.EQ.INTG(K)) GO TO 70
50	CONTINUE
	DO 60 K=1,NLIST
	IF (LTEST.EQ.ORDER(K)) GO TO 70
60	CONTINUE
	GO TO 80
70	CONTINUE
	GO TO 130
80	CONTINUE
C
C	SORT TEST
	DO 90 I=1,75
	IF (MTRX(I,1).LT.0) GO TO 110
90	CONTINUE
	IF (IERR.EQ.1) GO TO 100
C	SUCCESSFUL SORT
	TEST1=2
	RETURN
C	UNSUCCESSFUL SORT
100	TEST1=1
	RETURN
C	SORT FAILURE - SET ERROR INDICATOR, TYPE ERROR MESSAGE,
C	   AND PUT BLOCK IN THE SORT ORDER LIST TO DETERMINE
C	   WHETHER THE REST OF THE CONFIGURATION WOULD BE OK
110	IERR=1
	WRITE(4,120) I
120	FORMAT(22H SORT FAILURE AT BLOCK,I3)
130	MTRX(I,1)=-MTRX(I,1)
	NLIST=NLIST+1
	ORDER (NLIST)=I
	GO TO 20
	END
