Index: /trunk/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp.F90
===================================================================
--- /trunk/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp.F90	(revision 3844)
+++ /trunk/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp.F90	(revision 3845)
@@ -21,17 +21,17 @@
    !!   ldf_slp_init  : initialization of the slopes computation
    !!----------------------------------------------------------------------
-   USE oce            ! ocean dynamics and tracers
-   USE dom_oce        ! ocean space and time domain
-   USE ldftra_oce     ! lateral diffusion: traceur
-   USE ldfdyn_oce     ! lateral diffusion: dynamics
-   USE phycst         ! physical constants
-   USE zdfmxl         ! mixed layer depth
-   USE eosbn2         ! equation of states
-   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
-   USE in_out_manager ! I/O manager
-   USE prtctl         ! Print control
-   USE wrk_nemo       ! work arrays
-   USE timing         ! Timing
-   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE ldftra_oce      ! lateral diffusion: traceur
+   USE ldfdyn_oce      ! lateral diffusion: dynamics
+   USE phycst          ! physical constants
+   USE zdfmxl          ! mixed layer depth
+   USE eosbn2          ! equation of states
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+   USE wrk_nemo        ! work arrays
+   USE timing          ! Timing
+   USE lib_fortran     ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
 
    IMPLICIT NONE
@@ -495,13 +495,23 @@
                DO ji = 1, fs_jpim1
                   ip = jl   ;   jp = jl
-                  jk = MIN( nmln(ji+ip,jj) , mbkt(ji+ip,jj) ) + 1         ! ML level+1 (MIN in case ML depth is the ocean depth)
-                  ! Add s-coordinate slope at t-points (do this by *subtracting* gradient of depth)
-                  zti_g_raw = (  zdxrho(ji+ip,jj,jk-kp,1-ip) / zdzrho(ji+ip,jj,jk-kp,kp)      &
-                     &      - ( fsdept(ji+1,jj,jk-kp) - fsdept(ji,jj,jk-kp) ) / e1u(ji,jj)  ) * umask(ji,jj,jk)
-                  jk = MIN( nmln(ji,jj+jp) , mbkt(ji,jj+jp) ) + 1
-                  ztj_g_raw = (  zdyrho(ji,jj+jp,jk-kp,1-jp) / zdzrho(ji,jj+jp,jk-kp,kp)      &
-                     &      - ( fsdept(ji,jj+1,jk-kp) - fsdept(ji,jj,jk-kp) ) / e2v(ji,jj)  ) * vmask(ji,jj,jk)
-                  zti_mlb(ji+ip,jj   ,1-ip,kp) = SIGN( MIN( rn_slpmax, ABS( zti_g_raw ) ), zti_g_raw )
-                  ztj_mlb(ji   ,jj+jp,1-jp,kp) = SIGN( MIN( rn_slpmax, ABS( ztj_g_raw ) ), ztj_g_raw )
+                  !
+                  jk = nmln(ji+ip,jj) + 1
+                  IF( jk .GT. mbkt(ji+ip,jj) ) THEN  !ML reaches bottom
+                    zti_mlb(ji+ip,jj   ,1-ip,kp) = 0.0_wp
+                  ELSE
+                    ! Add s-coordinate slope at t-points (do this by *subtracting* gradient of depth)
+                    zti_g_raw = (  zdxrho(ji+ip,jj,jk-kp,1-ip) / zdzrho(ji+ip,jj,jk-kp,kp)      &
+                       &      - ( fsdept(ji+1,jj,jk-kp) - fsdept(ji,jj,jk-kp) ) / e1u(ji,jj)  ) * umask(ji,jj,jk)
+                    zti_mlb(ji+ip,jj   ,1-ip,kp) = SIGN( MIN( rn_slpmax, ABS( zti_g_raw ) ), zti_g_raw )
+                  ENDIF
+                  !
+                  jk = nmln(ji,jj+jp) + 1
+                  IF( jk .GT. mbkt(ji,jj+jp) ) THEN  !ML reaches bottom
+                    ztj_mlb(ji   ,jj+jp,1-jp,kp) = 0.0_wp
+                  ELSE
+                    ztj_g_raw = (  zdyrho(ji,jj+jp,jk-kp,1-jp) / zdzrho(ji,jj+jp,jk-kp,kp)      &
+                       &      - ( fsdept(ji,jj+1,jk-kp) - fsdept(ji,jj,jk-kp) ) / e2v(ji,jj)  ) * vmask(ji,jj,jk)
+                    ztj_mlb(ji   ,jj+jp,1-jp,kp) = SIGN( MIN( rn_slpmax, ABS( ztj_g_raw ) ), ztj_g_raw )
+                  ENDIF
                END DO
             END DO
