      COMPLEX*16 FUNCTION CEXIW(Z1,Z2,DEPW,RHOW,GRHOW,
     1                          ALPHA1,ALPHA2)
C
C     THIS FUNCTION EVALUATES THE INTEGRAL OF THE PRODUCT OF
C     TWO BASIC DEPTH FUNCTIONS OVER THE INTERVAL Z1 TO Z2 IN THE
C     WATER, WEIGHTED BY AN EXPONENTIAL DENSITY PROFILE.
C
      IMPLICIT REAL*8 (A-H,O-Z)
C
      COMPLEX*16 ALPHA1,ALPHA2
      COMPLEX*16 CFAC,CGRHOW,CI
      COMPLEX*16 U,V,W,X
      COMMON /BLKEVN/ HB,CW,CB,FKW,FKB,ROHW,ROHB,ATEN
C
      CI=DCMPLX(0.0D0,1.0D0)
      CGRHOW=DCMPLX(GRHOW,0.0D0)
C
      CFAC=-FKB**4/(4.0D0*RHOW*ALPHA1*ALPHA2)
C
      CEXIW=DCMPLX(0.0D0,0.0D0)
C
      W=CI*(ALPHA1+ALPHA2)-CGRHOW
      IF(CDABS(W) .GT. 1.0D-12) THEN
      U=CDEXP(CI*(ALPHA1+ALPHA2)*Z2-CGRHOW*(Z2-DEPW))
      V=CDEXP(CI*(ALPHA1+ALPHA2)*Z1-CGRHOW*(Z1-DEPW))
      CEXIW=CEXIW+(U-V)/W
      ELSE 
      X=CDEXP(CGRHOW*DEPW)
      CEXIW=CEXIW+X*(Z2-Z1)
      END IF
C
      W=CI*(ALPHA1-ALPHA2)-CGRHOW
      IF(CDABS(W) .GT. 1.0D-12) THEN
      U=CDEXP(CI*(ALPHA1-ALPHA2)*Z2-CGRHOW*(Z2-DEPW))
      V=CDEXP(CI*(ALPHA1-ALPHA2)*Z1-CGRHOW*(Z1-DEPW))
      CEXIW=CEXIW-(U-V)/W
      ELSE 
      X=CDEXP(CGRHOW*DEPW)
      CEXIW=CEXIW-X*(Z2-Z1)
      END IF
C
      W=CI*(ALPHA2-ALPHA1)-CGRHOW
      IF(CDABS(W) .GT. 1.0D-12) THEN
      U=CDEXP(CI*(ALPHA2-ALPHA1)*Z2-CGRHOW*(Z2-DEPW))
      V=CDEXP(CI*(ALPHA2-ALPHA1)*Z1-CGRHOW*(Z1-DEPW))
      CEXIW=CEXIW-(U-V)/W
      ELSE 
      X=CDEXP(CGRHOW*DEPW)
      CEXIW=CEXIW-X*(Z2-Z1)
      END IF
C
      W=-CI*(ALPHA1+ALPHA2)-CGRHOW
      IF(CDABS(W) .GT. 1.0D-12) THEN
      U=CDEXP(-CI*(ALPHA1+ALPHA2)*Z2-CGRHOW*(Z2-DEPW))
      V=CDEXP(-CI*(ALPHA1+ALPHA2)*Z1-CGRHOW*(Z1-DEPW))
      CEXIW=CEXIW+(U-V)/W
      ELSE 
      X=CDEXP(CGRHOW*DEPW)
      CEXIW=CEXIW+X*(Z2-Z1)
      END IF
C
      CEXIW=CFAC*CEXIW
      RETURN
      END
