Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/field_def_nemo-oce.xml
===================================================================
--- NEMO/trunk/cfgs/SHARED/field_def_nemo-oce.xml	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/field_def_nemo-oce.xml	(revision 11395)
@@ -264,20 +264,31 @@
 
           <!-- * variable related to ice shelf forcing * -->
-          <field id="fwfisf"       long_name="Ice shelf melting"                             unit="kg/m2/s"  />
-          <field id="fwfisf3d"     long_name="Ice shelf melting"                             unit="kg/m2/s"  grid_ref="grid_T_3D" />
-          <field id="qlatisf"      long_name="Ice shelf latent heat flux"                    unit="W/m2"     />
-          <field id="qlatisf3d"    long_name="Ice shelf latent heat flux"                    unit="W/m2"     grid_ref="grid_T_3D" />
-          <field id="qhcisf"       long_name="Ice shelf heat content flux"                   unit="W/m2"     />
-          <field id="qhcisf3d"     long_name="Ice shelf heat content flux"                   unit="W/m2"     grid_ref="grid_T_3D" />
-          <field id="isfgammat"    long_name="transfert coefficient for isf (temperature) "  unit="m/s"      />
-          <field id="isfgammas"    long_name="transfert coefficient for isf (salinity)    "  unit="m/s"      />
-          <field id="stbl"         long_name="salinity in the Losh tbl                    "  unit="PSU"      />
-          <field id="ttbl"         long_name="temperature in the Losh tbl                 "  unit="C"        />
-          <field id="utbl"         long_name="zonal current in the Losh tbl at T point    "  unit="m/s"      />
-          <field id="vtbl"         long_name="merid current in the Losh tbl at T point    "  unit="m/s"      />
-          <field id="thermald"     long_name="thermal driving of ice shelf melting        "  unit="C"        />
-          <field id="tfrz"         long_name="top freezing point (used to compute melt)   "  unit="C"        />
-          <field id="tinsitu"      long_name="top insitu temperature (used to cmpt melt)  "  unit="C"        />
-          <field id="ustar"        long_name="ustar at T point used in ice shelf melting  "  unit="m/s"      />
+          <field id="fwfisf_cav"      long_name="Ice shelf melting"                             unit="kg/m2/s"  />
+          <field id="fwfisf_par"      long_name="Ice shelf melting"                             unit="kg/m2/s"  />
+          <field id="qoceisf_cav"     long_name="Ice shelf ocean  heat flux"                    unit="W/m2"     />
+          <field id="qoceisf_par"     long_name="Ice shelf ocean  heat flux"                    unit="W/m2"     />
+          <field id="qlatisf_cav"     long_name="Ice shelf latent heat flux"                    unit="W/m2"     />
+          <field id="qlatisf_par"     long_name="Ice shelf latent heat flux"                    unit="W/m2"     />
+          <field id="qhcisf_cav"      long_name="Ice shelf heat content flux"                   unit="W/m2"     />
+          <field id="qhcisf_par"      long_name="Ice shelf heat content flux"                   unit="W/m2"     />
+          <field id="fwfisf3d_cav"    long_name="Ice shelf melting"                             unit="kg/m2/s"  grid_ref="grid_T_3D" />
+          <field id="fwfisf3d_par"    long_name="Ice shelf melting"                             unit="kg/m2/s"  grid_ref="grid_T_3D" />
+          <field id="qoceisf3d_cav"   long_name="Ice shelf ocean  heat flux"                    unit="W/m2"     grid_ref="grid_T_3D" />
+          <field id="qoceisf3d_par"   long_name="Ice shelf ocean  heat flux"                    unit="W/m2"     grid_ref="grid_T_3D" />
+          <field id="qlatisf3d_cav"   long_name="Ice shelf latent heat flux"                    unit="W/m2"     grid_ref="grid_T_3D" />
+          <field id="qlatisf3d_par"   long_name="Ice shelf latent heat flux"                    unit="W/m2"     grid_ref="grid_T_3D" />
+          <field id="qhcisf3d_cav"    long_name="Ice shelf heat content flux"                   unit="W/m2"     grid_ref="grid_T_3D" />
+          <field id="qhcisf3d_par"    long_name="Ice shelf heat content flux"                   unit="W/m2"     grid_ref="grid_T_3D" />
+          <field id="ttbl_cav"        long_name="temperature in the tracer sample depth      "  unit="C"        />
+          <field id="ttbl_par"        long_name="temperature in the tracer sample depth      "  unit="C"        />
+          <field id="isfthermald_cav" long_name="thermal driving of ice shelf melting        "  unit="C"        />
+          <field id="isfthermald_par" long_name="thermal driving of ice shelf melting        "  unit="C"        />
+          <field id="isfgammat"       long_name="transfert coefficient for isf (temperature) "  unit="m/s"      />
+          <field id="isfgammas"       long_name="transfert coefficient for isf (salinity)    "  unit="m/s"      />
+          <field id="stbl"            long_name="salinity in the Losh tbl                    "  unit="PSU"      />
+          <field id="utbl"            long_name="zonal current in the Losh tbl at T point    "  unit="m/s"      />
+          <field id="vtbl"            long_name="merid current in the Losh tbl at T point    "  unit="m/s"      />
+          <field id="isfustar"        long_name="ustar at T point used in ice shelf melting  "  unit="m/s"      />
+          <field id="qconisf"         long_name="Conductive heat flux through the ice shelf"    unit="W/m2"     />
 
           <!-- *_oce variables available with ln_blk_clio or ln_blk_core -->
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/namelist_ref
===================================================================
--- NEMO/trunk/cfgs/SHARED/namelist_ref	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/namelist_ref	(revision 11395)
@@ -52,5 +52,5 @@
       cn_ocerst_outdir = "."         !  directory in which to write output ocean restarts
    ln_iscpl    = .false.   !  cavity evolution forcing or coupling to ice sheet model
-   nn_istate   =       0   !  output the initial state (1) or not (0)
+   nn_istate   =       1   !  output the initial state (1) or not (0)
    ln_rst_list = .false.   !  output restarts at list of times using nn_stocklist (T) or at set frequency with nn_stock (F)
    nn_stock    =    5840   !  frequency of creation of a restart file (modulo referenced to 1)
@@ -68,5 +68,4 @@
 !-----------------------------------------------------------------------
    ln_linssh   = .false.   !  =T  linear free surface  ==>>  model level are fixed in time
-   rn_isfhmin  =    1.00   !  treshold [m] to discriminate grounding ice from floating ice
    !
    rn_rdt      = 5400.     !  time step for the dynamics and tracer
@@ -75,5 +74,5 @@
    ln_crs      = .false.   !  Logical switch for coarsening module      (T => fill namcrs)
    !
-   ln_meshmask = .false.   !  =T create a mesh file
+   ln_meshmask = .true.   !  =T create a mesh file
 /
 !-----------------------------------------------------------------------
@@ -180,5 +179,4 @@
 !!   namsbc_rnf      river runoffs                                      (ln_rnf     =T)
 !!   namsbc_apr      Atmospheric Pressure                               (ln_apr_dyn =T)
-!!   namsbc_isf      ice shelf melting/freezing                         (ln_isfcav  =T : read (ln_read_cfg=T) or set or usr_def_zgr )
 !!   namsbc_iscpl    coupling option between land ice model and ocean   (ln_isfcav  =T)
 !!   namsbc_wave     external fields from wave model                    (ln_wave    =T)
@@ -436,36 +434,49 @@
 /
 !-----------------------------------------------------------------------
-&namsbc_isf    !  Top boundary layer (ISF)                              (ln_isfcav =T : read (ln_read_cfg=T) 
-!-----------------------------------------------------------------------             or set or usr_def_zgr )
+&namisf       !  Top boundary layer (ISF)                              (ln_isf = T .AND. ln_isfcav: read (ln_read_cfg=T) 
+!-----------------------------------------------------------------------                         or set or usr_def_zgr )
    !                 ! type of top boundary layer 
-   nn_isf      = 1         !  ice shelf melting/freezing
-                           !  1 = presence of ISF   ;  2 = bg03 parametrisation 
-                           !  3 = rnf file for ISF  ;  4 = ISF specified freshwater flux
-                           !  options 1 and 4 need ln_isfcav = .true. (domzgr)
-      !              !  nn_isf = 1 or 2 cases:
+   ln_isfcav_mlt = .false.    ! ice shelf melting into the cavity
+      cn_isfcav_mlt = '3eq'   ! ice shelf melting formulation (spe/2eq/3eq/oasis)
+      !                       ! spe = fwfisf is read from a forcing field
+      !                       ! 2eq = ISOMIP  like: 2 equations formulation (Hunter et al., 2006)
+      !                       ! 3eq = ISOMIP+ like: 3 equations formulation (Asay-Davis et al., 2015)
+      !                       ! oasis = fwfisf is given by oasis
+      !              !  cn_isfcav_mlt = 2eq or 3eq cases:
+      cn_gammablk = 'ad15'    ! scheme to compute gammat/s (spe,ad15,hj99)
+      !                       ! ad15 = velocity dependend Gamma (u* * gammat/s)  (Jenkins et al. 2010)
+      !                       ! hj99 = velocity and stability dependent Gamma    (Holland et al. 1999)
       rn_gammat0  = 1.e-4     ! gammat coefficient used in blk formula
       rn_gammas0  = 1.e-4     ! gammas coefficient used in blk formula
-      !              !  nn_isf = 1 or 4 cases:
-      rn_hisf_tbl =  30.      ! thickness of the top boundary layer    (Losh et al. 2008)
+      !
+      rn_htbl     =  30.      ! thickness of the top boundary layer    (Losh et al. 2008)
       !                       ! 0 => thickness of the tbl = thickness of the first wet cell
-      !              ! nn_isf = 1 case
-      nn_isfblk   = 1         ! 1 ISOMIP  like: 2 equations formulation (Hunter et al., 2006)
-      !                       ! 2 ISOMIP+ like: 3 equations formulation (Asay-Davis et al., 2015)
-      nn_gammablk = 1         ! 0 = cst Gammat (= gammat/s)
-      !                       ! 1 = velocity dependend Gamma (u* * gammat/s)  (Jenkins et al. 2010)
-      !                       ! 2 = velocity and stability dependent Gamma    (Holland et al. 1999)
-
-   !___________!_____________!___________________!___________!_____________!_________!___________!__________!__________!_______________!
-   !           !  file name  ! frequency (hours) ! variable  ! time interp.!  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
-   !           !             !  (if <0  months)  !   name    !  (logical)  !  (T/F)  ! 'monthly' ! filename ! pairing  ! filename      !
-!* nn_isf = 4 case
-   sn_fwfisf   = 'rnfisf'    ,         -12       ,'sowflisf' ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
-!* nn_isf = 3 case
-   sn_rnfisf   = 'rnfisf'    ,         -12       ,'sofwfisf' ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
-!* nn_isf = 2 and 3 cases 
-   sn_depmax_isf ='rnfisf'    ,         -12       ,'sozisfmax',  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
-   sn_depmin_isf ='rnfisf'    ,         -12       ,'sozisfmin',  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
-!* nn_isf = 2 case
-   sn_Leff_isf = 'rnfisf'    ,         -12       ,'Leff'     ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
+      !
+      !* 'spe' and 'oasis' case
+      !___________!_____________!___________________!___________!_____________!_________!___________!__________!__________!_______________!
+      !           !  file name  ! frequency (hours) ! variable  ! time interp.!  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+      !           !             !  (if <0  months)  !   name    !  (logical)  !  (T/F)  ! 'monthly' ! filename ! pairing  ! filename      !
+      sn_isfcav_fwf = 'isfmlt_cav',      -12       , 'fwflisf' ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
+      !
+   !
+   ln_isfpar_mlt = .false.   ! ice shelf melting parametrised
+      cn_isfpar_mlt = 'spe'  ! ice shelf melting parametrisation (spe/bg03/oasis)
+      !
+      !* all cases
+      !___________!_____________!___________________!___________!_____________!_________!___________!__________!__________!_______________!
+      !           !  file name  ! frequency (hours) ! variable  ! time interp.!  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+      !           !             !  (if <0  months)  !   name    !  (logical)  !  (T/F)  ! 'monthly' ! filename ! pairing  ! filename      !
+      sn_isfpar_zmax = 'isfmlt_par',       0        ,'sozisfmax',  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
+      sn_isfpar_zmin = 'isfmlt_par',       0        ,'sozisfmin',  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
+      !* 'spe' and 'oasis' case
+      sn_isfpar_fwf = 'isfmlt_par' ,      -12       ,'fwfisf'   ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
+      !* 'bg03' case
+      sn_isfpar_Leff = 'isfmlt_par',       0        ,'Leff'     ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
+      !
+   !
+   !ln_iscpl = .false.
+   !   nn_drown    = 10        ! number of iteration of the extrapolation loop (fill the new wet cells)
+   !   ln_hsb      = .false.   ! activate conservation module (conservation exact after a time of rn_fiscpl)
+   !   nn_fiscpl   = 43800     ! (number of time step) conservation period (maybe should be fix to the coupling frequencey of restart frequency)
 /
 !-----------------------------------------------------------------------
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdyvol.F90
===================================================================
--- NEMO/trunk/src/OCE/BDY/bdyvol.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdyvol.F90	(revision 11395)
@@ -16,5 +16,5 @@
    USE dom_oce        ! ocean space and time domain 
    USE phycst         ! physical constants
-   USE sbcisf         ! ice shelf
+   USE isf            ! ice shelf
    !
    USE in_out_manager ! I/O manager
@@ -77,5 +77,5 @@
       ! Calculate the cumulate surface Flux z_cflxemp (m3/s) over all the domain
       ! -----------------------------------------------------------------------
-      IF ( kc == 1 ) z_cflxemp = glob_sum( 'bdyvol', ( emp(:,:) - rnf(:,:) + fwfisf(:,:) ) * bdytmask(:,:) * e1e2t(:,:)  ) / rau0
+      IF ( kc == 1 ) z_cflxemp = glob_sum( 'bdyvol', ( emp(:,:) - rnf(:,:) + fwfisf_cav(:,:) + fwfisf_par(:,:) ) * bdytmask(:,:) * e1e2t(:,:)  ) / rau0
 
       ! Compute bdy surface each cycle if non linear free surface
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diahsb.F90
===================================================================
--- NEMO/trunk/src/OCE/DIA/diahsb.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diahsb.F90	(revision 11395)
@@ -18,5 +18,5 @@
    USE sbc_oce        ! surface thermohaline fluxes
    USE sbcrnf         ! river runoff
-   USE sbcisf         ! ice shelves
+   USE isf            ! ice shelves
    USE domvvl         ! vertical scale factors
    USE traqsr         ! penetrative solar radiation
@@ -91,5 +91,5 @@
       ! 1 - Trends due to forcing !
       ! ------------------------- !
-      z_frc_trd_v = r1_rau0 * glob_sum( 'diahsb', - ( emp(:,:) - rnf(:,:) + fwfisf(:,:) ) * surf(:,:) )   ! volume fluxes
+      z_frc_trd_v = r1_rau0 * glob_sum( 'diahsb', - ( emp(:,:) - rnf(:,:) + fwfisf_cav(:,:) + fwfisf_par(:,:) ) * surf(:,:) )   ! volume fluxes
       z_frc_trd_t =           glob_sum( 'diahsb', sbc_tsc(:,:,jp_tem) * surf(:,:) )                       ! heat fluxes
       z_frc_trd_s =           glob_sum( 'diahsb', sbc_tsc(:,:,jp_sal) * surf(:,:) )                       ! salt fluxes
@@ -98,5 +98,6 @@
       IF( ln_rnf_sal)   z_frc_trd_s = z_frc_trd_s + glob_sum( 'diahsb', rnf_tsc(:,:,jp_sal) * surf(:,:) )
       !                    ! Add ice shelf heat & salt input
-      IF( ln_isf    )   z_frc_trd_t = z_frc_trd_t + glob_sum( 'diahsb', risf_tsc(:,:,jp_tem) * surf(:,:) )
+      IF( ln_isf    )   z_frc_trd_t = z_frc_trd_t &
+         &                          + glob_sum( 'diahsb', ( risf_cav_tsc(:,:,jp_tem) + risf_par_tsc(:,:,jp_tem) ) * surf(:,:) )
       !                    ! Add penetrative solar radiation
       IF( ln_traqsr )   z_frc_trd_t = z_frc_trd_t + r1_rau0_rcp * glob_sum( 'diahsb', qsr     (:,:) * surf(:,:) )
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diawri.F90
===================================================================
--- NEMO/trunk/src/OCE/DIA/diawri.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diawri.F90	(revision 11395)
@@ -26,4 +26,5 @@
    !!----------------------------------------------------------------------
    USE oce            ! ocean dynamics and tracers 
+   USE isf
    USE dom_oce        ! ocean space and time domain
    USE phycst         ! physical constants
@@ -904,4 +905,15 @@
       CALL iom_rstput( 0, 0, inum, 'vomecrty', vn                )    ! now j-velocity
       CALL iom_rstput( 0, 0, inum, 'vovecrtz', wn                )    ! now k-velocity
+      CALL iom_rstput( 0, 0, inum, 'risfdep', risfdep          )    ! now k-velocity
+      CALL iom_rstput( 0, 0, inum, 'fwfisf_cav', fwfisf_cav          )    ! now k-velocity
+      CALL iom_rstput( 0, 0, inum, 'rhisf_cav_tbl', rhisf_tbl_cav    )    ! now k-velocity
+      CALL iom_rstput( 0, 0, inum, 'rfrac_cav_tbl', rfrac_tbl_cav    )    ! now k-velocity
+      CALL iom_rstput( 0, 0, inum, 'misfkb_cav', REAL(misfkb_cav,8)    )    ! now k-velocity
+      CALL iom_rstput( 0, 0, inum, 'misfkt_cav', REAL(misfkt_cav,8)    )    ! now k-velocity
+      CALL iom_rstput( 0, 0, inum, 'fwfisf_par', fwfisf_par          )    ! now k-velocity
+      CALL iom_rstput( 0, 0, inum, 'rhisf_par_tbl', rhisf_tbl_par    )    ! now k-velocity
+      CALL iom_rstput( 0, 0, inum, 'rfrac_par_tbl', rfrac_tbl_par    )    ! now k-velocity
+      CALL iom_rstput( 0, 0, inum, 'misfkb_par', REAL(misfkb_par,8)    )    ! now k-velocity
+      CALL iom_rstput( 0, 0, inum, 'misfkt_par', REAL(misfkt_par,8)    )    ! now k-velocity
       IF( ALLOCATED(ahtu) ) THEN
          CALL iom_rstput( 0, 0, inum,  'ahtu', ahtu              )    ! aht at u-point
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/dom_oce.F90
===================================================================
--- NEMO/trunk/src/OCE/DOM/dom_oce.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/dom_oce.F90	(revision 11395)
@@ -32,5 +32,4 @@
    LOGICAL , PUBLIC ::   ln_linssh      !: =T  linear free surface ==>> model level are fixed in time
    LOGICAL , PUBLIC ::   ln_meshmask    !: =T  create a mesh-mask file (mesh_mask.nc)
-   REAL(wp), PUBLIC ::   rn_isfhmin     !: threshold to discriminate grounded ice to floating ice
    REAL(wp), PUBLIC ::   rn_rdt         !: time step for the dynamics and tracer
    REAL(wp), PUBLIC ::   rn_atfp        !: asselin time filter parameter
@@ -170,7 +169,5 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   tmask_h            !: internal domain T-point mask (Figure 8.5 NEMO book)
 
-   INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   misfdep                 !: top first ocean level             (ISF)
-   INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   mikt, miku, mikv, mikf  !: top first wet T-, U-, V-, F-level (ISF)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   risfdep                 !: Iceshelf draft                    (ISF)
+   INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   mikt, miku, mikv, mikf  !: top first wet T-, U-, V-, F-level           (ISF)
 
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ssmask, ssumask, ssvmask             !: surface mask at T-,U-, V- and F-pts
@@ -281,6 +278,5 @@
          &      mbkt   (jpi,jpj) , mbku   (jpi,jpj) , mbkv   (jpi,jpj) , STAT=ierr(9) )
          !
-      ALLOCATE( misfdep(jpi,jpj) , mikt(jpi,jpj) , miku(jpi,jpj) ,     &
-         &      risfdep(jpi,jpj) , mikv(jpi,jpj) , mikf(jpi,jpj) , STAT=ierr(10) )
+      ALLOCATE( mikt(jpi,jpj), miku(jpi,jpj), mikv(jpi,jpj), mikf(jpi,jpj), STAT=ierr(10) )
          !
       ALLOCATE( tmask(jpi,jpj,jpk) , umask(jpi,jpj,jpk) ,     & 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/domain.F90
===================================================================
--- NEMO/trunk/src/OCE/DOM/domain.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/domain.F90	(revision 11395)
@@ -140,11 +140,4 @@
                                        ! Read in masks to define closed seas and lakes 
       !
-      DO jj = 1, jpj                   ! depth of the iceshelves
-         DO ji = 1, jpi
-            ik = mikt(ji,jj)
-            risfdep(ji,jj) = gdepw_0(ji,jj,ik)
-         END DO
-      END DO
-      !
       ht_0(:,:) = 0._wp  ! Reference ocean thickness
       hu_0(:,:) = 0._wp
@@ -293,5 +286,5 @@
          &             nn_stock, nn_write , ln_mskland  , ln_clobber   , nn_chunksz, nn_euler  ,     &
          &             ln_cfmeta, ln_iscpl, ln_xios_read, nn_wxios
-      NAMELIST/namdom/ ln_linssh, rn_isfhmin, rn_rdt, rn_atfp, ln_crs, ln_meshmask
+      NAMELIST/namdom/ ln_linssh, rn_rdt, rn_atfp, ln_crs, ln_meshmask
 #if defined key_netcdf4
       NAMELIST/namnc4/ nn_nchunks_i, nn_nchunks_j, nn_nchunks_k, ln_nc4zip
@@ -412,5 +405,4 @@
          WRITE(numout,*) '      linear free surface (=T)                ln_linssh   = ', ln_linssh
          WRITE(numout,*) '      create mesh/mask file                   ln_meshmask = ', ln_meshmask
-         WRITE(numout,*) '      treshold to open the isf cavity         rn_isfhmin  = ', rn_isfhmin, ' [m]'
          WRITE(numout,*) '      ocean time step                         rn_rdt      = ', rn_rdt
          WRITE(numout,*) '      asselin time filter parameter           rn_atfp     = ', rn_atfp
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/domwri.F90
===================================================================
--- NEMO/trunk/src/OCE/DOM/domwri.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/domwri.F90	(revision 11395)
@@ -16,4 +16,5 @@
    !!   dom_stiff      : diagnose maximum grid stiffness/hydrostatic consistency (s-coordinate)
    !!----------------------------------------------------------------------
+   USE isf             ! ice shelf
    USE dom_oce         ! ocean space and time domain
    USE phycst ,   ONLY :   rsmall
@@ -155,10 +156,8 @@
       
       ! note that mbkt is set to 1 over land ==> use surface tmask
-      zprt(:,:) = ssmask(:,:) * REAL( mbkt(:,:) , wp )
+      zprt(:,:) = REAL( mbkt(:,:) , wp )
       CALL iom_rstput( 0, 0, inum, 'mbathy', zprt, ktype = jp_i4 )     !    ! nb of ocean T-points
-      zprt(:,:) = ssmask(:,:) * REAL( mikt(:,:) , wp )
+      zprt(:,:) = REAL( mikt(:,:) , wp )
       CALL iom_rstput( 0, 0, inum, 'misf', zprt, ktype = jp_i4 )       !    ! nb of ocean T-points
-      zprt(:,:) = ssmask(:,:) * REAL( risfdep(:,:) , wp )
-      CALL iom_rstput( 0, 0, inum, 'isfdraft', zprt, ktype = jp_r8 )   !    ! nb of ocean T-points
       !															             ! vertical mesh
       CALL iom_rstput( 0, 0, inum, 'e3t_0', e3t_0, ktype = jp_r8  )    !    ! scale factors
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/divhor.F90
===================================================================
--- NEMO/trunk/src/OCE/DYN/divhor.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/divhor.F90	(revision 11395)
@@ -22,5 +22,5 @@
    USE sbc_oce, ONLY : ln_rnf, ln_isf ! surface boundary condition: ocean
    USE sbcrnf          ! river runoff 
-   USE sbcisf          ! ice shelf
+   USE isfhdiv         ! ice shelf
    USE iscplhsb        ! ice sheet / ocean coupling
    USE iscplini        ! ice sheet / ocean coupling
@@ -100,7 +100,5 @@
       ! 
 #endif
-      IF( ln_isf )   CALL sbc_isf_div( hdivn )      !==  ice shelf  ==!   (update hdivn field)
-      !
-      IF( ln_iscpl .AND. ln_hsb )   CALL iscpl_div( hdivn ) !==  ice sheet  ==!   (update hdivn field)
+      IF( ln_isf )   CALL isf_hdiv( hdivn )      !==  ice shelf  ==!   (update hdivn field)
       !
       CALL lbc_lnk( 'divhor', hdivn, 'T', 1. )   !   (no sign change)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynhpg.F90
===================================================================
--- NEMO/trunk/src/OCE/DYN/dynhpg.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynhpg.F90	(revision 11395)
@@ -31,4 +31,5 @@
    !!----------------------------------------------------------------------
    USE oce             ! ocean dynamics and tracers
+   USE isf             ! ice shelf
    USE sbc_oce         ! surface variable (only for the flag with ice shelf)
    USE dom_oce         ! ocean space and time domain
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynnxt.F90
===================================================================
--- NEMO/trunk/src/OCE/DYN/dynnxt.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynnxt.F90	(revision 11395)
@@ -29,5 +29,5 @@
    USE sbc_oce        ! Surface boundary condition: ocean fields
    USE sbcrnf         ! river runoffs
-   USE sbcisf         ! ice shelf
+   USE isfnxt
    USE phycst         ! physical constants
    USE dynadv         ! dynamics: vector invariant versus flux form
@@ -241,20 +241,7 @@
                ENDIF
             END IF
-
-            IF ( ln_isf ) THEN   ! if ice shelf melting
-               DO jk = 1, jpkm1 ! Deal with isf separetely, as can be through depth too
-                  DO jj = 1, jpj
-                     DO ji = 1, jpi
-                        IF( misfkt(ji,jj) <=jk .and. jk < misfkb(ji,jj)  ) THEN
-                           e3t_b(ji,jj,jk) = e3t_b(ji,jj,jk) - zcoef * ( fwfisf_b(ji,jj) - fwfisf(ji,jj) ) &
-                                &          * ( e3t_n(ji,jj,jk) * r1_hisf_tbl(ji,jj) ) * tmask(ji,jj,jk)
-                        ELSEIF ( jk==misfkb(ji,jj) ) THEN
-                           e3t_b(ji,jj,jk) = e3t_b(ji,jj,jk) - zcoef * ( fwfisf_b(ji,jj) - fwfisf(ji,jj) ) &
-                                &          * ( e3t_n(ji,jj,jk) * r1_hisf_tbl(ji,jj) ) * ralpha(ji,jj) * tmask(ji,jj,jk)
-                        ENDIF
-                     END DO
-                  END DO
-               END DO
-            END IF
+            !
+            ! ice shelf melting
+            IF ( ln_isf ) CALL isf_dynnxt( zcoef )
             !
             IF( ln_dynadv_vec ) THEN      ! Asselin filter applied on velocity
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynspg_ts.F90
===================================================================
--- NEMO/trunk/src/OCE/DYN/dynspg_ts.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynspg_ts.F90	(revision 11395)
@@ -33,5 +33,5 @@
    USE zdf_oce         ! vertical physics: variables
    USE zdfdrg          ! vertical physics: top/bottom drag coef.
-   USE sbcisf          ! ice shelf variable (fwfisf)
+   USE isf             ! ice shelf variable (fwfisf)
    USE sbcapr          ! surface boundary condition: atmospheric pressure
    USE dynadv    , ONLY: ln_dynadv_vec
@@ -632,9 +632,10 @@
       !                                         ! Surface net water flux and rivers
       IF (ln_bt_fw) THEN
-         zssh_frc(:,:) = r1_rau0 * ( emp(:,:) - rnf(:,:) + fwfisf(:,:) )
+         zssh_frc(:,:) = r1_rau0 * ( emp(:,:) - rnf(:,:) + fwfisf_cav(:,:) + fwfisf_par(:,:) )
       ELSE
          zztmp = r1_rau0 * r1_2
          zssh_frc(:,:) = zztmp * (  emp(:,:) + emp_b(:,:) - rnf(:,:) - rnf_b(:,:)   &
-                &                 + fwfisf(:,:) + fwfisf_b(:,:)                     )
+                &                 + fwfisf_cav(:,:) + fwfisf_cav_b(:,:)             &
+                &                 + fwfisf_par(:,:) + fwfisf_par_b(:,:)             )
       ENDIF
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/sshwzv.F90
===================================================================
--- NEMO/trunk/src/OCE/DYN/sshwzv.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/sshwzv.F90	(revision 11395)
@@ -17,4 +17,5 @@
    !!----------------------------------------------------------------------
    USE oce            ! ocean dynamics and tracers variables
+   USE isf            ! ice shelf
    USE dom_oce        ! ocean space and time domain variables 
    USE sbc_oce        ! surface boundary condition: ocean
@@ -256,5 +257,6 @@
             sshb(:,:) = sshb(:,:) - zcoef * (     emp_b(:,:) - emp   (:,:)   &
                &                             -    rnf_b(:,:) + rnf   (:,:)   &
-               &                             + fwfisf_b(:,:) - fwfisf(:,:)   ) * ssmask(:,:)
+               &                             + fwfisf_cav_b(:,:) - fwfisf_cav(:,:)   &
+               &                             + fwfisf_par_b(:,:) - fwfisf_par(:,:)   ) * ssmask(:,:)
          ENDIF
          sshn(:,:) = ssha(:,:)                              ! now <-- after
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/iscplhsb.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/iscplhsb.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/iscplhsb.F90	(revision 11395)
@@ -0,0 +1,324 @@
+MODULE iscplhsb
+   !!======================================================================
+   !!                       ***  MODULE  iscplhsb  ***
+   !! Ocean forcing: ice sheet/ocean coupling (conservation)
+   !!=====================================================================
+   !! History :  NEMO  ! 2015-01 P. Mathiot: original 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   iscpl_alloc    : variable allocation
+   !!   iscpl_hsb      : compute and store the input of heat/salt/volume 
+   !!                    into the system due to the coupling process
+   !!   iscpl_div      : correction of divergence to keep volume conservation
+   !!----------------------------------------------------------------------
+   USE oce             ! global tra/dyn variable
+   USE dom_oce         ! ocean space and time domain
+   USE domwri          ! ocean space and time domain
+   USE domngb          ! 
+   USE phycst          ! physical constants
+   USE sbc_oce         ! surface boundary condition variables
+   USE iscplini        ! 
+   !
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
+   USE lib_fortran     ! MPP library
+   USE lbclnk          !
+
+   IMPLICIT NONE
+   PRIVATE
+   
+   PUBLIC   iscpl_div   
+   PUBLIC   iscpl_cons       
+   !! * Substitutions  
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE iscpl_cons(ptmask_b, psmask_b, pe3t_b, pts_flx, pvol_flx, prdt_iscpl)
+      !!---------------------------------------------------------------------- 
+      !!                   ***  ROUTINE iscpl_cons  ***
+      !! 
+      !! ** Purpose :   compute input into the system during the coupling step
+      !!                compute the correction term
+      !!                compute where the correction have to be applied
+      !! 
+      !! ** Method  :   compute tsn*e3t-tsb*e3tb and e3t-e3t_b
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:,:,:  ), INTENT(in ) :: ptmask_b    !! mask before
+      REAL(wp), DIMENSION(:,:,:  ), INTENT(in ) :: pe3t_b      !! scale factor before
+      REAL(wp), DIMENSION(:,:    ), INTENT(in ) :: psmask_b    !! mask before
+      REAL(wp), DIMENSION(:,:,:,:), INTENT(out) :: pts_flx     !! corrective flux to have tracer conservation
+      REAL(wp), DIMENSION(:,:,:  ), INTENT(out) :: pvol_flx    !! corrective flux to have volume conservation
+      REAL(wp),                     INTENT(in ) :: prdt_iscpl  !! coupling period 
+      !
+      INTEGER  ::   ji  , jj  , jk           ! loop index
+      INTEGER  ::   jip1, jim1, jjp1, jjm1
+      REAL(wp) ::   summsk, zsum , zsumn, zjip1_ratio  , zjim1_ratio, zdtem, zde3t, z1_rdtiscpl
+      REAL(wp) ::   zarea , zsum1, zsumb, zjjp1_ratio  , zjjm1_ratio, zdsal
+      REAL(wp), DIMENSION(jpi,jpj)        ::   zdssh   ! workspace
+      REAL(wp), DIMENSION(:), ALLOCATABLE ::   zlon, zlat
+      REAL(wp), DIMENSION(:), ALLOCATABLE ::   zcorr_vol, zcorr_tem, zcorr_sal
+      INTEGER , DIMENSION(:), ALLOCATABLE ::   ixpts, iypts, izpts, inpts
+      INTEGER :: jpts, npts
+      !!----------------------------------------------------------------------
+
+      ! get imbalance (volume heat and salt)
+      ! initialisation difference
+      zde3t = 0._wp   ;   zdsal = 0._wp   ;   zdtem = 0._wp
+
+      ! initialisation correction term
+      pvol_flx(:,:,:  ) = 0._wp
+      pts_flx (:,:,:,:) = 0._wp
+      
+      z1_rdtiscpl = 1._wp / prdt_iscpl 
+
+      ! mask tsn and tsb 
+      tsb(:,:,:,jp_tem) = tsb(:,:,:,jp_tem) * ptmask_b(:,:,:)
+      tsn(:,:,:,jp_tem) = tsn(:,:,:,jp_tem) *  tmask  (:,:,:)
+      tsb(:,:,:,jp_sal) = tsb(:,:,:,jp_sal) * ptmask_b(:,:,:)
+      tsn(:,:,:,jp_sal) = tsn(:,:,:,jp_sal) *  tmask  (:,:,:)
+
+      !==============================================================================
+      ! diagnose the heat, salt and volume input and compute the correction variable
+      !==============================================================================
+
+      ! 
+      zdssh(:,:) = sshn(:,:) * ssmask(:,:) - sshb(:,:) * psmask_b(:,:)
+      IF (.NOT. ln_linssh ) zdssh = 0.0_wp ! already included in the levels by definition
+      
+      DO jk = 1,jpk-1
+         DO jj = 2,jpj-1
+            DO ji = fs_2,fs_jpim1
+               IF (tmask_h(ji,jj) == 1._wp) THEN
+
+                  ! volume differences
+                  zde3t = e3t_n(ji,jj,jk) * tmask(ji,jj,jk) - pe3t_b(ji,jj,jk) * ptmask_b(ji,jj,jk)
+
+                  ! heat diff
+                  zdtem = tsn(ji,jj,jk,jp_tem) * e3t_n(ji,jj,jk) *  tmask  (ji,jj,jk)   &
+                        - tsb(ji,jj,jk,jp_tem) * pe3t_b (ji,jj,jk) * ptmask_b(ji,jj,jk)
+                  ! salt diff
+                  zdsal = tsn(ji,jj,jk,jp_sal) * e3t_n(ji,jj,jk) *  tmask  (ji,jj,jk)   &
+                        - tsb(ji,jj,jk,jp_sal) * pe3t_b (ji,jj,jk) * ptmask_b(ji,jj,jk)
+               
+                  ! shh changes
+                  IF ( ptmask_b(ji,jj,jk) == 1._wp .OR. tmask(ji,jj,jk) == 1._wp ) THEN 
+                     zde3t = zde3t + zdssh(ji,jj) ! zdssh = 0 if vvl
+                     zdssh(ji,jj) = 0._wp
+                  END IF
+
+                  ! volume, heat and salt differences in each cell 
+                  pvol_flx(ji,jj,jk)       =   pvol_flx(ji,jj,jk)        + zde3t * z1_rdtiscpl
+                  pts_flx (ji,jj,jk,jp_sal)=   pts_flx (ji,jj,jk,jp_sal) + zdsal * z1_rdtiscpl 
+                  pts_flx (ji,jj,jk,jp_tem)=   pts_flx (ji,jj,jk,jp_tem) + zdtem * z1_rdtiscpl
+
+                  ! case where we close a cell: check if the neighbour cells are wet 
+                  IF ( tmask(ji,jj,jk) == 0._wp .AND. ptmask_b(ji,jj,jk) == 1._wp ) THEN
+
+                     jip1=ji+1 ; jim1=ji-1 ; jjp1=jj+1 ; jjm1=jj-1 ;
+
+                     zsum =   e1e2t(ji  ,jjp1) * tmask(ji  ,jjp1,jk) + e1e2t(ji  ,jjm1) * tmask(ji  ,jjm1,jk) &
+                       &    + e1e2t(jim1,jj  ) * tmask(jim1,jj  ,jk) + e1e2t(jip1,jj  ) * tmask(jip1,jj  ,jk)
+
+                     IF ( zsum /= 0._wp ) THEN
+                        zjip1_ratio   = e1e2t(jip1,jj  ) * tmask(jip1,jj  ,jk) / zsum
+                        zjim1_ratio   = e1e2t(jim1,jj  ) * tmask(jim1,jj  ,jk) / zsum
+                        zjjp1_ratio   = e1e2t(ji  ,jjp1) * tmask(ji  ,jjp1,jk) / zsum
+                        zjjm1_ratio   = e1e2t(ji  ,jjm1) * tmask(ji  ,jjm1,jk) / zsum
+
+                        pvol_flx(ji  ,jjp1,jk       ) = pvol_flx(ji  ,jjp1,jk       ) + pvol_flx(ji,jj,jk       ) * zjjp1_ratio
+                        pvol_flx(ji  ,jjm1,jk       ) = pvol_flx(ji  ,jjm1,jk       ) + pvol_flx(ji,jj,jk       ) * zjjm1_ratio
+                        pvol_flx(jip1,jj  ,jk       ) = pvol_flx(jip1,jj  ,jk       ) + pvol_flx(ji,jj,jk       ) * zjip1_ratio
+                        pvol_flx(jim1,jj  ,jk       ) = pvol_flx(jim1,jj  ,jk       ) + pvol_flx(ji,jj,jk       ) * zjim1_ratio
+                        pts_flx (ji  ,jjp1,jk,jp_sal) = pts_flx (ji  ,jjp1,jk,jp_sal) + pts_flx (ji,jj,jk,jp_sal) * zjjp1_ratio
+                        pts_flx (ji  ,jjm1,jk,jp_sal) = pts_flx (ji  ,jjm1,jk,jp_sal) + pts_flx (ji,jj,jk,jp_sal) * zjjm1_ratio
+                        pts_flx (jip1,jj  ,jk,jp_sal) = pts_flx (jip1,jj  ,jk,jp_sal) + pts_flx (ji,jj,jk,jp_sal) * zjip1_ratio
+                        pts_flx (jim1,jj  ,jk,jp_sal) = pts_flx (jim1,jj  ,jk,jp_sal) + pts_flx (ji,jj,jk,jp_sal) * zjim1_ratio
+                        pts_flx (ji  ,jjp1,jk,jp_tem) = pts_flx (ji  ,jjp1,jk,jp_tem) + pts_flx (ji,jj,jk,jp_tem) * zjjp1_ratio
+                        pts_flx (ji  ,jjm1,jk,jp_tem) = pts_flx (ji  ,jjm1,jk,jp_tem) + pts_flx (ji,jj,jk,jp_tem) * zjjm1_ratio
+                        pts_flx (jip1,jj  ,jk,jp_tem) = pts_flx (jip1,jj  ,jk,jp_tem) + pts_flx (ji,jj,jk,jp_tem) * zjip1_ratio
+                        pts_flx (jim1,jj  ,jk,jp_tem) = pts_flx (jim1,jj  ,jk,jp_tem) + pts_flx (ji,jj,jk,jp_tem) * zjim1_ratio
+
+                        ! set to 0 the cell we distributed over neigbourg cells
+                        pvol_flx(ji,jj,jk       ) = 0._wp
+                        pts_flx (ji,jj,jk,jp_sal) = 0._wp
+                        pts_flx (ji,jj,jk,jp_tem) = 0._wp
+
+                     ELSE IF (zsum == 0._wp ) THEN
+                        ! case where we close a cell and no adjacent cell open
+                        ! check if the cell beneath is wet
+                        IF ( tmask(ji,jj,jk+1) == 1._wp ) THEN
+                           pvol_flx(ji,jj,jk+1)       =  pvol_flx(ji,jj,jk+1)        + pvol_flx(ji,jj,jk)
+                           pts_flx (ji,jj,jk+1,jp_sal)=  pts_flx (ji,jj,jk+1,jp_sal) + pts_flx (ji,jj,jk,jp_sal)
+                           pts_flx (ji,jj,jk+1,jp_tem)=  pts_flx (ji,jj,jk+1,jp_tem) + pts_flx (ji,jj,jk,jp_tem)
+
+                           ! set to 0 the cell we distributed over neigbourg cells
+                           pvol_flx(ji,jj,jk       ) = 0._wp
+                           pts_flx (ji,jj,jk,jp_sal) = 0._wp
+                           pts_flx (ji,jj,jk,jp_tem) = 0._wp
+                        ELSE
+                        ! case no adjacent cell on the horizontal and on the vertical
+                           IF ( lwp ) THEN   ! JMM : cAution this warning may occur on any mpp subdomain but numout is only
+                                             ! open for narea== 1 (lwp=T)
+                           WRITE(numout,*) 'W A R N I N G iscpl: no adjacent cell on the vertical and horizontal'
+                           WRITE(numout,*) '                     ',mig(ji),' ',mjg(jj),' ',jk
+                           WRITE(numout,*) '                     ',ji,' ',jj,' ',jk,' ',narea
+                           WRITE(numout,*) ' we are now looking for the closest wet cell on the horizontal '
+                           ENDIF
+                        ! We deal with these points later.
+                        END IF
+                     END IF
+                  END IF
+               END IF
+            END DO
+         END DO
+      END DO
+
+!!gm  ERROR !!!!
+!!    juste use tmask_i  or in case of ISF smask_i (to be created to compute the sum without halos)
+!
+!      CALL lbc_sum(pvol_flx(:,:,:       ),'T',1.)
+!      CALL lbc_sum(pts_flx (:,:,:,jp_sal),'T',1.)
+!      CALL lbc_sum(pts_flx (:,:,:,jp_tem),'T',1.)
+      STOP ' iscpl_cons:   please modify this module !'
+!!gm end
+      ! if no neighbour wet cell in case of 2close a cell", need to find the nearest wet point 
+      ! allocation and initialisation of the list of problematic point
+      ALLOCATE( inpts(jpnij) )
+      inpts(:) = 0
+
+      ! fill narea location with the number of problematic point
+      DO jk = 1,jpk-1
+         DO jj = 2,jpj-1
+            DO ji = fs_2,fs_jpim1
+               IF (     ptmask_b(ji,jj,jk) == 1._wp .AND. tmask(ji,jj,jk+1)  == 0._wp .AND. tmask_h(ji,jj) == 1._wp  &
+                  .AND. SUM(tmask(ji-1:ji+1,jj,jk)) + SUM(tmask(ji,jj-1:jj+1,jk)) == 0._wp) THEN
+                  inpts(narea) = inpts(narea) + 1 
+               END IF
+            END DO
+         END DO
+      END DO
+
+      ! build array of total problematic point on each cpu (share to each cpu)
+      CALL mpp_max('iscplhsb', inpts,jpnij) 
+
+      ! size of the new variable
+      npts  = SUM(inpts)    
+      
+      ! allocation of the coordinates, correction, index vector for the problematic points 
+      ALLOCATE(ixpts(npts), iypts(npts), izpts(npts), zcorr_vol(npts), zcorr_sal(npts), zcorr_tem(npts), zlon(npts), zlat(npts))
+      ixpts(:) = -9999 ; iypts(:) = -9999 ; izpts(:) = -9999 ; zlon(:) = -1.0e20_wp ; zlat(:) = -1.0e20_wp
+      zcorr_vol(:) = -1.0e20_wp
+      zcorr_sal(:) = -1.0e20_wp
+      zcorr_tem(:) = -1.0e20_wp
+
+      ! fill new variable
+      jpts = SUM(inpts(1:narea-1))
+      DO jk = 1,jpk-1
+         DO jj = 2,jpj-1
+            DO ji = fs_2,fs_jpim1
+               IF (     ptmask_b(ji,jj,jk) == 1._wp .AND. tmask(ji,jj,jk+1)  == 0._wp .AND. tmask_h(ji,jj) == 1._wp  &
+                  .AND. SUM(tmask(ji-1:ji+1,jj,jk)) + SUM(tmask(ji,jj-1:jj+1,jk)) == 0._wp) THEN
+                  jpts = jpts + 1  ! positioning in the inpts vector for the area narea
+                  ixpts(jpts) = ji           ; iypts(jpts) = jj ; izpts(jpts) = jk
+                  zlon (jpts) = glamt(ji,jj) ; zlat (jpts) = gphit(ji,jj)
+                  zcorr_vol(jpts) = pvol_flx(ji,jj,jk)
+                  zcorr_sal(jpts) = pts_flx (ji,jj,jk,jp_sal)
+                  zcorr_tem(jpts) = pts_flx (ji,jj,jk,jp_tem)
+
+                  ! set flx to 0 (safer)
+                  pvol_flx(ji,jj,jk       ) = 0.0_wp
+                  pts_flx (ji,jj,jk,jp_sal) = 0.0_wp
+                  pts_flx (ji,jj,jk,jp_tem) = 0.0_wp
+               END IF
+            END DO
+         END DO
+      END DO
+
+      ! build array of total problematic point on each cpu (share to each cpu)
+      ! point coordinates
+      CALL mpp_max('iscplhsb', zlat ,npts)
+      CALL mpp_max('iscplhsb', zlon ,npts)
+      CALL mpp_max('iscplhsb', izpts,npts)
+
+      ! correction values 
+      CALL mpp_max('iscplhsb', zcorr_vol,npts)
+      CALL mpp_max('iscplhsb', zcorr_sal,npts)
+      CALL mpp_max('iscplhsb', zcorr_tem,npts)
+
+      ! put correction term in the closest cell          
+      DO jpts = 1,npts
+         CALL dom_ngb(zlon(jpts), zlat(jpts), ixpts(jpts), iypts(jpts),'T', izpts(jpts))
+         DO jj = mj0(iypts(jpts)),mj1(iypts(jpts))
+            DO ji = mi0(ixpts(jpts)),mi1(ixpts(jpts))
+               jk = izpts(jpts)
+
+               IF (tmask_h(ji,jj) == 1._wp) THEN
+                  ! correct the vol_flx in the closest cell
+                  pvol_flx(ji,jj,jk)        =  pvol_flx(ji,jj,jk       ) + zcorr_vol(jpts)
+                  pts_flx (ji,jj,jk,jp_sal) =  pts_flx (ji,jj,jk,jp_sal) + zcorr_sal(jpts)
+                  pts_flx (ji,jj,jk,jp_tem) =  pts_flx (ji,jj,jk,jp_tem) + zcorr_tem(jpts)
+
+                  ! set correction to 0
+                  zcorr_vol(jpts) = 0.0_wp
+                  zcorr_sal(jpts) = 0.0_wp
+                  zcorr_tem(jpts) = 0.0_wp
+               END IF
+            END DO
+         END DO
+      END DO
+
+      ! deallocate variables 
+      DEALLOCATE(inpts)
+      DEALLOCATE(ixpts, iypts, izpts, zcorr_vol, zcorr_sal, zcorr_tem, zlon, zlat)
+    
+      ! add contribution store on the hallo (lbclnk remove one of the contribution)
+      pvol_flx(:,:,:       ) = pvol_flx(:,:,:       ) * tmask(:,:,:)
+      pts_flx (:,:,:,jp_sal) = pts_flx (:,:,:,jp_sal) * tmask(:,:,:)
+      pts_flx (:,:,:,jp_tem) = pts_flx (:,:,:,jp_tem) * tmask(:,:,:)
+
+!!gm  ERROR !!!!
+!!    juste use tmask_i  or in case of ISF smask_i (to be created to compute the sum without halos)
+!
+!      ! compute sum over the halo and set it to 0.
+!      CALL lbc_sum(pvol_flx(:,:,:       ),'T',1._wp)
+!      CALL lbc_sum(pts_flx (:,:,:,jp_sal),'T',1._wp)
+!      CALL lbc_sum(pts_flx (:,:,:,jp_tem),'T',1._wp)
+!!gm end
+
+      !
+   END SUBROUTINE iscpl_cons
+
+
+   SUBROUTINE iscpl_div( phdivn )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE iscpl_div  ***
+      !!
+      !! ** Purpose :   update the horizontal divergenc
+      !!
+      !! ** Method  :
+      !!                CAUTION : iscpl is positive (inflow) and expressed in m/s
+      !!
+      !! ** Action  :   phdivn   increase by the iscpl correction term
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   phdivn   ! horizontal divergence
+      !!
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      !!----------------------------------------------------------------------
+      !
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               phdivn(ji,jj,jk) = phdivn(ji,jj,jk) + hdiv_iscpl(ji,jj,jk) / e3t_n(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE iscpl_div
+
+END MODULE iscplhsb
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/iscplini.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/iscplini.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/iscplini.F90	(revision 11395)
@@ -0,0 +1,89 @@
+MODULE iscplini
+   !!======================================================================
+   !!                       ***  MODULE  sbciscpl  ***
+   !! Ocean forcing:  ?????
+   !!=====================================================================
+   !! History :  NEMO  ! 2015-01 P. Mathiot: original 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   iscpl_init     : initialisation routine (namelist)
+   !!   iscpl_alloc    : allocation of correction variables
+   !!----------------------------------------------------------------------
+   USE oce             ! global tra/dyn variable
+   USE dom_oce         ! ocean space and time domain
+   !
+   USE lib_mpp         ! MPP library
+   USE lib_fortran     ! MPP library
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+   
+   PUBLIC   iscpl_init      
+   PUBLIC   iscpl_alloc 
+   !                                 !!* namsbc_iscpl namelist *
+   LOGICAL , PUBLIC ::   ln_iscpl_hsb !:
+   INTEGER , PUBLIC ::   nn_fiscpl    !:
+   INTEGER , PUBLIC ::   nn_drown     !:
+   ! 
+   INTEGER , PUBLIC ::   nstp_iscpl   !:
+   REAL(wp), PUBLIC ::   rdt_iscpl    !: 
+   !
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   hdiv_iscpl   !:
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   htsc_iscpl   !:
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   INTEGER FUNCTION iscpl_alloc()
+      !!----------------------------------------------------------------------
+      !!                ***  ROUTINE sbc_iscpl_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( htsc_iscpl(jpi,jpj,jpk,jpts) , hdiv_iscpl(jpi,jpj,jpk) , STAT=iscpl_alloc )
+         !
+      CALL mpp_sum ( 'iscplini', iscpl_alloc )
+      IF( iscpl_alloc > 0 )   CALL ctl_warn('iscpl_alloc: allocation of arrays failed')
+   END FUNCTION iscpl_alloc
+
+
+   SUBROUTINE iscpl_init()
+      !!----------------------------------------------------------------------
+      !!----------------------------------------------------------------------
+      INTEGER ::   ios           ! Local integer output status for namelist read
+      NAMELIST/namsbc_iscpl/ nn_fiscpl, ln_iscpl_hsb, nn_drown
+      !!----------------------------------------------------------------------
+      !
+      nn_fiscpl = 0
+      ln_iscpl_hsb    = .FALSE.
+      REWIND( numnam_ref )              ! Namelist namsbc_iscpl in reference namelist : Ice sheet coupling
+      READ  ( numnam_ref, namsbc_iscpl, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_iscpl in reference namelist', lwp )
+      REWIND( numnam_cfg )              ! Namelist namsbc_iscpl in configuration namelist : Ice Sheet coupling
+      READ  ( numnam_cfg, namsbc_iscpl, IOSTAT = ios, ERR = 902 )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_iscpl in configuration namelist', lwp )
+      IF(lwm) WRITE ( numond, namsbc_iscpl )
+      !
+      nstp_iscpl=MIN( nn_fiscpl, nitend-nit000+1 ) ! the coupling period have to be less or egal than the total number of time step
+      rdt_iscpl = nstp_iscpl * rn_rdt
+      !
+      IF (lwp) THEN
+         WRITE(numout,*) 'iscpl_rst:'
+         WRITE(numout,*) '~~~~~~~~~'
+         WRITE(numout,*) ' coupling     flag (ln_iscpl    )            = ', ln_iscpl
+         WRITE(numout,*) ' conservation flag (ln_iscpl_hsb)            = ', ln_iscpl_hsb
+         WRITE(numout,*) ' nb of stp for cons (rn_fiscpl  )            = ', nstp_iscpl
+         IF (nstp_iscpl .NE. nn_fiscpl) WRITE(numout,*) 'W A R N I N G: nb of stp for cons has been modified &
+            &                                           (larger than run length)'
+         WRITE(numout,*) ' coupling time step                       = ', rdt_iscpl
+         WRITE(numout,*) ' number of call of the extrapolation loop = ', nn_drown
+      ENDIF
+      !
+   END SUBROUTINE iscpl_init
+
+   !!======================================================================
+END MODULE iscplini
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/iscplrst.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/iscplrst.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/iscplrst.F90	(revision 11395)
@@ -0,0 +1,407 @@
+MODULE iscplrst
+   !!======================================================================
+   !!                       ***  MODULE  iscplrst  ***
+   !! Ocean forcing: update the restart file in case of ice sheet/ocean coupling
+   !!=====================================================================
+   !! History :  NEMO  ! 2015-01 P. Mathiot: original 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   iscpl_stp          : step management
+   !!   iscpl_rst_interpol : restart interpolation in case of coupling with ice sheet
+   !!----------------------------------------------------------------------
+   USE oce             ! global tra/dyn variable
+   USE dom_oce         ! ocean space and time domain
+   USE domwri          ! ocean space and time domain
+   USE domvvl   , ONLY : dom_vvl_interpol
+   USE phycst          ! physical constants
+   USE sbc_oce         ! surface boundary condition variables
+   USE iscplini        ! ice sheet coupling: initialisation
+   USE iscplhsb        ! ice sheet coupling: conservation
+   !
+   USE in_out_manager  ! I/O manager
+   USE iom             ! I/O module
+   USE lib_mpp         ! MPP library
+   USE lib_fortran     ! MPP library
+   USE lbclnk          ! communication
+
+   IMPLICIT NONE
+   PRIVATE
+   
+   PUBLIC   iscpl_stp          ! step management 
+   !!
+   !! * Substitutions  
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE iscpl_stp
+      !!---------------------------------------------------------------------- 
+      !!                   ***  ROUTINE iscpl_stp  ***
+      !! 
+      !! ** Purpose : compute initialisation
+      !!              compute extrapolation of restart variable un, vn, tsn, sshn (wetting/drying)   
+      !!              compute correction term if needed
+      !! 
+      !!----------------------------------------------------------------------
+      INTEGER  ::   inum0
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zsmask_b
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztmask_b, zumask_b, zvmask_b
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ze3t_b  , ze3u_b  , ze3v_b  
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zdepw_b
+      CHARACTER(20) :: cfile
+      !!----------------------------------------------------------------------
+      !
+      !                       ! get restart variable
+      CALL iom_get( numror, jpdom_autoglo, 'tmask'  , ztmask_b, ldxios = lrxios   ) ! need to extrapolate T/S
+      CALL iom_get( numror, jpdom_autoglo, 'umask'  , zumask_b, ldxios = lrxios   ) ! need to correct barotropic velocity
+      CALL iom_get( numror, jpdom_autoglo, 'vmask'  , zvmask_b, ldxios = lrxios   ) ! need to correct barotropic velocity
+      CALL iom_get( numror, jpdom_autoglo, 'smask'  , zsmask_b, ldxios = lrxios   ) ! need to correct barotropic velocity
+      CALL iom_get( numror, jpdom_autoglo, 'e3t_n'  , ze3t_b(:,:,:), ldxios = lrxios )  ! need to compute temperature correction
+      CALL iom_get( numror, jpdom_autoglo, 'e3u_n'  , ze3u_b(:,:,:), ldxios = lrxios )  ! need to correct barotropic velocity
+      CALL iom_get( numror, jpdom_autoglo, 'e3v_n'  , ze3v_b(:,:,:), ldxios = lrxios )  ! need to correct barotropic velocity
+      CALL iom_get( numror, jpdom_autoglo, 'gdepw_n', zdepw_b(:,:,:), ldxios = lrxios ) ! need to interpol vertical profile (vvl)
+      !
+      CALL iscpl_init()       ! read namelist
+      !                       ! Extrapolation/interpolation of modify cell and new cells ... (maybe do it later after domvvl)
+      CALL iscpl_rst_interpol( ztmask_b, zumask_b, zvmask_b, zsmask_b, ze3t_b, ze3u_b, ze3v_b, zdepw_b )
+      !
+      IF ( ln_iscpl_hsb ) THEN      ! compute correction if conservation needed
+         IF( iscpl_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'rst_iscpl : unable to allocate rst_iscpl arrays' )
+         CALL iscpl_cons(ztmask_b, zsmask_b, ze3t_b, htsc_iscpl, hdiv_iscpl, rdt_iscpl)
+      END IF
+         
+      !                       ! create  a domain file
+      IF( ln_meshmask .AND. ln_iscpl )   CALL dom_wri
+      !
+      IF ( ln_iscpl_hsb ) THEN
+         cfile='correction'
+         cfile = TRIM( cfile )
+         CALL iom_open  ( cfile, inum0, ldwrt = .TRUE. )
+         CALL iom_rstput( 0, 0, inum0, 'vol_cor', hdiv_iscpl(:,:,:) )
+         CALL iom_rstput( 0, 0, inum0, 'tem_cor', htsc_iscpl(:,:,:,jp_tem) )
+         CALL iom_rstput( 0, 0, inum0, 'sal_cor', htsc_iscpl(:,:,:,jp_sal) )
+         CALL iom_close ( inum0 )
+      END IF
+      !
+      neuler = 0              ! next step is an euler time step
+      !
+      !                       ! set _b and _n variables equal
+      tsb (:,:,:,:) = tsn (:,:,:,:)
+      ub  (:,:,:)   = un  (:,:,:)
+      vb  (:,:,:)   = vn  (:,:,:)
+      sshb(:,:)     = sshn(:,:)
+      !
+      !                       ! set _b and _n vertical scale factor equal
+      e3t_b (:,:,:) = e3t_n (:,:,:)
+      e3u_b (:,:,:) = e3u_n (:,:,:)
+      e3v_b (:,:,:) = e3v_n (:,:,:)
+      !
+      e3uw_b (:,:,:) = e3uw_n (:,:,:)
+      e3vw_b (:,:,:) = e3vw_n (:,:,:)
+      gdept_b(:,:,:) = gdept_n(:,:,:)
+      gdepw_b(:,:,:) = gdepw_n(:,:,:)
+      hu_b   (:,:)   = hu_n   (:,:)
+      hv_b   (:,:)   = hv_n   (:,:)
+      r1_hu_b(:,:)   = r1_hu_n(:,:)
+      r1_hv_b(:,:)   = r1_hv_n(:,:)
+      !
+   END SUBROUTINE iscpl_stp
+
+
+   SUBROUTINE iscpl_rst_interpol (ptmask_b, pumask_b, pvmask_b, psmask_b, pe3t_b, pe3u_b, pe3v_b, pdepw_b)
+      !!---------------------------------------------------------------------- 
+      !!                   ***  ROUTINE iscpl_rst_interpol  ***
+      !! 
+      !! ** Purpose :   compute new tn, sn, un, vn and sshn in case of evolving geometry of ice shelves 
+      !!                compute 2d fields of heat, salt and volume correction
+      !! 
+      !! ** Method  :   tn, sn : extrapolation from neigbourg cells
+      !!                un, vn : fill with 0 velocity and keep barotropic transport by modifing surface velocity or adjacent velocity
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:,:,:  ), INTENT(in ) :: ptmask_b, pumask_b, pvmask_b    !! mask before
+      REAL(wp), DIMENSION(:,:,:  ), INTENT(in ) :: pe3t_b  , pe3u_b  , pe3v_b      !! scale factor before
+      REAL(wp), DIMENSION(:,:,:  ), INTENT(in ) :: pdepw_b                         !! depth w before
+      REAL(wp), DIMENSION(:,:    ), INTENT(in ) :: psmask_b                        !! mask before
+      !!
+      INTEGER :: ji, jj, jk, iz          !! loop index
+      INTEGER :: jip1, jim1, jjp1, jjm1, jkp1, jkm1
+      !!
+      REAL(wp):: summsk, zsum, zsum1, zarea, zsumn, zsumb
+      REAL(wp):: zdz, zdzm1, zdzp1
+      !!
+      REAL(wp), DIMENSION(jpi,jpj)          :: zdmask , zsmask0, zucorr, zbub, zbun, zssh0, zhu1, zde3t
+      REAL(wp), DIMENSION(jpi,jpj)          :: zdsmask, zsmask1, zvcorr, zbvb, zbvn, zssh1, zhv1
+      REAL(wp), DIMENSION(jpi,jpj,jpk)      :: ztmask0, zwmaskn, ztrp
+      REAL(wp), DIMENSION(jpi,jpj,jpk)      :: ztmask1, zwmaskb, ztmp3d
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts) :: zts0
+      !!----------------------------------------------------------------------
+      !
+      !                 ! mask value to be sure
+      tsn(:,:,:,jp_tem) = tsn(:,:,:,jp_tem) * ptmask_b(:,:,:)
+      tsn(:,:,:,jp_sal) = tsn(:,:,:,jp_sal) * ptmask_b(:,:,:)
+      !
+      !                 ! compute wmask
+      zwmaskn(:,:,1) = tmask   (:,:,1)
+      zwmaskb(:,:,1) = ptmask_b(:,:,1)
+      DO jk = 2,jpk
+         zwmaskn(:,:,jk) =  tmask  (:,:,jk) *  tmask  (:,:,jk-1)
+         zwmaskb(:,:,jk) = ptmask_b(:,:,jk) * ptmask_b(:,:,jk-1)
+      END DO
+      !    
+      !                 ! compute new ssh if we open a full water column (average of the closest neigbourgs)  
+      sshb (:,:)=sshn(:,:)
+      zssh0(:,:)=sshn(:,:)
+      zsmask0(:,:) = psmask_b(:,:)
+      zsmask1(:,:) = psmask_b(:,:)
+      DO iz = 1, 10                 ! need to be tuned (configuration dependent) (OK for ISOMIP+)
+         zdsmask(:,:) = ssmask(:,:)-zsmask0(:,:)
+         DO jj = 2,jpj-1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               jip1=ji+1; jim1=ji-1;
+               jjp1=jj+1; jjm1=jj-1;
+               summsk=(zsmask0(jip1,jj)+zsmask0(jim1,jj)+zsmask0(ji,jjp1)+zsmask0(ji,jjm1))
+               IF (zdsmask(ji,jj) == 1._wp .AND. summsk /= 0._wp) THEN
+                  sshn(ji,jj)=( zssh0(jip1,jj)*zsmask0(jip1,jj)     &
+                  &           + zssh0(jim1,jj)*zsmask0(jim1,jj)     &
+                  &           + zssh0(ji,jjp1)*zsmask0(ji,jjp1)     &
+                  &           + zssh0(ji,jjm1)*zsmask0(ji,jjm1))/summsk
+                  zsmask1(ji,jj)=1._wp
+               ENDIF
+            END DO
+         END DO
+         CALL lbc_lnk_multi( 'iscplrst', sshn, 'T', 1., zsmask1, 'T', 1. )
+         zssh0   = sshn
+         zsmask0 = zsmask1
+      END DO
+      sshn(:,:) = sshn(:,:) * ssmask(:,:)
+
+!=============================================================================
+!PM: Is this needed since introduction of VVL by default?
+      IF ( .NOT.ln_linssh ) THEN
+      ! Reconstruction of all vertical scale factors at now time steps
+      ! =============================================================================
+      ! Horizontal scale factor interpolations
+      ! --------------------------------------
+         DO jk = 1,jpk
+            DO jj=1,jpj
+               DO ji=1,jpi
+                  IF (tmask(ji,jj,1) == 0._wp .OR. ptmask_b(ji,jj,1) == 0._wp) THEN
+                     e3t_n(ji,jj,jk) = e3t_0(ji,jj,jk) * ( 1._wp + sshn(ji,jj) /   &
+                     &   ( ht_0(ji,jj) + 1._wp - ssmask(ji,jj) ) * tmask(ji,jj,jk) )
+                  ENDIF
+               END DO
+            END DO
+         END DO
+         !
+         CALL dom_vvl_interpol( e3t_n(:,:,:), e3u_n(:,:,:), 'U' )
+         CALL dom_vvl_interpol( e3t_n(:,:,:), e3v_n(:,:,:), 'V' )
+         CALL dom_vvl_interpol( e3u_n(:,:,:), e3f_n(:,:,:), 'F' )
+
+         ! Vertical scale factor interpolations
+         ! ------------------------------------
+         CALL dom_vvl_interpol( e3t_n(:,:,:), e3w_n (:,:,:), 'W'  )
+         CALL dom_vvl_interpol( e3u_n(:,:,:), e3uw_n(:,:,:), 'UW' )
+         CALL dom_vvl_interpol( e3v_n(:,:,:), e3vw_n(:,:,:), 'VW' )
+         
+         ! t- and w- points depth
+         ! ----------------------
+         gdept_n(:,:,1) = 0.5_wp * e3w_n(:,:,1)
+         gdepw_n(:,:,1) = 0.0_wp
+         gde3w_n(:,:,1) = gdept_n(:,:,1) - sshn(:,:)
+         DO jj = 1,jpj
+            DO ji = 1,jpi
+               DO jk = 2,mikt(ji,jj)-1
+                  gdept_n(ji,jj,jk) = gdept_0(ji,jj,jk)
+                  gdepw_n(ji,jj,jk) = gdepw_0(ji,jj,jk)
+                  gde3w_n(ji,jj,jk) = gdept_0(ji,jj,jk) - sshn(ji,jj)
+               END DO
+               IF (mikt(ji,jj) > 1) THEN
+                  jk = mikt(ji,jj)
+                  gdept_n(ji,jj,jk) = gdepw_0(ji,jj,jk) + 0.5_wp * e3w_n(ji,jj,jk)
+                  gdepw_n(ji,jj,jk) = gdepw_0(ji,jj,jk)
+                  gde3w_n(ji,jj,jk) = gdept_n(ji,jj,jk  ) - sshn   (ji,jj)
+               END IF
+               DO jk = mikt(ji,jj)+1, jpk
+                  gdept_n(ji,jj,jk) = gdept_n(ji,jj,jk-1) + e3w_n(ji,jj,jk)
+                  gdepw_n(ji,jj,jk) = gdepw_n(ji,jj,jk-1) + e3t_n(ji,jj,jk-1)
+                  gde3w_n(ji,jj,jk) = gdept_n(ji,jj,jk  ) - sshn (ji,jj)
+               END DO
+            END DO
+         END DO
+
+      ! t-, u- and v- water column thickness
+      ! ------------------------------------
+         ht_n(:,:) = 0._wp ; hu_n(:,:) = 0._wp ; hv_n(:,:) = 0._wp
+         DO jk = 1, jpkm1
+            hu_n(:,:) = hu_n(:,:) + e3u_n(:,:,jk) * umask(:,:,jk)
+            hv_n(:,:) = hv_n(:,:) + e3v_n(:,:,jk) * vmask(:,:,jk)
+            ht_n(:,:) = ht_n(:,:) + e3t_n(:,:,jk) * tmask(:,:,jk)
+         END DO
+         !                                        ! Inverse of the local depth
+         r1_hu_n(:,:) = 1._wp / ( hu_n(:,:) + 1._wp - ssumask(:,:) ) * ssumask(:,:)
+         r1_hv_n(:,:) = 1._wp / ( hv_n(:,:) + 1._wp - ssvmask(:,:) ) * ssvmask(:,:)
+
+      END IF
+
+!=============================================================================
+! compute velocity
+! compute velocity in order to conserve barotropic velocity (modification by poderation of the scale factor).
+      ub(:,:,:)=un(:,:,:)
+      vb(:,:,:)=vn(:,:,:)
+      DO jk = 1,jpk
+         DO jj = 1,jpj
+            DO ji = 1,jpi
+               un(ji,jj,jk) = ub(ji,jj,jk)*pe3u_b(ji,jj,jk)*pumask_b(ji,jj,jk)/e3u_n(ji,jj,jk)*umask(ji,jj,jk);
+               vn(ji,jj,jk) = vb(ji,jj,jk)*pe3v_b(ji,jj,jk)*pvmask_b(ji,jj,jk)/e3v_n(ji,jj,jk)*vmask(ji,jj,jk);
+            END DO
+         END DO
+      END DO
+
+! compute new velocity if we close a cell (check barotropic velocity and change velocity over the water column)
+! compute barotropic velocity now and after 
+      ztrp(:,:,:) = ub(:,:,:)*pe3u_b(:,:,:); 
+      zbub(:,:)   = SUM(ztrp,DIM=3)
+      ztrp(:,:,:) = vb(:,:,:)*pe3v_b(:,:,:); 
+      zbvb(:,:)   = SUM(ztrp,DIM=3)
+      ztrp(:,:,:) = un(:,:,:)*e3u_n(:,:,:); 
+      zbun(:,:)   = SUM(ztrp,DIM=3)
+      ztrp(:,:,:) = vn(:,:,:)*e3v_n(:,:,:); 
+      zbvn(:,:)   = SUM(ztrp,DIM=3)
+
+      ! new water column
+      zhu1=0.0_wp ;
+      zhv1=0.0_wp ;
+      DO jk  = 1,jpk
+        zhu1(:,:) = zhu1(:,:) + e3u_n(:,:,jk) * umask(:,:,jk)
+        zhv1(:,:) = zhv1(:,:) + e3v_n(:,:,jk) * vmask(:,:,jk)
+      END DO
+      
+      ! compute correction      
+      zucorr = 0._wp
+      zvcorr = 0._wp
+      DO jj = 1,jpj
+         DO ji = 1,jpi
+            IF (zbun(ji,jj) /= zbub(ji,jj) .AND. zhu1(ji,jj) /= 0._wp ) THEN
+               zucorr(ji,jj) = (zbun(ji,jj) - zbub(ji,jj))/zhu1(ji,jj)
+            END IF
+            IF (zbvn(ji,jj) /= zbvb(ji,jj) .AND. zhv1(ji,jj) /= 0._wp ) THEN
+               zvcorr(ji,jj) = (zbvn(ji,jj) - zbvb(ji,jj))/zhv1(ji,jj)
+            END IF
+         END DO
+      END DO 
+      
+      ! update velocity
+      DO jk  = 1,jpk
+         un(:,:,jk)=(un(:,:,jk) - zucorr(:,:))*umask(:,:,jk)
+         vn(:,:,jk)=(vn(:,:,jk) - zvcorr(:,:))*vmask(:,:,jk)
+      END DO
+
+!=============================================================================
+      ! compute temp and salt
+      ! compute new tn and sn if we open a new cell
+      tsb (:,:,:,:) = tsn(:,:,:,:)
+      zts0(:,:,:,:) = tsn(:,:,:,:)
+      ztmask1(:,:,:) = ptmask_b(:,:,:)
+      ztmask0(:,:,:) = ptmask_b(:,:,:)
+      DO iz = 1,nn_drown ! resolution dependent (OK for ISOMIP+ case)
+          DO jk = 1,jpk-1
+              zdmask=tmask(:,:,jk)-ztmask0(:,:,jk);
+              DO jj = 2,jpj-1
+                 DO ji = fs_2,fs_jpim1
+                      jip1=ji+1; jim1=ji-1;
+                      jjp1=jj+1; jjm1=jj-1;
+                      summsk= (ztmask0(jip1,jj  ,jk)+ztmask0(jim1,jj  ,jk)+ztmask0(ji  ,jjp1,jk)+ztmask0(ji  ,jjm1,jk))
+                      IF (zdmask(ji,jj) == 1._wp .AND. summsk /= 0._wp) THEN
+                      !! horizontal basic extrapolation
+                         tsn(ji,jj,jk,1)=( zts0(jip1,jj  ,jk,1)*ztmask0(jip1,jj  ,jk) &
+                         &                +zts0(jim1,jj  ,jk,1)*ztmask0(jim1,jj  ,jk) &
+                         &                +zts0(ji  ,jjp1,jk,1)*ztmask0(ji  ,jjp1,jk) &
+                         &                +zts0(ji  ,jjm1,jk,1)*ztmask0(ji  ,jjm1,jk) ) / summsk
+                         tsn(ji,jj,jk,2)=( zts0(jip1,jj  ,jk,2)*ztmask0(jip1,jj  ,jk) &
+                         &                +zts0(jim1,jj  ,jk,2)*ztmask0(jim1,jj  ,jk) &
+                         &                +zts0(ji  ,jjp1,jk,2)*ztmask0(ji  ,jjp1,jk) &
+                         &                +zts0(ji  ,jjm1,jk,2)*ztmask0(ji  ,jjm1,jk) ) / summsk
+                         ztmask1(ji,jj,jk)=1
+                      ELSEIF (zdmask(ji,jj) == 1._wp .AND. summsk == 0._wp) THEN
+                      !! vertical extrapolation if horizontal extrapolation failed
+                         jkm1=max(1,jk-1) ; jkp1=min(jpk,jk+1)
+                         summsk=(ztmask0(ji,jj,jkm1)+ztmask0(ji,jj,jkp1))
+                         IF (zdmask(ji,jj) == 1._wp .AND. summsk /= 0._wp ) THEN
+                            tsn(ji,jj,jk,1)=( zts0(ji,jj,jkp1,1)*ztmask0(ji,jj,jkp1)     &
+                            &                +zts0(ji,jj,jkm1,1)*ztmask0(ji,jj,jkm1))/summsk
+                            tsn(ji,jj,jk,2)=( zts0(ji,jj,jkp1,2)*ztmask0(ji,jj,jkp1)     &
+                            &                +zts0(ji,jj,jkm1,2)*ztmask0(ji,jj,jkm1))/summsk
+                            ztmask1(ji,jj,jk)=1._wp
+                         END IF
+                      END IF
+                  END DO
+              END DO
+          END DO
+          
+          CALL lbc_lnk_multi( 'iscplrst', tsn(:,:,:,jp_tem), 'T', 1., tsn(:,:,:,jp_sal), 'T', 1., ztmask1, 'T', 1.)
+
+          ! update
+          zts0(:,:,:,:) = tsn(:,:,:,:)
+          ztmask0 = ztmask1
+
+      END DO
+
+      ! mask new tsn field
+      tsn(:,:,:,jp_tem) = tsn(:,:,:,jp_tem) * tmask(:,:,:)
+      tsn(:,:,:,jp_sal) = tsn(:,:,:,jp_sal) * tmask(:,:,:)
+
+      ! compute new T/S (interpolation) if vvl only for common wet cell in before and after wmask
+      !PM: Is this IF needed since change to VVL by default
+      IF (.NOT.ln_linssh) THEN
+         DO jk = 2,jpk-1
+            DO jj = 1,jpj
+               DO ji = 1,jpi
+                  IF (zwmaskn(ji,jj,jk) * zwmaskb(ji,jj,jk) == 1._wp .AND.   &
+                  &      (tmask(ji,jj,1)==0._wp .OR. ptmask_b(ji,jj,1)==0._wp) ) THEN
+                     !compute weight
+                     zdzp1 = MAX(0._wp,gdepw_n(ji,jj,jk+1) - pdepw_b(ji,jj,jk+1))
+                     zdz   =           gdepw_n(ji,jj,jk+1) - pdepw_b(ji,jj,jk  ) 
+                     zdzm1 = MAX(0._wp,pdepw_b(ji,jj,jk  ) - gdepw_n(ji,jj,jk  ))
+                     IF (zdz .LT. 0._wp) THEN 
+                        CALL ctl_stop( 'STOP', 'rst_iscpl : unable to compute the interpolation' )
+                     END IF
+                     tsn(ji,jj,jk,jp_tem) = ( zdzp1*tsb(ji,jj,jk+1,jp_tem)      &
+                        &                   + zdz  *tsb(ji,jj,jk  ,jp_tem)      &
+                        &                   + zdzm1*tsb(ji,jj,jk-1,jp_tem)      )/e3t_n(ji,jj,jk)
+                     tsn(ji,jj,jk,jp_sal) = ( zdzp1*tsb(ji,jj,jk+1,jp_sal)      &
+                        &                   + zdz  *tsb(ji,jj,jk  ,jp_sal)      &
+                        &                   + zdzm1*tsb(ji,jj,jk-1,jp_sal)      )/e3t_n(ji,jj,jk)
+                  END IF
+               END DO
+            END DO
+         END DO               
+      END IF
+
+      ! closed pool
+      ! -----------------------------------------------------------------------------------------
+      ! case we open a cell but no neigbour cells available to get an estimate of T and S
+      WHERE (tmask(:,:,:) == 1._wp .AND. tsn(:,:,:,2) == 0._wp) 
+         tsn(:,:,:,2) = -99._wp  ! Special value for closed pool (checking purpose in output.init)
+         tmask(:,:,:) = 0._wp    ! set mask to 0 to run
+         umask(:,:,:) = 0._wp
+         vmask(:,:,:) = 0._wp
+      END WHERE
+      
+      ! set mbkt and mikt to 1 in thiese location
+      WHERE (SUM(tmask,dim=3) == 0)
+         mbkt(:,:)=1 ; mbku(:,:)=1 ; mbkv(:,:)=1
+         mikt(:,:)=1 ; miku(:,:)=1 ; mikv(:,:)=1
+      END WHERE
+      ! -------------------------------------------------------------------------------------------
+      ! compute new tn and sn if we close cell 
+      ! nothing to do
+      ! 
+   END SUBROUTINE iscpl_rst_interpol
+
+   !!======================================================================
+END MODULE iscplrst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isf.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isf.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isf.F90	(revision 11395)
@@ -0,0 +1,171 @@
+MODULE isf
+   !!======================================================================
+   !!                       ***  MODULE  sbcisf  ***
+   !! Surface module :  compute iceshelf melt and heat flux
+   !!======================================================================
+   !! History :  3.2  !  2011-02  (C.Harris  ) Original code isf cav
+   !!            X.X  !  2006-02  (C. Wang   ) Original code bg03
+   !!            3.4  !  2013-03  (P. Mathiot) Merging + parametrization
+   !!            4.1  !  2019-09  (P. Mathiot) Split param/explicit ice shelf and re-organisation
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   isfmlt       : compute iceshelf melt and heat flux
+   !!----------------------------------------------------------------------
+
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
+   USE fldread        ! read input fields
+
+   IMPLICIT NONE
+
+   PRIVATE
+
+   PUBLIC   isf_alloc, isf_alloc_par, isf_alloc_cav
+
+   ! public in order to be able to output then 
+
+   LOGICAL, PUBLIC :: ln_isfpar_mlt                  !: logical for the computation of melt inside the cavity
+   LOGICAL, PUBLIC :: ln_isfcav_mlt                  !: logical for the use of ice shelf parametrisation
+   REAL(wp), PUBLIC ::   rn_hisf_tbl                 !: thickness of top boundary layer [m]
+   REAL(wp), PUBLIC ::   rn_gammat0                  !: temperature exchange coeficient    []
+   REAL(wp), PUBLIC ::   rn_gammas0                  !: salinity    exchange coeficient    []
+   REAL(wp), PUBLIC ::   rn_htbl                     !: Losch top boundary layer thickness [m]
+   CHARACTER(LEN=256), PUBLIC :: cn_gammablk         !: gamma formulation
+   CHARACTER(LEN=256), PUBLIC :: cn_isfcav_mlt, cn_isfpar_mlt !: melt formulation (cavity/param)
+   TYPE(FLD_N), PUBLIC                                  :: sn_isfcav_fwf   !: information about the isf melting file to be read
+   TYPE(FLD_N), PUBLIC                                  :: sn_isfpar_fwf   !: information about the isf melting file to be read
+   TYPE(FLD_N), PUBLIC                                  :: sn_isfpar_zmax  !: information about the grounding line depth file to be read
+   TYPE(FLD_N), PUBLIC                                  :: sn_isfpar_zmin  !: information about the calving   line depth file to be read
+   TYPE(FLD_N), PUBLIC                                  :: sn_isfpar_Leff  !: information about the effective length     file to be read
+
+   LOGICAL, PUBLIC :: l_isfcpl
+   !
+   INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   misfkt_par, misfkt_cav   !: Level of ice shelf base
+   INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   misfkb_par, misfkb_cav   !: Level of ice shelf base
+   !
+   INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   mskisf_par, mskisf_cav   !: Level of ice shelf base
+   !
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   rhisf_tbl, rhisf_tbl_0   !: thickness of tbl  [m]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   rhisf_tbl_cav, rhisf_tbl_par !: thickness of tbl  [m]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   rfrac_tbl_cav, rfrac_tbl_par !: fraction of the deepest cell affect by isf tbl  []
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   rhisf0_tbl_par
+   !
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   fwfisf_par, fwfisf_par_b !: net fwf from the ice shelf        [kg/m2/s]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   fwfisf_cav, fwfisf_cav_b !: net fwf from the ice shelf        [kg/m2/s]
+   !
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   risfdep                  !: Iceshelf draft                              (ISF)
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   bathy                    !: Bathymetry (needed for isf tbl definition)  (ISF)
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   risfLeff
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   risf_cav_tsc_b, risf_cav_tsc     !: before and now T & S isf contents [K.m/s & PSU.m/s]  
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   risf_par_tsc_b, risf_par_tsc     !: before and now T & S isf contents [K.m/s & PSU.m/s]  
+
+   REAL(wp), PARAMETER, PUBLIC :: rLfusisf = 0.334e6_wp    !: latent heat of fusion of ice shelf     [J/kg]
+   REAL(wp), PARAMETER, PUBLIC :: rcpisf = 2000.0_wp       !: specific heat of ice shelf             [J/kg/K]
+   REAL(wp), PARAMETER, PUBLIC :: rkappa = 1.54e-6_wp      !: heat diffusivity through the ice-shelf [m2/s]
+   REAL(wp), PARAMETER, PUBLIC :: rhoisf = 920.0_wp        !: volumic mass of ice shelf              [kg/m3]
+   REAL(wp), PARAMETER, PUBLIC :: rtsurf = -20.0           !: surface temperature                    [C]
+   REAL(wp), PARAMETER, PUBLIC :: risf_eps = 1.e-20_wp        
+
+   REAL(wp), PUBLIC            :: risf_lamb1, risf_lamb2, risf_lamb3  ! freezing point linearization coeficient
+
+   REAL(wp), PUBLIC            :: r1_Lfusisf               !: 1/rLfusisf
+
+   TYPE(FLD)  , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) :: sf_isfcav_fwf
+   TYPE(FLD)  , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) :: sf_isfpar_fwf
+
+!: Variable used in fldread to read the forcing file (nn_isf == 4 .OR. nn_isf == 3)
+   CHARACTER(len=100), PUBLIC           :: cn_dirisf  = './' !: Root directory for location of ssr files
+   TYPE(FLD_N)       , PUBLIC           :: sn_fwfisf         !: information about the isf melting file to be read
+   TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_fwfisf
+   TYPE(FLD_N)       , PUBLIC           :: sn_rnfisf         !: information about the isf melting param.   file to be read
+   TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_rnfisf           
+   
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: sbcisf.F90 10536 2019-01-16 19:21:09Z mathiot $
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE isf_alloc_par()
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE isfmlt_alloc  ***
+      !!
+      !! ** Purpose : 
+      !!
+      !! ** Method  : 
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER :: ierr, ialloc
+      !!----------------------------------------------------------------------
+      ierr = 0       ! set to zero if no array to be allocated
+      !
+      ALLOCATE(risfLeff(jpi,jpj), STAT=ialloc)
+      ierr = ierr + ialloc
+      !
+      CALL mpp_sum ( 'isf', ierr )
+      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'isf: failed to allocate arrays.' )
+   END SUBROUTINE isf_alloc_par
+
+   SUBROUTINE isf_alloc_cav()
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE isfmlt_alloc  ***
+      !!
+      !! ** Purpose : 
+      !!
+      !! ** Method  : 
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER :: ierr, ialloc
+      !!----------------------------------------------------------------------
+      ierr = 0       ! set to zero if no array to be allocated
+      !
+      CALL mpp_sum ( 'isf', ierr )
+      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'isf: failed to allocate arrays.' )
+   END SUBROUTINE isf_alloc_cav
+
+   SUBROUTINE isf_alloc()
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE isfmlt_alloc  ***
+      !!
+      !! ** Purpose : 
+      !!
+      !! ** Method  : 
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER :: ierr, ialloc
+      !!----------------------------------------------------------------------
+      !
+      ierr = 0       ! set to zero if no array to be allocated
+      !
+      ALLOCATE(misfkt_par(jpi,jpj), misfkb_par(jpi,jpj),             &
+         &     misfkt_cav(jpi,jpj), misfkb_cav(jpi,jpj), STAT=ialloc )
+      ierr = ierr + ialloc
+      !
+      ALLOCATE(fwfisf_par(jpi,jpj), fwfisf_par_b(jpi,jpj),             &
+         &     fwfisf_cav(jpi,jpj), fwfisf_cav_b(jpi,jpj), STAT=ialloc )
+      ierr = ierr + ialloc
+      !
+      ALLOCATE(risf_cav_tsc(jpi,jpj,jpts), risf_cav_tsc_b(jpi,jpj,jpts),             &
+         &     risf_par_tsc(jpi,jpj,jpts), risf_par_tsc_b(jpi,jpj,jpts), STAT=ialloc )
+      ierr = ierr + ialloc
+      !
+      ALLOCATE( rfrac_tbl_cav(jpi,jpj), rfrac_tbl_par(jpi,jpj), STAT=ialloc)
+      ierr = ierr + ialloc
+      !
+      ALLOCATE( rhisf_tbl_par(jpi,jpj), rhisf_tbl_cav(jpi,jpj), STAT=ialloc)
+      ierr = ierr + ialloc
+      !
+      ALLOCATE( mskisf_cav(jpi,jpj), mskisf_par(jpi,jpj), STAT=ialloc)
+      ierr = ierr + ialloc
+      !
+      ALLOCATE(risfdep(jpi,jpj), bathy(jpi,jpj), STAT=ialloc)
+      ierr = ierr + ialloc
+      !
+      CALL mpp_sum ( 'isf', ierr )
+      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'isf: failed to allocate arrays.' )
+
+   END SUBROUTINE isf_alloc
+   !
+END MODULE isf
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfcav.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfcav.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfcav.F90	(revision 11395)
@@ -0,0 +1,200 @@
+MODULE isfcav
+   !!======================================================================
+   !!                       ***  MODULE  sbcisf  ***
+   !! Surface module :  update surface ocean boundary condition under ice
+   !!                   shelf
+   !!======================================================================
+   !! History :  3.2  !  2011-02  (C.Harris  ) Original code isf cav
+   !!            X.X  !  2006-02  (C. Wang   ) Original code bg03
+   !!            3.4  !  2013-03  (P. Mathiot) Merging + parametrization
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   sbc_isf       : update sbc under ice shelf
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE isf            !
+   USE isftbl         !
+   USE isfcavmlt
+   USE isfgammats
+   USE isfdiags
+   USE dom_oce        ! ocean space and time domain
+   USE phycst         ! physical constants
+   USE eosbn2         ! equation of state
+   USE zdfdrg         ! vertical physics: top/bottom drag coef.
+   !
+   USE in_out_manager ! I/O manager
+   USE iom            ! I/O library
+   USE fldread        ! read input field at current time step
+   USE lbclnk         !
+
+   IMPLICIT NONE
+
+   PRIVATE
+
+   PUBLIC   isf_cav, isf_cav_init ! routine called in isfmlt
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: sbcisf.F90 10536 2019-01-16 19:21:09Z mathiot $
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE isf_cav( kt, ptsc, pqfwf )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE sbc_isf_cav  ***
+      !!
+      !! ** Purpose :   handle surface boundary condition under ice shelf
+      !!
+      !! ** Method  : -
+      !!
+      !! ** Action  :   utau, vtau : remain unchanged
+      !!                taum, wndm : remain unchanged
+      !!                qns        : update heat flux below ice shelf
+      !!                emp, emps  : update freshwater flux below ice shelf
+      !!---------------------------------------------------------------------
+      !!-------------------------- OUT --------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj)     , INTENT(inout) :: pqfwf
+      REAL(wp), DIMENSION(jpi,jpj,jpts), INTENT(inout) :: ptsc
+      !!-------------------------- IN  --------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+      !!---------------------------------------------------------------------
+      LOGICAL :: lit
+      INTEGER :: nit
+      REAL(wp) :: zerr
+      REAL(wp), DIMENSION(jpi,jpj) :: zqlat, zqoce, zqhc, zqh
+      REAL(wp), DIMENSION(jpi,jpj) :: zqoce_b
+      REAL(wp), DIMENSION(jpi,jpj) :: zgammat, zgammas
+      REAL(wp), DIMENSION(jpi,jpj) :: zttbl, zstbl
+      !!---------------------------------------------------------------------
+      !
+      ! compute misfkb_par, rhisf_tbl
+      rhisf_tbl_cav(:,:) = rn_htbl
+      CALL isf_tbl_lvl( ht_n, e3t_n, misfkt_cav, misfkb_cav, rhisf_tbl_cav, rfrac_tbl_cav )
+      !
+      ! compute T/S/U/V for the top boundary layer
+      CALL isf_tbl(tsn(:,:,:,jp_tem),zttbl(:,:),'T', misfkt_cav, misfkb_cav, rhisf_tbl_cav, rfrac_tbl_cav )
+      CALL isf_tbl(tsn(:,:,:,jp_sal),zstbl(:,:),'T', misfkt_cav, misfkb_cav, rhisf_tbl_cav, rfrac_tbl_cav )
+      ! 
+      ! output T/S/U/V for the top boundary layer
+      CALL iom_put('ttbl_cav',zttbl(:,:))
+      CALL iom_put('stbl'    ,zstbl(:,:))
+      !
+      ! initialisation
+      IF (TRIM(cn_gammablk) == 'HJ99' ) zqoce_b (:,:) = ptsc(:,:,jp_tem) * rau0_rcp ! last time step total heat fluxes (to speed up convergence)
+      !
+      ! compute ice shelf melting
+      nit = 1 ; lit = .TRUE.
+      DO WHILE ( lit )    ! maybe just a constant number of iteration as in blk_core is fine
+         !
+         ! compute gammat every where (2d)
+         ! useless if melt specified
+         IF ( TRIM(cn_isfcav_mlt) .NE. 'spe' ) THEN
+            CALL isfcav_gammats( zttbl, zstbl, zqoce  , pqfwf,  &
+               &                               zgammat, zgammas )
+         END IF
+         !   
+         ! compute tfrz, latent heat and melt (2d)
+         CALL isfcav_mlt(kt, zgammat, zgammas, zttbl, zstbl, &
+            &                         zqhc   , zqoce, pqfwf  )
+         !
+         ! define if we need to iterate (nn_gammablk 0/1 do not need iteration)
+         SELECT CASE ( cn_gammablk )
+         CASE ( 'spe','ad15' )
+            ! no convergence needed
+            lit = .FALSE.
+         CASE ( 'hj99' )
+            ! compute error between 2 iterations
+            zerr = MAXVAL(ABS(zqoce(:,:) - zqoce_b(:,:)))
+            !
+            ! define if iteration needed
+            IF (nit >= 100) THEN              ! too much iteration
+               CALL ctl_stop( 'STOP', 'isf_cav: HJ99 gamma formulation had too many iterations ...' )
+            ELSE IF ( zerr <= 0.01_wp ) THEN  ! convergence is achieve
+               lit = .FALSE.
+            ELSE                              ! converge is not yet achieve
+               nit = nit + 1
+               zqoce_b(:,:) = zqoce(:,:)
+            END IF
+         END SELECT
+
+      END DO
+      !
+      ! compute heat and water flux  (change signe directly in the melt subroutine)
+      pqfwf(:,:) = pqfwf(:,:) * mskisf_cav(:,:)
+      zqoce(:,:) = zqoce(:,:) * mskisf_cav(:,:)
+      zqhc (:,:) = zqhc(:,:)  * mskisf_cav(:,:)
+      !
+      ! compute heat content flux
+      zqlat(:,:) = - pqfwf(:,:) * rLfusisf    ! 2d latent heat flux (W/m2) ( > 0 out )
+      !
+      ! total heat flux ( >0 out )
+      zqh(:,:) = ( zqhc (:,:) + zqoce(:,:) )
+      !
+      ! lbclnk on melt
+      CALL lbc_lnk_multi( 'isfmlt', zqh, 'T', 1., pqfwf, 'T', 1.)
+      !
+      ! output fluxes
+      CALL isf_diags_flx( misfkt_cav, misfkb_cav, rhisf_tbl_cav, rfrac_tbl_cav, 'cav', pqfwf, zqoce, zqlat, zqhc)
+      !
+      ! set temperature content
+      ptsc(:,:,jp_tem) = - zqh(:,:) * r1_rau0_rcp
+      !
+   END SUBROUTINE isf_cav
+
+   SUBROUTINE isf_cav_init
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE isf_diags_2dto3d ***
+      !!
+      !! ** Purpose : 
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER :: ierr
+      !!---------------------------------------------------------------------
+
+      ! allocation isfcav gamtisf, gamsisf, 
+      CALL isf_alloc_cav()
+
+      ! initialisation
+      mskisf_cav(:,:) = (1._wp - tmask(:,:,1)) * ssmask(:,:)
+      !
+      misfkt_cav(:,:) = mikt(:,:)
+      !
+      SELECT CASE ( TRIM(cn_isfcav_mlt) )
+      CASE( 'spe' )
+
+         ALLOCATE( sf_isfcav_fwf(1), STAT=ierr )
+         ALLOCATE( sf_isfcav_fwf(1)%fnow(jpi,jpj,1), sf_isfcav_fwf(1)%fdta(jpi,jpj,1,2) )
+         CALL fld_fill( sf_isfcav_fwf, (/ sn_isfcav_fwf /), cn_dirisf, 'isf_cav_init', 'read fresh water flux isf data', 'namisf' )
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '  ==>> The ice shelf melt inside the cavity is read from forcing files'
+
+      CASE( '2eq' )
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '  ==>> The original ISOMIP melt formulation is used to compute melt under the ice shelves'
+
+      CASE( '3eq' )
+         ! coeficient for linearisation of potential tfreez
+         ! Crude approximation for pressure (but commonly used)
+         IF ( l_useCT ) THEN   ! linearisation from Jourdain et al. (2017)
+            risf_lamb1 =-0.0564_wp
+            risf_lamb2 = 0.0773_wp
+            risf_lamb3 =-7.8633e-8 * grav * rau0
+         ELSE                  ! linearisation from table 4 (Asay-Davis et al., 2015)
+            risf_lamb1 =-0.0573_wp
+            risf_lamb2 = 0.0832_wp
+            risf_lamb3 =-7.5300e-8 * grav * rau0
+         ENDIF
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '  ==>> The 3 equations melt formulation is used to compute melt under the ice shelves'
+
+      CASE DEFAULT
+         CALL ctl_stop(' cn_isfcav_mlt method unknown (spe, 2eq, 3eq), check namelist')
+      END SELECT
+      !
+   END SUBROUTINE isf_cav_init
+
+END MODULE isfcav
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfcav_gam.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfcav_gam.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfcav_gam.F90	(revision 11395)
@@ -0,0 +1,230 @@
+MODULE isfgammats
+   !!======================================================================
+   !!                       ***  MODULE  isfgammats  ***
+   !! Ice shelf module :  compute exchange coeficient at the ice/ocean interface
+   !!======================================================================
+   !! History :  4.1  !  (P. Mathiot) original
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   isf_gammats       : compute exchange coeficient gamma 
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE isf
+   USE isftbl
+   USE dom_oce        ! ocean space and time domain
+   USE phycst         ! physical constants
+   USE eosbn2         ! equation of state
+   USE zdfdrg         ! vertical physics: top/bottom drag coef.
+   USE iom
+   USE in_out_manager ! I/O manager
+   !
+   IMPLICIT NONE
+   !
+   PRIVATE
+   !
+   PUBLIC   isfcav_gammats
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: sbcisf.F90 10536 2019-01-16 19:21:09Z mathiot $
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+   !
+   !!-----------------------------------------------------------------------------------------------------
+   !!                              PUBLIC SUBROUTINES 
+   !!-----------------------------------------------------------------------------------------------------
+   !
+   SUBROUTINE isfcav_gammats( pttbl, pstbl, pqoce, pqfwf, pgt, pgs )
+      !!----------------------------------------------------------------------
+      !! ** Purpose    : compute the coefficient echange for heat and fwf flux
+      !!
+      !! ** Method     : select the gamma formulation
+      !!                 3 method available (cst, AD15 and HJ99)
+      !!---------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pgt  , pgs      ! gamma t and gamma s 
+      !!-------------------------- IN  -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pqoce, pqfwf    ! isf heat and fwf
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pttbl, pstbl    ! top boundary layer tracer
+      !!---------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj)                :: zutbl, zvtbl    ! top boundary layer velocity
+      !!---------------------------------------------------------------------
+      !
+      ! compute velocity in the tbl
+      SELECT CASE ( cn_gammablk )
+      CASE ( 'spe'  ) ! gamma is constant (specified in namelist)
+      ! nothing to do
+      CASE ('ad15', 'hj99')
+         CALL isf_tbl(un(:,:,:) ,zutbl(:,:),'U')
+         CALL isf_tbl(vn(:,:,:) ,zvtbl(:,:),'V')
+         CALL iom_put('utbl',zutbl(:,:))
+         CALL iom_put('vtbl',zvtbl(:,:))
+      CASE DEFAULT
+         CALL ctl_stop('STOP','method to compute gamma (cn_gammablk) is unknown (should not see this)')
+      END SELECT
+      ! 
+      ! compute gamma
+      SELECT CASE ( cn_gammablk )
+      CASE ( 'spe'  ) ! gamma is constant (specified in namelist)
+         pgt(:,:) = rn_gammat0
+         pgs(:,:) = rn_gammas0
+      CASE ( 'ad15' ) ! gamma is proportional to u*
+         CALL gammats_AD15 (              zutbl, zvtbl, rCdU_top, r_ke0_top,               pgt, pgs )
+      CASE ( 'hj99' ) ! gamma depends of stability of boundary layer and u*
+         CALL gammats_HJ99 (pttbl, pstbl, zutbl, zvtbl, rCdU_top, r_ke0_top, pqoce, pqfwf, pgt, pgs )
+      CASE DEFAULT
+         CALL ctl_stop('STOP','method to compute gamma (cn_gammablk) is unknown (should not see this)')
+      END SELECT
+      !
+      ! ouput exchange coeficient and tbl velocity
+      CALL iom_put('isfgammat', pgt(:,:))
+      CALL iom_put('isfgammas', pgs(:,:))
+      !
+   END SUBROUTINE isfcav_gammats
+   !
+   !!-----------------------------------------------------------------------------------------------------
+   !!                              PRIVATE SUBROUTINES 
+   !!-----------------------------------------------------------------------------------------------------
+   !
+   SUBROUTINE gammats_AD15(putbl, pvtbl, pCd, pke2, &   ! <<== in
+      &                                  pgt, pgs   )   ! ==>> out gammats [m/s]
+      !!----------------------------------------------------------------------
+      !! ** Purpose    : compute the coefficient echange coefficient 
+      !!
+      !! ** Method     : gamma is velocity dependent (gt= gt0 * Ustar
+      !!
+      !! ** Reference  : Jenkins et al., 2010, JPO, p2298-2312
+      !!                 Asay-Davis et al. (2015)
+      !!---------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pgt, pgs     ! gammat and gammas [m/s]
+      !!-------------------------- IN  -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: putbl, pvtbl ! velocity in the losch top boundary layer
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pCd          ! drag coefficient
+      REAL(wp),                     INTENT(in   ) :: pke2         ! background velocity
+      !!---------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj) :: zustar
+      !!---------------------------------------------------------------------
+      !
+      ! compute ustar (AD15 eq. 27)
+      zustar(:,:) = SQRT( pCd(:,:) * ( putbl(:,:) * putbl(:,:) + pvtbl(:,:) * pvtbl(:,:) + pke2 ) )
+      !
+      ! Compute gammats
+      pgt(:,:) = zustar(:,:) * rn_gammat0
+      pgs(:,:) = zustar(:,:) * rn_gammas0
+      !
+      ! output ustar
+      CALL iom_put('isfustar',zustar(:,:))
+      !
+   END SUBROUTINE gammats_AD15
+
+   SUBROUTINE gammats_HJ99( pttbl, pstbl, putbl, pvtbl, pCd, pke2, pqoce, pqfwf, &  ! <<== in
+      &                                                            pgt  , pgs    )  ! ==>> out gammats [m/s]
+      !!----------------------------------------------------------------------
+      !! ** Purpose    : compute the coefficient echange coefficient 
+      !!
+      !! ** Method     : gamma is velocity dependent and stability dependent
+      !!
+      !! ** Reference  : Holland and Jenkins, 1999, JPO, p1787-1800
+      !!---------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pgt, pgs     ! gammat and gammas
+      !!-------------------------- IN  -------------------------------------
+      REAL(wp),                     INTENT(in   ) :: pke2           ! background velocity squared
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pqoce, pqfwf   ! surface heat flux and fwf flux
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pCd            ! drag coeficient
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: putbl, pvtbl   ! velocity in the losch top boundary layer
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pttbl, pstbl   ! tracer   in the losch top boundary layer
+      !!---------------------------------------------------------------------
+      INTEGER  :: ji, jj                     ! loop index
+      INTEGER  :: ikt                        ! local integer
+      REAL(wp) :: zdku, zdkv                 ! U, V shear 
+      REAL(wp) :: zPr, zSc, zRc              ! Prandtl, Scmidth and Richardson number 
+      REAL(wp) :: zmob, zmols                ! Monin Obukov length, coriolis factor at T point
+      REAL(wp) :: zbuofdep, zhnu             ! Bouyancy length scale, sublayer tickness
+      REAL(wp) :: zhmax                      ! limitation of mol
+      REAL(wp) :: zetastar                   ! stability parameter
+      REAL(wp) :: zgmolet, zgmoles, zgturb   ! contribution of modelecular sublayer and turbulence 
+      REAL(wp) :: zcoef                      ! temporary coef
+      REAL(wp) :: zdep
+      REAL(wp) :: zeps = 1.0e-20_wp    
+      REAL(wp), PARAMETER :: zxsiN = 0.052_wp   ! dimensionless constant
+      REAL(wp), PARAMETER :: znu   = 1.95e-6_wp ! kinamatic viscosity of sea water (m2.s-1)
+      REAL(wp), DIMENSION(2) :: zts, zab
+      REAL(wp), DIMENSION(jpi,jpj) :: zustar    ! friction velocity
+      !!---------------------------------------------------------------------
+      !
+      ! compute ustar
+      zustar(:,:) = SQRT( pCd * ( putbl(:,:) * putbl(:,:) + pvtbl(:,:) * pvtbl(:,:) + r_ke0_top ) )
+      !
+      ! output ustar
+      CALL iom_put('isfustar',zustar(:,:))
+      !
+      ! compute Pr and Sc number (eq ??)
+      zPr =   13.8_wp
+      zSc = 2432.0_wp
+      !
+      ! compute gamma mole (eq ??)
+      zgmolet = 12.5_wp * zPr ** (2.0/3.0) - 6.0_wp
+      zgmoles = 12.5_wp * zSc ** (2.0/3.0) - 6.0_wp
+      !
+      ! compute gamma
+      DO ji = 2, jpi
+         DO jj = 2, jpj
+            ikt = mikt(ji,jj)
+
+            IF( zustar(ji,jj) == 0._wp ) THEN           ! only for kt = 1 I think
+               pgt = rn_gammat0
+               pgs = rn_gammas0
+            ELSE
+               ! compute Rc number (as done in zdfric.F90)
+!!gm better to do it like in the new zdfric.F90   i.e. avm weighted Ri computation
+               zcoef = 0.5_wp / e3w_n(ji,jj,ikt+1)
+               !                                            ! shear of horizontal velocity
+               zdku = zcoef * (  un(ji-1,jj  ,ikt  ) + un(ji,jj,ikt  )  &
+                  &             -un(ji-1,jj  ,ikt+1) - un(ji,jj,ikt+1)  )
+               zdkv = zcoef * (  vn(ji  ,jj-1,ikt  ) + vn(ji,jj,ikt  )  &
+                  &             -vn(ji  ,jj-1,ikt+1) - vn(ji,jj,ikt+1)  )
+               !                                            ! richardson number (minimum value set to zero)
+               zRc = MAX(rn2(ji,jj,ikt+1), 0._wp) / MAX( zdku*zdku + zdkv*zdkv, zeps )
+
+               ! compute bouyancy 
+               zts(jp_tem) = pttbl(ji,jj)
+               zts(jp_sal) = pstbl(ji,jj)
+               zdep        = gdepw_n(ji,jj,ikt)
+               !
+               CALL eos_rab( zts, zdep, zab )
+               !
+               ! compute length scale (Eq ??)
+               zbuofdep = grav * ( zab(jp_tem) * pqoce(ji,jj) - zab(jp_sal) * pqfwf(ji,jj) )
+               !
+               ! compute Monin Obukov Length
+               ! Maximum boundary layer depth (Eq ??)
+               zhmax = gdept_n(ji,jj,mbkt(ji,jj)) - gdepw_n(ji,jj,mikt(ji,jj)) -0.001_wp
+               !
+               ! Compute Monin obukhov length scale at the surface and Ekman depth: (Eq ??)
+               zmob   = zustar(ji,jj) ** 3 / (vkarmn * (zbuofdep + zeps))
+               zmols  = SIGN(1._wp, zmob) * MIN(ABS(zmob), zhmax) * tmask(ji,jj,ikt)
+               !
+               ! compute eta* (stability parameter) (Eq ??)
+               zetastar = 1._wp / ( SQRT(1._wp + MAX(zxsiN * zustar(ji,jj) / ( ABS(ff_f(ji,jj)) * zmols * zRc ), 0._wp)))
+               !
+               ! compute the sublayer thickness (Eq ??)
+               zhnu = 5 * znu / zustar(ji,jj)
+               !
+               ! compute gamma turb (Eq ??)
+               zgturb = 1._wp / vkarmn * LOG(zustar(ji,jj) * zxsiN * zetastar * zetastar / ( ABS(ff_f(ji,jj)) * zhnu )) &
+               &      + 1._wp / ( 2 * zxsiN * zetastar ) - 1._wp / vkarmn
+               !
+               ! compute gammats
+               pgt(ji,jj) = zustar(ji,jj) / (zgturb + zgmolet)
+               pgs(ji,jj) = zustar(ji,jj) / (zgturb + zgmoles)
+            END IF
+         END DO
+      END DO
+
+   END SUBROUTINE gammats_HJ99
+
+END MODULE isfgammats
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfcav_mlt.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfcav_mlt.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfcav_mlt.F90	(revision 11395)
@@ -0,0 +1,215 @@
+MODULE isfcavmlt
+   !!======================================================================
+   !!                       ***  MODULE  isfcav_mlt  ***
+   !! ice shelf module :  update surface ocean boundary condition under ice
+   !!                   shelf
+   !!======================================================================
+   !! History :  4.0  !  2019-09  (P. Mathiot) Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   isfcav_mlt    : 
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE isf
+   USE isfdiags
+   USE dom_oce        ! ocean space and time domain
+   USE phycst         ! physical constants
+   USE eosbn2         ! equation of state
+   USE zdfdrg         ! vertical physics: top/bottom drag coef.
+   !
+   USE in_out_manager ! I/O manager
+   USE iom            ! I/O library
+   USE fldread        ! read input field at current time step
+   USE lbclnk         !
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   isfcav_mlt
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: sbcisf.F90 10536 2019-01-16 19:21:09Z mathiot $
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+! -------------------------------------------------------------------------------------------------------
+! -------------------------------- PUBLIC SUBROUTINE ----------------------------------------------------
+! -------------------------------------------------------------------------------------------------------
+
+   SUBROUTINE isfcav_mlt(kt, pgt, pgs , pttbl, pstbl,   &
+      &                           pqhc, pqoce, pqfwf    )
+      !!----------------------------------------------------------------------
+      !! ** Purpose    : 
+      !!
+      !! ** Method     : 
+      !!---------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pqhc, pqoce, pqfwf  ! heat and fwf fluxes
+      !!-------------------------- IN  -------------------------------------
+      INTEGER, INTENT(in) :: kt
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pgt  , pgs    ! gamma t and gamma s
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pttbl, pstbl  ! top boundary layer tracer
+      !!---------------------------------------------------------------------
+      !!---------------------------------------------------------------------
+      !
+      ! compute latent heat and melt (2d)
+      SELECT CASE ( cn_isfcav_mlt )
+      CASE ( 'spe' )   ! ice shelf melt specified (read input file, and heat fluxes derived from
+         CALL isfmlt_spe( kt, pstbl,                  &
+            &                  pqhc, pqoce, pqfwf    )
+      CASE ( '2eq' )   !  ISOMIP  formulation (2 equations) for volume flux (Hunter et al., 2006)
+         CALL isfmlt_2eq( pgt, pttbl, pstbl,          &
+            &                  pqhc , pqoce, pqfwf    )
+      CASE ( '3eq' )   ! ISOMIP+ formulation (3 equations) for volume flux (Asay-Davis et al., 2015)
+         CALL isfmlt_3eq( pgt, pgs , pttbl, pstbl,   &
+            &                  pqhc, pqoce, pqfwf    )
+      CASE ( 'oasis' ) ! fwf pass trough oasis
+         !CALL isfmlt_oasis( kt, pstbl,               &
+         !   &                    zqhc, zqoce, pqfwf  )
+      CASE DEFAULT
+         CALL ctl_stop('STOP', 'unknown isf melt formulation : cn_isfcav (should not see this)')
+      END SELECT
+      !
+   END SUBROUTINE isfcav_mlt
+
+! -------------------------------------------------------------------------------------------------------
+! -------------------------------- PRIVATE SUBROUTINE ---------------------------------------------------
+! -------------------------------------------------------------------------------------------------------
+
+   SUBROUTINE isfmlt_spe(kt, pstbl,                  &  ! <<== in
+      &                       pqhc, pqoce, pqfwf    )  ! ==>> out
+      !!----------------------------------------------------------------------
+      !! ** Purpose    : 
+      !!
+      !! ** Method     : 
+      !!---------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pqhc, pqoce, pqfwf  ! heat content, latent heat and fwf fluxes
+      !!-------------------------- IN  -------------------------------------
+      INTEGER                     , INTENT(in   ) :: kt
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pstbl         ! salinity in top boundary layer
+      !!--------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj) :: ztfrz         ! freezing temperature
+      !!--------------------------------------------------------------------
+      !
+      ! Calculate freezing temperature
+      CALL eos_fzp( pstbl(:,:), ztfrz(:,:), risfdep(:,:) )
+      !
+      ! read input file
+      CALL fld_read ( kt, nn_fsbc, sf_isfcav_fwf )
+      !
+      ! define fwf and qoce
+      pqfwf(:,:) = -sf_isfcav_fwf(1)%fnow(:,:,1)            ! fwf
+      ! ocean heat flux is assume to be equal to the latent heat
+      pqoce(:,:) =  pqfwf(:,:) * rLfusisf             ! ocean heat flux
+      pqhc (:,:) =  pqfwf(:,:) * ztfrz(:,:) * rcp     ! heat content flux
+      !
+   END SUBROUTINE isfmlt_spe
+
+   SUBROUTINE isfmlt_2eq(pgt, pttbl, pstbl,          &  ! <<== in
+      &                       pqhc , pqoce, pqfwf    )  ! ==>> out
+      !!----------------------------------------------------------------------
+      !! ** Purpose    : 
+      !!
+      !! ** Method     : 
+      !!---------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pqhc, pqoce, pqfwf  ! hean content, ocean-ice heat and fwf fluxes
+      !!-------------------------- IN  -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pgt           ! temperature exchange coeficient
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pttbl, pstbl  ! temperature and salinity in top boundary layer
+      !!--------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj) :: ztfrz         ! freezing temperature
+      !!--------------------------------------------------------------------
+      !
+      ! Calculate freezing temperature
+      CALL eos_fzp( pstbl(:,:), ztfrz(:,:), risfdep(:,:) )
+      !
+      ! compute ocean-ice heat flux and then derive fwf assuming that ocean heat flux equal latent heat
+      pqfwf(:,:) = - pgt(:,:) * rau0_rcp * ( pttbl(:,:)-ztfrz(:,:) ) * r1_Lfusisf  ! fresh water flux ( > 0 out )
+      pqoce(:,:) = - pqfwf(:,:) * rLfusisf                                         ! ocea-ice flux (assume to be equal to latent heat flux) ( > 0 out )
+      pqhc (:,:) =   pqfwf(:,:) * ztfrz(:,:) * rcp                                 ! heat content flux ( > 0 out )
+      !
+      ! output thermal driving
+      CALL iom_put('isfthermald_cav',( pttbl(:,:)-ztfrz(:,:) ))
+      !
+   END SUBROUTINE isfmlt_2eq
+
+   SUBROUTINE isfmlt_3eq(pgt, pgs , pttbl, pstbl,   &
+      &                       pqhc, pqoce, pqfwf    )
+      !!----------------------------------------------------------------------
+      !! ** Purpose    : 
+      !!
+      !! ** Method     : 
+      !!---------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pqhc, pqoce, pqfwf  ! latent heat and fwf fluxes
+      !!-------------------------- IN  -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pgt  , pgs    ! temperature exchange coeficient
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pttbl, pstbl  ! temperature and salinity in top boundary layer
+      !!--------------------------------------------------------------------
+      REAL(wp) :: zeps1,zeps2,zeps3,zeps4,zeps6,zeps7
+      REAL(wp) :: zaqe,zbqe,zcqe,zaqer,zdis,zsfrz,zcfac
+      REAL(wp) :: zeps = 1.e-20
+      REAL(wp), DIMENSION(jpi,jpj) :: ztfrz             ! freezing point
+      REAL(wp), DIMENSION(jpi,jpj) :: zqcon             ! conductive flux through the ice shelf
+      !
+      INTEGER  ::   ji, jj     ! dummy loop indices
+      !!--------------------------------------------------------------------
+      !
+      ! compute upward heat flux zhtflx and upward water flux zwflx
+      ! Resolution of a 2d equation from equation 24, 25 and 26
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            !
+            ! compute coeficient to solve the 2nd order equation
+            zeps1 = rau0_rcp*pgt(ji,jj)
+            zeps2 = rLfusisf*rau0*pgs(ji,jj)
+            zeps3 = rhoisf*rcpisf*rkappa/MAX(risfdep(ji,jj),zeps)
+            zeps4 = risf_lamb2+risf_lamb3*risfdep(ji,jj)
+            zeps6 = zeps4-pttbl(ji,jj)
+            zeps7 = zeps4-rtsurf
+            !
+            ! solve the 2nd order equation to find zsfrz
+            zaqe  = risf_lamb1 * (zeps1 + zeps3)
+            zaqer = 0.5_wp/MIN(zaqe,-risf_eps)
+            zbqe  = zeps1*zeps6+zeps3*zeps7-zeps2
+            zcqe  = zeps2*pstbl(ji,jj)
+            zdis  = zbqe*zbqe-4.0_wp*zaqe*zcqe               
+            !
+            ! Presumably zdis can never be negative because gammas is very small compared to gammat
+            zsfrz=(-zbqe-SQRT(zdis))*zaqer
+            IF ( zsfrz < 0.0_wp ) zsfrz=(-zbqe+SQRT(zdis))*zaqer  ! check this if this if is needed
+            !
+            ! compute t freeze (eq. 25)
+            ztfrz(ji,jj) = zeps4 + risf_lamb1 * zsfrz
+            !
+            ! compute the upward water and heat flux (eq. 24 and eq. 26)
+            ! ocean heat content flux added later on.
+            pqfwf(ji,jj) = rau0 * pgs(ji,jj) * ( zsfrz - pstbl(ji,jj) ) / MAX(zsfrz,zeps) ! fresh water flux (> 0 out)
+            pqoce(ji,jj) = pgt(ji,jj) * rau0_rcp * ( pttbl(ji,jj) - ztfrz(ji,jj) )        ! ocean-ice heat flux (> 0 out)
+            pqhc (ji,jj) = pqfwf(ji,jj) * ztfrz(ji,jj) * rcp                              ! heat content   flux (> 0 out)
+            zqcon(ji,jj) = zeps3 * ( ztfrz(ji,jj) - rtsurf ) ! to be check
+            !
+         END DO
+      END DO
+      !
+      ! output conductive heat flux through the ice
+      CALL iom_put('qconisf', zqcon)
+      !
+      ! output thermal driving
+      CALL iom_put('isfthermald_cav',( pttbl(:,:) - ztfrz(:,:) ))
+      !
+   END SUBROUTINE isfmlt_3eq
+
+   !SUBROUTINE isfmlt_3eq_frz_ktm1
+   ! compute tfrz based on sfrz value at kt-1 (need to be SAVED local array)
+   ! compute qfwf (eq 24)
+   ! compute zqoce, zqlat, zqcon, zqhc
+   ! compute sfrz (eq 26)
+   !END SUBROUTINE isfmlt_3eq_frz_ktm1
+
+END MODULE isfcavmlt
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfdiags.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfdiags.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfdiags.F90	(revision 11395)
@@ -0,0 +1,112 @@
+MODULE isfdiags
+   !!======================================================================
+   !!                       ***  MODULE  sbcisf  ***
+   !! Surface module :  update surface ocean boundary condition under ice
+   !!                   shelf
+   !!======================================================================
+   !! History :  3.2  !  2011-02  (C.Harris  ) Original code isf cav
+   !!            X.X  !  2006-02  (C. Wang   ) Original code bg03
+   !!            3.4  !  2013-03  (P. Mathiot) Merging + parametrization
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   sbc_isf       : update sbc under ice shelf
+   !!----------------------------------------------------------------------
+
+   USE in_out_manager ! I/O manager
+   USE dom_oce
+   USE isf            ! ice shelf variable
+   USE iom            ! 
+
+   IMPLICIT NONE
+
+   PRIVATE
+
+   PUBLIC   isf_diags_flx
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: sbcisf.F90 10536 2019-01-16 19:21:09Z mathiot $
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE isf_diags_flx(ktop, kbot, phtbl, pfrac, cdisf, pqfwf, pqoce, pqlat, pqhc)
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE isf_diags_2dto3d ***
+      !!
+      !! ** Purpose : 
+      !!
+      !!----------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      !!-------------------------- IN  -------------------------------------
+      INTEGER , DIMENSION(jpi,jpj), INTENT(in) :: ktop , kbot               ! top and bottom level of the tbl
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: phtbl, pfrac              ! thickness of the tbl and fraction of last cell affected by the tbl
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pqfwf, pqoce, pqlat, pqhc ! 2d var to map in 3d
+      CHARACTER(LEN=256), INTENT(in) :: cdisf                               ! parametrisation or interactive melt
+      !!---------------------------------------------------------------------
+      CHARACTER(LEN=256) :: cvarqfwf  , cvarqoce  , cvarqlat  , cvarqhc
+      CHARACTER(LEN=256) :: cvarqfwf3d, cvarqoce3d, cvarqlat3d, cvarqhc3d
+      !!---------------------------------------------------------------------
+      !
+      ! output melt
+      cvarqfwf = 'fwfisf_'//cdisf  ; cvarqfwf3d = 'fwfisf3d_'//cdisf
+      cvarqoce = 'qoceisf_'//cdisf ; cvarqoce3d = 'qoceisf3d_'//cdisf
+      cvarqlat = 'qlatisf_'//cdisf ; cvarqlat3d = 'qlatisf3d_'//cdisf 
+      cvarqhc  = 'qhcisf_'//cdisf  ; cvarqhc3d  = 'qhcisf3d_'//cdisf
+      !
+      ! output 2d melt rate, latent heat and heat content flux
+      CALL iom_put( TRIM(cvarqfwf), pqfwf(:,:) )   ! isf mass flux (opposite sign)
+      CALL iom_put( TRIM(cvarqoce), pqoce(:,:) )   ! isf oce to ice   flux  (cpo*gt*dt)
+      CALL iom_put( TRIM(cvarqlat), pqlat(:,:) )   ! isf oce to ice   flux  (cpo*gt*dt)
+      CALL iom_put( TRIM(cvarqhc) , pqhc (:,:) )   ! isf heat content flux  (cpo*fwf*Tfrz)
+      !
+      ! output 3d Diagnostics
+      IF ( iom_use( TRIM(cvarqfwf3d) ) ) CALL isf_diags_2dto3d( ktop, kbot, phtbl, pfrac, TRIM(cvarqfwf3d) , pqfwf(:,:))
+      IF ( iom_use( TRIM(cvarqoce3d) ) ) CALL isf_diags_2dto3d( ktop, kbot, phtbl, pfrac, TRIM(cvarqoce3d) , pqoce(:,:))
+      IF ( iom_use( TRIM(cvarqlat3d) ) ) CALL isf_diags_2dto3d( ktop, kbot, phtbl, pfrac, TRIM(cvarqlat3d) , pqoce(:,:))
+      IF ( iom_use( TRIM(cvarqhc3d)  ) ) CALL isf_diags_2dto3d( ktop, kbot, phtbl, pfrac, TRIM(cvarqhc3d)  , pqhc (:,:))
+      !
+   END SUBROUTINE
+
+   SUBROUTINE isf_diags_2dto3d(ktop, kbot, phtbl, pfrac, cdvar, pvar2d)
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE isf_diags_2dto3d ***
+      !!
+      !! ** Purpose : 
+      !!
+      !!----------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      !!-------------------------- IN  -------------------------------------
+      INTEGER , DIMENSION(jpi,jpj), INTENT(in) :: ktop , kbot   ! top and bottom level of the tbl
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: phtbl, pfrac  ! thickness of the tbl and fraction of last cell affected by the tbl
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pvar2d        ! 2d var to map in 3d
+      CHARACTER(LEN=256), INTENT(in) :: cdvar
+      !!---------------------------------------------------------------------
+      INTEGER  :: ji, jj, jk                       ! loop indices
+      INTEGER  :: ikt, ikb                         ! top and bottom level of the tbl
+      REAL(wp), DIMENSION(jpi,jpj)     :: zvar2d   !
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zvar3d   ! 3d var to output
+      !!---------------------------------------------------------------------
+      !
+      ! compute 3d output
+      zvar2d(:,:) = pvar2d(:,:) / phtbl(:,:)
+      DO jj = 1,jpj
+         DO ji = 1,jpi
+            ikt = ktop(ji,jj)
+            ikb = kbot(ji,jj)
+            DO jk = ikt, ikb - 1
+               zvar3d(ji,jj,jk) = zvar3d(ji,jj,jk) + zvar2d(ji,jj) * e3t_n(ji,jj,jk)
+            END DO
+            ! phtbl(ji,jj) * pfrac(ji,jj) = thickness of bottom affected by tbl
+            zvar3d(ji,jj,ikb) = zvar3d(ji,jj,ikb) + zvar2d(ji,jj) * e3t_n(ji,jj,ikb) * pfrac(ji,jj)
+         END DO
+      END DO
+      !
+      ! output data
+      CALL iom_put( TRIM(cdvar) , zvar3d(:,:,:))
+      !
+   END SUBROUTINE isf_diags_2dto3d
+
+END MODULE isfdiags
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfhdiv.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfhdiv.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfhdiv.F90	(revision 11395)
@@ -0,0 +1,85 @@
+MODULE isfhdiv
+
+USE oce
+USE dom_oce
+USE isf
+USE isfutils
+USE phycst
+
+IMPLICIT NONE
+
+PRIVATE
+
+PUBLIC isf_hdiv
+
+CONTAINS
+
+   SUBROUTINE isf_hdiv( phdiv )
+      !!----------------------------------------------------------------------
+      !!                  ***  SUBROUTINE isf_hdiv  ***
+      !!       
+      !! ** Purpose :   
+      !!
+      !! ** Method  :   
+      !!
+      !! ** Action  :   phdiv   decreased by the fwf inflow (isf melt in this case)
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:,:,:), INTENT( inout ) ::   phdiv   ! horizontal divergence
+      !!----------------------------------------------------------------------
+      !
+      ! ice shelf cavity contribution
+      IF ( ln_isfcav_mlt ) CALL isf_hdiv_mlt(misfkt_cav, misfkb_cav, rhisf_tbl_cav, rfrac_tbl_cav, fwfisf_cav, fwfisf_cav_b, phdiv)
+      !
+      ! ice shelf parametrisation contribution
+      IF ( ln_isfpar_mlt ) CALL isf_hdiv_mlt(misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par, fwfisf_par, fwfisf_par_b, phdiv)
+      !
+      ! ice sheet coupling contribution (if conservation needed)
+      !IF ( ln_iscpl_hsb  ) CALL isf_hdiv_cpl(hdiv_iscpl, phdivn)
+      !
+   END SUBROUTINE isf_hdiv
+
+   SUBROUTINE isf_hdiv_mlt(ktop, kbot, phtbl, pfrac, pfwf, pfwf_b, phdiv)
+      !!----------------------------------------------------------------------
+      !!                  ***  SUBROUTINE sbc_isf_div  ***
+      !!       
+      !! ** Purpose :   update the horizontal divergence with the runoff inflow
+      !!
+      !! ** Method  :   
+      !!                CAUTION : risf_tsc(:,:,jp_sal) is negative (outflow) increase the 
+      !!                          divergence and expressed in m/s
+      !!
+      !! ** Action  :   phdivn   decreased by the runoff inflow
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) :: phdiv
+      !!----------------------------------------------------------------------
+      INTEGER , DIMENSION(jpi,jpj), INTENT(in   ) :: ktop , kbot
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pfrac, phtbl
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pfwf , pfwf_b
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      INTEGER  ::   ikt, ikb 
+      REAL(wp), DIMENSION(jpi,jpj) :: zqvol
+      !!----------------------------------------------------------------------
+      !
+      !==   fwf distributed over several levels   ==!
+      !
+      ! compute integrated divergence correction
+      zqvol(:,:) = 0.5_wp * ( pfwf(:,:) + pfwf_b(:,:) ) * r1_rau0 / phtbl(:,:)
+      !
+      ! update divergence at each level affected by ice shelf top boundary layer
+      DO jj = 1,jpj
+         DO ji = 1,jpi
+               ikt = ktop(ji,jj)
+               ikb = kbot(ji,jj)
+               ! level fully include in the ice shelf boundary layer
+               DO jk = ikt, ikb - 1
+                  phdiv(ji,jj,jk) = phdiv(ji,jj,jk) + zqvol(ji,jj)
+               END DO
+               ! level partially include in ice shelf boundary layer 
+               phdiv(ji,jj,ikb) = phdiv(ji,jj,ikb) + zqvol(ji,jj) * pfrac(ji,jj)
+         END DO
+      END DO
+      !
+   END SUBROUTINE isf_hdiv_mlt
+
+END MODULE isfhdiv
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfmlt.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfmlt.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfmlt.F90	(revision 11395)
@@ -0,0 +1,202 @@
+MODULE isfmlt
+   !!======================================================================
+   !!                       ***  MODULE  sbcisf  ***
+   !! Surface module :  compute iceshelf melt and heat flux
+   !!======================================================================
+   !! History :  3.2  !  2011-02  (C.Harris  ) Original code isf cav
+   !!            X.X  !  2006-02  (C. Wang   ) Original code bg03
+   !!            3.4  !  2013-03  (P. Mathiot) Merging + parametrization
+   !!            4.1  !  2019-09  (P. Mathiot) Split param/explicit ice shelf and re-organisation
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   isfmlt       : compute iceshelf melt and heat flux
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE dom_oce        ! ocean space and time domain
+   USE phycst         ! physical constants
+   USE eosbn2         ! equation of state
+   USE sbc_oce        ! surface boundary condition: ocean fields
+   USE zdfdrg         ! vertical physics: top/bottom drag coef.
+   !
+   USE in_out_manager ! I/O manager
+   USE iom            ! I/O library
+   USE fldread        ! read input field at current time step
+   USE lbclnk         !
+   USE lib_fortran    ! glob_sum
+   !
+   USE isfrst         ! iceshelf restart
+   USE isftbl         ! ice shelf boundary layer
+   USE isfpar         ! ice shelf parametrisation
+   USE isfcav         ! ice shelf cavity
+   USE isf            ! isf variables
+
+   IMPLICIT NONE
+
+   PRIVATE
+
+   PUBLIC   isf_mlt, isf_mlt_init  ! routine called in sbcmod and divhor
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+ 
+  SUBROUTINE isf_mlt( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE isf_mlt  ***
+      !!
+      !! ** Purpose : 
+      !!
+      !! ** Method  : 
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+      !!---------------------------------------------------------------------
+      !
+      IF ( ln_isfcav_mlt ) THEN
+         !
+         ! before time step 
+         IF ( kt /= nit000 ) THEN 
+            risf_cav_tsc_b (:,:,:) = risf_cav_tsc (:,:,:)
+            fwfisf_cav_b(:,:)      = fwfisf_cav(:,:)
+         END IF
+         !
+         ! compute tbl lvl/h
+         CALL isf_tbl_lvl(ht_n, e3t_n, misfkt_cav, misfkb_cav, rhisf_tbl_cav, rfrac_tbl_cav)
+         !
+         ! compute ice shelf melt
+         CALL isf_cav( kt, risf_cav_tsc, fwfisf_cav)
+         !
+         ! write restart variables (qoceisf, qhcisf, fwfisf for now and before)
+         IF (lrst_oce) CALL isfrst_write(kt, 'cav', risf_cav_tsc, fwfisf_cav)
+         !
+      END IF
+      ! 
+      IF ( ln_isfpar_mlt ) THEN
+         !
+         ! before time step 
+         IF ( kt /= nit000 ) THEN 
+            risf_par_tsc_b (:,:) = risf_par_tsc (:,:)
+            fwfisf_par_b(:,:)    = fwfisf_par(:,:)
+         END IF
+         !
+         ! compute misfkb, rhisf_tbl, rfrac (deepest level, thickness, fraction of deepest cell affected by tbl)
+         CALL isf_tbl_lvl(ht_n, e3t_n, misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par)
+         !
+         ! compute ice shelf melt
+         CALL isf_par( kt, risf_par_tsc, fwfisf_par)
+         !
+         ! write restart variables (qoceisf, qhcisf, fwfisf for now and before)
+         IF (lrst_oce) CALL isfrst_write(kt, 'par', risf_par_tsc, fwfisf_par)
+         !
+      END IF
+      !
+   END SUBROUTINE isf_mlt
+
+   SUBROUTINE isf_mlt_init
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE isfmlt_init  ***
+      !!
+      !! ** Purpose :
+      !!
+      !! ** Method  :
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER               :: inum, ierror
+      INTEGER               :: ios                  ! Local integer output status for namelist read
+      INTEGER               :: ikt, ikb
+      INTEGER               :: ji, jj
+      !!----------------------------------------------------------------------
+      NAMELIST/namisf/ ln_isfcav_mlt, cn_isfcav_mlt, cn_gammablk, rn_gammat0, rn_gammas0, rn_htbl, sn_isfcav_fwf,  &
+         &             ln_isfpar_mlt, cn_isfpar_mlt, sn_isfpar_fwf, sn_isfpar_zmin, sn_isfpar_zmax, sn_isfpar_Leff
+      !!----------------------------------------------------------------------
+
+      REWIND( numnam_ref )              ! Namelist namsbc_rnf in reference namelist : Runoffs 
+      READ  ( numnam_ref, namisf, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namisf in reference namelist', lwp )
+
+      REWIND( numnam_cfg )              ! Namelist namsbc_rnf in configuration namelist : Runoffs
+      READ  ( numnam_cfg, namisf, IOSTAT = ios, ERR = 902 )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namisf in configuration namelist', lwp )
+      IF(lwm) WRITE ( numond, namisf )
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'isf_init : ice shelf initialisation'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
+      IF(lwp) WRITE(numout,*) '   Namelist namisf :'
+      IF(lwp) WRITE(numout,*) '      melt inside the cavity                  ln_isfcav_mlt   = ', ln_isfcav_mlt
+      IF ( ln_isfcav ) THEN
+         IF(lwp) WRITE(numout,*) '         melt formulation                        cn_isfcav_mlt   = ', cn_isfcav_mlt
+         IF(lwp) WRITE(numout,*) '         thickness of the top boundary layer     rn_htbl     = ', rn_htbl
+         IF(lwp) WRITE(numout,*) '         gamma formulation                       cn_gammablk = ', cn_gammablk 
+         IF ( TRIM(cn_gammablk) .NE. 'spe' ) THEN 
+            IF(lwp) WRITE(numout,*) '            gammat coefficient                      rn_gammat0  = ', rn_gammat0  
+            IF(lwp) WRITE(numout,*) '            gammas coefficient                      rn_gammas0  = ', rn_gammas0  
+            IF(lwp) WRITE(numout,*) '            top drag coef. used (from namdrg_top)   rn_Cd0      = ', r_Cdmin_top 
+         END IF
+      END IF
+      IF(lwp) WRITE(numout,*) ''
+      IF(lwp) WRITE(numout,*) '      ice shelf melt parametrisation          ln_isfpar_mlt    = ', ln_isfpar_mlt
+      IF ( ln_isfpar_mlt ) THEN
+         IF(lwp) WRITE(numout,*) '         isf parametrisation formulation         cn_isfpar_mlt   = ', cn_isfpar_mlt
+      END IF
+      IF(lwp) WRITE(numout,*) ''
+      !
+      ! Allocate public array
+      CALL isf_alloc()
+      !
+      ! initialisation
+      ! cav
+      misfkt_cav(:,:)     = mikt(:,:) ; misfkb_cav(:,:)       = mikt(:,:)
+      fwfisf_cav(:,:)     = 0.0_wp    ; fwfisf_cav_b(:,:)     = 0.0_wp
+      rhisf_tbl_cav(:,:)  = 1e-20     ; rfrac_tbl_cav(:,:)    = 0.0_wp
+      risf_cav_tsc(:,:,:) = 0.0_wp    ; risf_cav_tsc_b(:,:,:) = 0.0_wp
+      !
+      mskisf_cav(:,:) = (1._wp - tmask(:,:,1)) * ssmask(:,:)
+      !
+      ! par
+      misfkt_par(:,:)     = 1         ; misfkb_par(:,:)       = 1         
+      fwfisf_par(:,:)     = 0.0_wp    ; fwfisf_par_b(:,:)     = 0.0_wp
+      rhisf_tbl_par(:,:)  = 1e-20     ; rfrac_tbl_par(:,:)    = 0.0_wp
+      risf_par_tsc(:,:,:) = 0.0_wp    ; risf_par_tsc_b(:,:,:) = 0.0_wp
+      !
+      mskisf_par(:,:) = 0
+      !
+      ! initialisation useful variable
+      r1_Lfusisf =  1._wp / rLfusisf
+      !
+      DO jj = 1,jpj
+         DO ji = 1,jpi
+            ikt = mikt(ji,jj)
+            ikb = mbkt(ji,jj)
+            bathy  (ji,jj) = gdepw_0(ji,jj,ikb+1)
+            risfdep(ji,jj) = gdepw_0(ji,jj,ikt  )
+         END DO
+      END DO
+      !
+      IF ( ln_isfcav_mlt ) THEN
+         !
+         ! initialisation  of cav variable
+         CALL isf_cav_init()
+         !
+         ! read cav variable from restart
+         IF ( ln_rstart ) CALL isfrst_read('cav', risf_cav_tsc, fwfisf_cav, risf_cav_tsc_b, fwfisf_cav_b)
+         !
+      END IF
+      !
+      IF ( ln_isfpar_mlt ) THEN
+         !
+         ! initialisation  of par variable
+         CALL isf_par_init()
+         !
+         ! read par variable from restart
+         IF ( ln_rstart ) CALL isfrst_read('par', risf_par_tsc, fwfisf_par, risf_par_tsc_b, fwfisf_par_b)
+         !
+      END IF
+      !
+  END SUBROUTINE isf_mlt_init
+   !!======================================================================
+END MODULE isfmlt
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfnxt.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfnxt.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfnxt.F90	(revision 11395)
@@ -0,0 +1,63 @@
+MODULE isfnxt
+
+USE isf
+USE isfutils
+
+USE dom_oce
+USE in_out_manager
+
+IMPLICIT NONE
+
+PRIVATE
+
+PUBLIC isf_dynnxt !, isf_tranxt_mlt, isf_dynnxt_cpl, isf_tranxt_cpl
+
+CONTAINS
+
+   SUBROUTINE isf_dynnxt ( pcoef )
+      !!----------------------------------------------------------------------
+      REAL(wp),                     INTENT(in   ) :: pcoef           ! atfp * rdt * r1_rau0
+      !!----------------------------------------------------------------------
+      !
+      ! ice shelf cavity
+      IF ( ln_isfcav_mlt ) CALL isf_dynnxt_mlt(misfkt_cav, misfkb_cav, rhisf_tbl_cav, rfrac_tbl_cav, fwfisf_cav, fwfisf_cav_b, pcoef)
+      !
+      ! ice shelf parametrised
+      IF ( ln_isfpar_mlt ) CALL isf_dynnxt_mlt(misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par, fwfisf_par, fwfisf_par_b, pcoef)
+      !
+      ! ice sheet coupling
+      !IF ( ln_iscpl_hsb  ) CALL isf_dynnxt_cpl(...zcoef)
+      !
+   END SUBROUTINE isf_dynnxt
+
+   SUBROUTINE isf_dynnxt_mlt ( ktop, kbot, phtbl, pfrac, pfwf, pfwf_b, pcoef )
+   !atfp * rdt * r1_rau0
+      !!----------------------------------------------------------------------
+      INTEGER , DIMENSION(jpi,jpj), INTENT(in   ) :: ktop , kbot     ! top and bottom level of tbl
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pfrac, phtbl    ! fraction of bottom cell included in tbl, tbl thickness
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pfwf , pfwf_b   ! now/before fwf
+      REAL(wp),                     INTENT(in   ) :: pcoef           ! atfp * rdt * r1_rau0
+      !!----------------------------------------------------------------------
+      INTEGER :: ji,jj,jk
+      REAL(wp), DIMENSION(jpi,jpj) :: zfwfinc
+      !!----------------------------------------------------------------------
+      !
+      ! compute fwf conservation correction
+      zfwfinc(:,:) = pcoef * ( pfwf_b(:,:) - pfwf(:,:) ) / phtbl(:,:)
+      !
+      ! add the in depth increment
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( ktop(ji,jj) <= jk .AND. jk < kbot(ji,jj)  ) THEN
+                  e3t_b(ji,jj,jk) = e3t_b(ji,jj,jk) - zfwfinc(ji,jj) * e3t_n(ji,jj,jk)
+               ELSEIF ( jk == kbot(ji,jj) ) THEN
+                  e3t_b(ji,jj,jk) = e3t_b(ji,jj,jk) - zfwfinc(ji,jj) * e3t_n(ji,jj,jk) * pfrac(ji,jj)
+               ENDIF
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE isf_dynnxt_mlt
+
+END MODULE isfnxt
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfpar.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfpar.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfpar.F90	(revision 11395)
@@ -0,0 +1,168 @@
+MODULE isfpar
+   !!======================================================================
+   !!                       ***  MODULE  isfpar  ***
+   !! ice shelf module :  update ocean boundary condition under ice
+   !!                   shelf
+   !!======================================================================
+   !! History :  3.2  !  2011-02  (C.Harris  ) Original code isf cav
+   !!            X.X  !  2006-02  (C. Wang   ) Original code bg03
+   !!            3.4  !  2013-03  (P. Mathiot) Merging + parametrization
+   !!            4.0  !  2019-09  (P. Mathiot) Restructuration
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   isf_par       : compute ice shelf melt using a prametrisation of ice shelf cavities
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE isf
+   USE isfparmlt
+   USE isftbl
+   USE isfdiags
+   USE isfutils
+   USE dom_oce        ! ocean space and time domain
+   USE phycst         ! physical constants
+   USE eosbn2         ! equation of state
+   !
+   USE in_out_manager ! I/O manager
+   USE iom            ! I/O library
+   USE fldread        ! read input field at current time step
+   USE lbclnk         !
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   isf_par, isf_par_init
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: sbcisf.F90 10536 2019-01-16 19:21:09Z mathiot $
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+ 
+   SUBROUTINE isf_par( kt, ptsc, pqfwf )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE sbc_isf_cav  ***
+      !!
+      !! ** Purpose :   
+      !!
+      !! ** Method  : 
+      !!
+      !! ** Action  :   
+      !!                
+      !!---------------------------------------------------------------------
+      !!-------------------------- OUT --------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj)     , INTENT(inout) :: pqfwf
+      REAL(wp), DIMENSION(jpi,jpj,jpts), INTENT(inout) :: ptsc
+      !!-------------------------- IN  --------------------------------------
+      INTEGER, INTENT(in) ::   kt                                           ! ocean time step
+      !!---------------------------------------------------------------------
+      !!---------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj) :: zqoce, zqhc, zqlat, zqh
+      !!---------------------------------------------------------------------
+      !
+      ! compute misfkb_par, rhisf_tbl
+      rhisf_tbl_par(:,:) = rhisf0_tbl_par(:,:)
+      CALL isf_tbl_lvl( ht_n, e3t_n, misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par )
+      !
+      ! compute heat content, latent heat and melt fluxes (2d)
+      CALL isfpar_mlt( kt, zqhc, zqoce, pqfwf  )
+      !
+      ! compute heat and water flux  (change signe directly in the melt subroutine)
+      pqfwf(:,:) = pqfwf(:,:) * mskisf_par(:,:)
+      zqoce(:,:) = zqoce(:,:) * mskisf_par(:,:)
+      zqhc (:,:) = zqhc(:,:)  * mskisf_par(:,:)
+      !
+      ! compute heat content flux
+      zqlat(:,:) = pqfwf(:,:) * rLfusisf    ! 2d latent heat flux (W/m2)
+      !
+      ! total heat flux
+      zqh(:,:) = ( zqhc (:,:) + zqoce(:,:) )
+      !
+      ! lbclnk on melt
+      CALL lbc_lnk_multi( 'isfmlt', zqh, 'T', 1., pqfwf, 'T', 1.)
+      !
+      ! output fluxes
+      CALL isf_diags_flx( misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par, 'par', pqfwf, zqoce, zqlat, zqhc)
+      !
+      ! set temperature content
+      ptsc(:,:,jp_tem) = zqh(:,:) * r1_rau0_rcp
+      !
+   END SUBROUTINE isf_par
+
+   SUBROUTINE isf_par_init
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE isf_par_init  ***
+      !!
+      !! ** Purpose : 
+      !!
+      !! ** Method  :  
+      !!----------------------------------------------------------------------
+      INTEGER               :: ierr
+      REAL(wp), DIMENSION(jpi,jpj) :: ztblmax, ztblmin
+      !!----------------------------------------------------------------------
+      !
+      ! allocation
+      CALL isf_alloc_par()
+      !
+      ! define isf tbl tickness, top and bottom indice
+      CALL read_2dcstdta(TRIM(sn_isfpar_zmax%clname), TRIM(sn_isfpar_zmax%clvar), ztblmax)
+      CALL read_2dcstdta(TRIM(sn_isfpar_zmin%clname), TRIM(sn_isfpar_zmin%clvar), ztblmin)
+      !
+      ! mask ice shelf parametrisation location
+      ztblmax(:,:) = ztblmax(:,:) * ssmask(:,:)
+      ztblmin(:,:) = ztblmin(:,:) * ssmask(:,:)
+      !
+      ! if param used under an ice shelf overwrite ztblmax by the ice shelf draft
+      WHERE ( risfdep > 0._wp )
+         ztblmin(:,:) = risfdep(:,:)
+      END WHERE
+      !
+      ! compute ktop
+      CALL isftbl_ktop(ztblmin, misfkt_par)
+      !
+      ! initial tbl thickness
+      rhisf0_tbl_par(:,:) = ztblmax(:,:) - ztblmin(:,:)
+      !
+      ! compute misfkb_par, rhisf_tbl
+      rhisf_tbl(:,:) = rhisf0_tbl_par(:,:)
+      CALL isf_tbl_lvl( ht_n, e3t_n, misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par )
+      !
+      ! define iceshelf parametrisation mask
+      mskisf_par = 0
+      WHERE ( ztblmax > 0._wp )
+         mskisf_par(:,:) = 1._wp
+      END WHERE
+      !
+      SELECT CASE ( TRIM(cn_isfpar_mlt) )
+         !
+      CASE ( 'spe' )
+
+         ALLOCATE( sf_isfpar_fwf(1), STAT=ierr )
+         ALLOCATE( sf_isfpar_fwf(1)%fnow(jpi,jpj,1), sf_isfpar_fwf(1)%fdta(jpi,jpj,1,2) )
+         CALL fld_fill( sf_isfpar_fwf, (/ sn_isfpar_fwf /), cn_dirisf, 'isf_par_init', 'read fresh water flux isf data', 'namisf' )
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '      ==>>>   ice melt read from forcing field (cn_isfmlt_par = spe)'
+
+      CASE ( 'bg03' )
+         !
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '      ==>>>   bg03 parametrisation (cn_isfmlt_par = bg03)'
+         !
+         ! read effective length
+         CALL read_2dcstdta(TRIM(sn_isfpar_Leff%clname), TRIM(sn_isfpar_Leff%clvar), risfLeff)
+         risfLeff = risfLeff*1000.0_wp           !: convertion in m
+         !
+      CASE ( 'oasis' )
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '      ==>>>    isf melt provided by OASIS (cn_isfmlt_par = oasis)'
+
+      CASE DEFAULT
+         CALL ctl_stop( 'sbc_isf_init: wrong value of nn_isf' )
+      END SELECT
+      !
+   END SUBROUTINE isf_par_init
+
+   END MODULE isfpar
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfpar_mlt.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfpar_mlt.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfpar_mlt.F90	(revision 11395)
@@ -0,0 +1,159 @@
+MODULE isfparmlt
+   !!======================================================================
+   !!                       ***  MODULE  sbcisf  ***
+   !! Surface module :  update surface ocean boundary condition under ice
+   !!                   shelf
+   !!======================================================================
+   !! History :  4.0  ! original code
+   !!----------------------------------------------------------------------
+
+   USE oce            ! ocean dynamics and tracers
+   USE isf
+   USE isftbl
+   USE dom_oce        ! ocean space and time domain
+   USE phycst         ! physical constants
+   USE eosbn2         ! equation of state
+
+   USE in_out_manager ! I/O manager
+   USE iom            ! I/O library
+   USE fldread
+
+   IMPLICIT NONE
+
+   PRIVATE
+
+   PUBLIC  isfpar_mlt 
+   
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: sbcisf.F90 10536 2019-01-16 19:21:09Z mathiot $
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+! -------------------------------------------------------------------------------------------------------
+! -------------------------------- PUBLIC SUBROUTINE ----------------------------------------------------
+! -------------------------------------------------------------------------------------------------------
+
+  SUBROUTINE isfpar_mlt( kt, pqfwf, pqoce, pqhc )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE sbc_isf  ***
+      !!
+      !! ** Purpose : Compute Salt and Heat fluxes related to ice_shelf 
+      !!              melting and freezing 
+      !!
+      !! ** Method  :  2 parameterizations are available according to XXXXX
+      !!                        2 : Beckmann & Goose parameterization
+      !!                        3 : Specified runoff in deptht (Mathiot & al. 2017)
+      !!----------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pqfwf,pqoce, pqhc  ! fresh water, ice-ocean heat and heat content fluxes
+      !!-------------------------- IN  -------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+      !!---------------------------------------------------------------------
+      !
+      ! Choose among the available ice shelf parametrisation
+      SELECT CASE ( cn_isfpar_mlt )
+      CASE ( 'spe' )    ! specified runoff in depth (Mathiot et al., 2017 in preparation)
+         CALL isfpar_mlt_spe(kt, pqhc, pqoce, pqfwf)
+      CASE ( 'bg03' )    ! Beckmann and Goosse parametrisation 
+         CALL isfpar_mlt_bg03(kt, pqhc, pqoce, pqfwf)
+      CASE ( 'oasis' )
+         !CALL isfpar_mlt_oasis
+      CASE DEFAULT
+         CALL ctl_stop('STOP', 'unknown isf melt formulation : cn_isfpar (should not see this)')
+      END SELECT
+      !
+   END SUBROUTINE isfpar_mlt
+
+! -------------------------------------------------------------------------------------------------------
+! -------------------------------- PRIVATE SUBROUTINE ---------------------------------------------------
+! -------------------------------------------------------------------------------------------------------
+
+   SUBROUTINE isfpar_mlt_spe(kt, pqhc, pqfwf, pqoce)
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE sbc_isf_bg03  ***
+      !!
+      !! ** Purpose : prescribed ice shelf melting in case ice shelf cavities are closed.
+      !!              data read into a forcing files.
+      !!
+      !! ** Reference : Mathiot et al. (2017)
+      !!----------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pqhc, pqfwf,pqoce  ! fresh water and ice-ocean heat fluxes
+      !!-------------------------- IN  -------------------------------------
+      INTEGER,  INTENT(in) :: kt
+      !!--------------------------------------------------------------------
+      INTEGER :: jk
+      REAL(wp), DIMENSION(jpi,jpj,jpk)  :: ztfrz3d
+      REAL(wp), DIMENSION(jpi,jpj)      :: ztfrz
+      !!--------------------------------------------------------------------
+      !
+      ! specified runoff in depth (Mathiot et al., 2017)
+      CALL fld_read ( kt, nn_fsbc, sf_isfpar_fwf   )
+      !
+      ! compute ptfrz
+      ! 0. ------------Mean freezing point
+      DO jk = 1,jpk
+         CALL eos_fzp(tsn(:,:,jk,jp_sal), ztfrz3d(:,:,jk), gdept_n(:,:,jk))
+      END DO
+      CALL isf_tbl(ztfrz3d, ztfrz, 'T', misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par )
+      !
+      pqfwf(:,:) = - sf_isfpar_fwf(1)%fnow(:,:,1)      ! fresh water flux from the isf (fwfisf <0 mean melting) 
+      pqoce(:,:) =   pqfwf(:,:) * rLfusisf             ! ocean/ice shelf flux assume to be equal to latent heat flux
+      pqhc (:,:) =   pqfwf(:,:) * ztfrz(:,:) * rcp     ! heat content flux 
+      !
+   END SUBROUTINE isfpar_mlt_spe
+
+   SUBROUTINE isfpar_mlt_bg03(kt, pqhc, pqoce, pqfwf)
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE sbc_isf_bg03  ***
+      !!
+      !! ** Purpose : compute an estimate of ice shelf melting in case cavities are closed
+      !!              based on the far fields T and S properties. 
+      !!
+      !! ** Method  :   See reference
+      !!
+      !! ** Reference : Beckmann and Goosse (2003), "A parameterization of ice shelf-ocean
+      !!         interaction for climate models", Ocean Modelling 5(2003) 157-170.
+      !!         (hereafter BG)
+      !!----------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pqhc, pqfwf,pqoce  ! fresh water and ice-ocean heat fluxes
+      !!-------------------------- IN  -------------------------------------
+      INTEGER,  INTENT(in) :: kt
+      !!--------------------------------------------------------------------
+      INTEGER :: jk
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: ztfrz3d        ! freezing point
+      REAL(wp), DIMENSION(jpi,jpj)     :: ztfrz          ! freezing point
+      REAL(wp), DIMENSION(jpi,jpj)     :: ztavg          ! temperature avg
+      !!----------------------------------------------------------------------
+      !
+      ! 0. ------------Mean freezing point
+      DO jk = 1,jpk
+         CALL eos_fzp(tsn(:,:,jk,jp_sal), ztfrz3d(:,:,jk), gdept_n(:,:,jk))
+      END DO
+      CALL isf_tbl(ztfrz3d, ztfrz, 'T', misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par )
+      !
+      ! 1. ------------Mean temperature
+      CALL isf_tbl(tsn(:,:,jk,jp_tem), ztavg, 'T', misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par )
+      !
+      ! 2. ------------Net heat flux and fresh water flux due to the ice shelf
+      pqoce(:,:) = - rau0 * rcp * rn_gammat0 * risfLeff(:,:) * e1t(:,:) * ( ztfrz(:,:) - ztavg(:,:) ) * r1_e1e2t(:,:)
+      pqfwf(:,:) =   pqoce(:,:) / rLfusisf
+      pqhc (:,:) =   pqfwf(:,:) * ztfrz(:,:) * rcp     ! heat content flux 
+      !
+      ! output ttbl
+      CALL iom_put('ttbl_par', ztavg(:,:) )
+      !
+      ! output thermal driving
+      CALL iom_put('isfthermald_par',( ztfrz(:,:) - ztavg(:,:) ))
+      !
+      !
+   END SUBROUTINE isfpar_mlt_bg03
+
+   SUBROUTINE isfpar_mlt_oasis
+   !TODO
+   END SUBROUTINE isfpar_mlt_oasis
+
+END MODULE isfparmlt
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfrst.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfrst.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfrst.F90	(revision 11395)
@@ -0,0 +1,100 @@
+MODULE isfrst
+   !!======================================================================
+   !!                       ***  MODULE  isfrst  ***
+   !! iceshelf restart module :read and write iceshelf variables in/from restart
+   !!======================================================================
+   !! History :  4.1  !  2019-07  (P. Mathiot) Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   isfrst : read/write iceshelf variables in/from restart
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE isf            ! ice shelf variable
+   !
+   USE in_out_manager ! I/O manager
+   USE iom            ! I/O library
+   !
+   IMPLICIT NONE
+
+   PRIVATE
+
+   PUBLIC isfrst_read, isfrst_write  ! iceshelf restart read and write 
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: sbcisf.F90 10536 2019-01-16 19:21:09Z mathiot $
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+   ! 
+   SUBROUTINE isfrst_read(cdisf, ptsc, pfwf, ptsc_b, pfwf_b )
+      !!----------------------------------------------------------------------
+      !!   isfrst_read : read iceshelf variables from restart
+      !!----------------------------------------------------------------------
+      CHARACTER(LEN=256)               , INTENT(in   ) :: cdisf
+      REAL(wp), DIMENSION(jpi,jpj)     , INTENT(in   ) :: pfwf
+      REAL(wp), DIMENSION(jpi,jpj)     , INTENT(inout) :: pfwf_b
+      REAL(wp), DIMENSION(jpi,jpj,jpts), INTENT(in   ) :: ptsc
+      REAL(wp), DIMENSION(jpi,jpj,jpts), INTENT(inout) :: ptsc_b
+      !!----------------------------------------------------------------------
+      CHARACTER(LEN=256) :: cfwf_b, chc_b, csc_b
+      !!----------------------------------------------------------------------
+      !
+      ! define variable name
+      cfwf_b = 'fwfisf_'//TRIM(cdisf)//'_b'
+      chc_b  = 'isf_hc_'//TRIM(cdisf)//'_b'
+      csc_b  = 'isf_sc_'//TRIM(cdisf)//'_b'
+      !
+      ! read restart
+      IF( iom_varid( numror, cfwf_b, ldstop = .FALSE. ) > 0 ) THEN
+         IF(lwp) WRITE(numout,*) '          nit000-1 isf tracer content forcing fields read in the restart file'
+         CALL iom_get( numror, jpdom_autoglo, cfwf_b, pfwf_b(:,:)        , ldxios = lrxios )   ! before ice shelf melt
+         CALL iom_get( numror, jpdom_autoglo, chc_b , ptsc_b (:,:,jp_tem), ldxios = lrxios )   ! before ice shelf heat flux
+         CALL iom_get( numror, jpdom_autoglo, csc_b , ptsc_b (:,:,jp_sal), ldxios = lrxios )   ! before ice shelf heat flux
+      ELSE
+         pfwf_b(:,:)   = pfwf(:,:)
+         ptsc_b(:,:,:) = ptsc(:,:,:)
+      ENDIF
+      !
+      IF( lwxios ) THEN
+          CALL iom_set_rstw_var_active(TRIM(chc_b ))
+          CALL iom_set_rstw_var_active(TRIM(csc_b ))
+          CALL iom_set_rstw_var_active(TRIM(cfwf_b))
+      ENDIF
+
+   END SUBROUTINE isfrst_read
+   ! 
+   SUBROUTINE isfrst_write(kt, cdisf, ptsc, pfwf )
+      !!----------------------------------------------------------------------
+      !!   isfrst_write : write iceshelf variables in restart
+      !!----------------------------------------------------------------------
+      INTEGER                     , INTENT(in   ) :: kt
+      CHARACTER(LEN=256)          , INTENT(in   ) :: cdisf
+      REAL(wp), DIMENSION(jpi,jpj)     , INTENT(in   ) :: pfwf
+      REAL(wp), DIMENSION(jpi,jpj,jpts), INTENT(in   ) :: ptsc
+      !!----------------------------------------------------------------------
+      CHARACTER(LEN=256) :: cfwf_b, chc_b, csc_b
+      !!----------------------------------------------------------------------
+      !
+      ! ocean output print
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'isf : isf fwf and heat fluxes written in ocean restart file ',   &
+         &                    'at it= ', kt,' date= ', ndastp
+      IF(lwp) WRITE(numout,*) '~~~~'
+      !
+      ! define variable name
+      cfwf_b = 'fwfisf_'//TRIM(cdisf)//'_b'
+      chc_b  = 'isf_hc_'//TRIM(cdisf)//'_b'
+      csc_b  = 'isf_sc_'//TRIM(cdisf)//'_b'
+      !
+      ! write restart variable
+      IF( lwxios ) CALL iom_swap( cwxios_context )
+      CALL iom_rstput( kt, nitrst, numrow, cfwf_b, pfwf(:,:)       , ldxios = lwxios )
+      CALL iom_rstput( kt, nitrst, numrow, chc_b , ptsc(:,:,jp_tem), ldxios = lwxios )
+      CALL iom_rstput( kt, nitrst, numrow, csc_b , ptsc(:,:,jp_sal), ldxios = lwxios )
+      IF( lwxios ) CALL iom_swap( cxios_context )
+      !
+   END SUBROUTINE isfrst_write
+   !
+END MODULE isfrst
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 11395)
@@ -0,0 +1,238 @@
+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
+
+CONTAINS
+
+   SUBROUTINE isf_tbl( pvarin, pvarout, cd_ptin, ktop, kbot, phtbl, pfrac )
+      !!----------------------------------------------------------------------
+      !!                  ***  SUBROUTINE sbc_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
+      !!--------------------------------------------------------------------
+      INTEGER ::   ji, jj                   ! loop index
+      INTEGER , DIMENSION(jpi,jpj) :: iktbl ! bottom level of the tbl
+      REAL(wp), DIMENSION(jpi,jpj) :: zhtbl ! thickness of the tbl
+      REAL(wp), DIMENSION(jpi,jpj) :: zfrac ! thickness of the tbl
+      !!----------------------------------------------------------------------
+      ! 
+      SELECT CASE ( cd_ptin )
+      CASE ( 'U' )
+         !
+         ! compute tbl lvl/h
+         CALL isf_tbl_lvl( hu_n, e3u_n, miku, iktbl, zhtbl, zfrac )
+         !
+         ! compute tbl property at U point
+         CALL isf_tbl_avg( miku, iktbl, zhtbl, zfrac, e3u_n, pvarin, pvarout )
+         !
+         ! compute tbl property at T point
+         DO jj = 1, jpj
+            DO ji = 2, jpi
+               pvarout(ji,jj) = 0.5_wp * (pvarout(ji,jj) + pvarout(ji-1,jj))
+            END DO
+         END DO
+         !
+         ! check if needed (probably yes)
+         CALL lbc_lnk('sbcisf', pvarout,'T',-1.)
+         ! 
+      CASE ( 'V' )
+         !
+         ! compute tbl lvl/h
+         CALL isf_tbl_lvl( hv_n, e3v_n, mikv, iktbl, zhtbl, zfrac )
+         !
+         ! compute tbl property at V point
+         CALL isf_tbl_avg( mikv, iktbl, zhtbl, zfrac, e3v_n, pvarin, pvarout )
+         !
+         ! pvarout is an averaging of wet point
+         DO jj = 2, jpj
+            DO ji = 1, jpi
+               pvarout(ji,jj) = 0.5_wp * (pvarout(ji,jj) + pvarout(ji,jj-1))
+            END DO
+         END DO
+         !
+         ! check if needed (probably yes)
+         CALL lbc_lnk('sbcisf', pvarout,'T',-1.)
+         !
+      CASE ( 'T' )
+         !
+         ! compute tbl property at T point
+         CALL isf_tbl_avg( ktop, kbot, phtbl, pfrac, e3t_n, pvarin, pvarout )
+         !
+      END SELECT
+      !
+      ! mask mean tbl value
+      pvarout(:,:) = pvarout(:,:) * ssmask(:,:)
+      !
+   END SUBROUTINE isf_tbl
+
+   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
+      !!---------------------------------------------------------------------
+      INTEGER  :: ji,jj,jk                    ! loop indices
+      INTEGER  :: ikt, ikb                    ! top and bottom levels
+      !!---------------------------------------------------------------------
+      !
+      ! compute tbl top.bottom level and thickness
+      DO jj = 1,jpj
+         DO ji = 1,jpi
+            !
+            ! tbl top/bottom indices initialisation
+            ikt = ktop(ji,jj) ; ikb = kbot(ji,jj)
+            !
+            ! level fully include in the ice shelf boundary layer
+            pvarout(ji,jj) = SUM( pvarin(ji,jj,ikt:ikb-1) * pe3(ji,jj,ikt:ikb-1) ) / phtbl(ji,jj)
+            !
+            ! level partially include in ice shelf boundary layer 
+            pvarout(ji,jj) = pvarout(ji,jj) + pvarin(ji,jj,ikb) * pe3(ji,jj,ikb) / phtbl(ji,jj) * pfrac(ji,jj)
+            !
+         END DO
+      END DO
+
+   END SUBROUTINE isf_tbl_avg
+
+   SUBROUTINE isf_tbl_lvl( phw, pe3, ktop, kbot, phtbl, pfrac )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE isf_tbl_lvl  ***
+      !!
+      !! ** Purpose : - compute bottom level fully included in the top boundary layer
+      !!              - 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
+      !!---------------------------------------------------------------------
+      INTEGER :: ji,jj,jk
+      INTEGER :: ikt, ikb
+      !!---------------------------------------------------------------------
+      !
+      ! get htbl
+      DO jj = 1,jpj
+         DO ji = 1,jpi
+            !
+            ! tbl top/bottom indices initialisation
+            ikt = ktop(ji,jj)
+            !
+            ! limit the tbl to water thickness.
+            phtbl(ji,jj) = MIN( phtbl(ji,jj), phw(ji,jj) )
+            !
+            ! thickness of boundary layer must be at least the top level thickness
+            phtbl(ji,jj) = MAX( phtbl(ji,jj), pe3(ji,jj,ikt) )
+            !
+         END DO
+      END DO
+      !
+      ! get ktbl
+      CALL isftbl_kbot(ktop, phtbl, pe3, kbot)
+      !
+      ! get pfrac
+      DO jj = 1,jpj
+         DO ji = 1,jpi
+            !
+            ! tbl top/bottom indices initialisation
+            ikt = ktop(ji,jj) ; ikb = kbot(ji,jj)
+            !
+            ! proportion of the bottom cell included in ice shelf boundary layer 
+            pfrac(ji,jj) = ( phtbl(ji,jj) - SUM( pe3(ji,jj,ikt:ikb-1) ) ) / pe3(ji,jj,ikb)
+            !
+         END DO
+      END DO
+      !
+   END SUBROUTINE isf_tbl_lvl
+   !
+   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
+      !!---------------------------------------------------------------------
+      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
+         DO ji = 1,jpi
+            !
+            ! determine the deepest level influenced by the boundary layer
+            ikt = ktop(ji,jj)
+            ikb = ikt
+            DO WHILE ( SUM(pe3(ji,jj,ikt:ikb-1)) < phtbl(ji,jj ) ) ;  ikb = ikb + 1 ;  END DO
+            kbot(ji,jj) = ikb - 1
+            !
+         END DO
+      END DO
+      !
+   END SUBROUTINE isftbl_kbot
+      !
+   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
+      !!---------------------------------------------------------------------
+      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
+            ikt = 2
+            DO WHILE ( gdepw_n(ji,jj,ikt) <= pdep(ji,jj ) ) ;  ikt = ikt + 1 ;  END DO
+            ktop(ji,jj) = ikt - 1
+         END DO
+      END DO
+      !
+   END SUBROUTINE
+
+END MODULE isftbl
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfutils.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfutils.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfutils.F90	(revision 11395)
@@ -0,0 +1,64 @@
+MODULE isfutils
+
+USE oce
+USE in_out_manager
+USE iom
+USE lib_fortran
+USE lib_mpp
+
+IMPLICIT NONE
+
+PRIVATE
+
+INTERFACE isf_debug
+   MODULE PROCEDURE isf_debug2d, isf_debug3d
+END INTERFACE isf_debug
+
+PUBLIC read_2dcstdta, isf_debug
+
+CONTAINS
+
+   SUBROUTINE read_2dcstdta(cdfile, cdvar, pvar)
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE read_2dcstdta  ***
+      !!
+      !! ** Purpose : read input file
+      !!
+      !!----------------------------------------------------------------------
+      !!-------------------------- OUT -------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pvar
+      !!-------------------------- IN  -------------------------------------
+      CHARACTER(len=256), INTENT(in) :: cdfile, cdvar
+      !!--------------------------------------------------------------------
+      INTEGER :: inum
+
+      CALL iom_open( cdfile, inum )
+      CALL iom_get( inum, jpdom_data, cdvar, pvar, 1)
+      CALL iom_close(inum)
+
+   END SUBROUTINE read_2dcstdta
+
+   SUBROUTINE isf_debug2d(cdtxt,pvar)
+      CHARACTER(LEN=256), INTENT(in) :: cdtxt
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pvar
+      REAL(wp) :: zmin, zmax, zsum
+      zsum = glob_sum( 'isf_debug', pvar(:,:) )
+      zmin = MINVAL( pvar(:,:) ) ; CALL mpp_min( 'isf_debug', zmin ) ! min over the global domain
+      zmax = MAXVAL( pvar(:,:) ) ; CALL mpp_max( 'isf_debug', zmax ) ! max over the global domain
+      WRITE(numout,*) TRIM(cdtxt),' (min, max, sum) : ',zmin, zmax, zsum
+      FLUSH(numout)
+   END SUBROUTINE isf_debug2d
+
+   SUBROUTINE isf_debug3d(cdtxt,pvar)
+      CHARACTER(LEN=256), INTENT(in) :: cdtxt
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) :: pvar
+      REAL(wp) :: zmin, zmax, zsum
+      zsum = glob_sum( 'isf_debug', pvar(:,:) )
+      zmin = MINVAL( pvar(:,:) ) ; CALL mpp_min( 'isf_debug', zmin ) ! min over the global domain
+      zmax = MAXVAL( pvar(:,:) ) ; CALL mpp_max( 'isf_debug', zmax ) ! max over the global domain
+      WRITE(numout,*) TRIM(cdtxt),' (min, max, sum) : ',zmin, zmax, zsum
+      FLUSH(numout)
+   END SUBROUTINE isf_debug3d
+
+END MODULE isfutils
+
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LDF/ldfslp.F90
===================================================================
--- NEMO/trunk/src/OCE/LDF/ldfslp.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LDF/ldfslp.F90	(revision 11395)
@@ -21,4 +21,5 @@
    !!----------------------------------------------------------------------
    USE oce            ! ocean dynamics and tracers
+   USE isf            ! ice shelf
    USE dom_oce        ! ocean space and time domain
 !   USE ldfdyn         ! lateral diffusion: eddy viscosity coef.
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbc_oce.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/sbc_oce.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbc_oce.F90	(revision 11395)
@@ -123,5 +123,4 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   fmmflx            !: freshwater budget: freezing/melting          [Kg/m2/s]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   rnf    , rnf_b    !: river runoff        [Kg/m2/s]  
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   fwfisf , fwfisf_b !: ice shelf melting   [Kg/m2/s]  
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   fwficb , fwficb_b !: iceberg melting [Kg/m2/s]  
 
@@ -174,6 +173,6 @@
          &      sfx    (jpi,jpj) , sfx_b(jpi,jpj) , emp_tot(jpi,jpj), fmmflx(jpi,jpj), STAT=ierr(2) )
          !
-      ALLOCATE( fwfisf  (jpi,jpj), rnf  (jpi,jpj) , sbc_tsc  (jpi,jpj,jpts) , qsr_hc  (jpi,jpj,jpk) ,  &
-         &      fwfisf_b(jpi,jpj), rnf_b(jpi,jpj) , sbc_tsc_b(jpi,jpj,jpts) , qsr_hc_b(jpi,jpj,jpk) ,  &
+      ALLOCATE( rnf  (jpi,jpj) , sbc_tsc  (jpi,jpj,jpts) , qsr_hc  (jpi,jpj,jpk) ,  &
+         &      rnf_b(jpi,jpj) , sbc_tsc_b(jpi,jpj,jpts) , qsr_hc_b(jpi,jpj,jpk) ,  &
          &      fwficb  (jpi,jpj), fwficb_b(jpi,jpj), STAT=ierr(3) )
          !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbccpl.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/sbccpl.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbccpl.F90	(revision 11395)
@@ -36,5 +36,5 @@
    USE eosbn2         ! 
    USE sbcrnf  , ONLY : l_rnfcpl
-   USE sbcisf  , ONLY : l_isfcpl
+   USE isf     , ONLY : l_isfcpl, fwfisf_cav, fwfisf_par
 #if defined key_cice
    USE ice_domain_size, only: ncat
@@ -478,4 +478,5 @@
          IF(lwp) WRITE(numout,*)
          IF(lwp) WRITE(numout,*) '   iceshelf received from oasis '
+         CALL ctl_stop('STOP','not coded')
       ENDIF
       !
@@ -1405,5 +1406,5 @@
              rnf(:,:)    = rnf(:,:) + fwficb(:,:)   ! iceberg added to runfofs
          ENDIF
-         IF( srcv(jpr_isf)%laction )  fwfisf(:,:) = - frcv(jpr_isf)%z3(:,:,1)  ! fresh water flux from the isf (fwfisf <0 mean melting)  
+         IF( srcv(jpr_isf)%laction )  fwfisf_par(:,:) = - frcv(jpr_isf)%z3(:,:,1)  ! fresh water flux from the isf (fwfisf <0 mean melting)  
         
          IF( ln_mixcpl ) THEN   ;   emp(:,:) = emp(:,:) * xcplmask(:,:,0) + zemp(:,:) * zmsk(:,:)
@@ -1708,5 +1709,5 @@
       ENDIF
       IF( srcv(jpr_isf)%laction ) THEN   ! iceshelf (fwfisf <0 mean melting)
-        fwfisf(:,:) = - frcv(jpr_isf)%z3(:,:,1)  
+        fwfisf_par(:,:) = - frcv(jpr_isf)%z3(:,:,1)  
       ENDIF
 
@@ -1747,5 +1748,5 @@
       ENDIF
       IF( srcv(jpr_isf)%laction ) THEN   ! iceshelf (fwfisf <0 mean melting)
-        fwfisf(:,:) = - frcv(jpr_isf)%z3(:,:,1)
+        fwfisf_par(:,:) = - frcv(jpr_isf)%z3(:,:,1)
       ENDIF
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcfwb.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/sbcfwb.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcfwb.F90	(revision 11395)
@@ -20,5 +20,5 @@
    USE phycst         ! physical constants
    USE sbcrnf         ! ocean runoffs
-   USE sbcisf         ! ice shelf melting contribution
+   USE isf            ! ice shelf melting contribution
    USE sbcssr         ! Sea-Surface damping terms
    !
@@ -104,5 +104,5 @@
          !
          IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN
-            y_fwfnow(1) = local_sum( e1e2t(:,:) * ( emp(:,:) - rnf(:,:) + fwfisf(:,:) - snwice_fmass(:,:) ) )
+            y_fwfnow(1) = local_sum( e1e2t(:,:) * ( emp(:,:) - rnf(:,:) + fwfisf_cav(:,:) + fwfisf_par(:,:) - snwice_fmass(:,:) ) )
             CALL mpp_delay_sum( 'sbcfwb', 'fwb', y_fwfnow(:), z_fwfprv(:), kt == nitend - nn_fsbc + 1 )
             z_fwfprv(1) = z_fwfprv(1) / area
@@ -159,5 +159,5 @@
             ztmsk_neg(:,:) = tmask_i(:,:) - ztmsk_pos(:,:)
             !                                                  ! fwf global mean (excluding ocean to ice/snow exchanges) 
-            z_fwf     = glob_sum( 'sbcfwb', e1e2t(:,:) * ( emp(:,:) - rnf(:,:) + fwfisf(:,:) - snwice_fmass(:,:) ) ) / area
+            z_fwf     = glob_sum( 'sbcfwb', e1e2t(:,:) * ( emp(:,:) - rnf(:,:) + fwfisf_cav(:,:) + fwfisf_par(:,:) - snwice_fmass(:,:) ) ) / area
             !            
             IF( z_fwf < 0._wp ) THEN         ! spread out over >0 erp area to increase evaporation
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcmod.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/sbcmod.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcmod.F90	(revision 11395)
@@ -37,5 +37,4 @@
 #endif
    USE sbcice_cice    ! surface boundary condition: CICE sea-ice model
-   USE sbcisf         ! surface boundary condition: ice-shelf
    USE sbccpl         ! surface boundary condition: coupled formulation
    USE cpl_oasis3     ! OASIS routines for coupling
@@ -43,5 +42,5 @@
    USE sbcrnf         ! surface boundary condition: runoffs
    USE sbcapr         ! surface boundary condition: atmo pressure 
-   USE sbcisf         ! surface boundary condition: ice shelf
+   USE isf            ! surface boundary condition: ice shelf
    USE sbcfwb         ! surface boundary condition: freshwater budget
    USE icbstp         ! Icebergs
@@ -239,9 +238,4 @@
 #endif
       !
-      IF( .NOT.ln_isf ) THEN        !* No ice-shelf in the domain : allocate and set to zero
-         IF( sbc_isf_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_init : unable to allocate sbc_isf arrays' )
-         fwfisf  (:,:)   = 0._wp   ;   risf_tsc  (:,:,:) = 0._wp
-         fwfisf_b(:,:)   = 0._wp   ;   risf_tsc_b(:,:,:) = 0._wp
-      END IF
       IF( nn_ice == 0 ) THEN        !* No sea-ice in the domain : ice fraction is always zero
          IF( nn_components /= jp_iam_opa )   fr_i(:,:) = 0._wp    ! except for OPA in SAS-OPA coupled case
@@ -329,6 +323,4 @@
       IF( ln_ssr      )   CALL sbc_ssr_init            ! Sea-Surface Restoring initialization
       !
-      IF( ln_isf      )   CALL sbc_isf_init            ! Compute iceshelves
-      !
                           CALL sbc_rnf_init            ! Runof initialization
       !
@@ -397,8 +389,4 @@
             rnf_b    (:,:  ) = rnf    (:,:  )
             rnf_tsc_b(:,:,:) = rnf_tsc(:,:,:)
-         ENDIF
-         IF( ln_isf )  THEN
-            fwfisf_b  (:,:  ) = fwfisf  (:,:  )               
-            risf_tsc_b(:,:,:) = risf_tsc(:,:,:)              
          ENDIF
         !
@@ -450,6 +438,4 @@
          IF( .NOT. ln_passive_mode ) CALL lbc_lnk( 'sbcmod', emp, 'T', 1. ) ! ensure restartability with icebergs
       ENDIF
-
-      IF( ln_isf         )   CALL sbc_isf( kt )                   ! compute iceshelves
 
       IF( ln_rnf         )   CALL sbc_rnf( kt )                   ! add runoffs to fresh water fluxes
@@ -554,7 +540,7 @@
       !
       IF(ln_ctl) THEN         ! print mean trends (used for debugging)
-         CALL prt_ctl(tab2d_1=fr_i              , clinfo1=' fr_i    - : ', mask1=tmask )
-         CALL prt_ctl(tab2d_1=(emp-rnf + fwfisf), clinfo1=' emp-rnf - : ', mask1=tmask )
-         CALL prt_ctl(tab2d_1=(sfx-rnf + fwfisf), clinfo1=' sfx-rnf - : ', mask1=tmask )
+         CALL prt_ctl(tab2d_1=fr_i             , clinfo1=' fr_i     - : ', mask1=tmask )
+         CALL prt_ctl(tab2d_1=(emp-rnf)        , clinfo1=' emp-rnf  - : ', mask1=tmask )
+         CALL prt_ctl(tab2d_1=(sfx-rnf)        , clinfo1=' sfx-rnf  - : ', mask1=tmask )
          CALL prt_ctl(tab2d_1=qns              , clinfo1=' qns      - : ', mask1=tmask )
          CALL prt_ctl(tab2d_1=qsr              , clinfo1=' qsr      - : ', mask1=tmask )
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcrnf.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/sbcrnf.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcrnf.F90	(revision 11395)
@@ -19,5 +19,5 @@
    USE phycst         ! physical constants
    USE sbc_oce        ! surface boundary condition variables
-   USE sbcisf         ! PM we could remove it I think
+   USE isf            ! ice shelf
    USE eosbn2         ! Equation Of State
    USE closea         ! closed seas
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/traisf.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/traisf.F90	(revision 11395)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/traisf.F90	(revision 11395)
@@ -0,0 +1,141 @@
+MODULE traisf
+   !!==============================================================================
+   !!                       ***  MODULE  trasbc  ***
+   !! Ocean active tracers:  surface boundary condition
+   !!==============================================================================
+   !! History :    4.0  !  2019-09  (P. Mathiot) original file
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_isf       : update the tracer trend at ocean surface
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and active tracers
+   USE dom_oce        ! ocean space domain variables
+   USE phycst         ! physical constant
+   USE eosbn2         ! Equation Of State
+   USE isf            ! Ice shelf variable
+   USE isfutils       !
+   USE iscplini       ! Ice sheet coupling
+   !
+   USE in_out_manager ! I/O manager
+   USE iom            ! xIOS server
+   USE timing         ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_isf   ! routine called by step.F90
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: trasbc.F90 10499 2019-01-10 15:12:24Z deazer $
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE tra_isf ( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_sbc  ***
+      !!                   
+      !! ** Purpose :   Compute the tracer surface boundary condition trend of
+      !!      (flux through the interface, concentration/dilution effect)
+      !!      and add it to the general trend of tracer equations.
+      !!
+      !! ** Method :   The (air+ice)-sea flux has two components: 
+      !!      (1) Fext, external forcing (i.e. flux through the (air+ice)-sea interface); 
+      !!      (2) Fwe , tracer carried with the water that is exchanged with air+ice. 
+      !!               The input forcing fields (emp, rnf, sfx, isf) contain Fext+Fwe,
+      !!             they are simply added to the tracer trend (tsa).
+      !!               In linear free surface case (ln_linssh=T), the volume of the
+      !!             ocean does not change with the water exchanges at the (air+ice)-sea
+      !!             interface. Therefore another term has to be added, to mimic the
+      !!             concentration/dilution effect associated with water exchanges.
+      !!
+      !! ** Action  : - Update tsa with the surface boundary condition trend 
+      !!              - send trends to trdtra module for further diagnostics(l_trdtra=T)
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+      !!----------------------------------------------------------------------
+      !
+      IF( ln_timing )   CALL timing_start('tra_sbc')
+      !
+      !----------------------------------------
+      !       Ice Shelf effects (ISF)
+      !     tbl treated as in Losh (2008) JGR
+      !----------------------------------------
+      IF ( ln_isfcav_mlt ) CALL tra_isf_mlt(misfkt_cav, misfkb_cav, rhisf_tbl_cav, rfrac_tbl_cav, risf_cav_tsc, risf_cav_tsc_b, tsa)
+      IF ( ln_isfpar_mlt ) CALL tra_isf_mlt(misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par, risf_par_tsc, risf_par_tsc_b, tsa)
+      !
+      !CALL tra_isf_cpl()
+      !
+      IF( ln_timing )   CALL timing_stop('tra_isf')
+      !
+   END SUBROUTINE tra_isf
+   !
+   SUBROUTINE tra_isf_mlt(ktop, kbot, phtbl, pfrac, ptsc, ptsc_b, pts)
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(inout) :: pts
+      !!----------------------------------------------------------------------
+      INTEGER , DIMENSION(jpi,jpj)     , INTENT(in   ) :: ktop , kbot
+      REAL(wp), DIMENSION(jpi,jpj)     , INTENT(in   ) :: phtbl, pfrac
+      REAL(wp), DIMENSION(jpi,jpj,jpts), INTENT(in   ) :: ptsc , ptsc_b
+      !!----------------------------------------------------------------------
+      !
+      INTEGER  ::   ji, jj, jk, jn              ! dummy loop indices  
+      INTEGER  ::   ikt, ikb                    ! local integers
+      REAL(wp) :: zeps = 1.e-20
+      REAL(wp), DIMENSION(jpi,jpj) :: ztc
+      !!----------------------------------------------------------------------
+      !
+      !----------------------------------------
+      !       Ice Shelf effects (ISF)
+      !     tbl treated as in Losh (2008) JGR
+      !----------------------------------------
+      ! 
+      ! compute 2d total trend due to isf
+      ztc(:,:) = 0.5_wp * ( ptsc(:,:,jp_tem) + ptsc_b(:,:,jp_tem) ) / phtbl(:,:)
+      !
+      ! update tsa
+      DO jj = 1,jpj
+         DO ji = 1,jpi
+            !
+            ikt = ktop(ji,jj)
+            ikb = kbot(ji,jj)
+            !
+            ! level fully include in the ice shelf boundary layer
+            ! sign - because fwf sign of evapo (rnf sign of precip)
+            DO jk = ikt, ikb - 1
+               pts(ji,jj,jk,jp_tem) = pts(ji,jj,jk,jp_tem) + ztc(ji,jj)
+            END DO
+            !
+            ! level partially include in ice shelf boundary layer 
+            pts(ji,jj,ikb,jp_tem) = pts(ji,jj,ikb,jp_tem) + ztc(ji,jj) * pfrac(ji,jj)
+            !
+         END DO
+      END DO
+      !
+   END SUBROUTINE tra_isf_mlt
+   !
+   !SUBROUTINE tra_isf_cpl
+       !
+!      !----------------------------------------
+!      !        Ice Sheet coupling imbalance correction to have conservation
+!      !----------------------------------------
+!      !
+!      IF( ln_iscpl .AND. ln_iscpl_hsb) THEN         ! input of heat and salt due to river runoff 
+!         DO jk = 1,jpk
+!            DO jj = 2, jpj 
+!               DO ji = fs_2, fs_jpim1
+!                  zdep = 1._wp / e3t_n(ji,jj,jk) 
+!                  tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem) - htsc_iscpl(ji,jj,jk,jp_tem) * zdep
+!                  tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal) - htsc_iscpl(ji,jj,jk,jp_sal) * zdep  
+!               END DO  
+!            END DO  
+!         END DO
+!      ENDIF
+!      !
+!   END SUBROUTINE tra_isf_cpl
+   !
+END MODULE traisf
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/tranxt.F90
===================================================================
--- NEMO/trunk/src/OCE/TRA/tranxt.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/tranxt.F90	(revision 11395)
@@ -28,5 +28,5 @@
    USE sbc_oce         ! surface boundary condition: ocean
    USE sbcrnf          ! river runoffs
-   USE sbcisf          ! ice shelf melting
+   USE isf             ! ice shelf melting
    USE zdf_oce         ! ocean vertical mixing
    USE domvvl          ! variable volume
@@ -312,17 +312,16 @@
                   ztc_f  = ztc_n  + atfp * ztc_d
                   !
-                  IF( jk == mikt(ji,jj) ) THEN           ! first level 
-                     ze3t_f = ze3t_f - zfact2 * ( (emp_b(ji,jj)    - emp(ji,jj)   )  &
-                            &                   + (fwfisf_b(ji,jj) - fwfisf(ji,jj))  )
+                  IF( jk == 1 ) THEN           ! first level 
+                     ze3t_f = ze3t_f - zfact2 * ( emp_b(ji,jj) - emp(ji,jj)   )
                      ztc_f  = ztc_f  - zfact1 * ( psbc_tc(ji,jj,jn) - psbc_tc_b(ji,jj,jn) )
                   ENDIF
                   IF( ln_rnf_depth ) THEN
                      ! Rivers are not just at the surface must go down to nk_rnf(ji,jj)
-                     IF( mikt(ji,jj) <=jk .and. jk <= nk_rnf(ji,jj)  ) THEN
+                     IF( jk <= nk_rnf(ji,jj)  ) THEN
                         ze3t_f = ze3t_f - zfact2 * ( - (rnf_b(ji,jj) - rnf(ji,jj)   )  ) &
                     &                            * ( e3t_n(ji,jj,jk) / h_rnf(ji,jj) ) 
                      ENDIF
                   ELSE
-                     IF( jk == mikt(ji,jj) ) THEN           ! first level 
+                     IF( jk == 1 ) THEN           ! first level 
                         ze3t_f = ze3t_f - zfact2 * ( - (rnf_b(ji,jj)    - rnf(ji,jj)   ) ) 
                      ENDIF
@@ -341,12 +340,36 @@
                   ! ice shelf
                   IF( ll_isf ) THEN
-                     ! level fully include in the Losch_2008 ice shelf boundary layer
-                     IF ( jk >= misfkt(ji,jj) .AND. jk < misfkb(ji,jj) )                          &
-                        ztc_f  = ztc_f  - zfact1 * ( risf_tsc(ji,jj,jn) - risf_tsc_b(ji,jj,jn) )  &
-                               &                 * e3t_n(ji,jj,jk) * r1_hisf_tbl (ji,jj)
-                     ! level partially include in Losch_2008 ice shelf boundary layer 
-                     IF ( jk == misfkb(ji,jj) )                                                   &
-                        ztc_f  = ztc_f  - zfact1 * ( risf_tsc(ji,jj,jn) - risf_tsc_b(ji,jj,jn) )  &
-                               &                 * e3t_n(ji,jj,jk) * r1_hisf_tbl (ji,jj) * ralpha(ji,jj)
+                     IF ( ln_isfcav_mlt ) THEN
+                        ! level fully include in the Losch_2008 ice shelf boundary layer
+                        IF ( jk >= misfkt_cav(ji,jj) .AND. jk < misfkb_cav(ji,jj) ) THEN
+                           ztc_f  = ztc_f  - zfact1 * ( risf_cav_tsc(ji,jj,jn) - risf_cav_tsc_b(ji,jj,jn) ) &
+                              &                     * e3t_n(ji,jj,jk) / rhisf_tbl_cav(ji,jj)
+                           ze3t_f = ze3t_f - zfact2 * ( fwfisf_cav_b(ji,jj) - fwfisf_cav(ji,jj) )           &
+                              &                     * e3t_n(ji,jj,jk) / rhisf_tbl_cav(ji,jj)
+                        END IF
+                        ! level partially include in Losch_2008 ice shelf boundary layer 
+                        IF ( jk == misfkb_cav(ji,jj) ) THEN
+                           ztc_f  = ztc_f  - zfact1 * ( risf_cav_tsc(ji,jj,jn) - risf_cav_tsc_b(ji,jj,jn) )  &
+                                  &                 * e3t_n(ji,jj,jk) / rhisf_tbl_cav(ji,jj) * rfrac_tbl_cav(ji,jj)
+                           ze3t_f = ze3t_f - zfact2 * ( fwfisf_cav_b(ji,jj) - fwfisf_cav(ji,jj) )            &
+                              &                     * e3t_n(ji,jj,jk) / rhisf_tbl_cav(ji,jj) * rfrac_tbl_cav(ji,jj)
+                        END IF
+                     END IF
+                     IF ( ln_isfpar_mlt ) THEN
+                        ! level fully include in the Losch_2008 ice shelf boundary layer
+                        IF ( jk >= misfkt_par(ji,jj) .AND. jk < misfkb_par(ji,jj) ) THEN
+                           ztc_f  = ztc_f  - zfact1 * ( risf_par_tsc(ji,jj,jn) - risf_par_tsc_b(ji,jj,jn) )  &
+                                  &                 * e3t_n(ji,jj,jk) / rhisf_tbl_par(ji,jj)
+                           ze3t_f = ze3t_f - zfact2 * ( fwfisf_par_b(ji,jj) - fwfisf_par(ji,jj) )            &
+                              &                     * e3t_n(ji,jj,jk) / rhisf_tbl_par(ji,jj)
+                        END IF
+                        ! level partially include in Losch_2008 ice shelf boundary layer 
+                        IF ( jk == misfkb_par(ji,jj) ) THEN
+                           ztc_f  = ztc_f  - zfact1 * ( risf_par_tsc(ji,jj,jn) - risf_par_tsc_b(ji,jj,jn) )  &
+                                  &                 * e3t_n(ji,jj,jk) / rhisf_tbl_par(ji,jj) * rfrac_tbl_par(ji,jj)
+                           ze3t_f = ze3t_f - zfact2 * ( fwfisf_par_b(ji,jj) - fwfisf_par(ji,jj) )            &
+                              &                     * e3t_n(ji,jj,jk) / rhisf_tbl_par(ji,jj) * rfrac_tbl_par(ji,jj)
+                        END IF
+                     END IF
                   END IF
                   !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/trasbc.F90
===================================================================
--- NEMO/trunk/src/OCE/TRA/trasbc.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/trasbc.F90	(revision 11395)
@@ -22,6 +22,4 @@
    USE sbcmod         ! ln_rnf  
    USE sbcrnf         ! River runoff  
-   USE sbcisf         ! Ice shelf   
-   USE iscplini       ! Ice sheet coupling
    USE traqsr         ! solar radiation penetration
    USE trd_oce        ! trends: ocean variables
@@ -155,38 +153,4 @@
       !
       !----------------------------------------
-      !       Ice Shelf effects (ISF)
-      !     tbl treated as in Losh (2008) JGR
-      !----------------------------------------
-      !
-!!gm BUG ?   Why no differences between non-linear and linear free surface ?
-!!gm         probably taken into account in r1_hisf_tbl : to be verified
-      IF( ln_isf ) THEN
-         zfact = 0.5_wp
-         DO jj = 2, jpj
-            DO ji = fs_2, fs_jpim1
-               !
-               ikt = misfkt(ji,jj)
-               ikb = misfkb(ji,jj)
-               !
-               ! level fully include in the ice shelf boundary layer
-               ! sign - because fwf sign of evapo (rnf sign of precip)
-               DO jk = ikt, ikb - 1
-               ! compute trend
-                  tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem)                                                &
-                     &           + zfact * ( risf_tsc_b(ji,jj,jp_tem) + risf_tsc(ji,jj,jp_tem) )             &
-                     &           * r1_hisf_tbl(ji,jj)
-               END DO
-   
-               ! level partially include in ice shelf boundary layer 
-               ! compute trend
-               tsa(ji,jj,ikb,jp_tem) = tsa(ji,jj,ikb,jp_tem)                                                 &
-                  &              + zfact * ( risf_tsc_b(ji,jj,jp_tem) + risf_tsc(ji,jj,jp_tem) )             &
-                  &              * r1_hisf_tbl(ji,jj) * ralpha(ji,jj)
-
-            END DO
-         END DO
-      END IF
-      !
-      !----------------------------------------
       !        River Runoff effects
       !----------------------------------------
@@ -242,20 +206,4 @@
 #endif
       !
-      !----------------------------------------
-      !        Ice Sheet coupling imbalance correction to have conservation
-      !----------------------------------------
-      !
-      IF( ln_iscpl .AND. ln_hsb) THEN         ! input of heat and salt due to river runoff 
-         DO jk = 1,jpk
-            DO jj = 2, jpj 
-               DO ji = fs_2, fs_jpim1
-                  zdep = 1._wp / e3t_n(ji,jj,jk) 
-                  tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem) - htsc_iscpl(ji,jj,jk,jp_tem) * zdep
-                  tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal) - htsc_iscpl(ji,jj,jk,jp_sal) * zdep  
-               END DO  
-            END DO  
-         END DO
-      ENDIF
-
       IF( l_trdtra )   THEN                      ! save the horizontal diffusive trends for further diagnostics
          ztrdt(:,:,:) = tsa(:,:,:,jp_tem) - ztrdt(:,:,:)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfmxl.F90
===================================================================
--- NEMO/trunk/src/OCE/ZDF/zdfmxl.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfmxl.F90	(revision 11395)
@@ -12,4 +12,5 @@
    !!----------------------------------------------------------------------
    USE oce            ! ocean dynamics and tracers variables
+   USE isf            ! ice shelf
    USE dom_oce        ! ocean space and time domain variables
    USE trc_oce  , ONLY: l_offline         ! ocean space and time domain variables
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/nemogcm.F90
===================================================================
--- NEMO/trunk/src/OCE/nemogcm.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/nemogcm.F90	(revision 11395)
@@ -60,4 +60,5 @@
    USE diacfl         ! CFL diagnostics               (dia_cfl_init routine)
    USE step           ! NEMO time-stepping                 (stp     routine)
+   USE isfmlt         ! ice shelf                     (isf_mlt_init routine)
    USE icbini         ! handle bergs, initialisation
    USE icbstp         ! handle bergs, calving, themodynamics and transport
@@ -452,4 +453,5 @@
       !                                      ! Active tracers
       IF( ln_traqsr    )   CALL tra_qsr_init      ! penetrative solar radiation qsr
+      IF (ln_isf       )   CALL isf_mlt_init      ! ice shelf
                            CALL tra_bbc_init      ! bottom heat flux
                            CALL tra_bbl_init      ! advective (and/or diffusive) bottom boundary layer scheme
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/step.F90
===================================================================
--- NEMO/trunk/src/OCE/step.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/step.F90	(revision 11395)
@@ -113,4 +113,5 @@
       IF( ln_apr_dyn )   CALL sbc_apr ( kstp )                   ! atmospheric pressure (NB: call before bdy_dta which needs ssh_ib) 
       IF( ln_bdy     )   CALL bdy_dta ( kstp, time_offset=+1 )   ! update dynamic & tracer data at open boundaries
+      IF( ln_isf     )   CALL isf_mlt ( kstp )
                          CALL sbc     ( kstp )                   ! Sea Boundary Condition (including sea-ice)
 
@@ -240,4 +241,5 @@
                          CALL tra_sbc       ( kstp )  ! surface boundary condition
       IF( ln_traqsr  )   CALL tra_qsr       ( kstp )  ! penetrative solar radiation qsr
+      IF( ln_isf     )   CALL tra_isf       ( kstp )  ! ice shelf heat flux
       IF( ln_trabbc  )   CALL tra_bbc       ( kstp )  ! bottom heat flux
       IF( ln_trabbl  )   CALL tra_bbl       ( kstp )  ! advective (and/or diffusive) bottom boundary layer scheme
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/step_oce.F90
===================================================================
--- NEMO/trunk/src/OCE/step_oce.F90	(revision 11310)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/step_oce.F90	(revision 11395)
@@ -22,5 +22,8 @@
    USE sbcwave         ! Wave intialisation
 
+   USE isfmlt          ! ice shelf boundary condition     (isf_mlt routine)
+
    USE traqsr          ! solar radiation penetration      (tra_qsr routine)
+   USE traisf          ! ice shelf                        (tra_isf routine)
    USE trasbc          ! surface boundary condition       (tra_sbc routine)
    USE trabbc          ! bottom boundary condition        (tra_bbc routine)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/iscplhsb.F90
===================================================================
--- NEMO/trunk/src/OCE/DOM/iscplhsb.F90	(revision 11310)
+++ 	(revision )
@@ -1,324 +1,0 @@
-MODULE iscplhsb
-   !!======================================================================
-   !!                       ***  MODULE  iscplhsb  ***
-   !! Ocean forcing: ice sheet/ocean coupling (conservation)
-   !!=====================================================================
-   !! History :  NEMO  ! 2015-01 P. Mathiot: original 
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   iscpl_alloc    : variable allocation
-   !!   iscpl_hsb      : compute and store the input of heat/salt/volume 
-   !!                    into the system due to the coupling process
-   !!   iscpl_div      : correction of divergence to keep volume conservation
-   !!----------------------------------------------------------------------
-   USE oce             ! global tra/dyn variable
-   USE dom_oce         ! ocean space and time domain
-   USE domwri          ! ocean space and time domain
-   USE domngb          ! 
-   USE phycst          ! physical constants
-   USE sbc_oce         ! surface boundary condition variables
-   USE iscplini        ! 
-   !
-   USE in_out_manager  ! I/O manager
-   USE lib_mpp         ! MPP library
-   USE lib_fortran     ! MPP library
-   USE lbclnk          !
-
-   IMPLICIT NONE
-   PRIVATE
-   
-   PUBLIC   iscpl_div   
-   PUBLIC   iscpl_cons       
-   !! * Substitutions  
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id$
-   !! Software governed by the CeCILL license (see ./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE iscpl_cons(ptmask_b, psmask_b, pe3t_b, pts_flx, pvol_flx, prdt_iscpl)
-      !!---------------------------------------------------------------------- 
-      !!                   ***  ROUTINE iscpl_cons  ***
-      !! 
-      !! ** Purpose :   compute input into the system during the coupling step
-      !!                compute the correction term
-      !!                compute where the correction have to be applied
-      !! 
-      !! ** Method  :   compute tsn*e3t-tsb*e3tb and e3t-e3t_b
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(:,:,:  ), INTENT(in ) :: ptmask_b    !! mask before
-      REAL(wp), DIMENSION(:,:,:  ), INTENT(in ) :: pe3t_b      !! scale factor before
-      REAL(wp), DIMENSION(:,:    ), INTENT(in ) :: psmask_b    !! mask before
-      REAL(wp), DIMENSION(:,:,:,:), INTENT(out) :: pts_flx     !! corrective flux to have tracer conservation
-      REAL(wp), DIMENSION(:,:,:  ), INTENT(out) :: pvol_flx    !! corrective flux to have volume conservation
-      REAL(wp),                     INTENT(in ) :: prdt_iscpl  !! coupling period 
-      !
-      INTEGER  ::   ji  , jj  , jk           ! loop index
-      INTEGER  ::   jip1, jim1, jjp1, jjm1
-      REAL(wp) ::   summsk, zsum , zsumn, zjip1_ratio  , zjim1_ratio, zdtem, zde3t, z1_rdtiscpl
-      REAL(wp) ::   zarea , zsum1, zsumb, zjjp1_ratio  , zjjm1_ratio, zdsal
-      REAL(wp), DIMENSION(jpi,jpj)        ::   zdssh   ! workspace
-      REAL(wp), DIMENSION(:), ALLOCATABLE ::   zlon, zlat
-      REAL(wp), DIMENSION(:), ALLOCATABLE ::   zcorr_vol, zcorr_tem, zcorr_sal
-      INTEGER , DIMENSION(:), ALLOCATABLE ::   ixpts, iypts, izpts, inpts
-      INTEGER :: jpts, npts
-      !!----------------------------------------------------------------------
-
-      ! get imbalance (volume heat and salt)
-      ! initialisation difference
-      zde3t = 0._wp   ;   zdsal = 0._wp   ;   zdtem = 0._wp
-
-      ! initialisation correction term
-      pvol_flx(:,:,:  ) = 0._wp
-      pts_flx (:,:,:,:) = 0._wp
-      
-      z1_rdtiscpl = 1._wp / prdt_iscpl 
-
-      ! mask tsn and tsb 
-      tsb(:,:,:,jp_tem) = tsb(:,:,:,jp_tem) * ptmask_b(:,:,:)
-      tsn(:,:,:,jp_tem) = tsn(:,:,:,jp_tem) *  tmask  (:,:,:)
-      tsb(:,:,:,jp_sal) = tsb(:,:,:,jp_sal) * ptmask_b(:,:,:)
-      tsn(:,:,:,jp_sal) = tsn(:,:,:,jp_sal) *  tmask  (:,:,:)
-
-      !==============================================================================
-      ! diagnose the heat, salt and volume input and compute the correction variable
-      !==============================================================================
-
-      ! 
-      zdssh(:,:) = sshn(:,:) * ssmask(:,:) - sshb(:,:) * psmask_b(:,:)
-      IF (.NOT. ln_linssh ) zdssh = 0.0_wp ! already included in the levels by definition
-      
-      DO jk = 1,jpk-1
-         DO jj = 2,jpj-1
-            DO ji = fs_2,fs_jpim1
-               IF (tmask_h(ji,jj) == 1._wp) THEN
-
-                  ! volume differences
-                  zde3t = e3t_n(ji,jj,jk) * tmask(ji,jj,jk) - pe3t_b(ji,jj,jk) * ptmask_b(ji,jj,jk)
-
-                  ! heat diff
-                  zdtem = tsn(ji,jj,jk,jp_tem) * e3t_n(ji,jj,jk) *  tmask  (ji,jj,jk)   &
-                        - tsb(ji,jj,jk,jp_tem) * pe3t_b (ji,jj,jk) * ptmask_b(ji,jj,jk)
-                  ! salt diff
-                  zdsal = tsn(ji,jj,jk,jp_sal) * e3t_n(ji,jj,jk) *  tmask  (ji,jj,jk)   &
-                        - tsb(ji,jj,jk,jp_sal) * pe3t_b (ji,jj,jk) * ptmask_b(ji,jj,jk)
-               
-                  ! shh changes
-                  IF ( ptmask_b(ji,jj,jk) == 1._wp .OR. tmask(ji,jj,jk) == 1._wp ) THEN 
-                     zde3t = zde3t + zdssh(ji,jj) ! zdssh = 0 if vvl
-                     zdssh(ji,jj) = 0._wp
-                  END IF
-
-                  ! volume, heat and salt differences in each cell 
-                  pvol_flx(ji,jj,jk)       =   pvol_flx(ji,jj,jk)        + zde3t * z1_rdtiscpl
-                  pts_flx (ji,jj,jk,jp_sal)=   pts_flx (ji,jj,jk,jp_sal) + zdsal * z1_rdtiscpl 
-                  pts_flx (ji,jj,jk,jp_tem)=   pts_flx (ji,jj,jk,jp_tem) + zdtem * z1_rdtiscpl
-
-                  ! case where we close a cell: check if the neighbour cells are wet 
-                  IF ( tmask(ji,jj,jk) == 0._wp .AND. ptmask_b(ji,jj,jk) == 1._wp ) THEN
-
-                     jip1=ji+1 ; jim1=ji-1 ; jjp1=jj+1 ; jjm1=jj-1 ;
-
-                     zsum =   e1e2t(ji  ,jjp1) * tmask(ji  ,jjp1,jk) + e1e2t(ji  ,jjm1) * tmask(ji  ,jjm1,jk) &
-                       &    + e1e2t(jim1,jj  ) * tmask(jim1,jj  ,jk) + e1e2t(jip1,jj  ) * tmask(jip1,jj  ,jk)
-
-                     IF ( zsum /= 0._wp ) THEN
-                        zjip1_ratio   = e1e2t(jip1,jj  ) * tmask(jip1,jj  ,jk) / zsum
-                        zjim1_ratio   = e1e2t(jim1,jj  ) * tmask(jim1,jj  ,jk) / zsum
-                        zjjp1_ratio   = e1e2t(ji  ,jjp1) * tmask(ji  ,jjp1,jk) / zsum
-                        zjjm1_ratio   = e1e2t(ji  ,jjm1) * tmask(ji  ,jjm1,jk) / zsum
-
-                        pvol_flx(ji  ,jjp1,jk       ) = pvol_flx(ji  ,jjp1,jk       ) + pvol_flx(ji,jj,jk       ) * zjjp1_ratio
-                        pvol_flx(ji  ,jjm1,jk       ) = pvol_flx(ji  ,jjm1,jk       ) + pvol_flx(ji,jj,jk       ) * zjjm1_ratio
-                        pvol_flx(jip1,jj  ,jk       ) = pvol_flx(jip1,jj  ,jk       ) + pvol_flx(ji,jj,jk       ) * zjip1_ratio
-                        pvol_flx(jim1,jj  ,jk       ) = pvol_flx(jim1,jj  ,jk       ) + pvol_flx(ji,jj,jk       ) * zjim1_ratio
-                        pts_flx (ji  ,jjp1,jk,jp_sal) = pts_flx (ji  ,jjp1,jk,jp_sal) + pts_flx (ji,jj,jk,jp_sal) * zjjp1_ratio
-                        pts_flx (ji  ,jjm1,jk,jp_sal) = pts_flx (ji  ,jjm1,jk,jp_sal) + pts_flx (ji,jj,jk,jp_sal) * zjjm1_ratio
-                        pts_flx (jip1,jj  ,jk,jp_sal) = pts_flx (jip1,jj  ,jk,jp_sal) + pts_flx (ji,jj,jk,jp_sal) * zjip1_ratio
-                        pts_flx (jim1,jj  ,jk,jp_sal) = pts_flx (jim1,jj  ,jk,jp_sal) + pts_flx (ji,jj,jk,jp_sal) * zjim1_ratio
-                        pts_flx (ji  ,jjp1,jk,jp_tem) = pts_flx (ji  ,jjp1,jk,jp_tem) + pts_flx (ji,jj,jk,jp_tem) * zjjp1_ratio
-                        pts_flx (ji  ,jjm1,jk,jp_tem) = pts_flx (ji  ,jjm1,jk,jp_tem) + pts_flx (ji,jj,jk,jp_tem) * zjjm1_ratio
-                        pts_flx (jip1,jj  ,jk,jp_tem) = pts_flx (jip1,jj  ,jk,jp_tem) + pts_flx (ji,jj,jk,jp_tem) * zjip1_ratio
-                        pts_flx (jim1,jj  ,jk,jp_tem) = pts_flx (jim1,jj  ,jk,jp_tem) + pts_flx (ji,jj,jk,jp_tem) * zjim1_ratio
-
-                        ! set to 0 the cell we distributed over neigbourg cells
-                        pvol_flx(ji,jj,jk       ) = 0._wp
-                        pts_flx (ji,jj,jk,jp_sal) = 0._wp
-                        pts_flx (ji,jj,jk,jp_tem) = 0._wp
-
-                     ELSE IF (zsum == 0._wp ) THEN
-                        ! case where we close a cell and no adjacent cell open
-                        ! check if the cell beneath is wet
-                        IF ( tmask(ji,jj,jk+1) == 1._wp ) THEN
-                           pvol_flx(ji,jj,jk+1)       =  pvol_flx(ji,jj,jk+1)        + pvol_flx(ji,jj,jk)
-                           pts_flx (ji,jj,jk+1,jp_sal)=  pts_flx (ji,jj,jk+1,jp_sal) + pts_flx (ji,jj,jk,jp_sal)
-                           pts_flx (ji,jj,jk+1,jp_tem)=  pts_flx (ji,jj,jk+1,jp_tem) + pts_flx (ji,jj,jk,jp_tem)
-
-                           ! set to 0 the cell we distributed over neigbourg cells
-                           pvol_flx(ji,jj,jk       ) = 0._wp
-                           pts_flx (ji,jj,jk,jp_sal) = 0._wp
-                           pts_flx (ji,jj,jk,jp_tem) = 0._wp
-                        ELSE
-                        ! case no adjacent cell on the horizontal and on the vertical
-                           IF ( lwp ) THEN   ! JMM : cAution this warning may occur on any mpp subdomain but numout is only
-                                             ! open for narea== 1 (lwp=T)
-                           WRITE(numout,*) 'W A R N I N G iscpl: no adjacent cell on the vertical and horizontal'
-                           WRITE(numout,*) '                     ',mig(ji),' ',mjg(jj),' ',jk
-                           WRITE(numout,*) '                     ',ji,' ',jj,' ',jk,' ',narea
-                           WRITE(numout,*) ' we are now looking for the closest wet cell on the horizontal '
-                           ENDIF
-                        ! We deal with these points later.
-                        END IF
-                     END IF
-                  END IF
-               END IF
-            END DO
-         END DO
-      END DO
-
-!!gm  ERROR !!!!
-!!    juste use tmask_i  or in case of ISF smask_i (to be created to compute the sum without halos)
-!
-!      CALL lbc_sum(pvol_flx(:,:,:       ),'T',1.)
-!      CALL lbc_sum(pts_flx (:,:,:,jp_sal),'T',1.)
-!      CALL lbc_sum(pts_flx (:,:,:,jp_tem),'T',1.)
-      STOP ' iscpl_cons:   please modify this module !'
-!!gm end
-      ! if no neighbour wet cell in case of 2close a cell", need to find the nearest wet point 
-      ! allocation and initialisation of the list of problematic point
-      ALLOCATE( inpts(jpnij) )
-      inpts(:) = 0
-
-      ! fill narea location with the number of problematic point
-      DO jk = 1,jpk-1
-         DO jj = 2,jpj-1
-            DO ji = fs_2,fs_jpim1
-               IF (     ptmask_b(ji,jj,jk) == 1._wp .AND. tmask(ji,jj,jk+1)  == 0._wp .AND. tmask_h(ji,jj) == 1._wp  &
-                  .AND. SUM(tmask(ji-1:ji+1,jj,jk)) + SUM(tmask(ji,jj-1:jj+1,jk)) == 0._wp) THEN
-                  inpts(narea) = inpts(narea) + 1 
-               END IF
-            END DO
-         END DO
-      END DO
-
-      ! build array of total problematic point on each cpu (share to each cpu)
-      CALL mpp_max('iscplhsb', inpts,jpnij) 
-
-      ! size of the new variable
-      npts  = SUM(inpts)    
-      
-      ! allocation of the coordinates, correction, index vector for the problematic points 
-      ALLOCATE(ixpts(npts), iypts(npts), izpts(npts), zcorr_vol(npts), zcorr_sal(npts), zcorr_tem(npts), zlon(npts), zlat(npts))
-      ixpts(:) = -9999 ; iypts(:) = -9999 ; izpts(:) = -9999 ; zlon(:) = -1.0e20_wp ; zlat(:) = -1.0e20_wp
-      zcorr_vol(:) = -1.0e20_wp
-      zcorr_sal(:) = -1.0e20_wp
-      zcorr_tem(:) = -1.0e20_wp
-
-      ! fill new variable
-      jpts = SUM(inpts(1:narea-1))
-      DO jk = 1,jpk-1
-         DO jj = 2,jpj-1
-            DO ji = fs_2,fs_jpim1
-               IF (     ptmask_b(ji,jj,jk) == 1._wp .AND. tmask(ji,jj,jk+1)  == 0._wp .AND. tmask_h(ji,jj) == 1._wp  &
-                  .AND. SUM(tmask(ji-1:ji+1,jj,jk)) + SUM(tmask(ji,jj-1:jj+1,jk)) == 0._wp) THEN
-                  jpts = jpts + 1  ! positioning in the inpts vector for the area narea
-                  ixpts(jpts) = ji           ; iypts(jpts) = jj ; izpts(jpts) = jk
-                  zlon (jpts) = glamt(ji,jj) ; zlat (jpts) = gphit(ji,jj)
-                  zcorr_vol(jpts) = pvol_flx(ji,jj,jk)
-                  zcorr_sal(jpts) = pts_flx (ji,jj,jk,jp_sal)
-                  zcorr_tem(jpts) = pts_flx (ji,jj,jk,jp_tem)
-
-                  ! set flx to 0 (safer)
-                  pvol_flx(ji,jj,jk       ) = 0.0_wp
-                  pts_flx (ji,jj,jk,jp_sal) = 0.0_wp
-                  pts_flx (ji,jj,jk,jp_tem) = 0.0_wp
-               END IF
-            END DO
-         END DO
-      END DO
-
-      ! build array of total problematic point on each cpu (share to each cpu)
-      ! point coordinates
-      CALL mpp_max('iscplhsb', zlat ,npts)
-      CALL mpp_max('iscplhsb', zlon ,npts)
-      CALL mpp_max('iscplhsb', izpts,npts)
-
-      ! correction values 
-      CALL mpp_max('iscplhsb', zcorr_vol,npts)
-      CALL mpp_max('iscplhsb', zcorr_sal,npts)
-      CALL mpp_max('iscplhsb', zcorr_tem,npts)
-
-      ! put correction term in the closest cell          
-      DO jpts = 1,npts
-         CALL dom_ngb(zlon(jpts), zlat(jpts), ixpts(jpts), iypts(jpts),'T', izpts(jpts))
-         DO jj = mj0(iypts(jpts)),mj1(iypts(jpts))
-            DO ji = mi0(ixpts(jpts)),mi1(ixpts(jpts))
-               jk = izpts(jpts)
-
-               IF (tmask_h(ji,jj) == 1._wp) THEN
-                  ! correct the vol_flx in the closest cell
-                  pvol_flx(ji,jj,jk)        =  pvol_flx(ji,jj,jk       ) + zcorr_vol(jpts)
-                  pts_flx (ji,jj,jk,jp_sal) =  pts_flx (ji,jj,jk,jp_sal) + zcorr_sal(jpts)
-                  pts_flx (ji,jj,jk,jp_tem) =  pts_flx (ji,jj,jk,jp_tem) + zcorr_tem(jpts)
-
-                  ! set correction to 0
-                  zcorr_vol(jpts) = 0.0_wp
-                  zcorr_sal(jpts) = 0.0_wp
-                  zcorr_tem(jpts) = 0.0_wp
-               END IF
-            END DO
-         END DO
-      END DO
-
-      ! deallocate variables 
-      DEALLOCATE(inpts)
-      DEALLOCATE(ixpts, iypts, izpts, zcorr_vol, zcorr_sal, zcorr_tem, zlon, zlat)
-    
-      ! add contribution store on the hallo (lbclnk remove one of the contribution)
-      pvol_flx(:,:,:       ) = pvol_flx(:,:,:       ) * tmask(:,:,:)
-      pts_flx (:,:,:,jp_sal) = pts_flx (:,:,:,jp_sal) * tmask(:,:,:)
-      pts_flx (:,:,:,jp_tem) = pts_flx (:,:,:,jp_tem) * tmask(:,:,:)
-
-!!gm  ERROR !!!!
-!!    juste use tmask_i  or in case of ISF smask_i (to be created to compute the sum without halos)
-!
-!      ! compute sum over the halo and set it to 0.
-!      CALL lbc_sum(pvol_flx(:,:,:       ),'T',1._wp)
-!      CALL lbc_sum(pts_flx (:,:,:,jp_sal),'T',1._wp)
-!      CALL lbc_sum(pts_flx (:,:,:,jp_tem),'T',1._wp)
-!!gm end
-
-      !
-   END SUBROUTINE iscpl_cons
-
-
-   SUBROUTINE iscpl_div( phdivn )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE iscpl_div  ***
-      !!
-      !! ** Purpose :   update the horizontal divergenc
-      !!
-      !! ** Method  :
-      !!                CAUTION : iscpl is positive (inflow) and expressed in m/s
-      !!
-      !! ** Action  :   phdivn   increase by the iscpl correction term
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   phdivn   ! horizontal divergence
-      !!
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      !!----------------------------------------------------------------------
-      !
-      DO jk = 1, jpk
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               phdivn(ji,jj,jk) = phdivn(ji,jj,jk) + hdiv_iscpl(ji,jj,jk) / e3t_n(ji,jj,jk)
-            END DO
-         END DO
-      END DO
-      !
-   END SUBROUTINE iscpl_div
-
-END MODULE iscplhsb
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/iscplini.F90
===================================================================
--- NEMO/trunk/src/OCE/DOM/iscplini.F90	(revision 11310)
+++ 	(revision )
@@ -1,90 +1,0 @@
-MODULE iscplini
-   !!======================================================================
-   !!                       ***  MODULE  sbciscpl  ***
-   !! Ocean forcing:  ?????
-   !!=====================================================================
-   !! History :  NEMO  ! 2015-01 P. Mathiot: original 
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   iscpl_init     : initialisation routine (namelist)
-   !!   iscpl_alloc    : allocation of correction variables
-   !!----------------------------------------------------------------------
-   USE oce             ! global tra/dyn variable
-   USE dom_oce         ! ocean space and time domain
-   !
-   USE lib_mpp         ! MPP library
-   USE lib_fortran     ! MPP library
-   USE in_out_manager  ! I/O manager
-
-   IMPLICIT NONE
-   PRIVATE
-   
-   PUBLIC   iscpl_init      
-   PUBLIC   iscpl_alloc 
-   
-   !                                 !!* namsbc_iscpl namelist *
-   LOGICAL , PUBLIC ::   ln_hsb       !:
-   INTEGER , PUBLIC ::   nn_fiscpl    !:
-   INTEGER , PUBLIC ::   nn_drown     !:
-   
-   INTEGER , PUBLIC ::   nstp_iscpl   !:
-   REAL(wp), PUBLIC ::   rdt_iscpl    !: 
-   !
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   hdiv_iscpl   !:
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   htsc_iscpl   !:
-
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id$
-   !! Software governed by the CeCILL license (see ./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   INTEGER FUNCTION iscpl_alloc()
-      !!----------------------------------------------------------------------
-      !!                ***  ROUTINE sbc_iscpl_alloc  ***
-      !!----------------------------------------------------------------------
-      ALLOCATE( htsc_iscpl(jpi,jpj,jpk,jpts) , hdiv_iscpl(jpi,jpj,jpk) , STAT=iscpl_alloc )
-         !
-      CALL mpp_sum ( 'iscplini', iscpl_alloc )
-      IF( iscpl_alloc > 0 )   CALL ctl_warn('iscpl_alloc: allocation of arrays failed')
-   END FUNCTION iscpl_alloc
-
-
-   SUBROUTINE iscpl_init()
-      !!----------------------------------------------------------------------
-      !!----------------------------------------------------------------------
-      INTEGER ::   ios           ! Local integer output status for namelist read
-      NAMELIST/namsbc_iscpl/ nn_fiscpl, ln_hsb, nn_drown
-      !!----------------------------------------------------------------------
-      !
-      nn_fiscpl = 0
-      ln_hsb    = .FALSE.
-      REWIND( numnam_ref )              ! Namelist namsbc_iscpl in reference namelist : Ice sheet coupling
-      READ  ( numnam_ref, namsbc_iscpl, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_iscpl in reference namelist', lwp )
-      REWIND( numnam_cfg )              ! Namelist namsbc_iscpl in configuration namelist : Ice Sheet coupling
-      READ  ( numnam_cfg, namsbc_iscpl, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_iscpl in configuration namelist', lwp )
-      IF(lwm) WRITE ( numond, namsbc_iscpl )
-      !
-      nstp_iscpl=MIN( nn_fiscpl, nitend-nit000+1 ) ! the coupling period have to be less or egal than the total number of time step
-      rdt_iscpl = nstp_iscpl * rn_rdt
-      !
-      IF (lwp) THEN
-         WRITE(numout,*) 'iscpl_rst:'
-         WRITE(numout,*) '~~~~~~~~~'
-         WRITE(numout,*) ' coupling     flag (ln_iscpl )            = ', ln_iscpl
-         WRITE(numout,*) ' conservation flag (ln_hsb   )            = ', ln_hsb
-         WRITE(numout,*) ' nb of stp for cons (rn_fiscpl)           = ', nstp_iscpl
-         IF (nstp_iscpl .NE. nn_fiscpl) WRITE(numout,*) 'W A R N I N G: nb of stp for cons has been modified &
-            &                                           (larger than run length)'
-         WRITE(numout,*) ' coupling time step                       = ', rdt_iscpl
-         WRITE(numout,*) ' number of call of the extrapolation loop = ', nn_drown
-      ENDIF
-      !
-   END SUBROUTINE iscpl_init
-
-   !!======================================================================
-END MODULE iscplini
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/iscplrst.F90
===================================================================
--- NEMO/trunk/src/OCE/DOM/iscplrst.F90	(revision 11310)
+++ 	(revision )
@@ -1,407 +1,0 @@
-MODULE iscplrst
-   !!======================================================================
-   !!                       ***  MODULE  iscplrst  ***
-   !! Ocean forcing: update the restart file in case of ice sheet/ocean coupling
-   !!=====================================================================
-   !! History :  NEMO  ! 2015-01 P. Mathiot: original 
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   iscpl_stp          : step management
-   !!   iscpl_rst_interpol : restart interpolation in case of coupling with ice sheet
-   !!----------------------------------------------------------------------
-   USE oce             ! global tra/dyn variable
-   USE dom_oce         ! ocean space and time domain
-   USE domwri          ! ocean space and time domain
-   USE domvvl   , ONLY : dom_vvl_interpol
-   USE phycst          ! physical constants
-   USE sbc_oce         ! surface boundary condition variables
-   USE iscplini        ! ice sheet coupling: initialisation
-   USE iscplhsb        ! ice sheet coupling: conservation
-   !
-   USE in_out_manager  ! I/O manager
-   USE iom             ! I/O module
-   USE lib_mpp         ! MPP library
-   USE lib_fortran     ! MPP library
-   USE lbclnk          ! communication
-
-   IMPLICIT NONE
-   PRIVATE
-   
-   PUBLIC   iscpl_stp          ! step management 
-   !!
-   !! * Substitutions  
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id$
-   !! Software governed by the CeCILL license (see ./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE iscpl_stp
-      !!---------------------------------------------------------------------- 
-      !!                   ***  ROUTINE iscpl_stp  ***
-      !! 
-      !! ** Purpose : compute initialisation
-      !!              compute extrapolation of restart variable un, vn, tsn, sshn (wetting/drying)   
-      !!              compute correction term if needed
-      !! 
-      !!----------------------------------------------------------------------
-      INTEGER  ::   inum0
-      REAL(wp), DIMENSION(jpi,jpj)     ::   zsmask_b
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztmask_b, zumask_b, zvmask_b
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ze3t_b  , ze3u_b  , ze3v_b  
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zdepw_b
-      CHARACTER(20) :: cfile
-      !!----------------------------------------------------------------------
-      !
-      !                       ! get restart variable
-      CALL iom_get( numror, jpdom_autoglo, 'tmask'  , ztmask_b, ldxios = lrxios   ) ! need to extrapolate T/S
-      CALL iom_get( numror, jpdom_autoglo, 'umask'  , zumask_b, ldxios = lrxios   ) ! need to correct barotropic velocity
-      CALL iom_get( numror, jpdom_autoglo, 'vmask'  , zvmask_b, ldxios = lrxios   ) ! need to correct barotropic velocity
-      CALL iom_get( numror, jpdom_autoglo, 'smask'  , zsmask_b, ldxios = lrxios   ) ! need to correct barotropic velocity
-      CALL iom_get( numror, jpdom_autoglo, 'e3t_n'  , ze3t_b(:,:,:), ldxios = lrxios )  ! need to compute temperature correction
-      CALL iom_get( numror, jpdom_autoglo, 'e3u_n'  , ze3u_b(:,:,:), ldxios = lrxios )  ! need to correct barotropic velocity
-      CALL iom_get( numror, jpdom_autoglo, 'e3v_n'  , ze3v_b(:,:,:), ldxios = lrxios )  ! need to correct barotropic velocity
-      CALL iom_get( numror, jpdom_autoglo, 'gdepw_n', zdepw_b(:,:,:), ldxios = lrxios ) ! need to interpol vertical profile (vvl)
-      !
-      CALL iscpl_init()       ! read namelist
-      !                       ! Extrapolation/interpolation of modify cell and new cells ... (maybe do it later after domvvl)
-      CALL iscpl_rst_interpol( ztmask_b, zumask_b, zvmask_b, zsmask_b, ze3t_b, ze3u_b, ze3v_b, zdepw_b )
-      !
-      IF ( ln_hsb ) THEN      ! compute correction if conservation needed
-         IF( iscpl_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'rst_iscpl : unable to allocate rst_iscpl arrays' )
-         CALL iscpl_cons(ztmask_b, zsmask_b, ze3t_b, htsc_iscpl, hdiv_iscpl, rdt_iscpl)
-      END IF
-         
-      !                       ! create  a domain file
-      IF( ln_meshmask .AND. ln_iscpl )   CALL dom_wri
-      !
-      IF ( ln_hsb ) THEN
-         cfile='correction'
-         cfile = TRIM( cfile )
-         CALL iom_open  ( cfile, inum0, ldwrt = .TRUE. )
-         CALL iom_rstput( 0, 0, inum0, 'vol_cor', hdiv_iscpl(:,:,:) )
-         CALL iom_rstput( 0, 0, inum0, 'tem_cor', htsc_iscpl(:,:,:,jp_tem) )
-         CALL iom_rstput( 0, 0, inum0, 'sal_cor', htsc_iscpl(:,:,:,jp_sal) )
-         CALL iom_close ( inum0 )
-      END IF
-      !
-      neuler = 0              ! next step is an euler time step
-      !
-      !                       ! set _b and _n variables equal
-      tsb (:,:,:,:) = tsn (:,:,:,:)
-      ub  (:,:,:)   = un  (:,:,:)
-      vb  (:,:,:)   = vn  (:,:,:)
-      sshb(:,:)     = sshn(:,:)
-      !
-      !                       ! set _b and _n vertical scale factor equal
-      e3t_b (:,:,:) = e3t_n (:,:,:)
-      e3u_b (:,:,:) = e3u_n (:,:,:)
-      e3v_b (:,:,:) = e3v_n (:,:,:)
-      !
-      e3uw_b (:,:,:) = e3uw_n (:,:,:)
-      e3vw_b (:,:,:) = e3vw_n (:,:,:)
-      gdept_b(:,:,:) = gdept_n(:,:,:)
-      gdepw_b(:,:,:) = gdepw_n(:,:,:)
-      hu_b   (:,:)   = hu_n   (:,:)
-      hv_b   (:,:)   = hv_n   (:,:)
-      r1_hu_b(:,:)   = r1_hu_n(:,:)
-      r1_hv_b(:,:)   = r1_hv_n(:,:)
-      !
-   END SUBROUTINE iscpl_stp
-
-
-   SUBROUTINE iscpl_rst_interpol (ptmask_b, pumask_b, pvmask_b, psmask_b, pe3t_b, pe3u_b, pe3v_b, pdepw_b)
-      !!---------------------------------------------------------------------- 
-      !!                   ***  ROUTINE iscpl_rst_interpol  ***
-      !! 
-      !! ** Purpose :   compute new tn, sn, un, vn and sshn in case of evolving geometry of ice shelves 
-      !!                compute 2d fields of heat, salt and volume correction
-      !! 
-      !! ** Method  :   tn, sn : extrapolation from neigbourg cells
-      !!                un, vn : fill with 0 velocity and keep barotropic transport by modifing surface velocity or adjacent velocity
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(:,:,:  ), INTENT(in ) :: ptmask_b, pumask_b, pvmask_b    !! mask before
-      REAL(wp), DIMENSION(:,:,:  ), INTENT(in ) :: pe3t_b  , pe3u_b  , pe3v_b      !! scale factor before
-      REAL(wp), DIMENSION(:,:,:  ), INTENT(in ) :: pdepw_b                         !! depth w before
-      REAL(wp), DIMENSION(:,:    ), INTENT(in ) :: psmask_b                        !! mask before
-      !!
-      INTEGER :: ji, jj, jk, iz          !! loop index
-      INTEGER :: jip1, jim1, jjp1, jjm1, jkp1, jkm1
-      !!
-      REAL(wp):: summsk, zsum, zsum1, zarea, zsumn, zsumb
-      REAL(wp):: zdz, zdzm1, zdzp1
-      !!
-      REAL(wp), DIMENSION(jpi,jpj)          :: zdmask , zsmask0, zucorr, zbub, zbun, zssh0, zhu1, zde3t
-      REAL(wp), DIMENSION(jpi,jpj)          :: zdsmask, zsmask1, zvcorr, zbvb, zbvn, zssh1, zhv1
-      REAL(wp), DIMENSION(jpi,jpj,jpk)      :: ztmask0, zwmaskn, ztrp
-      REAL(wp), DIMENSION(jpi,jpj,jpk)      :: ztmask1, zwmaskb, ztmp3d
-      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts) :: zts0
-      !!----------------------------------------------------------------------
-      !
-      !                 ! mask value to be sure
-      tsn(:,:,:,jp_tem) = tsn(:,:,:,jp_tem) * ptmask_b(:,:,:)
-      tsn(:,:,:,jp_sal) = tsn(:,:,:,jp_sal) * ptmask_b(:,:,:)
-      !
-      !                 ! compute wmask
-      zwmaskn(:,:,1) = tmask   (:,:,1)
-      zwmaskb(:,:,1) = ptmask_b(:,:,1)
-      DO jk = 2,jpk
-         zwmaskn(:,:,jk) =  tmask  (:,:,jk) *  tmask  (:,:,jk-1)
-         zwmaskb(:,:,jk) = ptmask_b(:,:,jk) * ptmask_b(:,:,jk-1)
-      END DO
-      !    
-      !                 ! compute new ssh if we open a full water column (average of the closest neigbourgs)  
-      sshb (:,:)=sshn(:,:)
-      zssh0(:,:)=sshn(:,:)
-      zsmask0(:,:) = psmask_b(:,:)
-      zsmask1(:,:) = psmask_b(:,:)
-      DO iz = 1, 10                 ! need to be tuned (configuration dependent) (OK for ISOMIP+)
-         zdsmask(:,:) = ssmask(:,:)-zsmask0(:,:)
-         DO jj = 2,jpj-1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               jip1=ji+1; jim1=ji-1;
-               jjp1=jj+1; jjm1=jj-1;
-               summsk=(zsmask0(jip1,jj)+zsmask0(jim1,jj)+zsmask0(ji,jjp1)+zsmask0(ji,jjm1))
-               IF (zdsmask(ji,jj) == 1._wp .AND. summsk /= 0._wp) THEN
-                  sshn(ji,jj)=( zssh0(jip1,jj)*zsmask0(jip1,jj)     &
-                  &           + zssh0(jim1,jj)*zsmask0(jim1,jj)     &
-                  &           + zssh0(ji,jjp1)*zsmask0(ji,jjp1)     &
-                  &           + zssh0(ji,jjm1)*zsmask0(ji,jjm1))/summsk
-                  zsmask1(ji,jj)=1._wp
-               ENDIF
-            END DO
-         END DO
-         CALL lbc_lnk_multi( 'iscplrst', sshn, 'T', 1., zsmask1, 'T', 1. )
-         zssh0   = sshn
-         zsmask0 = zsmask1
-      END DO
-      sshn(:,:) = sshn(:,:) * ssmask(:,:)
-
-!=============================================================================
-!PM: Is this needed since introduction of VVL by default?
-      IF ( .NOT.ln_linssh ) THEN
-      ! Reconstruction of all vertical scale factors at now time steps
-      ! =============================================================================
-      ! Horizontal scale factor interpolations
-      ! --------------------------------------
-         DO jk = 1,jpk
-            DO jj=1,jpj
-               DO ji=1,jpi
-                  IF (tmask(ji,jj,1) == 0._wp .OR. ptmask_b(ji,jj,1) == 0._wp) THEN
-                     e3t_n(ji,jj,jk) = e3t_0(ji,jj,jk) * ( 1._wp + sshn(ji,jj) /   &
-                     &   ( ht_0(ji,jj) + 1._wp - ssmask(ji,jj) ) * tmask(ji,jj,jk) )
-                  ENDIF
-               END DO
-            END DO
-         END DO
-         !
-         CALL dom_vvl_interpol( e3t_n(:,:,:), e3u_n(:,:,:), 'U' )
-         CALL dom_vvl_interpol( e3t_n(:,:,:), e3v_n(:,:,:), 'V' )
-         CALL dom_vvl_interpol( e3u_n(:,:,:), e3f_n(:,:,:), 'F' )
-
-         ! Vertical scale factor interpolations
-         ! ------------------------------------
-         CALL dom_vvl_interpol( e3t_n(:,:,:), e3w_n (:,:,:), 'W'  )
-         CALL dom_vvl_interpol( e3u_n(:,:,:), e3uw_n(:,:,:), 'UW' )
-         CALL dom_vvl_interpol( e3v_n(:,:,:), e3vw_n(:,:,:), 'VW' )
-         
-         ! t- and w- points depth
-         ! ----------------------
-         gdept_n(:,:,1) = 0.5_wp * e3w_n(:,:,1)
-         gdepw_n(:,:,1) = 0.0_wp
-         gde3w_n(:,:,1) = gdept_n(:,:,1) - sshn(:,:)
-         DO jj = 1,jpj
-            DO ji = 1,jpi
-               DO jk = 2,mikt(ji,jj)-1
-                  gdept_n(ji,jj,jk) = gdept_0(ji,jj,jk)
-                  gdepw_n(ji,jj,jk) = gdepw_0(ji,jj,jk)
-                  gde3w_n(ji,jj,jk) = gdept_0(ji,jj,jk) - sshn(ji,jj)
-               END DO
-               IF (mikt(ji,jj) > 1) THEN
-                  jk = mikt(ji,jj)
-                  gdept_n(ji,jj,jk) = gdepw_0(ji,jj,jk) + 0.5_wp * e3w_n(ji,jj,jk)
-                  gdepw_n(ji,jj,jk) = gdepw_0(ji,jj,jk)
-                  gde3w_n(ji,jj,jk) = gdept_n(ji,jj,jk  ) - sshn   (ji,jj)
-               END IF
-               DO jk = mikt(ji,jj)+1, jpk
-                  gdept_n(ji,jj,jk) = gdept_n(ji,jj,jk-1) + e3w_n(ji,jj,jk)
-                  gdepw_n(ji,jj,jk) = gdepw_n(ji,jj,jk-1) + e3t_n(ji,jj,jk-1)
-                  gde3w_n(ji,jj,jk) = gdept_n(ji,jj,jk  ) - sshn (ji,jj)
-               END DO
-            END DO
-         END DO
-
-      ! t-, u- and v- water column thickness
-      ! ------------------------------------
-         ht_n(:,:) = 0._wp ; hu_n(:,:) = 0._wp ; hv_n(:,:) = 0._wp
-         DO jk = 1, jpkm1
-            hu_n(:,:) = hu_n(:,:) + e3u_n(:,:,jk) * umask(:,:,jk)
-            hv_n(:,:) = hv_n(:,:) + e3v_n(:,:,jk) * vmask(:,:,jk)
-            ht_n(:,:) = ht_n(:,:) + e3t_n(:,:,jk) * tmask(:,:,jk)
-         END DO
-         !                                        ! Inverse of the local depth
-         r1_hu_n(:,:) = 1._wp / ( hu_n(:,:) + 1._wp - ssumask(:,:) ) * ssumask(:,:)
-         r1_hv_n(:,:) = 1._wp / ( hv_n(:,:) + 1._wp - ssvmask(:,:) ) * ssvmask(:,:)
-
-      END IF
-
-!=============================================================================
-! compute velocity
-! compute velocity in order to conserve barotropic velocity (modification by poderation of the scale factor).
-      ub(:,:,:)=un(:,:,:)
-      vb(:,:,:)=vn(:,:,:)
-      DO jk = 1,jpk
-         DO jj = 1,jpj
-            DO ji = 1,jpi
-               un(ji,jj,jk) = ub(ji,jj,jk)*pe3u_b(ji,jj,jk)*pumask_b(ji,jj,jk)/e3u_n(ji,jj,jk)*umask(ji,jj,jk);
-               vn(ji,jj,jk) = vb(ji,jj,jk)*pe3v_b(ji,jj,jk)*pvmask_b(ji,jj,jk)/e3v_n(ji,jj,jk)*vmask(ji,jj,jk);
-            END DO
-         END DO
-      END DO
-
-! compute new velocity if we close a cell (check barotropic velocity and change velocity over the water column)
-! compute barotropic velocity now and after 
-      ztrp(:,:,:) = ub(:,:,:)*pe3u_b(:,:,:); 
-      zbub(:,:)   = SUM(ztrp,DIM=3)
-      ztrp(:,:,:) = vb(:,:,:)*pe3v_b(:,:,:); 
-      zbvb(:,:)   = SUM(ztrp,DIM=3)
-      ztrp(:,:,:) = un(:,:,:)*e3u_n(:,:,:); 
-      zbun(:,:)   = SUM(ztrp,DIM=3)
-      ztrp(:,:,:) = vn(:,:,:)*e3v_n(:,:,:); 
-      zbvn(:,:)   = SUM(ztrp,DIM=3)
-
-      ! new water column
-      zhu1=0.0_wp ;
-      zhv1=0.0_wp ;
-      DO jk  = 1,jpk
-        zhu1(:,:) = zhu1(:,:) + e3u_n(:,:,jk) * umask(:,:,jk)
-        zhv1(:,:) = zhv1(:,:) + e3v_n(:,:,jk) * vmask(:,:,jk)
-      END DO
-      
-      ! compute correction      
-      zucorr = 0._wp
-      zvcorr = 0._wp
-      DO jj = 1,jpj
-         DO ji = 1,jpi
-            IF (zbun(ji,jj) /= zbub(ji,jj) .AND. zhu1(ji,jj) /= 0._wp ) THEN
-               zucorr(ji,jj) = (zbun(ji,jj) - zbub(ji,jj))/zhu1(ji,jj)
-            END IF
-            IF (zbvn(ji,jj) /= zbvb(ji,jj) .AND. zhv1(ji,jj) /= 0._wp ) THEN
-               zvcorr(ji,jj) = (zbvn(ji,jj) - zbvb(ji,jj))/zhv1(ji,jj)
-            END IF
-         END DO
-      END DO 
-      
-      ! update velocity
-      DO jk  = 1,jpk
-         un(:,:,jk)=(un(:,:,jk) - zucorr(:,:))*umask(:,:,jk)
-         vn(:,:,jk)=(vn(:,:,jk) - zvcorr(:,:))*vmask(:,:,jk)
-      END DO
-
-!=============================================================================
-      ! compute temp and salt
-      ! compute new tn and sn if we open a new cell
-      tsb (:,:,:,:) = tsn(:,:,:,:)
-      zts0(:,:,:,:) = tsn(:,:,:,:)
-      ztmask1(:,:,:) = ptmask_b(:,:,:)
-      ztmask0(:,:,:) = ptmask_b(:,:,:)
-      DO iz = 1,nn_drown ! resolution dependent (OK for ISOMIP+ case)
-          DO jk = 1,jpk-1
-              zdmask=tmask(:,:,jk)-ztmask0(:,:,jk);
-              DO jj = 2,jpj-1
-                 DO ji = fs_2,fs_jpim1
-                      jip1=ji+1; jim1=ji-1;
-                      jjp1=jj+1; jjm1=jj-1;
-                      summsk= (ztmask0(jip1,jj  ,jk)+ztmask0(jim1,jj  ,jk)+ztmask0(ji  ,jjp1,jk)+ztmask0(ji  ,jjm1,jk))
-                      IF (zdmask(ji,jj) == 1._wp .AND. summsk /= 0._wp) THEN
-                      !! horizontal basic extrapolation
-                         tsn(ji,jj,jk,1)=( zts0(jip1,jj  ,jk,1)*ztmask0(jip1,jj  ,jk) &
-                         &                +zts0(jim1,jj  ,jk,1)*ztmask0(jim1,jj  ,jk) &
-                         &                +zts0(ji  ,jjp1,jk,1)*ztmask0(ji  ,jjp1,jk) &
-                         &                +zts0(ji  ,jjm1,jk,1)*ztmask0(ji  ,jjm1,jk) ) / summsk
-                         tsn(ji,jj,jk,2)=( zts0(jip1,jj  ,jk,2)*ztmask0(jip1,jj  ,jk) &
-                         &                +zts0(jim1,jj  ,jk,2)*ztmask0(jim1,jj  ,jk) &
-                         &                +zts0(ji  ,jjp1,jk,2)*ztmask0(ji  ,jjp1,jk) &
-                         &                +zts0(ji  ,jjm1,jk,2)*ztmask0(ji  ,jjm1,jk) ) / summsk
-                         ztmask1(ji,jj,jk)=1
-                      ELSEIF (zdmask(ji,jj) == 1._wp .AND. summsk == 0._wp) THEN
-                      !! vertical extrapolation if horizontal extrapolation failed
-                         jkm1=max(1,jk-1) ; jkp1=min(jpk,jk+1)
-                         summsk=(ztmask0(ji,jj,jkm1)+ztmask0(ji,jj,jkp1))
-                         IF (zdmask(ji,jj) == 1._wp .AND. summsk /= 0._wp ) THEN
-                            tsn(ji,jj,jk,1)=( zts0(ji,jj,jkp1,1)*ztmask0(ji,jj,jkp1)     &
-                            &                +zts0(ji,jj,jkm1,1)*ztmask0(ji,jj,jkm1))/summsk
-                            tsn(ji,jj,jk,2)=( zts0(ji,jj,jkp1,2)*ztmask0(ji,jj,jkp1)     &
-                            &                +zts0(ji,jj,jkm1,2)*ztmask0(ji,jj,jkm1))/summsk
-                            ztmask1(ji,jj,jk)=1._wp
-                         END IF
-                      END IF
-                  END DO
-              END DO
-          END DO
-          
-          CALL lbc_lnk_multi( 'iscplrst', tsn(:,:,:,jp_tem), 'T', 1., tsn(:,:,:,jp_sal), 'T', 1., ztmask1, 'T', 1.)
-
-          ! update
-          zts0(:,:,:,:) = tsn(:,:,:,:)
-          ztmask0 = ztmask1
-
-      END DO
-
-      ! mask new tsn field
-      tsn(:,:,:,jp_tem) = tsn(:,:,:,jp_tem) * tmask(:,:,:)
-      tsn(:,:,:,jp_sal) = tsn(:,:,:,jp_sal) * tmask(:,:,:)
-
-      ! compute new T/S (interpolation) if vvl only for common wet cell in before and after wmask
-      !PM: Is this IF needed since change to VVL by default
-      IF (.NOT.ln_linssh) THEN
-         DO jk = 2,jpk-1
-            DO jj = 1,jpj
-               DO ji = 1,jpi
-                  IF (zwmaskn(ji,jj,jk) * zwmaskb(ji,jj,jk) == 1._wp .AND.   &
-                  &      (tmask(ji,jj,1)==0._wp .OR. ptmask_b(ji,jj,1)==0._wp) ) THEN
-                     !compute weight
-                     zdzp1 = MAX(0._wp,gdepw_n(ji,jj,jk+1) - pdepw_b(ji,jj,jk+1))
-                     zdz   =           gdepw_n(ji,jj,jk+1) - pdepw_b(ji,jj,jk  ) 
-                     zdzm1 = MAX(0._wp,pdepw_b(ji,jj,jk  ) - gdepw_n(ji,jj,jk  ))
-                     IF (zdz .LT. 0._wp) THEN 
-                        CALL ctl_stop( 'STOP', 'rst_iscpl : unable to compute the interpolation' )
-                     END IF
-                     tsn(ji,jj,jk,jp_tem) = ( zdzp1*tsb(ji,jj,jk+1,jp_tem)      &
-                        &                   + zdz  *tsb(ji,jj,jk  ,jp_tem)      &
-                        &                   + zdzm1*tsb(ji,jj,jk-1,jp_tem)      )/e3t_n(ji,jj,jk)
-                     tsn(ji,jj,jk,jp_sal) = ( zdzp1*tsb(ji,jj,jk+1,jp_sal)      &
-                        &                   + zdz  *tsb(ji,jj,jk  ,jp_sal)      &
-                        &                   + zdzm1*tsb(ji,jj,jk-1,jp_sal)      )/e3t_n(ji,jj,jk)
-                  END IF
-               END DO
-            END DO
-         END DO               
-      END IF
-
-      ! closed pool
-      ! -----------------------------------------------------------------------------------------
-      ! case we open a cell but no neigbour cells available to get an estimate of T and S
-      WHERE (tmask(:,:,:) == 1._wp .AND. tsn(:,:,:,2) == 0._wp) 
-         tsn(:,:,:,2) = -99._wp  ! Special value for closed pool (checking purpose in output.init)
-         tmask(:,:,:) = 0._wp    ! set mask to 0 to run
-         umask(:,:,:) = 0._wp
-         vmask(:,:,:) = 0._wp
-      END WHERE
-      
-      ! set mbkt and mikt to 1 in thiese location
-      WHERE (SUM(tmask,dim=3) == 0)
-         mbkt(:,:)=1 ; mbku(:,:)=1 ; mbkv(:,:)=1
-         mikt(:,:)=1 ; miku(:,:)=1 ; mikv(:,:)=1
-      END WHERE
-      ! -------------------------------------------------------------------------------------------
-      ! compute new tn and sn if we close cell 
-      ! nothing to do
-      ! 
-   END SUBROUTINE iscpl_rst_interpol
-
-   !!======================================================================
-END MODULE iscplrst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcisf.F90
===================================================================
--- NEMO/trunk/src/OCE/SBC/sbcisf.F90	(revision 11310)
+++ 	(revision )
@@ -1,902 +1,0 @@
-MODULE sbcisf
-   !!======================================================================
-   !!                       ***  MODULE  sbcisf  ***
-   !! Surface module :  update surface ocean boundary condition under ice
-   !!                   shelf
-   !!======================================================================
-   !! History :  3.2  !  2011-02  (C.Harris  ) Original code isf cav
-   !!            X.X  !  2006-02  (C. Wang   ) Original code bg03
-   !!            3.4  !  2013-03  (P. Mathiot) Merging + parametrization
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   sbc_isf       : update sbc under ice shelf
-   !!----------------------------------------------------------------------
-   USE oce            ! ocean dynamics and tracers
-   USE dom_oce        ! ocean space and time domain
-   USE phycst         ! physical constants
-   USE eosbn2         ! equation of state
-   USE sbc_oce        ! surface boundary condition: ocean fields
-   USE zdfdrg         ! vertical physics: top/bottom drag coef.
-   !
-   USE in_out_manager ! I/O manager
-   USE iom            ! I/O library
-   USE fldread        ! read input field at current time step
-   USE lbclnk         !
-   USE lib_fortran    ! glob_sum
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   sbc_isf, sbc_isf_init, sbc_isf_div, sbc_isf_alloc  ! routine called in sbcmod and divhor
-
-   ! public in order to be able to output then 
-
-   REAL(wp), PUBLIC ::   rn_hisf_tbl                 !: thickness of top boundary layer [m]
-   INTEGER , PUBLIC ::   nn_isf                      !: flag to choose between explicit/param/specified  
-   INTEGER , PUBLIC ::   nn_isfblk                   !: flag to choose the bulk formulation to compute the ice shelf melting
-   INTEGER , PUBLIC ::   nn_gammablk                 !: flag to choose how the exchange coefficient is computed
-   REAL(wp), PUBLIC ::   rn_gammat0                  !: temperature exchange coeficient []
-   REAL(wp), PUBLIC ::   rn_gammas0                  !: salinity    exchange coeficient []
-
-   INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   misfkt   , misfkb        !: Level of ice shelf base
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   rzisf_tbl                !: depth of calving front (shallowest point) nn_isf ==2/3
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   rhisf_tbl, rhisf_tbl_0   !: thickness of tbl  [m]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   r1_hisf_tbl              !: 1/thickness of tbl
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   ralpha                   !: proportion of bottom cell influenced by tbl 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   risfLeff                 !: effective length (Leff) BG03 nn_isf==2
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   ttbl, stbl, utbl, vtbl   !: top boundary layer variable at T point
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   qisf                     !: net heat flux from ice shelf      [W/m2]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   risf_tsc_b, risf_tsc     !: before and now T & S isf contents [K.m/s & PSU.m/s]  
-
-   LOGICAL, PUBLIC ::   l_isfcpl = .false.       !: isf recieved from oasis
-
-   REAL(wp), PUBLIC, SAVE ::   rcpisf   = 2000.0_wp     !: specific heat of ice shelf             [J/kg/K]
-   REAL(wp), PUBLIC, SAVE ::   rkappa   = 1.54e-6_wp    !: heat diffusivity through the ice-shelf [m2/s]
-   REAL(wp), PUBLIC, SAVE ::   rhoisf   = 920.0_wp      !: volumic mass of ice shelf              [kg/m3]
-   REAL(wp), PUBLIC, SAVE ::   tsurf    = -20.0_wp      !: air temperature on top of ice shelf    [C]
-   REAL(wp), PUBLIC, SAVE ::   rLfusisf = 0.334e6_wp    !: latent heat of fusion of ice shelf     [J/kg]
-
-!: Variable used in fldread to read the forcing file (nn_isf == 4 .OR. nn_isf == 3)
-   CHARACTER(len=100), PUBLIC           :: cn_dirisf  = './' !: Root directory for location of ssr files
-   TYPE(FLD_N)       , PUBLIC           :: sn_fwfisf         !: information about the isf melting file to be read
-   TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_fwfisf
-   TYPE(FLD_N)       , PUBLIC           :: sn_rnfisf         !: information about the isf melting param.   file to be read
-   TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_rnfisf           
-   TYPE(FLD_N)       , PUBLIC           :: sn_depmax_isf     !: information about the grounding line depth file to be read
-   TYPE(FLD_N)       , PUBLIC           :: sn_depmin_isf     !: information about the calving   line depth file to be read
-   TYPE(FLD_N)       , PUBLIC           :: sn_Leff_isf       !: information about the effective length     file to be read
-   
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id$
-   !! Software governed by the CeCILL license (see ./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
- 
-  SUBROUTINE sbc_isf( kt )
-      !!---------------------------------------------------------------------
-      !!                  ***  ROUTINE sbc_isf  ***
-      !!
-      !! ** Purpose : Compute Salt and Heat fluxes related to ice_shelf 
-      !!              melting and freezing 
-      !!
-      !! ** Method  :  4 parameterizations are available according to nn_isf 
-      !!               nn_isf = 1 : Realistic ice_shelf formulation
-      !!                        2 : Beckmann & Goose parameterization
-      !!                        3 : Specified runoff in deptht (Mathiot & al. )
-      !!                        4 : specified fwf and heat flux forcing beneath the ice shelf
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kt   ! ocean time step
-      !
-      INTEGER ::   ji, jj, jk   ! loop index
-      INTEGER ::   ikt, ikb     ! local integers
-      REAL(wp), DIMENSION(jpi,jpj) ::   zt_frz, zdep   ! freezing temperature (zt_frz) at depth (zdep) 
-      REAL(wp), DIMENSION(:,:)  , ALLOCATABLE ::   zqhcisf2d
-      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   zfwfisf3d, zqhcisf3d, zqlatisf3d
-      !!---------------------------------------------------------------------
-      !
-      IF( MOD( kt-1, nn_fsbc) == 0 ) THEN    ! compute salt and heat flux
-         !
-         SELECT CASE ( nn_isf )
-         CASE ( 1 )    ! realistic ice shelf formulation
-            ! compute T/S/U/V for the top boundary layer
-            CALL sbc_isf_tbl(tsn(:,:,:,jp_tem),ttbl(:,:),'T')
-            CALL sbc_isf_tbl(tsn(:,:,:,jp_sal),stbl(:,:),'T')
-            CALL sbc_isf_tbl(un(:,:,:)        ,utbl(:,:),'U')
-            CALL sbc_isf_tbl(vn(:,:,:)        ,vtbl(:,:),'V')
-            ! iom print
-            CALL iom_put('ttbl',ttbl(:,:))
-            CALL iom_put('stbl',stbl(:,:))
-            CALL iom_put('utbl',utbl(:,:) * (1._wp - tmask(:,:,1)) * ssmask(:,:))
-            CALL iom_put('vtbl',vtbl(:,:) * (1._wp - tmask(:,:,1)) * ssmask(:,:))
-            ! compute fwf and heat flux
-            ! compute fwf and heat flux
-            IF( .NOT.l_isfcpl ) THEN    ;   CALL sbc_isf_cav (kt)
-            ELSE                        ;   qisf(:,:)  = fwfisf(:,:) * rLfusisf  ! heat        flux
-            ENDIF
-            !
-         CASE ( 2 )    ! Beckmann and Goosse parametrisation 
-            stbl(:,:)   = soce
-            CALL sbc_isf_bg03(kt)
-            !
-         CASE ( 3 )    ! specified runoff in depth (Mathiot et al., XXXX in preparation)
-            ! specified runoff in depth (Mathiot et al., XXXX in preparation)
-            IF( .NOT.l_isfcpl ) THEN
-               CALL fld_read ( kt, nn_fsbc, sf_rnfisf   )
-               fwfisf(:,:) = - sf_rnfisf(1)%fnow(:,:,1)         ! fresh water flux from the isf (fwfisf <0 mean melting) 
-            ENDIF
-            qisf(:,:)   = fwfisf(:,:) * rLfusisf             ! heat flux
-            stbl(:,:)   = soce
-            !
-         CASE ( 4 )    ! specified fwf and heat flux forcing beneath the ice shelf
-            !          ! specified fwf and heat flux forcing beneath the ice shelf
-            IF( .NOT.l_isfcpl ) THEN
-               CALL fld_read ( kt, nn_fsbc, sf_fwfisf   )
-               !CALL fld_read ( kt, nn_fsbc, sf_qisf   )
-               fwfisf(:,:) = -sf_fwfisf(1)%fnow(:,:,1)            ! fwf
-            ENDIF
-            qisf(:,:)   = fwfisf(:,:) * rLfusisf               ! heat flux
-            stbl(:,:)   = soce
-            !
-         END SELECT
-
-         ! compute tsc due to isf
-         ! isf melting implemented as a volume flux and we assume that melt water is at 0 PSU.
-         ! WARNING water add at temp = 0C, need to add a correction term (fwfisf * tfreez / rau0).
-         ! compute freezing point beneath ice shelf (or top cell if nn_isf = 3)
-         DO jj = 1,jpj
-            DO ji = 1,jpi
-               zdep(ji,jj)=gdepw_n(ji,jj,misfkt(ji,jj))
-            END DO
-         END DO
-         CALL eos_fzp( stbl(:,:), zt_frz(:,:), zdep(:,:) )
-         
-         risf_tsc(:,:,jp_tem) = qisf(:,:) * r1_rau0_rcp - fwfisf(:,:) * zt_frz(:,:) * r1_rau0 !
-         risf_tsc(:,:,jp_sal) = 0.0_wp
-
-         ! lbclnk
-         CALL lbc_lnk_multi( 'sbcisf', risf_tsc(:,:,jp_tem), 'T', 1., risf_tsc(:,:,jp_sal), 'T', 1., fwfisf,'T', 1., qisf, 'T', 1.)
-         ! output
-         IF( iom_use('iceshelf_cea') )   CALL iom_put( 'iceshelf_cea', -fwfisf(:,:)                      )   ! isf mass flux
-         IF( iom_use('hflx_isf_cea') )   CALL iom_put( 'hflx_isf_cea', risf_tsc(:,:,jp_tem) * rau0 * rcp )   ! isf sensible+latent heat (W/m2)
-         IF( iom_use('qlatisf' ) )       CALL iom_put( 'qlatisf'     , qisf(:,:)                         )   ! isf latent heat
-         IF( iom_use('fwfisf'  ) )       CALL iom_put( 'fwfisf'      , fwfisf(:,:)                       )   ! isf mass flux (opposite sign)
-
-         ! Diagnostics
-         IF( iom_use('fwfisf3d') .OR. iom_use('qlatisf3d') .OR. iom_use('qhcisf3d') .OR. iom_use('qhcisf')) THEN
-            ALLOCATE( zfwfisf3d(jpi,jpj,jpk) , zqhcisf3d(jpi,jpj,jpk) , zqlatisf3d(jpi,jpj,jpk) )
-            ALLOCATE( zqhcisf2d(jpi,jpj) )
-            !
-            zfwfisf3d (:,:,:) = 0._wp                         ! 3d ice shelf melting (kg/m2/s)
-            zqhcisf3d (:,:,:) = 0._wp                         ! 3d heat content flux (W/m2)
-            zqlatisf3d(:,:,:) = 0._wp                         ! 3d ice shelf melting latent heat flux (W/m2)
-            zqhcisf2d (:,:)   = fwfisf(:,:) * zt_frz * rcp    ! 2d heat content flux (W/m2)
-            !
-            DO jj = 1,jpj
-               DO ji = 1,jpi
-                  ikt = misfkt(ji,jj)
-                  ikb = misfkb(ji,jj)
-                  DO jk = ikt, ikb - 1
-                     zfwfisf3d (ji,jj,jk) = zfwfisf3d (ji,jj,jk) + fwfisf   (ji,jj) * r1_hisf_tbl(ji,jj) * e3t_n(ji,jj,jk)
-                     zqhcisf3d (ji,jj,jk) = zqhcisf3d (ji,jj,jk) + zqhcisf2d(ji,jj) * r1_hisf_tbl(ji,jj) * e3t_n(ji,jj,jk)
-                     zqlatisf3d(ji,jj,jk) = zqlatisf3d(ji,jj,jk) + qisf     (ji,jj) * r1_hisf_tbl(ji,jj) * e3t_n(ji,jj,jk)
-                  END DO
-                  zfwfisf3d (ji,jj,jk) = zfwfisf3d (ji,jj,jk) + fwfisf   (ji,jj) * r1_hisf_tbl(ji,jj)   & 
-                     &                                                                   * ralpha(ji,jj) * e3t_n(ji,jj,jk)
-                  zqhcisf3d (ji,jj,jk) = zqhcisf3d (ji,jj,jk) + zqhcisf2d(ji,jj) * r1_hisf_tbl(ji,jj)   & 
-                     &                                                                   * ralpha(ji,jj) * e3t_n(ji,jj,jk)
-                  zqlatisf3d(ji,jj,jk) = zqlatisf3d(ji,jj,jk) + qisf     (ji,jj) * r1_hisf_tbl(ji,jj)   &  
-                     &                                                                   * ralpha(ji,jj) * e3t_n(ji,jj,jk)
-               END DO
-            END DO
-            !
-            CALL iom_put('fwfisf3d' , zfwfisf3d (:,:,:))
-            CALL iom_put('qlatisf3d', zqlatisf3d(:,:,:))
-            CALL iom_put('qhcisf3d' , zqhcisf3d (:,:,:))
-            CALL iom_put('qhcisf'   , zqhcisf2d (:,:  ))
-            !
-            DEALLOCATE( zfwfisf3d, zqhcisf3d, zqlatisf3d )
-            DEALLOCATE( zqhcisf2d )
-         ENDIF
-         !
-      ENDIF
-
-      IF( kt == nit000 ) THEN                         !   set the forcing field at nit000 - 1    !
-         IF( ln_rstart .AND.    &                     ! Restart: read in restart file
-            &   iom_varid( numror, 'fwf_isf_b', ldstop = .FALSE. ) > 0 ) THEN
-            IF(lwp) WRITE(numout,*) '          nit000-1 isf tracer content forcing fields read in the restart file'
-            CALL iom_get( numror, jpdom_autoglo, 'fwf_isf_b', fwfisf_b(:,:)         , ldxios = lrxios )   ! before salt content isf_tsc trend
-            CALL iom_get( numror, jpdom_autoglo, 'isf_sc_b' , risf_tsc_b(:,:,jp_sal), ldxios = lrxios )   ! before salt content isf_tsc trend
-            CALL iom_get( numror, jpdom_autoglo, 'isf_hc_b' , risf_tsc_b(:,:,jp_tem), ldxios = lrxios )   ! before salt content isf_tsc trend
-         ELSE
-            fwfisf_b(:,:)    = fwfisf(:,:)
-            risf_tsc_b(:,:,:)= risf_tsc(:,:,:)
-         ENDIF
-      ENDIF
-      ! 
-      IF( lrst_oce ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'sbc : isf surface tracer content forcing fields written in ocean restart file ',   &
-            &                    'at it= ', kt,' date= ', ndastp
-         IF(lwp) WRITE(numout,*) '~~~~'
-         IF( lwxios ) CALL iom_swap(      cwxios_context          )
-         CALL iom_rstput( kt, nitrst, numrow, 'fwf_isf_b', fwfisf(:,:)         , ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'isf_hc_b' , risf_tsc(:,:,jp_tem), ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'isf_sc_b' , risf_tsc(:,:,jp_sal), ldxios = lwxios )
-         IF( lwxios ) CALL iom_swap(      cxios_context          )
-      ENDIF
-      !
-   END SUBROUTINE sbc_isf
-
-
-   INTEGER FUNCTION sbc_isf_alloc()
-      !!----------------------------------------------------------------------
-      !!               ***  FUNCTION sbc_isf_rnf_alloc  ***
-      !!----------------------------------------------------------------------
-      sbc_isf_alloc = 0       ! set to zero if no array to be allocated
-      IF( .NOT. ALLOCATED( qisf ) ) THEN
-         ALLOCATE(  risf_tsc(jpi,jpj,jpts), risf_tsc_b(jpi,jpj,jpts), qisf(jpi,jpj)   , &
-               &    rhisf_tbl(jpi,jpj)    , r1_hisf_tbl(jpi,jpj), rzisf_tbl(jpi,jpj)  , &
-               &    ttbl(jpi,jpj)         , stbl(jpi,jpj)       , utbl(jpi,jpj)       , &
-               &    vtbl(jpi, jpj)        , risfLeff(jpi,jpj)   , rhisf_tbl_0(jpi,jpj), &
-               &    ralpha(jpi,jpj)       , misfkt(jpi,jpj)     , misfkb(jpi,jpj)     , &
-               &    STAT= sbc_isf_alloc )
-         !
-         CALL mpp_sum ( 'sbcisf', sbc_isf_alloc )
-         IF( sbc_isf_alloc /= 0 )   CALL ctl_stop( 'STOP', 'sbc_isf_alloc: failed to allocate arrays.' )
-         !
-      ENDIF
-   END FUNCTION
-
-
-  SUBROUTINE sbc_isf_init
-      !!---------------------------------------------------------------------
-      !!                  ***  ROUTINE sbc_isf_init  ***
-      !!
-      !! ** Purpose : Initialisation of variables for iceshelf fluxes formulation
-      !!
-      !! ** Method  :  4 parameterizations are available according to nn_isf 
-      !!               nn_isf = 1 : Realistic ice_shelf formulation
-      !!                        2 : Beckmann & Goose parameterization
-      !!                        3 : Specified runoff in deptht (Mathiot & al. )
-      !!                        4 : specified fwf and heat flux forcing beneath the ice shelf
-      !!----------------------------------------------------------------------
-      INTEGER               :: ji, jj, jk           ! loop index
-      INTEGER               :: ik                   ! current level index
-      INTEGER               :: ikt, ikb             ! top and bottom level of the isf boundary layer
-      INTEGER               :: inum, ierror
-      INTEGER               :: ios                  ! Local integer output status for namelist read
-      REAL(wp)              :: zhk
-      CHARACTER(len=256)    :: cvarzisf, cvarhisf   ! name for isf file
-      CHARACTER(LEN=32 )    :: cvarLeff             ! variable name for efficient Length scale
-      !!----------------------------------------------------------------------
-      NAMELIST/namsbc_isf/ nn_isfblk, rn_hisf_tbl, rn_gammat0, rn_gammas0, nn_gammablk, nn_isf, &
-                         & sn_fwfisf, sn_rnfisf, sn_depmax_isf, sn_depmin_isf, sn_Leff_isf
-      !!----------------------------------------------------------------------
-
-      REWIND( numnam_ref )              ! Namelist namsbc_rnf in reference namelist : Runoffs 
-      READ  ( numnam_ref, namsbc_isf, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_isf in reference namelist', lwp )
-
-      REWIND( numnam_cfg )              ! Namelist namsbc_rnf in configuration namelist : Runoffs
-      READ  ( numnam_cfg, namsbc_isf, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_isf in configuration namelist', lwp )
-      IF(lwm) WRITE ( numond, namsbc_isf )
-
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'sbc_isf_init : heat flux of the ice shelf'
-      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
-      IF(lwp) WRITE(numout,*) '   Namelist namsbc_isf :'
-      IF(lwp) WRITE(numout,*) '      type ice shelf melting/freezing         nn_isf      = ', nn_isf
-      IF(lwp) WRITE(numout,*) '      bulk formulation (nn_isf=1 only)        nn_isfblk   = ', nn_isfblk
-      IF(lwp) WRITE(numout,*) '      thickness of the top boundary layer     rn_hisf_tbl = ', rn_hisf_tbl
-      IF(lwp) WRITE(numout,*) '      gamma formulation                       nn_gammablk = ', nn_gammablk 
-      IF(lwp) WRITE(numout,*) '      gammat coefficient                      rn_gammat0  = ', rn_gammat0  
-      IF(lwp) WRITE(numout,*) '      gammas coefficient                      rn_gammas0  = ', rn_gammas0  
-      IF(lwp) WRITE(numout,*) '      top drag coef. used (from namdrg_top)   rn_Cd0      = ', r_Cdmin_top 
-
-
-                           !  1 = presence of ISF    2 = bg03 parametrisation 
-                           !  3 = rnf file for isf   4 = ISF fwf specified
-                           !  option 1 and 4 need ln_isfcav = .true. (domzgr)
-      !
-      ! Allocate public variable
-      IF ( sbc_isf_alloc()  /= 0 )         CALL ctl_stop( 'STOP', 'sbc_isf : unable to allocate arrays' )
-      !
-      ! initialisation
-      qisf    (:,:)    = 0._wp   ;   fwfisf  (:,:) = 0._wp
-      risf_tsc(:,:,:)  = 0._wp   ;   fwfisf_b(:,:) = 0._wp
-      !
-      ! define isf tbl tickness, top and bottom indice
-      SELECT CASE ( nn_isf )
-      CASE ( 1 ) 
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) '      ==>>>   presence of under iceshelf seas (nn_isf = 1)'
-         rhisf_tbl(:,:) = rn_hisf_tbl
-         misfkt   (:,:) = mikt(:,:)         ! same indice for bg03 et cav => used in isfdiv
-         !
-      CASE ( 2 , 3 )
-         IF( .NOT.l_isfcpl ) THEN
-             ALLOCATE( sf_rnfisf(1), STAT=ierror )
-             ALLOCATE( sf_rnfisf(1)%fnow(jpi,jpj,1), sf_rnfisf(1)%fdta(jpi,jpj,1,2) )
-             CALL fld_fill( sf_rnfisf, (/ sn_rnfisf /), cn_dirisf, 'sbc_isf_init', 'read fresh water flux isf data', 'namsbc_isf' )
-          ENDIF
-          !  read effective lenght (BG03)
-          IF( nn_isf == 2 ) THEN
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '      ==>>>   bg03 parametrisation (nn_isf = 2)'
-            CALL iom_open( sn_Leff_isf%clname, inum )
-            cvarLeff = TRIM(sn_Leff_isf%clvar)
-            CALL iom_get( inum, jpdom_data, cvarLeff, risfLeff , 1)
-            CALL iom_close(inum)
-            !
-            risfLeff = risfLeff*1000.0_wp           !: convertion in m
-         ELSE
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '      ==>>>   rnf file for isf (nn_isf = 3)'
-         ENDIF
-         ! read depth of the top and bottom of the isf top boundary layer (in this case, isf front depth and grounding line depth)
-         CALL iom_open( sn_depmax_isf%clname, inum )
-         cvarhisf = TRIM(sn_depmax_isf%clvar)
-         CALL iom_get( inum, jpdom_data, cvarhisf, rhisf_tbl, 1) !: depth of deepest point of the ice shelf base
-         CALL iom_close(inum)
-         !
-         CALL iom_open( sn_depmin_isf%clname, inum )
-         cvarzisf = TRIM(sn_depmin_isf%clvar)
-         CALL iom_get( inum, jpdom_data, cvarzisf, rzisf_tbl, 1) !: depth of shallowest point of the ice shelves base
-         CALL iom_close(inum)
-         !
-         rhisf_tbl(:,:) = rhisf_tbl(:,:) - rzisf_tbl(:,:)        !: tickness isf boundary layer
-
-         !! compute first level of the top boundary layer
-         DO ji = 1, jpi
-            DO jj = 1, jpj
-                ik = 2
-!!gm potential bug: use gdepw_0 not _n
-                DO WHILE ( ik <= mbkt(ji,jj) .AND. gdepw_n(ji,jj,ik) < rzisf_tbl(ji,jj) ) ;  ik = ik + 1 ;  END DO
-                misfkt(ji,jj) = ik-1
-            END DO
-         END DO
-         !
-      CASE ( 4 ) 
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) '      ==>>>   specified fresh water flux in ISF (nn_isf = 4)'
-         ! as in nn_isf == 1
-         rhisf_tbl(:,:) = rn_hisf_tbl
-         misfkt   (:,:) = mikt(:,:)         ! same indice for bg03 et cav => used in isfdiv
-         !
-         ! load variable used in fldread (use for temporal interpolation of isf fwf forcing)
-         IF( .NOT.l_isfcpl ) THEN
-           ALLOCATE( sf_fwfisf(1), STAT=ierror )
-           ALLOCATE( sf_fwfisf(1)%fnow(jpi,jpj,1), sf_fwfisf(1)%fdta(jpi,jpj,1,2) )
-           CALL fld_fill( sf_fwfisf, (/ sn_fwfisf /), cn_dirisf, 'sbc_isf_init', 'read fresh water flux isf data', 'namsbc_isf' )
-         ENDIF
-         !
-      CASE DEFAULT
-         CALL ctl_stop( 'sbc_isf_init: wrong value of nn_isf' )
-      END SELECT
-         
-      rhisf_tbl_0(:,:) = rhisf_tbl(:,:)
-
-      ! compute bottom level of isf tbl and thickness of tbl below the ice shelf
-      DO jj = 1,jpj
-         DO ji = 1,jpi
-            ikt = misfkt(ji,jj)
-            ikb = misfkt(ji,jj)
-            ! thickness of boundary layer at least the top level thickness
-            rhisf_tbl(ji,jj) = MAX(rhisf_tbl_0(ji,jj), e3t_n(ji,jj,ikt))
-
-            ! determine the deepest level influenced by the boundary layer
-            DO jk = ikt+1, mbkt(ji,jj)
-               IF( (SUM(e3t_n(ji,jj,ikt:jk-1)) < rhisf_tbl(ji,jj)) .AND. (tmask(ji,jj,jk) == 1) )   ikb = jk
-            END DO
-            rhisf_tbl(ji,jj) = MIN(rhisf_tbl(ji,jj), SUM(e3t_n(ji,jj,ikt:ikb))) ! limit the tbl to water thickness.
-            misfkb(ji,jj) = ikb                                                   ! last wet level of the tbl
-            r1_hisf_tbl(ji,jj) = 1._wp / rhisf_tbl(ji,jj)
-
-            zhk           = SUM( e3t_n(ji, jj, ikt:ikb - 1)) * r1_hisf_tbl(ji,jj) ! proportion of tbl cover by cell from ikt to ikb - 1
-            ralpha(ji,jj) = rhisf_tbl(ji,jj) * (1._wp - zhk ) / e3t_n(ji,jj,ikb)  ! proportion of bottom cell influenced by boundary layer
-         END DO
-      END DO
-
-      IF( lwxios ) THEN
-          CALL iom_set_rstw_var_active('fwf_isf_b')
-          CALL iom_set_rstw_var_active('isf_hc_b')
-          CALL iom_set_rstw_var_active('isf_sc_b')
-      ENDIF
-
-
-  END SUBROUTINE sbc_isf_init
-
-
-  SUBROUTINE sbc_isf_bg03(kt)
-      !!---------------------------------------------------------------------
-      !!                  ***  ROUTINE sbc_isf_bg03  ***
-      !!
-      !! ** Purpose : add net heat and fresh water flux from ice shelf melting
-      !!          into the adjacent ocean
-      !!
-      !! ** Method  :   See reference
-      !!
-      !! ** Reference : Beckmann and Goosse (2003), "A parameterization of ice shelf-ocean
-      !!         interaction for climate models", Ocean Modelling 5(2003) 157-170.
-      !!         (hereafter BG)
-      !! History :  06-02  (C. Wang) Original code
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT ( in ) :: kt
-      !
-      INTEGER  :: ji, jj, jk ! dummy loop index
-      INTEGER  :: ik         ! current level
-      REAL(wp) :: zt_sum     ! sum of the temperature between 200m and 600m
-      REAL(wp) :: zt_ave     ! averaged temperature between 200m and 600m
-      REAL(wp) :: zt_frz     ! freezing point temperature at depth z
-      REAL(wp) :: zpress     ! pressure to compute the freezing point in depth
-      !!----------------------------------------------------------------------
-      !
-      DO ji = 1, jpi
-         DO jj = 1, jpj
-            ik = misfkt(ji,jj)
-            !! Initialize arrays to 0 (each step)
-            zt_sum = 0.e0_wp
-            IF ( ik > 1 ) THEN
-               ! 1. -----------the average temperature between 200m and 600m ---------------------
-               DO jk = misfkt(ji,jj),misfkb(ji,jj)
-                  ! Calculate freezing temperature
-                  zpress = grav*rau0*gdept_n(ji,jj,ik)*1.e-04
-                  CALL eos_fzp(stbl(ji,jj), zt_frz, zpress) 
-                  zt_sum = zt_sum + (tsn(ji,jj,jk,jp_tem)-zt_frz) * e3t_n(ji,jj,jk) * tmask(ji,jj,jk)  ! sum temp
-               END DO
-               zt_ave = zt_sum/rhisf_tbl(ji,jj) ! calcul mean value
-               ! 2. ------------Net heat flux and fresh water flux due to the ice shelf
-               ! For those corresponding to zonal boundary    
-               qisf(ji,jj) = - rau0 * rcp * rn_gammat0 * risfLeff(ji,jj) * e1t(ji,jj) * zt_ave  &
-                           & * r1_e1e2t(ji,jj) * tmask(ji,jj,jk)
-             
-               fwfisf(ji,jj) = qisf(ji,jj) / rLfusisf          !fresh water flux kg/(m2s)                  
-               fwfisf(ji,jj) = fwfisf(ji,jj) * ( soce / stbl(ji,jj) )
-               !add to salinity trend
-            ELSE
-               qisf(ji,jj) = 0._wp   ;   fwfisf(ji,jj) = 0._wp
-            END IF
-         END DO
-      END DO
-      !
-  END SUBROUTINE sbc_isf_bg03
-
-
-  SUBROUTINE sbc_isf_cav( kt )
-      !!---------------------------------------------------------------------
-      !!                     ***  ROUTINE sbc_isf_cav  ***
-      !!
-      !! ** Purpose :   handle surface boundary condition under ice shelf
-      !!
-      !! ** Method  : -
-      !!
-      !! ** Action  :   utau, vtau : remain unchanged
-      !!                taum, wndm : remain unchanged
-      !!                qns        : update heat flux below ice shelf
-      !!                emp, emps  : update freshwater flux below ice shelf
-      !!---------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kt   ! ocean time step
-      !
-      INTEGER  ::   ji, jj     ! dummy loop indices
-      INTEGER  ::   nit
-      LOGICAL  ::   lit
-      REAL(wp) ::   zlamb1, zlamb2, zlamb3
-      REAL(wp) ::   zeps1,zeps2,zeps3,zeps4,zeps6,zeps7
-      REAL(wp) ::   zaqe,zbqe,zcqe,zaqer,zdis,zsfrz,zcfac
-      REAL(wp) ::   zeps = 1.e-20_wp        
-      REAL(wp) ::   zerr
-      REAL(wp), DIMENSION(jpi,jpj) ::   zfrz
-      REAL(wp), DIMENSION(jpi,jpj) ::   zgammat, zgammas 
-      REAL(wp), DIMENSION(jpi,jpj) ::   zfwflx, zhtflx, zhtflx_b
-      !!---------------------------------------------------------------------
-      !
-      ! coeficient for linearisation of potential tfreez
-      ! Crude approximation for pressure (but commonly used)
-      IF ( l_useCT ) THEN   ! linearisation from Jourdain et al. (2017)
-         zlamb1 =-0.0564_wp
-         zlamb2 = 0.0773_wp
-         zlamb3 =-7.8633e-8 * grav * rau0
-      ELSE                  ! linearisation from table 4 (Asay-Davis et al., 2015)
-         zlamb1 =-0.0573_wp
-         zlamb2 = 0.0832_wp
-         zlamb3 =-7.53e-8 * grav * rau0
-      ENDIF
-      !
-      ! initialisation
-      zgammat(:,:) = rn_gammat0 ; zgammas (:,:) = rn_gammas0
-      zhtflx (:,:) = 0.0_wp     ; zhtflx_b(:,:) = 0.0_wp    
-      zfwflx (:,:) = 0.0_wp
-
-      ! compute ice shelf melting
-      nit = 1 ; lit = .TRUE.
-      DO WHILE ( lit )    ! maybe just a constant number of iteration as in blk_core is fine
-         SELECT CASE ( nn_isfblk )
-         CASE ( 1 )   !  ISOMIP formulation (2 equations) for volume flux (Hunter et al., 2006)
-            ! Calculate freezing temperature
-            CALL eos_fzp( stbl(:,:), zfrz(:,:), risfdep(:,:) )
-
-            ! compute gammat every where (2d)
-            CALL sbc_isf_gammats(zgammat, zgammas, zhtflx, zfwflx)
-            
-            ! compute upward heat flux zhtflx and upward water flux zwflx
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zhtflx(ji,jj) =   zgammat(ji,jj)*rcp*rau0*(ttbl(ji,jj)-zfrz(ji,jj))
-                  zfwflx(ji,jj) = - zhtflx(ji,jj)/rLfusisf
-               END DO
-            END DO
-
-            ! Compute heat flux and upward fresh water flux
-            qisf  (:,:) = - zhtflx(:,:) * (1._wp - tmask(:,:,1)) * ssmask(:,:)
-            fwfisf(:,:) =   zfwflx(:,:) * (1._wp - tmask(:,:,1)) * ssmask(:,:)
-
-         CASE ( 2 )  ! ISOMIP+ formulation (3 equations) for volume flux (Asay-Davis et al., 2015)
-            ! compute gammat every where (2d)
-            CALL sbc_isf_gammats(zgammat, zgammas, zhtflx, zfwflx)
-
-            ! compute upward heat flux zhtflx and upward water flux zwflx
-            ! Resolution of a 2d equation from equation 21, 22 and 23 to find Sb (Asay-Davis et al., 2015)
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  ! compute coeficient to solve the 2nd order equation
-                  zeps1 = rcp*rau0*zgammat(ji,jj)
-                  zeps2 = rLfusisf*rau0*zgammas(ji,jj)
-                  zeps3 = rhoisf*rcpisf*rkappa/MAX(risfdep(ji,jj),zeps)
-                  zeps4 = zlamb2+zlamb3*risfdep(ji,jj)
-                  zeps6 = zeps4-ttbl(ji,jj)
-                  zeps7 = zeps4-tsurf
-                  zaqe  = zlamb1 * (zeps1 + zeps3)
-                  zaqer = 0.5_wp/MIN(zaqe,-zeps)
-                  zbqe  = zeps1*zeps6+zeps3*zeps7-zeps2
-                  zcqe  = zeps2*stbl(ji,jj)
-                  zdis  = zbqe*zbqe-4.0_wp*zaqe*zcqe               
-
-                  ! Presumably zdis can never be negative because gammas is very small compared to gammat
-                  ! compute s freeze
-                  zsfrz=(-zbqe-SQRT(zdis))*zaqer
-                  IF ( zsfrz < 0.0_wp ) zsfrz=(-zbqe+SQRT(zdis))*zaqer
-
-                  ! compute t freeze (eq. 22)
-                  zfrz(ji,jj)=zeps4+zlamb1*zsfrz
-  
-                  ! zfwflx is upward water flux
-                  ! zhtflx is upward heat flux (out of ocean)
-                  ! compute the upward water and heat flux (eq. 28 and eq. 29)
-                  zfwflx(ji,jj) = rau0 * zgammas(ji,jj) * (zsfrz-stbl(ji,jj)) / MAX(zsfrz,zeps)
-                  zhtflx(ji,jj) = zgammat(ji,jj) * rau0 * rcp * (ttbl(ji,jj) - zfrz(ji,jj) ) 
-               END DO
-            END DO
-
-            ! compute heat and water flux
-            qisf  (:,:) = - zhtflx(:,:) * (1._wp - tmask(:,:,1)) * ssmask(:,:)
-            fwfisf(:,:) =   zfwflx(:,:) * (1._wp - tmask(:,:,1)) * ssmask(:,:)
-
-         END SELECT
-
-         ! define if we need to iterate (nn_gammablk 0/1 do not need iteration)
-         IF ( nn_gammablk <  2 ) THEN ; lit = .FALSE.
-         ELSE                           
-            ! check total number of iteration
-            IF (nit >= 100) THEN ; CALL ctl_stop( 'STOP', 'sbc_isf_hol99 : too many iteration ...' )
-            ELSE                 ; nit = nit + 1
-            END IF
-
-            ! compute error between 2 iterations
-            ! if needed save gammat and compute zhtflx_b for next iteration
-            zerr = MAXVAL(ABS(zhtflx-zhtflx_b))
-            IF ( zerr <= 0.01_wp ) THEN ; lit = .FALSE.
-            ELSE                        ; zhtflx_b(:,:) = zhtflx(:,:)
-            END IF
-         END IF
-      END DO
-      !
-      CALL iom_put('isfgammat', zgammat)
-      CALL iom_put('isfgammas', zgammas)
-      ! 
-   END SUBROUTINE sbc_isf_cav
-
-
-   SUBROUTINE sbc_isf_gammats(pgt, pgs, pqhisf, pqwisf )
-      !!----------------------------------------------------------------------
-      !! ** Purpose    : compute the coefficient echange for heat flux
-      !!
-      !! ** Method     : gamma assume constant or depends of u* and stability
-      !!
-      !! ** References : Holland and Jenkins, 1999, JPO, p1787-1800, eq 14
-      !!                Jenkins et al., 2010, JPO, p2298-2312
-      !!---------------------------------------------------------------------
-      REAL(wp), DIMENSION(:,:), INTENT(  out) ::   pgt   , pgs      ! 
-      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   pqhisf, pqwisf   ! 
-      !
-      INTEGER  :: ji, jj                     ! loop index
-      INTEGER  :: ikt                        ! local integer
-      REAL(wp) :: zdku, zdkv                 ! U, V shear 
-      REAL(wp) :: zPr, zSc, zRc              ! Prandtl, Scmidth and Richardson number 
-      REAL(wp) :: zmob, zmols                ! Monin Obukov length, coriolis factor at T point
-      REAL(wp) :: zbuofdep, zhnu             ! Bouyancy length scale, sublayer tickness
-      REAL(wp) :: zhmax                      ! limitation of mol
-      REAL(wp) :: zetastar                   ! stability parameter
-      REAL(wp) :: zgmolet, zgmoles, zgturb   ! contribution of modelecular sublayer and turbulence 
-      REAL(wp) :: zcoef                      ! temporary coef
-      REAL(wp) :: zdep
-      REAL(wp) :: zeps = 1.0e-20_wp    
-      REAL(wp), PARAMETER :: zxsiN = 0.052_wp   ! dimensionless constant
-      REAL(wp), PARAMETER :: znu   = 1.95e-6_wp ! kinamatic viscosity of sea water (m2.s-1)
-      REAL(wp), DIMENSION(2) :: zts, zab
-      REAL(wp), DIMENSION(jpi,jpj) :: zustar   ! U, V at T point and friction velocity
-      !!---------------------------------------------------------------------
-      !
-      SELECT CASE ( nn_gammablk )
-      CASE ( 0 ) ! gamma is constant (specified in namelist)
-         !! ISOMIP formulation (Hunter et al, 2006)
-         pgt(:,:) = rn_gammat0
-         pgs(:,:) = rn_gammas0
-
-      CASE ( 1 ) ! gamma is assume to be proportional to u*
-         !! Jenkins et al., 2010, JPO, p2298-2312
-         !! Adopted by Asay-Davis et al. (2015)
-         !! compute ustar (eq. 24)
-!!gm  NB  use pCdU here so that it will incorporate local boost of Cd0 and log layer case :
-!!         zustar(:,:) = SQRT( rCdU_top(:,:) * SQRT(utbl(:,:) * utbl(:,:) + vtbl(:,:) * vtbl(:,:) + r_ke0_top) )
-!! or better :  compute ustar in zdfdrg  and use it here as well as in TKE, GLS and Co
-!!
-!!     ===>>>>    GM  to be done this chrismas
-!!         
-!!gm end
-         zustar(:,:) = SQRT( r_Cdmin_top * (utbl(:,:) * utbl(:,:) + vtbl(:,:) * vtbl(:,:) + r_ke0_top) )
-
-         !! Compute gammats
-         pgt(:,:) = zustar(:,:) * rn_gammat0
-         pgs(:,:) = zustar(:,:) * rn_gammas0
-      
-      CASE ( 2 ) ! gamma depends of stability of boundary layer
-         !! Holland and Jenkins, 1999, JPO, p1787-1800, eq 14
-         !! as MOL depends of flux and flux depends of MOL, best will be iteration (TO DO)
-         !! compute ustar
-         zustar(:,:) = SQRT( r_Cdmin_top * (utbl(:,:) * utbl(:,:) + vtbl(:,:) * vtbl(:,:) + r_ke0_top) )
-
-         !! compute Pr and Sc number (can be improved)
-         zPr =   13.8_wp
-         zSc = 2432.0_wp
-
-         !! compute gamma mole
-         zgmolet = 12.5_wp * zPr ** (2.0/3.0) - 6.0_wp
-         zgmoles = 12.5_wp * zSc ** (2.0/3.0) - 6.0_wp
-
-         !! compute gamma
-         DO ji = 2, jpi
-            DO jj = 2, jpj
-               ikt = mikt(ji,jj)
-
-               IF( zustar(ji,jj) == 0._wp ) THEN           ! only for kt = 1 I think
-                  pgt = rn_gammat0
-                  pgs = rn_gammas0
-               ELSE
-                  !! compute Rc number (as done in zdfric.F90)
-!!gm better to do it like in the new zdfric.F90   i.e. avm weighted Ri computation
-!!gm moreover, use Max(rn2,0) to take care of static instabilities....
-                  zcoef = 0.5_wp / e3w_n(ji,jj,ikt+1)
-                  !                                            ! shear of horizontal velocity
-                  zdku = zcoef * (  un(ji-1,jj  ,ikt  ) + un(ji,jj,ikt  )  &
-                     &             -un(ji-1,jj  ,ikt+1) - un(ji,jj,ikt+1)  )
-                  zdkv = zcoef * (  vn(ji  ,jj-1,ikt  ) + vn(ji,jj,ikt  )  &
-                     &             -vn(ji  ,jj-1,ikt+1) - vn(ji,jj,ikt+1)  )
-                  !                                            ! richardson number (minimum value set to zero)
-                  zRc = rn2(ji,jj,ikt+1) / MAX( zdku*zdku + zdkv*zdkv, zeps )
-
-                  !! compute bouyancy 
-                  zts(jp_tem) = ttbl(ji,jj)
-                  zts(jp_sal) = stbl(ji,jj)
-                  zdep        = gdepw_n(ji,jj,ikt)
-                  !
-                  CALL eos_rab( zts, zdep, zab )
-                  !
-                  !! compute length scale 
-                  zbuofdep = grav * ( zab(jp_tem) * pqhisf(ji,jj) - zab(jp_sal) * pqwisf(ji,jj) )  !!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-                  !! compute Monin Obukov Length
-                  ! Maximum boundary layer depth
-                  zhmax = gdept_n(ji,jj,mbkt(ji,jj)) - gdepw_n(ji,jj,mikt(ji,jj)) -0.001_wp
-                  ! Compute Monin obukhov length scale at the surface and Ekman depth:
-                  zmob   = zustar(ji,jj) ** 3 / (vkarmn * (zbuofdep + zeps))
-                  zmols  = SIGN(1._wp, zmob) * MIN(ABS(zmob), zhmax) * tmask(ji,jj,ikt)
-
-                  !! compute eta* (stability parameter)
-                  zetastar = 1._wp / ( SQRT(1._wp + MAX(zxsiN * zustar(ji,jj) / ( ABS(ff_f(ji,jj)) * zmols * zRc ), 0._wp)))
-
-                  !! compute the sublayer thickness
-                  zhnu = 5 * znu / zustar(ji,jj)
-
-                  !! compute gamma turb
-                  zgturb = 1._wp / vkarmn * LOG(zustar(ji,jj) * zxsiN * zetastar * zetastar / ( ABS(ff_f(ji,jj)) * zhnu )) &
-                  &      + 1._wp / ( 2 * zxsiN * zetastar ) - 1._wp / vkarmn
-
-                  !! compute gammats
-                  pgt(ji,jj) = zustar(ji,jj) / (zgturb + zgmolet)
-                  pgs(ji,jj) = zustar(ji,jj) / (zgturb + zgmoles)
-               END IF
-            END DO
-         END DO
-         CALL lbc_lnk_multi( 'sbcisf', pgt, 'T', 1., pgs, 'T', 1.)
-      END SELECT
-      !
-   END SUBROUTINE sbc_isf_gammats
-
-
-   SUBROUTINE sbc_isf_tbl( pvarin, pvarout, cd_ptin )
-      !!----------------------------------------------------------------------
-      !!                  ***  SUBROUTINE sbc_isf_tbl  ***
-      !!
-      !! ** Purpose : compute mean T/S/U/V in the boundary layer at T- point
-      !!
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) :: pvarin
-      REAL(wp), DIMENSION(:,:)  , INTENT(  out) :: pvarout
-      CHARACTER(len=1),           INTENT(in   ) :: cd_ptin ! point of variable in/out
-      !
-      INTEGER ::   ji, jj, jk                ! loop index
-      INTEGER ::   ikt, ikb                    ! top and bottom index of the tbl
-      REAL(wp) ::   ze3, zhk
-      REAL(wp), DIMENSION(jpi,jpj) :: zhisf_tbl ! thickness of the tbl
-      !!----------------------------------------------------------------------
-      
-      ! initialisation
-      pvarout(:,:)=0._wp
-   
-      SELECT CASE ( cd_ptin )
-      CASE ( 'U' ) ! compute U in the top boundary layer at T- point 
-         DO jj = 1,jpj
-            DO ji = 1,jpi
-               ikt = miku(ji,jj) ; ikb = miku(ji,jj)
-               ! thickness of boundary layer at least the top level thickness
-               zhisf_tbl(ji,jj) = MAX( rhisf_tbl_0(ji,jj) , e3u_n(ji,jj,ikt) )
-
-               ! determine the deepest level influenced by the boundary layer
-               DO jk = ikt+1, mbku(ji,jj)
-                  IF ( (SUM(e3u_n(ji,jj,ikt:jk-1)) < zhisf_tbl(ji,jj)) .AND. (umask(ji,jj,jk) == 1) ) ikb = jk
-               END DO
-               zhisf_tbl(ji,jj) = MIN(zhisf_tbl(ji,jj), SUM(e3u_n(ji,jj,ikt:ikb)))  ! limit the tbl to water thickness.
-
-               ! level fully include in the ice shelf boundary layer
-               DO jk = ikt, ikb - 1
-                  ze3 = e3u_n(ji,jj,jk)
-                  pvarout(ji,jj) = pvarout(ji,jj) + pvarin(ji,jj,jk) / zhisf_tbl(ji,jj) * ze3
-               END DO
-
-               ! level partially include in ice shelf boundary layer 
-               zhk = SUM( e3u_n(ji, jj, ikt:ikb - 1)) / zhisf_tbl(ji,jj)
-               pvarout(ji,jj) = pvarout(ji,jj) + pvarin(ji,jj,ikb) * (1._wp - zhk)
-            END DO
-         END DO
-         DO jj = 2, jpj
-            DO ji = 2, jpi
-!!gm a wet-point only average should be used here !!!
-               pvarout(ji,jj) = 0.5_wp * (pvarout(ji,jj) + pvarout(ji-1,jj))
-            END DO
-         END DO
-         CALL lbc_lnk('sbcisf', pvarout,'T',-1.)
-      
-      CASE ( 'V' ) ! compute V in the top boundary layer at T- point 
-         DO jj = 1,jpj
-            DO ji = 1,jpi
-               ikt = mikv(ji,jj) ; ikb = mikv(ji,jj)
-               ! thickness of boundary layer at least the top level thickness
-               zhisf_tbl(ji,jj) = MAX(rhisf_tbl_0(ji,jj), e3v_n(ji,jj,ikt))
-
-               ! determine the deepest level influenced by the boundary layer
-               DO jk = ikt+1, mbkv(ji,jj)
-                  IF ( (SUM(e3v_n(ji,jj,ikt:jk-1)) < zhisf_tbl(ji,jj)) .AND. (vmask(ji,jj,jk) == 1) ) ikb = jk
-               END DO
-               zhisf_tbl(ji,jj) = MIN(zhisf_tbl(ji,jj), SUM(e3v_n(ji,jj,ikt:ikb)))  ! limit the tbl to water thickness.
-
-               ! level fully include in the ice shelf boundary layer
-               DO jk = ikt, ikb - 1
-                  ze3 = e3v_n(ji,jj,jk)
-                  pvarout(ji,jj) = pvarout(ji,jj) + pvarin(ji,jj,jk) / zhisf_tbl(ji,jj) * ze3
-               END DO
-
-               ! level partially include in ice shelf boundary layer 
-               zhk = SUM( e3v_n(ji, jj, ikt:ikb - 1)) / zhisf_tbl(ji,jj)
-               pvarout(ji,jj) = pvarout(ji,jj) + pvarin(ji,jj,ikb) * (1._wp - zhk)
-            END DO
-         END DO
-         DO jj = 2, jpj
-            DO ji = 2, jpi
-!!gm a wet-point only average should be used here !!!
-               pvarout(ji,jj) = 0.5_wp * (pvarout(ji,jj) + pvarout(ji,jj-1))
-            END DO
-         END DO
-         CALL lbc_lnk('sbcisf', pvarout,'T',-1.)
-
-      CASE ( 'T' ) ! compute T in the top boundary layer at T- point 
-         DO jj = 1,jpj
-            DO ji = 1,jpi
-               ikt = misfkt(ji,jj)
-               ikb = misfkb(ji,jj)
-
-               ! level fully include in the ice shelf boundary layer
-               DO jk = ikt, ikb - 1
-                  ze3 = e3t_n(ji,jj,jk)
-                  pvarout(ji,jj) = pvarout(ji,jj) + pvarin(ji,jj,jk) * r1_hisf_tbl(ji,jj) * ze3
-               END DO
-
-               ! level partially include in ice shelf boundary layer 
-               zhk = SUM( e3t_n(ji, jj, ikt:ikb - 1)) * r1_hisf_tbl(ji,jj)
-               pvarout(ji,jj) = pvarout(ji,jj) + pvarin(ji,jj,ikb) * (1._wp - zhk)
-            END DO
-         END DO
-      END SELECT
-      !
-      ! mask mean tbl value
-      pvarout(:,:) = pvarout(:,:) * ssmask(:,:)
-      !
-   END SUBROUTINE sbc_isf_tbl
-      
-
-   SUBROUTINE sbc_isf_div( phdivn )
-      !!----------------------------------------------------------------------
-      !!                  ***  SUBROUTINE sbc_isf_div  ***
-      !!       
-      !! ** Purpose :   update the horizontal divergence with the runoff inflow
-      !!
-      !! ** Method  :   
-      !!                CAUTION : risf_tsc(:,:,jp_sal) is negative (outflow) increase the 
-      !!                          divergence and expressed in m/s
-      !!
-      !! ** Action  :   phdivn   decreased by the runoff inflow
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(:,:,:), INTENT( inout ) ::   phdivn   ! horizontal divergence
-      ! 
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      INTEGER  ::   ikt, ikb 
-      REAL(wp) ::   zhk
-      REAL(wp) ::   zfact     ! local scalar
-      !!----------------------------------------------------------------------
-      !
-      zfact   = 0.5_wp
-      !
-      IF(.NOT.ln_linssh ) THEN     ! need to re compute level distribution of isf fresh water
-         DO jj = 1,jpj
-            DO ji = 1,jpi
-               ikt = misfkt(ji,jj)
-               ikb = misfkt(ji,jj)
-               ! thickness of boundary layer at least the top level thickness
-               rhisf_tbl(ji,jj) = MAX(rhisf_tbl_0(ji,jj), e3t_n(ji,jj,ikt))
-
-               ! determine the deepest level influenced by the boundary layer
-               DO jk = ikt, mbkt(ji,jj)
-                  IF ( (SUM(e3t_n(ji,jj,ikt:jk-1)) .LT. rhisf_tbl(ji,jj)) .AND. (tmask(ji,jj,jk) == 1) ) ikb = jk
-               END DO
-               rhisf_tbl(ji,jj) = MIN(rhisf_tbl(ji,jj), SUM(e3t_n(ji,jj,ikt:ikb)))  ! limit the tbl to water thickness.
-               misfkb(ji,jj) = ikb                                                  ! last wet level of the tbl
-               r1_hisf_tbl(ji,jj) = 1._wp / rhisf_tbl(ji,jj)
-
-               zhk           = SUM( e3t_n(ji, jj, ikt:ikb - 1)) * r1_hisf_tbl(ji,jj)  ! proportion of tbl cover by cell from ikt to ikb - 1
-               ralpha(ji,jj) = rhisf_tbl(ji,jj) * (1._wp - zhk ) / e3t_n(ji,jj,ikb)  ! proportion of bottom cell influenced by boundary layer
-            END DO
-         END DO
-      END IF 
-      !
-      !==   ice shelf melting distributed over several levels   ==!
-      DO jj = 1,jpj
-         DO ji = 1,jpi
-               ikt = misfkt(ji,jj)
-               ikb = misfkb(ji,jj)
-               ! level fully include in the ice shelf boundary layer
-               DO jk = ikt, ikb - 1
-                  phdivn(ji,jj,jk) = phdivn(ji,jj,jk) + ( fwfisf(ji,jj) + fwfisf_b(ji,jj) ) &
-                    &              * r1_hisf_tbl(ji,jj) * r1_rau0 * zfact
-               END DO
-               ! level partially include in ice shelf boundary layer 
-               phdivn(ji,jj,ikb) = phdivn(ji,jj,ikb) + ( fwfisf(ji,jj) &
-                    &            + fwfisf_b(ji,jj) ) * r1_hisf_tbl(ji,jj) * r1_rau0 * zfact * ralpha(ji,jj) 
-         END DO
-      END DO
-      !
-   END SUBROUTINE sbc_isf_div
-
-   !!======================================================================
-END MODULE sbcisf
