Index: utils/tools_AGRIF_CMEMS_2020/DOMAINcfg/src/domzgr.F90
===================================================================
--- utils/tools_AGRIF_CMEMS_2020/DOMAINcfg/src/domzgr.f90	(revision 10082)
+++ utils/tools_AGRIF_CMEMS_2020/DOMAINcfg/src/domzgr.F90	(revision 10727)
@@ -17,5 +17,5 @@
    !!            3.4  ! 2012-08  (J. Siddorn) added Siddorn and Furner stretching function
    !!            3.4  ! 2012-12  (R. Bourdalle-Badie and G. Reffray)  modify C1D case  
-   !!            3.6  ! 2014-11  (P. Mathiot and C. Harris) add ice shelf capabilitye  
+   !!            3.6  ! 2014-11  (P. Mathiot and C. Harris) add ice shelf capabilitye
    !!            3.?  ! 2015-11  (H. Liu) Modifications for Wetting/Drying
    !!----------------------------------------------------------------------
@@ -37,5 +37,5 @@
    USE oce               ! ocean variables
    USE dom_oce           ! ocean domain
-   USE closea            ! closed seas
+!   USE closea            ! closed seas
    !
    USE in_out_manager    ! I/O manager
@@ -45,4 +45,5 @@
    USE wrk_nemo          ! Memory allocation
    USE timing            ! Timing
+   USE dombat
 
    IMPLICIT NONE
@@ -59,4 +60,9 @@
    REAL(wp) ::   rn_rmax           ! maximum cut-off r-value allowed (0<rn_rmax<1)
    REAL(wp) ::   rn_hc             ! Critical depth for transition from sigma to stretched coordinates
+   INTEGER , PUBLIC ::   ntopo           !: = 0/1 ,compute/read the bathymetry file
+   REAL(wp), PUBLIC ::   e3zps_min       !: miminum thickness for partial steps (meters)
+   REAL(wp), PUBLIC ::   e3zps_rat       !: minimum thickness ration for partial steps
+   INTEGER, PUBLIC ::   nperio            !: type of lateral boundary condition
+
    ! Song and Haidvogel 1994 stretching parameters
    REAL(wp) ::   rn_theta          ! surface control parameter (0<=rn_theta<=20)
@@ -115,5 +121,5 @@
       !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )   CALL timing_start('dom_zgr')
+  !    IF( nn_timing == 1 )   CALL timing_start('dom_zgr')
       !
       REWIND( numnam_ref )              ! Namelist namzgr in reference namelist : Vertical coordinate
@@ -183,5 +189,5 @@
       ENDIF
       !
-      IF( nn_timing == 1 )  CALL timing_stop('dom_zgr')
+    !  IF( nn_timing == 1 )  CALL timing_stop('dom_zgr')
       !
    END SUBROUTINE dom_zgr
@@ -217,5 +223,5 @@
       !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start('zgr_z')
+   !   IF( nn_timing == 1 )  CALL timing_start('zgr_z')
       !
       ! Set variables from parameters
@@ -349,5 +355,5 @@
       END DO
       !
-      IF( nn_timing == 1 )  CALL timing_stop('zgr_z')
+   !   IF( nn_timing == 1 )  CALL timing_stop('zgr_z')
       !
    END SUBROUTINE zgr_z
@@ -395,5 +401,5 @@
       !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start('zgr_bat')
+   !   IF( nn_timing == 1 )  CALL timing_start('zgr_bat')
       !
       IF(lwp) WRITE(numout,*)
@@ -516,5 +522,5 @@
          !
          !                                            ! ================ !
-      ELSEIF( ntopo == 1 ) THEN                       !   read in file   ! (over the local domain)
+      ELSEIF( ntopo == 1 .OR. ntopo ==2 ) THEN                       !   read in file   ! (over the local domain)
          !                                            ! ================ !
          !
@@ -554,11 +560,27 @@
          ENDIF
          IF( ln_zps .OR. ln_sco )   THEN              ! zps or sco : read meter bathymetry
-            CALL iom_open ( 'bathy_meter.nc', inum ) 
-            IF ( ln_isfcav ) THEN
-               CALL iom_get  ( inum, jpdom_data, 'Bathymetry_isf', bathy, lrowattr=.false. )
+#if defined key_agrif
+            IF (agrif_root()) THEN
+#endif
+            IF( ntopo == 1) THEN
+               CALL iom_open ( 'bathy_meter.nc', inum ) 
+               IF ( ln_isfcav ) THEN
+                  CALL iom_get  ( inum, jpdom_data, 'Bathymetry_isf', bathy, lrowattr=.false. )
+               ELSE
+                  CALL iom_get  ( inum, jpdom_data, 'Bathymetry'    , bathy, lrowattr=ln_use_jattr  )
+               END IF
+               CALL iom_close( inum )
             ELSE
-               CALL iom_get  ( inum, jpdom_data, 'Bathymetry'    , bathy, lrowattr=ln_use_jattr  )
-            END IF
-            CALL iom_close( inum )
+               CALL dom_bat
+            ENDIF       
+#if defined key_agrif
+            ELSE
+               IF( ntopo == 1) THEN
+                  CALL agrif_create_bathy_meter()
+               ELSE 
+                  CALL dom_bat 
+               ENDIF    
+            ENDIF
+#endif
             !                                                
             ! initialisation isf variables
@@ -611,5 +633,5 @@
       ENDIF
       !
-      IF( nn_closea == 0 )   CALL clo_bat( bathy, mbathy )    !==  NO closed seas or lakes  ==!
+    !  IF( nn_closea == 0 )   CALL clo_bat( bathy, mbathy )    !==  NO closed seas or lakes  ==!
       !                       
       IF ( .not. ln_sco ) THEN                                !==  set a minimum depth  ==!
@@ -624,5 +646,5 @@
       ENDIF
       !
-      IF( nn_timing == 1 )  CALL timing_stop('zgr_bat')
+   !   IF( nn_timing == 1 )  CALL timing_stop('zgr_bat')
       !
    END SUBROUTINE zgr_bat
@@ -708,5 +730,5 @@
       !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start('zgr_bat_ctl')
+  !    IF( nn_timing == 1 )  CALL timing_start('zgr_bat_ctl')
       !
       CALL wrk_alloc( jpi, jpj, zbathy )
@@ -738,5 +760,5 @@
          END DO
       END DO
-      IF( lk_mpp )   CALL mpp_sum( icompt )
+   !   IF( lk_mpp )   CALL mpp_sum( icompt )
       IF( icompt == 0 ) THEN
          IF(lwp) WRITE(numout,*)'     no isolated ocean grid points'
@@ -746,5 +768,5 @@
       IF( lk_mpp ) THEN
          zbathy(:,:) = FLOAT( mbathy(:,:) )
-         CALL lbc_lnk( zbathy, 'T', 1._wp )
+         CALL lbc_lnk( 'toto',zbathy, 'T', 1._wp )
          mbathy(:,:) = INT( zbathy(:,:) )
       ENDIF
@@ -784,5 +806,5 @@
          !   ... mono- or macro-tasking: T-point, >0, 2D array, no slab
          zbathy(:,:) = FLOAT( mbathy(:,:) )
-         CALL lbc_lnk( zbathy, 'T', 1._wp )
+         CALL lbc_lnk( 'toto',zbathy, 'T', 1._wp )
          mbathy(:,:) = INT( zbathy(:,:) )
       ENDIF
@@ -805,5 +827,5 @@
       CALL wrk_dealloc( jpi, jpj, zbathy )
       !
-      IF( nn_timing == 1 )  CALL timing_stop('zgr_bat_ctl')
+   !!   IF( nn_timing == 1 )  CALL timing_stop('zgr_bat_ctl')
       !
    END SUBROUTINE zgr_bat_ctl
@@ -826,5 +848,5 @@
       !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start('zgr_bot_level')
+   !   IF( nn_timing == 1 )  CALL timing_start('zgr_bot_level')
       !
       CALL wrk_alloc( jpi, jpj, zmbk )
@@ -844,10 +866,10 @@
       END DO
       ! converte into REAL to use lbc_lnk ; impose a min value of 1 as a zero can be set in lbclnk 
-      zmbk(:,:) = REAL( mbku(:,:), wp )   ;   CALL lbc_lnk(zmbk,'U',1.)   ;   mbku  (:,:) = MAX( INT( zmbk(:,:) ), 1 )
-      zmbk(:,:) = REAL( mbkv(:,:), wp )   ;   CALL lbc_lnk(zmbk,'V',1.)   ;   mbkv  (:,:) = MAX( INT( zmbk(:,:) ), 1 )
+      zmbk(:,:) = REAL( mbku(:,:), wp )   ;   CALL lbc_lnk('toto',zmbk,'U',1.)   ;   mbku  (:,:) = MAX( INT( zmbk(:,:) ), 1 )
+      zmbk(:,:) = REAL( mbkv(:,:), wp )   ;   CALL lbc_lnk('toto',zmbk,'V',1.)   ;   mbkv  (:,:) = MAX( INT( zmbk(:,:) ), 1 )
       !
       CALL wrk_dealloc( jpi, jpj, zmbk )
       !
-      IF( nn_timing == 1 )  CALL timing_stop('zgr_bot_level')
+   !   IF( nn_timing == 1 )  CALL timing_stop('zgr_bot_level')
       !
    END SUBROUTINE zgr_bot_level
@@ -870,5 +892,5 @@
       !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start('zgr_top_level')
+   !   IF( nn_timing == 1 )  CALL timing_start('zgr_top_level')
       !
       CALL wrk_alloc( jpi, jpj, zmik )
@@ -889,11 +911,11 @@
 
       ! converte into REAL to use lbc_lnk ; impose a min value of 1 as a zero can be set in lbclnk 
-      zmik(:,:) = REAL( miku(:,:), wp )   ;   CALL lbc_lnk(zmik,'U',1.)   ;   miku  (:,:) = MAX( INT( zmik(:,:) ), 1 )
-      zmik(:,:) = REAL( mikv(:,:), wp )   ;   CALL lbc_lnk(zmik,'V',1.)   ;   mikv  (:,:) = MAX( INT( zmik(:,:) ), 1 )
-      zmik(:,:) = REAL( mikf(:,:), wp )   ;   CALL lbc_lnk(zmik,'F',1.)   ;   mikf  (:,:) = MAX( INT( zmik(:,:) ), 1 )
+      zmik(:,:) = REAL( miku(:,:), wp )   ;   CALL lbc_lnk('toto',zmik,'U',1.)   ;   miku  (:,:) = MAX( INT( zmik(:,:) ), 1 )
+      zmik(:,:) = REAL( mikv(:,:), wp )   ;   CALL lbc_lnk('toto',zmik,'V',1.)   ;   mikv  (:,:) = MAX( INT( zmik(:,:) ), 1 )
+      zmik(:,:) = REAL( mikf(:,:), wp )   ;   CALL lbc_lnk('toto',zmik,'F',1.)   ;   mikf  (:,:) = MAX( INT( zmik(:,:) ), 1 )
       !
       CALL wrk_dealloc( jpi, jpj, zmik )
       !
-      IF( nn_timing == 1 )  CALL timing_stop('zgr_top_level')
+   !   IF( nn_timing == 1 )  CALL timing_stop('zgr_top_level')
       !
    END SUBROUTINE zgr_top_level
@@ -911,5 +933,5 @@
       !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start('zgr_zco')
+    !  IF( nn_timing == 1 )  CALL timing_start('zgr_zco')
       !
       DO jk = 1, jpk
@@ -926,5 +948,5 @@
       END DO
       !
-      IF( nn_timing == 1 )  CALL timing_stop('zgr_zco')
+   !   IF( nn_timing == 1 )  CALL timing_stop('zgr_zco')
       !
    END SUBROUTINE zgr_zco
@@ -985,5 +1007,5 @@
       !!---------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start('zgr_zps')
+   !   IF( nn_timing == 1 )  CALL timing_start('zgr_zps')
       !
       CALL wrk_alloc( jpi,jpj,jpk,   zprt )
@@ -1118,6 +1140,6 @@
       END IF
 
-      CALL lbc_lnk( e3u_0 , 'U', 1._wp )   ;   CALL lbc_lnk( e3uw_0, 'U', 1._wp )   ! lateral boundary conditions
-      CALL lbc_lnk( e3v_0 , 'V', 1._wp )   ;   CALL lbc_lnk( e3vw_0, 'V', 1._wp )
+      CALL lbc_lnk('toto', e3u_0 , 'U', 1._wp )   ;   CALL lbc_lnk('toto', e3uw_0, 'U', 1._wp )   ! lateral boundary conditions
+      CALL lbc_lnk( 'toto',e3v_0 , 'V', 1._wp )   ;   CALL lbc_lnk('toto', e3vw_0, 'V', 1._wp )
       !
 
@@ -1140,5 +1162,5 @@
          END DO
       END DO
-      CALL lbc_lnk( e3f_0, 'F', 1._wp )       ! Lateral boundary conditions
+      CALL lbc_lnk('toto', e3f_0, 'F', 1._wp )       ! Lateral boundary conditions
       !
       DO jk = 1, jpk                        ! set to z-scale factor if zero (i.e. along closed boundaries)
@@ -1183,5 +1205,5 @@
       CALL wrk_dealloc( jpi,jpj,jpk,   zprt )
       !
-      IF( nn_timing == 1 )  CALL timing_stop('zgr_zps')
+   !   IF( nn_timing == 1 )  CALL timing_stop('zgr_zps')
       !
    END SUBROUTINE zgr_zps
@@ -1217,5 +1239,5 @@
       !!---------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )   CALL timing_start('zgr_isf')
+  !!    IF( nn_timing == 1 )   CALL timing_start('zgr_isf')
       !
       CALL wrk_alloc( jpi,jpj,   zbathy, zmask, zrisfdep)
@@ -1264,12 +1286,12 @@
          IF( lk_mpp ) THEN
             zbathy(:,:)  = FLOAT( misfdep(:,:) )
-            CALL lbc_lnk( zbathy, 'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. )
             misfdep(:,:) = INT( zbathy(:,:) )
 
-            CALL lbc_lnk( risfdep,'T', 1. )
-            CALL lbc_lnk( bathy,  'T', 1. )
+            CALL lbc_lnk( 'toto',risfdep,'T', 1. )
+            CALL lbc_lnk( 'toto',bathy,  'T', 1. )
 
             zbathy(:,:)  = FLOAT( mbathy(:,:) )
-            CALL lbc_lnk( zbathy, 'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. )
             mbathy(:,:)  = INT( zbathy(:,:) )
          ENDIF
@@ -1385,12 +1407,12 @@
          IF( lk_mpp ) THEN
             zbathy(:,:)  = FLOAT( misfdep(:,:) )
-            CALL lbc_lnk( zbathy, 'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. )
             misfdep(:,:) = INT( zbathy(:,:) )
 
-            CALL lbc_lnk( risfdep,'T', 1. )
-            CALL lbc_lnk( bathy,  'T', 1. )
+            CALL lbc_lnk( 'toto',risfdep,'T', 1. )
+            CALL lbc_lnk( 'toto',bathy,  'T', 1. )
 
             zbathy(:,:)  = FLOAT( mbathy(:,:) )
-            CALL lbc_lnk( zbathy, 'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. )
             mbathy(:,:)  = INT( zbathy(:,:) )
          ENDIF
@@ -1422,12 +1444,12 @@
          IF( lk_mpp ) THEN 
             zbathy(:,:)  = FLOAT( misfdep(:,:) )
-            CALL lbc_lnk( zbathy, 'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. )
             misfdep(:,:) = INT( zbathy(:,:) )
 
-            CALL lbc_lnk( risfdep,'T', 1. )
-            CALL lbc_lnk( bathy,  'T', 1. )
+            CALL lbc_lnk( 'toto',risfdep,'T', 1. )
+            CALL lbc_lnk( 'toto',bathy,  'T', 1. )
 
             zbathy(:,:)  = FLOAT( mbathy(:,:) )
-            CALL lbc_lnk( zbathy, 'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. )
             mbathy(:,:)  = INT( zbathy(:,:) )
          ENDIF 
@@ -1459,12 +1481,12 @@
          IF( lk_mpp ) THEN 
             zbathy(:,:)  = FLOAT( misfdep(:,:) )
-            CALL lbc_lnk( zbathy, 'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. )
             misfdep(:,:) = INT( zbathy(:,:) )
 
-            CALL lbc_lnk( risfdep,'T', 1. )
-            CALL lbc_lnk( bathy,  'T', 1. )
+            CALL lbc_lnk( 'toto',risfdep,'T', 1. )
+            CALL lbc_lnk( 'toto',bathy,  'T', 1. )
 
             zbathy(:,:)  = FLOAT( mbathy(:,:) )
-            CALL lbc_lnk( zbathy, 'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. )
             mbathy(:,:)  = INT( zbathy(:,:) )
          ENDIF 
@@ -1496,12 +1518,12 @@
          IF( lk_mpp ) THEN
             zbathy(:,:)  = FLOAT( misfdep(:,:) )
-            CALL lbc_lnk( zbathy, 'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. )
             misfdep(:,:) = INT( zbathy(:,:) )
 
-            CALL lbc_lnk( risfdep,'T', 1. )
-            CALL lbc_lnk( bathy,  'T', 1. )
+            CALL lbc_lnk( 'toto',risfdep,'T', 1. )
+            CALL lbc_lnk( 'toto',bathy,  'T', 1. )
 
             zbathy(:,:)  = FLOAT( mbathy(:,:) )
-            CALL lbc_lnk( zbathy, 'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. )
             mbathy(:,:)  = INT( zbathy(:,:) )
          ENDIF
@@ -1533,12 +1555,12 @@
          IF( lk_mpp ) THEN
             zbathy(:,:)  = FLOAT( misfdep(:,:) )
-            CALL lbc_lnk( zbathy, 'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. )
             misfdep(:,:) = INT( zbathy(:,:) )
 
-            CALL lbc_lnk( risfdep,'T', 1. )
-            CALL lbc_lnk( bathy,  'T', 1. )
+            CALL lbc_lnk( 'toto',risfdep,'T', 1. )
+            CALL lbc_lnk('toto', bathy,  'T', 1. )
 
             zbathy(:,:)  = FLOAT( mbathy(:,:) )
-            CALL lbc_lnk( zbathy, 'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. )
             mbathy(:,:)  = INT( zbathy(:,:) )
          ENDIF
@@ -1565,12 +1587,12 @@
          IF( lk_mpp ) THEN
             zbathy(:,:)  = FLOAT( misfdep(:,:) )
-            CALL lbc_lnk( zbathy, 'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. )
             misfdep(:,:) = INT( zbathy(:,:) )
 
-            CALL lbc_lnk( risfdep,'T', 1. )
-            CALL lbc_lnk( bathy,  'T', 1. )
+            CALL lbc_lnk( 'toto',risfdep,'T', 1. )
+            CALL lbc_lnk( 'toto',bathy,  'T', 1. )
 
             zbathy(:,:)  = FLOAT( mbathy(:,:) )
-            CALL lbc_lnk( zbathy, 'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. )
             mbathy(:,:)  = INT( zbathy(:,:) )
          ENDIF
@@ -1601,12 +1623,12 @@
          IF( lk_mpp ) THEN 
             zbathy(:,:)  = FLOAT( misfdep(:,:) ) 
-            CALL lbc_lnk( zbathy,  'T', 1. ) 
+            CALL lbc_lnk( 'toto',zbathy,  'T', 1. ) 
             misfdep(:,:) = INT( zbathy(:,:) ) 
 
-            CALL lbc_lnk( risfdep, 'T', 1. ) 
-            CALL lbc_lnk( bathy,   'T', 1. )
+            CALL lbc_lnk( 'toto',risfdep, 'T', 1. ) 
+            CALL lbc_lnk( 'toto',bathy,   'T', 1. )
 
             zbathy(:,:) = FLOAT( mbathy(:,:) )
-            CALL lbc_lnk( zbathy,  'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy,  'T', 1. )
             mbathy(:,:) = INT( zbathy(:,:) )
          ENDIF 
@@ -1634,12 +1656,12 @@
          IF( lk_mpp ) THEN 
             zbathy(:,:)  = FLOAT( misfdep(:,:) ) 
-            CALL lbc_lnk( zbathy,  'T', 1. ) 
+            CALL lbc_lnk( 'toto',zbathy,  'T', 1. ) 
             misfdep(:,:) = INT( zbathy(:,:) ) 
 
-            CALL lbc_lnk( risfdep, 'T', 1. ) 
-            CALL lbc_lnk( bathy,   'T', 1. )
+            CALL lbc_lnk( 'toto',risfdep, 'T', 1. ) 
+            CALL lbc_lnk( 'toto',bathy,   'T', 1. )
 
             zbathy(:,:) = FLOAT( mbathy(:,:) )
-            CALL lbc_lnk( zbathy,  'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy,  'T', 1. )
             mbathy(:,:) = INT( zbathy(:,:) )
          ENDIF 
@@ -1654,12 +1676,12 @@
          IF( lk_mpp ) THEN 
             zbathy(:,:)  = FLOAT( misfdep(:,:) ) 
-            CALL lbc_lnk( zbathy,  'T', 1. ) 
+            CALL lbc_lnk( 'toto',zbathy,  'T', 1. ) 
             misfdep(:,:) = INT( zbathy(:,:) ) 
 
-            CALL lbc_lnk( risfdep, 'T', 1. ) 
-            CALL lbc_lnk( bathy,   'T', 1. )
+            CALL lbc_lnk('toto', risfdep, 'T', 1. ) 
+            CALL lbc_lnk('toto', bathy,   'T', 1. )
 
             zbathy(:,:) = FLOAT( mbathy(:,:) )
-            CALL lbc_lnk( zbathy,  'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy,  'T', 1. )
             mbathy(:,:) = INT( zbathy(:,:) )
          ENDIF 
@@ -1674,12 +1696,12 @@
          IF( lk_mpp ) THEN 
             zbathy(:,:)  = FLOAT( misfdep(:,:) ) 
-            CALL lbc_lnk( zbathy, 'T', 1. ) 
+            CALL lbc_lnk('toto', zbathy, 'T', 1. ) 
             misfdep(:,:) = INT( zbathy(:,:) ) 
 
-            CALL lbc_lnk( risfdep,'T', 1. ) 
-            CALL lbc_lnk( bathy,  'T', 1. )
+            CALL lbc_lnk('toto', risfdep,'T', 1. ) 
+            CALL lbc_lnk( 'toto',bathy,  'T', 1. )
 
             zbathy(:,:) = FLOAT( mbathy(:,:) )
-            CALL lbc_lnk( zbathy, 'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. )
             mbathy(:,:) = INT( zbathy(:,:) )
          ENDIF 
@@ -1694,12 +1716,12 @@
          IF( lk_mpp ) THEN 
             zbathy(:,:)  = FLOAT( misfdep(:,:) ) 
-            CALL lbc_lnk( zbathy, 'T', 1. ) 
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. ) 
             misfdep(:,:) = INT( zbathy(:,:) ) 
 
-            CALL lbc_lnk( risfdep,'T', 1. ) 
-            CALL lbc_lnk( bathy,  'T', 1. )
+            CALL lbc_lnk( 'toto',risfdep,'T', 1. ) 
+            CALL lbc_lnk('toto', bathy,  'T', 1. )
 
             zbathy(:,:) = FLOAT( mbathy(:,:) )
-            CALL lbc_lnk( zbathy, 'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. )
             mbathy(:,:) = INT( zbathy(:,:) )
          ENDIF 
@@ -1714,12 +1736,12 @@
          IF( lk_mpp ) THEN 
             zbathy(:,:)  = FLOAT( misfdep(:,:) ) 
-            CALL lbc_lnk( zbathy, 'T', 1. ) 
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. ) 
             misfdep(:,:) = INT( zbathy(:,:) ) 
 
-            CALL lbc_lnk( risfdep,'T', 1. ) 
-            CALL lbc_lnk( bathy,  'T', 1. )
+            CALL lbc_lnk( 'toto',risfdep,'T', 1. ) 
+            CALL lbc_lnk( 'toto',bathy,  'T', 1. )
 
             zbathy(:,:) = FLOAT( mbathy(:,:) )
-            CALL lbc_lnk( zbathy, 'T', 1. )
+            CALL lbc_lnk( 'toto',zbathy, 'T', 1. )
             mbathy(:,:) = INT( zbathy(:,:) )
          ENDIF 
@@ -1827,7 +1849,8 @@
             !       ... on ik / ik-1 
                e3w_0  (ji,jj,ik  ) = e3t_0  (ji,jj,ik) !2._wp * (gdept_0(ji,jj,ik) - gdepw_0(ji,jj,ik)) 
+               gdept_0(ji,jj,ik-1) = gdept_0(ji,jj,ik) - e3w_0(ji,jj,ik)
                e3t_0  (ji,jj,ik-1) = gdepw_0(ji,jj,ik) - gdepw_1d(ik-1)
-! The next line isn't required and doesn't affect results - included for consistency with bathymetry code 
-               gdept_0(ji,jj,ik-1) = gdept_1d(ik-1)
+               e3w_0  (ji,jj,ik-1) = gdept_0(ji,jj,ik-1) - gdept_1d(ik-2)
+               gdepw_0(ji,jj,ik-1) = gdepw_0(ji,jj,ik) - e3t_0(ji,jj,ik-1)
             ENDIF 
          END DO 
@@ -1857,5 +1880,5 @@
       CALL wrk_dealloc( jpi, jpj, zmisfdep, zmbathy )
       !
-      IF( nn_timing == 1 )   CALL timing_stop('zgr_isf')
+  !    IF( nn_timing == 1 )   CALL timing_stop('zgr_isf')
       !      
    END SUBROUTINE zgr_isf
@@ -1919,5 +1942,5 @@
      !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start('zgr_sco')
+   !!   IF( nn_timing == 1 )  CALL timing_start('zgr_sco')
       !
       CALL wrk_alloc( jpi,jpj,   zenv, ztmp, zmsk, zri, zrj, zhbat , ztmpi1, ztmpi2, ztmpj1, ztmpj2 )
@@ -2001,5 +2024,5 @@
 
       ! apply lateral boundary condition   CAUTION: keep the value when the lbc field is zero
-      CALL lbc_lnk( zenv, 'T', 1._wp, 'no0' )
+      CALL lbc_lnk( 'toto',zenv, 'T', 1._wp, 'no0' )
       ! 
       ! smooth the bathymetry (if required)
@@ -2055,5 +2078,5 @@
             END DO
          END DO
-         IF( lk_mpp )   CALL mpp_max( zrmax )   ! max over the global domain
+  !       IF( lk_mpp )   CALL mpp_max( zrmax )   ! max over the global domain
          !
          IF(lwp)WRITE(numout,*) 'zgr_sco :   iter= ',jl, ' rmax= ', zrmax
@@ -2065,5 +2088,5 @@
          END DO
          ! apply lateral boundary condition   CAUTION: keep the value when the lbc field is zero
-         CALL lbc_lnk( zenv, 'T', 1._wp, 'no0' )
+         CALL lbc_lnk( 'toto',zenv, 'T', 1._wp, 'no0' )
          !                                                  ! ================ !
       END DO                                                !     End loop     !
@@ -2109,5 +2132,5 @@
       ! Apply lateral boundary condition
 !!gm  ! CAUTION: retain non zero value in the initial file this should be OK for orca cfg, not for EEL
-      zhbat(:,:) = hbatu(:,:)   ;   CALL lbc_lnk( hbatu, 'U', 1._wp )
+      zhbat(:,:) = hbatu(:,:)   ;   CALL lbc_lnk('toto', hbatu, 'U', 1._wp )
       DO jj = 1, jpj
          DO ji = 1, jpi
@@ -2119,5 +2142,5 @@
          END DO
       END DO
-      zhbat(:,:) = hbatv(:,:)   ;   CALL lbc_lnk( hbatv, 'V', 1._wp )
+      zhbat(:,:) = hbatv(:,:)   ;   CALL lbc_lnk('toto', hbatv, 'V', 1._wp )
       DO jj = 1, jpj
          DO ji = 1, jpi
@@ -2128,5 +2151,5 @@
          END DO
       END DO
-      zhbat(:,:) = hbatf(:,:)   ;   CALL lbc_lnk( hbatf, 'F', 1._wp )
+      zhbat(:,:) = hbatf(:,:)   ;   CALL lbc_lnk('toto', hbatf, 'F', 1._wp )
       DO jj = 1, jpj
          DO ji = 1, jpi
@@ -2176,11 +2199,11 @@
       ENDIF 
 
-      CALL lbc_lnk( e3t_0 , 'T', 1._wp )
-      CALL lbc_lnk( e3u_0 , 'U', 1._wp )
-      CALL lbc_lnk( e3v_0 , 'V', 1._wp )
-      CALL lbc_lnk( e3f_0 , 'F', 1._wp )
-      CALL lbc_lnk( e3w_0 , 'W', 1._wp )
-      CALL lbc_lnk( e3uw_0, 'U', 1._wp )
-      CALL lbc_lnk( e3vw_0, 'V', 1._wp )
+      CALL lbc_lnk( 'toto',e3t_0 , 'T', 1._wp )
+      CALL lbc_lnk( 'toto',e3u_0 , 'U', 1._wp )
+      CALL lbc_lnk( 'toto',e3v_0 , 'V', 1._wp )
+      CALL lbc_lnk( 'toto',e3f_0 , 'F', 1._wp )
+      CALL lbc_lnk( 'toto',e3w_0 , 'W', 1._wp )
+      CALL lbc_lnk( 'toto',e3uw_0, 'U', 1._wp )
+      CALL lbc_lnk('toto', e3vw_0, 'V', 1._wp )
       !
         WHERE( e3t_0 (:,:,:) == 0._wp )   e3t_0 (:,:,:) = 1._wp
@@ -2314,5 +2337,5 @@
       CALL wrk_dealloc( jpi, jpj, zenv, ztmp, zmsk, zri, zrj, zhbat , ztmpi1, ztmpi2, ztmpj1, ztmpj2 )
       !
-      IF( nn_timing == 1 )  CALL timing_stop('zgr_sco')
+   !!!   IF( nn_timing == 1 )  CALL timing_stop('zgr_sco')
       !
    END SUBROUTINE zgr_sco
@@ -2585,8 +2608,8 @@
       ENDDO
       !
-      CALL lbc_lnk(e3t_0 ,'T',1.) ; CALL lbc_lnk(e3u_0 ,'T',1.)
-      CALL lbc_lnk(e3v_0 ,'T',1.) ; CALL lbc_lnk(e3f_0 ,'T',1.)
-      CALL lbc_lnk(e3w_0 ,'T',1.)
-      CALL lbc_lnk(e3uw_0,'T',1.) ; CALL lbc_lnk(e3vw_0,'T',1.)
+      CALL lbc_lnk('toto',e3t_0 ,'T',1.) ; CALL lbc_lnk('toto',e3u_0 ,'T',1.)
+      CALL lbc_lnk('toto',e3v_0 ,'T',1.) ; CALL lbc_lnk('toto',e3f_0 ,'T',1.)
+      CALL lbc_lnk('toto',e3w_0 ,'T',1.)
+      CALL lbc_lnk('toto',e3uw_0,'T',1.) ; CALL lbc_lnk('toto',e3vw_0,'T',1.)
       !
       CALL wrk_dealloc( jpi,jpj,jpk,   z_gsigw3, z_gsigt3, z_gsi3w3                                      )
