      PROGRAM MAIN
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C                                                                      C
C              M O R T R A N 2     VERSION 0    JUNE 1975              C
C                                                                      C
C                              A. J. COOK                              C
C                            L. J. SHUSTEK                             C
C                           J. E. ZOLNOWSKY                            C
C                  STANFORD LINEAR ACCELERATOR CENTER                  C
C                        P.O. BOX 4349, BIN 88                         C
C                        STANFORD, CALIF. 94305                        C
C                                                                      C
C       THIS PROGRAM WAS PRODUCED BY ANOTHER PROGRAM.  IT IS NOT       C
C      INTENDED TO BE READ OR UNDERSTOOD BY HUMANS IN THIS FORM.       C
C                                                                      C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      INTEGER A,B,C,D,E,F,G,H,O,P,Q,R,S,T,U,V,W,X,Y,Z
      DIMENSION MM( 50 000)
      COMMON/MEM/MM
      COMMON/STATUS/IQ,Q,IR,R,C,NC,H,MTRC,MDEF,MCNT,NGEN,IQUO,MORT,MERR,
     XUPTR,UNIT,LIST,INDT,NOTE
      LOGICAL CNV
      EQUIVALENCE(LIMS,V),(LIMF,IO),(LIMR,IC),(LIMQ,IR)
      DATA IC/300/,IA/400/,IS/401/,G/10000/,NSCN/0/,LIMU/ 50 000/
      CALL IOINIT
      READ(1,1)(MM(K)  ,K=1,152)
      WRITE(6,3)(MM(K)  ,K=1,72)
      WRITE(7,2)(MM(K)  ,K=1,72)
    2 FORMAT(1HC,72A1)
    1 FORMAT(80A1)
    3 FORMAT(1H1,72A1,12X,32H PROCESSOR VERSION OF 06/24/75  /)
    6 FORMAT(1X,120A1)
      F=LIMU/8
      IO=F*5
      IE=F*7
      MM(IA)=IA+25
      MM(IE)=MM(132)
      MM(IR)=0
      LIMA=F
      O=IO
      U=IE
      S=IE
      V=IE
      K=F+14
      READ(1,5)KQ,KA,IP,(MM(J)  ,J=F,K)
    5 FORMAT(40A2)
      J=IC
      MM(J)  =MM(140)
      MM(J+1)=F
      MM(J+3)=0
      MM(F)  =0
      MM(F+1)=F+12
      MM(F+2)=F+14
      MM(F+3)=0
      F=F+15
 1011 IF(C .EQ.NC )GO TO 1029
 1010 C=C+1
      IF(C .GT.NC )CALL NXTCRD( MM(117) )
   11 IF(MM(C)   .NE.MM(135))GO TO   12
   13 C=C+1
      IF(C .GT.NC )CALL NXTCRD( MM(135) )
      IF(C .NE.NC )GO TO   14
      IF(  IQUO .EQ.1)GO TO 1011
   14 IF(MM(C)   .EQ.MM(135))GO TO 1011
      GO TO   13
   12 U=U+1
      IF(LIMU.LE.U)U=U+ NONO(1,6,8,1)
      MM(U)  =MM(C)
      IF(MM(C)   .NE.MM(134))GO TO   15
      MM(U)  =KQ
  512 C=C+1
      IF(C .GT.NC )CALL NXTCRD( MM(134) )
      U=U+1
      IF(LIMU.LE.U)U=U+ NONO(1,6,8,1)
      MM(U)  =MM(C)
      IF(MM(C)   .NE.MM(134))GO TO  512
      C=C+1
      IF(C .GT.NC )CALL NXTCRD( MM(134) )
      IF(MM(C)   .EQ.MM(134))GO TO  512
      MM(U)  =KQ
      GO TO   11
   15 IF(MM(C)   .NE.MM(117))GO TO   19
      IF( S .EQ.U )GO TO  514
      IF(  MM(U-1) .EQ.MM(117))U=U-1
  514 IF(C .EQ.NC )GO TO 1029
      C=C+1
      IF(MM(C)   .NE.MM(117))GO TO   11
      GO TO  514
   19 IF(MM(C)   .EQ.MM(132))GO TO 1029
      IF(MM(130) .NE.MM(C)  )GO TO   22
      H=H+1
      GO TO   23
   22 IF(MM(131) .NE.MM(C)  )GO TO   23
      H=H-1
   23 GO TO 1011
 1029 IF( S .LE.U )GO TO   25
      S=IE
      U=S-1
      GO TO 1010
   25 IF(MM(S)   .NE.MM(135))GO TO   26
      NSCN=1
      S=S+1
      GO TO   88
   26 M=IC
  516 IF(MM(M)   .EQ.MM(S)  )GO TO  515
      M=M+2
      IF(  MM(M+1) .LE.00)GO TO   88
      GO TO  516
  515 M=M+1
 1015 M=MM(M)
      IF( M .EQ.0 )GO TO   88
      D=M+4
      B=MM(M+1)
      Z=0
      E=0
      T=IA-1
      A=MM(IA)
      V=S
 1012 IF( V .LE.U )GO TO   27
      IF(S .NE.U  )GO TO   28
      S=IE
      MM(S)  =MM(U)
      U=S
   28 IF(  MORT .EQ.0)GO TO 1015
      GO TO 1010
   27 IF(MM(D)   .NE.IP)GO TO   29
      D=D+1
      T=T+1
      MM(T)  =A
      IF(MM(D)   .NE.KA)GO TO   30
      D=D+1
      E=N1(MM(D)  ,0,36,0)
      D=D+1
  518 IF( E .LE.0 )GO TO   31
      IF( V .GT.U )GO TO 1010
      MM(A)  =MM(V)
      A=A+1
      IF(LIMA.LE.A)A=A+ NONO(2,6,8,1)
      V=V+1
      E=E-1
      GO TO  518
   30 E=D
      W=V
      IZ=Z
      P=0
   31 IF( B .LE.D )GO TO 1032
      GO TO 1012
   29 IF(MM(D)   .NE.MM(V)  )GO TO   32
      IF(MM(D)   .EQ.KQ)Z=1-Z
      D=D+1
      V=V+1
      IF( B .GT.D )GO TO 1012
 1032 LA=T
      MM(T+1)=A
      MM(T+2)=0
      E=MM(M+2)
      B=B-1
      S=O
      W=MM(M+3)
      MCNT=MCNT-1
      IF(  MCNT .LE.0)MTRC=3+NONO(3,15,16,0)
      IF(  MTRC .EQ.2)CALLMACTRC(1,M+4,B,IA,LA)
      GO TO 1014
   32 IF(MM(V)  .NE.MM(117).OR. Z.NE.0 )GO TO   34
      V=V+1
      GO TO 1012
   34 IF( E .EQ.0 )GO TO 1015
      IF(MM(T)  .NE.A .OR.MM(W)  .NE.MM(117))GO TO   37
      IF( Z .NE.0 )GO TO   37
      W=W+1
      GO TO 1012
   37 MM(A)  =MM(W)
      A=A+1
      IF(LIMA.LE.A)A=A+ NONO(2,6,8,1)
      IF(MM(W)   .NE.KQ)GO TO   38
      IF( Z.EQ.1 .OR.IZ.EQ.1 )GO TO 1015
  520 W=W+1
      MM(A)  =MM(W)
      A=A+1
      IF(LIMA.LE.A)A=A+ NONO(2,6,8,1)
      IF( W .GT.U )GO TO 1015
      IF(MM(W)   .EQ.KQ)GO TO   39
      GO TO  520
   38 IF( Z .NE.0 )GO TO   40
      IF(MM(120) .NE.MM(W)  )GO TO   41
      P=P+1
      GO TO   42
   41 IF(MM(121) .NE.MM(W)  )GO TO   42
      P=P-1
   42 IF(MM(130) .NE.MM(W)  )GO TO   44
      P=P+1
      GO TO   45
   44 IF(MM(131) .NE.MM(W)  )GO TO   45
      P=P-1
   45 IF( 0 .GT.P )GO TO 1015
      IF(MM(W)   .EQ.MM(132))GO TO 1015
   40 IF(MM(W)   .NE.KA)GO TO   39
      W=W+1
      MM(A)  =MM(W)
      A=A+1
   39 W=W+1
      IF( W .LE.U )GO TO   48
      IF(  MORT .EQ.0)GO TO 1015
      GO TO 1010
   48 IF( P .NE.0 )GO TO   37
      D=E
      V=W
      Z=IZ
      GO TO 1012
 1014 B=B+1
      IF( B .LE.E )GO TO   50
      IF( W .EQ.00)GO TO   51
      B=W+1
      E=MM(B)
      W=MM(W)
      GO TO 1014
   51 IF(  MTRC .EQ.0)GO TO   53
      IF( S .NE.O )CALLMACTRC(2,O+1,S,0,0)
   53 IF( S .NE.O )GO TO   54
      S=V
      GO TO 1029
   54 V=V-1
      MM(V)  =MM(S)
      S=S-1
      GO TO   53
   50 IF(MM(B)   .NE.IP)GO TO   55
      B=B+1
      N=N1(MM(B)  ,1,LA-IA+1,1)+IA
      A=MM(N-1)
      N=MM(N)
   56 IF( N .LE.A )GO TO 1014
      S=S+1
      MM(S)  =MM(A)
      A=A+1
      GO TO   56
   55 S=S+1
      IF(LIMS.LE.S)S=S+ NONO(15,6,8,1)
      MM(S)  =MM(B)
      IF(MM(B)   .NE.KA)GO TO   57
      B=B+1
      IF(MM(B)   .NE.MM(93))GO TO   58
      B=B+1
      S=S-1
      IF(MM(B)   .NE.MM(104))GO TO   59
      IF(  NGEN .NE.0)GO TO   60
      KGEN=1
      NGEN=1
      GO TO   61
   60 KGEN=KGEN+1
   61 GO TO 1014
   59 IF(MM(B)   .NE.MM(97))GO TO   62
      IF(  NGEN .EQ.1)KGEN=KGEN+1
      GO TO 1014
   62 IF(MM(B)   .NE.MM(95))GO TO   58
      KGEN=KGEN-1
      IF(  KGEN .LE.0)NGEN=0
      GO TO 1014
   58 IF(  NGEN .NE.1)GO TO   64
      S=S-1
      GO TO 1014
   64 IF(MM(B)   .NE.MM(99))GO TO   65
      B=B+1
      S=S-1
      IF(MM(B)   .NE.MM(124))GO TO   66
      KNT=KNT+1
      GO TO 1014
   66 IF(MM(B)   .NE.MM(125))GO TO   67
      KNT=KNT-1
      GO TO 1014
   67 IF(MM(B)   .NE.MM(81))GO TO   68
      KNT=0
      GO TO 1014
   68 IF(MM(B)   .NE.MM(123))GO TO   69
      KNT=MM(S)
      S=S-2
      GO TO 1014
   69 IF(MM(B)   .NE.MM(93))GO TO   65
      S=S+2
      MM(S)  =KNT
      GO TO 1014
   65 IF(MM(B)   .NE.MM(103))GO TO   71
      B=B+1
      IF(MM(B)   .NE.MM(109))GO TO   72
      S=S-1
      B=B+1
      Q=Q+1
      IF(LIMQ.LE.Q)Q=Q+ NONO(3,7,8,0)
      MM(Q)  =MM(B)
      GO TO 1014
   72 IF(MM(B)   .NE.MM(108))GO TO   73
      S=S-1
      B=B+1
      MM(Q)  =MM(B)
      GO TO 1014
   73 IF(MM(B)   .NE.MM(111))GO TO   74
      MM(S)  =MM(142)
      S=S+1
      IF(Q .EQ.IQ )Q=Q-NONO(3,7,9,0)
      MM(S)  =MM(Q)
      Q=Q-1
      GO TO 1014
   74 IF(MM(B)   .NE.MM(110))GO TO   75
      IF(  MTRC .EQ.1)CALLMACTRC(1,M+4,MM(M+1)-1,IA,LA)
      S=S-1
      GO TO 1014
   75 IF(MM(B)   .NE.MM(97))GO TO   76
      ICAT=0
      GO TO 1016
   76 IF(MM(B)   .NE.MM(93))GO TO   77
      ICAT=1
      GO TO 1016
   77 IF(MM(B)   .NE.MM(103))GO TO   71
      J=MM(IA)
      K=MM(IS)-1
      WRITE(6,6)(MM(JJ),JJ= J,K )
      S=S-1
      GO TO 1014
   71 IF(MM(B)   .NE.MM(102))GO TO   79
      B=B+1
      IF(MM(B)   .NE.MM(97))GO TO   80
      G=G+10
      S=S+1
      MM(S)  =G
      GO TO 1014
   80 J=N1(MM(B+1),0,9,0)
      IF(MM(B)   .NE.MM(93))GO TO   81
      S=S+1
      K=R-J
      MM(S)  =MM(K)  +N1(MM(B+2),0,9,0)
      B=B+2
      GO TO 1014
   81 IF(MM(B)   .NE.MM(109))GO TO   82
      R=R+1
      IF(LIMR.LE.R)R=R+ NONO(4,7,8,0)
      IF( J .EQ.0 )GO TO   83
      DO   84K=1,J
      KK=R-K
   84 MM(KK+1)=MM(KK)
   83 K=R-J
      MM(K)  =MM(S-1)
      B=B+1
      S=S-3
      GO TO 1014
   82 IF(MM(B)   .NE.MM(111))GO TO   79
      K=R-IR
      IF( J .GT.K )J=NONO(4,7,9,0)
      IF( J .LE.0 )GO TO   86
      DO   87K=1,J
      KK=R-J+K
   87 MM(KK-1)=MM(KK)
   86 IF( 0 .LE.J )R=R-1
      B=B+1
      S=S-1
      GO TO 1014
   79 B=B-1
   57 GO TO 1014
   88 IF(MM(S)   .NE.MM(132))GO TO   89
      IF(O .NE.IO )CALLOUTLIN(IO,O)
      GO TO   90
   89 IF(MM(S)  .NE.KA.AND.MM(S)  .NE.KQ)GO TO   91
      Z=0
  522 IF(MM(S)   .NE.KA)GO TO   92
      S=S+1
      CALLNCV(O,MM(S)  )
      IF( Z .EQ.0 )GO TO   90
      GO TO   93
   92 IF(MM(S)  .NE.KQ.AND. S.LE.U )GO TO   94
      IF( Z .NE.0 )GO TO   95
      Z=O
      IF(  NGEN .NE.0)GO TO   96
      O=O+6
      MM(O-1)=MM(98)
   96 GO TO   93
   95 CALLNCV(Z,O-Z-6)
      GO TO   90
   94 IF(  NGEN .NE.0)GO TO   93
      MM(O)  =MM(S)
      O=O+1
   93 S=S+1
      GO TO  522
   91 IF(MM(S)   .NE.MM(135))GO TO  101
      NSCN=0
      S=S+1
      GO TO 1029
  101 IF(  NGEN .NE.0)GO TO   90
      IF(MM(S)  .EQ.MM(117).AND. O.EQ.IO)GO TO   90
      MM(O)  =MM(S)
      O=O+1
   90 S=S+1
      IF(  NSCN .EQ.0)GO TO 1029
      IF( S .GT.U )GO TO 1029
      GO TO   88
 1016 T=IA
      S=S-1
      IF(  MM(T+1) .NE.MM(T)  )GO TO  524
      I=NONO(12,3,14,0)
      GO TO 1014
  524 A=MM(T)
      T=T+1
      N=A-1
      Z=0
  526 IF(MM(T)   .LE.A )GO TO  525
      IF(MM(A)   .NE.MM(134))GO TO  105
      IF( Z .NE.0 )GO TO  106
      MM(A)  =KQ
      Z=1
      GO TO  107
  106 A=A+1
      IF(MM(A)  .EQ.MM(134).AND.MM(T)  .GT.A )GO TO  107
      A=A-1
      MM(A)  =KQ
      Z=0
  107 GO TO  109
  105 IF(MM(A)   .NE.MM(141))GO TO  110
      IF(  MM(A+1) .NE.MM(141))GO TO  111
      A=A+1
      GO TO  112
  111 MM(A)  =IP
  112 GO TO  109
  110 IF(MM(A)   .NE.MM(142))GO TO  109
      IF(  MM(A+1) .NE.MM(142))GO TO  115
      A=A+1
      GO TO  109
  115 MM(A)  =KA
  109 N=N+1
      MM(N)  =MM(A)
      IF(MM(A)  .EQ.MM(117).AND. Z.NE.1 )GO TO  528
      A=A+1
      GO TO  526
  528 A=A+1
      IF(MM(T)  .LE.A .OR.MM(A)  .NE.MM(117))GO TO  526
      GO TO  528
  525 IF(T .NE.IS )GO TO  119
      I1=N
      GO TO  524
  119 I2=N
      GO TO  523
  523 IF(  ICAT .NE.0)GO TO  121
 1018 N=F
      F=F+4
      A=MM(IA)
  530 IF(A .GT.I1 )GO TO  529
      MM(F)  =MM(A)
      F=F+1
      IF(LIMF.LE.F)F=F+ NONO(3,6,8,1)
      A=A+1
      GO TO  530
  529 MM(N+1)=F
      A=MM(IS)
  532 IF(A .GT.I2 )GO TO  531
      MM(F)  =MM(A)
      F=F+1
      IF(LIMF.LE.F)F=F+ NONO(3,6,8,1)
      A=A+1
      GO TO  532
  531 MM(N+2)=F-1
      MM(N+3)=0
      T=IC
      A=MM(IA)
  534 IF(MM(A)   .NE.MM(T)  )GO TO  122
      MM(N)  =MM(T+1)
      GO TO  533
  122 T=T+2
      IF(  MM(T+1) .GT.00)GO TO  534
      MM(T)  =MM(A)
      MM(T+3)=0
      MM(N)  =0
      GO TO  533
  533 MM(T+1)=N
      T=3
      GO TO  124
  121 T=IC
      A=MM(IA)
  536 IF(MM(T)   .EQ.MM(A)  )GO TO  535
      T=T+2
      IF(  MM(T+1) .EQ.00)GO TO 1018
      GO TO  536
  535 T=MM(T+1)
      N=T
  125 T=N+4
      A=MM(IA)
  538 IF(MM(T)   .NE.MM(A)  )GO TO  537
      T=T+1
      A=A+1
      IF(A .GT.I1 )GO TO 1026
      GO TO  538
  537 N=MM(N)
      IF( N .EQ.0 )GO TO 1018
      GO TO  125
 1026 T=N+3
  540 IF(MM(T)   .EQ.00)GO TO  126
      T=MM(T)
      GO TO  540
  126 MM(T)  =F
      GO TO  539
  539 A=MM(IS)
      MM(F)  =0
      N=F+1
      F=F+2
  542 IF(A .GT.I2 )GO TO  541
      MM(F)  =MM(A)
      F=F+1
      IF(LIMF.LE.F)F=F+ NONO(3,6,8,1)
      A=A+1
      GO TO  542
  541 MM(N)  =F-1
      T=4
  124 IF(  MDEF .GT.0)CALLMACTRC(T,MM(IA),I1,MM(IS),I2)
      GO TO 1014
      END
      BLOCKDATA
      INTEGER A,B,C,D,E,F,G,H,O,P,Q,R,S,T,U,V,W,X,Y,Z
      COMMON/STATUS/IQ,Q,IR,R,C,NC,H,MTRC,MDEF,MCNT,NGEN,IQUO,MORT,MERR,
     XUPTR,UNIT,LIST,INDT,NOTE
      INTEGER UNIT,UPTR
      DATA IQ/200/,Q/200/,IR/250/,R/250/,C/80/,NC/72/,H/0/,MTRC/0/,MDEF/
     X0/,MCNT/500/,NGEN/0/,IQUO/0/,MORT/1/,MERR/0/,UPTR/1/,UNIT/1/,LIST/
     X0/,INDT/0/,NOTE/0/
      END
      SUBROUTINE MACTRC(W,I,J,K,L)
      INTEGER A,B,C,D,E,F,G,H,O,P,Q,R,S,T,U,V,W,X,Y,Z
      DIMENSION MM( 50 000)
      COMMON/MEM/MM
      GOTO( 1010, 1011, 1012, 1013),W
 1010 WRITE(6,1)(MM(JJ),JJ= I,J )
      IF( K .GT.L )GO TO  128
      DO  129T=K,L
      M=MM(T)
      N=MM(T+1)-1
      A=T-K+1
  129 IF( M .LE.N )WRITE(6,2)A,(MM(JJ),JJ=M,N)
  128 GO TO 1034
 1011 WRITE(6,3)(MM(JJ),JJ= I,J )
      GO TO 1034
 1012 WRITE(6,4)(MM(JJ),JJ= I,J )
      WRITE(6,5)(MM(JJ),JJ= K,L )
      GO TO 1034
 1013 WRITE(6,4)(MM(JJ),JJ= I,J )
      WRITE(6,6)(MM(JJ),JJ= K,L )
 1034 RETURN
    1 FORMAT(11X,19HPATTERN MATCHED IS ,80A1/(30X,80A1) )
    2 FORMAT(15X,8HARGUMENT,I3,4H IS ,80A1/(30X,80A1) )
    3 FORMAT(17X,13HEXPANSION IS ,80A1/(30X,80A1) )
    4 FORMAT(30H MACRO DEFINITION, PATTERN IS ,80A1/(30X,80A1) )
    5 FORMAT(15X,15HREPLACEMENT IS ,80A1/(30X,80A1) )
    6 FORMAT(9X,21HCATENATION STRING IS ,80A1/(30X,80A1) )
      END
      SUBROUTINE NXTCRD(M)
      INTEGER A,B,C,D,E,F,G,H,O,P,Q,R,S,T,U,V,W,X,Y,Z
      DIMENSION MM( 50 000)
      COMMON/MEM/MM
      COMMON/STATUS/IQ,Q,IR,R,C,NC,H,MTRC,MDEF,MCNT,NGEN,IQUO,MORT,MERR,
     XUPTR,UNIT,LIST,INDT,NOTE
      LOGICAL CNV
      INTEGER USTK,UPTR,UNIT
      DIMENSION USTK(20),I80(80),I79(79)
      EQUIVALENCE(MM(1),I79(1),I80(1)),(MM(180),USTK(1) )
      IF(  UPTR .NE.0)GO TO 1034
      IF(Q .EQ.IQ )GO TO  131
      MERR=MERR+1
      WRITE(6,  132)
  132 FORMAT(17H ******** ERROR -,23H UNCLOSED LOOP OR BLOCK)
  131 IF(R .EQ.IR )GO TO  133
      MERR=MERR+1
      WRITE(6,  134)
  134 FORMAT(17H ******** ERROR -,23H MISSING RIGHT BRACKET )
  133 IF(M .NE.MM(134) )GO TO  135
      MERR=MERR+1
      WRITE(6,  136)
  136 FORMAT(17H ******** ERROR -,17H UNCLOSED STRING )
  135 IF(M .NE.MM(135) )GO TO  137
      MERR=MERR+1
      WRITE(6,  138)
  138 FORMAT(17H ******** ERROR -,17H UNCLOSED COMMENT)
  137 WRITE(6,8)MERR
    8 FORMAT(I5,27H MORTRAN ERRORS ENCOUNTERED)
      IF(  MERR .EQ.0)STOP
      WRITE(7,7)
    7 FORMAT(6X,38H****** MORTRAN ERROR(S), CHECK LISTING/6X,3HEND)
      STOP12
 1034 READ(UNIT,1,END=9999)I80
    1 FORMAT(80A1)
      IF(  LIST .EQ.0)GO TO  139
      IF(MORT.NE.0.AND.MM(1)  .NE.MM(140))GO TO  140
      WRITE(6,2)I80
    2 FORMAT(9X,80A1)
      GO TO  139
  140 K=MAX0(INDT*H+1,1)
      L=1
      IF(  INDT .EQ.0)GO TO  142
  544 IF(MM(L)   .NE.MM(117))GO TO  142
      L=L+1
      IF(NC .GT.L )GO TO  544
      L=1
      GO TO  142
  142 IGEN=MM(117)
      IF(  NGEN .NE.0)IGEN=MM(114)
      WRITE(6,3)IGEN,M,H,(MM(117),I=1,K),(MM(I)  ,I=L,80)
    3 FORMAT(1X,2A1,I3,2X,3(124A1/7X) )
  139 IF(  MORT .NE.0)GO TO  144
      IF(MM(1)   .EQ.MM(140))GO TO  145
      WRITE(7,1)I80
  145 GO TO  146
  144 IF(  NOTE .NE.1)GO TO  147
      WRITE(7,4)I79
      IF(   MM(80) .NE.MM(117))WRITE(7,4)MM(80)
    4 FORMAT(1HC,79A1)
  147 IF(  NOTE .NE.2)GO TO  146
      WRITE(7,5)I80
    5 FORMAT(1HC,39X,40A1)
  146 IF(MM(1)   .NE.MM(140))GO TO  149
      IF(MM(2)   .NE.MM(107))GO TO  150
      IQUO=N2(0,1,0)
      GO TO 1034
  150 IF(MM(2)   .NE.MM(110))GO TO  151
      MTRC=N2(0,2,0)
      GO TO 1034
  151 IF(MM(2)   .NE.MM(94))GO TO  152
      MDEF=N2(0,2,0)
      GO TO 1034
  152 IF(MM(2)   .NE.MM(95))GO TO  153
      WRITE(6,6)
    6 FORMAT(1H1)
      GO TO 1034
  153 IF(MM(2)   .NE.MM(102))GO TO  154
      LIST=1
      GO TO 1034
  154 IF(MM(2)   .NE.MM(104))GO TO  155
      LIST=0
      GO TO 1034
  155 IF(MM(2)   .EQ.MM(96))GO TO 1033
      IF(MM(2)   .NE.MM(103))GO TO  156
      MORT=1
      C=NC
      MM(C)  =MM(132)
      RETURN
  156 IF(MM(2)   .NE.MM(99))GO TO  157
      INDT=N2(0,50,2)
      GO TO 1034
  157 IF(MM(2)   .NE.MM(91))GO TO  158
      NOTE=N2(0,2,1)
      GO TO 1034
  158 IF(MM(2)   .NE.MM(93))GO TO  159
      NC=N2(10,80,72)
      GO TO 1034
  159 IF(MM(2)   .NE.MM(111))GO TO  160
      USTK(UPTR)=UNIT
      UPTR=UPTR+1
      UNIT=N2(1,99,UNIT)
      GO TO 1034
  160 IF(MM(2)   .NE.MM(140))GO TO  149
 9999 UPTR=UPTR-1
      IF(  UPTR .EQ.0)GO TO 1033
      UNIT=USTK(UPTR)
      GO TO 1034
 1033 MORT=0
      C=NC-1
      MM(C)  =MM(132)
      MM(NC)=MM(132)
      RETURN
  149 IF(  MORT .EQ.0)GO TO 1034
      C=1
      RETURN
      END
      SUBROUTINE OUTLIN(A,Z)
      INTEGER A,B,C,D,E,F,G,H,O,P,Q,R,S,T,U,V,W,X,Y,Z
      DIMENSION MM( 50 000)
      COMMON/MEM/MM
      COMMON/STATUS/IQ,Q,IR,R,C,NC,H,MTRC,MDEF,MCNT,NGEN,IQUO,MORT,MERR,
     XUPTR,UNIT,LIST,INDT,NOTE
      LOGICAL CNV
      DIMENSION L(5)
      MCNT=500
      IF(  NGEN .NE.0)RETURN
      I=1
      B=A
      Y=Z-1
      DO  163J=1,5
  163 L(J)=MM(117)
  546 IF(MM(B)   .EQ.MM(117))GO TO  164
      IF(CNV(MM(B)  ,J,0,9))GO TO  545
      L(I)=MM(B)
      I=I+1
  164 B=B+1
      IF( I.GT.5 .OR. B.GT.Y )GO TO  545
      GO TO  546
  545 WRITE(7,1)L,(MM(J)  ,J=B,Y)
      Z=A
      RETURN
    1 FORMAT(5A1,1X,66A1/(5X,1H*,66A1) )
      END
      SUBROUTINE NCV(P,N)
      INTEGER A,B,C,D,E,F,G,H,O,P,Q,R,S,T,U,V,W,X,Y,Z
      DIMENSION MM( 50 000)
      COMMON/MEM/MM
      COMMON/STATUS/IQ,Q,IR,R,C,NC,H,MTRC,MDEF,MCNT,NGEN,IQUO,MORT,MERR,
     XUPTR,UNIT,LIST,INDT,NOTE
      IF(  NGEN .NE.0)RETURN
      I=N
      P=P+5
      DO  165J=1,5
      K=P-J
      MM(K)  =MM(117)
      T=I/10
      IF( I.EQ.0 .AND. J.NE.1 )GO TO  166
      I=I-T*10+81
      MM(K)  =MM(I)
  166 I=T
  165 CONTINUE
      RETURN
      END
      LOGICAL FUNCTION CNV(I,O,L,M)
      INTEGER A,B,C,D,E,F,G,H,O,P,Q,R,S,T,U,V,W,X,Y,Z
      DIMENSION MM( 50 000)
      COMMON/MEM/MM
      CNV=.TRUE.
      IF( L .GT.M )RETURN
      KL=L+81
      KM=M+81
      DO  167K=KL,KM
      IF(MM(K)   .NE.I )GO TO  167
      O=K-81
      CNV=.FALSE.
      GO TO 1034
  167 CONTINUE
 1034 RETURN
      END
      FUNCTION N1(I,L,M,K)
      INTEGER A,B,C,D,E,F,G,H,O,P,Q,R,S,T,U,V,W,X,Y,Z
      DIMENSION MM( 50 000)
      COMMON/MEM/MM
      COMMON/STATUS/IQ,Q,IR,R,C,NC,H,MTRC,MDEF,MCNT,NGEN,IQUO,MORT,MERR,
     XUPTR,UNIT,LIST,INDT,NOTE
      LOGICAL CNV
      N1=K
      N=K
      IF(CNV(I,N,L,M))GO TO 1014
      N1=N
      RETURN
 1014 MERR=MERR+1
      WRITE(6,1) I
      RETURN
    1 FORMAT(38H ******** ERROR - BAD PARAMETER NUMBER,1X,A2)
      END
      FUNCTION N2(L,M,K)
      INTEGER A,B,C,D,E,F,G,H,O,P,Q,R,S,T,U,V,W,X,Y,Z
      DIMENSION MM( 50 000)
      COMMON/MEM/MM
      COMMON/STATUS/IQ,Q,IR,R,C,NC,H,MTRC,MDEF,MCNT,NGEN,IQUO,MORT,MERR,
     XUPTR,UNIT,LIST,INDT,NOTE
      LOGICAL CNV
      N2=-1
      IF(MM(3)   .EQ.MM(117))GO TO  169
      IF(CNV(MM(3)  ,N1,0,9))GO TO 1014
      N2=N1
  169 IF(MM(4)   .EQ.MM(117))GO TO  170
      IF(CNV(MM(4)  ,N1,0,9))GO TO 1014
      N2=10*N2+N1
  170 IF( L.LE.N2.AND.N2.LE.M )GO TO 1034
 1014 N2=K
      WRITE(6,1) K
    1 FORMAT(46H ******** ERROR - BAD NUMERICS ON CONTROL CARD,I3,8H ASS
     XUMED)
      MERR=MERR+1
 1034 RETURN
      END
      FUNCTION NONO(I,J,K,L)
      INTEGER A,B,C,D,E,F,G,H,O,P,Q,R,S,T,U,V,W,X,Y,Z
      DIMENSION MM( 50 000)
      COMMON/MEM/MM
      COMMON/STATUS/IQ,Q,IR,R,C,NC,H,MTRC,MDEF,MCNT,NGEN,IQUO,MORT,MERR,
     XUPTR,UNIT,LIST,INDT,NOTE
      DIMENSION A(64)
      DATAA(01),A(02),A(03),A(04)/2HIN,2HPU,2HT ,2H  /,A(05),A(06),A(07)
     X,A(08)/2HPA,2HRA,2HMT,2HER/,A(09),A(10),A(11),A(12)/2HMA,2HCR,2HO
     X,2H  /,A(13),A(14),A(15),A(16)/2HLA,2HBE,2HL ,2H  /,A(17),A(18),A(
     X19),A(20)/2HOU,2HTP,2HUT,2H  /,A(21),A(22),A(23),A(24)/2HBU,2HFF,2
     XHER,2H  /,A(25),A(26),A(27),A(28)/2HST,2HAC,2HK ,2H  /,A(29),A(30)
     X,A(31),A(32)/2HOV,2HER,2HFL,2HOW/,A(33),A(34),A(35),A(36)/2HUN,2HD
     XR,2HFL,2HOW/,A(37),A(38),A(39),A(40)/2HDI,2HGI,2HT ,2H  /,A(41),A(
     X42),A(43),A(44)/2HUN,2HDE,2HFI,2HND/,A(45),A(46),A(47),A(48)/2HIL,
     X2HLE,2HGA,2HL /,A(49),A(50),A(51),A(52)/2HST,2HRI,2HNG,2H  /
      DATA A(53)
     X,A(54),A(55),A(56)/2HPA,2HTT,2HER,2HN /,A(57),A(58),A(59),A(60)/2H
     XEX,2HPN,2HSI,2HON/,A(61),A(62),A(63),A(64)/2HLO,2HOP,2H  ,2H  /
      WRITE(6,1)A(4*I-3),A(4*I-2),A(4*I-1),A(4*I),A(4*J-3),A(4*J-2),A(4*
     XJ-1),A(4*J),A(4*K-3),A(4*K-2),A(4*K-1),A(4*K)
      NONO=-1
      IF( L .NE.0 )STOP16
      MERR=MERR+1
      WRITE(6,2)
      RETURN
    1 FORMAT(18H ******** ERROR - ,3(1X,4A2) )
    2 FORMAT(30H MORTRAN PROCESSING CONTINUING )
      END
      SUBROUTINE IOINIT
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C     THIS SUBROUTINE OPENS AND MAKES AVAILABLE TO THE PROGRAM THE
C     THE VARIOUS INPUT AND OUTPUT FILES IT USES.  IT SHOULD BE
C     PROGRAMMED BY THE USER, IN ACCORDANCE WITH HIS SYSTEM.
C
C
C        TAPE1- FILE OF MORTRAN MACROS.
C
C        TAPE5- THE MORTRAN SOURCE FILE.
C
C        TAPE6- THE MORTRAN LISTING.
C
C        TAPE7- THE FORTRAN SOURCE FILE.
C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      OPEN(UNIT=1,FILE='/export/home/andy/mortran/AREMACS')
      OPEN(UNIT=5)
      OPEN(UNIT=6,FILE='LST')
      OPEN(UNIT=7,FILE='FTN')
      RETURN
      END
