C     SSAR4                                                             SR4   1 
C     SMALLEST SPACE ANALYSIS-RECTANGULAR - IV, A NONMETRIC METHOD FOR  SR4   2 
C     SOLVING FOR TWO SETS OF POINTS GIVEN THE INTER-SET DISTANCES/SIM- SR4   3 
C     ILARITIES FOR SQUARE MATRICES WITH DIAGONAL ELEMENTS MISSING, DIS-SR4   4 
C     TANCES FOR WHICH ARE TO BE DERIVED.  AN SSA-II ANALYSIS IN A JOINTSR4   5 
C     SPACE.  USEFUL FOR MULTIDIMENSIONAL UNFOLDING (COOMBS).  THIS     SR4   6 
C     RESEARCH IN NONMETRIC METHODS IS SUPPORTED IN PART BY A NSF GRANT SR4   7 
C     (GS-929) TO L. GUTTMAN AND J. C. LINGOES.  PROGRAMMED IN FORTRAN  SR4   8 
C     II BY LINGOES - 5/15/66.                                          SR4   9 
C                                                                       SR4  10 
C     DECK SET-UP FOR G-L(SSAR-IV) -                                    SR4  11 
C                                                                       SR4  12 
C        1.  SYSTEM ID CARD/S.                                          SR4  13 
C        2.  BINARY PROGRAM.                                            SR4  14 
C        3.  TITLE CARD (PUNCH A 1 IN COLUMN 1 AND ANY BCD TITLE IN COL-SR4  15 
C            UMNS 2-72, WHICH WILL BE PRINTED OUT FOR EACH PAGE OF OUT- SR4  16 
C            PUT).                                                      SR4  17 
C        4.  PARAMETER CARD, 8 4-COLUMN FIELDS CONTAINING THE FOLLOWING SR4  18 
C            INFORMATION SERIATUM -                                     SR4  19 
C            A)  NS=ORDER OF MATRIX (.LE. 38),                          SR4  20 
C            B)  MIND=MINIMUM NUMBER OF DIMENSIONS DESIRED.  IF ZERO OR SR4  21 
C                BLANK PROGRAM WILL DETERMINE,                          SR4  22 
C            C)  MAXD=MAXIMUM NUMBER OF DIMENSIONS DESIRED .LE.         SR4  23 
C                (NS-1,10)MIN,                                          SR4  24 
C            D)  ISIM=ZERO OR BLANK IF DISTANCES/DISSIMILARITIES AND 1  SR4  25 
C                IF SIMILARITIES/PROXIMITIES,                           SR4  26 
C            E)  MU=0 OR BLANK IF BOTH A ROW AND A COLUMN SOLUTION IS   SR4  27 
C                DESIRED AND MU=1 IF ONLY A ROW SOLUTION IS NEEDED,     SR4  28 
C            F)  IFD=1 IF DISTANCE MATRIX IS TO BE PRINTED FOR 2 OR MORESR4  29 
C                DIMENSIONS, OTHERWISE SET TO ZERO OR LEAVE BLANK,      SR4  30 
C            G)  IFC=1 IF COORDINATES ARE TO BE PUNCHED FOR 2 OR MORE   SR4  31 
C                DIMENSIONS, OTHERWISE SET TO ZERO OR LEAVE BLANK,      SR4  32 
C            H)  IFCB=1 IF CITY-BLOCK MODEL IS TO BE USED (N.B.  IF THISSR4  33 
C                MODEL IS USED MIND MUST BE .G. 0), OTHERWISE SET TO    SR4  34 
C                ZERO OR LEAVE BLANK FOR EUCLIDEAN MODEL.               SR4  35 
C        5.  FORMAT CARD (DESCRIBING IN F-NOTATION HOW DATA IS PUNCHED).SR4  36 
C        6.  DATA - EACH SET OF CARDS CONTAINS ALL THE DATA FOR ONE ROW SR4  37 
C            OF SUBMATRIX.  NS SETS WILL BE INPUT (SEE SSA-II).         SR4  38 
C        7.  REPEAT ITEMS 3-6 FOR ADDITIONAL RUNS.                      SR4  39 
C                                                                       SR4  40 
C     *** REFERENCES - LINGOES, J. C.  AN IBM 7090 PROGRAM FOR GUTTMAN- SR4  41 
C                                  LINGOES SMALLEST SPACE ANALYSIS-RII. SR4  42 
C                                  BEHAV. SCI., 1966,11, 322.           SR4  43 
C                      LINGOES, J. C.  AN IBM 7090 PROGRAM FOR GUTTMAN- SR4  44 
C                                  LINGOES SMALLEST SPACE ANALYSIS-RIV. SR4  45 
C                                  BEHAV. SCI., 1967,12,74-75.          SR4  46 
C                      LINGOES, J. C.  RECENT COMPUTATIONAL ADVANCES IN SR4  47 
C                                  NONMETRIC METHODOLOGY FOR THE BEHAV- SR4  48 
C                                  IORAL SCIENCES.  PROCEEDINGS OF THE  SR4  49 
C                                  INTERNATIONAL SYMPOSIUM ON MATHEMAT- SR4  50 
C                                  ICAL AND COMPUTATIONAL METHODS IN SO-SR4  51 
C                                  CIAL SCIENCES, ROME, ITALY, 1966.    SR4  52 
C                                                                       SR4  53 
C     *** NOTE COMMENT CARDS FOR PROGRAM CHANGES ON OTHER SYSTEMS.      SR4  54 
C                                                                       SR4  55 
      DIMENSION DIST(76,76), EVAL(5776), C(76,76), EVEC(5776), X(76,10),SR4  56 
     1 XP1(76,11), IND(76,11), STRESS(100), FMT(18), INDEXI(38,38), INDESR4  57 
     2XJ(38,38), PD(38,38), NOTYR(38,38), NTR(38), PHI(76)              SR4  58 
      COMMON INDEXI,DIST,EVAL,INDEXJ,X,XP1,PD,NOTYR                     SR4  59 
      EQUIVALENCE (DIST,EVEC), (EVAL,C), (XP1,IND)                      SR4  60 
C                                                                       SR4  61 
C     SUBROUTINES NEEDED=EIGEN,PLOT,MXOUT, AND ORDER                    SR4  62 
C                                                                       SR4  63 
      DEFINE FILE 13(3000,255,L,KT)                                     SR4  64 
C     TAPE ASSIGNMENTS                                                  SR4  65 
      ITAPE=5                                                           SR4  66 
      JTAPE=6                                                           SR4  67 
174   KT=1                                                              SR4  68 
C     READ TITLE, PARAMETERS, AND FORMAT                                SR4  69 
      READ (ITAPE,158)                                                  SR4  70 
      READ (ITAPE,159) NS,MIND,MAXD,ISIM,MU,IFD,IFC,IFCB                SR4  71 
      READ (ITAPE,160) (FMT(J),J=1,18)                                  SR4  72 
C     INPUT DATA                                                        SR4  73 
      DO 1 J=1,NS                                                       SR4  74 
1     READ (ITAPE,FMT) (PD(I,J),I=1,NS)                                 SR4  75 
C     PRINT INPUT VALUES                                                SR4  76 
      WRITE (JTAPE,158)                                                 SR4  77 
      WRITE (JTAPE,167)                                                 SR4  78 
      DO 2 I=1,NS                                                       SR4  79 
      WRITE (JTAPE,168) I                                               SR4  80 
2     WRITE (JTAPE,169) (PD(J,I),J=1,NS)                                SR4  81 
      MU=MU+1                                                           SR4  82 
      GO TO (3,5), MU                                                   SR4  83 
C     SAVE DATA IF BOTH ROW AND COLUMN SOLUTIONS OPTED                  SR4  84 
3     DO 4 I=1,NS                                                       SR4  85 
4     WRITE (13'KT) (PD(J,I),J=1,NS)                                    SR4  86 
      KT=1                                                              SR4  87 
5     NSP1=NS+1                                                         SR4  88 
C     INITIALIZE                                                        SR4  89 
      MD=76                                                             SR4  90 
      ND=11                                                             SR4  91 
      M1=1                                                              SR4  92 
      NSM1=NS-1                                                         SR4  93 
      NSPNV=NS+NS                                                       SR4  94 
      NSNVM1=NSPNV-1                                                    SR4  95 
      NSNVP1=NSPNV+1                                                    SR4  96 
      FNS=NS                                                            SR4  97 
      FN=NSNVM1                                                         SR4  98 
      FNR=FN+1.                                                         SR4  99 
C     PREPARE MATRIX FOR SORTING                                        SR4 100 
6     DO 7 I=1,NSM1                                                     SR4 101 
      IP1=I+1                                                           SR4 102 
      DO 7 J=IP1,NS                                                     SR4 103 
7     PD(J-1,I)=PD(J,I)                                                 SR4 104 
      DO 9 J=1,NS                                                       SR4 105 
C     *** INSERT CALL TO FAST SORT SUBROUTINE HERE THAT TAKES ADVANTAGE SR4 106 
C     OF PARTIAL ORDERING.                                              SR4 107 
      CALL ORDER (-1,NSM1,PD(1,J),ISIM,INDEXI(1,J))                     SR4 108 
      S=0.                                                              SR4 109 
      DO 8 I=1,NSM1                                                     SR4 110 
      S=S+1.                                                            SR4 111 
      KK=INDEXI(I,J)+NS                                                 SR4 112 
8     DIST(J,KK)=S                                                      SR4 113 
9     CONTINUE                                                          SR4 114 
C     PREPARE MATRIX FOR OBTAINING INITIAL CONFIGURATION                SR4 115 
      STR=2.*FN                                                         SR4 116 
      A=(2.*FNS+FNS)/STR                                                SR4 117 
      DO 10 I=1,NSM1                                                    SR4 118 
      DIST(I,I)=1.                                                      SR4 119 
      IP1=I+1                                                           SR4 120 
      DO 10 J=IP1,NS                                                    SR4 121 
      DIST(I,J)=A                                                       SR4 122 
10    DIST(J,I)=A                                                       SR4 123 
      DIST(NS,NS)=1.                                                    SR4 124 
      DO 11 I=NSP1,NSNVM1                                               SR4 125 
      DIST(I,I)=1.                                                      SR4 126 
      IP1=I+1                                                           SR4 127 
      DO 11 J=IP1,NSPNV                                                 SR4 128 
      DIST(I,J)=A                                                       SR4 129 
11    DIST(J,I)=A                                                       SR4 130 
      DIST(NSPNV,NSPNV)=1.                                              SR4 131 
C     TEST FOR TIES                                                     SR4 132 
      NOTR=0                                                            SR4 133 
      DO 19 I=1,NS                                                      SR4 134 
      NTR(I)=0                                                          SR4 135 
      JJ=1                                                              SR4 136 
      II=-1                                                             SR4 137 
      KK=JJ                                                             SR4 138 
12    LL=1                                                              SR4 139 
      MM=INDEXI(JJ,I)                                                   SR4 140 
      MMM=MM+NS                                                         SR4 141 
      S=DIST(I,MMM)                                                     SR4 142 
13    KK=KK+1                                                           SR4 143 
      NN=INDEXI(KK,I)                                                   SR4 144 
      IF (PD(MM,I)-PD(NN,I)) 15,14,15                                   SR4 145 
14    LL=LL+1                                                           SR4 146 
      NOTR=NOTR+1                                                       SR4 147 
      NNN=NN+NS                                                         SR4 148 
      S=S+DIST(I,NNN)                                                   SR4 149 
      IF (KK-NSM1) 13,16,16                                             SR4 150 
15    IF (LL-2) 18,16,16                                                SR4 151 
16    II=II+2                                                           SR4 152 
      NTR(I)=NTR(I)+2                                                   SR4 153 
      NOTYR(I,II)=LL                                                    SR4 154 
      NOTYR(I,II+1)=JJ                                                  SR4 155 
      S=S/FLOAT(LL)                                                     SR4 156 
      IJ=JJ                                                             SR4 157 
      DO 17 KL=1,LL                                                     SR4 158 
      MMM=INDEXI(IJ,I)+NS                                               SR4 159 
      DIST(I,MMM)=S                                                     SR4 160 
17    IJ=IJ+1                                                           SR4 161 
18    JJ=KK                                                             SR4 162 
      IF (JJ-NSM1) 12,19,19                                             SR4 163 
19    CONTINUE                                                          SR4 164 
      DO 21 I=1,NS                                                      SR4 165 
      JJ=NS                                                             SR4 166 
      DO 21 J=NSP1,NSNVM1                                               SR4 167 
      JJ=JJ+1                                                           SR4 168 
      IF (I-J+NS) 21,20,21                                              SR4 169 
20    JJ=JJ+1                                                           SR4 170 
21    DIST(JJ,I)=DIST(I,J)                                              SR4 171 
      DO 24 I=1,NS                                                      SR4 172 
      DO 24 J=NSP1,NSPNV                                                SR4 173 
      IF (I-J+NS) 23,22,23                                              SR4 174 
22    DIST(J,I)=A                                                       SR4 175 
      GO TO 24                                                          SR4 176 
23    DIST(J,I)=DIST(J,I)/FN                                            SR4 177 
24    DIST(I,J)=DIST(J,I)                                               SR4 178 
      DO 26 I=1,NSPNV                                                   SR4 179 
      DO 26 J=1,NSPNV                                                   SR4 180 
      IF (I-J) 25,26,25                                                 SR4 181 
25    DIST(I,I)=DIST(I,I)+DIST(I,J)                                     SR4 182 
26    CONTINUE                                                          SR4 183 
      DO 27 I=1,NSNVM1                                                  SR4 184 
      IP1=I+1                                                           SR4 185 
      DO 27 J=IP1,NSPNV                                                 SR4 186 
      DIST(I,J)=1.-DIST(I,J)                                            SR4 187 
27    DIST(J,I)=DIST(I,J)                                               SR4 188 
C     OBTAIN INITIAL CONFIGURATION                                      SR4 189 
      KK=MAXD+1                                                         SR4 190 
C     CALL ON HOUSEHOLDER SUBROUTINE                                    SR4 191 
      CALL EIGEN (DIST,C,NSPNV,STRESS,KK,MD,X(1,1),X(1,4),X(1,5),X(1,6),SR4 192 
     1X(1,7),X(1,8))                                                    SR4 193 
      DO 28 J=2,KK                                                      SR4 194 
      STRESS(J-1)=STRESS(J)                                             SR4 195 
      DO 28 I=1,NSPNV                                                   SR4 196 
28    X(I,J-1)=C(I,J)                                                   SR4 197 
C     INITIALIZE                                                        SR4 198 
      ITER=100                                                          SR4 199 
      PRESTR=1.                                                         SR4 200 
      A=1.                                                              SR4 201 
      ASSIGN 51 TO N1                                                   SR4 202 
      LFACT=1                                                           SR4 203 
C     DETERMINE WHETHER TO GO UP OR DOWN                                SR4 204 
      IF (MIND) 29,29,36                                                SR4 205 
29    DIM=NSNVM1*2                                                      SR4 206 
      DIM=FNR**2/DIM                                                    SR4 207 
      II=0                                                              SR4 208 
      DO 31 J=1,MAXD                                                    SR4 209 
      IF (STRESS(J)-DIM) 32,30,30                                       SR4 210 
30    II=II+1                                                           SR4 211 
31    CONTINUE                                                          SR4 212 
32    IF (II) 33,33,34                                                  SR4 213 
33    MAXD=1                                                            SR4 214 
      GO TO 35                                                          SR4 215 
34    MAXD=II                                                           SR4 216 
35    MIND=MAXD                                                         SR4 217 
      LFACT=0                                                           SR4 218 
      ITER=25                                                           SR4 219 
36    M=MIND-1                                                          SR4 220 
C     START LEAST-SQUARES-RANK-IMAGES ITERATIONS                        SR4 221 
37    II=0                                                              SR4 222 
      JJ=0                                                              SR4 223 
      M=M+1                                                             SR4 224 
      NTIER=NOTR                                                        SR4 225 
38    II=II+1                                                           SR4 226 
39    ITCT=0                                                            SR4 227 
C     COMPUTE DISTANCES                                                 SR4 228 
40    IF (IFCB) 41,45,41                                                SR4 229 
41    DO 44 I=1,NS                                                      SR4 230 
      KK=0                                                              SR4 231 
      MM=NS                                                             SR4 232 
      DO 44 J=NSP1,NSPNV                                                SR4 233 
      IF (I-J+NS) 42,44,42                                              SR4 234 
42    MM=MM+1                                                           SR4 235 
      KK=KK+1                                                           SR4 236 
      DO 43 K=1,M                                                       SR4 237 
43    DIST(I,KK)=DIST(I,KK)+ABS(X(I,K)-X(J,K))                          SR4 238 
44    CONTINUE                                                          SR4 239 
      GO TO 49                                                          SR4 240 
45    DO 48 I=1,NS                                                      SR4 241 
      KK=0                                                              SR4 242 
      MM=NS                                                             SR4 243 
      DO 48 J=NSP1,NSPNV                                                SR4 244 
      IF (I-J+NS) 46,48,46                                              SR4 245 
46    MM=MM+1                                                           SR4 246 
      KK=KK+1                                                           SR4 247 
      DIST(I,KK)=0.                                                     SR4 248 
      DO 47 K=1,M                                                       SR4 249 
47    DIST(I,KK)=DIST(I,KK)+(X(I,K)-X(J,K))**2                          SR4 250 
      DIST(I,KK)=SQRT(DIST(I,KK))                                       SR4 251 
      DIST(MM,I)=DIST(I,KK)                                             SR4 252 
48    CONTINUE                                                          SR4 253 
49    IF (ITCT) 75,50,75                                                SR4 254 
50    GO TO N1, (51,53)                                                 SR4 255 
51    DO 52 J=1,NS                                                      SR4 256 
C     *** CALL ON SORT SUBROUTINE.                                      SR4 257 
52    CALL ORDER (0,0,DIST(NSP1,J),0,INDEXJ(1,J))                       SR4 258 
      ASSIGN 53 TO N1                                                   SR4 259 
      GO TO 55                                                          SR4 260 
53    DO 54 J=1,NS                                                      SR4 261 
C     *** CALL ON SORT.                                                 SR4 262 
54    CALL ORDER (1,0,DIST(NSP1,J),0,INDEXJ(1,J))                       SR4 263 
55    IF (NTIER) 66,66,56                                               SR4 264 
56    NTIER=0                                                           SR4 265 
C     OPTIMALLY BREAK TIES ON FIRST AND LAST ITERATION                  SR4 266 
      DO 65 I=1,NS                                                      SR4 267 
      IF (NTR(I)) 57,65,57                                              SR4 268 
57    KK=NTR(I)                                                         SR4 269 
      DO 64 J=1,KK,2                                                    SR4 270 
      LL=NOTYR(I,J)                                                     SR4 271 
      MM=NOTYR(I,J+1)                                                   SR4 272 
      NN=MM                                                             SR4 273 
      DO 58 K=1,LL                                                      SR4 274 
      IJ=INDEXI(NN,I)                                                   SR4 275 
      EVAL(K)=DIST(I,IJ)                                                SR4 276 
      IND(K,1)=IJ                                                       SR4 277 
58    NN=NN+1                                                           SR4 278 
      IJ=LL-1                                                           SR4 279 
59    JI=0                                                              SR4 280 
      DO 61 L=1,IJ                                                      SR4 281 
      LP1=L+1                                                           SR4 282 
      DO 61 N=LP1,LL                                                    SR4 283 
      IF (EVAL(N)-EVAL(L)) 60,61,61                                     SR4 284 
60    S=EVAL(L)                                                         SR4 285 
      EVAL(L)=EVAL(N)                                                   SR4 286 
      EVAL(N)=S                                                         SR4 287 
      JI=1                                                              SR4 288 
      NN=IND(L,1)                                                       SR4 289 
      IND(L,1)=IND(N,1)                                                 SR4 290 
      IND(N,1)=NN                                                       SR4 291 
61    CONTINUE                                                          SR4 292 
      IF (JI) 62,62,59                                                  SR4 293 
62    NN=MM                                                             SR4 294 
      DO 63 KL=1,LL                                                     SR4 295 
      INDEXI(NN,I)=IND(KL,1)                                            SR4 296 
63    NN=NN+1                                                           SR4 297 
64    CONTINUE                                                          SR4 298 
65    CONTINUE                                                          SR4 299 
C     RANK-IMAGE PERMUTATIONS                                           SR4 300 
66    DO 67 J=1,NS                                                      SR4 301 
      DO 67 I=1,NSM1                                                    SR4 302 
      KK=INDEXI(I,J)                                                    SR4 303 
      LL=INDEXJ(I,J)                                                    SR4 304 
67    PD(KK,J)=DIST(J,LL)                                               SR4 305 
      IF (JJ) 110,68,110                                                SR4 306 
C     TIE TIES                                                          SR4 307 
68    IF (NOTR) 69,75,69                                                SR4 308 
69    DO 74 I=1,NS                                                      SR4 309 
      IF (NTR(I)) 70,74,70                                              SR4 310 
70    KK=NTR(I)                                                         SR4 311 
      DO 73 J=1,KK,2                                                    SR4 312 
      LL=NOTYR(I,J)                                                     SR4 313 
      MM=NOTYR(I,J+1)                                                   SR4 314 
      NN=MM                                                             SR4 315 
      S=0.                                                              SR4 316 
      DO 71 K=1,LL                                                      SR4 317 
      IJ=INDEXI(NN,I)                                                   SR4 318 
      S=S+PD(IJ,I)                                                      SR4 319 
71    NN=NN+1                                                           SR4 320 
      NN=MM                                                             SR4 321 
      S=S/FLOAT(LL)                                                     SR4 322 
      DO 72 L=1,LL                                                      SR4 323 
      IJ=INDEXI(NN,I)                                                   SR4 324 
      PD(IJ,I)=S                                                        SR4 325 
72    NN=NN+1                                                           SR4 326 
73    CONTINUE                                                          SR4 327 
74    CONTINUE                                                          SR4 328 
C     TEST FOR ZERO DISTANCES                                           SR4 329 
75    DO 76 J=1,NS                                                      SR4 330 
      KK=INDEXJ(1,J)                                                    SR4 331 
      IF (DIST(J,KK)) 76,77,76                                          SR4 332 
76    CONTINUE                                                          SR4 333 
      GO TO 80                                                          SR4 334 
77    DO 78 I=2,NSM1                                                    SR4 335 
      KK=INDEXJ(I,J)                                                    SR4 336 
      IF (DIST(J,KK)) 79,78,79                                          SR4 337 
78    CONTINUE                                                          SR4 338 
79    LL=INDEXJ(NSM1,J)                                                 SR4 339 
      GL=DIST(J,LL)/DIST(J,KK)                                          SR4 340 
      GO TO 81                                                          SR4 341 
80    GL=0.                                                             SR4 342 
81    DO 89 I=1,NS                                                      SR4 343 
      MM=NS                                                             SR4 344 
      DO 89 J=1,NSM1                                                    SR4 345 
      MM=MM+1                                                           SR4 346 
      IF (I-MM+NS) 83,82,83                                             SR4 347 
82    MM=MM+1                                                           SR4 348 
83    IF (GL) 84,88,84                                                  SR4 349 
84    IF (PD(J,I)+DIST(I,J)) 86,85,86                                   SR4 350 
85    C(MM,I)=1.                                                        SR4 351 
      GO TO 89                                                          SR4 352 
86    IF (DIST(I,J)) 88,87,88                                           SR4 353 
87    C(MM,I)=GL                                                        SR4 354 
      GO TO 89                                                          SR4 355 
88    C(MM,I)=PD(J,I)/DIST(I,J)                                         SR4 356 
89    CONTINUE                                                          SR4 357 
C     COMPUTE CORRECTION MATRIX                                         SR4 358 
      DO 90 J=1,NS                                                      SR4 359 
      MM=J+NS                                                           SR4 360 
90    C(MM,J)=1.                                                        SR4 361 
      DO 91 I=NSP1,NSPNV                                                SR4 362 
      C(I,I)=FNS                                                        SR4 363 
      DO 91 J=1,NS                                                      SR4 364 
91    C(I,I)=C(I,I)+C(I,J)                                              SR4 365 
      DO 92 J=1,NS                                                      SR4 366 
      C(J,J)=FNS                                                        SR4 367 
      DO 92 I=NSP1,NSPNV                                                SR4 368 
92    C(J,J)=C(J,J)+C(I,J)                                              SR4 369 
      DO 93 I=NSP1,NSPNV                                                SR4 370 
      DO 93 J=1,NS                                                      SR4 371 
93    C(I,J)=1.-C(I,J)                                                  SR4 372 
C     APPLY CORRECTIONS                                                 SR4 373 
      DO 95 K=1,M                                                       SR4 374 
      DO 95 I=1,NS                                                      SR4 375 
      XP1(I,K)=X(I,K)*C(I,I)                                            SR4 376 
      DO 94 J=NSP1,NSPNV                                                SR4 377 
94    XP1(I,K)=XP1(I,K)+X(J,K)*C(J,I)                                   SR4 378 
95    XP1(I,K)=XP1(I,K)/FNR                                             SR4 379 
      DO 97 K=1,M                                                       SR4 380 
      DO 97 I=NSP1,NSPNV                                                SR4 381 
      XP1(I,K)=X(I,K)*C(I,I)                                            SR4 382 
      DO 96 J=1,NS                                                      SR4 383 
96    XP1(I,K)=XP1(I,K)+X(J,K)*C(I,J)                                   SR4 384 
97    XP1(I,K)=XP1(I,K)/FNR                                             SR4 385 
      DO 98 K=1,M                                                       SR4 386 
      DO 98 I=1,NSPNV                                                   SR4 387 
98    X(I,K)=XP1(I,K)                                                   SR4 388 
      ITCT=ITCT+1                                                       SR4 389 
      IF (10-ITCT) 99,99,40                                             SR4 390 
C     COMPUTE NORMALIZED PHI                                            SR4 391 
99    S=0.                                                              SR4 392 
      STR=0.                                                            SR4 393 
      DO 100 I=1,NS                                                     SR4 394 
      DO 100 J=1,NSM1                                                   SR4 395 
      S=S+DIST(I,J)**2                                                  SR4 396 
100   STR=STR+(DIST(I,J)-PD(J,I))**2                                    SR4 397 
      STR=STR/(2.*S)                                                    SR4 398 
      STRESS(II)=STR                                                    SR4 399 
C     TEST FOR TERMINATION                                              SR4 400 
      IF (II-6) 38,101,101                                              SR4 401 
101   IF (STRESS(II-5)-STRESS(II)-1E-06) 103,103,102                    SR4 402 
102   IF (II-ITER) 38,103,103                                           SR4 403 
103   IF (LFACT) 106,106,104                                            SR4 404 
104   IF (PRESTR-STR) 155,155,105                                       SR4 405 
105   PRESTR=STR                                                        SR4 406 
106   WRITE (JTAPE,158)                                                 SR4 407 
      WRITE (JTAPE,161) M,(KK,KK=1,M)                                   SR4 408 
      GO TO (107,108), M1                                               SR4 409 
107   WRITE (JTAPE,162)                                                 SR4 410 
      GO TO 109                                                         SR4 411 
108   WRITE (JTAPE,172)                                                 SR4 412 
109   JJ=1                                                              SR4 413 
      NTIER=NOTR                                                        SR4 414 
      GO TO 39                                                          SR4 415 
C     COMPUTE INDIVIDUAL PHI'S                                          SR4 416 
110   S=0.                                                              SR4 417 
      DO 111 I=1,NS                                                     SR4 418 
      PHI(I)=0.                                                         SR4 419 
      DO 111 J=1,NSM1                                                   SR4 420 
      S=S+DIST(I,J)**2                                                  SR4 421 
111   PHI(I)=PHI(I)+(DIST(I,J)-PD(J,I))**2                              SR4 422 
      STR=0.                                                            SR4 423 
      S=2.*S                                                            SR4 424 
      DO 112 J=1,NS                                                     SR4 425 
      PHI(J)=PHI(J)/S                                                   SR4 426 
112   STR=STR+PHI(J)                                                    SR4 427 
      IF (M-2) 118,113,113                                              SR4 428 
113   IF (IFCB) 118,114,118                                             SR4 429 
C     PERFORM PRINCIPAL AXIS ROTATION                                   SR4 430 
114   DO 116 I=1,NSPNV                                                  SR4 431 
      DO 116 J=I,NSPNV                                                  SR4 432 
      DIST(I,J)=0.                                                      SR4 433 
      DO 115 K=1,M                                                      SR4 434 
115   DIST(I,J)=DIST(I,J)+X(I,K)*X(J,K)                                 SR4 435 
116   DIST(J,I)=DIST(I,J)                                               SR4 436 
C     CALL ON HOUSEHOLDER SUBROUTINE                                    SR4 437 
      CALL EIGEN (DIST,C,NSPNV,STRESS,M,MD,XP1(1,1),XP1(1,4),XP1(1,5),XPSR4 438 
     11(1,6),XP1(1,7),XP1(1,8))                                         SR4 439 
      DO 117 J=1,M                                                      SR4 440 
      DO 117 I=1,NSPNV                                                  SR4 441 
117   X(I,J)=C(I,J)                                                     SR4 442 
C     NORMALIZE COORDINATES TO LIE IN RANGE -1 TO +1                    SR4 443 
118   A=0.                                                              SR4 444 
      DO 120 K=1,M                                                      SR4 445 
      C(1,K)=X(1,K)                                                     SR4 446 
      C(2,K)=X(1,K)                                                     SR4 447 
      DO 119 I=2,NSPNV                                                  SR4 448 
      C(1,K)=AMIN1(C(1,K),X(I,K))                                       SR4 449 
119   C(2,K)=AMAX1(C(2,K),X(I,K))                                       SR4 450 
120   A=AMAX1(A,(C(2,K)-C(1,K)))                                        SR4 451 
      A=2./A                                                            SR4 452 
      DO 121 K=1,M                                                      SR4 453 
      DO 121 I=1,NSPNV                                                  SR4 454 
121   XP1(I,K)=A*(X(I,K)-C(1,K))-1.                                     SR4 455 
C     COMPUTE CENTRALITY INDEX                                          SR4 456 
      KK=M+1                                                            SR4 457 
      DO 125 I=1,NSPNV                                                  SR4 458 
      XP1(I,KK)=0.                                                      SR4 459 
      DO 122 K=1,M                                                      SR4 460 
122   XP1(I,KK)=XP1(I,KK)+X(I,K)**2                                     SR4 461 
      IF (IFCB) 123,124,123                                             SR4 462 
123   XP1(I,KK)=A*XP1(I,KK)                                             SR4 463 
      GO TO 125                                                         SR4 464 
124   XP1(I,KK)=A*SQRT(XP1(I,KK))                                       SR4 465 
125   CONTINUE                                                          SR4 466 
C     PRINT RESULTS                                                     SR4 467 
      DO 126 I=1,NS                                                     SR4 468 
126   WRITE (JTAPE,163) I,PHI(I),(XP1(I,K),K=1,KK)                      SR4 469 
      GO TO (127,128), M1                                               SR4 470 
127   WRITE (JTAPE,170)                                                 SR4 471 
      GO TO 129                                                         SR4 472 
128   WRITE (JTAPE,173)                                                 SR4 473 
129   DO 130 I=NSP1,NSPNV                                               SR4 474 
130   WRITE (JTAPE,171) I,(XP1(I,K),K=1,KK)                             SR4 475 
      CAL=SQRT(1.-(1.-STR)**2)                                          SR4 476 
      WRITE (JTAPE,164) STR,II,CAL                                      SR4 477 
      IF (LFACT) 131,143,131                                            SR4 478 
131   IF (M-2) 153,132,132                                              SR4 479 
C     CALL PLOT SUBROUTINE                                              SR4 480 
132   CALL PLOT (XP1,DIST(1,1),DIST(1,2),DIST(1,3),DIST(1,4),DIST(1,5),NSR4 481 
     1SPNV,M,MD,ND)                                                     SR4 482 
      IF (IFC) 133,135,133                                              SR4 483 
133   DO 134 I=1,NSPNV                                                  SR4 484 
134   PUNCH 166, (XP1(I,J),J=1,M)                                       SR4 485 
135   IF (IFD) 136,153,136                                              SR4 486 
136   IF (IFCB) 140,137,140                                             SR4 487 
137   DO 139 I=1,NSNVM1                                                 SR4 488 
      DIST(I,I)=0.                                                      SR4 489 
      IP1=I+1                                                           SR4 490 
      DO 139 J=IP1,NSPNV                                                SR4 491 
      DIST(J,I)=0.                                                      SR4 492 
      DO 138 K=1,M                                                      SR4 493 
138   DIST(J,I)=DIST(J,I)+(XP1(I,K)-XP1(J,K))**2                        SR4 494 
139   DIST(J,I)=SQRT(DIST(J,I))                                         SR4 495 
      GO TO 142                                                         SR4 496 
140   DO 141 I=1,NSNVM1                                                 SR4 497 
      DIST(I,I)=0.                                                      SR4 498 
      IP1=I+1                                                           SR4 499 
      DO 141 J=IP1,NSPNV                                                SR4 500 
      DIST(J,I)=0.                                                      SR4 501 
      DO 141 K=1,M                                                      SR4 502 
141   DIST(J,I)=DIST(J,I)+ABS(XP1(I,K)-XP1(J,K))                        SR4 503 
142   DIST(NSPNV,NSPNV)=0.                                              SR4 504 
      CALL MXOUT (DIST,NSPNV,1,MD)                                      SR4 505 
      GO TO 153                                                         SR4 506 
143   IF (IFCB) 144,145,144                                             SR4 507 
144   WRITE (JTAPE,165)                                                 SR4 508 
      GO TO 174                                                         SR4 509 
C     DETERMINE HOW MANY DIMENSIONS TO DROP                             SR4 510 
145   LL=1                                                              SR4 511 
      KK=M                                                              SR4 512 
      DO 147 J=2,KK                                                     SR4 513 
      S=STRESS(J)/STRESS(1)                                             SR4 514 
      IF (S-.3) 148,148,146                                             SR4 515 
146   LL=LL+1                                                           SR4 516 
147   CONTINUE                                                          SR4 517 
148   M=LL-1                                                            SR4 518 
      MAXD=LL                                                           SR4 519 
      IF (ITER-100) 149,150,150                                         SR4 520 
149   ITER=ITER+25                                                      SR4 521 
150   IF (KK-LL) 151,151,37                                             SR4 522 
151   LFACT=1                                                           SR4 523 
      IF (M) 155,155,152                                                SR4 524 
152   M=M+1                                                             SR4 525 
      GO TO 132                                                         SR4 526 
153   IF (.000001-STR) 154,155,155                                      SR4 527 
154   IF (M-MAXD) 37,155,155                                            SR4 528 
155   GO TO (156,174), MU                                               SR4 529 
C     RE-INPUT DATA FOR COLUMN SOLUTION                                 SR4 530 
156   MU=2                                                              SR4 531 
      M1=2                                                              SR4 532 
      DO 157 I=1,NS                                                     SR4 533 
157   READ (13'KT) (PD(I,J),J=1,NS)                                     SR4 534 
      GO TO 6                                                           SR4 535 
C     *** FORMAT STATEMENTS ***                                         SR4 536 
C                                                                       SR4 537 
158   FORMAT (72H                                                       SR4 538 
     1                 )                                                SR4 539 
159   FORMAT (8I4)                                                      SR4 540 
160   FORMAT (18A4)                                                     SR4 541 
161   FORMAT (33H0G-L(SSAR-IV) COORDINATES FOR M =,I3,1H./1H0,9X10H DIMESR4 542 
     1NSION,10I10)                                                      SR4 543 
162   FORMAT (1H ,130(1H-)/6H0  ROW,8X6HN. PHI)                         SR4 544 
163   FORMAT (I5,5XF10.5,2P11F10.3)                                     SR4 545 
164   FORMAT (17H0NORMALIZED PHI =,F7.5,4H FOR,I4,11H ITERATIONS/28H COESR4 546 
     1FFICIENT OF ALIENATION =,E12.6)                                   SR4 547 
165   FORMAT (27H0ERROR - IFCB=1 AND MIND=0.)                           SR4 548 
166   FORMAT (9F8.5)                                                    SR4 549 
167   FORMAT (19H0INPUT COEFFICIENTS)                                   SR4 550 
168   FORMAT (4H0ROW,I3)                                                SR4 551 
169   FORMAT (10F13.4)                                                  SR4 552 
170   FORMAT (8H0 COLUMN)                                               SR4 553 
171   FORMAT (I5,15X2P11F10.3)                                          SR4 554 
172   FORMAT (1H ,130(1H-)/8H0 COLUMN,6X6HN. PHI)                       SR4 555 
173   FORMAT (6H0  ROW)                                                 SR4 556 
      END                                                               SR4 557-
1SSAR-IV TEST EXAMPLE OF FIVE POINTS.                                           
   5   2   2           1                                                        
(5F1.0)                                                                         
01234                                                                           
40123                                                                           
21043                                                                           
43201                                                                           
34210                                                                           
1UNFOLDING SOCIOMETRY - TEST EXAMPLE B.                                         
  17   2   2       1                                                            
(17F3.0)                                                                        
085110090070020100160030150130010050140040120060080                             
150085010030090060050110040020160130100140120070080                             
110010085020070060050080040030160120140130150090100                             
090020010085050030080060070040120140160130150100110                             
020090060040085050160010130120030080150070140100110                             
060050030010040085090020100070080120160110150130140                             
150030040050110100085130010020160120060140070090080                             
020080060040010030140085130120050090160070150100110                             
140030060090120130020150085010160100050110040080070                             
150020040050120130030140010085160100060110070090080                             
010100090080040110160050150140085030130020120060070                             
040120110100060150160080140130020085090010070030050                             
140060080110120160070150020050130090085100010040030                             
030110090080050140160070150130020010120085100040060                             
130080090100140160110150060070120040030050085020010                             
130070090100140160120150060080110040030050020085010                             
050100110090080150160120140130040010070020060030085                             
