Index: NEMO/branches/2021/dev_r14383_PISCES_NEWDEV_PISCO/src/OCE/LBC/mpp_nfd_generic.h90
===================================================================
--- NEMO/branches/2021/dev_r14383_PISCES_NEWDEV_PISCO/src/OCE/LBC/mpp_nfd_generic.h90	(revision 14384)
+++ NEMO/branches/2021/dev_r14383_PISCES_NEWDEV_PISCO/src/OCE/LBC/mpp_nfd_generic.h90	(revision 14448)
@@ -1,87 +1,11 @@
-#if defined MULTI
-#   define NAT_IN(k)                cd_nat(k)   
-#   define SGN_IN(k)                psgn(k)
-#   define F_SIZE(ptab)             kfld
-#   define LBC_ARG                  (jf)
-#   if defined DIM_2d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_2D_sp)     , INTENT(inout) ::   ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_2D_dp)     , INTENT(inout) ::   ptab(f)
-#      endif
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt2d(i,j)
-#      define K_SIZE(ptab)             1
-#      define L_SIZE(ptab)             1
-#   endif
-#   if defined DIM_3d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_3D_sp)     , INTENT(inout) ::   ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_3D_dp)     , INTENT(inout) ::   ptab(f)
-#      endif
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt3d(i,j,k)
-#      define K_SIZE(ptab)             SIZE(ptab(1)%pt3d,3)
-#      define L_SIZE(ptab)             1
-#   endif
-#   if defined DIM_4d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_4D_sp)     , INTENT(inout) ::   ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_4D_dp)     , INTENT(inout) ::   ptab(f)
-#      endif
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt4d(i,j,k,l)
-#      define K_SIZE(ptab)             SIZE(ptab(1)%pt4d,3)
-#      define L_SIZE(ptab)             SIZE(ptab(1)%pt4d,4)
-#   endif
-#else
-!                          !==  IN: ptab is an array  ==!
-#   if defined SINGLE_PRECISION
-#      define ARRAY_TYPE(i,j,k,l,f)    REAL(sp)         , INTENT(inout) ::   ARRAY_IN(i,j,k,l,f)
-#   else
-#      define ARRAY_TYPE(i,j,k,l,f)    REAL(dp)         , INTENT(inout) ::   ARRAY_IN(i,j,k,l,f)
-#   endif
-#   define NAT_IN(k)                cd_nat
-#   define SGN_IN(k)                psgn
-#   define F_SIZE(ptab)             1
-#   define LBC_ARG
-#   if defined DIM_2d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j)
-#      define K_SIZE(ptab)          1
-#      define L_SIZE(ptab)          1
-#   endif
-#   if defined DIM_3d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k)
-#      define K_SIZE(ptab)          SIZE(ptab,3)
-#      define L_SIZE(ptab)          1
-#   endif
-#   if defined DIM_4d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k,l)
-#      define K_SIZE(ptab)          SIZE(ptab,3)
-#      define L_SIZE(ptab)          SIZE(ptab,4)
-#   endif
-#endif
 
-# if defined SINGLE_PRECISION
-#    define PRECISION sp
-#    define SENDROUTINE mppsend_sp
-#    define RECVROUTINE mpprecv_sp
-#    define MPI_TYPE MPI_REAL
-#    define HUGEVAL(x)   HUGE(x/**/_sp)
-# else
-#    define PRECISION dp
-#    define SENDROUTINE mppsend_dp
-#    define RECVROUTINE mpprecv_dp
-#    define MPI_TYPE MPI_DOUBLE_PRECISION
-#    define HUGEVAL(x)   HUGE(x/**/_dp)
-# endif
-
-   SUBROUTINE ROUTINE_NFD( ptab, cd_nat, psgn, kfillmode, pfillval, kfld )
-      !!----------------------------------------------------------------------
-      ARRAY_TYPE(:,:,:,:,:)   ! 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
-      INTEGER          , INTENT(in   ) ::   kfillmode   ! filling method for halo over land 
-      REAL(wp)         , INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
-      INTEGER, OPTIONAL, INTENT(in   ) ::   kfld        ! number of pt3d arrays
+   SUBROUTINE mpp_nfd_/**/PRECISION( ptab, cd_nat, psgn, kfillmode, pfillval, khls, kfld )
+      TYPE(PTR_4d_/**/PRECISION),  DIMENSION(:), INTENT(inout) ::   ptab        ! pointer of arrays on which apply the b.c.
+      CHARACTER(len=1), DIMENSION(:), INTENT(in   ) ::   cd_nat      ! nature of array grid-points
+      REAL(PRECISION),  DIMENSION(:), INTENT(in   ) ::   psgn        ! sign used across the north fold boundary
+      INTEGER                       , INTENT(in   ) ::   kfillmode   ! filling method for halo over land 
+      REAL(PRECISION)               , INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
+      INTEGER                       , INTENT(in   ) ::   khls        ! halo size, default = nn_hls
+      INTEGER                       , INTENT(in   ) ::   kfld        ! number of pt3d arrays
       !
       LOGICAL  ::   ll_add_line
@@ -95,5 +19,4 @@
       INTEGER, DIMENSION (jpmaxngh)       ::   ml_req_nf   ! for mpi_isend when avoiding mpi_allgather
       INTEGER                             ::   ml_err      ! for mpi_isend when avoiding mpi_allgather
-      INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat     ! for mpi_isend when avoiding mpi_allgather
       !                                                    ! Workspace for message transfers avoiding mpi_allgather
       INTEGER                             ::   ipj_b       ! sum of lines for all multi fields
@@ -103,13 +26,14 @@
       INTEGER , DIMENSION(:)          , ALLOCATABLE ::   ipj_s ! number of sent lines
       REAL(PRECISION), DIMENSION(:,:,:,:)    , ALLOCATABLE ::   ztabb, ztabr, ztabw  ! buffer, receive and work arrays
-      REAL(PRECISION), DIMENSION(:,:,:,:,:)  , ALLOCATABLE ::   ztabglo, znorthloc
+      REAL(PRECISION), DIMENSION(:,:,:,:,:)  , ALLOCATABLE ::   znorthloc
       REAL(PRECISION), DIMENSION(:,:,:,:,:,:), ALLOCATABLE ::   znorthglo
+      TYPE(PTR_4D_/**/PRECISION), DIMENSION(:), ALLOCATABLE ::   ztabglo        ! array or pointer of arrays on which apply the b.c.
       !!----------------------------------------------------------------------
       !
-      ipk = K_SIZE(ptab)   ! 3rd dimension
-      ipl = L_SIZE(ptab)   ! 4th    -
-      ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
+      ipk = SIZE(ptab(1)%pt4d,3)
+      ipl = SIZE(ptab(1)%pt4d,4)
+      ipf = kfld
       !
-      IF( l_north_nogather ) THEN      !==  no allgather exchanges  ==!
+      IF( ln_nnogather ) THEN      !==  no allgather exchanges  ==!
 
          !   ---   define number of exchanged lines   ---
@@ -118,12 +42,12 @@
          !
          ! However, some other points are duplicated in the north pole folding:
-         !  - jperio=[34], grid=T : half of the last line (jpiglo/2+2:jpiglo-nn_hls)
-         !  - jperio=[34], grid=U : half of the last line (jpiglo/2+1:jpiglo-nn_hls)
-         !  - jperio=[34], grid=V : all the last line nn_hls+1 and (nn_hls+2:jpiglo-nn_hls)
-         !  - jperio=[34], grid=F : all the last line (nn_hls+1:jpiglo-nn_hls)
-         !  - jperio=[56], grid=T : 2 points of the last line (jpiglo/2+1 and jpglo-nn_hls)
-         !  - jperio=[56], grid=U : no points are duplicated
-         !  - jperio=[56], grid=V : half of the last line (jpiglo/2+1:jpiglo-nn_hls)
-         !  - jperio=[56], grid=F : half of the last line (jpiglo/2+1:jpiglo-nn_hls-1)
+         !  - c_NFtype='T', grid=T : half of the last line (jpiglo/2+2:jpiglo-nn_hls)
+         !  - c_NFtype='T', grid=U : half of the last line (jpiglo/2+1:jpiglo-nn_hls)
+         !  - c_NFtype='T', grid=V : all the last line nn_hls+1 and (nn_hls+2:jpiglo-nn_hls)
+         !  - c_NFtype='T', grid=F : all the last line (nn_hls+1:jpiglo-nn_hls)
+         !  - c_NFtype='F', grid=T : 2 points of the last line (jpiglo/2+1 and jpglo-nn_hls)
+         !  - c_NFtype='F', grid=U : no points are duplicated
+         !  - c_NFtype='F', grid=V : half of the last line (jpiglo/2+1:jpiglo-nn_hls)
+         !  - c_NFtype='F', grid=F : half of the last line (jpiglo/2+1:jpiglo-nn_hls-1)
          ! The order of the calculations may differ for these duplicated points (as, for example jj+1 becomes jj-1)
          ! This explain why these duplicated points may have different values even if they are at the exact same location.
@@ -141,8 +65,8 @@
          IF( ll_add_line ) THEN
             DO jf = 1, ipf                      ! Loop over the number of arrays to be processed
-               ipj_s(jf) = nn_hls + COUNT( (/ npolj == 3 .OR. npolj == 4 .OR. NAT_IN(jf) == 'V' .OR. NAT_IN(jf) == 'F' /) ) 
+               ipj_s(jf) = khls + COUNT( (/ c_NFtype == 'T' .OR. cd_nat(jf) == 'V' .OR. cd_nat(jf) == 'F' /) ) 
             END DO
          ELSE
-            ipj_s(:) = nn_hls
+            ipj_s(:) = khls
          ENDIF
          
@@ -155,21 +79,21 @@
          DO jf = 1, ipf                      ! Loop over the number of arrays to be processed
             !
-            SELECT CASE ( npolj )
-            CASE ( 3, 4 )                       ! *  North fold  T-point pivot
-               SELECT CASE ( NAT_IN(jf) )
+            IF( c_NFtype == 'T' ) THEN          ! *  North fold  T-point pivot
+               SELECT CASE ( cd_nat(jf) )
                CASE ( 'T', 'W', 'U' )   ;   i012 = 1   ! T-, U-, W-point
                CASE ( 'V', 'F'      )   ;   i012 = 2   ! V-, F-point
                END SELECT
-            CASE ( 5, 6 )                       ! *  North fold  F-point pivot
-               SELECT CASE ( NAT_IN(jf) )
+            ENDIF
+            IF( c_NFtype == 'F' ) THEN          ! *  North fold  F-point pivot
+               SELECT CASE ( cd_nat(jf) )
                CASE ( 'T', 'W', 'U' )   ;   i012 = 0   ! T-, U-, W-point
                CASE ( 'V', 'F'      )   ;   i012 = 1   ! V-, F-point
                END SELECT
-            END SELECT
+            ENDIF
                !
             DO jj = 1, ipj_s(jf)
                ij1 = ij1 + 1
                jj_b(jj,jf) = ij1
-               jj_s(jj,jf) = jpj - 2*nn_hls + jj - i012
+               jj_s(jj,jf) = jpj - 2*khls + jj - i012
             END DO
             !
@@ -184,8 +108,8 @@
                ij2 = jj_s(jj,jf)
                DO ji = 1, jpi
-                  ztabb(ji,ij1,jk,jl) = ARRAY_IN(ji,ij2,jk,jl,jf)
+                  ztabb(ji,ij1,jk,jl) = ptab(jf)%pt4d(ji,ij2,jk,jl)
                END DO
                DO ji = jpi+1, jpimax
-                  ztabb(ji,ij1,jk,jl) = HUGEVAL(0.)   ! avoid sending uninitialized values (make sure we don't use it)
+                  ztabb(ji,ij1,jk,jl) = HUGE(0._/**/PRECISION)   ! avoid sending uninitialized values (make sure we don't use it)
                END DO
             END DO
@@ -199,5 +123,7 @@
             iproc = nfproc(isendto(jr))
             IF( iproc /= narea-1 .AND. iproc /= -1 ) THEN
-               CALL SENDROUTINE( 5, ztabb, ibuffsize, iproc, ml_req_nf(jr) )
+#if ! defined key_mpi_off
+               CALL MPI_ISEND( ztabb, ibuffsize, MPI_TYPE, iproc, 5, mpi_comm_oce, ml_req_nf(jr), ierr )
+#endif
             ENDIF
          END DO
@@ -212,9 +138,9 @@
             ipi   = nfjpi (ipni)
             !
-            IF( ipni ==   1  ) THEN   ;   iis0 =   1            ! domain  left side: as e-w comm already done -> from 1st column
-            ELSE                      ;   iis0 =   1 + nn_hls   ! default: -> from inner domain 
-            ENDIF
-            IF( ipni == jpni ) THEN   ;   iie0 = ipi            ! domain right side: as e-w comm already done -> until last column
-            ELSE                      ;   iie0 = ipi - nn_hls   ! default: -> until inner domain 
+            IF( ipni ==   1  ) THEN   ;   iis0 =   1          ! domain  left side: as e-w comm already done -> from 1st column
+            ELSE                      ;   iis0 =   1 + khls   ! default: -> from inner domain 
+            ENDIF
+            IF( ipni == jpni ) THEN   ;   iie0 = ipi          ! domain right side: as e-w comm already done -> until last column
+            ELSE                      ;   iie0 = ipi - khls   ! default: -> until inner domain 
             ENDIF
             impp = nfimpp(ipni) - nfimpp(isendto(1))
@@ -230,5 +156,5 @@
                         ij2 = jj_s(jj,jf)
                         DO ji = iis0, iie0
-                           ztabr(impp+ji,ij1,jk,jl) = ARRAY_IN(Nis0,ij2,jk,jl,jf)   ! chose to take the 1st iner domain point
+                           ztabr(impp+ji,ij1,jk,jl) = ptab(jf)%pt4d(Nis0,ij2,jk,jl)   ! chose to take the 1st iner domain point
                         END DO
                      END DO
@@ -251,5 +177,5 @@
                      ij2 = jj_s(jj,jf)
                      DO ji = iis0, iie0
-                        ztabr(impp+ji,ij1,jk,jl) = ARRAY_IN(ji,ij2,jk,jl,jf)
+                        ztabr(impp+ji,ij1,jk,jl) = ptab(jf)%pt4d(ji,ij2,jk,jl)
                      END DO
                   END DO
@@ -258,5 +184,7 @@
             ELSE                               ! get data from a neighbour trough communication
                !  
-               CALL RECVROUTINE(5, ztabw, ibuffsize, iproc)
+#if ! defined key_mpi_off
+               CALL MPI_RECV( ztabw, ibuffsize, MPI_TYPE, iproc, 5, mpi_comm_oce, MPI_STATUS_IGNORE, ierr )
+#endif
                DO jl = 1, ipl   ;   DO jk = 1, ipk
                   DO jj = 1, ipj_b
@@ -278,5 +206,5 @@
             ij1 = jj_b(       1 ,jf)
             ij2 = jj_b(ipj_s(jf),jf)
-            CALL lbc_nfd_nogather( ARRAY_IN(:,:,:,:,jf), ztabr(:,ij1:ij2,:,:), cd_nat LBC_ARG, psgn LBC_ARG )
+            CALL lbc_nfd_nogather( ptab(jf)%pt4d(:,:,:,:), ztabr(:,ij1:ij2,:,:), cd_nat(jf), psgn(jf), khls )
          END DO
          !
@@ -286,5 +214,5 @@
             iproc = nfproc(isendto(jr))
             IF( iproc /= narea-1 .AND. iproc /= -1 ) THEN
-               CALL mpi_wait( ml_req_nf(jr), ml_stat, ml_err )   ! put the wait at the very end just before the deallocate
+               CALL mpi_wait( ml_req_nf(jr), MPI_STATUS_IGNORE, ml_err )   ! put the wait at the very end just before the deallocate
             ENDIF
          END DO
@@ -294,9 +222,9 @@
          !
          ! how many lines do we exchange at max? -> ipj    (no further optimizations in this case...)
-         ipj =      nn_hls + 2
+         ipj =      khls + 2
          ! how many lines do we     need at max? -> ipj2   (no further optimizations in this case...)
-         ipj2 = 2 * nn_hls + 2
-         !
-         i0max = jpimax - 2 * nn_hls
+         ipj2 = 2 * khls + 2
+         !
+         i0max = jpimax - 2 * khls
          ibuffsize = i0max * ipj * ipk * ipl * ipf
          ALLOCATE( znorthloc(i0max,ipj,ipk,ipl,ipf), znorthglo(i0max,ipj,ipk,ipl,ipf,ndim_rank_north) )
@@ -307,8 +235,8 @@
                DO ji = 1, Ni_0
                   ii2 = Nis0 - 1 + ji                       ! inner domain: Nis0 to Nie0
-                  znorthloc(ji,jj,jk,jl,jf) = ARRAY_IN(ii2,ij2,jk,jl,jf)
+                  znorthloc(ji,jj,jk,jl,jf) = ptab(jf)%pt4d(ii2,ij2,jk,jl)
                END DO
                DO ji = Ni_0+1, i0max
-                  znorthloc(ji,jj,jk,jl,jf) = HUGEVAL(0.)   ! avoid sending uninitialized values (make sure we don't use it)
+                  znorthloc(ji,jj,jk,jl,jf) = HUGE(0._/**/PRECISION)   ! avoid sending uninitialized values (make sure we don't use it)
                END DO
             END DO
@@ -323,12 +251,15 @@
          IF( ln_timing ) CALL tic_tac(.FALSE.)
          DEALLOCATE( znorthloc )
-         ALLOCATE( ztabglo(jpiglo,ipj2,ipk,ipl,ipf) )
-         !
-         ! need to fill only the first ipj lines of ztabglo as lbc_nfd don't use the last nn_hls lines
+         ALLOCATE( ztabglo(ipf) )
+         DO jf = 1, ipf
+            ALLOCATE( ztabglo(jf)%pt4d(jpiglo,ipj2,ipk,ipl) )
+         END DO
+         !
+         ! need to fill only the first ipj lines of ztabglo as lbc_nfd don't use the last khls lines
          ijnr = 0
          DO jr = 1, jpni                                                        ! recover the global north array
             iproc = nfproc(jr)
             impp  = nfimpp(jr)
-            ipi   = nfjpi( jr) - 2 * nn_hls                       ! corresponds to Ni_0 but for subdomain iproc
+            ipi   = nfjpi( jr) - 2 * khls                       ! corresponds to Ni_0 but for subdomain iproc
             IF( iproc == -1 ) THEN   ! No neighbour (land proc that was suppressed)
               !
@@ -340,6 +271,6 @@
                         ij2 = jpj - ipj2 + jj                    ! the first ipj lines of the last ipj2 lines
                         DO ji = 1, ipi
-                           ii1 = impp + nn_hls + ji - 1          ! corresponds to mig(nn_hls + ji) but for subdomain iproc
-                           ztabglo(ii1,jj,jk,jl,jf) = ARRAY_IN(Nis0,ij2,jk,jl,jf)   ! chose to take the 1st iner domain point
+                           ii1 = impp + khls + ji - 1            ! corresponds to mig(khls + ji) but for subdomain iproc
+                           ztabglo(jf)%pt4d(ii1,jj,jk,jl) = ptab(jf)%pt4d(Nis0,ij2,jk,jl) ! chose to take the 1st inner domain point
                         END DO
                      END DO
@@ -349,6 +280,6 @@
                      DO jj = 1, ipj
                         DO ji = 1, ipi
-                           ii1 = impp + nn_hls + ji - 1          ! corresponds to mig(nn_hls + ji) but for subdomain iproc
-                           ztabglo(ii1,jj,jk,jl,jf) = pfillval
+                           ii1 = impp + khls + ji - 1            ! corresponds to mig(khls + ji) but for subdomain iproc
+                           ztabglo(jf)%pt4d(ii1,jj,jk,jl) = pfillval
                         END DO
                      END DO
@@ -361,6 +292,6 @@
                   DO jj = 1, ipj
                      DO ji = 1, ipi
-                        ii1 = impp + nn_hls + ji - 1             ! corresponds to mig(nn_hls + ji) but for subdomain iproc
-                        ztabglo(ii1,jj,jk,jl,jf) = znorthglo(ji,jj,jk,jl,jf,ijnr)
+                        ii1 = impp + khls + ji - 1               ! corresponds to mig(khls + ji) but for subdomain iproc
+                        ztabglo(jf)%pt4d(ii1,jj,jk,jl) = znorthglo(ji,jj,jk,jl,jf,ijnr)
                      END DO
                   END DO
@@ -372,10 +303,10 @@
          !
          DO jf = 1, ipf
-            CALL lbc_nfd( ztabglo(:,:,:,:,jf), cd_nat LBC_ARG, psgn LBC_ARG )   ! North fold boundary condition
+            CALL lbc_nfd( ztabglo(jf:jf), cd_nat(jf:jf), psgn(jf:jf), khls, 1 )   ! North fold boundary condition
             DO jl = 1, ipl   ;   DO jk = 1, ipk                  ! e-w periodicity
-               DO jj = 1, nn_hls + 1
-                  ij1 = ipj2 - (nn_hls + 1) + jj                 ! need only the last nn_hls + 1 lines until ipj2
-                  ztabglo(              1:nn_hls,ij1,jk,jl,jf) = ztabglo(jpiglo-2*nn_hls+1:jpiglo-nn_hls,ij1,jk,jl,jf)
-                  ztabglo(jpiglo-nn_hls+1:jpiglo,ij1,jk,jl,jf) = ztabglo(         nn_hls+1:     2*nn_hls,ij1,jk,jl,jf)
+               DO jj = 1, khls + 1
+                  ij1 = ipj2 - (khls + 1) + jj                   ! need only the last khls + 1 lines until ipj2
+                  ztabglo(jf)%pt4d(            1:  khls,ij1,jk,jl) = ztabglo(jf)%pt4d(jpiglo-2*khls+1:jpiglo-khls,ij1,jk,jl)
+                  ztabglo(jf)%pt4d(jpiglo-khls+1:jpiglo,ij1,jk,jl) = ztabglo(jf)%pt4d(         khls+1:     2*khls,ij1,jk,jl)
                END DO
             END DO   ;   END DO
@@ -383,31 +314,21 @@
          !
          DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk               ! Scatter back to ARRAY_IN
-            DO jj = 1, nn_hls + 1
-               ij1 = jpj  - (nn_hls + 1) + jj   ! last nn_hls + 1 lines until jpj
-               ij2 = ipj2 - (nn_hls + 1) + jj   ! last nn_hls + 1 lines until ipj2
+            DO jj = 1, khls + 1
+               ij1 = jpj  - (khls + 1) + jj   ! last khls + 1 lines until jpj
+               ij2 = ipj2 - (khls + 1) + jj   ! last khls + 1 lines until ipj2
                DO ji= 1, jpi
                   ii2 = mig(ji)
-                  ARRAY_IN(ji,ij1,jk,jl,jf) = ztabglo(ii2,ij2,jk,jl,jf)
+                  ptab(jf)%pt4d(ji,ij1,jk,jl) = ztabglo(jf)%pt4d(ii2,ij2,jk,jl)
                END DO
             END DO
          END DO   ;   END DO   ;   END DO
          !
+         DO jf = 1, ipf
+            DEALLOCATE( ztabglo(jf)%pt4d )
+         END DO
          DEALLOCATE( ztabglo )
          !
       ENDIF   ! l_north_nogather
       !
-   END SUBROUTINE ROUTINE_NFD
+   END SUBROUTINE mpp_nfd_/**/PRECISION
 
-#undef PRECISION
-#undef MPI_TYPE
-#undef SENDROUTINE
-#undef RECVROUTINE
-#undef ARRAY_TYPE
-#undef NAT_IN
-#undef SGN_IN
-#undef ARRAY_IN
-#undef K_SIZE
-#undef L_SIZE
-#undef F_SIZE
-#undef LBC_ARG
-#undef HUGEVAL
