      SUBROUTINE EIGENFUNCTION (M, DEPTH, RF, HF)
      INCLUDE 'param.inc'
      real*8 depth
      INCLUDE 'COMMON.inc'
      LOC = 1
      DO 350 L = 2, LX
      IF (Z(L) .GE. DEPTH) GO TO 370
  350 CONTINUE
      LOC = LX
      GO TO 380
  370 LOC = L - 1  
  380 CONTINUE
      X1 = CAY (LOC) - EIGEN (M)
      X2 = CAY (LOC) + EIGEN (M)
      X3 = CAYI(LOC) - EIGENI(M)
      X4 = CAYI(LOC) + EIGENI(M)
      TEMP = X1 * X2 - X3 * X4
      TEMPI = X1 * X4 + X3 * X2
      TEMDEN = G SQ(LOC) **2 + G SQI(LOC)**2
      ZE = (TEMP * GSQ(LOC) + TEMPI * G SQI(LOC)) / TEMDEN
      ZEI = (TEMPI * GSQ(LOC) + TEMP * GSQI(LOC)) / TEMDEN
      TEM1 = ZE
      IF (ZE .GT. -7.5) GO TO 438
      S = CAY(LOC)
      T = CAYI(LOC)
      DO 437 K = 1,20
      TEMP = S**2 + T**2
      TEMPI = (EIGENI(M) * S - EIGEN(M) * T) / TEMP
      TEMP = (EIGEN(M) * S + EIGENI(M) * T) / TEMP
      ZE = ((1. + TEMP) * (1. - TEMP) + TEMPI**2) * CON(LOC)
      ZEI = -2. * TEMPI * TEMP * CON(LOC)
      ZR = ZE / (-7.5)
      IF (ABS(ZR-1.) .LT. 1.D-3) GO TO 438
      S = EIGEN(M) + (S - EIGEN(M)) / ZR
 437  CONTINUE
 438  IF (G(LOC) .LT. 0.) GO TO 439
      ZE = G(LOC) * (DEPTH - Z(LOC)) + TEM1
      IF (ZE .GT. -7.5) GO TO 442
      RF = 1.D-12
      HF = 0.
      RETURN
 439  ZE = G(LOC) * (DEPTH - Z(LOC)) + ZE
      IF (ZE .GT. SLIM) GO TO 442
      RF = 1.D-12
      HF = 0.
      RETURN
 442  ZEI =GI(LOC) * (DEPTH - Z(LOC)) + ZEI
 315  FORMAT (' MODE:', I5, ' DEPTH:', F4.0,' ZETAR:',F8.0,
     : ' ZETAI:',F5.3)
      CALL HANKEL(ZE,ZEI,1)
      RF =  (AF(LOC,M) * H1R - AG(LOC,M) * H1I +
     :        BF(LOC,M) * H2R - BG(LOC,M) * H2I) * rho(loc)
      HF =  (AG(LOC,M) * H1R + AF(LOC,M) * H1I +
     :        BG(LOC,M) * H2R + BF(LOC,M) * H2I) * rho(loc)
      RETURN
      END
