  SUBROUTINE dyn2dy_tls_coef(v,u,xeu,vstar,ustar)

   !&E---------------------------------------------------------------------
   !&E                 ***  ROUTINE dyn2dy_tls_coef  ***
   !&E
   !&E ** Purpose : Estimate of the coefficients of the tridiagonal
   !&E              linear system and the RHS relative to the
   !&E              momentum and continuity equations
   !&E
   !&E ** Description : estimate along y-direction
   !&E
   !&E ** Called by : dyn2dyx.F90
   !&E
   !&E ** External calls :
   !&E
   !&E ** Used ij-arrays : xeu,u,v,ustar,vstar,igdv,hy,htx,hty,dy,dx_f,dx_v,
   !&E                     dy_v,dy_u,fv,hey,hex,surf,phieau,
   !&E                     tfivsr,vis2d,tosy,pa,potgene,buoy2d
   !&E
   !&E ** Modified variables : y2dxe,y2dv,axe,bxe,cxe,cv,bv,av
   !&E
   !&E ** Reference :
   !&E                T. Duhaut, M. Honnorat, L. Debreu, 2008 : Rapport
   !&E                contrat PREVIMER - Ref : 06/2 210 290 (pages 100-125)
   !&E
   !&E ** History :
   !&E        !  2007-09 (V. Garnier) homogeneneity of dx dy...
   !&E        !  2008-07  (L. Debreu, T. Duhaut, M. Honnorat) time scheme
   !&E        !  2008-07  (T. Odaka) MPI
   !&E        !  2009-01  (A. Mano) MPI2D
   !&E        !  2009-01  (V. Garnier) OMP
   !&E        !  2009-07  (N. Bruneau F. Dumas) coupling with swan
   !&E        !  2011-11  (V. Garnier) Spatial extension of ssh(liminm2:limaxp2,ljminm2:ljmaxp2)
   !&E        !  2014-07  (F. Ganthy) Obstruction-induced force on momentum
   !&E
   !&E---------------------------------------------------------------------

#include "toolcpp.h"

   !! * Modules used
   USE parameters
   USE comvars2d,  ONLY : botstressmax,tfivsr,ig,id,jb,jh,          &
                          htx,hty,hy,hey,hex,dx_u,dx_v,dx_f,surf,   &
                          dy,dy_v,dy_u,fv,vis2d,halfdt,frot_lin,    &
                          dt,icon,h0,hminfrot,hmaxfrot,z0b,fwet,fwetp
   USE comvarp2d,  ONLY : u_vtmp
   USE comfluxdo,  ONLY : nbfl,buoy2d,phieau
   USE comaree,    ONLY : l_genpot,potgene
   USE cometdyn,   ONLY : tosy,pa
   USE comvars3d,  ONLY : rhoref
   USE comcolig2d, ONLY : y2dxe,y2dv,axe,bxe,cxe,cv,bv,av,igdv,me,mo,why
#ifdef key_bottom_stress_wave
   USE waveforcing,ONLY : CfH,Orb_v
#endif
#ifdef key_waveforcing
   USE waveforcing,ONLY : Qx,Qy,Jsmith,Dsmith,Qy_u,k_x,k_y,hlim_calc, &
                          l_wave_brgm_phillips,l_wave_brgm_smith,     &
                          Qx_u,Qx_v,Qy_u,Qy_v,temp_radu,temp_radv
   USE_MPI toolmpi,ONLY : ex_i_rsh,ex_j_rsh
#endif
#ifdef key_obstructions
   USE obstructions,      ONLY : obst_fv_e,obst_fv_i
#endif

   IMPLICIT NONE

   !! * Arguments
   REAL(KIND=rsh), DIMENSION(liminm2:limaxp2,ljminm2:ljmaxp2),INTENT(in) :: xeu
   REAL(KIND=rsh), DIMENSION(liminm2:limaxp2,ljminm2:ljmaxp2),INTENT(in) :: u,v,ustar,vstar

   !! * Local declarations
   INTEGER                                       :: i,j,k,j1,j2
   REAL(KIND=rlg)                                :: phieautot              !dyn2dy_cty.h
   REAL(KIND=rsh)  :: ft,gdt,vit,factft,udvsdx,udvdx,udvdx2,   &           !dyn2dy_mtm.h
                      vdvsdy,vdvdy,vdvdy2,dvsdx,dvsdx2,u_vtmp2
#if defined key_dyn_adv_quick || defined key_dyn_adv_quickest
   REAL(KIND=rsh)  :: vc,vp,vm,up,um                                       !dyn2dy_mtm.h
#endif

   !!----------------------------------------------------------------------
   !! * Executable part

   PRINT_DBG*, 'enter DYN2DY_TLS_COEF routine'

#ifdef key_MPI_2D
!$OMP DO SCHEDULE(RUNTIME)
#else
!$OMP DO SCHEDULE(DYNAMIC,5)
#endif
   DO j=ljmin,ljmax
     DO i =liminp1,limax
       IF (j >= jb(i)-1 .and. j <= jh(i)-1) THEN
         u_vtmp(i,j)=0.25_rsh*(u(i,j)+u(i,j+1)+u(i-1,j)+u(i-1,j+1))
       END IF
     END DO
   END DO
!$OMP END DO

#ifdef key_waveforcing
   CALL_MPI ex_i_rsh(-1,1,1,liminm1,limaxp1,ljminm1,ljmaxp1,u_vtmp(liminm1:limaxp1,ljminm1:ljmaxp1))
   CALL_MPI ex_j_rsh(-1,1,1,liminm1,limaxp1,ljminm1,ljmaxp1,u_vtmp(liminm1:limaxp1,ljminm1:ljmaxp1))
#endif

#ifdef key_MPI_2D
!$OMP DO SCHEDULE(RUNTIME) &
#else
!$OMP DO SCHEDULE(DYNAMIC,5)&
#endif
!$OMP& PRIVATE(i,j,ft,gdt,vit,factft,dvsdx,dvsdx2,u_vtmp2,phieautot)
   DO j=ljminp1,ljmax
     DO i =liminp2,limaxm1

#      include "dyn2dy_mtm.h"
#      include "dyn2dy_cty.h"

     END DO
   END DO
!$OMP END DO

   PRINT_DBG*, 'exit DYN2DY_TLS_COEF routine'

  END SUBROUTINE dyn2dy_tls_coef
