Index: branches/2017/dev_r7881_HPC09_ZDF/NEMOGCM/NEMO/NST_SRC/agrif_opa_interp.F90
===================================================================
--- branches/2017/dev_r7881_HPC09_ZDF/NEMOGCM/NEMO/NST_SRC/agrif_opa_interp.F90	(revision 7899)
+++ branches/2017/dev_r7881_HPC09_ZDF/NEMOGCM/NEMO/NST_SRC/agrif_opa_interp.F90	(revision 7953)
@@ -21,5 +21,5 @@
    USE oce
    USE dom_oce      
-   USE zdf_oce
+   USE zdf_oce          ! vertical physics
    USE agrif_oce
    USE phycst
@@ -34,11 +34,9 @@
 
    PUBLIC   Agrif_tra, Agrif_dyn, Agrif_ssh, Agrif_dyn_ts, Agrif_ssh_ts, Agrif_dta_ts
-   PUBLIC   interpun, interpvn
-   PUBLIC   interptsn,  interpsshn
-   PUBLIC   interpunb, interpvnb, interpub2b, interpvb2b
+   PUBLIC   interpun , interpvn
+   PUBLIC   interptsn, interpsshn
+   PUBLIC   interpunb, interpvnb , interpub2b, interpvb2b
    PUBLIC   interpe3t, interpumsk, interpvmsk
-# if defined key_zdftke
    PUBLIC   Agrif_tke, interpavm
-# endif
 
    INTEGER ::   bdy_tinterp = 0
@@ -46,5 +44,5 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/NST 3.7 , NEMO Consortium (2015)
+   !! NEMO/NST 4.0 , NEMO Consortium (2017)
    !! $Id$
    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
@@ -385,5 +383,4 @@
       !!                  ***  ROUTINE Agrif_dyn_ts  ***
       !!----------------------------------------------------------------------  
-      !! 
       INTEGER, INTENT(in) ::   jn
       !!
@@ -444,5 +441,4 @@
       !!                  ***  ROUTINE Agrif_dta_ts  ***
       !!----------------------------------------------------------------------  
-      !! 
       INTEGER, INTENT(in) ::   kt
       !!
@@ -504,5 +500,4 @@
       !!----------------------------------------------------------------------  
       INTEGER, INTENT(in) ::   kt
-      !!
       !!----------------------------------------------------------------------  
       !
@@ -541,5 +536,5 @@
       !!----------------------------------------------------------------------  
       !
-      IF((nbondi == -1).OR.(nbondi == 2)) THEN
+      IF( nbondi == -1 .OR. nbondi == 2 ) THEN
          DO jj = 1, jpj
             ssha_e(2,jj) = hbdy_w(jj)
@@ -547,5 +542,5 @@
       ENDIF
       !
-      IF((nbondi == 1).OR.(nbondi == 2)) THEN
+      IF( nbondi == 1 .OR. nbondi == 2 ) THEN
          DO jj = 1, jpj
             ssha_e(nlci-1,jj) = hbdy_e(jj)
@@ -553,5 +548,5 @@
       ENDIF
       !
-      IF((nbondj == -1).OR.(nbondj == 2)) THEN
+      IF( nbondj == -1 .OR.(nbondj == 2 ) THEN
          DO ji = 1, jpi
             ssha_e(ji,2) = hbdy_s(ji)
@@ -559,5 +554,5 @@
       ENDIF
       !
-      IF((nbondj == 1).OR.(nbondj == 2)) THEN
+      IF( nbondj == 1 .OR. nbondj == 2 ) THEN
          DO ji = 1, jpi
             ssha_e(ji,nlcj-1) = hbdy_n(ji)
@@ -567,5 +562,4 @@
    END SUBROUTINE Agrif_ssh_ts
 
-# if defined key_zdftke
 
    SUBROUTINE Agrif_tke
@@ -579,18 +573,17 @@
       IF( zalpha > 1. )   zalpha = 1.
       !
-      Agrif_SpecialValue    = 0.e0
+      Agrif_SpecialValue    = 0._wp
       Agrif_UseSpecialValue = .TRUE.
       !
-      CALL Agrif_Bc_variable(avm_id ,calledweight=zalpha, procname=interpavm)       
+      CALL Agrif_Bc_variable( avm_id , calledweight=zalpha, procname=interpavm )       
       !
       Agrif_UseSpecialValue = .FALSE.
       !
    END SUBROUTINE Agrif_tke
-   
-# endif
+
 
    SUBROUTINE interptsn( ptab, i1, i2, j1, j2, k1, k2, n1, n2, before, nb, ndir )
       !!----------------------------------------------------------------------
-      !!   *** ROUTINE interptsn ***
+      !!                  *** ROUTINE interptsn ***
       !!----------------------------------------------------------------------
       REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) ::   ptab
@@ -599,9 +592,9 @@
       INTEGER                                     , INTENT(in   ) ::   nb , ndir
       !
-      INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices
-      INTEGER  ::   imin, imax, jmin, jmax
-      REAL(wp) ::   zrhox , zalpha1, zalpha2, zalpha3
-      REAL(wp) ::   zalpha4, zalpha5, zalpha6, zalpha7
-      LOGICAL  ::   western_side, eastern_side,northern_side,southern_side
+      INTEGER ::   ji, jj, jk, jn   ! dummy loop indices
+      INTEGER ::   imin, imax, jmin, jmax
+      REAL(wp)::   zrhox , zalpha1, zalpha2, zalpha3
+      REAL(wp)::   zalpha4, zalpha5, zalpha6, zalpha7
+      LOGICAL ::   western_side, eastern_side,northern_side,southern_side
       !!----------------------------------------------------------------------
       !
@@ -770,5 +763,5 @@
    SUBROUTINE interpun( ptab, i1, i2, j1, j2, k1, k2, before )
       !!----------------------------------------------------------------------
-      !!   *** ROUTINE interpun ***
+      !!                         *** ROUTINE interpun ***
       !!----------------------------------------------------------------------
       INTEGER                               , INTENT(in   ) ::   i1, i2, j1, j2, k1, k2
@@ -776,6 +769,6 @@
       LOGICAL                               , INTENT(in   ) ::   before
       !
-      INTEGER  ::   ji, jj, jk
-      REAL(wp) ::   zrhoy	
+      INTEGER ::   ji, jj, jk
+      REAL(wp)::   zrhoy	
       !!----------------------------------------------------------------------
       !
@@ -798,5 +791,5 @@
    SUBROUTINE interpvn( ptab, i1, i2, j1, j2, k1, k2, before )
       !!----------------------------------------------------------------------
-      !!   *** ROUTINE interpvn ***
+      !!                      *** ROUTINE interpvn ***
       !!----------------------------------------------------------------------
       INTEGER                               , INTENT(in   ) ::   i1, i2, j1, j2, k1, k2
@@ -804,6 +797,6 @@
       LOGICAL                               , INTENT(in   ) ::   before
       !
-      INTEGER  ::   ji, jj, jk
-      REAL(wp) ::   zrhox	
+      INTEGER ::   ji, jj, jk
+      REAL(wp)::   zrhox	
       !!----------------------------------------------------------------------
       !      
@@ -831,7 +824,7 @@
       INTEGER                         , INTENT(in   ) ::   nb , ndir
       !
-      INTEGER  ::   ji, jj
-      REAL(wp) ::   zrhoy, zrhot, zt0, zt1, ztcoeff
-      LOGICAL  ::   western_side, eastern_side,northern_side,southern_side
+      INTEGER ::   ji, jj
+      REAL(wp)::   zrhoy, zrhot, zt0, zt1, ztcoeff
+      LOGICAL ::   western_side, eastern_side,northern_side,southern_side
       !!----------------------------------------------------------------------  
       !
@@ -901,7 +894,7 @@
       INTEGER                         , INTENT(in   ) ::   nb , ndir
       !
-      INTEGER  ::   ji,jj
-      REAL(wp) ::   zrhox, zrhot, zt0, zt1, ztcoeff   
-      LOGICAL  ::   western_side, eastern_side,northern_side,southern_side
+      INTEGER ::   ji,jj
+      REAL(wp)::   zrhox, zrhot, zt0, zt1, ztcoeff   
+      LOGICAL ::   western_side, eastern_side,northern_side,southern_side
       !!----------------------------------------------------------------------  
       ! 
@@ -919,9 +912,9 @@
          zt1 = REAL(Agrif_NbStepint()+1, wp) / zrhot      
          IF( bdy_tinterp == 1 ) THEN
-            ztcoeff = zrhot * (  zt1**2._wp * (       zt1 - 1._wp)        &
-               &               - zt0**2._wp * (       zt0 - 1._wp)        )
+            ztcoeff = zrhot * (  zt1**2._wp * ( zt1 - 1._wp)        &
+               &               - zt0**2._wp * ( zt0 - 1._wp)        )
          ELSEIF( bdy_tinterp == 2 ) THEN
-            ztcoeff = zrhot * (  zt1        * (       zt1 - 1._wp)**2._wp &
-               &               - zt0        * (       zt0 - 1._wp)**2._wp ) 
+            ztcoeff = zrhot * (  zt1        * ( zt1 - 1._wp)**2._wp &
+               &               - zt0        * ( zt0 - 1._wp)**2._wp ) 
          ELSE
             ztcoeff = 1
@@ -942,19 +935,8 @@
          !            
          IF( bdy_tinterp == 0 .OR. bdy_tinterp == 2) THEN
-            IF(western_side) THEN
-               vbdy_w(j1:j2) = vbdy_w(j1:j2) / (zrhox*e1v(i1,j1:j2))   &
-                     &                                  * vmask(i1,j1:j2,1)
-            ENDIF
-            IF(eastern_side) THEN
-               vbdy_e(j1:j2) = vbdy_e(j1:j2) / (zrhox*e1v(i1,j1:j2))   &
-                     &                                  * vmask(i1,j1:j2,1)
-            ENDIF
-            IF(southern_side) THEN
-               vbdy_s(i1:i2) = vbdy_s(i1:i2) / (zrhox*e1v(i1:i2,j1))   &
-                     &                                  * vmask(i1:i2,j1,1)
-            ENDIF
-            IF(northern_side) THEN
-               vbdy_n(i1:i2) = vbdy_n(i1:i2) / (zrhox*e1v(i1:i2,j1))   &
-                     &                                  * vmask(i1:i2,j1,1)
+            IF( western_side  )   vbdy_w(j1:j2) = vbdy_w(j1:j2) / (zrhox*e1v(i1,j1:j2)) * vmask(i1,j1:j2,1)
+            IF( eastern_side  )   vbdy_e(j1:j2) = vbdy_e(j1:j2) / (zrhox*e1v(i1,j1:j2)) * vmask(i1,j1:j2,1)
+            IF( southern_side )   vbdy_s(i1:i2) = vbdy_s(i1:i2) / (zrhox*e1v(i1:i2,j1)) * vmask(i1:i2,j1,1)
+            IF( northern_side )   vbdy_n(i1:i2) = vbdy_n(i1:i2) / (zrhox*e1v(i1:i2,j1)) * vmask(i1:i2,j1,1)
             ENDIF
          ENDIF
@@ -973,7 +955,7 @@
       INTEGER                         , INTENT(in   ) ::   nb , ndir
       !
-      INTEGER  ::   ji,jj
-      REAL(wp) ::   zrhot, zt0, zt1,zat
-      LOGICAL  ::   western_side, eastern_side,northern_side,southern_side
+      INTEGER ::   ji,jj
+      REAL(wp)::   zrhot, zt0, zt1,zat
+      LOGICAL ::   western_side, eastern_side,northern_side,southern_side
       !!----------------------------------------------------------------------  
       IF( before ) THEN
@@ -1030,8 +1012,8 @@
             &           - zt0**2._wp * (-2._wp*zt0 + 3._wp)    ) 
          !
-         IF(western_side )   vbdy_w(j1:j2) = zat * ptab(i1,j1:j2)  
-         IF(eastern_side )   vbdy_e(j1:j2) = zat * ptab(i1,j1:j2)  
-         IF(southern_side)   vbdy_s(i1:i2) = zat * ptab(i1:i2,j1) 
-         IF(northern_side)   vbdy_n(i1:i2) = zat * ptab(i1:i2,j1) 
+         IF( western_side  )   vbdy_w(j1:j2) = zat * ptab(i1,j1:j2)  
+         IF( eastern_side  )   vbdy_e(j1:j2) = zat * ptab(i1,j1:j2)  
+         IF( southern_side )   vbdy_s(i1:i2) = zat * ptab(i1:i2,j1) 
+         IF( northern_side )   vbdy_n(i1:i2) = zat * ptab(i1:i2,j1) 
       ENDIF
       !      
@@ -1048,7 +1030,7 @@
       INTEGER                              , INTENT(in   ) :: nb , ndir
       !
-      INTEGER :: ji, jj, jk
-      LOGICAL :: western_side, eastern_side, northern_side, southern_side
-      REAL(wp) :: ztmpmsk      
+      INTEGER ::   ji, jj, jk
+      LOGICAL ::   western_side, eastern_side, northern_side, southern_side
+      REAL(wp)::   ztmpmsk      
       !!----------------------------------------------------------------------  
       !    
@@ -1065,8 +1047,8 @@
                DO ji = i1, i2
                   ! Get velocity mask at boundary edge points:
-                  IF( western_side )   ztmpmsk = umask(ji    ,jj    ,1)
-                  IF( eastern_side )   ztmpmsk = umask(nlci-2,jj    ,1)
-                  IF( northern_side)   ztmpmsk = vmask(ji    ,nlcj-2,1)
-                  IF( southern_side)   ztmpmsk = vmask(ji    ,2     ,1)
+                  IF( western_side  )   ztmpmsk = umask(ji    ,jj    ,1)
+                  IF( eastern_side  )   ztmpmsk = umask(nlci-2,jj    ,1)
+                  IF( northern_side )   ztmpmsk = vmask(ji    ,nlcj-2,1)
+                  IF( southern_side )   ztmpmsk = vmask(ji    ,2     ,1)
                   !
                   IF( ABS( ptab(ji,jj,jk) - tmask(ji,jj,jk) * e3t_0(ji,jj,jk) )*ztmpmsk > 1.D-2) THEN
@@ -1141,5 +1123,5 @@
       REAL(wp),DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) ::   ptab
       LOGICAL                              , INTENT(in   ) ::   before
-      INTEGER                              , INTENT(in   ) :: nb , ndir
+      INTEGER                              , INTENT(in   ) ::   nb , ndir
       !
       INTEGER ::   ji, jj, jk
@@ -1175,5 +1157,4 @@
    END SUBROUTINE interpvmsk
 
-# if defined key_zdftke
 
    SUBROUTINE interpavm( ptab, i1, i2, j1, j2, k1, k2, before )
@@ -1186,13 +1167,9 @@
       !!----------------------------------------------------------------------  
       !      
-      IF( before ) THEN
-         ptab (i1:i2,j1:j2,k1:k2) = avm_k(i1:i2,j1:j2,k1:k2)
-      ELSE
-         avm_k(i1:i2,j1:j2,k1:k2) = ptab (i1:i2,j1:j2,k1:k2)
+      IF( before ) THEN   ;   ptab (i1:i2,j1:j2,k1:k2) = avm_k(i1:i2,j1:j2,k1:k2)
+      ELSE                ;   avm_k(i1:i2,j1:j2,k1:k2) = ptab (i1:i2,j1:j2,k1:k2)
       ENDIF
       !
    END SUBROUTINE interpavm
-
-# endif /* key_zdftke */
 
 #else
