      SUBROUTINE BOTDEPS(HW,DEPB,CGRADB,CINTB,NPB,AVGB,LHB,MX)
C
C     THIS SUBROUTINE REDEFINES THE DEPTHS AND INTERCEPTS OF
C     THE INDEX OF REFRACTION SQUARED IN THE BOTTOM. THE DEPTHS
C     MOVE UP AND DOWN AS THE WATER DEPTH HW CHANGES WHILE THE 
C     INTERCEPTS MOVE WITH THEM. THE SUBROUTINE THE FINDS THE 
C     INDEX LHB OF THE LAYER IN THE NEW DEPTH PRROFILE THAT 
C     CONTAINS HB. THE SQUARED INDEX OF REFRACTION CAN BE 
C     INTERPOLATED OR EXTRAPOLATED TO HB BASED ON LHB.
C
      IMPLICIT REAL*8 (A-H,O-Z)
      COMPLEX*16 CGRADB(MX),CINTB(MX) 
      DIMENSION DEPB(MX)
C
      COMMON /BLKEVN/ HB,CW,CB,FKW,FKB,ROHW,ROHB,ATEN
C
C     SET AVERAGE INDEX OF REFRACTION SQUARED IN THE BOTTOM
C     TO ONE
C
      AVGB=1.0D0
C
C     DEPP(1) IS ASSUMED TO BE THE WATER DEPTH BEFORE THE DEPTH
C     CHANGES TO HW. MOVE THE DEPTHS AND INTERCEPTS.
C
      DELH=HW-DEPB(1)
      DO 50 I=1,NPB
      DEPB(I)=DEPB(I)+DELH
      CINTB(I)=CINTB(I)-CGRADB(I)*DCMPLX(DELH,0.0D0)
   50 CONTINUE
C
      IF(HB .LE. DEPB(1)) THEN
      WRITE(*,*) 'NO BOTTOM PROFILE WATER DEPTH= ',HW
      WRITE(*,*) 'AND BOTTOM DEPTH= ',HB
      WRITE(*,*) '*** MAKE HB BIGGER ***'
      WRITE(9,*) 'NO BOTTOM PROFILE WATER DEPTH= ',HW
      WRITE(9,*) 'AND BOTTOM DEPTH= ',HB
      WRITE(9,*) '*** MAKE HB BIGGER ***'
      STOP 'MAKE HB BIGGER'
      END IF 
C
      LHB=0
      NPBM1=NPB-1
      DO 100 I=1,NPBM1
      IF(DEPB(I+1) .GE. HB) GO TO 200
  100 CONTINUE
C
C     HB IS .GT. DEPB(NP)
C
      LHB=NPB
      GO TO 250
C
  200 CONTINUE
      LHB=I
  250 CONTINUE
C
      RETURN
      END
