Index: /branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/DOM/dom_oce.F90
===================================================================
--- /branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/DOM/dom_oce.F90	(revision 2442)
+++ /branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/DOM/dom_oce.F90	(revision 2443)
@@ -6,8 +6,5 @@
    !!======================================================================
    !! History :  1.0  ! 2005-10  (A. Beckmann, G. Madec)  reactivate s-coordinate 
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !!            3.3  ! 2010-11  (G. Madec) add mbk. arrays associated to the deepest ocean level
    !!----------------------------------------------------------------------
    USE par_oce      ! ocean parameters
@@ -172,12 +169,14 @@
    !! masks, bathymetry
    !! ---------------------------------------------------------------------
-   INTEGER , PUBLIC, DIMENSION(jpi,jpj) ::   mbathy    !: number of ocean level (=0, 1, ... , jpk-1)
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   bathy     !: ocean depth (meters)
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   tmask_i   !: interior domain T-point mask
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   bmask     !: land/ocean mask of barotropic stream function
-
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   tmask, umask, vmask, fmask   !: land/ocean mask at T-, U-, V- and F-points
-
-   REAL(wp), PUBLIC, DIMENSION(jpiglo) ::   tpol, fpol          !: north fold mask (nperio= 3 or 4)
+   INTEGER , PUBLIC, DIMENSION(jpi,jpj) ::   mbathy       !: number of ocean level (=0, 1, ... , jpk-1)
+   INTEGER , PUBLIC, DIMENSION(jpi,jpj) ::   mbkt         !: vertical index of the bottom last T- ocean level
+   INTEGER , PUBLIC, DIMENSION(jpi,jpj) ::   mbku, mbkv   !: vertical index of the bottom last U- and W- ocean level
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   bathy        !: ocean depth (meters)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   tmask_i      !: interior domain T-point mask
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   bmask        !: land/ocean mask of barotropic stream function
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   tmask, umask, vmask, fmask   !: land/ocean mask at T-, U-, V- and F-pts
+
+   REAL(wp), PUBLIC, DIMENSION(jpiglo) ::   tpol, fpol          !: north fold mask (jperio= 3 or 4)
 
 #if defined key_noslip_accurate
@@ -233,4 +232,8 @@
    END FUNCTION Agrif_CFixed
 #endif
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!======================================================================
 END MODULE dom_oce
Index: /branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90
===================================================================
--- /branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 2442)
+++ /branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 2443)
@@ -14,4 +14,5 @@
    !!            3.0  ! 2008-06  (G. Madec)  insertion of domzgr_zps.h90 & conding style
    !!            3.2  ! 2009-07  (R. Benshila) Suppression of rigid-lid option
+   !!            3.3  ! 2010-11  (G. Madec) add mbk. arrays associated to the deepest ocean level
    !!----------------------------------------------------------------------
 
@@ -497,4 +498,8 @@
       IF( .NOT.lk_c1d )   CALL zgr_bat_ctl            !   Bathymetry check  !
       !                                               ! =================== !
+      !
+      !                                               ! ========================= !
+                          CALL zgr_bot_level          !   level of ocean bottom   !
+      !                                               ! ========================= !
    END SUBROUTINE zgr_bat
 
@@ -682,4 +687,39 @@
       !
    END SUBROUTINE zgr_bat_ctl
+
+
+   SUBROUTINE zgr_bot_level
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE zgr_bot_level  ***
+      !!
+      !! ** Purpose :   defines the vertical index of ocean bottom (mbk. arrays)
+      !!
+      !! ** Method  :   computes from mbathy with a minimum value of 1 over land
+      !!
+      !! ** Action  :   mbkt, mbku, mbkv :   vertical indices of the deeptest 
+      !!                                     ocean level at t-, u- & v-points
+      !!                                     (min value = 1 over land)
+      !!----------------------------------------------------------------------
+      INTEGER ::   ji, jj   ! dummy loop indices
+      REAL(wp), DIMENSION(jpi,jpj) ::   zmbk   ! 2D workspace 
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '    zgr_bot_level : ocean bottom k-index of T-, U-, V- and W-levels '
+      IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~~~'
+      !
+      mbkt(:,:) = MAX( mbathy(:,:) , 1 )    ! bottom k-index of T-level (=1 over land)
+      !                                     ! bottom k-index of W-level = mbkt+1
+      DO jj = 1, jpjm1                      ! bottom k-index of u- (v-) level
+         DO ji = 1, jpim1
+            mbku(ji,jj) = MIN(  mbkt(ji+1,jj  ) , mbkt(ji,jj)  )
+            mbkv(ji,jj) = MIN(  mbkt(ji  ,jj+1) , mbkt(ji,jj)  )
+         END DO
+      END DO
+      ! converte into REAL to use lbc_lnk ; impose a min value of 1 as a zero can be set in lbclnk 
+      zmbk(:,:) = REAL( mbku(:,:), wp )   ;   CALL lbc_lnk(zmbk,'U',1.)   ;   mbku  (:,:) = MAX( INT( zmbk(:,:) ), 1 )
+      zmbk(:,:) = REAL( mbkv(:,:), wp )   ;   CALL lbc_lnk(zmbk,'V',1.)   ;   mbkv  (:,:) = MAX( INT( zmbk(:,:) ), 1 )
+      !
+   END SUBROUTINE zgr_bot_level
 
 
Index: /branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/TRA/trabbc.F90
===================================================================
--- /branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/TRA/trabbc.F90	(revision 2442)
+++ /branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/TRA/trabbc.F90	(revision 2443)
@@ -8,14 +8,16 @@
    !!             -   ! 2002-11 (A. Bozec)  tra_bbc_init: original code
    !!            3.3  ! 2010-10 (G. Madec)  dynamical allocation + suppression of key_trabbc
+   !!             -   ! 2010-11 (G. Madec)  use mbkt array (deepest ocean t-level)
    !!----------------------------------------------------------------------
 
+   !!----------------------------------------------------------------------
    !!   tra_bbc      : update the tracer trend at ocean bottom 
    !!   tra_bbc_init : initialization of geothermal heat flux trend
    !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and active tracers
-   USE dom_oce         ! ocean space and time domain
+   USE oce             ! ocean variables
+   USE dom_oce         ! domain: ocean
    USE phycst          ! physical constants
-   USE trdmod_oce      ! ocean trends 
-   USE trdtra      ! ocean trends 
+   USE trdmod_oce      ! trends: ocean variables 
+   USE trdtra          ! trends: active tracers 
    USE in_out_manager  ! I/O manager
    USE prtctl          ! Print control
@@ -32,5 +34,4 @@
    REAL(wp)        ::   rn_geoflx_cst = 86.4e-3_wp   !  Constant value of geothermal heat flux
 
-   INTEGER , DIMENSION(:,:), ALLOCATABLE ::   nbotlevt   ! ocean bottom level index at T-pt
    REAL(wp), PUBLIC, DIMENSION(:,:), ALLOCATABLE ::   qgh_trd0   ! geothermal heating trend
  
@@ -57,5 +58,5 @@
       !!       ocean bottom can be computed once and is added to the temperature
       !!       trend juste above the bottom at each time step:
-      !!            ta = ta + Qsf / (rau0 rcp e3T) for k= mbathy -1
+      !!            ta = ta + Qsf / (rau0 rcp e3T) for k= mbkt
       !!       Where Qsf is the geothermal heat flux.
       !!
@@ -66,16 +67,15 @@
       !!              Emile-Geay and Madec, 2009, Ocean Science.
       !!----------------------------------------------------------------------
-      !!
       INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
       !!
       INTEGER  ::   ji, jj, ik    ! dummy loop indices
-      REAL(wp) ::   zqgh_trd  ! geothermal heat flux trend
+      REAL(wp) ::   zqgh_trd      ! geothermal heat flux trend
       REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  ztrdt
       !!----------------------------------------------------------------------
-
+      !
       IF( l_trdtra )   THEN         ! Save ta and sa trends
          ALLOCATE( ztrdt(jpi,jpj,jpk) )     ;   ztrdt(:,:,:) = tsa(:,:,:,jp_tem)
       ENDIF
-
+      !
       !                             !  Add the geothermal heat flux trend on temperature
 #if defined key_vectopt_loop
@@ -86,10 +86,10 @@
          DO ji = 2, jpim1
 #endif
-            ik = nbotlevt(ji,jj)
+            ik = mbkt(ji,jj)
             zqgh_trd = qgh_trd0(ji,jj) / fse3t(ji,jj,ik)
             tsa(ji,jj,ik,jp_tem) = tsa(ji,jj,ik,jp_tem) + zqgh_trd
          END DO
       END DO
-
+      !
       IF( l_trdtra ) THEN        ! Save the geothermal heat flux trend for diagnostics
          ztrdt(:,:,:) = tsa(:,:,:,jp_tem) - ztrdt(:,:,:)
@@ -117,5 +117,4 @@
       !!
       !! ** Action  : - read/fix the geothermal heat qgh_trd0
-      !!              - compute the bottom ocean level nbotlevt
       !!----------------------------------------------------------------------
       USE iom
@@ -127,6 +126,6 @@
       !!----------------------------------------------------------------------
 
-      REWIND ( numnam )              ! Read Namelist nambbc : bottom momentum boundary condition
-      READ   ( numnam, nambbc )
+      REWIND( numnam )                 ! Read Namelist nambbc : bottom momentum boundary condition
+      READ  ( numnam, nambbc )
 
       IF(lwp) THEN                     ! Control print
@@ -143,12 +142,5 @@
       IF( ln_trabbc ) THEN             !==  geothermal heating  ==!
          !
-         ALLOCATE( nbotlevt(jpi,jpj) )    ! allocation
-         ALLOCATE( qgh_trd0(jpi,jpj) )     
-         !             
-         DO jj = 1, jpj                   ! level of the ocean bottom at T-point
-            DO ji = 1, jpi
-               nbotlevt(ji,jj) = MAX( mbathy(ji,jj)-1, 1 )
-            END DO
-         END DO
+         ALLOCATE( qgh_trd0(jpi,jpj) )    ! allocation
          !
          SELECT CASE ( nn_geoflx )        ! geothermal heat flux / (rauO * Cp)
@@ -172,5 +164,5 @@
          !
       ELSE
-            IF(lwp) WRITE(numout,*) '      *** no geothermal heat flux'
+         IF(lwp) WRITE(numout,*) '      *** no geothermal heat flux'
       ENDIF
       !
Index: /branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/TRA/trabbl.F90
===================================================================
--- /branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/TRA/trabbl.F90	(revision 2442)
+++ /branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/TRA/trabbl.F90	(revision 2443)
@@ -4,11 +4,12 @@
    !! Ocean physics :  advective and/or diffusive bottom boundary layer scheme
    !!==============================================================================
-   !! History :  OPA  !  1996-06  (L. Mortier)  Original code
-   !!            8.0  !  1997-11  (G. Madec)    Optimization
-   !!   NEMO     1.0  !  2002-08  (G. Madec)  free form + modules
-   !!             -   !  2004-01  (A. de Miranda, G. Madec, J.M. Molines ) add advective bbl
-   !!            3.3  !  2009-11  (G. Madec)  merge trabbl and trabbl_adv + style + optimization 
-   !!             -   !  2010-04  (G. Madec)  Campin & Goosse advective bbl 
-   !!             -   !  2010-06  (C. Ethe, G. Madec)  merge TRA-TRC
+   !! History :  OPA  ! 1996-06  (L. Mortier)  Original code
+   !!            8.0  ! 1997-11  (G. Madec)    Optimization
+   !!   NEMO     1.0  ! 2002-08  (G. Madec)  free form + modules
+   !!             -   ! 2004-01  (A. de Miranda, G. Madec, J.M. Molines ) add advective bbl
+   !!            3.3  ! 2009-11  (G. Madec)  merge trabbl and trabbl_adv + style + optimization 
+   !!             -   ! 2010-04  (G. Madec)  Campin & Goosse advective bbl 
+   !!             -   ! 2010-06  (C. Ethe, G. Madec)  merge TRA-TRC
+   !!             -   ! 2010-11  (G. Madec) add mbk. arrays associated to the deepest ocean level
    !!----------------------------------------------------------------------
 #if   defined key_trabbl   ||   defined key_esopa
@@ -24,8 +25,8 @@
    USE oce            ! ocean dynamics and active tracers
    USE dom_oce        ! ocean space and time domain
-   USE phycst         ! 
+   USE phycst         ! physical constant
    USE eosbn2         ! equation of state
-   USE trdmod_oce     ! ocean space and time domain
-   USE trdtra         ! ocean active tracers trends
+   USE trdmod_oce     ! trends: ocean variables
+   USE trdtra         ! trends: active tracers
    USE iom            ! IOM server               
    USE in_out_manager ! I/O manager
@@ -38,7 +39,7 @@
    PUBLIC   tra_bbl       !  routine called by step.F90
    PUBLIC   tra_bbl_init  !  routine called by opa.F90
-   PUBLIC   tra_bbl_dif   !  routine called by tra_bbl and trc_bbl
+   PUBLIC   tra_bbl_dif   !  routine called by trcbbl.F90
    PUBLIC   tra_bbl_adv   !  -          -          -              -
-   PUBLIC   bbl           !  -          -          -              -
+   PUBLIC   bbl           !  routine called by trcbbl.F90 and dtadyn.F90
 
 # if defined key_trabbl
@@ -48,16 +49,14 @@
 # endif
 
-   !                                         !!* Namelist nambbl * 
-   INTEGER , PUBLIC ::   nn_bbl_ldf = 0       !: =1   : diffusive bbl or not (=0)
-   INTEGER , PUBLIC ::   nn_bbl_adv = 0       !: =1/2 : advective bbl or not (=0)
-   !                                          !  =1 : advective bbl using the bottom ocean velocity
-   !                                          !  =2 :     -      -  using utr_bbl proportional to grad(rho)
-   REAL(wp), PUBLIC ::   rn_ahtbbl  = 1.e+3   !: along slope bbl diffusive coefficient [m2/s]
-   REAL(wp), PUBLIC ::   rn_gambbl  = 10.e0   !: lateral coeff. for bottom boundary layer scheme [s]
+   !                                           !!* Namelist nambbl * 
+   INTEGER , PUBLIC ::   nn_bbl_ldf = 0         !: =1   : diffusive bbl or not (=0)
+   INTEGER , PUBLIC ::   nn_bbl_adv = 0         !: =1/2 : advective bbl or not (=0)
+   !                                            !  =1 : advective bbl using the bottom ocean velocity
+   !                                            !  =2 :     -      -  using utr_bbl proportional to grad(rho)
+   REAL(wp), PUBLIC ::   rn_ahtbbl  = 1.e3_wp   !: along slope bbl diffusive coefficient [m2/s]
+   REAL(wp), PUBLIC ::   rn_gambbl  = 10.0_wp   !: lateral coeff. for bottom boundary layer scheme [s]
 
    REAL(wp), DIMENSION(jpi,jpj), PUBLIC ::   utr_bbl  , vtr_bbl   ! u- (v-) transport in the bottom boundary layer
 
-   INTEGER , DIMENSION(jpi,jpj) ::   mbkt                   ! vertical index of the bottom ocean T-level
-   INTEGER , DIMENSION(jpi,jpj) ::   mbku     , mbkv        ! vertical index of the (upper) bottom ocean U/V-level
    INTEGER , DIMENSION(jpi,jpj) ::   mbku_d   , mbkv_d      ! vertical index of the "lower" bottom ocean U/V-level
    INTEGER , DIMENSION(jpi,jpj) ::   mgrhu    , mgrhv       ! = +/-1, sign of grad(H) in u-(v-)direction
@@ -74,9 +73,7 @@
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
    !! $Id$
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
-
 
    SUBROUTINE tra_bbl( kt )
@@ -85,6 +82,6 @@
       !!                   
       !! ** Purpose :   Compute the before tracer (t & s) trend associated 
-      !!     with the bottom boundary layer and add it to the general trend
-      !!     of tracer equations.
+      !!              with the bottom boundary layer and add it to the general
+      !!              trend of tracer equations.
       !!
       !! ** Method  :   Depending on namtra_bbl namelist parameters the bbl
@@ -218,8 +215,6 @@
       !!                       transport proportional to the along-slope density gradient                   
       !!
-      !!
       !! References : Beckmann, A., and R. Doscher, 1997, J. Phys.Oceanogr., 581-591.
       !!              Campin, J.-M., and H. Goosse, 1999, Tellus, 412-430.
-      !!
       !!----------------------------------------------------------------------  
       INTEGER                              , INTENT(in   ) ::   kjpt    ! number of tracers
@@ -233,5 +228,5 @@
       REAL(wp) ::   zu_bbl, zv_bbl           !   -      -
       !!----------------------------------------------------------------------
-
+      !
       !                                                          ! ===========
       DO jn = 1, kjpt                                            ! tracer loop
@@ -547,22 +542,14 @@
       e1e2t_r(:,:) = 1.0 / ( e1t(:,:) * e2t(:,:) )
       
-      !                             !* vertical index of bottom t-, u- and v-points
-      DO jj = 1, jpj                      ! bottom k-index of T-level
-         DO ji = 1, jpi
-            mbkt(ji,jj) = MAX( mbathy(ji,jj) - 1, 1 )
+      !                             !* vertical index of  "deep" bottom u- and v-points
+      DO jj = 1, jpjm1                    ! (the "shelf" bottom k-indices are mbku and mbkv)
+         DO ji = 1, jpim1
+            mbku_d(ji,jj) = MAX(  mbkt(ji+1,jj  ) , mbkt(ji,jj)  )   ! >= 1 as mbkt=1 over land
+            mbkv_d(ji,jj) = MAX(  mbkt(ji  ,jj+1) , mbkt(ji,jj)  )
          END DO
       END DO
-      DO jj = 1, jpjm1                    ! bottom k-index of u- (v-) level (shelf and deep)
-         DO ji = 1, jpim1
-            mbku  (ji,jj) = MAX( MIN( mbathy(ji+1,jj  ), mbathy(ji,jj) ) - 1, 1 )   ! "shelf"
-            mbkv  (ji,jj) = MAX( MIN( mbathy(ji  ,jj+1), mbathy(ji,jj) ) - 1, 1 )
-            mbku_d(ji,jj) = MAX( MAX( mbathy(ji+1,jj  ), mbathy(ji,jj) ) - 1, 1 )   ! "deep"
-            mbkv_d(ji,jj) = MAX( MAX( mbathy(ji  ,jj+1), mbathy(ji,jj) ) - 1, 1 )
-         END DO
-      END DO
-      zmbk(:,:) = FLOAT( mbku  (:,:) )   ;   CALL lbc_lnk(zmbk,'U',1.)   ;   mbku  (:,:) = MAX( INT( zmbk(:,:) ), 1 )
-      zmbk(:,:) = FLOAT( mbkv  (:,:) )   ;   CALL lbc_lnk(zmbk,'V',1.)   ;   mbkv  (:,:) = MAX( INT( zmbk(:,:) ), 1 )
-      zmbk(:,:) = FLOAT( mbku_d(:,:) )   ;   CALL lbc_lnk(zmbk,'U',1.)   ;   mbku_d(:,:) = MAX( INT( zmbk(:,:) ), 1 )
-      zmbk(:,:) = FLOAT( mbkv_d(:,:) )   ;   CALL lbc_lnk(zmbk,'V',1.)   ;   mbkv_d(:,:) = MAX( INT( zmbk(:,:) ), 1 )
+      ! converte into REAL to use lbc_lnk ; impose a min value of 1 as a zero can be set in lbclnk 
+      zmbk(:,:) = REAL( mbku_d(:,:), wp )   ;   CALL lbc_lnk(zmbk,'U',1.)   ;   mbku_d(:,:) = MAX( INT( zmbk(:,:) ), 1 )
+      zmbk(:,:) = REAL( mbkv_d(:,:), wp )   ;   CALL lbc_lnk(zmbk,'V',1.)   ;   mbkv_d(:,:) = MAX( INT( zmbk(:,:) ), 1 )
 
                                         !* sign of grad(H) at u- and v-points
