Index: trunk/NEMO/OPA_SRC/TRA/traadv_cen2.F90
===================================================================
--- trunk/NEMO/OPA_SRC/TRA/traadv_cen2.F90	(revision 833)
+++ trunk/NEMO/OPA_SRC/TRA/traadv_cen2.F90	(revision 888)
@@ -1,11 +1,13 @@
 MODULE traadv_cen2
-   !!==============================================================================
-   !!                       ***  MODULE  traadv_cen2  ***
+   !!======================================================================
+   !!                     ***  MODULE  traadv_cen2  ***
    !! Ocean active tracers:  horizontal & vertical advective trend
-   !!==============================================================================
-   !! History :  8.2  !  01-08  (G. Madec, E. Durand)  trahad+trazad = traadv 
-   !!            8.5  !  02-06  (G. Madec)  F90: Free form and module
-   !!            9.0  !  05-11  (V. Garnier) Surface pressure gradient organization
-   !!            " "  !  06-04  (R. Benshila, G. Madec) Step reorganization
+   !!======================================================================
+   !! History :   8.2  !  01-08  (G. Madec, E. Durand)  trahad+trazad=traadv 
+   !!             8.5  !  02-06  (G. Madec)  F90: Free form and module
+   !!             9.0  !  04-08  (C. Talandier) New trends organization
+   !!             " "  !  05-11  (V. Garnier) Surface pressure gradient organization
+   !!             " "  !  06-04  (R. Benshila, G. Madec) Step reorganization
+   !!             " "  !  06-07  (G. madec)  add ups_orca_set routine
    !!----------------------------------------------------------------------
 
@@ -13,17 +15,21 @@
    !!   tra_adv_cen2 : update the tracer trend with the horizontal and
    !!                  vertical advection trends using a seconder order
+   !!   ups_orca_set : allow mixed upstream/centered scheme in specific
+   !!                  area (set for orca 2 and 4 only)
    !!----------------------------------------------------------------------
    USE oce             ! ocean dynamics and active tracers
    USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE dynspg_oce      ! choice/control of key cpp for surface pressure gradient
+   USE trdmod_oce      ! ocean variables trends
    USE trdmod          ! ocean active tracers trends 
-   USE trdmod_oce      ! ocean variables trends
-   USE flxrnf          !
+   USE closea          ! closed sea
    USE trabbl          ! advective term in the BBL
    USE ocfzpt          !
+   USE sbcrnf          ! river runoffs
+   USE in_out_manager  ! I/O manager
    USE lib_mpp
    USE lbclnk          ! ocean lateral boundary condition (or mpp link)
-   USE in_out_manager  ! I/O manager
    USE diaptr          ! poleward transport diagnostics
-   USE dynspg_oce      ! choice/control of key cpp for surface pressure gradient
    USE prtctl          ! Print control
 
@@ -31,5 +37,9 @@
    PRIVATE
 
-   PUBLIC   tra_adv_cen2   ! routine called by step.F90
+   PUBLIC   tra_adv_cen2    ! routine called by step.F90
+   PUBLIC   ups_orca_set    ! routine used by traadv_cen2_jki.F90
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   upsmsk    !: mixed upstream/centered scheme near some straits 
+   !                                                   !  and in closed seas (orca 2 and 4 configurations)
 
    REAL(wp), DIMENSION(jpi,jpj) ::   btr2   ! inverse of T-point surface [1/(e1t*e2t)]
@@ -39,6 +49,6 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
-   !! $Header$ 
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$
    !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
@@ -118,14 +128,13 @@
       !!
       INTEGER  ::   ji, jj, jk                           ! dummy loop indices
-      REAL(wp) ::                           &
-         zbtr, zta, zsa, zfui, zfvj,        &  ! temporary scalars
-         zhw, ze3tr, zcofi, zcofj,          &  !    "         "
-         zupsut, zupsvt, zupsus, zupsvs,    &  !    "         "
-         zfp_ui, zfp_vj, zfm_ui, zfm_vj,    &  !    "         "
-         zcofk, zupst, zupss, zcent,        &  !    "         "
-         zcens, zfp_w, zfm_w,               &  !    "         "
-         zcenut, zcenvt, zcenus, zcenvs,    &  !    "         "
-         z_hdivn_x, z_hdivn_y, z_hdivn
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwz, ztrdt, zind   ! 3D workspace 
+      REAL(wp) ::   zta, zsa, zbtr, zhw, ze3tr,       &  ! temporary scalars
+         &          zfp_ui, zfp_vj, zfp_w , zfui  ,   &  !    "         "
+         &          zfm_ui, zfm_vj, zfm_w , zfvj  ,   &  !    "         "
+         &          zcofi , zcofj , zcofk ,           &  !    "         "
+         &          zupsut, zupsus, zcenut, zcenus,   &  !    "         "
+         &          zupsvt, zupsvs, zcenvt, zcenvs,   &  !    "         "
+         &          zupst , zupss , zcent , zcens ,   &  !    "         "
+         &          z_hdivn_x, z_hdivn_y, z_hdivn 
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwz, ztrdt, zind   ! 3D workspace
       REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zww, ztrds         !  "      "
       !!----------------------------------------------------------------------
@@ -136,6 +145,10 @@
          IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~   Vector optimization case'
          IF(lwp) WRITE(numout,*)
-         ! 
-         btr2(:,:) = 1. / ( e1t(:,:) * e2t(:,:) )
+         !
+         upsmsk(:,:) = 0.e0                              ! not upstream by default
+         IF( cp_cfg == "orca" )   CALL ups_orca_set      ! set mixed Upstream/centered scheme near some straits
+         !                                               ! and in closed seas (orca2 and orca4 only)
+         !   
+         btr2(:,:) = 1. / ( e1t(:,:) * e2t(:,:) )        ! inverse of T-point surface
       ENDIF
 
@@ -145,10 +158,10 @@
          DO jj = 1, jpj
             DO ji = 1, jpi
-               zind(ji,jj,jk) =  MAX ( upsrnfh(ji,jj) * upsrnfz(jk),     &  ! changing advection scheme near runoff
-                  &                    upsadv(ji,jj)                     &  ! in the vicinity of some straits
+               zind(ji,jj,jk) = MAX (   &
+                  rnfmsk(ji,jj) * rnfmsk_z(jk),      &  ! near runoff mouths (& closed sea outflows)
+                  upsmsk(ji,jj)                      &  ! some of some straits
 #if defined key_lim3 || defined key_lim2
-                  &                  , tmask(ji,jj,jk)                   &  ! half upstream tracer fluxes
-                  &                  * MAX( 0., SIGN( 1., fzptn(ji,jj)   &  ! if tn < ("freezing"+0.1 )
-                  &                                +0.1-tn(ji,jj,jk) ) ) &
+                  !                                     ! below ice covered area (if tn < "freezing"+0.1 )
+                  , MAX(  0., SIGN( 1., fzptn(ji,jj) + 0.1 - tn(ji,jj,jk) )  ) * tmask(ji,jj,jk)   &
 #endif
                   &                  )
@@ -157,7 +170,8 @@
       END DO
 
-
-      !  Horizontal advective fluxes
-      ! -----------------------------
+      ! I. Horizontal advective fluxes
+      ! ------------------------------
+      !  Second order centered tracer flux at u and v-points
+      ! -----------------------------------------------------
       !                                                ! ===============
       DO jk = 1, jpkm1                                 ! Horizontal slab
@@ -278,6 +292,6 @@
          &                       tab3d_2=sa, clinfo2=            ' Sa: ', mask2=tmask, clinfo3='tra' )
 
-      ! 4. "zonal" mean advective heat and salt transport 
-      ! -------------------------------------------------
+      ! "zonal" mean advective heat and salt transport 
+      ! ----------------------------------------------
 
       IF( ln_diaptr .AND. ( MOD( kt, nf_ptr ) == 0 ) ) THEN
@@ -312,5 +326,5 @@
       ENDIF
 
-      ! 1. Vertical advective fluxes
+      ! 1. Vertical advective fluxes 
       ! ----------------------------
       ! Second order centered tracer flux at w-point
@@ -386,4 +400,65 @@
       !
    END SUBROUTINE tra_adv_cen2
+   
+   
+   SUBROUTINE ups_orca_set
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ups_orca_set  ***
+      !!       
+      !! ** Purpose :   add a portion of upstream scheme in area where the
+      !!                centered scheme generates too strong overshoot
+      !!
+      !! ** Method  :   orca (R4 and R2) confiiguration setting. Set upsmsk
+      !!                array to nozero value in some straith. 
+      !!
+      !! ** Action : - upsmsk set to 1 at some strait, 0 elsewhere for orca
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ii0, ii1, ij0, ij1      ! temporary integers
+      !!----------------------------------------------------------------------
+      
+      ! mixed upstream/centered scheme near river mouths
+      ! ------------------------------------------------
+      SELECT CASE ( jp_cfg )
+      !                                        ! =======================
+      CASE ( 4 )                               !  ORCA_R4 configuration 
+         !                                     ! =======================
+         !                                          ! Gibraltar Strait
+         ii0 =  70   ;   ii1 =  71
+         ij0 =  52   ;   ij1 =  53   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
+         !
+         !                                     ! =======================
+      CASE ( 2 )                               !  ORCA_R2 configuration 
+         !                                     ! =======================
+         !                                          ! Gibraltar Strait
+         ij0 = 102   ;   ij1 = 102
+         ii0 = 138   ;   ii1 = 138   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.20
+         ii0 = 139   ;   ii1 = 139   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.40
+         ii0 = 140   ;   ii1 = 140   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
+         ij0 = 101   ;   ij1 = 102
+         ii0 = 141   ;   ii1 = 141   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
+         !                                          ! Bab el Mandeb Strait
+         ij0 =  87   ;   ij1 =  88
+         ii0 = 164   ;   ii1 = 164   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.10
+         ij0 =  88   ;   ij1 =  88
+         ii0 = 163   ;   ii1 = 163   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
+         ii0 = 162   ;   ii1 = 162   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.40
+         ii0 = 160   ;   ii1 = 161   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
+         ij0 =  89   ;   ij1 =  89
+         ii0 = 158   ;   ii1 = 160   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
+         ij0 =  90   ;   ij1 =  90
+         ii0 = 160   ;   ii1 = 160   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
+         !                                          ! Sound Strait
+         ij0 = 116   ;   ij1 = 116
+         ii0 = 144   ;   ii1 = 144   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
+         ii0 = 145   ;   ii1 = 147   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
+         ii0 = 148   ;   ii1 = 148   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
+         !
+      END SELECT 
+      
+      ! mixed upstream/centered scheme over closed seas
+      ! -----------------------------------------------
+      CALL clo_ups( upsmsk(:,:) )
+      !
+   END SUBROUTINE ups_orca_set
 
    !!======================================================================
