!        Generated by TAPENADE     (INRIA, Tropics team)
!  Tapenade 3.6 (r4165) - 21 sep 2011 20:54
!
!  Differentiation of da_couple_uv in reverse (adjoint) mode:
!   gradient     of useful results: u v mu
!   with respect to varying inputs: u v mu
!   RW status of diff variables: u:in-out v:in-out mu:incr
SUBROUTINE DA_COUPLE_UV_B(u, ub, v, vb, mu, mub0, mub, msfu, msfv, ids, &
&  ide, jds, jde, kds, kde)
  IMPLICIT NONE
! if (trace_use) call da_trace_exit("da_couple_uv")  
  INTEGER, INTENT(IN) :: ids, ide, jds, jde, kds, kde
  REAL, INTENT(INOUT) :: u(ids:ide+1, jds:jde, kds:kde)
  REAL, INTENT(INOUT) :: ub(ids:ide+1, jds:jde, kds:kde)
  REAL, INTENT(INOUT) :: v(ids:ide, jds:jde+1, kds:kde)
  REAL, INTENT(INOUT) :: vb(ids:ide, jds:jde+1, kds:kde)
  REAL, INTENT(IN) :: msfu(ids:ide+1, jds:jde)
  REAL, INTENT(IN) :: msfv(ids:ide, jds:jde+1)
  REAL, INTENT(IN) :: mu(ids:ide, jds:jde)
  REAL :: mub0(ids:ide, jds:jde)
  REAL, INTENT(IN) :: mub(ids:ide, jds:jde)
  REAL, ALLOCATABLE :: muu(:, :), muv(:, :)
  REAL, ALLOCATABLE :: muub(:, :), muvb(:, :)
  INTEGER :: arg1
  ALLOCATE(muub(ids:ide+1, jds:jde))
! update_bc
! if (trace_use) call da_trace_entry("da_couple_uv")  
  ALLOCATE(muu(ids:ide+1, jds:jde))
  ALLOCATE(muvb(ids:ide, jds:jde+1))
  ALLOCATE(muv(ids:ide, jds:jde+1))
! couple variables u, v
  CALL DA_CALC_MU_UV(mu, mub, muu, muv, ids, ide, jds, jde)
  arg1 = jde + 1
  CALL DA_COUPLE_B(muv, muvb, v, vb, msfv, ids, ide, jds, arg1, kds, kde&
&            )
  arg1 = ide + 1
  CALL DA_COUPLE_B(muu, muub, u, ub, msfu, ids, arg1, jds, jde, kds, kde&
&            )
  CALL DA_CALC_MU_UV_B(mu, mub0, mub, muu, muub, muv, muvb, ids, ide, &
&                 jds, jde)
  muub = 0.0
  muvb = 0.0
  DEALLOCATE(muv)
  DEALLOCATE(muvb)
  DEALLOCATE(muu)
  DEALLOCATE(muub)
END SUBROUTINE DA_COUPLE_UV_B
