      SUBROUTINE ENTMAT (NB, A, D, N, WGT, MATRIX, WMATRX, AMIN, AMAX,      0010
     1   NA, DMIN, DMAX, ND)                                                0030
CENTMAT  ENTERS POINT (A,D) INTO 2 - DIM. HISTOGRAM MATRIX                  0020
C                                                                           0040
      DIMENSION    MATRIX(2), A(2), D(2), WMATRX(2), WGT(2)                 0050
C                                                                           0070
      NAA = MIN0(NA, 20)                                                    0080
      DA = (AMAX - AMIN) / FLOAT(NAA)                                       0090
      DD = (DMAX - DMIN) / FLOAT(ND)                                        0100
      NAA = NAA + 1                                                         0110
      NTT = NAA*(ND + 1)                                                    0120
      MTT = NTT + 5                                                         0130
C                                                                           0140
      DO 100   K = 1, N                                                     0150
      IF (A(K) - AMIN)   5, 10, 10                                          0160
 5    NRET = 1                                                              0170
      GO TO 35                                                              0180
 10   IF (A(K) - AMAX)   20, 20, 15                                         0190
 15   NRET = 2                                                              0200
      GO TO 35                                                              0210
 20   IF (D(K) - DMIN)   25, 30, 30                                         0220
 25   NRET = 3                                                              0230
      GO TO 35                                                              0240
 30   IF (D(K) - DMAX)   40, 40, 32                                         0250
 32   NRET = 4                                                              0260
C                                                                           0270
 35   NOV = NTT + NRET                                                      0280
      GO TO (36, 38), NB                                                    0290
 36   MATRIX(NOV) = MATRIX(NOV) + 1                                         0300
      MATRIX(MTT) = MATRIX(MTT) + 1                                         0310
      GO TO 100                                                             0320
 38   WMATRX(NOV) = WMATRX(NOV) + WGT(K)                                    0330
      WMATRX(MTT) = WMATRX(MTT) + WGT(K)                                    0340
      GO TO 100                                                             0350
C                                                                           0360
 40   CONTINUE                                                              0370
      IA = (A(K) - AMIN) / DA + 1.0                                         0380
      ID = (D(K) - DMIN) / DD + 1.0                                         0390
      MM = (ID - 1) * NAA + IA                                              0400
      NAT = ID*NAA                                                          0410
      NDT = ND*NAA + IA                                                     0420
      GO TO (60, 80), NB                                                    0430
 60   MATRIX(MM) = MATRIX(MM) + 1                                           0440
      MATRIX(NTT) = MATRIX(NTT) + 1                                         0450
      MATRIX(NAT) = MATRIX(NAT) + 1                                         0460
      MATRIX(NDT) = MATRIX(NDT) + 1                                         0470
      MATRIX(MTT) = MATRIX(MTT) + 1                                         0480
      GO TO 100                                                             0490
 80   WMATRX(MM) = WMATRX(MM) + WGT(K)                                      0500
      WMATRX(NTT) = WMATRX(NTT) + WGT(K)                                    0510
      WMATRX(NAT) = WMATRX(NAT) + WGT(K)                                    0520
      WMATRX(NDT) = WMATRX(NDT) + WGT(K)                                    0530
      WMATRX(MTT) = WMATRX(MTT) + WGT(K)                                    0540
 100  CONTINUE                                                              0550
C                                                                           0560
 200  RETURN                                                                0570
      END                                                                   0580
      SUBROUTINE OUTMAT(NOT,HEAD,NB,IPLOT,AMIN,AMAX,NA,DMIN,DMAX,ND)
COUTMAT  PRINT ROUTINE FOR 2-DIMENSIONAL HISTOGRAMS
C
C	EXTENSIVE CHANGES MADE FOR PDP-10  LDK  12/69
      INTEGER TYPEA,TYPEB,TYPEC
      DIMENSION IPLOT(2), HEAD(6)
      DIMENSION AROW(50), IAROW(50), ALABEL(50)
      DIMENSION IFMT(10), FMT(10)
      DIMENSION IDASH(4), KDASH(2)
      DIMENSION KQDT1(3),KQDT2(3),KQDT3(3),TOT(2)
      DIMENSION IQDT(5), LQDT(7), MQDT(2)
      EQUIVALENCE (ALABEL,AROW,IAROW), (FMT,IFMT), (XNN,NN)
	DATA TOT /'TOTALS    '/
      DATA IDASH /'I-----I-----I-------'/
      DATA KDASH /'I--  --I  '/
      DATA KQDT1/' IS UNFILLED'/
      DATA KQDT2/', UNWEIGHTED'/
      DATA KQDT3/', WEIGHTED  '/
      DATA IQDT /'(6X       F10.3,5X2A5/)  '/
      DATA LQDT /'(12X      2HI       (A4,1X)1HI5XA4)'/
      DATA MQDT /'(3X2A4,1X '/
	EQUIVALENCE  (IBLANK,IQDT(2))
C
      NAA = MIN0(NA, 20)
      MTT = (NAA + 1)*(ND + 1) + 5
      IF(IPLOT(MTT)) 2,2,4
2     TYPEA=KQDT1(1)
      TYPEB=KQDT1(2)
      TYPEC=KQDT1(3)
      NBR = 2
      GO TO 10
 4    NBR = 1
      GO TO (6, 8), NB
6     TYPEA=KQDT2(1)
      TYPEB=KQDT2(2)
      TYPEC=KQDT2(3)
      GO TO 10
8     TYPEA=KQDT3(1)
      TYPEB=KQDT3(2)
      TYPEC=KQDT3(3)
10    WRITE(NOT,9000)HEAD,TYPEA,TYPEB,TYPEC
9000  FORMAT(1H1/1H 10X24HTWO DIMENSIONAL PLOT OF 3A5,4H VS 6A5/)
      GO TO (12, 120), NBR
C
12    CONTINUE
      DA = (AMAX - AMIN) / FLOAT(NAA)
      NLA = NAA/2 + 1
      NDM = ND + 1
      NAM = NAA + 1
C	PRINT SCALE ACROSS TOP
      ALABEL(1) = AMIN
      DO 20   N = 2, NLA
 20   ALABEL(N) = ALABEL(N - 1) + 2.0 * DA
	DO 210 N=1,5
210	IFMT(N) = IQDT(N)
	FMT(2) = BCDW(NLA)
      WRITE(NOT,IFMT)(ALABEL(K),K=1,NLA),TOT
	DO 225 N=1,7
225	IFMT(N) = LQDT(N)
	FMT(4) = BCDW(NAA)
      NGO = 1
      DLABEL = DMIN
	NAMT = NAA + 3
22    IAROW(1)=IDASH(1)
	DO 24 I=2,NAA
24	IAROW(I) = IDASH(2)
	IAROW(NAM) = IDASH(3)
	IAROW(NAM+1) = IDASH(4)
	IAROW(NAMT) = IDASH(4)
      WRITE(NOT,9024)DLABEL,(IAROW(M),M=1,NAMT)
9024  FORMAT(1XF10.3,1X24A5)
      GO TO (28, 82), NGO
C
 28   DD = (DMAX - DMIN) / FLOAT(ND)
      MM = 0
      N=0
  130 N=N+1
      DO 30 K=1,NAMT
30    IAROW(K)=IBLANK
      DO 48   K = 1, NAM
      MM = MM + 1
      IF(IPLOT(MM))48,32,36
 32   GO TO (34, 36), NBR
 34   IF (K - NAM)   48, 36, 48
36    NN=IPLOT(MM)
      IF(NB.EQ.2)  NN=XNN+SIGN(0.5,XNN)
      AROW(K)=BCDW(NN)
 48   CONTINUE
 50   GO TO (60, 90), NBR
C	PRINT HORIZONTAL DIVIDING LINE
60    CONTINUE
      WRITE(NOT,IFMT)(IAROW(K),K=1,NAM)
      DLABEL = DLABEL + DD
      IF (N - ND)   70, 80, 80
70    IAROW(1)=KDASH(1)
      IAROW(NAM)=KDASH(2)
      DO 74   K = 2, NAA
74    IAROW(K)=IBLANK
      WRITE(NOT,9024) DLABEL,(IAROW(M),M=1,NAM)
      GO TO 130
C
80    NGO=2
C	GO PRINT BOTTOM AXIS
      GO TO 22
82    IFMT(1)=MQDT(1)
      IFMT(2)=MQDT(2)
      NBR = 2
      GO TO 130
90	CONTINUE
      WRITE(NOT,IFMT)(IBLANK,I=1,NAMT)
      WRITE(NOT,IFMT)TOT,(IAROW(K),K=1,NAM)
      IAROW(1) = IPLOT(MTT)
      DO 95 I=1,4
      N = MM + I
95    IAROW(I+1) = IPLOT(N)
      IF (NB-1) 110,111,110
110   WRITE(NOT,9103) (AROW(I),I=1,5)
 9103 FORMAT (1H0 10X26HTOTAL NUMBER OF ENTRIES =  F10.3, 45H INCLUDING 
     1UNDERFLOW AND OVERFLOW AS FOLLOWS  / 1H0 32X9HUNDERFLOW 7X8HOVERFL
     2OW / 1H  20X6HACROSS 2(5XF10.3) / 1H  20X6HDOWN   2(5XF10.3) /)
      GO TO 120
111   WRITE(NOT,9104) (IAROW(I),I=1,5)
 9104 FORMAT (1H0 10X26HTOTAL NUMBER OF ENTRIES =  I10  , 45H INCLUDING 
     1UNDERFLOW AND OVERFLOW AS FOLLOWS  / 1H0 32X9HUNDERFLOW 7X8HOVERFL
     2OW / 1H  20X6HACROSS 2(5XI10  ) / 1H  20X6HDOWN   2(5XI10  ) /)
 120  RETURN
      END
