*     M888-1505,FMS,DEBUG,3,3,200,000
*     LIST
C     PROGRAM TO PRODUCE STATE-BY-STATE PRINTOUT OF ALL CLUSTERS
C     FIRST DATA CARD CONTAINS TITLE, 12A6.
C     SECOND DATA CARD CONTAINS ITAPE, I1.
C     THIRD DATA CARD CONTAINS THE VARIABLE TPRIME FORMAT, 12A6.
C     NEXT FOUR DATA CARDS CONTAIN STATE NAMES, 4(12A6).
C     DECK OF 1628 TPRIMES FOLLOWS, FORMAT
C
      DIMENSION R(60),P(60),Q(60),IMISS(20),PP(60,3),QQ(60,3),
     1PSUM(48,60,3),QSUM(48,60,3),TSUM(48,60,3),ISTATE(5),T(3),N(3),
     2STATE(48),TITLE(12),FORMAT(12)
      COMMON NCLUS,I,J,K,L,R,P,Q,NMISS,IMISS,PP,QQ,PSUM,QSUM,TSUM
C
C     READ PARAMETERS AND PRINT TITLE
C
      READ 200, (TITLE(I),I=1,12)
      PRINT 300, (TITLE(I),I=1,12)
      READ 201, ITAPE,(FORMAT(K),K=1,12),(STATE(M),M=1,48)
C
C     INITIALIZE SUMS AND COUNTERS, AND POSITION INPUT TAPE
C
      DO 1 M=1,48
      DO 1 N=1,60
      DO 1 L=1,3
      PSUM(M,N,L) = 0.0
      QSUM(M,N,L) = 0.0
    1 TSUM(M,N,L) = 0.0
      ISTATE(1) = 5
      ISTATE(2) = 9
      ISTATE(3) = 11
      ISTATE(4) = 12
      ISTATE(5) = 11
      IF (ITAPE)  2,2,3
    2 ITAPE = 1
   3   INDEX = 1
  495 READ TAPE 9, FILE, NCLUS
      IF (INDEX - ITAPE) 50, 20, 20
   50 DO 51 IXYZ=1,480
   51 READ TAPE 9, I,J,K,L,(R(IX),P(IX),Q(IX),IX=1,NCLUS)
      INDEX = INDEX + 1
      GO TO 495
C
C     BEGIN CYCLE AND READ IN DATA
C
   20 DO 36 ICYCLE=1,160
      DO 25 LQ=1,3
      READ TAPE 9, I,J,K,L,(R(IX),P(IX),Q(IX),IX=1,NCLUS)
      IF (L-LQ) 70,21,70
   21 DO 25 NQ=1,NCLUS
      PP(NQ,LQ) = P(NQ)
   25 QQ(NQ,LQ) = Q(NQ)
C
C     READ IN T-PRIMES
C
   30 IIALL = ISTATE(I+1)
      DO 39 IALL=1,IIALL
      READ FORMAT,IA,JA,KA,M,(T(LQ),LQ=1,3)
      IF (IA-I) 74,31,74
   31 IF (JA-J) 74,32,74
   32 IF (KA-K) 74,33,74
C
C     COMPUTE SUMS
C
   33 DO 35 LQ=1,3
      DO 35 NQ=1,NCLUS
      PSUM(M,NQ,LQ) = PP(NQ,LQ)*T(LQ) + PSUM(M,NQ,LQ)
      QSUM(M,NQ,LQ) = QQ(NQ,LQ)*T(LQ) + QSUM(M,NQ,LQ)
   35 TSUM(M,NQ,LQ) = T(LQ) + TSUM(M,NQ,LQ)
   39 CONTINUE
   36 CONTINUE
C
C     COMPUTE FINAL OUTPUT
C
      DO 47 M=1,48
      DO 45 N=1,NCLUS
      A = 0.0
      B = 0.0
      C = 0.0
      DO 43 L=1,3
      A = A + PSUM(M,N,L)
      B = B + QSUM(M,N,L)
      C = C + TSUM(M,N,L)
      IF (TSUM(M,N,L)) 75,75,41
   41 PSUM(M,N,L) = PSUM(M,N,L)/TSUM(M,N,L)
      QSUM(M,N,L) = QSUM(M,N,L)/TSUM(M,N,L)
   43 CONTINUE
      IF (C) 76,76,44
   44 TSUM(M,N,1) = A/C
      TSUM(M,N,2) = B/C
   45 CONTINUE
   47 CONTINUE
C
C     WRITE OUTPUT TWO WAYS
C
      DO 55 M=1,48
      WRITE OUTPUT TAPE 2, 310, (TITLE(I),I=1,12),M,STATE(M),
     1(N,(PSUM(M,N,L),QSUM(M,N,L),L=1,3),(TSUM(M,N,L),L=1,2),N=1,NCLUS)
   55 CONTINUE
      DO 59 N=1,NCLUS
      WRITE OUTPUT TAPE 2, 311, (TITLE(I),I=1,12),N,(M,STATE(M),
     1(PSUM(M,N,L),QSUM(M,N,L),L=1,3),(TSUM(M,N,L),L=1,2),M=1,48)
   59 CONTINUE
C
      REWIND 9
      PRINT 312
      CALL EXIT
C
C     ERROR SECTION
C
   70 PRINT 302, I,J,K,L,LQ
      CALL EXIT
   74 PRINT 304, I,J,K,IA,JA,KA,M
      CALL EXIT
   75 PRINT 305, M,N,L,TSUM(M,N,L)
      PSUM(M,N,L) = 0.0
      QSUM(M,N,L) = 0.0
      GO TO 43
   76 LA = 4
      PRINT 305, M,N,LA,C
      TSUM(M,N,1) = 0.0
      TSUM(M,N,2) = 0.0
      GO TO 45
C
C     FORMAT SPECIFICATIONS
C
  200 FORMAT (12A6)
  201 FORMAT (I1/12A6/12A6/12A6/12A6/12A6)
  300 FORMAT (99H1SIMULMATICS PROJECT, PROGRAM TO PRODUCE STATE-BY-STATE
     1 PRINTOUT OF ALL CLUSTERS, NOW IN OPERATION.//12A6/1H1)
  302 FORMAT (10H0FOR CELL 4I1,30H ON CLUSTER SUMMARY TAPE, LQ =I2,17H.
     1RUN TERMINATED.)
  304 FORMAT (6H0CELL 3I1,39H ON THE CLUSTER SUMMARY TAPE, AND CELL 3I1,
     146HIN THE TPRIME DECK ENCOUNTERED SIMULTANEOUSLY./
     216H RUN TERMINATED.)
  305 FORMAT (6H0TSUM(I2,1H,I2,1H,I1,3H) =F8.5,64H. THE CORRESPONDING CL
     1USTER PERCENTAGES WILL BE SET EQUAL TO 0.0)
  310 FORMAT (1H125X,12A6/1H014X,92HPROS AND ANTIS FOR ALL CLUSTERS, AS
     1PERCENTAGES OF ELIGIBLE VOTING POPULATION IN THIS STATE./1H056X,
     25HSTATEI3,3H.  A6//8H0CLUSTER6X,9HDEMOCRATS14X,11HREPUBLICANS13X,
     312HINDEPENDENTS27H,5HTOTAL/8H   NO.  3X,3HPRO8X,4HANTI9X,3HPRO8X,
     44HANTI9X,3HPRO8X,4HANTI21X,3HPRO8X,4HANTI//(I4,6F12.5,12X,2F12.5))
  311 FORMAT (1H125X,12A6/1H014X,93HPROS AND ANTIS FOR THIS CLUSTER, AS
     1PERCENTAGES OF ELIGIBLE VOTING POPULATIONS IN ALL STATES./1H055X,
     27HCLUSTERI4//7H0 STATE13X,      9HDEMOCRATS14X,11HREPUBLICANS13X,
     312HINDEPENDENTS27H,5HTOTAL/7H0 STATE13X,3HPRO8X,4HANTI9X,3HPRO8X,
     44HANTI9X,3HPRO8X,4HANTI21X,3HPRO8X,4HANTI//(I3,1X,A6,6F12.5,12X,
     52F12.5))
  312 FORMAT (12H1END OF RUN.)
      END
File Name: box1batch10.bin, Fingerprint: 7e5c43-233f5d
