Index: NEMO/trunk/src/OCE/USR/usrdef_fmask.F90
===================================================================
--- NEMO/trunk/src/OCE/USR/usrdef_fmask.F90	(revision 13226)
+++ NEMO/trunk/src/OCE/USR/usrdef_fmask.F90	(revision 13286)
@@ -68,14 +68,18 @@
             !
             IF(lwp) WRITE(numout,*) '      Gibraltar '
-            ij0 = 101   ;   ij1 = 101           ! Gibraltar strait  : partial slip (pfmsk=0.5)
-            ii0 = 139   ;   ii1 = 140   ;   pfmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  0.5_wp
-            ij0 = 102   ;   ij1 = 102
-            ii0 = 139   ;   ii1 = 140   ;   pfmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  0.5_wp
+            ij0 = 101 + nn_hls       ;   ij1 = 101 + nn_hls           ! Gibraltar strait  : partial slip (pfmsk=0.5)
+            ii0 = 139 + nn_hls - 1   ;   ii1 = 140 + nn_hls - 1
+            pfmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  0.5_wp
+            ij0 = 102 + nn_hls       ;   ij1 = 102 + nn_hls
+            ii0 = 139 + nn_hls - 1   ;   ii1 = 140 + nn_hls - 1
+            pfmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  0.5_wp
             !
             IF(lwp) WRITE(numout,*) '      Bab el Mandeb '
-            ij0 =  87   ;   ij1 =  88           ! Bab el Mandeb : partial slip (pfmsk=1)
-            ii0 = 160   ;   ii1 = 160   ;   pfmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  1._wp
-            ij0 =  88   ;   ij1 =  88
-            ii0 = 159   ;   ii1 = 159   ;   pfmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  1._wp
+            ij0 =  87 + nn_hls       ;   ij1 = 88  + nn_hls          ! Bab el Mandeb : partial slip (pfmsk=1)
+            ii0 = 160 + nn_hls - 1   ;   ii1 = 160 + nn_hls - 1
+            pfmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  1._wp
+            ij0 =  88 + nn_hls       ;   ij1 =  88 + nn_hls
+            ii0 = 159 + nn_hls - 1   ;   ii1 = 159 + nn_hls - 1
+            pfmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  1._wp
             !
             ! We keep this as an example but it is instable in this case 
@@ -94,39 +98,47 @@
 !!gm    ! Currently these hard-wired indices relate to configuration with extend grid (jpjglo=332)
             !
-            isrow = 332 - jpjglo
+            isrow = 332 - (Nj0glo + 1)   ! was 332 - jpjglo -> jpjglo_old_version = Nj0glo + 1
             !
             IF(lwp) WRITE(numout,*)
             IF(lwp) WRITE(numout,*) '   orca_r1: increase friction near the following straits : '
             IF(lwp) WRITE(numout,*) '      Gibraltar '
-            ii0 = 282           ;   ii1 = 283        ! Gibraltar Strait 
-            ij0 = 241 - isrow   ;   ij1 = 241 - isrow   ;   pfmsk( mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),1:jpk ) = 2._wp  
+            ii0 = 282 + nn_hls - 1       ;   ii1 = 283 + nn_hls - 1        ! Gibraltar Strait 
+            ij0 = 241 + nn_hls - isrow   ;   ij1 = 241 + nn_hls - isrow
+            pfmsk( mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),1:jpk ) = 2._wp  
             !
             IF(lwp) WRITE(numout,*) '      Bhosporus '
-            ii0 = 314           ;   ii1 = 315        ! Bhosporus Strait 
-            ij0 = 248 - isrow   ;   ij1 = 248 - isrow   ;   pfmsk( mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),1:jpk ) = 2._wp  
+            ii0 = 314 + nn_hls - 1       ;   ii1 = 315 + nn_hls - 1        ! Bhosporus Strait 
+            ij0 = 248 + nn_hls - isrow   ;   ij1 = 248 + nn_hls - isrow
+            pfmsk( mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),1:jpk ) = 2._wp  
             !
             IF(lwp) WRITE(numout,*) '      Makassar (Top) '
-            ii0 =  48           ;   ii1 =  48        ! Makassar Strait (Top) 
-            ij0 = 189 - isrow   ;   ij1 = 190 - isrow   ;   pfmsk( mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),1:jpk ) = 3._wp  
+            ii0 =  48 + nn_hls - 1       ;   ii1 =  48 + nn_hls - 1        ! Makassar Strait (Top) 
+            ij0 = 189 + nn_hls - isrow   ;   ij1 = 190 + nn_hls - isrow
+            pfmsk( mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),1:jpk ) = 3._wp  
             !
             IF(lwp) WRITE(numout,*) '      Lombok '
-            ii0 =  44           ;   ii1 =  44        ! Lombok Strait 
-            ij0 = 164 - isrow   ;   ij1 = 165 - isrow   ;   pfmsk( mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),1:jpk ) = 2._wp  
+            ii0 =  44 + nn_hls - 1       ;   ii1 =  44 + nn_hls - 1        ! Lombok Strait 
+            ij0 = 164 + nn_hls - isrow   ;   ij1 = 165 + nn_hls - isrow
+            pfmsk( mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),1:jpk ) = 2._wp  
             !
             IF(lwp) WRITE(numout,*) '      Ombai '
-            ii0 =  53           ;   ii1 =  53        ! Ombai Strait 
-            ij0 = 164 - isrow   ;   ij1 = 165 - isrow   ;   pfmsk( mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),1:jpk ) = 2._wp  
+            ii0 =  53 + nn_hls - 1       ;   ii1 =  53 + nn_hls - 1        ! Ombai Strait 
+            ij0 = 164 + nn_hls - isrow   ;   ij1 = 165 + nn_hls - isrow
+            pfmsk( mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),1:jpk ) = 2._wp  
             !
             IF(lwp) WRITE(numout,*) '      Timor Passage '
-            ii0 =  56           ;   ii1 =  56        ! Timor Passage 
-            ij0 = 164 - isrow   ;   ij1 = 165 - isrow   ;   pfmsk( mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),1:jpk ) = 2._wp  
+            ii0 =  56 + nn_hls - 1       ;   ii1 =  56 + nn_hls - 1        ! Timor Passage 
+            ij0 = 164 + nn_hls - isrow   ;   ij1 = 165 + nn_hls - isrow
+            pfmsk( mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),1:jpk ) = 2._wp  
             !
             IF(lwp) WRITE(numout,*) '      West Halmahera '
-            ii0 =  58           ;   ii1 =  58        ! West Halmahera Strait 
-            ij0 = 181 - isrow   ;   ij1 = 182 - isrow   ;   pfmsk( mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),1:jpk ) = 3._wp  
+            ii0 =  58 + nn_hls - 1       ;   ii1 =  58 + nn_hls - 1        ! West Halmahera Strait 
+            ij0 = 181 + nn_hls - isrow   ;   ij1 = 182 + nn_hls - isrow
+            pfmsk( mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),1:jpk ) = 3._wp  
             !
             IF(lwp) WRITE(numout,*) '      East Halmahera '
-            ii0 =  55           ;   ii1 =  55        ! East Halmahera Strait 
-            ij0 = 181 - isrow   ;   ij1 = 182 - isrow   ;   pfmsk( mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),1:jpk ) = 3._wp  
+            ii0 =  55 + nn_hls - 1       ;   ii1 =  55 + nn_hls - 1        ! East Halmahera Strait 
+            ij0 = 181 + nn_hls - isrow   ;   ij1 = 182 + nn_hls - isrow
+            pfmsk( mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),1:jpk ) = 3._wp  
             !
          CASE DEFAULT
Index: NEMO/trunk/src/OCE/USR/usrdef_hgr.F90
===================================================================
--- NEMO/trunk/src/OCE/USR/usrdef_hgr.F90	(revision 13226)
+++ NEMO/trunk/src/OCE/USR/usrdef_hgr.F90	(revision 13286)
@@ -13,5 +13,5 @@
    !!   usr_def_hgr   : initialize the horizontal mesh 
    !!----------------------------------------------------------------------
-   USE dom_oce  , ONLY: nimpp, njmpp       ! ocean space and time domain
+   USE dom_oce        ! ocean space and time domain
    USE par_oce        ! ocean space and time domain
    USE phycst         ! physical constants
@@ -90,6 +90,6 @@
       zcos_alpha =   SQRT( 2._wp ) * 0.5_wp
       ze1deg = ze1 / (ra * rad)
-      zlam0 = zlam1 + zcos_alpha * ze1deg * REAL( jpjglo-2 , wp )
-      zphi0 = zphi1 + zsin_alpha * ze1deg * REAL( jpjglo-2 , wp )
+      zlam0 = zlam1 + zcos_alpha * ze1deg * REAL( Ni0glo - 2, wp )
+      zphi0 = zphi1 + zsin_alpha * ze1deg * REAL( Nj0glo - 2, wp )
 
 #if defined key_agrif
@@ -97,8 +97,8 @@
       ! Laurent: Should be modify in case of an east-west cyclic parent grid
       IF (.NOT.Agrif_root()) THEN
-         zlam0 = zlam1 + Agrif_irhox() * REAL(Agrif_Parent(jpjglo)-2 , wp) * ze1deg * zcos_alpha  &
+         zlam0 = zlam1 + Agrif_irhox() * REAL(Agrif_Parent(Ni0glo) -2, wp) * ze1deg * zcos_alpha  &
                    &   + ( Agrif_Ix()*Agrif_irhox()-(0.5_wp+nbghostcells)) * ze1deg * zcos_alpha  &
                    &   + ( Agrif_Iy()*Agrif_irhoy()-(0.5_wp+nbghostcells)) * ze1deg * zsin_alpha
-         zphi0 = zphi1 + Agrif_irhoy() * REAL(Agrif_Parent(jpjglo)-2 , wp) * ze1deg * zsin_alpha  &
+         zphi0 = zphi1 + Agrif_irhoy() * REAL(Agrif_Parent(Nj0glo) -2, wp) * ze1deg * zsin_alpha  &
                    &   - ( Agrif_Ix()*Agrif_irhox()-nbghostcells )         * ze1deg * zsin_alpha  &
                    &   + ( Agrif_Iy()*Agrif_irhoy()-nbghostcells )         * ze1deg * zcos_alpha
@@ -110,5 +110,5 @@
          CALL ctl_warn( ' GYRE used as Benchmark: e1=e2=106km, no need to adjust rn_Dt, ahm,aht ' )
       ENDIF
-      IF( nprint==1 .AND. lwp )   THEN
+      IF( lwp )   THEN
          WRITE(numout,*) 'ze1', ze1, 'cosalpha', zcos_alpha, 'sinalpha', zsin_alpha
          WRITE(numout,*) 'ze1deg', ze1deg, 'zlam0', zlam0, 'zphi0', zphi0
@@ -116,6 +116,6 @@
       !   
       DO_2D_11_11
-         zim1 = REAL( ji + nimpp - 1 ) - 1.   ;   zim05 = REAL( ji + nimpp - 1 ) - 1.5 
-         zjm1 = REAL( jj + njmpp - 1 ) - 1.   ;   zjm05 = REAL( jj + njmpp - 1 ) - 1.5 
+         zim1 = REAL( mig0_oldcmp(ji), wp ) - 1.   ;   zim05 = REAL( mig0_oldcmp(ji), wp ) - 1.5
+         zjm1 = REAL( mjg0_oldcmp(jj), wp ) - 1.   ;   zjm05 = REAL( mjg0_oldcmp(jj), wp ) - 1.5
          !   
          !glamt(i,j) longitude at T-point
Index: NEMO/trunk/src/OCE/USR/usrdef_nam.F90
===================================================================
--- NEMO/trunk/src/OCE/USR/usrdef_nam.F90	(revision 13226)
+++ NEMO/trunk/src/OCE/USR/usrdef_nam.F90	(revision 13286)
@@ -14,5 +14,5 @@
    !!   usr_def_hgr   : initialize the horizontal mesh 
    !!----------------------------------------------------------------------
-   USE dom_oce  , ONLY: nimpp, njmpp       ! ocean space and time domain
+   USE dom_oce
    USE par_oce        ! ocean space and time domain
    USE phycst         ! physical constants
@@ -70,10 +70,12 @@
       kk_cfg = nn_GYRE
       !
-      kpi = 30 * nn_GYRE + 2        ! Global Domain size
+      kpi = 30 * nn_GYRE + 2       !                     
       kpj = 20 * nn_GYRE + 2
 #if defined key_agrif
-      IF( .NOT. Agrif_Root() ) THEN
-         kpi  = nbcellsx + 2 + 2*nbghostcells_x
-         kpj  = nbcellsy + 2 + 2*nbghostcells_y_s
+      IF( .NOT.Agrif_Root() ) THEN         ! Global Domain size: add 1 land point on each side
+         kpi  = nbcellsx + 2 * ( nbghostcells + 1 )
+         kpj  = nbcellsy + 2 * ( nbghostcells + 1 )
+!!$         kpi  = nbcellsx + nbghostcells_x   + nbghostcells_x   + 2
+!!$         kpj  = nbcellsy + nbghostcells_y_s + nbghostcells_y_n + 2
       ENDIF
 #endif
@@ -93,12 +95,12 @@
          IF( Agrif_Root() ) THEN
 #endif
-         WRITE(numout,*) '         jpiglo = 30*nn_GYRE+2                            jpiglo = ', kpi
-         WRITE(numout,*) '         jpjglo = 20*nn_GYRE+2                            jpjglo = ', kpj
+         WRITE(numout,*) '      Ni0glo = 30*nn_GYRE                              Ni0glo = ', kpi
+         WRITE(numout,*) '      Nj0glo = 20*nn_GYRE                              Nj0glo = ', kpj
 #if defined key_agrif
          ENDIF
 #endif
-         WRITE(numout,*) '      number of model levels                              jpkglo = ', kpk
+         WRITE(numout,*) '      number of model levels                           jpkglo = ', kpk
          WRITE(numout,*) '   '
-         WRITE(numout,*) '   Lateral b.c. of the global domain set to closed        jperio = ', kperio
+         WRITE(numout,*) '   Lateral b.c. of the global domain set to closed     jperio = ', kperio
       ENDIF
       !
Index: NEMO/trunk/src/OCE/USR/usrdef_zgr.F90
===================================================================
--- NEMO/trunk/src/OCE/USR/usrdef_zgr.F90	(revision 13226)
+++ NEMO/trunk/src/OCE/USR/usrdef_zgr.F90	(revision 13286)
@@ -198,7 +198,5 @@
       IF(lwp) WRITE(numout,*) '       GYRE case : closed flat box ocean without ocean cavities'
       !
-      z2d(:,:) = REAL( jpkm1 , wp )          ! flat bottom
-      !
-      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1.0_wp )           ! set surrounding land to zero (here jperio=0 ==>> closed)
+      z2d(:,:) = REAL( jpkm1 , wp )                              ! flat bottom
       !
       k_bot(:,:) = NINT( z2d(:,:) )          ! =jpkm1 over the ocean point, =0 elsewhere
