  SUBROUTINE ts_stateeq2d(sal)

!&E---------------------------------------------------------------------
!&E                 ***  ROUTINE ts_stateeq2d  ***
!&E
!&E ** Purpose : compute buoyancy, useful for the computation of the driving term
!&E              resulting from the integral from the bottom to the surface
!&E              of the baroclinic pressure gradient.
!&E
!&E ** Description :
!&E
!&E ** Called by : step2dxy, step2dyx
!&E
!&E ** External calls :
!&E
!&E ** Used ij-arrays : sal
!&E
!&E ** Modified variables : buoy2d
!&E
!&E ** Reference :
!&E
!&E
!&E ** History :
!&E         !  2008-07  (T. Odaka)   MPI
!&E         !  2009-04  (A. Mano)    MPI2D
!&E         !  2009-05  (V. Garnier) sal(kmax) to manage river discharges and
!&E                                  spin-up in 2D for a 3D run
!&E
!&E---------------------------------------------------------------------





























































!! * Modules used
   USE parameters,ONLY : jmin,jmax,ljmin,ljmax,imin,imax,rsh,kmax,grav, &
     limin,limax,limaxp1,ljmaxp1,liminm1,limaxp2,ljminm1,ljmaxp2
   USE comfluxdo, ONLY : buoy2d

   USE toolmpi,   ONLY : ex_i_rsh,ex_j_rsh


   IMPLICIT NONE

!! * Arguments
   REAL(kind=rsh),DIMENSION(kmax,liminm1:limaxp2,ljminm1:ljmaxp2),INTENT(in) :: sal

!! * Local declarations
   INTEGER        :: j
   REAL(kind=rsh) :: betasel

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

!$OMP PARALLEL DEFAULT(NONE) PRIVATE(j,betasel) &
!$OMP& SHARED(buoy2d,sal,limin,limax,ljmin,ljmax)
   betasel=0.00078_rsh
!$OMP DO schedule(static)
   DO j=ljmin,ljmax
     buoy2d(limin:limax,j)=-grav*betasel*sal(1,limin:limax,j)
   ENDDO
!$OMP end do
!$OMP end parallel

   CALL ex_i_rsh(0,1,1,limin,limaxp1,ljmin,ljmaxp1,buoy2d(limin:limaxp1,ljmin:ljmaxp1))
   CALL ex_j_rsh(0,1,1,limin,limaxp1,ljmin,ljmaxp1,buoy2d(limin:limaxp1,ljmin:ljmaxp1))

  END SUBROUTINE ts_stateeq2d
