C
C *** EIGEN VALUE EQUATION OF LOVE WAVE
C
      REAL FUNCTION FNFL*8 (CC,ML,NL,DNS,VS,DEP)
C
C INPUT DATA
C OM     : CIRCULAR FREQUENCY (OMEGA) FROM COMMON
C CC     : PHASE VELOCITY OF LOVE WAVE
C ML     : NL IN MAIN 
C NL     : TOTAL NUMBER OF LAYERS           
C DNS(I) : DENSITY OF Ith LAYER 
C VS (I) : VS OF Ith LAYER      
C DEP(I) : DEPTH (THICKNESS) OF Ith LAYER  
C OUTPUT DATA
C FNFL   : EIGEN VALUE EQUATION OF LOVE WAVE
C
      IMPLICIT REAL*8(A-H,O-Z)
      DIMENSION DNS(ML),VS(ML),DEP(ML)
      COMMON / OMEGA /OM
      COMPLEX*16 R11,R12,R21,R22,SA11,SA12,SA21,SA22
     *          ,SB11,SB12,SB21,SB22
C
      WN=OM/CC
C
      R11=(1.0D0,0.0D0)
      R12=(0.0D0,0.0D0)
      R21=(0.0D0,0.0D0)
      R22=(1.0D0,0.0D0)
C
      DO 100 IL=NL-1,1,-1
C
        SA11=R11
        SA12=R12
        SA21=R21
        SA22=R22
C
        BM=VS(IL)
        CB2=CC*CC/(BM*BM)
        IF(BM-CC)10,20,30
C
   10     RBM=DSQRT(CB2-1.0D0)
          QM=WN*RBM*DEP(IL)
          CQ=DCOS(QM)
          SQ=DSIN(QM)
          STQ=RBM*SQ
          SDQ=SQ/RBM
          GOTO 40
C
   20     CQ=1.0D0
          STQ=0.0D0
          SDQ=WN*DEP(IL)
          GOTO 40
C
   30     RBM=DSQRT(1.0D0-CB2)
          QM=WN*RBM*DEP(IL)
          EX1=DEXP(QM)
          EX2=DEXP(-QM)
          CQ=(EX1+EX2)/2.0D0
          EX12=(EX1-EX2)/2.0D0
          STQ=-RBM*EX12
          SDQ=EX12/RBM
C
   40   SM=DNS(IL)*VS(IL)*VS(IL)
        SB11=DCMPLX(CQ,0.0D0)
        SB12=DCMPLX(0.0D0,SDQ/SM)
        SB21=DCMPLX(0.0D0,STQ*SM)
        SB22=DCMPLX(CQ,0.0D0)
C
        R11=SA11*SB11+SA12*SB21
        R12=SA11*SB12+SA12*SB22
        R21=SA21*SB11+SA22*SB21
        R22=SA21*SB12+SA22*SB22
C
  100 CONTINUE
C
      RBN=-DSQRT(1.0D0-CC*CC/(VS(NL)*VS(NL)))
      SM=DNS(NL)*VS(NL)*VS(NL)
      FNFL=IMAG(R21)+SM*RBN*REAL(R11)
C
      RETURN
      END
