      SUBROUTINE SETUP
      include 'param.inc'
      INCLUDE 'COMMON.inc'
      DENOM = V * V + VI * VI
      XI = OMEGA * V / DENOM
      XII = -OMEGA * VI/ DENOM
      
      DO 10 I = 0, LX - 1
      IF (I .EQ. 0) GO TO 35
      IF (ZR .GT. -7.4) GO TO 25
      IF (G(I) .LT. 0.) GO TO 25
      ZE = G(I) * (Z(I+1) - Z(I)) + ZE
      IF (ZE .LT. SLIM) ZE = SLIM
      GO TO 26
 25   CONTINUE
      ZE = G(I) * (Z(I+1) - Z(I)) + ZR
      IF (ZE .LT. SLIM) ZE = SLIM
 26   CONTINUE
      ZQ = GI(I) * (Z(I+1) - Z(I)) + ZI
 30   ZB(I) = ZE
      ZBI(I) = ZQ
      CALL HANKEL(ZE,ZQ,0)
      ZB(I) = ZE
      ZBI(I) = ZQ
      A(2*I,1) = H2R * RHO(I)
      Q(2*I,1) = H2I * RHO(I)
      A(2*I,2) = H1R * RHO(I)
      Q(2*I,2) = H1I * RHO(I)
      A(2*I+1,1) = H2PR * G(I) - H2PI * GI(I)
      Q(2*I+1,1) = H2PI * G(I) + H2PR * GI(I)
      A(2*I+1,2) = H1PR * G(I) - H1PI * GI(I)
      Q(2*I+1,2) = H1PI * G(I) + H1PR * GI(I)
 35   CONTINUE
      GSABS = G SQ(I+1)**2 + G SQI(I+1)**2
      X1 = CAY(I+1) - XI
      X2 = CAY(I+1) + XI
      X3 =CAYI(I+1) - XII
      X4 =CAYI(I+1) + XII
      X = X1 * X2 - X3 * X4
      Y = X1 * X4 + X3 * X2
      ZT(I+1) = (X * G SQ(I+1) + Y * G SQI(I+1)) / GSABS
      ZTI(I+1) = (Y * G SQ(I+1) - X * G SQI(I+1)) / GSABS
      ZR = ZT(I+1)
      ZI = ZTI(I+1)
                                                                               
      ZE = ZR
      ZQ = ZI
      IF (ZR .GT. SLIM) GO TO 40
      S = CAY(I+1)
      T = CAYI(I+1)
      CON(I+1) =  (G(I+1) * S + GI(I+1) * T) / (S**2 + T**2)
      CON(I+1) = 1. / CON(I+1)**2
      DO 36 J = 1,20
      TEMP = S**2 + T**2
      TEMPI = (XII * S - XI * T) / TEMP
      TEMP = (XI * S + XII * T) / TEMP
      ZR = ((1. + TEMP) * ( 1. - TEMP) + TEMPI**2) * CON(I+1)
      R = ZR / SLIM
      IF (ABS(R-1.) .LT. 1.D-3) GO TO 41
      S = XI + (S - XI) / R
 36   CONTINUE
 41   ZI = -2. * TEMPI * TEMP * CON(I+1)
      ZT(I+1) = ZR
      ZTI(I+1) = ZI
                                                                               
 40   CONTINUE
      CALL HANKEL(ZR,ZI,0)
      ZT(I+1) = ZR
      ZTI(I+1) = ZI
      IF (I .NE. 0) GO TO 45
      A(1,3) = H2R * RHO(1)
      Q(1,3) = H2I * RHO(1)
      A(1,4) = H1R * RHO(1)
      Q(1,4) = H1I * RHO(1)
      GO TO 10
 45   CONTINUE
      A(2*I,3) =-H2R * RHO(I+1)
      Q(2*I,3) =-H2I * RHO(I+1)
      A(2*I,4) =-H1R * RHO(I+1)
      Q(2*I,4) =-H1I * RHO(I+1)
      A(2*I+1,3) =-H2PR * G(I+1) + H2PI * GI(I+1)
      Q(2*I+1,3) =-H2PI * G(I+1) - H2PR * GI(I+1)
      A(2*I+1,4) =-H1PR * G(I+1) + H1PI * GI(I+1)
      Q(2*I+1,4) =-H1PI * G(I+1) - H1PR * GI(I+1)
 10   CONTINUE
      A( 2*LX-2 ,4) = 0.
      Q( 2*LX-2 ,4) = 0.
      A( 2*LX-1 ,4) = 0.
      RETURN
      END
