Index: branches/2017/dev_r7881_HPC09_ZDF/NEMOGCM/NEMO/NST_SRC/agrif_opa_sponge.F90
===================================================================
--- branches/2017/dev_r7881_HPC09_ZDF/NEMOGCM/NEMO/NST_SRC/agrif_opa_sponge.F90	(revision 7899)
+++ branches/2017/dev_r7881_HPC09_ZDF/NEMOGCM/NEMO/NST_SRC/agrif_opa_sponge.F90	(revision 7953)
@@ -3,13 +3,20 @@
 MODULE agrif_opa_sponge
    !!======================================================================
-   !!                ***  MODULE agrif_opa_update  ***
-   !! AGRIF :   
+   !!                   ***  MODULE  agrif_opa_interp  ***
+   !! AGRIF: interpolation package
    !!======================================================================
-   !! History :  
+   !! History :  2.0  !  2002-06  (XXX)  Original cade
+   !!             -   !  2005-11  (XXX) 
+   !!            3.2  !  2009-04  (R. Benshila) 
+   !!            3.6  !  2014-09  (R. Benshila) 
    !!----------------------------------------------------------------------
 #if defined key_agrif
+   !!----------------------------------------------------------------------
+   !!   'key_agrif'                                              AGRIF zoom
+   !!----------------------------------------------------------------------
    USE par_oce
    USE oce
    USE dom_oce
+   !
    USE in_out_manager
    USE agrif_oce
@@ -24,5 +31,5 @@
 
    !!----------------------------------------------------------------------
-   !! 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)
@@ -31,20 +38,20 @@
 
    SUBROUTINE Agrif_Sponge_Tra
-      !!---------------------------------------------
-      !!   *** ROUTINE Agrif_Sponge_Tra ***
-      !!---------------------------------------------
-      REAL(wp) :: timecoeff
-      !!---------------------------------------------
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE Agrif_Sponge_Tra ***
+      !!----------------------------------------------------------------------
+      REAL(wp) ::   timecoeff   ! local scalar
+      !!----------------------------------------------------------------------
       !
 #if defined SPONGE
       timecoeff = REAL(Agrif_NbStepint(),wp)/Agrif_rhot()
-
+      !
       CALL Agrif_Sponge
-      Agrif_SpecialValue=0.
+      Agrif_SpecialValue    = 0._wp
       Agrif_UseSpecialValue = .TRUE.
-      tabspongedone_tsn = .FALSE.
-
+      tabspongedone_tsn     = .FALSE.
+      !
       CALL Agrif_Bc_Variable(tsn_sponge_id,calledweight=timecoeff,procname=interptsn_sponge)
-
+      !
       Agrif_UseSpecialValue = .FALSE.
 #endif
@@ -54,24 +61,24 @@
 
    SUBROUTINE Agrif_Sponge_dyn
-      !!---------------------------------------------
-      !!   *** ROUTINE Agrif_Sponge_dyn ***
-      !!---------------------------------------------
-      REAL(wp) :: timecoeff
-      !!---------------------------------------------
-
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE Agrif_Sponge_dyn ***
+      !!----------------------------------------------------------------------
+      REAL(wp) ::   timecoeff   ! local scalar
+      !!----------------------------------------------------------------------
+      !
 #if defined SPONGE
       timecoeff = REAL(Agrif_NbStepint(),wp)/Agrif_rhot()
-
-      Agrif_SpecialValue=0.
+      !
+      Agrif_SpecialValue    = 0._wp
       Agrif_UseSpecialValue = ln_spc_dyn
-
+      !
       tabspongedone_u = .FALSE.
       tabspongedone_v = .FALSE.         
       CALL Agrif_Bc_Variable(un_sponge_id,calledweight=timecoeff,procname=interpun_sponge)
-
+      !
       tabspongedone_u = .FALSE.
       tabspongedone_v = .FALSE.
       CALL Agrif_Bc_Variable(vn_sponge_id,calledweight=timecoeff,procname=interpvn_sponge)
-
+      !
       Agrif_UseSpecialValue = .FALSE.
 #endif
@@ -81,7 +88,7 @@
 
    SUBROUTINE Agrif_Sponge
-      !!---------------------------------------------
-      !!   *** ROUTINE  Agrif_Sponge ***
-      !!---------------------------------------------
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE  Agrif_Sponge ***
+      !!----------------------------------------------------------------------
       INTEGER  :: ji,jj,jk
       INTEGER  :: ispongearea, ilci, ilcj
@@ -89,5 +96,6 @@
       REAL(wp) :: z1spongearea, zramp
       REAL(wp), POINTER, DIMENSION(:,:) :: ztabramp
-
+      !!----------------------------------------------------------------------
+      !
 #if defined SPONGE || defined SPONGE_TOP
       ll_spdone=.TRUE.
@@ -176,8 +184,8 @@
                fsahm_spt(ji,jj) = visc_dyn * ztabramp(ji,jj)
                fsahm_spf(ji,jj) = 0.25_wp * visc_dyn * ( ztabramp(ji,jj) + ztabramp(ji  ,jj+1) &
-                                                     &  +ztabramp(ji,jj) + ztabramp(ji+1,jj  ) )
-            END DO
-         END DO
-
+                  &                                     +ztabramp(ji,jj) + ztabramp(ji+1,jj  ) )
+            END DO
+         END DO
+         !
          CALL lbc_lnk( fsahm_spt, 'T', 1. )   ! Lateral boundary conditions
          CALL lbc_lnk( fsahm_spf, 'F', 1. )
@@ -192,11 +200,11 @@
 
 
-   SUBROUTINE interptsn_sponge(tabres,i1,i2,j1,j2,k1,k2,n1,n2,before)
-      !!---------------------------------------------
-      !!   *** ROUTINE interptsn_sponge ***
-      !!---------------------------------------------
-      INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2,n1,n2
-      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) :: tabres
-      LOGICAL, INTENT(in) :: before
+   SUBROUTINE interptsn_sponge( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before )
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE interptsn_sponge ***
+      !!----------------------------------------------------------------------
+      INTEGER                                     , INTENT(in   ) ::   i1, i2, j1, j2, k1, k2, n1, n2
+      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2), INTENT(inout) ::   tabres
+      LOGICAL                                     , INTENT(in   ) ::   before
       !
       INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices
@@ -205,4 +213,5 @@
       REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2) :: ztu, ztv
       REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2) ::tsbdiff
+      !!----------------------------------------------------------------------
       !
       IF( before ) THEN
@@ -258,20 +267,18 @@
 
 
-   SUBROUTINE interpun_sponge(tabres,i1,i2,j1,j2,k1,k2, before)
-      !!---------------------------------------------
-      !!   *** ROUTINE interpun_sponge ***
-      !!---------------------------------------------    
-      INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2
-      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: tabres
-      LOGICAL, INTENT(in) :: before
-
+   SUBROUTINE interpun_sponge( tabres, i1, i2, j1, j2, k1, k2, before )
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE interpun_sponge ***
+      !!----------------------------------------------------------------------
+      INTEGER                               , INTENT(in   ) ::   i1, i2, j1, j2, k1, k2
+      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) ::   tabres
+      LOGICAL                               , INTENT(in   ) ::   before
+      !!
       INTEGER :: ji,jj,jk
-
-      ! sponge parameters 
+      INTEGER :: jmax
       REAL(wp) :: ze2u, ze1v, zua, zva, zbtr
       REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2) :: ubdiff
       REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2) :: rotdiff, hdivdiff
-      INTEGER :: jmax
-      !!---------------------------------------------    
+      !!----------------------------------------------------------------------
       !
       IF( before ) THEN
@@ -356,19 +363,18 @@
 
 
-   SUBROUTINE interpvn_sponge(tabres,i1,i2,j1,j2,k1,k2, before,nb,ndir)
-      !!---------------------------------------------
-      !!   *** ROUTINE interpvn_sponge ***
-      !!--------------------------------------------- 
-      INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2
-      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: tabres
-      LOGICAL, INTENT(in) :: before
-      INTEGER, INTENT(in) :: nb , ndir
-      !
-      INTEGER  ::   ji, jj, jk
-      REAL(wp) ::   ze2u, ze1v, zua, zva, zbtr
-      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2) :: vbdiff
-      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2) :: rotdiff, hdivdiff
-      INTEGER :: imax
-      !!--------------------------------------------- 
+   SUBROUTINE interpvn_sponge( tabres, i1, i2, j1, j2, k1, k2, before, nb, ndir )
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE interpvn_sponge ***
+      !!----------------------------------------------------------------------
+      INTEGER                               , INTENT(in   ) ::   i1, i2, j1, j2, k1, k2
+      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) ::   tabres
+      LOGICAL                               , INTENT(in   ) ::   before
+      INTEGER                               , INTENT(in   ) ::   nb , ndir
+      !
+      INTEGER ::   ji, jj, jk
+      INTEGER ::   imax
+      REAL(wp)::   ze2u, ze1v, zua, zva, zbtr
+      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2) ::   vbdiff, rotdiff, hdivdiff
+      !!----------------------------------------------------------------------
 
       IF( before ) THEN 
@@ -403,5 +409,5 @@
          !                                                
 
-         imax = i2-1
+         imax = i2 - 1
          IF ((nbondi == 1).OR.(nbondi == 2))   imax = MIN(imax,nlci-3)
 
@@ -437,9 +443,12 @@
 
 #else
+   !!----------------------------------------------------------------------
+   !!   Empty module                                          no AGRIF zoom
+   !!----------------------------------------------------------------------
 CONTAINS
    SUBROUTINE agrif_opa_sponge_empty
-      !!---------------------------------------------
-      !!   *** ROUTINE agrif_OPA_sponge_empty ***
-      !!---------------------------------------------
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE agrif_OPA_sponge_empty ***
+      !!----------------------------------------------------------------------
       WRITE(*,*)  'agrif_opa_sponge : You should not have seen this print! error?'
    END SUBROUTINE agrif_opa_sponge_empty
