Index: NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_nfd_ext_generic.h90
===================================================================
--- NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_nfd_ext_generic.h90	(revision 14197)
+++ NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_nfd_ext_generic.h90	(revision 14644)
@@ -1,35 +1,14 @@
-!                          !==  IN: ptab is an array  ==!
-#define NAT_IN(k)                cd_nat
-#define SGN_IN(k)                psgn
-#define F_SIZE(ptab)             1
-#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 SINGLE_PRECISION
-#   define ARRAY_TYPE(i,j,k,l,f)    REAL(sp),INTENT(inout)::ARRAY_IN(i,j,k,l,f)
-#   define PRECISION sp
-#else
-#   define ARRAY_TYPE(i,j,k,l,f)    REAL(dp),INTENT(inout)::ARRAY_IN(i,j,k,l,f)
-#   define PRECISION dp
-#endif
 
-   SUBROUTINE ROUTINE_NFD( ptab, cd_nat, psgn, kextj )
+   SUBROUTINE lbc_nfd_ext_/**/PRECISION( ptab, cd_nat, psgn, kextj )
       !!----------------------------------------------------------------------
-      INTEGER          , INTENT(in   ) ::   kextj       ! extra halo width at north fold, declared before its use in ARRAY_TYPE
-      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
+      REAL(PRECISION), DIMENSION(:,1-kextj:),INTENT(inout) ::   ptab
+      CHARACTER(len=1), INTENT(in   ) ::   cd_nat      ! nature of array grid-points
+      REAL(PRECISION),  INTENT(in   ) ::   psgn        ! sign used across the north fold boundary
+      INTEGER,          INTENT(in   ) ::   kextj       ! extra halo width at north fold
       !
-      INTEGER  ::    ji,  jj,  jk,  jl, jh,  jf   ! dummy loop indices
-      INTEGER  ::   ipi, ipj, ipk, ipl,     ipf   ! dimension of the input array
+      INTEGER  ::    ji,  jj,  jh   ! dummy loop indices
+      INTEGER  ::   ipj
       INTEGER  ::   ijt, iju, ipjm1
       !!----------------------------------------------------------------------
-      !
-      ipk = K_SIZE(ptab)   ! 3rd dimension
-      ipl = L_SIZE(ptab)   ! 4th    -
-      ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
-      !
       !
       SELECT CASE ( jpni )
@@ -39,126 +18,103 @@
       !
       ipjm1 = ipj-1
+      !
+      IF( c_NFtype == 'T' ) THEN            ! *  North fold  T-point pivot
+         !
+         SELECT CASE ( cd_nat  )
+         CASE ( 'T' , 'W' )                         ! T-, W-point
+            DO jh = 0, kextj
+               DO ji = 2, jpiglo
+                  ijt = jpiglo-ji+2
+                  ptab(ji,ipj+jh) = psgn * ptab(ijt,ipj-2-jh)
+               END DO
+               ptab(1,ipj+jh) = psgn * ptab(3,ipj-2-jh)
+            END DO
+            DO ji = jpiglo/2+1, jpiglo
+               ijt = jpiglo-ji+2
+               ptab(ji,ipjm1) = psgn * ptab(ijt,ipjm1)
+            END DO
+         CASE ( 'U' )                               ! U-point
+            DO jh = 0, kextj
+               DO ji = 2, jpiglo-1
+                  iju = jpiglo-ji+1
+                  ptab(ji,ipj+jh) = psgn * ptab(iju,ipj-2-jh)
+               END DO
+               ptab(   1  ,ipj+jh) = psgn * ptab(    2   ,ipj-2-jh)
+               ptab(jpiglo,ipj+jh) = psgn * ptab(jpiglo-1,ipj-2-jh) 
+            END DO
+            DO ji = jpiglo/2, jpiglo-1
+               iju = jpiglo-ji+1
+               ptab(ji,ipjm1) = psgn * ptab(iju,ipjm1)
+            END DO
+         CASE ( 'V' )                               ! V-point
+            DO jh = 0, kextj
+               DO ji = 2, jpiglo
+                  ijt = jpiglo-ji+2
+                  ptab(ji,ipj-1+jh) = psgn * ptab(ijt,ipj-2-jh)
+                  ptab(ji,ipj+jh  ) = psgn * ptab(ijt,ipj-3-jh)
+               END DO
+               ptab(1,ipj+jh) = psgn * ptab(3,ipj-3-jh) 
+            END DO
+         CASE ( 'F' )                               ! F-point
+            DO jh = 0, kextj
+               DO ji = 1, jpiglo-1
+                  iju = jpiglo-ji+1
+                  ptab(ji,ipj-1+jh) = psgn * ptab(iju,ipj-2-jh)
+                  ptab(ji,ipj+jh  ) = psgn * ptab(iju,ipj-3-jh)
+               END DO
+            END DO
+            DO jh = 0, kextj
+               ptab(   1  ,ipj+jh) = psgn * ptab(    2   ,ipj-3-jh)
+               ptab(jpiglo,ipj+jh) = psgn * ptab(jpiglo-1,ipj-3-jh)
+            END DO
+         END SELECT
+         !
+      ENDIF   ! c_NFtype == 'T'
+      !
+      IF( c_NFtype == 'F' ) THEN            ! *  North fold  F-point pivot
+         !
+         SELECT CASE ( cd_nat  )
+         CASE ( 'T' , 'W' )                         ! T-, W-point
+            DO jh = 0, kextj
+               DO ji = 1, jpiglo
+                  ijt = jpiglo-ji+1
+                  ptab(ji,ipj+jh) = psgn * ptab(ijt,ipj-1-jh)
+               END DO
+            END DO
+         CASE ( 'U' )                               ! U-point
+            DO jh = 0, kextj
+               DO ji = 1, jpiglo-1
+                  iju = jpiglo-ji
+                  ptab(ji,ipj+jh) = psgn * ptab(iju,ipj-1-jh)
+               END DO
+               ptab(jpiglo,ipj+jh) = psgn * ptab(jpiglo-2,ipj-1-jh)
+            END DO
+         CASE ( 'V' )                               ! V-point
+            DO jh = 0, kextj
+               DO ji = 1, jpiglo
+                  ijt = jpiglo-ji+1
+                  ptab(ji,ipj+jh) = psgn * ptab(ijt,ipj-2-jh)
+               END DO
+            END DO
+            DO ji = jpiglo/2+1, jpiglo
+               ijt = jpiglo-ji+1
+               ptab(ji,ipjm1) = psgn * ptab(ijt,ipjm1)
+            END DO
+         CASE ( 'F' )                               ! F-point
+            DO jh = 0, kextj
+               DO ji = 1, jpiglo-1
+                  iju = jpiglo-ji
+                  ptab(ji,ipj+jh  ) = psgn * ptab(iju,ipj-2-jh)
+               END DO
+               ptab(jpiglo,ipj+jh) = psgn * ptab(jpiglo-2,ipj-2-jh)
+            END DO
+            DO ji = jpiglo/2+1, jpiglo-1
+               iju = jpiglo-ji
+               ptab(ji,ipjm1) = psgn * ptab(iju,ipjm1)
+            END DO
+         END SELECT
+         !
+      ENDIF   ! c_NFtype == 'F'
+      !
+   END SUBROUTINE lbc_nfd_ext_/**/PRECISION
 
-      !
-      DO jf = 1, ipf                      ! Loop on the number of arrays to be treated
-         !
-         SELECT CASE ( npolj )
-         !
-         CASE ( 3 , 4 )                        ! *  North fold  T-point pivot
-            !
-            SELECT CASE ( NAT_IN(jf)  )
-            CASE ( 'T' , 'W' )                         ! T-, W-point
-               DO jh = 0, kextj
-                  DO ji = 2, jpiglo
-                     ijt = jpiglo-ji+2
-                     ARRAY_IN(ji,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipj-2-jh,:,:,jf)
-                  END DO
-                  ARRAY_IN(1,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(3,ipj-2-jh,:,:,jf)
-               END DO
-               DO ji = jpiglo/2+1, jpiglo
-                  ijt = jpiglo-ji+2
-                  ARRAY_IN(ji,ipjm1,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipjm1,:,:,jf)
-               END DO
-            CASE ( 'U' )                               ! U-point
-               DO jh = 0, kextj
-                  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)
-                  END DO
-                 ARRAY_IN(   1  ,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(    2   ,ipj-2-jh,:,:,jf)
-                 ARRAY_IN(jpiglo,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(jpiglo-1,ipj-2-jh,:,:,jf) 
-               END DO
-               DO ji = jpiglo/2, jpiglo-1
-                  iju = jpiglo-ji+1
-                  ARRAY_IN(ji,ipjm1,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipjm1,:,:,jf)
-               END DO
-            CASE ( 'V' )                               ! V-point
-               DO jh = 0, kextj
-                  DO ji = 2, jpiglo
-                     ijt = jpiglo-ji+2
-                     ARRAY_IN(ji,ipj-1+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipj-2-jh,:,:,jf)
-                     ARRAY_IN(ji,ipj+jh  ,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipj-3-jh,:,:,jf)
-                  END DO
-                  ARRAY_IN(1,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(3,ipj-3-jh,:,:,jf) 
-               END DO
-            CASE ( 'F' )                               ! F-point
-               DO jh = 0, kextj
-                  DO ji = 1, jpiglo-1
-                     iju = jpiglo-ji+1
-                     ARRAY_IN(ji,ipj-1+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-2-jh,:,:,jf)
-                     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)
-               END DO
-            END SELECT
-            !
-         CASE ( 5 , 6 )                        ! *  North fold  F-point pivot
-            !
-            SELECT CASE ( NAT_IN(jf)  )
-            CASE ( 'T' , 'W' )                         ! T-, W-point
-               DO jh = 0, kextj
-                  DO ji = 1, jpiglo
-                     ijt = jpiglo-ji+1
-                     ARRAY_IN(ji,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipj-1-jh,:,:,jf)
-                  END DO
-               END DO
-            CASE ( 'U' )                               ! U-point
-               DO jh = 0, kextj
-                  DO ji = 1, jpiglo-1
-                     iju = jpiglo-ji
-                     ARRAY_IN(ji,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-1-jh,:,:,jf)
-                  END DO
-                  ARRAY_IN(jpiglo,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(jpiglo-2,ipj-1-jh,:,:,jf)
-               END DO
-            CASE ( 'V' )                               ! V-point
-               DO jh = 0, kextj
-                  DO ji = 1, jpiglo
-                     ijt = jpiglo-ji+1
-                     ARRAY_IN(ji,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipj-2-jh,:,:,jf)
-                  END DO
-               END DO
-               DO ji = jpiglo/2+1, jpiglo
-                  ijt = jpiglo-ji+1
-                  ARRAY_IN(ji,ipjm1,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipjm1,:,:,jf)
-               END DO
-            CASE ( 'F' )                               ! F-point
-               DO jh = 0, kextj
-                  DO ji = 1, jpiglo-1
-                     iju = jpiglo-ji
-                     ARRAY_IN(ji,ipj+jh  ,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-2-jh,:,:,jf)
-                  END DO
-                  ARRAY_IN(jpiglo,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(jpiglo-2,ipj-2-jh,:,:,jf)
-               END DO
-               DO ji = jpiglo/2+1, jpiglo-1
-                  iju = jpiglo-ji
-                  ARRAY_IN(ji,ipjm1,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipjm1,:,:,jf)
-               END DO
-            END SELECT
-            !
-         CASE DEFAULT                           ! *  closed : the code probably never go through
-            !
-            SELECT CASE ( NAT_IN(jf) )
-            CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
-               ARRAY_IN(:,  1:1-kextj  ,:,:,jf) = 0._wp
-               ARRAY_IN(:,ipj:ipj+kextj,:,:,jf) = 0._wp
-            CASE ( 'F' )                               ! F-point
-               ARRAY_IN(:,ipj:ipj+kextj,:,:,jf) = 0._wp
-            END SELECT
-            !
-         END SELECT     !  npolj
-         !
-      END DO
-      !
-   END SUBROUTINE ROUTINE_NFD
-
-#undef PRECISION
-#undef ARRAY_TYPE
-#undef ARRAY_IN
-#undef NAT_IN
-#undef SGN_IN
-#undef K_SIZE
-#undef L_SIZE
-#undef F_SIZE
