Index: branches/2017/dev_r7881_HPC09_ZDF/NEMOGCM/NEMO/NST_SRC/agrif_user.F90
===================================================================
--- branches/2017/dev_r7881_HPC09_ZDF/NEMOGCM/NEMO/NST_SRC/agrif_user.F90	(revision 7899)
+++ branches/2017/dev_r7881_HPC09_ZDF/NEMOGCM/NEMO/NST_SRC/agrif_user.F90	(revision 7953)
@@ -1,5 +1,5 @@
 #if defined key_agrif
 !!----------------------------------------------------------------------
-!! NEMO/NST 3.7 , NEMO Consortium (2016)
+!! NEMO/NST 4.0 , NEMO Consortium (2017)
 !! $Id$
 !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
@@ -107,4 +107,5 @@
    !!
    IMPLICIT NONE
+   !
    !!----------------------------------------------------------------------
    !
@@ -125,5 +126,5 @@
    USE par_oce       
    USE oce
-   !!
+   !
    IMPLICIT NONE
    !!----------------------------------------------------------------------
@@ -136,20 +137,20 @@
    ! 2. Type of interpolation
    !-------------------------
-   CALL Agrif_Set_bcinterp(e1u_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
-   CALL Agrif_Set_bcinterp(e2v_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
+   CALL Agrif_Set_bcinterp( e1u_id, interp1=Agrif_linear, interp2=AGRIF_ppm    )
+   CALL Agrif_Set_bcinterp( e2v_id, interp1=AGRIF_ppm   , interp2=Agrif_linear )
 
    ! 3. Location of interpolation
    !-----------------------------
-   CALL Agrif_Set_bc(e1u_id,(/0,0/))
-   CALL Agrif_Set_bc(e2v_id,(/0,0/))
+   CALL Agrif_Set_bc( e1u_id, (/0,0/) )
+   CALL Agrif_Set_bc( e2v_id, (/0,0/) )
 
    ! 5. Update type
    !--------------- 
-   CALL Agrif_Set_Updatetype(e1u_id,update1 = Agrif_Update_Copy, update2=Agrif_Update_Average)
-   CALL Agrif_Set_Updatetype(e2v_id,update1 = Agrif_Update_Average, update2=Agrif_Update_Copy)
+   CALL Agrif_Set_Updatetype( e1u_id, update1=Agrif_Update_Copy   , update2=Agrif_Update_Average )
+   CALL Agrif_Set_Updatetype( e2v_id, update1=Agrif_Update_Average, update2=Agrif_Update_Copy    )
 
 ! High order updates
-!   CALL Agrif_Set_Updatetype(e1u_id,update1 = Agrif_Update_Average,            update2=Agrif_Update_Full_Weighting)
-!   CALL Agrif_Set_Updatetype(e2v_id,update1 = Agrif_Update_Full_Weighting,     update2=Agrif_Update_Average)
+!   CALL Agrif_Set_Updatetype( e1u_id, update1=Agrif_Update_Average       , update2=Agrif_Update_Full_Weighting )
+!   CALL Agrif_Set_Updatetype( e2v_id, update1=Agrif_Update_Full_Weighting, update2=Agrif_Update_Average        )
     !
 END SUBROUTINE agrif_declare_var_dom
@@ -165,5 +166,7 @@
    USE oce 
    USE dom_oce
+   USE zdf_oce
    USE nemogcm
+   !
    USE lib_mpp
    USE in_out_manager
@@ -171,5 +174,5 @@
    USE agrif_opa_interp
    USE agrif_opa_sponge
-   !!
+   !
    IMPLICIT NONE
    !
@@ -184,5 +187,5 @@
    ! 2. First interpolations of potentially non zero fields
    !-------------------------------------------------------
-   Agrif_SpecialValue=0.
+   Agrif_SpecialValue    = 0._wp
    Agrif_UseSpecialValue = .TRUE.
    CALL Agrif_Bc_variable(tsn_id,calledweight=1.,procname=interptsn)
@@ -319,7 +322,5 @@
    ENDIF
    !
-# if defined key_zdftke
-   CALL Agrif_Update_tke(0)
-# endif
+   IF( ln_zdftke )   CALL Agrif_Update_tke( 0 )
    !
    Agrif_UseSpecialValueInUpdate = .FALSE.
@@ -337,7 +338,8 @@
    !!----------------------------------------------------------------------
    USE agrif_util
-   USE par_oce       !   ONLY : jpts
+   USE agrif_oce
+   USE par_oce       ! ocean parameters
+   USE zdf_oce       ! vertical physics
    USE oce
-   USE agrif_oce
    !!
    IMPLICIT NONE
@@ -371,9 +373,9 @@
    CALL agrif_declare_variable((/2,2/),(/3,3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),sshn_id)
 
-# if defined key_zdftke
-   CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/), en_id)
-   CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avt_id)
-   CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avm_id)
-# endif
+   IF( ln_zdftke ) THEN
+      CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/), en_id)
+      CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avt_id)
+      CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avm_id)
+   ENDIF
 
    ! 2. Type of interpolation
@@ -400,8 +402,5 @@
    CALL Agrif_Set_bcinterp(vmsk_id,interp=AGRIF_constant)
 
-# if defined key_zdftke
-   CALL Agrif_Set_bcinterp(avm_id ,interp=AGRIF_linear)
-# endif
-
+   IF( ln_zdftke )   CALL Agrif_Set_bcinterp( avm_id, interp=AGRIF_linear )
 
    ! 3. Location of interpolation
@@ -418,9 +417,9 @@
    CALL Agrif_Set_bc(vn_sponge_id ,(/-nn_sponge_len*Agrif_irhox()-1,0/))
 
-   CALL Agrif_Set_bc(sshn_id,(/0,0/))
-   CALL Agrif_Set_bc(unb_id ,(/0,0/))
-   CALL Agrif_Set_bc(vnb_id ,(/0,0/))
-   CALL Agrif_Set_bc(ub2b_interp_id,(/0,0/))
-   CALL Agrif_Set_bc(vb2b_interp_id,(/0,0/))
+   CALL Agrif_Set_bc( sshn_id       , (/0,0/) )
+   CALL Agrif_Set_bc( unb_id        , (/0,0/) )
+   CALL Agrif_Set_bc( vnb_id        , (/0,0/) )
+   CALL Agrif_Set_bc( ub2b_interp_id, (/0,0/) )
+   CALL Agrif_Set_bc( vb2b_interp_id, (/0,0/) )
 
    CALL Agrif_Set_bc(e3t_id,(/-2*Agrif_irhox()-1,0/))   ! if west and rhox=3: column 2 to 9
@@ -428,7 +427,5 @@
    CALL Agrif_Set_bc(vmsk_id,(/0,0/))
 
-# if defined key_zdftke
-   CALL Agrif_Set_bc(avm_id ,(/0,1/))
-# endif
+   IF( ln_zdftke )   CALL Agrif_Set_bc( avm_id, (/0,1/) )
 
    ! 5. Update type
@@ -446,9 +443,9 @@
    CALL Agrif_Set_Updatetype(vb2b_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy)
 
-# if defined key_zdftke
-   CALL Agrif_Set_Updatetype( en_id, update = AGRIF_Update_Average)
-   CALL Agrif_Set_Updatetype(avt_id, update = AGRIF_Update_Average)
-   CALL Agrif_Set_Updatetype(avm_id, update = AGRIF_Update_Average)
-# endif
+   IF( ln_zdftke) THEN
+      CALL Agrif_Set_Updatetype( en_id, update = AGRIF_Update_Average)
+      CALL Agrif_Set_Updatetype(avt_id, update = AGRIF_Update_Average)
+      CALL Agrif_Set_Updatetype(avm_id, update = AGRIF_Update_Average)
+   ENDIF
 
 ! High order updates
