      COMPLEX*16 FUNCTION CEXIWB(H1,H2,Z1,Z2,DEPB,RHOB,GRHOB,
     1                          ALPHA1,ALPHA2,BETA1,BETA2)
C
C     THIS FUNCTION EVALUATES THE CROSS COUPLING INTEGRAL OF 
C     TWO BASIC DEPTH FUNCTIONS OVER THE INTERVAL Z1 TO Z2 
C     WITH WATER ON ONE SIDE AND THE BOTTOM ON THE SECOND. 
C     THE INTEGRAL IS WEIGHTED BY AN EXPONENTIAL DENSITY PROFILE.
C
      IMPLICIT REAL*8 (A-H,O-Z)
C
      COMPLEX*16 ALPHA1,ALPHA2,BETA1,BETA2
      COMPLEX*16 B2,CFAC,CGRHOB,CI
      COMPLEX*16 U,V,W,X
      COMMON /BLKEVN/ HB,CW,CB,FKW,FKB,ROHW,ROHB,ATEN
C
      CI=DCMPLX(0.0D0,1.0D0)
      CGRHOB=DCMPLX(GRHOB,0.0D0)
      THBMH2=2.0D0*HB-H2
C
      CEXIWB=CMPLX(0.0D0,0.0D0)
      IF(Z2 .LE. Z1) GO TO 200
C
      CFAC=FKB**4*CDSIN(ALPHA2*H2)/(2.0D0*CI*RHOB*ALPHA1*ALPHA2)
C
      B2=2.0D0*BETA2*(HB-H2)
      IF(DIMAG(B2) .LT. 88.0D0) THEN
      CFAC=CFAC/(1.0D0-CDEXP(CI*B2))
      END IF
C
      W=CI*(ALPHA1+BETA2)-CGRHOB
      IF(CDABS(W) .GT. 1.0D-12) THEN
      U=CDEXP(CI*(ALPHA1*Z2+BETA2*(Z2-H2))-CGRHOB*(Z2-DEPB))
      V=CDEXP(CI*(ALPHA1*Z1+BETA2*(Z1-H2))-CGRHOB*(Z1-DEPB))
      CEXIWB=CEXIWB+(U-V)/W
      ELSE 
      X=CDEXP(CI*(ALPHA1*DEPB+BETA2*(DEPB-H2)))
      CEXIWB=CEXIWB+X*(Z2-Z1)
      END IF
C
      W=CI*(ALPHA1-BETA2)-CGRHOB
      IF(CDABS(W) .GT. 1.0D-12) THEN
      U=CDEXP(CI*(ALPHA1*Z2+BETA2*(THBMH2-Z2))-CGRHOB*(Z2-DEPB))
      V=CDEXP(CI*(ALPHA1*Z1+BETA2*(THBMH2-Z1))-CGRHOB*(Z1-DEPB))
      CEXIWB=CEXIWB-(U-V)/W
      ELSE 
      X=CDEXP(CI*(ALPHA1*DEPB+BETA2*(THBMH2-DEPB)))
      CEXIWB=CEXIWB-X*(Z2-Z1)
      END IF
C
      W=CI*(BETA2-ALPHA1)-CGRHOB
      IF(CDABS(W) .GT. 1.0D-12) THEN
      U=CDEXP(CI*(BETA2*(Z2-H2)-ALPHA1*Z2)-CGRHOB*(Z2-DEPB))
      V=CDEXP(CI*(BETA2*(Z1-H2)-ALPHA1*Z1)-CGRHOB*(Z1-DEPB))
      CEXIWB=CEXIWB-(U-V)/W
      ELSE 
      X=CDEXP(CI*(BETA2*(DEPB-H2)-ALPHA1*DEPB))
      CEXIWB=CEXIWB-X*(Z2-Z1)
      END IF
C
      W=-CI*(ALPHA1+BETA2)-CGRHOB
      IF(CDABS(W) .GT. 1.0D-12) THEN
      U=CDEXP(CI*(BETA2*(THBMH2-Z2)-ALPHA1*Z2)-CGRHOB*(Z2-DEPB))
      V=CDEXP(CI*(BETA2*(THBMH2-Z1)-ALPHA1*Z1)-CGRHOB*(Z1-DEPB))
      CEXIWB=CEXIWB+(U-V)/W
      ELSE 
      X=CDEXP(CI*(BETA2*(THBMH2-DEPB)-ALPHA1*DEPB))
      CEXIWB=CEXIWB+X*(Z2-Z1)
      END IF
C
      CEXIWB=CFAC*CEXIWB
C
  200 CONTINUE
C
      RETURN
      END
