C
C *** NORMAL MODE SOLUTION ***
C
      SUBROUTINE NORM(DOM,MOM,NOM,ML,NL,DNS,VP,VS,THK
     *               ,LS,SDEP,LO,ODEP,MOB,NOB,ROB,RAD
     *               ,TP,TS,QX,QY,QZ,AMP,IQF,QFL
     *               ,MMD,NSR,COMR,CR,NMDR,NSL,COML,CL,NMDL
     *               ,UR,QXR,QZR,VXR,WXR,WZR,UL,QXL,VXL,QN,VN,WN)
C
      IMPLICIT REAL*8(A-H,O-Z)
      COMPLEX*16 QN(MOM,MOB),VN(MOM,MOB),WN(MOM,MOB)
     *          ,CPX,CC,H0,H1,HR,HD
     *          ,QXT,QZT,VXT,WXT,WZT
      DIMENSION DNS(ML),VP(ML),VS(ML),THK(ML),ROB(MOB)
     *         ,COMR(0:MMD),COML(0:MMD),NMDR(MOM),NMDL(MOM)
     *         ,CR(MOM,0:MMD),CL(MOM,0:MMD)
     *         ,UR(0:MMD),UL(0:MMD)
     *         ,QXR(0:MMD),QZR(0:MMD),VXR(0:MMD)
     *         ,WXR(0:MMD),WZR(0:MMD),QXL(0:MMD),VXL(0:MMD)
      COMMON/OUT/NOUT
C
      CPX=(0.D0,1.D0)
      BB=TP*TP*0.0253302D0
      CRD=DCOS(RAD)
      SRD=DSIN(RAD)
      IF(IQF.NE.0)QFL=9999.D0
C
      DO 200 IOM=1,NOM
C
        OM=DOM*DFLOAT(IOM)
        OM2=OM*OM
        CC=AMP*OM2*DEXP(-OM2*BB)*CDEXP(DCMPLX(0.D0,-OM*TS))
C
        IF((LO.LT.LS).OR.((LO.EQ.LS).AND.(ODEP.LE.SDEP)))THEN
          CALL RYUA(MOM,OM,IOM,ML,NL,DNS,VP,VS,THK,CR,NMDR,COMR,NSR
     *             ,LS,SDEP,LO,ODEP,1,MMD,UR,QXR,QZR,VXR,WXR,WZR)
          IF(NL.NE.1)CALL LVUA(MOM,OM,IOM,ML,NL,DNS,VS,THK,CL,NMDL
     *                    ,COML,NSL,LS,SDEP,LO,ODEP,MMD,UL,QXL,VXL)
        ELSE
          CALL RYUA(MOM,OM,IOM,ML,NL,DNS,VP,VS,THK,CR,NMDR,COMR,NSR
     *             ,LO,ODEP,LS,SDEP,2,MMD,UR,QXR,QZR,VXR,WXR,WZR)
          IF(NL.NE.1)CALL LVUA(MOM,OM,IOM,ML,NL,DNS,VS,THK,CL,NMDL
     *                    ,COML,NSL,LO,ODEP,LS,SDEP,MMD,UL,QXL,VXL)
        END IF
C
      IF(NOUT.EQ.1)THEN
        WRITE(*,1000)IOM,OM
        WRITE(*,*)'UR(IOM,MODE):(MODE FROM 0 TO NMDR)'
        WRITE(*,1100)(UR(MD),MD=0,NMDR(IOM))
        WRITE(*,*)
        WRITE(*,*)'UL(IOM,MODE):(MODE FROM 0 TO NMDL)'
        WRITE(*,1200)(UL(MD),MD=0,NMDL(IOM))
      END IF
 1000 FORMAT(' IOM, OM   =',I5,F8.4)
 1100 FORMAT(' UR(IOM,*) =',5F7.1)
 1200 FORMAT(' UL(IOM,*) =',5F7.1)
C
        DO 210 IOB=1,NOB
C
          RR=ROB(IOB)
C
          QXT=(0.D0,0.D0)
          VXT=(0.D0,0.D0)
          WXT=(0.D0,0.D0)
          QZT=(0.D0,0.D0)
          WZT=(0.D0,0.D0)
C
          DO 220 MD=NSR,NMDR(IOM)
C
            IF(CR(IOM,MD).EQ.0.D0)THEN
              EQR=0.D0
              H0=(0.D0,0.D0)
              H1=(0.D0,0.D0)
              HR=(0.D0,0.D0)
              HD=(0.D0,0.D0)
            ELSE
              EQR=DEXP(-OM*RR/(2.D0*QFL*UR(MD)))
              WVN=OM/CR(IOM,MD)
              CALL HANK(WVN*RR,H0,H1,HR,HD)
            END IF
C
            IF(IQF.NE.0)EQR=1.D0
C
            QXT=QXT+QXR(MD)*HD*EQR
            VXT=VXT+VXR(MD)*HR*EQR
            WXT=WXT+WXR(MD)*H1*EQR
            QZT=QZT+QZR(MD)*H1*EQR
            WZT=WZT+WZR(MD)*H0*EQR
C
  220     CONTINUE
C
          IF(NL.NE.1)THEN
C
            DO 230 MD=NSL,NMDL(IOM)
C
              IF(CL(IOM,MD).EQ.0.D0)THEN
                EQR=0.D0
                H0=(0.D0,0.D0)
                H1=(0.D0,0.D0)
                HR=(0.D0,0.D0)
                HD=(0.D0,0.D0)
              ELSE
                EQR=DEXP(-OM*RR/(2.D0*QFL*UL(MD)))
                WVN=OM/CL(IOM,MD)
                CALL HANK(WVN*RR,H0,H1,HR,HD)
              END IF
C
              IF(IQF.NE.0)EQR=1.D0
C
              QXT=QXT+QXL(MD)*HR*EQR
              VXT=VXT+VXL(MD)*HD*EQR
C
  230       CONTINUE
C
          END IF
C
          QN(IOM,IOB)=CPX*CC*(QXT*(CRD*QX+SRD*QY)+QZT*QZ)
          VN(IOM,IOB)=CPX*CC* VXT*(SRD*QX-CRD*QY)
          WN(IOM,IOB)=CPX*CC*(WXT*(CRD*QX+SRD*QY)+WZT*QZ)
C
  210   CONTINUE
C
  200 CONTINUE
C
      RETURN
      END
