Index: branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/OPA_SRC/LBC/lbcnfd.F90
===================================================================
--- branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/OPA_SRC/LBC/lbcnfd.F90	(revision 4810)
+++ branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/OPA_SRC/LBC/lbcnfd.F90	(revision 5034)
@@ -33,5 +33,5 @@
 
    INTEGER, PUBLIC,  PARAMETER :: jpmaxngh = 3
-   INTEGER, PUBLIC                                  ::   nsndto
+   INTEGER, PUBLIC                                  ::   nsndto, nfsloop, nfeloop
    INTEGER, PUBLIC,  DIMENSION (jpmaxngh)           ::   isendto ! processes to which communicate
 
@@ -412,5 +412,5 @@
             SELECT CASE ( cd_type )
             CASE ( 'T' , 'W' )                         ! T-, W-point
-               IF (narea .ne. (jpnij - jpni + 1)) THEN
+               IF (nimpp .ne. 1) THEN
                  startloop = 1
                ELSE
@@ -420,7 +420,10 @@
                DO jk = 1, jpk
                   DO ji = startloop, nlci
-                     ijt = jpiglo - ji - nimpp - nimppt(isendto(1)) + 4
+                     ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
                      pt3dl(ji,ijpj,jk) = psgn * pt3dr(ijt,ijpj-2,jk)
                   END DO
+                  IF(nimpp .eq. 1) THEN
+                     pt3dl(1,ijpj,jk) = psgn * pt3dl(3,ijpj-2,jk)
+                  ENDIF
                END DO
 
@@ -435,5 +438,5 @@
                  DO jk = 1, jpk
                     DO ji = startloop, nlci
-                       ijt = jpiglo - ji - nimpp - nimppt(isendto(1)) + 4
+                       ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
                        jia = ji + nimpp - 1
                        ijta = jpiglo - jia + 2
@@ -448,7 +451,6 @@
 
 
-
             CASE ( 'U' )                               ! U-point
-               IF (narea .ne. (jpnij)) THEN
+               IF ((nimpp + nlci - 1) .ne. jpiglo) THEN
                   endloop = nlci
                ELSE
@@ -457,10 +459,16 @@
                DO jk = 1, jpk
                   DO ji = 1, endloop
-                     iju = jpiglo - ji - nimpp - nimppt(isendto(1)) + 3
+                     iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
                      pt3dl(ji,ijpj,jk) = psgn * pt3dr(iju,ijpj-2,jk)
                   END DO
-               END DO
-
-               IF (narea .ne. (jpnij)) THEN
+                  IF(nimpp .eq. 1) THEN
+                     pt3dl(   1  ,ijpj,jk) = psgn * pt3dl(    2   ,ijpj-2,jk)
+                  ENDIF
+                  IF((nimpp + nlci - 1) .eq. jpiglo) THEN
+                     pt3dl(nlci,ijpj,jk) = psgn * pt3dl(nlci-1,ijpj-2,jk)
+                  ENDIF
+               END DO
+
+               IF ((nimpp + nlci - 1) .ne. jpiglo) THEN
                   endloop = nlci
                ELSE
@@ -477,5 +485,5 @@
                  DO jk = 1, jpk
                     DO ji = startloop, endloop
-                      iju = jpiglo - ji - nimpp - nimppt(isendto(1)) + 3
+                      iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
                       jia = ji + nimpp - 1
                       ijua = jpiglo - jia + 1
@@ -490,5 +498,5 @@
 
             CASE ( 'V' )                               ! V-point
-               IF (narea .ne. (jpnij - jpni + 1)) THEN
+               IF (nimpp .ne. 1) THEN
                   startloop = 1
                ELSE
@@ -497,11 +505,14 @@
                DO jk = 1, jpk
                   DO ji = startloop, nlci
-                     ijt = jpiglo - ji - nimpp - nimppt(isendto(1)) + 4
+                     ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
                      pt3dl(ji,ijpj-1,jk) = psgn * pt3dr(ijt,ijpj-2,jk)
                      pt3dl(ji,ijpj  ,jk) = psgn * pt3dr(ijt,ijpj-3,jk)
                   END DO
+                  IF(nimpp .eq. 1) THEN
+                     pt3dl(1,ijpj,jk) = psgn * pt3dl(3,ijpj-3,jk)
+                  ENDIF
                END DO
             CASE ( 'F' )                               ! F-point
-               IF (narea .ne. (jpnij)) THEN
+               IF ((nimpp + nlci - 1) .ne. jpiglo) THEN
                   endloop = nlci
                ELSE
@@ -510,8 +521,14 @@
                DO jk = 1, jpk
                   DO ji = 1, endloop
-                     iju = jpiglo - ji - nimpp - nimppt(isendto(1)) + 3
+                     iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
                      pt3dl(ji,ijpj-1,jk) = psgn * pt3dr(iju,ijpj-2,jk)
                      pt3dl(ji,ijpj  ,jk) = psgn * pt3dr(iju,ijpj-3,jk)
                   END DO
+                  IF(nimpp .eq. 1) THEN
+                     pt3dl(   1  ,ijpj,jk) = psgn * pt3dl(    2   ,ijpj-3,jk)
+                  ENDIF
+                  IF((nimpp + nlci - 1) .eq. jpiglo) THEN
+                     pt3dl(nlci,ijpj,jk) = psgn * pt3dl(nlci-1,ijpj-3,jk)
+                  ENDIF
                END DO
             END SELECT
@@ -524,5 +541,5 @@
                DO jk = 1, jpk
                   DO ji = 1, nlci
-                     ijt = jpiglo - ji - nimpp - nimppt(isendto(1)) + 3
+                     ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
                      pt3dl(ji,ijpj,jk) = psgn * pt3dr(ijt,ijpj-1,jk)
                   END DO
@@ -530,5 +547,5 @@
 
             CASE ( 'U' )                               ! U-point
-               IF (narea .ne. (jpnij)) THEN
+               IF ((nimpp + nlci - 1) .ne. jpiglo) THEN
                   endloop = nlci
                ELSE
@@ -537,7 +554,10 @@
                DO jk = 1, jpk
                   DO ji = 1, endloop
-                     iju = jpiglo - ji - nimpp - nimppt(isendto(1)) + 2
+                     iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 2
                      pt3dl(ji,ijpj,jk) = psgn * pt3dr(iju,ijpj-1,jk)
                   END DO
+                  IF((nimpp + nlci - 1) .eq. jpiglo) THEN
+                     pt3dl(nlci,ijpj,jk) = psgn * pt3dr(1,ijpj-1,jk)
+                  ENDIF
                END DO
 
@@ -545,5 +565,5 @@
                DO jk = 1, jpk
                   DO ji = 1, nlci
-                     ijt = jpiglo - ji- nimpp - nimppt(isendto(1)) + 3
+                     ijt = jpiglo - ji- nimpp - nfiimpp(isendto(1),jpnj) + 3
                      pt3dl(ji,ijpj,jk) = psgn * pt3dr(ijt,ijpj-2,jk)
                   END DO
@@ -560,5 +580,5 @@
                  DO jk = 1, jpk
                     DO ji = startloop, nlci
-                       ijt = jpiglo - ji - nimpp - nimppt(isendto(1)) + 3
+                       ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
                        pt3dl(ji,ijpjm1,jk) = psgn * pt3dr(ijt,ijpjm1,jk)
                     END DO
@@ -567,5 +587,5 @@
 
             CASE ( 'F' )                               ! F-point
-               IF (narea .ne. (jpnij)) THEN
+               IF ((nimpp + nlci - 1) .ne. jpiglo) THEN
                   endloop = nlci
                ELSE
@@ -574,10 +594,13 @@
                DO jk = 1, jpk
                   DO ji = 1, endloop
-                     iju = jpiglo - ji - nimpp - nimppt(isendto(1)) + 2
+                     iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 2
                      pt3dl(ji,ijpj ,jk) = psgn * pt3dr(iju,ijpj-2,jk)
                   END DO
-               END DO
-
-               IF (narea .ne. (jpnij)) THEN
+                  IF((nimpp + nlci - 1) .eq. jpiglo) THEN
+                     pt3dl(nlci,ijpj,jk) = psgn * pt3dr(1,ijpj-2,jk)
+                  ENDIF
+               END DO
+
+               IF ((nimpp + nlci - 1) .ne. jpiglo) THEN
                   endloop = nlci
                ELSE
@@ -594,5 +617,5 @@
                   DO jk = 1, jpk
                      DO ji = startloop, endloop
-                        iju = jpiglo - ji - nimpp - nimppt(isendto(1)) + 2
+                        iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 2
                         pt3dl(ji,ijpjm1,jk) = psgn * pt3dr(iju,ijpjm1,jk)
                      END DO
@@ -656,5 +679,5 @@
          !
          CASE ( 'T' , 'W' )                               ! T- , W-points
-            IF (narea .ne. (jpnij - jpni + 1)) THEN
+            IF (nimpp .ne. 1) THEN
               startloop = 1
             ELSE
@@ -662,7 +685,10 @@
             ENDIF
             DO ji = startloop, nlci
-              ijt=jpiglo - ji - nimpp - nimppt(isendto(1)) + 4
+              ijt=jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
               pt2dl(ji,ijpj) = psgn * pt2dr(ijt,ijpjm1-1)
             END DO
+            IF (nimpp .eq. 1) THEN
+              pt2dl(1,ijpj)   = psgn * pt2dl(3,ijpj-2)
+            ENDIF
 
             IF(nimpp .ge. (jpiglo/2+1)) THEN
@@ -674,5 +700,5 @@
             ENDIF
             DO ji = startloop, nlci
-               ijt=jpiglo - ji - nimpp - nimppt(isendto(1)) + 4
+               ijt=jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
                jia = ji + nimpp - 1
                ijta = jpiglo - jia + 2
@@ -685,5 +711,5 @@
 
          CASE ( 'U' )                                     ! U-point
-            IF (narea .ne. (jpnij)) THEN
+            IF ((nimpp + nlci - 1) .ne. jpiglo) THEN
                endloop = nlci
             ELSE
@@ -691,9 +717,17 @@
             ENDIF
             DO ji = 1, endloop
-               iju = jpiglo - ji - nimpp - nimppt(isendto(1)) + 3
+               iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
                pt2dl(ji,ijpj) = psgn * pt2dr(iju,ijpjm1-1)
             END DO
 
-            IF (narea .ne. (jpnij)) THEN
+            IF (nimpp .eq. 1) THEN
+              pt2dl(   1  ,ijpj  ) = psgn * pt2dl(    2   ,ijpj-2)
+              pt2dl(1     ,ijpj-1) = psgn * pt2dr(jpiglo - nfiimpp(isendto(1), jpnj) + 1, ijpj-1)
+            ENDIF
+            IF((nimpp + nlci - 1) .eq. jpiglo) THEN
+              pt2dl(nlci,ijpj  ) = psgn * pt2dl(nlci-1,ijpj-2)
+            ENDIF
+
+            IF ((nimpp + nlci - 1) .ne. jpiglo) THEN
                endloop = nlci
             ELSE
@@ -708,5 +742,5 @@
             ENDIF
             DO ji = startloop, endloop
-               iju = jpiglo - ji - nimpp - nimppt(isendto(1)) + 3
+               iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
                jia = ji + nimpp - 1
                ijua = jpiglo - jia + 1
@@ -719,5 +753,5 @@
 
          CASE ( 'V' )                                     ! V-point
-            IF (narea .ne. (jpnij - jpni + 1)) THEN
+            IF (nimpp .ne. 1) THEN
               startloop = 1
             ELSE
@@ -725,11 +759,14 @@
             ENDIF
             DO ji = startloop, nlci
-              ijt=jpiglo - ji - nimpp - nimppt(isendto(1)) + 4
+              ijt=jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
               pt2dl(ji,ijpjm1) = psgn * pt2dr(ijt,ijpjm1-1)
               pt2dl(ji,ijpj) = psgn * pt2dr(ijt,ijpjm1-2)
             END DO
+            IF (nimpp .eq. 1) THEN
+              pt2dl( 1 ,ijpj)   = psgn * pt2dl( 3 ,ijpj-3) 
+            ENDIF
 
          CASE ( 'F' )                                     ! F-point
-            IF (narea .ne. (jpnij)) THEN
+            IF ((nimpp + nlci - 1) .ne. jpiglo) THEN
                endloop = nlci
             ELSE
@@ -737,11 +774,19 @@
             ENDIF
             DO ji = 1, endloop
-               iju = jpiglo - ji - nimpp - nimppt(isendto(1)) + 3
+               iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
                pt2dl(ji,ijpjm1) = psgn * pt2dr(iju,ijpjm1-1)
                pt2dl(ji,ijpj) = psgn * pt2dr(iju,ijpjm1-2)
             END DO
+            IF (nimpp .eq. 1) THEN
+              pt2dl(   1  ,ijpj)   = psgn * pt2dl(    2   ,ijpj-3)
+              pt2dl(   1  ,ijpj-1) = psgn * pt2dl(    2   ,ijpj-2)
+            ENDIF
+            IF((nimpp + nlci - 1) .eq. jpiglo) THEN
+              pt2dl(nlci,ijpj)   = psgn * pt2dl(nlci-1,ijpj-3)
+              pt2dl(nlci,ijpj-1) = psgn * pt2dl(nlci-1,ijpj-2) 
+            ENDIF
 
          CASE ( 'I' )                                     ! ice U-V point (I-point)
-            IF (narea .ne. (jpnij - jpni + 1)) THEN
+            IF (nimpp .ne. 1) THEN
                startloop = 1
             ELSE
@@ -750,10 +795,10 @@
             ENDIF
             DO ji = startloop, nlci
-               iju = jpiglo - ji - nimpp - nimppt(isendto(1)) + 5
+               iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 5
                pt2dl(ji,ijpj) = psgn * pt2dr(iju,ijpjm1)
             END DO
 
          CASE ( 'J' )                                     ! first ice U-V point
-            IF (narea .ne. (jpnij - jpni + 1)) THEN
+            IF (nimpp .ne. 1) THEN
                startloop = 1
             ELSE
@@ -762,10 +807,10 @@
             ENDIF
             DO ji = startloop, nlci
-               iju = jpiglo - ji - nimpp - nimppt(isendto(1)) + 5
+               iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 5
                pt2dl(ji,ijpj) = psgn * pt2dr(iju,ijpjm1)
             END DO
 
          CASE ( 'K' )                                     ! second ice U-V point
-            IF (narea .ne. (jpnij - jpni + 1)) THEN
+            IF (nimpp .ne. 1) THEN
                startloop = 1
             ELSE
@@ -774,5 +819,5 @@
             ENDIF
             DO ji = startloop, nlci
-               iju = jpiglo - ji - nimpp - nimppt(isendto(1)) + 5
+               iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 5
                pt2dl(ji,ijpj) = psgn * pt2dr(iju,ijpjm1)
             END DO
@@ -785,10 +830,10 @@
          CASE ( 'T' , 'W' )                               ! T-, W-point
             DO ji = 1, nlci
-               ijt = jpiglo - ji - nimpp - nimppt(isendto(1)) + 3
+               ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
                pt2dl(ji,ijpj) = psgn * pt2dr(ijt,ijpjm1)
             END DO
 
          CASE ( 'U' )                                     ! U-point
-            IF (narea .ne. (jpnij)) THEN
+            IF ((nimpp + nlci - 1) .ne. jpiglo) THEN
                endloop = nlci
             ELSE
@@ -796,11 +841,14 @@
             ENDIF
             DO ji = 1, endloop
-               iju = jpiglo - ji - nimpp - nimppt(isendto(1)) + 2
+               iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 2
                pt2dl(ji,ijpj) = psgn * pt2dr(iju,ijpjm1)
             END DO
+            IF((nimpp + nlci - 1) .eq. jpiglo) THEN
+               pt2dl(nlci,ijpj) = psgn * pt2dr(1,ijpj-1)
+            ENDIF
 
          CASE ( 'V' )                                     ! V-point
             DO ji = 1, nlci
-               ijt = jpiglo - ji - nimpp - nimppt(isendto(1)) + 3
+               ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
                pt2dl(ji,ijpj) = psgn * pt2dr(ijt,ijpjm1-1)
             END DO
@@ -813,10 +861,10 @@
             ENDIF
             DO ji = startloop, nlci
-               ijt = jpiglo - ji - nimpp - nimppt(isendto(1)) + 3
+               ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
                pt2dl(ji,ijpjm1) = psgn * pt2dr(ijt,ijpjm1)
             END DO
 
          CASE ( 'F' )                               ! F-point
-            IF (narea .ne. (jpnij)) THEN
+            IF ((nimpp + nlci - 1) .ne. jpiglo) THEN
                endloop = nlci
             ELSE
@@ -824,9 +872,12 @@
             ENDIF
             DO ji = 1, endloop
-               iju = jpiglo - ji - nimpp - nimppt(isendto(1)) + 2
+               iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 2
                pt2dl(ji,ijpj) = psgn * pt2dr(iju,ijpjm1-1)
             END DO
-
-            IF (narea .ne. (jpnij)) THEN
+            IF((nimpp + nlci - 1) .eq. jpiglo) THEN
+                pt2dl(nlci,ijpj) = psgn * pt2dr(1,ijpj-2)
+            ENDIF
+
+            IF ((nimpp + nlci - 1) .ne. jpiglo) THEN
                endloop = nlci
             ELSE
@@ -842,15 +893,15 @@
 
             DO ji = startloop, endloop
-               iju = jpiglo - ji - nimpp - nimppt(isendto(1)) + 2
+               iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 2
                pt2dl(ji,ijpjm1) = psgn * pt2dr(iju,ijpjm1)
             END DO
 
          CASE ( 'I' )                                  ! ice U-V point (I-point)
-               IF (narea .ne. (jpnij - jpni + 1)) THEN
+               IF (nimpp .ne. 1) THEN
                   startloop = 1
                ELSE
                   startloop = 2
                ENDIF
-               IF (narea .ne. jpnij) THEN
+               IF ((nimpp + nlci - 1) .ne. jpiglo) THEN
                   endloop = nlci
                ELSE
@@ -858,15 +909,15 @@
                ENDIF
                DO ji = startloop , endloop
-                  ijt = jpiglo - ji - nimpp - nimppt(isendto(1)) + 4
+                  ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
                   pt2dl(ji,ijpj)= 0.5 * (pt2dr(ji,ijpjm1) + psgn * pt2dr(ijt,ijpjm1))
                END DO
 
          CASE ( 'J' )                                  ! first ice U-V point
-               IF (narea .ne. (jpnij - jpni + 1)) THEN
+               IF (nimpp .ne. 1) THEN
                   startloop = 1
                ELSE
                   startloop = 2
                ENDIF
-               IF (narea .ne. jpnij) THEN
+               IF ((nimpp + nlci - 1) .ne. jpiglo) THEN
                   endloop = nlci
                ELSE
@@ -874,15 +925,15 @@
                ENDIF
                DO ji = startloop , endloop
-                  ijt = jpiglo - ji - nimpp - nimppt(isendto(1)) + 4
+                  ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
                   pt2dl(ji,ijpj) = pt2dr(ji,ijpjm1)
                END DO
 
          CASE ( 'K' )                                  ! second ice U-V point
-               IF (narea .ne. (jpnij - jpni + 1)) THEN
+               IF (nimpp .ne. 1) THEN
                   startloop = 1
                ELSE
                   startloop = 2
                ENDIF
-               IF (narea .ne. jpnij) THEN
+               IF ((nimpp + nlci - 1) .ne. jpiglo) THEN
                   endloop = nlci
                ELSE
@@ -890,5 +941,5 @@
                ENDIF
                DO ji = startloop, endloop
-                  ijt = jpiglo - ji - nimpp - nimppt(isendto(1)) + 4
+                  ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
                   pt2dl(ji,ijpj) = pt2dr(ijt,ijpjm1)
                END DO
