Index: /NEMO/branches/2019/fix_ticket2229/README.rst
===================================================================
--- /NEMO/branches/2019/fix_ticket2229/README.rst	(revision 10688)
+++ /NEMO/branches/2019/fix_ticket2229/README.rst	(revision 10689)
@@ -90,8 +90,8 @@
 .. Substitutions / Links
 
-.. |NEMO manual| image:: http://zenodo.org/badge/DOI/10.5281/zenodo.1464816.svg
-.. |NEMO guide|  image:: http://zenodo.org/badge/DOI/10.5281/zenodo.1475325.svg
-.. |SI3 manual|  image:: http://zenodo.org/badge/DOI/10.5281/zenodo.1471689.svg
-.. |TOP manual|  image:: http://zenodo.org/badge/DOI/10.5281/zenodo.1471700.svg
+.. |NEMO manual| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1464816.svg
+.. |NEMO guide|  image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1475325.svg
+.. |SI3 manual|  image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1471689.svg
+.. |TOP manual|  image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1471700.svg
 
 .. |NEMO strategy| replace:: multi-year development strategy
Index: /NEMO/branches/2019/fix_ticket2229/cfgs/AMM12/EXPREF/file_def_nemo-oce.xml
===================================================================
--- /NEMO/branches/2019/fix_ticket2229/cfgs/AMM12/EXPREF/file_def_nemo-oce.xml	(revision 10688)
+++ /NEMO/branches/2019/fix_ticket2229/cfgs/AMM12/EXPREF/file_def_nemo-oce.xml	(revision 10689)
@@ -67,6 +67,5 @@
 
      <file id="file15" name_suffix="_25hourm_grid_W" description="ocean W grid variables, 25h meaned" enabled=".TRUE." >
-     <field field_ref="vomecrtz25h"          name="vomerctz"  operation="instant" enabled=".TRUE."/>
-     <field field_ref="woce"                 name="vovecrtz"  operation="instant" enabled=".TRUE."/>
+     <field field_ref="vovecrtz25h"          name="vovecrtz"  operation="instant" enabled=".TRUE."/>
      <field field_ref="avt25h"               name="votkeavt"  operation="instant" enabled=".TRUE."/>
      <field field_ref="avm25h"               name="votkeavm"  operation="instant" enabled=".TRUE."/>
Index: /NEMO/branches/2019/fix_ticket2229/cfgs/SHARED/field_def_nemo-oce.xml
===================================================================
--- /NEMO/branches/2019/fix_ticket2229/cfgs/SHARED/field_def_nemo-oce.xml	(revision 10688)
+++ /NEMO/branches/2019/fix_ticket2229/cfgs/SHARED/field_def_nemo-oce.xml	(revision 10689)
@@ -975,5 +975,5 @@
 
     <field_group id="25h_grid_W" grid_ref="grid_W_3D" operation="instant">
-      <field id="vomecrtz25h"         name="k current 25h mean"                 unit="m/s"      />
+      <field id="vovecrtz25h"         name="k current 25h mean"                 unit="m/s"      />
       <field id="avt25h"              name="vertical diffusivity25h mean"       unit="m2/s" />
       <field id="avm25h"              name="vertical viscosity 25h mean"        unit="m2/s" />
Index: /NEMO/branches/2019/fix_ticket2229/src/OCE/BDY/bdydta.F90
===================================================================
--- /NEMO/branches/2019/fix_ticket2229/src/OCE/BDY/bdydta.F90	(revision 10688)
+++ /NEMO/branches/2019/fix_ticket2229/src/OCE/BDY/bdydta.F90	(revision 10689)
@@ -371,4 +371,17 @@
       END DO  ! jbdy
 
+      IF ( ln_apr_obc ) THEN
+         DO jbdy = 1, nb_bdy
+            IF (cn_tra(jbdy) /= 'runoff')THEN
+               igrd = 1                      ! meridional velocity
+               DO ib = 1, idx_bdy(jbdy)%nblenrim(igrd)
+                  ii   = idx_bdy(jbdy)%nbi(ib,igrd)
+                  ij   = idx_bdy(jbdy)%nbj(ib,igrd)
+                  dta_bdy(jbdy)%ssh(ib) = dta_bdy(jbdy)%ssh(ib) + ssh_ib(ii,ij)
+               END DO
+            ENDIF
+         END DO
+      ENDIF
+
       IF ( ln_tide ) THEN
          IF (ln_dynspg_ts) THEN      ! Fill temporary arrays with slow-varying bdy data                           
@@ -389,16 +402,4 @@
       ENDIF
 
-      IF ( ln_apr_obc ) THEN
-         DO jbdy = 1, nb_bdy
-            IF (cn_tra(jbdy) /= 'runoff')THEN
-               igrd = 1                      ! meridional velocity
-               DO ib = 1, idx_bdy(jbdy)%nblenrim(igrd)
-                  ii   = idx_bdy(jbdy)%nbi(ib,igrd)
-                  ij   = idx_bdy(jbdy)%nbj(ib,igrd)
-                  dta_bdy(jbdy)%ssh(ib) = dta_bdy(jbdy)%ssh(ib) + ssh_ib(ii,ij)
-               END DO
-            ENDIF
-         END DO
-      ENDIF
       !
       IF( ln_timing )   CALL timing_stop('bdy_dta')
Index: /NEMO/branches/2019/fix_ticket2229/src/OCE/BDY/bdyini.F90
===================================================================
--- /NEMO/branches/2019/fix_ticket2229/src/OCE/BDY/bdyini.F90	(revision 10688)
+++ /NEMO/branches/2019/fix_ticket2229/src/OCE/BDY/bdyini.F90	(revision 10689)
@@ -941,5 +941,5 @@
                      ii = idx_bdy(ib_bdy)%nbi(icount,igrd)
                      ij = idx_bdy(ib_bdy)%nbj(icount,igrd)
-                     if((com_east .ne. 1) .and. (ii == nlci) .and. (nbondi .le. 0)) then
+                     if((com_east .ne. 1) .and. (ii == (nlci-1)) .and. (nbondi .le. 0)) then
                         com_east = 1
                      elseif((com_west .ne. 1) .and. (ii == 2) .and. (nbondi .ge. 0) .and. (nbondi .ne. 2)) then
@@ -948,5 +948,5 @@
                      if((com_south .ne. 1) .and. (ij == 2) .and. (nbondj .ge. 0) .and. (nbondj .ne. 2)) then
                         com_south = 1
-                     elseif((com_north .ne. 1) .and. (ij == nlcj) .and. (nbondj .le. 0)) then
+                     elseif((com_north .ne. 1) .and. (ij == (nlcj-1)) .and. (nbondj .le. 0)) then
                         com_north = 1
                      endif 
@@ -960,5 +960,5 @@
                        & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
                        ii = nbidta(ib,igrd,ib_bdy)- iw_b(1)+2
-                       if((com_west_b .ne. 1) .and. (ii == (nlcit(nowe+1)))) then
+                       if((com_west_b .ne. 1) .and. (ii == (nlcit(nowe+1)-1))) then
                           ij = nbjdta(ib,igrd,ib_bdy) - is_b(1)+2
                           if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
@@ -989,5 +989,5 @@
                        & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
                        ii = nbidta(ib,igrd,ib_bdy)- iw_b(1)+2
-                       if((com_west_b .ne. 1) .and. (ii == (nlcit(nowe+1)))) then
+                       if((com_west_b .ne. 1) .and. (ii == (nlcit(nowe+1)-1))) then
                           ij = nbjdta(ib,igrd,ib_bdy) - is_b(1)+2
                           if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
@@ -1030,5 +1030,5 @@
                        & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
                        ij = nbjdta(ib,igrd,ib_bdy)- is_b(3)+2
-                       if((com_south_b .ne. 1) .and. (ij == (nlcjt(noso+1)))) then
+                       if((com_south_b .ne. 1) .and. (ij == (nlcjt(noso+1)-1))) then
                           com_south_b = 1
                        endif 
@@ -1052,5 +1052,5 @@
                        & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
                        ij = nbjdta(ib,igrd,ib_bdy)- is_b(3)+2
-                       if((com_south_b .ne. 1) .and. (ij == (nlcjt(noso+1)))) then
+                       if((com_south_b .ne. 1) .and. (ij == (nlcjt(noso+1)-1))) then
                           com_south_b = 1
                        endif 
Index: /NEMO/branches/2019/fix_ticket2229/src/OCE/DIA/dia25h.F90
===================================================================
--- /NEMO/branches/2019/fix_ticket2229/src/OCE/DIA/dia25h.F90	(revision 10688)
+++ /NEMO/branches/2019/fix_ticket2229/src/OCE/DIA/dia25h.F90	(revision 10689)
@@ -100,5 +100,4 @@
       un_25h  (:,:,:) = ub  (:,:,:)
       vn_25h  (:,:,:) = vb  (:,:,:)
-      wn_25h  (:,:,:) = wn  (:,:,:)
       avt_25h (:,:,:) = avt (:,:,:)
       avm_25h (:,:,:) = avm (:,:,:)
@@ -148,4 +147,9 @@
       ! local variable for debugging
       ll_print = ll_print .AND. lwp
+
+      ! wn_25h could not be initialised in dia_25h_init, so we do it here instead
+      IF( kt == nn_it000 ) THEN
+         wn_25h(:,:,:) = wn(:,:,:)
+      ENDIF
 
       ! Sum of 25 hourly instantaneous values to give a 25h mean from 24hours every day
@@ -223,5 +227,5 @@
          CALL iom_put("vomecrty25h", zw3d  )   ! j-current
          zw3d(:,:,:) = wn_25h(:,:,:)*wmask(:,:,:) + zmdi*(1.0-tmask(:,:,:))
-         CALL iom_put("vomecrtz25h", zw3d )   ! k-current
+         CALL iom_put("vovecrtz25h", zw3d )   ! k-current
          ! Write vertical physics
          zw3d(:,:,:) = avt_25h(:,:,:)*wmask(:,:,:) + zmdi*(1.0-tmask(:,:,:))
Index: /NEMO/branches/2019/fix_ticket2229/src/OCE/LBC/mpp_bdy_generic.h90
===================================================================
--- /NEMO/branches/2019/fix_ticket2229/src/OCE/LBC/mpp_bdy_generic.h90	(revision 10688)
+++ /NEMO/branches/2019/fix_ticket2229/src/OCE/LBC/mpp_bdy_generic.h90	(revision 10689)
@@ -140,16 +140,28 @@
          CASE ( -1 )
             CALL mppsend( 2, zt3we(1,1,1,1,1,1), imigr, noea, ml_req1 )
-            CALL mpprecv( 1, zt3ew(1,1,1,1,1,2), imigr, noea )
-            IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
          CASE ( 0 )
             CALL mppsend( 1, zt3ew(1,1,1,1,1,1), imigr, nowe, ml_req1 )
             CALL mppsend( 2, zt3we(1,1,1,1,1,1), imigr, noea, ml_req2 )
+         CASE ( 1 )
+            CALL mppsend( 1, zt3ew(1,1,1,1,1,1), imigr, nowe, ml_req1 )
+         END SELECT
+         !
+         SELECT CASE ( nbondi_bdy_b(IBD_IN(jf)) )
+         CASE ( -1 )
+            CALL mpprecv( 1, zt3ew(1,1,1,1,1,2), imigr, noea )
+         CASE ( 0 )
             CALL mpprecv( 1, zt3ew(1,1,1,1,1,2), imigr, noea )
             CALL mpprecv( 2, zt3we(1,1,1,1,1,2), imigr, nowe )
+         CASE ( 1 )
+            CALL mpprecv( 2, zt3we(1,1,1,1,1,2), imigr, nowe )
+         END SELECT
+         !
+         SELECT CASE ( nbondi_bdy(IBD_IN(jf)) )
+         CASE ( -1 )
+            IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+         CASE ( 0 )
             IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
             IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err)
          CASE ( 1 )
-            CALL mppsend( 1, zt3ew(1,1,1,1,1,1), imigr, nowe, ml_req1 )
-            CALL mpprecv( 2, zt3we(1,1,1,1,1,2), imigr, nowe )
             IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
          END SELECT
@@ -230,16 +242,28 @@
          CASE ( -1 )
             CALL mppsend( 4, zt3sn(1,1,1,1,1,1), imigr, nono, ml_req1 )
-            CALL mpprecv( 3, zt3ns(1,1,1,1,1,2), imigr, nono )
-            IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
          CASE ( 0 )
             CALL mppsend( 3, zt3ns(1,1,1,1,1,1), imigr, noso, ml_req1 )
             CALL mppsend( 4, zt3sn(1,1,1,1,1,1), imigr, nono, ml_req2 )
+         CASE ( 1 )
+            CALL mppsend( 3, zt3ns(1,1,1,1,1,1), imigr, noso, ml_req1 )
+         END SELECT
+         ! 
+         SELECT CASE ( nbondj_bdy_b(IBD_IN(jf)) )
+         CASE ( -1 )
+            CALL mpprecv( 3, zt3ns(1,1,1,1,1,2), imigr, nono )
+         CASE ( 0 )
             CALL mpprecv( 3, zt3ns(1,1,1,1,1,2), imigr, nono )
             CALL mpprecv( 4, zt3sn(1,1,1,1,1,2), imigr, noso )
+         CASE ( 1 )
+            CALL mpprecv( 4, zt3sn(1,1,1,1,1,2), imigr, noso )
+         END SELECT
+         ! 
+         SELECT CASE ( nbondj_bdy(IBD_IN(jf)) )
+         CASE ( -1 )
+            IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+         CASE ( 0 )
             IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
             IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err)
          CASE ( 1 )
-            CALL mppsend( 3, zt3ns(1,1,1,1,1,1), imigr, noso, ml_req1 )
-            CALL mpprecv( 4, zt3sn(1,1,1,1,1,2), imigr, noso )
             IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
          END SELECT
Index: /NEMO/branches/2019/fix_ticket2229/src/OCE/LBC/mpp_loc_generic.h90
===================================================================
--- /NEMO/branches/2019/fix_ticket2229/src/OCE/LBC/mpp_loc_generic.h90	(revision 10688)
+++ /NEMO/branches/2019/fix_ticket2229/src/OCE/LBC/mpp_loc_generic.h90	(revision 10689)
@@ -17,8 +17,10 @@
 #      define MPI_OPERATION mpi_maxloc
 #      define LOC_OPERATION MAXLOC
+#      define ERRVAL -HUGE
 #   endif
 #   if defined OPERATION_MINLOC
 #      define MPI_OPERATION mpi_minloc
 #      define LOC_OPERATION MINLOC
+#      define ERRVAL HUGE
 #   endif
 
@@ -42,26 +44,33 @@
       !
       idim = SIZE(kindex)
-      ALLOCATE ( ilocs(idim) )
       !
-      ilocs = LOC_OPERATION( ARRAY_IN(:,:,:) , mask= MASK_IN(:,:,:) == 1._wp )
-      zmin  = ARRAY_IN(ilocs(1),ilocs(2),ilocs(3))
-      !
-      kindex(1) = ilocs(1) + nimpp - 1
+      IF ( ALL(MASK_IN(:,:,:) /= 1._wp) ) THEN
+         ! special case for land processors
+         zmin = ERRVAL(zmin)
+         index0 = 0
+      ELSE
+         ALLOCATE ( ilocs(idim) )
+         !
+         ilocs = LOC_OPERATION( ARRAY_IN(:,:,:) , mask= MASK_IN(:,:,:) == 1._wp )
+         zmin  = ARRAY_IN(ilocs(1),ilocs(2),ilocs(3))
+         !
+         kindex(1) = mig( ilocs(1) )
 #  if defined DIM_2d || defined DIM_3d    /* avoid warning when kindex has 1 element */
-      kindex(2) = ilocs(2) + njmpp - 1
+         kindex(2) = mjg( ilocs(2) )
 #  endif
 #  if defined DIM_3d                      /* avoid warning when kindex has 2 elements */
-      kindex(3) = ilocs(3)
+         kindex(3) = ilocs(3)
 #  endif
-      ! 
-      DEALLOCATE (ilocs)
-      !
-      index0 = kindex(1)-1   ! 1d index starting at 0
+         ! 
+         DEALLOCATE (ilocs)
+         !
+         index0 = kindex(1)-1   ! 1d index starting at 0
 #  if defined DIM_2d || defined DIM_3d   /* avoid warning when kindex has 1 element */
-      index0 = index0 + jpiglo * (kindex(2)-1)
+         index0 = index0 + jpiglo * (kindex(2)-1)
 #  endif
 #  if defined DIM_3d                     /* avoid warning when kindex has 2 elements */
-      index0 = index0 + jpiglo * jpjglo * (kindex(3)-1)
+         index0 = index0 + jpiglo * jpjglo * (kindex(3)-1)
 #  endif
+      END IF
       zain(1,:) = zmin
       zain(2,:) = REAL(index0, wp)
