      COMPLEX*16 FUNCTION ZCEXIW(Z1,Z2,DEPW,RHOW,GRHOW,
     1                          ALPHA1,ALPHA2)
C
C     THIS FUNCTION EVALUATES THE INTEGRAL OF THE PRODUCT OF DEPTH
C     (Z) AND TWO BASIC DEPTH FUNCTIONS OVER THE INTERVAL Z1 TO
C     Z2 IN THE 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
      ZCEXIW=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))
      ZCEXIW=ZCEXIW+(((U*Z2-V*Z1)/W)-((U-V)/W**2))
      ELSE 
      X=CDEXP(CGRHOW*DEPW)
      ZCEXIW=ZCEXIW+(X*(Z2**2-Z1**2)/2.0D0)
      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))
      ZCEXIW=ZCEXIW-(((U*Z2-V*Z1)/W)-((U-V)/W**2))
      ELSE 
      X=CDEXP(CGRHOW*DEPW)
      ZCEXIW=ZCEXIW-(X*(Z2**2-Z1**2)/2.0D0)
      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))
      ZCEXIW=ZCEXIW-(((U*Z2-V*Z1)/W)-((U-V)/W**2))
      ELSE 
      X=CDEXP(CGRHOW*DEPW)
      ZCEXIW=ZCEXIW-(X*(Z2**2-Z1**2)/2.0D0)
      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))
      ZCEXIW=ZCEXIW+(((U*Z2-V*Z1)/W)-((U-V)/W**2))
      ELSE 
      X=CDEXP(CGRHOW*DEPW)
      ZCEXIW=ZCEXIW+(X*(Z2**2-Z1**2)/2.0D0)
      END IF
C
      ZCEXIW=CFAC*ZCEXIW
      RETURN
      END
