Index: /branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/LBC/lbc_nfd_ext_generic.h90
===================================================================
--- /branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/LBC/lbc_nfd_ext_generic.h90	(revision 9466)
+++ /branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/LBC/lbc_nfd_ext_generic.h90	(revision 9467)
@@ -12,5 +12,5 @@
    SUBROUTINE ROUTINE_NFD( ptab, cd_nat, psgn, kextj )
       !!----------------------------------------------------------------------
-      ARRAY_TYPE(:,:,:,:,:)                             ! array or pointer of arrays on which the boundary condition is applied
+      ARRAY_TYPE(:,1-kextj:,:,:,:)                      ! array or pointer of arrays on which the boundary condition is applied
       CHARACTER(len=1) , INTENT(in   ) ::   NAT_IN(:)   ! nature of array grid-points
       REAL(wp)         , INTENT(in   ) ::   SGN_IN(:)   ! sign used across the north fold boundary
@@ -56,5 +56,5 @@
             CASE ( 'U' )                               ! U-point
                DO jh = 0, kextj
-                  DO ji = 1, jpiglo-1
+                  DO ji = 2, jpiglo-1
                      iju = jpiglo-ji+1
                      ARRAY_IN(ji,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-2-jh,:,:,jf)
@@ -83,6 +83,8 @@
                      ARRAY_IN(ji,ipj+jh  ,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-3-jh,:,:,jf)
                   END DO
+               END DO
+               DO jh = 0, kextj
                   ARRAY_IN(   1  ,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(    2   ,ipj-3-jh,:,:,jf)
-                  ARRAY_IN(jpiglo,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(jpiglo-1,ipj-3-jh,:,:,jf) 
+                  ARRAY_IN(jpiglo,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(jpiglo-1,ipj-3-jh,:,:,jf)
                END DO
             END SELECT
Index: /branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90
===================================================================
--- /branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 9466)
+++ /branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 9467)
@@ -1369,20 +1369,22 @@
       !
       ipj=4
-      ALLOCATE( ztab_e(jpiglo,ipj+kextj), znorthloc_e(  jpimax,ipj+kextj), &
-     &                                    znorthgloio_e(jpimax,ipj+kextj,jpni) )
+      ALLOCATE(        ztab_e(jpiglo, 1-kextj:ipj+kextj)       ,       &
+     &            znorthloc_e(jpimax, 1-kextj:ipj+kextj)       ,       &
+     &          znorthgloio_e(jpimax, 1-kextj:ipj+kextj,jpni)    )
       !
       ztab_e(:,:)      = 0._wp
       znorthloc_e(:,:) = 0._wp
       !
-      ij = 0
-      ! put the last ipj+kextj lines of pt2d into znorthloc_e 
-      DO jj = jpj - ipj + 1, jpj + kextj
+      ij = 1 - kextj
+      ! put the last ipj+2*kextj lines of pt2d into znorthloc_e 
+      DO jj = jpj - ipj + 1 - kextj , jpj + kextj
+         znorthloc_e(1:jpi,ij)=pt2d(1:jpi,jj)
          ij = ij + 1
-         znorthloc_e(1:jpi,ij)=pt2d(1:jpi,jj)
       END DO
       !
-      itaille = jpimax * ( ipj + kextj )
-      CALL MPI_ALLGATHER( znorthloc_e(1,1)  , itaille, MPI_DOUBLE_PRECISION,    &
-         &                znorthgloio_e(1,1,1), itaille, MPI_DOUBLE_PRECISION, ncomm_north, ierr )
+      itaille = jpimax * ( ipj + 2*kextj )
+      CALL MPI_ALLGATHER( znorthloc_e(1,1-kextj)    , itaille, MPI_DOUBLE_PRECISION,    &
+         &                znorthgloio_e(1,1-kextj,1), itaille, MPI_DOUBLE_PRECISION,    &
+         &                ncomm_north, ierr )
       !
       DO jr = 1, ndim_rank_north            ! recover the global north array
@@ -1391,5 +1393,5 @@
          ilei = nleit (iproc)
          iilb = nimppt(iproc)
-         DO jj = 1, ipj+kextj
+         DO jj = 1-kextj, ipj+kextj
             DO ji = ildi, ilei
                ztab_e(ji+iilb-1,jj) = znorthgloio_e(ji,jj,jr)
@@ -1400,13 +1402,13 @@
       ! 2. North-Fold boundary conditions
       ! ----------------------------------
-      CALL lbc_nfd( ztab_e(:,:), cd_type, psgn, kextj )
-
-      ij = 0
+      CALL lbc_nfd( ztab_e(:,1-kextj:ipj+kextj), cd_type, psgn, kextj )
+
+      ij = 1 - kextj
       !! Scatter back to pt2d
-      DO jj = jpj - ipj + 1 , jpj + kextj
-      ij  = ij +1
+      DO jj = jpj - ipj + 1 - kextj , jpj + kextj
          DO ji= 1, jpi
             pt2d(ji,jj) = ztab_e(ji+nimpp-1,ij)
          END DO
+         ij  = ij +1
       END DO
       !
Index: /branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/SBC/geo2ocean.F90
===================================================================
--- /branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/SBC/geo2ocean.F90	(revision 9466)
+++ /branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/SBC/geo2ocean.F90	(revision 9467)
@@ -11,8 +11,8 @@
    !!----------------------------------------------------------------------
 !clem: these lines do not seem necessary anymore
-!#if defined key_agrif
-!!DIR$ OPTIMIZE:1        ! intel formulation
+#if defined key_agrif
+!DIR$ OPTIMIZE:1        ! intel formulation
 !!DIR$ OPTIMIZE (-O 1)   ! cray formulation
-!#endif
+#endif
    !!----------------------------------------------------------------------
    !!   rot_rep       : Rotate the Repere: geographic grid <==> stretched coordinates grid
