      program loops

      common/ispace/iter,m,j4,max24,E,F,IR,IX,ZONE
      integer iter(24),m,j4,max24,E(96),F(96),IR(1001),
     2  IX(1001),ZONE(300)

      common/spacer/A11,A12,A13,A21,A22,A23,A31,A32,A33,CO,
     2  DK,DM22,DM23,DM24,DM25,DM26,DM27,DM28,FLX,Q,R,S,SIG,
     3  STB5,T
      double precision A11,A12,A13,A21,A22,A23,A31,A32,A33,CO,
     2  DK,DM22,DM23,DM24,DM25,DM26,DM27,DM28,FLX,Q,R,S,SIG,
     3  STB5,T

      common/space1/B5,D,DEX,DEX1,EX,EX1,G,GRD,PLAN,RH,RX,SA,
     2  SB,VE3,VLIN,VLR,VSP,VSTP,VX,VXND,VXNE,XI,XX,U,V,W,X,Y,Z
      double precision B5(101),D(300),DEX(1001),DEX1(1001),EX(1001),
     2  EX1(1001),G(1001),GRD(1001),PLAN(300),RH(1001),RX(1001),SA(101),
     3  SB(101),VE3(101),VLIN(101),VLR(101),VSP(101),VSTP(101),VX(1001),
     4  VXND(101),VXNE(101),XI(1001),XX(1001),U(1001),V(1001),W(1001),
     5  X(1001),Y(1001),Z(1001)

      common/space2/B,C,H,P,CX,PX,U1,U2,U3,VF,VG,VH,VS,VY,ZA,ZB,ZM,
     2  ZP,ZQ,ZR,ZU,ZV,ZZ
      double precision B(64,64),C(64,64),H(64,64),P(4,512),
     2  CX(25,101),PX(25,101),U1(5,101,2),U2(5,101,2),U3(5,101,2),
     3  VF(101,7),VG(101,7),VH(101,7),VS(101,7),VY(101,25),ZA(101,7),
     4  ZB(101,7),ZM(101,7),ZP(101,7),ZQ(101,7),ZR(101,7),ZU(101,7),
     5  ZV(101,7),ZZ(101,7)

 100  write(6,'(''Which loop:'')')
      read(5,'(i2)') loop
      if(loop .eq. 0) stop
      if(loop .eq. 1) goto 1
      if(loop .eq. 2) goto 2
      if(loop .eq. 3) goto 3
      if(loop .eq. 4) goto 4
      if(loop .eq. 5) goto 5
      if(loop .eq. 6) goto 6
      if(loop .eq. 7) goto 7
      if(loop .eq. 8) goto 8
      if(loop .eq. 9) goto 9
      if(loop .eq. 10) goto 10
      if(loop .eq. 11) goto 11
      if(loop .eq. 12) goto 12
      if(loop .eq. 13) goto 13
      if(loop .eq. 14) goto 14
      if(loop .eq. 15) goto 15
      if(loop .eq. 16) goto 16
      if(loop .eq. 17) goto 17
      if(loop .eq. 18) goto 18
      if(loop .eq. 19) goto 19
      if(loop .eq. 20) goto 20
      if(loop .eq. 21) goto 21
      if(loop .eq. 22) goto 22
      if(loop .eq. 23) goto 23
      if(loop .eq. 24) goto 24
      goto 100
 1    call initial(1)
c      call wrinput(1)
      call Loop1(iter(1),Q,R,T,X,Y,Z)
c      call wroutput(1)
      goto 100
 2    call initial(2)
c      call wrinput(2)
      call Loop2(iter(2),V,X)
c      call wroutput(2)
      goto 100
 3    call initial(3)
c      call wrinput(3)
      call Loop3(iter(3),Q,X,Z)
c      call wroutput(3)
      goto 100
 4    call initial(4)
c      call wrinput(4)
      call Loop4(iter(4),X,Y)
c      call wroutput(4)
      goto 100
 5    call initial(5)
c      call wrinput(5)
      call Loop5(iter(5),X,Y,Z)
c      call wroutput(5)
      goto 100
 6    call initial(6)
c      call wrinput(6)
      call Loop6(iter(6),B,W)
c      call wroutput(6)
      goto 100
 7    call initial(7)
c      call wrinput(7)
      call Loop7(iter(7),R,T,U,X,Y,Z)
c      call wroutput(7)
      goto 100
 8    call initial(8)
c      call wrinput(8)
      call Loop8(iter(8),A11,A12,A13,A21,A22,A23,
     .   A31,A32,A33,SIG,U1,U2,U3)
c      call wroutput(8)
      goto 100
 9    call initial(9)
c      call wrinput(9)
      call Loop9(iter(9),CO,DM22,DM23,DM24,DM25,DM26,DM27,DM28,PX)
c      call wroutput(9)
      goto 100
 10   call initial(10)
c      call wrinput(10)
      call Loop10(iter(10),CX,PX)
c      call wroutput(10)
      goto 100
 11   call initial(11)
c      call wrinput(11)
      call Loop11(iter(11),X,Y)
c      call wroutput(11)
      goto 100
 12   call initial(12)
c      call wrinput(12)
      call Loop12(iter(12),X,Y)
c      call wroutput(12)
      goto 100
 13   call initial(13)
c      call wrinput(13)
      call Loop13(iter(13),E,F,B,C,H,P,Y,Z)
c      call wroutput(13)
      goto 100
 14   call initial(14)
c      call wrinput(14)
      call Loop14(iter(14),FLX,DEX,DEX1,EX,EX1,GRD,IR,IX,RH,
     .  RX,VX,XI,XX)
c      call wroutput(14)
      goto 100
 15   call initial(15)
c      call wrinput(15)
      call Loop15(iter(15),VF,VG,VH,VS,VY)
c      call wroutput(15)
      goto 100
 16   call initial(16)
c      call wrinput(16)
      call Loop16(iter(16),m,j4,R,S,T,D,PLAN,ZONE)
c      call wroutput(16)
      goto 100
 17   call initial(17)
c      call wrinput(17)
      call Loop17(iter(17),VE3,VLIN,VLR,VSP,VSTP,VXND,VXNE)
c      call wroutput(17)
      goto 100
 18   call initial(18)
c      call wrinput(18)
      call Loop18(iter(18),S,T,ZA,ZB,ZM,ZP,ZQ,ZR,ZU,ZV,ZZ)
c      call wroutput(18)
      goto 100
 19   call initial(19)
c      call wrinput(19)
      call Loop19(iter(19),STB5,B5,SA,SB)
c      call wroutput(19)
      goto 100
 20   call initial(20)
c      call wrinput(20)
      call Loop20(iter(20),DK,S,T,G,U,V,VX,W,X,XX,Y,Z)
c      call wroutput(20)
      goto 100
 21   call initial(21)
c      call wrinput(21)
      call Loop21(iter(21),CX,PX,VY)
c      call wroutput(21)
      goto 100
 22   call initial(22)
c      call wrinput(22)
      call Loop22(iter(22),U,V,W,X,Y)
c      call wroutput(22)
      goto 100
 23   call initial(23)
c      call wrinput(23)
      call Loop23(iter(23),ZA,ZB,ZR,ZU,ZV,ZZ)
c      call wroutput(23)
      goto 100
 24   call initial(24)
c      call wrinput(24)
      call Loop24(iter(24),max24,X)
c      call wroutput(24)
      goto 100
      end


      subroutine Loop1(n,Q,R,T,X,Y,Z)
      integer n,k
      double precision Q,R,T,X(1001),Y(1001),Z(1001)
      Do 1 k = 1,n
 1       X(k) = Q + (Y(k) * ((R * Z(k+10)) + (T * Z(k+11))))
      return
      end
 

      subroutine Loop2(n,V,X)
      integer n,k,i,IL,IPNT,IPNTP
      double precision V(1001),X(1001)
      IL = n
      IPNTP = 0
 21   IPNT = IPNTP
      IPNTP = IPNTP + IL
      IL = IL / 2
      i = IPNTP
      Do 20 k = IPNT+2,IPNTP,2
         i = i + 1
 20      X(i) = X(k) - (V(k) * X(k-1)) + (V(k+1) * X(k+1))
      If(IL .GT. 1)  GOTO 21
      return
      end


      subroutine Loop3(n,Q,X,Z)
      integer n
      double precision Q,X(1001),Z(1001)
      Q = 0.0d0
      Do 3 k = 1,n
 3       Q = Q + (Z(k) * X(k))
      return
      end


      subroutine Loop4(n,X,Y)
      integer n,k,j,lw
      double precision X(1001),Y(1001)
      Do 40 k = 7,1001,(1001 - 7)/2
         lw = k - 6
         Do 41 j = 5,n,5
            X(k-1) = X(k-1) - (X(lw) * Y(j))
 41         lw = lw + 1
 40      X(k-1) = Y(5) * X(k-1) 
      return
      end


      subroutine Loop5(n,X,Y,Z)
      integer i,n
      double precision X(1001),Y(1001),Z(1001)
      Do 5 i = 2,n
 5       X(i) = Z(i) * (Y(i) - X(i-1))
      return
      end


      subroutine Loop6(n,B,W)
      integer n
      double precision B(64,64),W(1001)
      Do 6 i = 2,n
      Do 6 k = 1,i-1
 6       W(i) = W(i) + (B(i,k) * W(i-k))
      return
      end

      subroutine Loop7(n,R,T,U,X,Y,Z)
      integer n
      double precision R,T,U(1001),X(1001),Y(1001),Z(1001)
      Do 7 k = 1,n
         X(k) = U(k) +
     .      (R * (Z(k) + (R * Y(k)))) +
     .      (T * (U(k+3) + (R * (U(k+2) + (R * U(k+1))))
     .      + (T * (U(k+6) + (R * (U(k+5) + (R * U(k+4))))))))
 7       Continue
      return
      end


      subroutine Loop8(n,A11,A12,A13,A21,A22,A23,A31,A32,A33,
     .                 SIG,U1,U2,U3)
      integer n,kx,ky,nl1,nl2
      double precision DU1(101),DU2(101),DU3(101)
      double precision U1(5,101,2),U2(5,101,2),U3(5,101,2)
      double precision A11,A12,A13,A21,A22,A23,A31,A32,A33,SIG
      nl1 = 1
      nl2 = 2
      Do 8 kx = 2,3
      Do 8 ky = 2,n
         DU1(ky) = U1(kx,ky+1,nl1) - U1(kx,ky-1,nl1)
         DU2(ky) = U2(kx,ky+1,nl1) - U2(kx,ky-1,nl1)
         DU3(ky) = U3(kx,ky+1,nl1) - U3(kx,ky-1,nl1)
         U1(kx,ky,nl2) = U1(kx,ky,nl1) + (A11 * DU1(ky)) + (A12 *
     .     DU2(ky)) + (A13 * DU3(ky)) + (SIG * (U1(kx+1,ky,nl1) -
     .     (2.0d0 * U1(kx,ky,nl1)) + U1(kx-1,ky,nl1)))
         U2(kx,ky,nl2) = U2(kx,ky,nl1) + (A21 * DU1(ky)) + (A22 *
     .     DU2(ky)) + (A23 * DU3(ky)) + (SIG * (U2(kx+1,ky,nl1) -
     .     (2.0d0 * U2(kx,ky,nl1)) + U2(kx-1,ky,nl1)))
         U3(kx,ky,nl2) = U3(kx,ky,nl1) + (A31 * DU1(ky)) + (A32 *
     .     DU2(ky)) + (A33 * DU3(ky)) + (SIG * (U3(kx+1,ky,nl1) -
     .     (2.0d0 * U3(kx,ky,nl1)) + U3(kx-1,ky,nl1)))
 8       Continue
      return
      end


      subroutine Loop9(n,CO,DM22,DM23,DM24,DM25,DM26,DM27,DM28,PX)
      integer i,n
      double precision CO,DM22,DM23,DM24,DM25,DM26,DM27,DM28,PX(25,101)
      Do 9 i = 1,n
         PX(1,i) = PX(3,i) +  (CO * (PX(5,i) + PX(6,i))) +
     .             (DM28 * PX(13,i)) + (DM27 * PX(12,i)) +
     .             (DM26 * PX(11,i)) + (DM25 * PX(10,i)) +
     .             (DM24 * PX(9,i))  + (DM23 * PX(8,i))  + 
     .             (DM22 * PX(7,i))
 9       Continue
      return
      end


      subroutine Loop10(n,CX,PX)
      integer i,n
      double precision AR,BR,CR,CX(25,101),PX(25,101)
      Do 10 i = 1,n
         AR = CX(5,i)
         BR = AR - PX(5,i)
         PX(5,i) = AR
         CR = BR - PX(6,i)
         PX(6,i) = BR
         AR = CR - PX(7,i)
         PX(7,i) = CR
         BR = AR - PX(8,i)
         PX(8,i) = AR
         CR = BR - PX(9,i)
         PX(9,i) = BR
         AR = CR - PX(10,i)
         PX(10,i) = CR
         BR = AR - PX(11,i)
         PX(11,i) = AR
         CR = BR - PX(12,i)
         PX(12,i) = BR
         PX(14,i) = CR - PX(13,i)
 10      PX(13,i) = CR
      return
      end


      subroutine Loop11(n,X,Y)
      integer k,n
      double precision X(1001),Y(1001)
      X(1) = Y(1)
      Do 11 k = 2,n
 11      X(k) = X(k-1) + Y(k)
      return
      end


      subroutine Loop12(n,X,Y)
      integer k,n
      double precision X(1001),Y(1001)
      Do 12 k = 1,n
 12      X(k) = Y(k+1) - Y(k)
      return
      end


      subroutine Loop13(n,E,F,B,C,H,P,Y,Z)
      integer n,ip,i1,j1,i2,j2,E(96),F(96)
      double precision B(64,64),C(64,64),H(64,64),P(4,512),
     .  Y(1001),Z(1001)
      Do 13 ip = 1,n
         i1 = P(1,ip)
         j1 = P(2,ip)
         i1 = 1 + MOD2N(i1,64)
         j1 = 1 + MOD2N(j1,64)
         P(3,ip) = P(3,ip) + B(i1,j1)
         P(4,ip) = P(4,ip) + C(i1,j1)
         P(1,ip) = P(1,ip) + P(3,ip)
         P(2,ip) = P(2,ip) + P(4,ip)
         i2 = P(1,ip)
         j2 = P(2,ip)
         i2 = MOD2N(i2,64)
         j2 = MOD2N(j2,64)
         P(1,ip) = P(1,ip) + Y(i2+32)
         P(2,ip) = P(2,ip) + Z(j2+32)
         i2 = i2 + E(i2+32)
         j2 = j2 + F(j2+32)
 13      H(i2,j2) = H(i2,j2) + 1.0d0
      return
      end


      subroutine Loop14(n,FLX,DEX,DEX1,EX,EX1,GRD,IR,IX,RH,RX,
     .                  VX,XI,XX)
      integer n,k,IR(1001),IX(1001)
      double precision FLX,DEX(1001),DEX1(1001),EX(1001),EX1(1001),
     .  GRD(1001),RH(1001),RX(1001),VX(1001),XI(1001),XX(1001)
      Do 141 k = 1,n
         VX(k) = 0.0d0
         XX(k) = 0.0d0
         IX(k) = INT(GRD(k))
         XI(k) = FLOAT(IX(k))
         EX1(k) = EX(IX(k))
 141     DEX1(k) = DEX(IX(k))
      Do 142 k = 1,n
         VX(k) = VX(k) + EX1(k) + (DEX1(k) * (XX(k) - XI(k)))
         XX(k) = XX(k) + VX(k) + FLX
         IR(k) = XX(k)
         RX(k) = XX(k) - IR(k)
         IR(k) = MOD2N(IR(k),512) + 1
 142     XX(k) = RX(k) + IR(k)
      Do 140 k = 1,n
         RH(IR(k)) = RH(IR(k)) - RX(k) + 1.0d0
 140     RH(IR(k) + 1) = RH(IR(k) + 1) + RX(k)
      return
      end


      subroutine Loop15(n,VF,VG,VH,VS,VY)
      integer j,k
      double precision R,S,T,VF(101,7),VG(101,7),VH(101,7),
     .  VS(101,7),VY(101,25)
      do 1500 j = 2,7
      do 1500 k = 2,n
         if(j-7) 1502,1501,1501
 1501    VY(k,j) = 0.0d0
         goto 1500
 1502    if(VH(k,j+1) - VH(k,j)) 1504,1504,1503
 1503    T = 0.053d0
         goto 1505
 1504    T = 0.073d0
 1505    if(VF(k,j) - VF(k-1,j)) 1506,1507,1507
 1506    R = max(VH(k-1,j), VH(k-1,j+1))
         S = VF(k-1,j)
         goto 1508
 1507    R = max(VH(k,j), VH(k,j+1))
         S = VF(k,j)
 1508    VY(k,j) = dsqrt(VG(k,j)**2 + R * R) * T / S
 1509    if(k-n) 1511,1510,1510
 1510    VS(k,j) = 0.0d0
         goto 1500
 1511    if(VF(k,j) - VF(k,j-1)) 1512,1513,1513
 1512    R = max(VG(k,j-1), VG(k+1,j-1))
         S = VF(k,j-1)
         T = 0.073d0
         goto 1514 
 1513    R = max(VG(k,j), VG(k+1,j))
         S = VF(k,j)
         T = 0.053d0
 1514    VS(k,j) = dsqrt(VH(k,j)**2 + R * R) * T / S
 1500 continue
      return
      end


      subroutine Loop16(n,m,j4,R,S,T,D,PLAN,ZONE)
      integer n,m,i1,j2,j4,j5,k,II,LB,ZONE(300)
      double precision R,S,T,D(300),PLAN(300)
      m = 1
      i1 = m
      II = n / 3
      LB = II + II
 1601 j2 = (n + n) * (m - 1) + 1
      do 1613 k = 1,n
         j4 = j2 + k + k
         j5 = ZONE(j4)
         if(j5 - n) 1603,1614,1609
 1602    if(j5 - n + II) 1605,1604,1604
 1603    if(j5 - n + LB) 1606,1602,1602
 1604    if(PLAN(j5) - R) 1608,1615,1607
 1605    if(PLAN(j5) - S) 1608,1615,1607
 1606    if(PLAN(j5) - T) 1608,1615,1607
 1607    if(ZONE(j4 - 1)) 1610,1616,1613
 1608    if(ZONE(j4 - 1)) 1613,1616,1610
 1609    if(D(j5) - (D(j5-1) * (T - D(j5-2))**2 + (S - D(j5-3))**2
     .      + (R - D(j5-4))**2)) 1608,1615,1607
 1610    m = m + 1
         if(m - ZONE(1)) 1612,1612,1611
 1611    m = 1
 1612    if(i1 - m) 1601,1615,1601
 1613 continue
 1614 continue
 1615 continue
 1616 continue
      return
      end


      subroutine Loop17(n,VE3,VLIN,VLR,VSP,VSTP,VXND,VXNE)
      integer i,n
      double precision E3,E6,XNC,XNEI,XNM,VE3(101),VLIN(101),
     .  VLR(101),VSP(101),VSTP(101),VXND(101),VXNE(101)
      i = n
      XNM = 1.0d0 / 3.0d0
      E6 = 1.03d0 / 3.07d0
      goto 172
 171  E6 = XNM * VSP(i) + VSTP(i)
      VXNE(i) = E6
      XNM = E6
      VE3(i) = E6
      i = i - 1
      if(i .eq. 1) goto 170
 172  E3 = XNM * VLR(i) + VLIN(i)
      XNC = 5.0d0 / 3.0d0 * E3
      XNEI = VXNE(i)
      VXND(i) = E6
      if(XNM .gt. XNC) goto 171
      if (XNEI .gt. XNC) goto 171
      VE3(i) = E3
      E6 = E3 + E3 - XNM
      VXNE(i) = E3 + E3 - XNEI
      XNM = E6
      i = i - 1
      if(i .ne. 1) goto 172
 170  continue
      return
      end


      subroutine Loop18(n,S,T,ZA,ZB,ZM,ZP,ZQ,ZR,ZU,ZV,ZZ)
      integer k,j,n
      double precision S,T,ZA(101,7),ZB(101,7),ZM(101,7),ZP(101,7),
     .  ZQ(101,7),ZR(101,7),ZU(101,7),ZV(101,7),ZZ(101,7)
      do 181 k = 2,6
      do 181 j = 2,n
         ZA(j,k) =
     .   (ZP(j-1,k+1) + ZQ(j-1,k+1) - ZP(j-1,k) - ZQ(j-1,k)) *
     .   (ZR(j,k) + ZR(j-1,k)) / (ZM(j-1,k) + ZM(j-1,k+1))
         ZB(j,k) = 
     .   (ZP(j-1,k) + ZQ(j-1,k) - ZP(j,k) - ZQ(j,k)) *
     .   (ZR(j,k) + ZR(j,k-1)) / (ZM(j,k) + ZM(j-1,k))
 181  continue
      do 182 k = 2,6
      do 182 j = 2,n
         ZU(j,k) = ZU(j,k) + S *
     .             (ZA(j,k)   * (ZZ(j,k) - ZZ(j+1,k)) -
     .              ZA(j-1,k) * (ZZ(j,k) - ZZ(j-1,k)) -
     .              ZB(j,k)   * (ZZ(j,k) - ZZ(j,k-1)) +
     .              ZB(j,k+1) * (ZZ(j,k) - ZZ(j,k+1)))
         ZV(j,k) = ZV(j,k) + S *
     .             (ZA(j,k)   * (ZR(j,k) - ZR(j+1,k)) -
     .              ZA(j-1,k) * (ZR(j,k) - ZR(j-1,k)) -
     .              ZB(j,k)   * (ZR(j,k) - ZR(j,k-1)) +
     .              ZB(j,k+1) * (ZR(j,k) - ZR(j,k+1)))
 182  continue
      do 183 k = 2,6
      do 183 j = 2,n
         ZR(j,k) = ZR(j,k) + T * ZU(j,k)
         ZZ(j,k) = ZZ(j,k) + T * ZV(j,k)
 183  continue
      return
      end


      subroutine Loop19(n,STB5,B5,SA,SB)
      integer i,k,n
      double precision STB5,B5(101),SA(101),SB(101)
      do 191 k = 1,n
         B5(k) = SA(k) + STB5 * SB(k)
 191     STB5 = B5(k) - STB5
      do 193 i = 1,n
         k = n - i + 1
         B5(k) = SA(k) + STB5 * SB(k)
 193     STB5 = B5(k) - STB5
      return
      end


      subroutine Loop20(n,DK,S,T,G,U,V,VX,W,X,XX,Y,Z)
      integer k,n
      double precision DK,DI,DN,S,T,G(1001),U(1001),V(1001),
     .  VX(1001),W(1001),X(1001),XX(1001),Y(1001),Z(1001)
      do 20 k = 1,n
         DI = Y(k) - (G(k) / (XX(k) + DK))
         DN = 0.2d0
         if(DI .NE. 0.0d0) DN = max(S, min(Z(k)/DI, T))
         X(k) = ((W(k) + V(k) * DN) * XX(k) + U(k)) /
     .          (VX(k) + V(k) * DN)
         XX(k+1) = (X(k) - XX(k)) * DN + XX(k)
 20    continue
       return
       end


      subroutine Loop21(n,CX,PX,VY)
      integer i,j,k,n
      double precision CX(25,101),PX(25,101),VY(101,25)
      do 21 k = 1,15
      do 21 i = 1,15
      do 21 j = 1,n
         PX(i,j) = PX(i,j) + VY(i,k) * CX(k,j)
 21   continue
      return
      end


      subroutine Loop22(n,U,V,W,X,Y)
      integer k,n
      double precision U(1001),V(1001),
     .  W(1001),X(1001),Y(1001)
      do 22 k = 1,n
         Y(k) = 20.0d0
         if(U(k) .lt. 20.0d0 * V(k)) Y(k) = U(k) / V(k)
         W(k) = X(k) / (dexp(Y(k)) - 1.0d0)
 22   continue
      return
      end


      subroutine Loop23(n,ZA,ZB,ZR,ZU,ZV,ZZ)
      integer j,k,n
      double precision QA,ZA(101,7),ZB(101,7),ZR(101,7),
     .  ZU(101,7),ZV(101,7),ZZ(101,7)
      do 23 j = 2,6
      do 23 k = 2,n
         QA = ZA(k,j+1) * ZR(k,j) + ZA(k,j-1) * ZB(k,j) +
     .        ZA(k+1,j) * ZU(k,j) + ZA(k-1,j) * ZV(k,j) + ZZ(k,j)
 23      ZA(k,j) = ZA(k,j) + 0.175d0 * (QA - ZA(k,j))
      return
      end


      subroutine Loop24(n,max24,X)
      integer k,max24,n
      double precision X(1001)
      max24 = 1
      do 24 k = 2,n
 24      if(X(k) .lt. X(max24)) max24 = k
      return
      end


      function MOD2N(i,j)
      integer i,j
      if(i .lt. 0) MOD2N = mod(i,j) + (j / 2) + iabs(j/2)
      if(i .ge. 0) MOD2N = mod(i,j) + (j / 2) - iabs(j/2)
      return
      end


      subroutine initial(n)
      common/ispace/iter,m,j4,max24,E,F,IR,IX,ZONE
      integer iter(24),m,j4,max24,E(96),F(96),IR(1001),
     2  IX(1001),ZONE(300)
      common/spacer/A11,A12,A13,A21,A22,A23,A31,A32,A33,CO,
     2  DK,DM22,DM23,DM24,DM25,DM26,DM27,DM28,FLX,Q,R,S,SIG,
     3  STB5,T
      double precision A11,A12,A13,A21,A22,A23,A31,A32,A33,CO,
     2  DK,DM22,DM23,DM24,DM25,DM26,DM27,DM28,FLX,Q,R,S,SIG,
     3  STB5,T
      common/space1/B5,D,DEX,DEX1,EX,EX1,G,GRD,PLAN,RH,RX,SA,
     2  SB,VE3,VLIN,VLR,VSP,VSTP,VX,VXND,VXNE,XI,XX,U,V,W,X,Y,Z
      double precision B5(101),D(300),DEX(1001),DEX1(1001),EX(1001),
     2  EX1(1001),G(1001),GRD(1001),PLAN(300),RH(1001),RX(1001),SA(101),
     3  SB(101),VE3(101),VLIN(101),VLR(101),VSP(101),VSTP(101),VX(1001),
     4  VXND(101),VXNE(101),XI(1001),XX(1001),U(1001),V(1001),W(1001),
     5  X(1001),Y(1001),Z(1001)
      common/space2/B,C,H,P,CX,PX,U1,U2,U3,VF,VG,VH,VS,VY,ZA,ZB,ZM,
     2  ZP,ZQ,ZR,ZU,ZV,ZZ
      double precision B(64,64),C(64,64),H(64,64),P(4,512),
     2  CX(25,101),PX(25,101),U1(5,101,2),U2(5,101,2),U3(5,101,2),
     3  VF(101,7),VG(101,7),VH(101,7),VS(101,7),VY(101,25),ZA(101,7),
     4  ZB(101,7),ZM(101,7),ZP(101,7),ZQ(101,7),ZR(101,7),ZU(101,7),
     5  ZV(101,7),ZZ(101,7)
      integer i,j,k,n,joke
      double precision ss,one9th
      call vector
      ss = 1.0d0
      one9th = 1.0d0 / 9.0d0
      iter(1) = 990
      iter(2) = 101
      iter(3) = 1001
      iter(4) = 35
      iter(5) = 101
      iter(6) = 64
      iter(7) = 995
      iter(8) = 100
      iter(9) = 101
      iter(10) = 101
      iter(11) = 128
      iter(12) = 1000
      iter(13) = 64
      iter(14) = 1001
      iter(15) = 101
      iter(16) = 75
      iter(17) = 101
      iter(18) = 100
      iter(19) = 101
      iter(20) = 100
      iter(21) = 10
      iter(22) = 101
      iter(23) = 100
      iter(24) = 1001
      Do 1 i=1,96
         E(i) = 1
 1       F(i) = 1
      Do 2 i=1,4
      Do 2 j=1,512
         P(i,j) = ss
 2       ss = ss + 0.5d0
      Do 3 i = 1,1001
         VX(i) = 0.001d0
         XX(i) = 2.001d0
 3       GRD(i) = 3.0d0 + one9th
      Do 4 i = 1,1001
         joke = i * one9th
         if(joke.lt.1) joke = 1
         EX(i) = joke
         RH(joke) = joke
 4       DEX(joke) = joke
      if(n .eq. 16) then
         D(1) = 1.01980486428764d0
         Do 5 i = 2,300
 5       D(i) = D(i-1) + (1.0d-4 / D(i-1))
         R = D(iter(16))
         Do 6 i = 1,2
            m = (iter(16) + iter(16)) * (i - 1)
            Do 6 j = 1,2
            Do 6 k = 1,iter(16)
               m = m + 1
               S = REAL(k)
               PLAN(m) = R * ((S + 1.0d0) / S)
 6             ZONE(m) = k + k
         S = D(iter(16) - 1)
         T = D(iter(16) - 2)
         ZONE(iter(16)+iter(16)+1) = iter(16)
      endif
      return
      end

      subroutine vector
      common/spacer/A
      common/space1/B
      common/space2/C
      double precision A(25),B(18627),C(34132)
      double precision bias,buzz,fizz,fuzz,scale
      bias = 0.0d0
      scale = 0.01d0
      fuzz = 1.2345D-3
      buzz = 1.0d0 + fuzz
      fizz = 1.1d0 * fuzz
      do 1 i = 1,25
         buzz = ((1.0d0 - fuzz) * buzz) + fuzz
         fuzz = -fuzz
 1       A(i) = ((buzz - fizz) - bias) * scale
      do 2 i = 1,18627
         buzz = ((1.0d0 - fuzz) * buzz) + fuzz
         fuzz = -fuzz
 2       B(i) = ((buzz - fizz) - bias) * scale
      do 3 i = 1,34132
         buzz = ((1.0d0 - fuzz) * buzz) + fuzz
         fuzz = -fuzz
 3       C(i) = ((buzz - fizz) - bias) * scale
      return
      end


c      subroutine wrinput(n)
c      integer i,j,k,n
c      common/ispace/iter,m,j4,max24,E,F,IR,IX,ZONE
c      integer iter(24),m,j4,max24,E(96),F(96),IR(1001),
c     2  IX(1001),ZONE(300)
c      common/spacer/A11,A12,A13,A21,A22,A23,A31,A32,A33,CO,
c     2  DK,DM22,DM23,DM24,DM25,DM26,DM27,DM28,FLX,Q,R,S,SIG,
c     3  STB5,T
c      double precision A11,A12,A13,A21,A22,A23,A31,A32,A33,CO,
c     2  DK,DM22,DM23,DM24,DM25,DM26,DM27,DM28,FLX,Q,R,S,SIG,
c     3  STB5,T
c      common/space1/B5,D,DEX,DEX1,EX,EX1,G,GRD,PLAN,RH,RX,SA,
c     2  SB,VE3,VLIN,VLR,VSP,VSTP,VX,VXND,VXNE,XI,XX,U,V,W,X,Y,Z
c      double precision B5(101),D(300),DEX(1001),DEX1(1001),EX(1001),
c     2  EX1(1001),G(1001),GRD(1001),PLAN(300),RH(1001),RX(1001),SA(101),
c     3  SB(101),VE3(101),VLIN(101),VLR(101),VSP(101),VSTP(101),VX(1001),
c     4  VXND(101),VXNE(101),XI(1001),XX(1001),U(1001),V(1001),W(1001),
c     5  X(1001),Y(1001),Z(1001)
c      common/space2/B,C,H,P,CX,PX,U1,U2,U3,VF,VG,VH,VS,VY,ZA,ZB,ZM,
c     2  ZP,ZQ,ZR,ZU,ZV,ZZ
c      double precision B(64,64),C(64,64),H(64,64),P(4,512),
c     2  CX(25,101),PX(25,101),U1(5,101,2),U2(5,101,2),U3(5,101,2),
c     3  VF(101,7),VG(101,7),VH(101,7),VS(101,7),VY(101,25),ZA(101,7),
c     4  ZB(101,7),ZM(101,7),ZP(101,7),ZQ(101,7),ZR(101,7),ZU(101,7),
c     5  ZV(101,7),ZZ(101,7)
c      if(n .eq. 1) goto 1
c      if(n .eq. 2) goto 2
c      if(n .eq. 3) goto 3
c      if(n .eq. 4) goto 4
c      if(n .eq. 5) goto 5
c      if(n .eq. 6) goto 6
c      if(n .eq. 7) goto 7
c      if(n .eq. 8) goto 8
c      if(n .eq. 9) goto 9
c      if(n .eq. 10) goto 10
c      if(n .eq. 11) goto 11
c      if(n .eq. 12) goto 12
c      if(n .eq. 13) goto 13
c      if(n .eq. 14) goto 14
c      if(n .eq. 15) goto 15
c      if(n .eq. 16) goto 16
c      if(n .eq. 17) goto 17
c      if(n .eq. 18) goto 18
c      if(n .eq. 19) goto 19
c      if(n .eq. 20) goto 20
c      if(n .eq. 21) goto 21
c      if(n .eq. 22) goto 22
c      if(n .eq. 23) goto 23
c      if(n .eq. 24) goto 24
c 1    open(file='loop1in',unit=1)
c      write(1,'(''Loop1('',i4,'','')') iter(1)
c      write(1,'(3(1PD21.14,'', ''))') Q,R,T
c      write(1,'(''[1:'')')
c      write(1,'(3(1PD21.14,2x))') (Y(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (Z(i), i=1,1001)
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 2    open(file='loop2in',unit=1)
c      write(1,'(''Loop2('',i4,'','')') iter(2)
c      write(1,'(''[1:'')')
c      write(1,'(3(1PD21.14,2x))') (V(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (X(i), i=1,1001)
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 3    open(file='loop3in',unit=1)
c      write(1,'(''Loop3('',i4,'','')') iter(3)
c      write(1,'(''[1:'')')
c      write(1,'(3(1PD21.14,2x))') (X(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (Z(i), i=1,1001)
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 4    open(file='loop4in',unit=1)
c      write(1,'(''Loop4('',i4,'','')') iter(4)
c      write(1,'(''[1:'')')
c      write(1,'(3(1PD21.14,2x))') (X(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (Y(i), i=1,1001)
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 5    open(file='loop5in',unit=1)
c      write(1,'(''Loop5('',i4,'','')') iter(5)
c      write(1,'(''[1:'')')
c      write(1,'(3(1PD21.14,2x))') (X(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (Y(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (Z(i), i=1,1001)
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 6    open(file='loop6in',unit=1)
c      write(1,'(''Loop6('',i4,'','')') iter(6)
c      write(1,'(''[1:'')')
c      do 61 i=1,64
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (B(i,j), j=1,64)
c 61      write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (W(i), i=1,1001)
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 7    open(file='loop7in',unit=1)
c      write(1,'(''Loop7('',i4,'','')') iter(7)
c      write(1,'(2(1PD21.14,'', ''))') R,T
c      write(1,'(''[1:'')')
c      write(1,'(3(1PD21.14,2x))') (U(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (Y(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (Z(i), i=1,1001)
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 8    open(file='loop8in',unit=1)
c      write(1,'(''Loop8('',i4,'','')') iter(8)
c      write(1,'(3(1PD21.14,'', ''))') A11,A12,A13
c      write(1,'(3(1PD21.14,'', ''))') A21,A22,A23
c      write(1,'(3(1PD21.14,'', ''))') A31,A32,A33
c      write(1,'(1PD21.14,'','')') SIG
c      write(1,'(''[1:'')')
c      do 812 i = 1,5
c         write(1,'(''[1:'')')
c         do 811 j = 1,101
c 811        write(1,'(''[1: '',2(1PD21.14,2x),'']'')')
c     .           (U1(i,j,k), k=1,2)
c 812     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 822 i = 1,5
c         write(1,'(''[1:'')')
c         do 821 j = 1,101
c 821        write(1,'(''[1: '',2(1PD21.14,2x),'']'')')
c     .           (U2(i,j,k), k=1,2)
c 822     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 832 i = 1,5
c         write(1,'(''[1:'')')
c         do 831 j = 1,101
c 831        write(1,'(''[1: '',2(1PD21.14,2x),'']'')')
c     .           (U3(i,j,k), k=1,2)
c 832     write(1,'('']'')')
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 9    open(file='loop9in',unit=1)
c      write(1,'(''Loop9('',i4,'','')') iter(9)
c      write(1,'(1PD21.14,'','')') CO
c      write(1,'(2(1PD21.14,'', ''))') DM22,DM23
c      write(1,'(2(1PD21.14,'', ''))') DM24,DM25
c      write(1,'(3(1PD21.14,'', ''))') DM26,DM27,DM28
c      write(1,'(''[1:'')')
c      do 91 i=1,25
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (PX(i,j), j=1,101)
c 91      write(1,'('']'')')
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 10   open(file='loop10in',unit=1)
c      write(1,'(''Loop10('',i4,'','')') iter(10)
c      write(1,'(''[1:'')')
c      do 101 i=1,25
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (CX(i,j), j=1,101)
c 101     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 102 i=1,25
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (PX(i,j), j=1,101)
c 102     write(1,'('']'')')
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 11   open(file='loop11in',unit=1)
c      write(1,'(''Loop11('',i4,'','')') iter(11)
c      write(1,'(''[1:'')')
c      write(1,'(3(1PD21.14,2x))') (Y(i), i=1,1001)
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 12   open(file='loop12in',unit=1)
c      write(1,'(''Loop12('',i4,'','')') iter(12)
c      write(1,'(''[1:'')')
c      write(1,'(3(1PD21.14,2x))') (Y(i), i=1,1001)
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 13   open(file='loop13in',unit=1)
c      write(1,'(''Loop13('',i4,'','')') iter(13)
c      write(1,'(''[1:'')')
c      write(1,'(10(i5,2x))') (E(i), i=1,96)
c      write(1,'(''], [1:'')')
c      write(1,'(10(i5,2x))') (F(i), i=1,96)
c      write(1,'(''], [1:'')')
c      do 131 i=1,64
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (B(i,j), j=1,64)
c 131     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 132 i=1,64
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (C(i,j), j=1,64)
c 132     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 133 i=1,64
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (H(i,j), j=1,64)
c 133     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 134 i=1,4
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (P(i,j), j=1,512)
c 134     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (Y(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (Z(i), i=1,1001)
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 14   open(file='loop14in',unit=1)
c      write(1,'(''Loop14('',i4,'','')') iter(14)
c      write(1,'(1PD21.14,'','')') FLX
c      write(1,'(''[1:'')')
c      write(1,'(3(1PD21.14,2x))') (DEX(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (EX(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (GRD(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (RH(i), i=1,1001)
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 15   open(file='loop15in',unit=1)
c      write(1,'(''Loop15('',i4,'','')') iter(15)
c      write(1,'(''[1:'')')
c      do 151 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (VF(i,j), j=1,7)
c 151     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 152 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (VG(i,j), j=1,7)
c 152     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 153 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (VH(i,j), j=1,7)
c 153     write(1,'('']'')')
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 16   open(file='loop16in',unit=1)
c      write(1,'(''Loop16('',i4,'','')') iter(16)
c      write(1,'(3(1PD21.14,'', ''))') R,S,T
c      write(1,'(''[1:'')')
c      write(1,'(3(1PD21.14,2x))') (D(i), i=1,300)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (PLAN(i), i=1,300)
c      write(1,'(''], [1:'')')
c      write(1,'(3(i5,2x))') (ZONE(i), i=1,300)
c      write(1,'(''    2 ]);'')')
c      close(1)
c      goto 100
c 17   open(file='loop17in',unit=1)
c      write(1,'(''Loop17('',i4,'','')') iter(17)
c      write(1,'(''[1:'')')
c      write(1,'(3(1PD21.14,2x))') (VLIN(i), i=1,101)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (VLR(i), i=1,101)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (VSP(i), i=1,101)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (VSTP(i), i=1,101)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (VXNE(i), i=1,101)
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 18   open(file='loop18in',unit=1)
c      write(1,'(''Loop18('',i4,'','')') iter(18)
c      write(1,'(1PD21.14,'', '',1PD21.14,'','')') S, T
c      write(1,'(''[1:'')')
c      do 181 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (ZA(i,j), j=1,7)
c 181     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 182 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (ZB(i,j), j=1,7)
c 182     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 183 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (ZM(i,j), j=1,7)
c 183     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 184 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (ZP(i,j), j=1,7)
c 184     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 185 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (ZQ(i,j), j=1,7)
c 185     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 186 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (ZR(i,j), j=1,7)
c 186     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 187 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (ZU(i,j), j=1,7)
c 187     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 188 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (ZV(i,j), j=1,7)
c 188     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 189 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (ZZ(i,j), j=1,7)
c 189     write(1,'('']'')')
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 19   open(file='loop19in',unit=1)
c      write(1,'(''Loop19('',i4,'','')') iter(19)
c      write(1,'(1PD21.14,'','')') STB5
c      write(1,'(''[1:'')')
c      write(1,'(3(1PD21.14,2x))') (SA(i), i=1,101)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (SB(i), i=1,101)
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 20   open(file='loop20in',unit=1)
c      write(1,'(''Loop20('',i4,'','')') iter(20)
c      write(1,'(2(1PD21.14,'', ''))') DK, S
c      write(1,'(2(1PD21.14,'', ''))') T, XX(1)
c      write(1,'(''[1:'')')
c      write(1,'(3(1PD21.14,2x))') (G(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (U(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (V(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (VX(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (W(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (Y(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (Z(i), i=1,1001)
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 21   open(file='loop21in',unit=1)
c      write(1,'(''Loop21('',i4,'','')') iter(21)
c      write(1,'(''[1:'')')
c      do 211 i=1,25
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (CX(i,j), j=1,101)
c 211     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 212 i=1,25
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (PX(i,j), j=1,101)
c 212     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 213 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (VY(i,j), j=1,25)
c 213     write(1,'('']'')')
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 22   open(file='loop22in',unit=1)
c      write(1,'(''Loop22('',i4,'','')') iter(22)
c      write(1,'(''[1:'')')
c      write(1,'(3(1PD21.14,2x))') (U(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (V(i), i=1,1001)
c      write(1,'(''], [1:'')')
c      write(1,'(3(1PD21.14,2x))') (X(i), i=1,1001)
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 23   open(file='loop23in',unit=1)
c      write(1,'(''Loop23('',i4,'','')') iter(23)
c      write(1,'(''[1:'')')
c      do 231 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (ZA(i,j), j=1,7)
c 231     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 232 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (ZB(i,j), j=1,7)
c 232     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 233 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (ZR(i,j), j=1,7)
c 233     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 234 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (ZU(i,j), j=1,7)
c 234     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 235 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (ZV(i,j), j=1,7)
c 235     write(1,'('']'')')
c      write(1,'(''], [1:'')')
c      do 236 i=1,101
c         write(1,'(''[1:'')')
c         write(1,'(3(1PD21.14,2x))') (ZZ(i,j), j=1,7)
c 236     write(1,'('']'')')
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 24   open(file='loop24in',unit=1)
c      write(1,'(''Loop24('',i4,'','')') iter(24)
c      write(1,'(''[1:'')')
c      write(1,'(3(1PD21.14,2x))') (X(i), i=1,1001)
c      write(1,'('']);'')')
c      close(1)
c      goto 100
c 100  return
c      end


c      subroutine wroutput(n)
c      integer i,j,n
c      common/ispace/iter,m,j4,max24,E,F,IR,IX,ZONE
c      integer iter(24),m,j4,max24,E(96),F(96),IR(1001),
c     2  IX(1001),ZONE(300)
c      common/spacer/A11,A12,A13,A21,A22,A23,A31,A32,A33,CO,
c     2  DK,DM22,DM23,DM24,DM25,DM26,DM27,DM28,FLX,Q,R,S,SIG,
c     3  STB5,T
c      double precision A11,A12,A13,A21,A22,A23,A31,A32,A33,CO,
c     2  DK,DM22,DM23,DM24,DM25,DM26,DM27,DM28,FLX,Q,R,S,SIG,
c     3  STB5,T
c      common/space1/B5,D,DEX,DEX1,EX,EX1,G,GRD,PLAN,RH,RX,SA,
c     2  SB,VE3,VLIN,VLR,VSP,VSTP,VX,VXND,VXNE,XI,XX,U,V,W,X,Y,Z
c      double precision B5(101),D(300),DEX(1001),DEX1(1001),EX(1001),
c     2  EX1(1001),G(1001),GRD(1001),PLAN(300),RH(1001),RX(1001),SA(101),
c     3  SB(101),VE3(101),VLIN(101),VLR(101),VSP(101),VSTP(101),VX(1001),
c     4  VXND(101),VXNE(101),XI(1001),XX(1001),U(1001),V(1001),W(1001),
c     5  X(1001),Y(1001),Z(1001)
c      common/space2/B,C,H,P,CX,PX,U1,U2,U3,VF,VG,VH,VS,VY,ZA,ZB,ZM,
c     2  ZP,ZQ,ZR,ZU,ZV,ZZ
c      double precision B(64,64),C(64,64),H(64,64),P(4,512),
c     2  CX(25,101),PX(25,101),U1(5,101,2),U2(5,101,2),U3(5,101,2),
c     3  VF(101,7),VG(101,7),VH(101,7),VS(101,7),VY(101,25),ZA(101,7),
c     4  ZB(101,7),ZM(101,7),ZP(101,7),ZQ(101,7),ZR(101,7),ZU(101,7),
c     5  ZV(101,7),ZZ(101,7)
c      if(n .eq. 1) goto 1
c      if(n .eq. 2) goto 2
c      if(n .eq. 3) goto 3
c      if(n .eq. 4) goto 4
c      if(n .eq. 5) goto 5
c      if(n .eq. 6) goto 6
c      if(n .eq. 7) goto 7
c      if(n .eq. 8) goto 8
c      if(n .eq. 9) goto 9
c      if(n .eq. 10) goto 10
c      if(n .eq. 11) goto 11
c      if(n .eq. 12) goto 12
c      if(n .eq. 13) goto 13
c      if(n .eq. 14) goto 14
c      if(n .eq. 15) goto 15
c      if(n .eq. 16) goto 16
c      if(n .eq. 17) goto 17
c      if(n .eq. 18) goto 18
c      if(n .eq. 19) goto 19
c      if(n .eq. 20) goto 20
c      if(n .eq. 21) goto 21
c      if(n .eq. 22) goto 22
c      if(n .eq. 23) goto 23
c      if(n .eq. 24) goto 24
c 1    open(file='loop1out',unit=1)
c      write(1,'(3(1PD21.14,2x))') (X(i), i=1,iter(1))
c      close(1)
c      goto 100
c 2    open(file='loop2out',unit=1)
c      write(1,'(3(1PD21.14,2x))') (X(i), i=1,198)
c      close(1)
c      goto 100
c 3    open(file='loop3out',unit=1)
c      write(1,'(1PD21.14)') Q
c      close(1)
c      goto 100
c 4    open(file='loop4out',unit=1)
c      write(1,'(3(1PD21.14,2x))') (X(i), i=1,1001)
c      close(1)
c      goto 100
c 5    open(file='loop5out',unit=1)
c      write(1,'(3(1PD21.14,2x))') (X(i), i=1,iter(5))
c      close(1)
c      goto 100
c 6    open(file='loop6out',unit=1)
c      write(1,'(3(1PD21.14,2x))') (W(i), i=1,iter(6))
c      close(1)
c      goto 100
c 7    open(file='loop7out',unit=1)
c      write(1,'(3(1PD21.14,2x))') (X(i), i=1,iter(7))
c      close(1)
c      goto 100
c 8    open(file='loop8out',unit=1)
c      do 81 i = 2,3
c      do 81 j = 2,iter(8)
c 81      write(1,'(2(1PD21.14,2x))') U1(i,j,1),U1(i,j,2)
c      do 82 i = 2,3
c      do 82 j = 2,iter(8)
c 82      write(1,'(2(1PD21.14,2x))') U2(i,j,1),U2(i,j,2)
c      do 83 i = 2,3
c      do 83 j = 2,iter(8)
c 83      write(1,'(2(1PD21.14,2x))') U3(i,j,1),U3(i,j,2)
c      close(1)
c      goto 100
c 9    open(file='loop9out',unit=1)
c      do 91 i=1,25
c 91      write(1,'(3(1PD21.14,2x))') (PX(i,j), j=1,iter(9))
c      close(1)
c      goto 100
c 10   open(file='loop10out',unit=1)
c      do 101 i=5,14
c 101     write(1,'(3(1PD21.14,2x))') (PX(i,j), j=1,iter(10))
c      close(1)
c      goto 100
c 11   open(file='loop11out',unit=1)
c      write(1,'(3(1PD21.14,2x))') (X(i), i=1,iter(11))
c      close(1)
c      goto 100
c 12   open(file='loop12out',unit=1)
c      write(1,'(3(1PD21.14,2x))') (X(i), i=1,iter(12))
c      close(1)
c      goto 100
c 13   open(file='loop13out',unit=1)
c      do 131 i=1,64
c 131     write(1,'(3(1PD21.14,2x))') (H(i,j), j=1,64)
c      do 132 i=1,4
c 132     write(1,'(3(1PD21.14,2x))') (P(i,j), j=1,512)
c      close(1)
c      goto 100
c 14   open(file='loop14out',unit=1)
c      write(1,'(3(1PD21.14,2x))') (DEX1(i), i=1,iter(14))
c      write(1,'(3(1PD21.14,2x))') (EX1(i), i=1,iter(14))
c      write(1,'(10(i5,2x))') (IR(i), i=1,iter(14))
c      write(1,'(10(i5,2x))') (IX(i), i=1,iter(14))
c      write(1,'(3(1PD21.14,2x))') (RX(i), i=1,iter(14))
c      write(1,'(3(1PD21.14,2x))') (VX(i), i=1,iter(14))
c      write(1,'(3(1PD21.14,2x))') (XI(i), i=1,iter(14))
c      write(1,'(3(1PD21.14,2x))') (XX(i), i=1,iter(14))
c      write(1,'(3(1PD21.14,2x))') (RH(i), i=1,1001)
c      close(1)
c      goto 100
c 15   open(file='loop15out',unit=1)
c      do 151 i=2,iter(15)
c 151     write(1,'(3(1PD21.14,2x))') (VS(i,j), j=2,6)
c      do 152 i=2,iter(15) - 1
c 152     write(1,'(3(1PD21.14,2x))') (VY(i,j), j=2,7)
c      close(1)
c      goto 100
c 16   open(file='loop16out',unit=1)
c      write(1,'(i5,2x,i5)') m,j4
c      close(1)
c      goto 100
c 17   open(file='loop17out',unit=1)
c      write(1,'(3(1PD21.14,2x))') (VE3(i), i=iter(17),2,-1)
c      write(1,'(3(1PD21.14,2x))') (VXND(i), i=iter(17),2,-1)
c      write(1,'(3(1PD21.14,2x))') (VXNE(i), i=iter(17),2,-1)
c      close(1)
c      goto 100
c 18   open(file='loop18out',unit=1)
c      do 181 i=1,101
c 181     write(1,'(3(1PD21.14,2x))') (ZA(i,j), j=1,7)
c      do 182 i=1,101
c 182     write(1,'(3(1PD21.14,2x))') (ZB(i,j), j=1,7)
c      do 183 i=2,iter(18)
c 183     write(1,'(3(1PD21.14,2x))') (ZU(i,j), j=2,6)
c      do 184 i=2,iter(18)
c 184     write(1,'(3(1PD21.14,2x))') (ZV(i,j), j=2,6)
c      do 185 i=2,iter(18)
c 185     write(1,'(3(1PD21.14,2x))') (ZR(i,j), j=2,6)
c      do 186 i=2,iter(18)
c 186     write(1,'(3(1PD21.14,2x))') (ZZ(i,j), j=2,6)
c      close(1)
c      goto 100
c 19   open(file='loop19out',unit=1)
c      write(1,'(3(1PD21.14,2x))') (B5(i), i=1,iter(19))
c      close(1)
c      goto 100
c 20   open(file='loop20out',unit=1)
c      write(1,'(3(1PD21.14,2x))') (X(i), i=1,iter(20))
c      write(1,'(3(1PD21.14,2x))') (XX(i), i=2,iter(20)+1)
c      close(1)
c      goto 100
c 21   open(file='loop21out',unit=1)
c      do 211 i=1,15
c 211     write(1,'(3(1PD21.14,2x))') (PX(i,j), j=1,iter(21))
c      close(1)
c      goto 100
c 22   open(file='loop22out',unit=1)
c      write(1,'(3(1PD21.14,2x))') (W(i), i=1,iter(22))
c      write(1,'(3(1PD21.14,2x))') (Y(i), i=1,iter(22))
c      close(1)
c      goto 100
c 23   open(file='loop23out',unit=1)
c      do 231 i = 1,101
c 231  write(1,'(3(1PD21.14,2x))') (ZA(i,j), j=1,7)
c      close(1)
c      goto 100
c 24   open(file='loop24out',unit=1)
c      write(1,'(i4)') max24
c      close(1)
c      goto 100
c 100  return
c      end
