      SUBROUTINE ESPI(DBPWL,FREQ,CB,FKB,ATEN)
C
C     THIS SUBROUTINE USES NEWTON'S METHOD TO CONVERT DB PER WAVE 
C     LENGTH (DBPWL) TO AN IMAGINARY PART OF THE SQUARE OF THE INDEX
C     OF REFRACTION. THE ATTENUATION ONLY EFFECT THE IMAGINARY PART
C     OF THE SQUARE OF THE INDEX OF REFRACTION, WHICH IS USEFUL IN
C     THE PERTURBATION-CONTINUATION PROCEDURE USE IN SUBROUTINE 
C     SEARCH TO FIND THE EIGENVALUES. THE RESULT (ESP) IS RETURNED
C     IN ATEN. THIS IS USED ONLY IN THE SEARCH METHOD. 
C
C     IN CONTRAST, THE GALERKIN METHOD USES THE ATENUATION PROFILE 
C     IN SUBROUTINE CFACIN TO DEFINE A COMPLEX WAVE NUMBER THAT IS
C     THEN SQUARED AND DIVIDED BY THE REAL REFERENCE WAVE NUMBER 
C     SQUARED SO THAT THE ATTENUATION EFFECTS BOTH THE REAL AND
C     IMAGINARY PART OF THE COMPLEX INDEX OF REFRACTION  SQUARED.
C
C     GENERATE CONSTANTS
C
      IMPLICIT REAL*8 (A-H,O-Z)
      PI=2.*ACOS(0.0)
      E=EXP(1.0)
      FAC=20.*DLOG10(E)      
C
C     FIND WAVE LENGTH
C
      WL=CB/FREQ
      DBPM=DBPWL/WL
      FK=DBPM/FAC
C
C     THE FOLLOWING IS A GOOD APPROXIMATE FOR ATEN WITH 
C     REASONABLE ATTENUATIONS. IT ALSO MAKES THE SEARCH METHOD  
C     AGREE APPROXIMATELY WITH THE GALERKIN METHOD IN REGARDS 
C     TO THE TREATMENT OF ATTENUATION.
C
      ESP=2.*FK/FKB
      I=0
C
C     START THE ITERATIONS OF NEWTON'S METHOD
C
  100 CONTINUE
C
      IF(I .GT. 20) GO TO 500
      I=I+1
      X=(1.0+ESP**2)**.25
      Y=SIN(ATAN(ESP)/2.)
      Z=COS(ATAN(ESP)/2.)
      W=X**3
C
      F=FKB*X*Y-FK
      FP=FKB*(ESP*Y+Z)/W           
      ESP=ESP-F/FP
C
      GO TO 100
C
  500 CONTINUE
      ATEN=ESP
C
      RETURN
      END
