Index: trunk/NEMO/NST_SRC/agrif_oce.F90
===================================================================
--- trunk/NEMO/NST_SRC/agrif_oce.F90	(revision 1604)
+++ trunk/NEMO/NST_SRC/agrif_oce.F90	(revision 1605)
@@ -1,16 +1,13 @@
 MODULE agrif_oce
+   !!======================================================================
+   !!                       ***  MODULE agrif_oce  ***
+   !! AGRIF :   define in memory AGRIF variables
    !!----------------------------------------------------------------------
-   !!                       ***  MODULE agrif_oce  ***
-   !!
-   !! ** Purpose :   Define in memory agrif variables
+   !! History :  2.0  ! 2007-12  (R. Benshila)  Original code
    !!----------------------------------------------------------------------
-   !! History :
-   !!   9.0  !  07-12  (R. Benshila)  initial version
+#if defined key_agrif
    !!----------------------------------------------------------------------
-   !!  OPA 9.0 , LOCEAN-IPSL (2006)
-   !! $Id$
-   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!   'key_agrif'                                              AGRIF zoom
    !!----------------------------------------------------------------------
-   !! * Modules used
    USE par_oce      ! ocean parameters
    USE dom_oce      ! domain parameters
@@ -19,20 +16,24 @@
    PUBLIC 
 
-#if defined key_agrif
+   !                                              !!* Namelist namagrif: AGRIF parameters
+   LOGICAL , PUBLIC ::   ln_spc_dyn    = .FALSE.   !:
+   INTEGER , PUBLIC ::   nn_cln_update = 3         !: update frequency 
+   REAL(wp), PUBLIC ::   rn_sponge_tra = rdt       !: sponge coeff. for tracers
+   REAL(wp), PUBLIC ::   rn_sponge_dyn = rdt       !: sponge coeff. for dynamics
 
-   !! Namelist parameters (namagrif)
-   !! ------------------------------
-   LOGICAL, PUBLIC :: ln_spc_dyn  = .FALSE.
-   INTEGER, PUBLIC :: nbclineupdate = 3  !: update frequency 
-   REAL(wp), PUBLIC :: visc_tra = rdt  !: sponge coeff. for tracers
-   REAL(wp), PUBLIC :: visc_dyn = rdt  !: sponge coeff. for dynamics
+   !                                              !!! OLD namelist names
+   INTEGER , PUBLIC ::   nbclineupdate             !: update frequency 
+   REAL(wp), PUBLIC ::   visc_tra                  !: sponge coeff. for tracers
+   REAL(wp), PUBLIC ::   visc_dyn                  !: sponge coeff. for dynamics
 
-   !! Use for sponge computation
-   !! --------------------------
-   LOGICAL, PUBLIC :: spongedoneT = .FALSE.  
-   LOGICAL, PUBLIC :: spongedoneU = .FALSE.
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &  
-      spe1ur, spe2vr ,spbtr2, spe1ur2, spe2vr2, spbtr3  
+   LOGICAL , PUBLIC :: spongedoneT = .FALSE.   !: tracer   sponge layer indicator
+   LOGICAL , PUBLIC :: spongedoneU = .FALSE.   !: dynamics sponge layer indicator
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   spe1ur, spe2vr ,spbtr2, spe1ur2, spe2vr2, spbtr3   !: ???
+
 #endif
-
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================
 END MODULE agrif_oce
Index: trunk/NEMO/NST_SRC/agrif_opa_interp.F90
===================================================================
--- trunk/NEMO/NST_SRC/agrif_opa_interp.F90	(revision 1604)
+++ trunk/NEMO/NST_SRC/agrif_opa_interp.F90	(revision 1605)
@@ -1,4 +1,21 @@
 MODULE agrif_opa_interp
+   !!======================================================================
+   !!                   ***  MODULE  agrif_opa_interp  ***
+   !! AGRIF: interpolation package
+   !!======================================================================
+   !! History :  2.0  !  2002-06  (XXX)  Original cade
+   !!             -   !  2005-11  (XXX) 
+   !!            3.2  !  2009-04  (R. Benshila) 
+   !!----------------------------------------------------------------------
 #if defined key_agrif && ! defined key_off_tra
+   !!----------------------------------------------------------------------
+   !!   'key_agrif'                                              AGRIF zoom
+   !!   NOT 'key_off_tra'                               NO off-line tracers
+   !!----------------------------------------------------------------------
+   !!   Agrif_tra     :
+   !!   Agrif_dyn     : 
+   !!   interpu       :
+   !!   interpv       :
+   !!----------------------------------------------------------------------
    USE par_oce
    USE oce
@@ -6,12 +23,16 @@
    USE sol_oce
    USE agrif_oce
+   USE phycst
+   USE in_out_manager
 
    IMPLICIT NONE
    PRIVATE
     
-   PUBLIC Agrif_tra, Agrif_dyn, interpu, interpv
-
-   !!----------------------------------------------------------------------
-   !!   OPA 9.0 , LOCEAN-IPSL (2006)
+   PUBLIC   Agrif_tra, Agrif_dyn, interpu, interpv
+
+#  include "domzgr_substitute.h90"  
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009)
    !! $Id$
    !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
@@ -21,47 +42,44 @@
    
    SUBROUTINE Agrif_tra
-      !!---------------------------------------------
-      !!   *** ROUTINE Agrif_Tra ***
-      !!---------------------------------------------
-#  include "domzgr_substitute.h90"  
-#  include "vectopt_loop_substitute.h90"
-      
-      INTEGER :: ji,jj,jk
-      REAL(wp) :: zrhox
-      REAL(wp) :: alpha1, alpha2, alpha3, alpha4
-      REAL(wp) :: alpha5, alpha6, alpha7
-      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zta, zsa
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE Agrif_Tra  ***
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zrhox , alpha1, alpha2, alpha3
+      REAL(wp) ::   alpha4, alpha5, alpha6, alpha7
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zta, zsa   ! 3D workspace
+      !!----------------------------------------------------------------------
       !
-      IF(Agrif_Root()) RETURN
-
-      Agrif_SpecialValue=0.
+      IF( Agrif_Root() )   RETURN
+
+      Agrif_SpecialValue    = 0.e0
       Agrif_UseSpecialValue = .TRUE.
-      zta = 0.e0
-      zsa = 0.e0
-
-      CALL Agrif_Bc_variable(zta,tn)
-      CALL Agrif_Bc_variable(zsa,sn)
+      zta(:,:,:) = 0.e0
+      zsa(:,:,:) = 0.e0
+
+      CALL Agrif_Bc_variable( zta, tn )
+      CALL Agrif_Bc_variable( zsa, sn )
       Agrif_UseSpecialValue = .FALSE.
 
       zrhox = Agrif_Rhox()
 
-      alpha1 = (zrhox-1.)/2.
-      alpha2 = 1.-alpha1
-
-      alpha3 = (zrhox-1)/(zrhox+1)
-      alpha4 = 1.-alpha3
-
-      alpha6 = 2.*(zrhox-1.)/(zrhox+1.)
-      alpha7 = -(zrhox-1)/(zrhox+3)
+      alpha1 = ( zrhox - 1. ) * 0.5
+      alpha2 = 1. - alpha1
+
+      alpha3 = ( zrhox - 1. ) / ( zrhox + 1. )
+      alpha4 = 1. - alpha3
+
+      alpha6 = 2. * ( zrhox - 1. ) / ( zrhox + 1. )
+      alpha7 =    - ( zrhox - 1. ) / ( zrhox + 3. )
       alpha5 = 1. - alpha6 - alpha7
 
-      IF((nbondi == 1).OR.(nbondi == 2)) THEN
+      IF( nbondi == 1 .OR. nbondi == 2 ) THEN
 
          ta(nlci,:,:) = alpha1 * zta(nlci,:,:) + alpha2 * zta(nlci-1,:,:)
          sa(nlci,:,:) = alpha1 * zsa(nlci,:,:) + alpha2 * zsa(nlci-1,:,:)
 
-         DO jk=1,jpk      
-            DO jj=1,jpj
-               IF (umask(nlci-2,jj,jk).EQ.0.) THEN
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               IF( umask(nlci-2,jj,jk) == 0.e0 ) THEN
                   ta(nlci-1,jj,jk) = ta(nlci,jj,jk) * tmask(nlci-1,jj,jk)
                   sa(nlci-1,jj,jk) = sa(nlci,jj,jk) * tmask(nlci-1,jj,jk)
@@ -69,9 +87,9 @@
                   ta(nlci-1,jj,jk)=(alpha4*ta(nlci,jj,jk)+alpha3*ta(nlci-2,jj,jk))*tmask(nlci-1,jj,jk)
                   sa(nlci-1,jj,jk)=(alpha4*sa(nlci,jj,jk)+alpha3*sa(nlci-2,jj,jk))*tmask(nlci-1,jj,jk)
-                  IF (un(nlci-2,jj,jk).GT.0.) THEN
+                  IF( un(nlci-2,jj,jk) > 0.e0 ) THEN
                      ta(nlci-1,jj,jk)=( alpha6*ta(nlci-2,jj,jk)+alpha5*ta(nlci,jj,jk)  &
-                                      + alpha7*ta(nlci-3,jj,jk) ) * tmask(nlci-1,jj,jk)
+                        &             + alpha7*ta(nlci-3,jj,jk) ) * tmask(nlci-1,jj,jk)
                      sa(nlci-1,jj,jk)=( alpha6*sa(nlci-2,jj,jk)+alpha5*sa(nlci,jj,jk)  &
-                                      + alpha7*sa(nlci-3,jj,jk) ) * tmask(nlci-1,jj,jk)
+                        &             + alpha7*sa(nlci-3,jj,jk) ) * tmask(nlci-1,jj,jk)
                   ENDIF
                ENDIF
@@ -80,12 +98,12 @@
       ENDIF
 
-      IF((nbondj == 1).OR.(nbondj == 2)) THEN
+      IF( nbondj == 1 .OR. nbondj == 2 ) THEN
 
          ta(:,nlcj,:) = alpha1 * zta(:,nlcj,:) + alpha2 * zta(:,nlcj-1,:)
          sa(:,nlcj,:) = alpha1 * zsa(:,nlcj,:) + alpha2 * zsa(:,nlcj-1,:)
 
-         DO jk=1,jpk      
-            DO ji=1,jpi
-               IF (vmask(ji,nlcj-2,jk).EQ.0.) THEN
+         DO jk = 1, jpkm1
+            DO ji = 1, jpi
+               IF( vmask(ji,nlcj-2,jk) == 0.e0 ) THEN
                   ta(ji,nlcj-1,jk) = ta(ji,nlcj,jk) * tmask(ji,nlcj-1,jk)
                   sa(ji,nlcj-1,jk) = sa(ji,nlcj,jk) * tmask(ji,nlcj-1,jk)
@@ -93,9 +111,9 @@
                   ta(ji,nlcj-1,jk)=(alpha4*ta(ji,nlcj,jk)+alpha3*ta(ji,nlcj-2,jk))*tmask(ji,nlcj-1,jk)        
                   sa(ji,nlcj-1,jk)=(alpha4*sa(ji,nlcj,jk)+alpha3*sa(ji,nlcj-2,jk))*tmask(ji,nlcj-1,jk)
-                  IF (vn(ji,nlcj-2,jk) .GT. 0.) THEN
+                  IF (vn(ji,nlcj-2,jk) > 0.e0 ) THEN
                      ta(ji,nlcj-1,jk)=( alpha6*ta(ji,nlcj-2,jk)+alpha5*ta(ji,nlcj,jk)  &
-                                      + alpha7*ta(ji,nlcj-3,jk) ) * tmask(ji,nlcj-1,jk)
+                        &             + alpha7*ta(ji,nlcj-3,jk) ) * tmask(ji,nlcj-1,jk)
                      sa(ji,nlcj-1,jk)=( alpha6*sa(ji,nlcj-2,jk)+alpha5*sa(ji,nlcj,jk)  &
-                                      + alpha7*sa(ji,nlcj-3,jk))*tmask(ji,nlcj-1,jk)
+                        &             + alpha7*sa(ji,nlcj-3,jk))*tmask(ji,nlcj-1,jk)
                   ENDIF
                ENDIF
@@ -104,10 +122,10 @@
       ENDIF
 
-      IF((nbondi == -1).OR.(nbondi == 2)) THEN
+      IF( nbondi == -1 .OR. nbondi == 2 ) THEN
          ta(1,:,:) = alpha1 * zta(1,:,:) + alpha2 * zta(2,:,:)
          sa(1,:,:) = alpha1 * zsa(1,:,:) + alpha2 * zsa(2,:,:)      
-         DO jk=1,jpk      
-            DO jj=1,jpj
-               IF (umask(2,jj,jk).EQ.0.) THEN
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               IF( umask(2,jj,jk) == 0.e0 ) THEN
                   ta(2,jj,jk) = ta(1,jj,jk) * tmask(2,jj,jk)
                   sa(2,jj,jk) = sa(1,jj,jk) * tmask(2,jj,jk)
@@ -115,5 +133,5 @@
                   ta(2,jj,jk)=(alpha4*ta(1,jj,jk)+alpha3*ta(3,jj,jk))*tmask(2,jj,jk)        
                   sa(2,jj,jk)=(alpha4*sa(1,jj,jk)+alpha3*sa(3,jj,jk))*tmask(2,jj,jk)
-                  IF (un(2,jj,jk).LT.0.) THEN
+                  IF( un(2,jj,jk) < 0.e0 ) THEN
                      ta(2,jj,jk)=(alpha6*ta(3,jj,jk)+alpha5*ta(1,jj,jk)+alpha7*ta(4,jj,jk))*tmask(2,jj,jk)
                      sa(2,jj,jk)=(alpha6*sa(3,jj,jk)+alpha5*sa(1,jj,jk)+alpha7*sa(4,jj,jk))*tmask(2,jj,jk)
@@ -124,10 +142,10 @@
       ENDIF
 
-      IF((nbondj == -1).OR.(nbondj == 2)) THEN
+      IF( nbondj == -1 .OR. nbondj == 2 ) THEN
          ta(:,1,:) = alpha1 * zta(:,1,:) + alpha2 * zta(:,2,:)
          sa(:,1,:) = alpha1 * zsa(:,1,:) + alpha2 * zsa(:,2,:)
          DO jk=1,jpk      
             DO ji=1,jpi
-               IF (vmask(ji,2,jk).EQ.0.) THEN
+               IF( vmask(ji,2,jk) == 0.e0 ) THEN
                   ta(ji,2,jk)=ta(ji,1,jk) * tmask(ji,2,jk)
                   sa(ji,2,jk)=sa(ji,1,jk) * tmask(ji,2,jk)
@@ -135,5 +153,5 @@
                   ta(ji,2,jk)=(alpha4*ta(ji,1,jk)+alpha3*ta(ji,3,jk))*tmask(ji,2,jk)
                   sa(ji,2,jk)=(alpha4*sa(ji,1,jk)+alpha3*sa(ji,3,jk))*tmask(ji,2,jk) 
-                  IF (vn(ji,2,jk) .LT. 0.) THEN
+                  IF( vn(ji,2,jk) < 0.e0 ) THEN
                      ta(ji,2,jk)=(alpha6*ta(ji,3,jk)+alpha5*ta(ji,1,jk)+alpha7*ta(ji,4,jk))*tmask(ji,2,jk)
                      sa(ji,2,jk)=(alpha6*sa(ji,3,jk)+alpha5*sa(ji,1,jk)+alpha7*sa(ji,4,jk))*tmask(ji,2,jk)
@@ -143,18 +161,15 @@
          END DO
       ENDIF
-
+      !
    END SUBROUTINE Agrif_tra
 
+
    SUBROUTINE Agrif_dyn( kt )
-      !!---------------------------------------------
-      !!   *** ROUTINE Agrif_DYN ***
-      !!---------------------------------------------
-      USE phycst
-      USE in_out_manager
-
-#  include "domzgr_substitute.h90"
-      
-      INTEGER, INTENT(in) :: kt
-
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE Agrif_DYN  ***
+      !!----------------------------------------------------------------------  
+      INTEGER, INTENT(in) ::   kt
+      !!
+      INTEGER :: ji,jj,jk
       REAL(wp) :: timeref
       REAL(wp) :: z2dt, znugdt
@@ -163,7 +178,7 @@
       REAL(wp), DIMENSION(jpi,jpj) :: spgu1,spgv1
       REAL(wp), DIMENSION(jpi,jpj,jpk) :: zua, zva
-      INTEGER :: ji,jj,jk
-
-      IF (Agrif_Root()) RETURN
+      !!----------------------------------------------------------------------  
+
+      IF( Agrif_Root() )   RETURN
 
       zrhox = Agrif_Rhox()
@@ -177,5 +192,5 @@
       IF( neuler == 0 .AND. kt == nit000 ) z2dt = rdt
       ! coefficients
-      znugdt =  rnu * grav * z2dt    
+      znugdt =  grav * z2dt    
 
       Agrif_SpecialValue=0.
@@ -505,14 +520,14 @@
    END SUBROUTINE Agrif_dyn
 
+
    SUBROUTINE interpu(tabres,i1,i2,j1,j2,k1,k2)
-      !!---------------------------------------------
-      !!   *** ROUTINE interpu ***
-      !!---------------------------------------------
-#  include "domzgr_substitute.h90"   
-    
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE interpu  ***
+      !!----------------------------------------------------------------------  
       INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2
       REAL(wp),DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: tabres
-
+      !!
       INTEGER :: ji,jj,jk
+      !!----------------------------------------------------------------------  
 
       DO jk=k1,k2
@@ -528,13 +543,14 @@
    END SUBROUTINE interpu
 
+
    SUBROUTINE interpu2d(tabres,i1,i2,j1,j2)
-      !!---------------------------------------------
-      !!   *** ROUTINE interpu2d ***
-      !!---------------------------------------------
-
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE interpu2d  ***
+      !!----------------------------------------------------------------------  
       INTEGER, INTENT(in) :: i1,i2,j1,j2
       REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) :: tabres
-
+      !!
       INTEGER :: ji,jj
+      !!----------------------------------------------------------------------  
 
       DO jj=j1,j2
@@ -547,14 +563,14 @@
    END SUBROUTINE interpu2d
 
+
    SUBROUTINE interpv(tabres,i1,i2,j1,j2,k1,k2)
-      !!---------------------------------------------
-      !!   *** ROUTINE interpv ***
-      !!---------------------------------------------
-#  include "domzgr_substitute.h90" 
-      
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE interpv  ***
+      !!----------------------------------------------------------------------  
       INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2
       REAL(wp),DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: tabres
-
+      !!
       INTEGER :: ji, jj, jk
+      !!----------------------------------------------------------------------  
 
       DO jk=k1,k2
@@ -571,13 +587,14 @@
    END SUBROUTINE interpv
 
+
    SUBROUTINE interpv2d(tabres,i1,i2,j1,j2)
-      !!---------------------------------------------
-      !!   *** ROUTINE interpv2d ***
-      !!---------------------------------------------
-
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE interpu2d  ***
+      !!----------------------------------------------------------------------  
       INTEGER, INTENT(in) :: i1,i2,j1,j2
       REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) :: tabres
-
+      !!
       INTEGER :: ji,jj
+      !!----------------------------------------------------------------------  
 
       DO jj=j1,j2
@@ -591,12 +608,13 @@
 
 #else
+   !!----------------------------------------------------------------------
+   !!   Empty module                                          no AGRIF zoom
+   !!----------------------------------------------------------------------
 CONTAINS
-
    SUBROUTINE Agrif_OPA_Interp_empty
-      !!---------------------------------------------
-      !!   *** ROUTINE agrif_OPA_Interp_empty ***
-      !!---------------------------------------------
       WRITE(*,*)  'agrif_opa_interp : You should not have seen this print! error?'
    END SUBROUTINE Agrif_OPA_Interp_empty
 #endif
+
+   !!======================================================================
 END MODULE agrif_opa_interp
Index: trunk/NEMO/NST_SRC/agrif_user.F90
===================================================================
--- trunk/NEMO/NST_SRC/agrif_user.F90	(revision 1604)
+++ trunk/NEMO/NST_SRC/agrif_user.F90	(revision 1605)
@@ -7,24 +7,29 @@
 
    SUBROUTINE Agrif_InitWorkspace
-      !!------------------------------------------
-      !!   *** ROUTINE Agrif_InitWorkspace ***
-      !!------------------------------------------ 
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE Agrif_InitWorkspace ***
+      !!----------------------------------------------------------------------
       USE par_oce
       USE dom_oce
       USE Agrif_Util
-
+      !!
       IMPLICIT NONE
-      
+      !!
 #if defined key_mpp_dyndist
       CHARACTER(len=20) :: namelistname
       INTEGER nummpp
-      NAMELIST/nam_mpp_dyndist/jpni,jpnj,jpnij
-
-      IF (Agrif_Nbstepint() .EQ. 0) THEN
+      NAMELIST/nammpp_dyndist/ jpni, jpnj, jpnij
+#endif
+      !!----------------------------------------------------------------------
+
+#if defined key_mpp_dyndist
+      ! MPP dynamical distribution : read the processor cutting in the namelist
+      IF( Agrif_Nbstepint() == 0 ) THEN
         nummpp = Agrif_Get_Unit()
         namelistname='namelist'
-        IF (.NOT. Agrif_Root()) namelistname=TRIM(Agrif_CFixed())//'_namelist'
-        OPEN(nummpp,file=namelistname,status='OLD',form='formatted')
-        READ (nummpp,nam_mpp_dyndist)
+        IF(.NOT. Agrif_Root() )   namelistname=TRIM(Agrif_CFixed())//'_namelist'
+        !
+        OPEN (nummpp,file=namelistname,status='OLD',form='formatted')
+        READ (nummpp,nammpp_dyndist)
         CLOSE(nummpp)
       ENDIF
@@ -32,32 +37,30 @@
 
       IF( .NOT. Agrif_Root() ) THEN
-         jpiglo = nbcellsx + 2 + 2*nbghostcells
-         jpjglo = nbcellsy + 2 + 2*nbghostcells
-         jpi = ( jpiglo-2*jpreci + (jpni-1+0) ) / jpni + 2*jpreci
-         jpj = ( jpjglo-2*jprecj + (jpnj-1+0) ) / jpnj + 2*jprecj
-         jpim1 = jpi-1
-         jpjm1 = jpj-1
-         jpkm1 = jpk-1                                        
-         jpij  = jpi*jpj
-         jpidta = jpiglo
-         jpjdta = jpjglo
+         jpiglo  = nbcellsx + 2 + 2*nbghostcells
+         jpjglo  = nbcellsy + 2 + 2*nbghostcells
+         jpi     = ( jpiglo-2*jpreci + (jpni-1+0) ) / jpni + 2*jpreci
+         jpj     = ( jpjglo-2*jprecj + (jpnj-1+0) ) / jpnj + 2*jprecj
+         jpim1   = jpi-1
+         jpjm1   = jpj-1
+         jpkm1   = jpk-1                                        
+         jpij    = jpi*jpj
+         jpidta  = jpiglo
+         jpjdta  = jpjglo
          jpizoom = 1
          jpjzoom = 1
-         nperio = 0
-         jperio = 0
+         nperio  = 0
+         jperio  = 0
       ENDIF
-
+      !
    END SUBROUTINE Agrif_InitWorkspace
 
-   !
 #if ! defined key_off_tra
 
    SUBROUTINE Agrif_InitValues
-      !!------------------------------------------
-      !!   *** ROUTINE Agrif_InitValues ***
-      !!
-      !! ** Purpose :: Declaration of variables to
-      !!               be interpolated
-      !!------------------------------------------
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE Agrif_InitValues ***
+      !!
+      !! ** Purpose :: Declaration of variables to be interpolated
+      !!----------------------------------------------------------------------
       USE Agrif_Util
       USE oce 
@@ -78,7 +81,7 @@
       USE agrif_top_interp
       USE agrif_top_sponge
-
+      !!
       IMPLICIT NONE
-
+      !!
       REAL(wp) :: tabtemp(jpi,jpj,jpk)
 #if defined key_top
@@ -86,4 +89,5 @@
 #endif 
       LOGICAL check_namelist
+      !!----------------------------------------------------------------------
 
       ! 0. Initializations
@@ -313,16 +317,15 @@
 #endif
       nbcline = 0
-
+      !
    END SUBROUTINE Agrif_InitValues
-   !
 
 #else
+
    SUBROUTINE Agrif_InitValues
-      !!------------------------------------------
-      !!   *** ROUTINE Agrif_InitValues ***
-      !!
-      !! ** Purpose :: Declaration of variables to
-      !!               be interpolated
-      !!------------------------------------------
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE Agrif_InitValues ***
+      !!
+      !! ** Purpose :: Declaration of variables to be interpolated
+      !!----------------------------------------------------------------------
       USE Agrif_Util
       USE oce 
@@ -334,9 +337,10 @@
       USE agrif_top_interp
       USE agrif_top_sponge
-
+      !!
       IMPLICIT NONE
-
+      !!
       REAL(wp) :: tabtrtemp(jpi,jpj,jpk,jptra)
       LOGICAL check_namelist
+      !!----------------------------------------------------------------------
 
       ! 0. Initializations
@@ -441,58 +445,71 @@
       CALL Agrif_Update_trc(0)
       nbcline_trc = 0
-
+      !
    END SUBROUTINE Agrif_InitValues
+
 #endif
    
-SUBROUTINE Agrif_detect(g,sizex)
-      !!------------------------------------------
+   SUBROUTINE Agrif_detect( g, sizex )
+      !!----------------------------------------------------------------------
       !!   *** ROUTINE Agrif_detect ***
-      !!------------------------------------------
+      !!----------------------------------------------------------------------
       USE Agrif_Types
- 
+      !! 
       INTEGER, DIMENSION(2) :: sizex
       INTEGER, DIMENSION(sizex(1),sizex(2)) :: g 
-
-      Return
-
-   End SUBROUTINE Agrif_detect
+      !!----------------------------------------------------------------------
+      !
+      RETURN
+      !
+   END SUBROUTINE Agrif_detect
+
 
    SUBROUTINE agrif_opa_init
-      !!---------------------------------------------
-      !!   *** ROUTINE agrif_init ***
-      !!---------------------------------------------
+      !!----------------------------------------------------------------------
+      !!                     *** ROUTINE agrif_init ***
+      !!----------------------------------------------------------------------
       USE agrif_oce 
       USE in_out_manager
-
+      !!
       IMPLICIT NONE
-
-      NAMELIST/namagrif/ nbclineupdate, visc_tra, visc_dyn, ln_spc_dyn
-
-      REWIND ( numnam )
-      READ   ( numnam, namagrif )
-      IF(lwp) THEN
+      !!
+      NAMELIST/namagrif/ nn_cln_update, rn_sponge_tra, rn_sponge_dyn, ln_spc_dyn
+      !!----------------------------------------------------------------------
+
+      REWIND( numnam )                ! Read namagrif namelist
+      READ  ( numnam, namagrif )
+      !
+      IF(lwp) THEN                    ! control print
          WRITE(numout,*)
-         WRITE(numout,*) 'agrif_opa_init : agrif parameters'
+         WRITE(numout,*) 'agrif_opa_init : AGRIF parameters'
          WRITE(numout,*) '~~~~~~~~~~~~'
-         WRITE(numout,*) '          Namelist namagrif : set agrif parameters'
-         WRITE(numout,*) '             baroclinic update frequency          =  ', nbclineupdate
-         WRITE(numout,*) '             sponge coefficient for tracers       =  ', visc_tra
-         WRITE(numout,*) '             sponge coefficient for dynamics      =  ', visc_dyn
-         WRITE(numout,*) '             use special values for dynamics      =  ', ln_spc_dyn
+         WRITE(numout,*) '   Namelist namagrif : set AGRIF parameters'
+         WRITE(numout,*) '      baroclinic update frequency       nn_cln_update = ', nn_cln_update
+         WRITE(numout,*) '      sponge coefficient for tracers    rn_sponge_tra = ', rn_sponge_tra, ' s'
+         WRITE(numout,*) '      sponge coefficient for dynamics   rn_sponge_tra = ', rn_sponge_dyn, ' s'
+         WRITE(numout,*) '      use special values for dynamics   ln_spc_dyn    = ', ln_spc_dyn
          WRITE(numout,*) 
       ENDIF
-
+      !
+      ! convert DOCTOR namelist name into OLD names
+      nbclineupdate = nn_cln_update
+      visc_tra      = rn_sponge_tra
+      visc_dyn      = rn_sponge_dyn
+      !
     END SUBROUTINE agrif_opa_init
-#if defined key_mpp_mpi
-   SUBROUTINE Agrif_InvLoc(indloc,nprocloc,i,indglob)
-      !!------------------------------------------
-      !!   *** ROUTINE Agrif_detect ***
-      !!------------------------------------------
+
+# if defined key_mpp_mpi
+
+   SUBROUTINE Agrif_InvLoc( indloc, nprocloc, i, indglob )
+      !!----------------------------------------------------------------------
+      !!                     *** ROUTINE Agrif_detect ***
+      !!----------------------------------------------------------------------
       USE dom_oce
-      
+      !!
       IMPLICIT NONE
-
+      !!
       INTEGER :: indglob,indloc,nprocloc,i
-
+      !!----------------------------------------------------------------------
+      !
       SELECT CASE(i)
       CASE(1)
@@ -505,12 +522,14 @@
          indglob = indloc
       END SELECT
-
+      !
    END SUBROUTINE Agrif_InvLoc
-#endif
+
+# endif
+
 #else
    SUBROUTINE Subcalledbyagrif
-      !!------------------------------------------
+      !!----------------------------------------------------------------------
       !!   *** ROUTINE Subcalledbyagrif ***
-      !!------------------------------------------
+      !!----------------------------------------------------------------------
       WRITE(*,*) 'Impossible to be here'
    END SUBROUTINE Subcalledbyagrif
