Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isftbl.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isftbl.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isftbl.F90	(revision 11403)
@@ -1,32 +1,43 @@
 MODULE isftbl
-
-USE in_out_manager
-USE dom_oce
-USE oce
-USE isf
-USE lbclnk
-
-IMPLICIT NONE
-
-PRIVATE
-
-PUBLIC isf_tbl, isf_tbl_avg, isf_tbl_lvl, isftbl_ktop, isftbl_kbot
+   !!======================================================================
+   !!                       ***  MODULE  isftbl  ***
+   !! isftbl module :  compute properties of top boundary layer
+   !!======================================================================
+   !! History :  4.1  !  2019-09  (P. Mathiot) original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   isftbl       : routine to compute : 
+   !!                  - geometry of the ice shelf tbl (isf_tbl_lvl, isftbl_ktop, isftbl_kbot)
+   !!                    (top and bottom level, thickness and fraction of deepest level affected)
+   !!                  - tbl averaged properties (isf_tbl, isf_tbl_avg)
+   !!----------------------------------------------------------------------
+
+   USE dom_oce ! vertical scale factor
+   USE lbclnk  ! lbc_lnk subroutine
+
+   IMPLICIT NONE
+
+   PRIVATE
+
+   PUBLIC isf_tbl, isf_tbl_avg, isf_tbl_lvl, isftbl_ktop, isftbl_kbot
 
 CONTAINS
 
    SUBROUTINE isf_tbl( pvarin, pvarout, cd_ptin, ktop, kbot, phtbl, pfrac )
-      !!----------------------------------------------------------------------
-      !!                  ***  SUBROUTINE sbc_isf_tbl  ***
+      !!--------------------------------------------------------------------
+      !!                  ***  SUBROUTINE isf_tbl  ***
       !!
       !! ** Purpose : compute mean T/S/U/V in the boundary layer at T- point
       !!
-      !!----------------------------------------------------------------------
-      !!-------------------------- OUT -------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) :: pvarout ! 2d average of pvarin
-      !!-------------------------- IN  -------------------------------------
-      CHARACTER(len=1),                       INTENT(in   ) :: cd_ptin ! point of variable in/out
-      INTEGER,  DIMENSION(jpi,jpj), OPTIONAL, INTENT(in   ) :: ktop , kbot
-      REAL(wp), DIMENSION(jpi,jpj), OPTIONAL, INTENT(in   ) :: phtbl, pfrac
-      REAL(wp), DIMENSION(jpi,jpj,jpk),       INTENT(in   ) :: pvarin  ! 3d variable to average over the tbl
+      !!--------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj)          , INTENT(  out) :: pvarout ! 2d average of pvarin
+      !!-------------------------- IN  -------------------------------------
+      CHARACTER(len=1)                      , INTENT(in   ) :: cd_ptin       ! point of variable in/out
+      REAL(wp), DIMENSION(jpi,jpj,jpk)      , INTENT(in   ) :: pvarin        ! 3d variable to average over the tbl
+      !!-------------------------- IN OPTIONAL -----------------------------
+      INTEGER,  DIMENSION(jpi,jpj), OPTIONAL, INTENT(in   ) :: ktop , kbot   ! top and bottom level
+      REAL(wp), DIMENSION(jpi,jpj), OPTIONAL, INTENT(in   ) :: phtbl, pfrac  ! tbl thickness and fraction of bottom cell affected
       !!--------------------------------------------------------------------
       INTEGER ::   ji, jj                   ! loop index
@@ -34,5 +45,5 @@
       REAL(wp), DIMENSION(jpi,jpj) :: zhtbl ! thickness of the tbl
       REAL(wp), DIMENSION(jpi,jpj) :: zfrac ! thickness of the tbl
-      !!----------------------------------------------------------------------
+      !!--------------------------------------------------------------------
       ! 
       SELECT CASE ( cd_ptin )
@@ -86,21 +97,24 @@
 
    SUBROUTINE isf_tbl_avg( ktop, kbot, phtbl, pfrac, pe3, pvarin, pvarout )
-      !!---------------------------------------------------------------------
+      !!--------------------------------------------------------------------
       !!                  ***  ROUTINE isf_tbl_lvl  ***
       !!
       !! ** Purpose : compute mean property in the boundary layer
       !!
-      !!----------------------------------------------------------------------
-      !!-------------------------- OUT -------------------------------------
-      REAL(wp), DIMENSION(:,:)  , INTENT(  out) :: pvarout
-      !!-------------------------- IN  -------------------------------------
-      INTEGER,  DIMENSION(jpi,jpj), INTENT(in) :: ktop, kbot   ! top and bottom level of the top boundary layer
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: phtbl, pfrac !! fraction of bottom level of the tbl to be affected by the tbl
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) :: pe3      ! vertical scale factor
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) :: pvarin   ! tbl property to average between ktop, kbot over phtbl
-      !!---------------------------------------------------------------------
+      !! ** Method  : Depth average is made between the top level ktop and the bottom level kbot
+      !!              over a thickness phtbl. The bottom level is partially counted (pfrac).
+      !!
+      !!--------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(  out) :: pvarout      ! tbl property averaged over phtbl between level ktop and kbot
+      !!-------------------------- IN  -------------------------------------
+      INTEGER,  DIMENSION(jpi,jpj)    , INTENT(in   ) :: ktop, kbot   ! top and bottom level of the top boundary layer
+      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(in   ) :: phtbl, pfrac ! fraction of bottom level to be affected by the tbl
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) :: pe3          ! vertical scale factor
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) :: pvarin       ! tbl property to average between ktop, kbot over phtbl
+      !!--------------------------------------------------------------------
       INTEGER  :: ji,jj,jk                    ! loop indices
       INTEGER  :: ikt, ikb                    ! top and bottom levels
-      !!---------------------------------------------------------------------
+      !!--------------------------------------------------------------------
       !
       ! compute tbl top.bottom level and thickness
@@ -123,5 +137,5 @@
 
    SUBROUTINE isf_tbl_lvl( phw, pe3, ktop, kbot, phtbl, pfrac )
-      !!---------------------------------------------------------------------
+      !!--------------------------------------------------------------------
       !!                  ***  ROUTINE isf_tbl_lvl  ***
       !!
@@ -129,13 +143,13 @@
       !!              - thickness of the top boundary layer
       !!
-      !!----------------------------------------------------------------------
-      !!-------------------------- OUT -------------------------------------
-      INTEGER,  DIMENSION(jpi,jpj), INTENT(inout) :: kbot         ! bottom level of the top boundary layer
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: phtbl        ! top boundary layer thickness
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pfrac        ! top boundary layer thickness
-      !!-------------------------- IN  -------------------------------------
-      INTEGER,  DIMENSION(jpi,jpj)    , INTENT(in) :: ktop       ! top level of the top boundary layer
-      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(in) :: phw        ! water column thickness
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) :: pe3         ! vertical scale factor
+      !!--------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      INTEGER,  DIMENSION(jpi,jpj)    , INTENT(  out) :: kbot   ! bottom level of the top boundary layer
+      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(  out) :: phtbl  ! top boundary layer thickness
+      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(  out) :: pfrac  ! top boundary layer thickness
+      !!-------------------------- IN  -------------------------------------
+      INTEGER,  DIMENSION(jpi,jpj)    , INTENT(in   ) :: ktop   ! top level of the top boundary layer
+      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(in   ) :: phw    ! water column thickness
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) :: pe3    ! vertical scale factor
       !!---------------------------------------------------------------------
       INTEGER :: ji,jj,jk
@@ -178,18 +192,25 @@
    !
    SUBROUTINE isftbl_kbot(ktop, phtbl, pe3, kbot)
-      !!-------------------------- OUT -------------------------------------
-      INTEGER,  DIMENSION(jpi,jpj), INTENT(inout) :: kbot         ! bottom level of the top boundary layer
-      !!-------------------------- IN  -------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: phtbl           ! top boundary layer thickness
-      INTEGER,  DIMENSION(jpi,jpj), INTENT(in) :: ktop            ! top level of the top boundary layer
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) :: pe3         ! vertical scale factor
-      !!---------------------------------------------------------------------
+      !!--------------------------------------------------------------------
+      !!                  ***  ROUTINE isf_tbl_lvl  ***
+      !!
+      !! ** Purpose : compute bottom level of the isf top boundary layer
+      !!
+      !!--------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      INTEGER,  DIMENSION(jpi,jpj)    , INTENT(  out) :: kbot   ! bottom level of the top boundary layer
+      !!-------------------------- IN  -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(in   ) :: phtbl  ! top boundary layer thickness
+      INTEGER,  DIMENSION(jpi,jpj)    , INTENT(in   ) :: ktop   ! top level of the top boundary layer
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) :: pe3    ! vertical scale factor
+      !!--------------------------------------------------------------------
       INTEGER :: ji, jj
       INTEGER :: ikt, ikb
-      !!---------------------------------------------------------------------
+      !!--------------------------------------------------------------------
       !
       ! phtbl need to be bounded by water column thickness before
       ! test: if phtbl = water column thickness, should return mbathy
       ! test: if phtbl = 0 should return ktop
+      !
       ! get ktbl
       DO jj = 1,jpj
@@ -208,22 +229,24 @@
       !
    SUBROUTINE isftbl_ktop(pdep, ktop)
-      !!---------------------------------------------------------------------
+      !!--------------------------------------------------------------------
       !!                  ***  ROUTINE isf_tbl_lvl  ***
       !!
       !! ** Purpose : compute top level of the isf top boundary layer in case of an ice shelf parametrisation
       !!
-      !!----------------------------------------------------------------------
-      !!-------------------------- OUT -------------------------------------
-      INTEGER,  DIMENSION(jpi,jpj), INTENT(inout) :: ktop         ! top level affected by the ice shelf parametrisation
-      !!-------------------------- IN  -------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pdep            ! top depth of the parametrisation influence
-      !!---------------------------------------------------------------------
+      !!--------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      INTEGER,  DIMENSION(jpi,jpj), INTENT(  out) :: ktop        ! top level affected by the ice shelf parametrisation
+      !!-------------------------- IN  -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pdep        ! top depth of the parametrisation influence
+      !!--------------------------------------------------------------------
       INTEGER :: ji,jj
       INTEGER :: ikt
-      !!---------------------------------------------------------------------
+      !!--------------------------------------------------------------------
+      !
       ! compute top level (need to be recomputed each time (z*, z~) 
       ! be sure pdep is already correctly bounded
       ! test: this routine run on isfdraft should return mikt
       ! test: this routine run with pdep = 0 should return 1
+      !
       DO ji = 1, jpi
          DO jj = 1, jpj
@@ -234,5 +257,5 @@
       END DO
       !
-   END SUBROUTINE
+   END SUBROUTINE isftbl_ktop
 
 END MODULE isftbl
