C
C *** NORMAL MODE SOLUTION OF RAYLEIGH WAVE ***
C
      SUBROUTINE RYUA(MOM,OM,IOM,ML,NL,DNS,VP,VS,THK,CC,NMODE
     *               ,CFOM,NSMD,L1,DEP1,L2,DEP2,ISO,MMD
     *               ,UU,QXR,QZR,VXR,WXR,WZR)
C
      IMPLICIT REAL*8(A-H,O-Z)
      DIMENSION VP(ML),VS(ML),THK(ML),DNS(ML)
     *         ,CC(MOM,0:MMD),NMODE(MOM),UU(0:MMD),CFOM(0:MOM)
     *         ,QXR(0:MMD),QZR(0:MMD),VXR(0:MMD)
     *         ,WXR(0:MMD),WZR(0:MMD)
      COMPLEX*16 RAN,RBN,B11,B22,B13,B24,RL,RK,RN,CPX
     *          ,AR1(4,4),AS2(4,4),RS2,GS2,HS2,SS2
     *          ,FWZ0,FWX0,WRX0,WRZ0,C1,C2
C
      IF(OM.LT.CFOM(NSMD))GOTO 9999
      CPX=(0.D0,1.D0)
      OM2=OM*OM
C
      DO 100 MODE=0,NMODE(IOM)
C
        CV=CC(IOM,MODE)
        WN=OM/CV
C
        CALL FRFK(ML,NL,DNS,VP,VS,THK,CV,WN,FRK,FRW,RN,RL,RK
     *           ,RAN,RBN,B11,B12,B13,B14,B21,B22,B23,B24)
C
        UU(MODE) =-FRK/FRW
C
        IF(L1.EQ.NL)THEN
C
          EPD=DEXP(WN*IMAG(RAN)*DEP1)
          ESD=DEXP(WN*IMAG(RBN)*DEP1)
          RS2= B14*EPD
          GS2=-RAN*RS2
          HS2= B14*ESD
          SS2= RBN*HS2
C
        ELSE
C
          CALL FRA2(AS2,L1,DEP1,CV,WN,DNS,VP,VS,THK,ML,NL)
C
          GS2=B11*AS2(1,3)+B12*AS2(2,3)+B13*AS2(3,3)+B14*AS2(4,3)
          RS2=B11*AS2(1,4)+B12*AS2(2,4)+B13*AS2(3,4)+B14*AS2(4,4)
          HS2=B21*AS2(1,3)+B22*AS2(2,3)+B23*AS2(3,3)+B24*AS2(4,3)
          SS2=B21*AS2(1,4)+B22*AS2(2,4)+B23*AS2(3,4)+B24*AS2(4,4)
C
        END IF
C
        FWZ0=GS2*RN-HS2*RL
        FWX0=RS2*RN-SS2*RL
C
        WRX0=-CPX*FWX0/(2.D0*FRK)
        WRZ0=     FWZ0/(2.D0*FRK)
C
        CALL FRA1(AR1,L2,DEP2,CV,WN,DNS,VP,VS,THK,ML)
C
        C1=AR1(1,2)-RK*AR1(1,1)/RL
        URX=DREAL(C1*WRX0)
        URZ=DREAL(C1*WRZ0)
        C2=AR1(2,2)-RK*AR1(2,1)/RL
        WRX=DIMAG(C2*WRX0)
        WRZ=DIMAG(C2*WRZ0)
C
        IF(ISO.EQ.1)THEN
          QXR(MODE)=-URX
          VXR(MODE)= URX
          WXR(MODE)=-WRX
          QZR(MODE)= URZ
          WZR(MODE)=-WRZ
        ELSE
          QXR(MODE)=-URX
          VXR(MODE)= URX
          WXR(MODE)=-URZ
          QZR(MODE)= WRX
          WZR(MODE)=-WRZ
        END IF
C
  100 CONTINUE
C                     
 9999 RETURN
      END
