Index: /trunk/NEMO/NST_SRC/agrif2model.F90
===================================================================
--- /trunk/NEMO/NST_SRC/agrif2model.F90	(revision 390)
+++ /trunk/NEMO/NST_SRC/agrif2model.F90	(revision 390)
@@ -0,0 +1,62 @@
+#if defined key_AGRIF
+!     ************************************************************************** 
+!!!   Subroutine   Agrif_Set_numberofcells
+!     ************************************************************************** 
+! 
+      Subroutine Agrif_Set_numberofcells(Agrif_Gr)
+      USE Agrif_Types
+      Implicit none
+      Type(Agrif_Grid), Pointer :: Agrif_Gr
+      if ( associated(Agrif_Curgrid) )then
+#include "SetNumberofcells.h"
+      endif
+      End Subroutine Agrif_Set_numberofcells
+!
+!     ************************************************************************** 
+!!!   Subroutine   Agrif_Get_numberofcells
+!     ************************************************************************** 
+      Subroutine Agrif_Get_numberofcells(Agrif_Gr)
+      USE Agrif_Types
+      Implicit none
+      Type(Agrif_Grid), Pointer :: Agrif_Gr
+#include "GetNumberofcells.h"     
+      End Subroutine Agrif_Get_numberofcells
+!
+!     ************************************************************************** 
+!!!   Subroutine Agrif_Allocationcalls
+!     ************************************************************************** 
+      Subroutine Agrif_Allocationcalls(Agrif_Gr)
+      USE Agrif_Types 
+#include "include_agrif.h"
+#include "include_use_instance_agrif.h"
+      Implicit none
+      Type(Agrif_Grid), Pointer :: Agrif_Gr
+#include "allocations_calls_agrif.h"
+      End Subroutine Agrif_Allocationcalls
+!
+!     **************************************************************************  
+!!!   Subroutine Agrif_probdim_modtype_def
+!     **************************************************************************
+      Subroutine Agrif_probdim_modtype_def()
+      Use Agrif_Types
+      Implicit none
+#include "modtype_agrif.h"
+#include "probdim_agrif.h"
+#include "keys_agrif.h"
+      Return
+      End Subroutine Agrif_probdim_modtype_def
+!
+!     **************************************************************************  
+!!!   Subroutine Agrif_clustering_def
+!     **************************************************************************  
+      Subroutine Agrif_clustering_def()
+      Use Agrif_Types
+      Implicit none
+#include "clustering_agrif.h"      
+      Return
+      End Subroutine Agrif_clustering_def
+#else
+      subroutine Agrif2Model
+         write(*,*) 'Impossible to bet here'
+      end subroutine Agrif2model
+#endif
Index: /trunk/NEMO/NST_SRC/agrif_opa_interp.F90
===================================================================
--- /trunk/NEMO/NST_SRC/agrif_opa_interp.F90	(revision 390)
+++ /trunk/NEMO/NST_SRC/agrif_opa_interp.F90	(revision 390)
@@ -0,0 +1,574 @@
+!
+      Module agrif_opa_interp
+#if defined key_AGRIF
+      USE par_oce
+      USE oce
+      USE dom_oce      
+      USE sol_oce
+
+      CONTAINS
+      SUBROUTINE Agrif_tra( kt )
+
+      Implicit none
+      
+   !! * Substitutions
+#  include "domzgr_substitute.h90"  
+#  include "vectopt_loop_substitute.h90"
+!
+      INTEGER :: kt
+      REAL(wp) tatemp(jpi,jpj,jpk) , satemp(jpi,jpj,jpk)
+      INTEGER :: ji,jj,jk
+      REAL(wp) :: rhox
+      REAL(wp) :: alpha1, alpha2, alpha3, alpha4
+      REAL(wp) :: alpha5, alpha6, alpha7
+!
+        IF (Agrif_Root()) RETURN
+
+           Agrif_SpecialValue=0.
+           Agrif_UseSpecialValue = .TRUE.
+           tatemp = 0.
+           satemp = 0.
+
+           Call Agrif_Bc_variable(tatemp,tn)
+           Call Agrif_Bc_variable(satemp,sn)
+           Agrif_UseSpecialValue = .FALSE.
+       
+           rhox = Agrif_Rhox()
+   
+           alpha1 = (rhox-1.)/2.
+           alpha2 = 1.-alpha1
+   
+           alpha3 = (rhox-1)/(rhox+1)
+           alpha4 = 1.-alpha3
+   
+           alpha6 = 2.*(rhox-1.)/(rhox+1.)
+           alpha7 = -(rhox-1)/(rhox+3)
+           alpha5 = 1. - alpha6 - alpha7
+   
+!
+      If ((nbondi == 1).OR.(nbondi == 2)) THEN
+      
+      ta(nlci,:,:) = alpha1 * tatemp(nlci,:,:) + alpha2 * tatemp(nlci-1,:,:)
+      sa(nlci,:,:) = alpha1 * satemp(nlci,:,:) + alpha2 * satemp(nlci-1,:,:)
+      
+      Do jk=1,jpk      
+      Do jj=1,jpj
+        IF (umask(nlci-2,jj,jk).EQ.0.) 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)
+        ELSE
+        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
+          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)
+          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)
+         ENDIF
+        ENDIF
+      End Do
+      enddo 
+      ENDIF        
+
+      If ((nbondj == 1).OR.(nbondj == 2)) THEN
+      
+      ta(:,nlcj,:) = alpha1 * tatemp(:,nlcj,:) + alpha2 * tatemp(:,nlcj-1,:)
+      sa(:,nlcj,:) = alpha1 * satemp(:,nlcj,:) + alpha2 * satemp(:,nlcj-1,:)
+              
+      Do jk=1,jpk      
+      Do ji=1,jpi
+        IF (vmask(ji,nlcj-2,jk).EQ.0.) 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)
+        ELSE
+        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
+           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)
+           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)
+          ENDIF
+        ENDIF
+      End Do
+      enddo
+      ENDIF
+
+      IF ((nbondi == -1).OR.(nbondi == 2)) THEN
+      
+      ta(1,:,:) = alpha1 * tatemp(1,:,:) + alpha2 * tatemp(2,:,:)
+      sa(1,:,:) = alpha1 * satemp(1,:,:) + alpha2 * satemp(2,:,:)      
+      
+      Do jk=1,jpk      
+      Do jj=1,jpj
+        IF (umask(2,jj,jk).EQ.0.) 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)
+        ELSE
+        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
+           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)
+         ENDIF
+        ENDIF
+      End Do
+      enddo
+      ENDIF
+
+      IF ((nbondj == -1).OR.(nbondj == 2)) THEN
+      
+      ta(:,1,:) = alpha1 * tatemp(:,1,:) + alpha2 * tatemp(:,2,:)
+      sa(:,1,:) = alpha1 * satemp(:,1,:) + alpha2 * satemp(:,2,:)
+            
+      Do jk=1,jpk      
+      Do ji=1,jpi
+        IF (vmask(ji,2,jk).EQ.0.) 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)
+        ELSE
+        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
+            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)
+          ENDIF
+        ENDIF
+      End Do
+      enddo 
+      ENDIF
+
+      Return
+      End Subroutine Agrif_tra
+!
+!
+       SUBROUTINE Agrif_dyn(kt)
+!
+      USE phycst
+      USE sol_oce
+      USE in_out_manager
+
+      implicit none
+#  include "domzgr_substitute.h90"
+!
+      REAL(wp) uatemp(jpi,jpj,jpk) , vatemp(jpi,jpj,jpk)
+      INTEGER :: ji,jj,jk
+      INTEGER kt
+      REAL(wp) :: z2dt, znugdt
+      REAL(wp), DIMENSION(jpi,jpj) :: uatemp2D, vatemp2D
+      REAL(wp) :: timeref
+      REAL(wp), DIMENSION(jpi,jpj) :: spgu1,spgv1
+      REAL(wp) :: rhox, rhoy
+
+      IF (Agrif_Root()) RETURN
+
+      rhox = Agrif_Rhox()
+      rhoy = Agrif_Rhoy()
+
+      timeref = 1.
+
+      ! time step: leap-frog
+      z2dt = 2. * rdt
+      ! time step: Euler if restart from rest
+      IF( neuler == 0 .AND. kt == nit000 ) z2dt = rdt
+      ! coefficients
+      znugdt =  rnu * grav * z2dt    
+
+        Agrif_SpecialValue=0.
+        Agrif_UseSpecialValue = .TRUE.
+        uatemp = 0.
+        vatemp = 0.
+        Call Agrif_Bc_variable(uatemp,un,procname=interpu)
+        Call Agrif_Bc_variable(vatemp,vn,procname=interpv)
+        uatemp2d = 0.
+        vatemp2d = 0.
+
+          Agrif_SpecialValue=0.
+        Agrif_UseSpecialValue = .TRUE.
+       Call Agrif_Bc_variable(uatemp2d,e1u,calledweight=1.,procname=interpu2d)
+       Call Agrif_Bc_variable(vatemp2d,e2v,calledweight=1.,procname=interpv2d)
+        Agrif_UseSpecialValue = .FALSE.
+
+
+        If ((nbondi == -1).OR.(nbondi == 2)) THEN
+
+        DO jj=1,jpj
+          laplacu(2,jj) = timeref * (uatemp2d(2,jj)/(rhoy*e2u(2,jj)))*umask(2,jj,1)
+        ENDDO
+        
+        Do jk=1,jpkm1
+        DO jj=1,jpj
+          ua(1:2,jj,jk) = (uatemp(1:2,jj,jk)/(rhoy*e2u(1:2,jj)))
+#if defined key_partial_steps
+           ua(1:2,jj,jk) = ua(1:2,jj,jk) / fse3u(1:2,jj,jk)
+#endif
+        ENDDO
+        ENDDO
+
+        Do jk=1,jpkm1
+        DO jj=1,jpj
+          ua(2,jj,jk) = (ua(2,jj,jk) - z2dt * znugdt * laplacu(2,jj))*umask(2,jj,jk)
+        ENDDO
+        ENDDO
+
+        spgu(2,:)=0.
+
+        do jk=1,jpkm1
+        do jj=1,jpj
+        spgu(2,jj)=spgu(2,jj)+fse3u(2,jj,jk)*ua(2,jj,jk)
+        enddo
+        enddo
+
+        DO jj=1,jpj
+        IF (umask(2,jj,1).NE.0.) THEN
+         spgu(2,jj)=spgu(2,jj)/hu(2,jj)
+        ENDIF
+        enddo
+
+        Do jk=1,jpkm1
+        DO jj=1,jpj
+          ua(2,jj,jk) = 0.25*(ua(1,jj,jk)+2.*ua(2,jj,jk)+ua(3,jj,jk))
+          ua(2,jj,jk) = ua(2,jj,jk) * umask(2,jj,jk)
+        ENDDO
+        ENDDO
+
+        spgu1(2,:)=0.
+
+        do jk=1,jpkm1
+        do jj=1,jpj
+        spgu1(2,jj)=spgu1(2,jj)+fse3u(2,jj,jk)*ua(2,jj,jk)
+        enddo
+        enddo
+
+        DO jj=1,jpj
+        IF (umask(2,jj,1).NE.0.) THEN
+         spgu1(2,jj)=spgu1(2,jj)/hu(2,jj)
+        ENDIF
+        enddo
+
+        DO jk=1,jpkm1
+        DO jj=1,jpj
+         ua(2,jj,jk) = (ua(2,jj,jk)+spgu(2,jj)-spgu1(2,jj))*umask(2,jj,jk)
+        ENDDO
+        ENDDO
+
+        Do jk=1,jpkm1
+        Do jj=1,jpj
+           va(2,jj,jk) = (vatemp(2,jj,jk)/(rhox*e1v(2,jj)))*vmask(2,jj,jk)
+#if defined key_partial_steps
+           va(2,jj,jk) = va(2,jj,jk) / fse3v(2,jj,jk)
+#endif           
+        End Do
+        End Do
+
+        sshn(2,:)=sshn(3,:)
+        sshb(2,:)=sshb(3,:)
+                                
+        ENDIF
+
+        If ((nbondi == 1).OR.(nbondi == 2)) THEN
+
+        DO jj=1,jpj
+          laplacu(nlci-2,jj) = timeref * (uatemp2d(nlci-2,jj)/(rhoy*e2u(nlci-2,jj)))
+        ENDDO
+
+        Do jk=1,jpkm1
+        DO jj=1,jpj
+          ua(nlci-2:nlci-1,jj,jk) = (uatemp(nlci-2:nlci-1,jj,jk)/(rhoy*e2u(nlci-2:nlci-1,jj)))
+
+#if defined key_partial_steps
+           ua(nlci-2:nlci-1,jj,jk) = ua(nlci-2:nlci-1,jj,jk) / fse3u(nlci-2:nlci-1,jj,jk)
+#endif
+
+        ENDDO
+        ENDDO
+
+        Do jk=1,jpkm1
+        DO jj=1,jpj
+          ua(nlci-2,jj,jk) = (ua(nlci-2,jj,jk)- z2dt * znugdt * laplacu(nlci-2,jj))*umask(nlci-2,jj,jk)
+        ENDDO
+        ENDDO
+
+
+        spgu(nlci-2,:)=0.
+
+        do jk=1,jpkm1
+        do jj=1,jpj
+        spgu(nlci-2,jj)=spgu(nlci-2,jj)+fse3u(nlci-2,jj,jk)*ua(nlci-2,jj,jk)
+        enddo
+        enddo
+
+        DO jj=1,jpj
+        IF (umask(nlci-2,jj,1).NE.0.) THEN
+         spgu(nlci-2,jj)=spgu(nlci-2,jj)/hu(nlci-2,jj)
+        ENDIF
+        enddo
+
+        Do jk=1,jpkm1
+        DO jj=1,jpj
+         ua(nlci-2,jj,jk) = 0.25*(ua(nlci-3,jj,jk)+2.*ua(nlci-2,jj,jk)+ua(nlci-1,jj,jk))
+
+          ua(nlci-2,jj,jk) = ua(nlci-2,jj,jk) * umask(nlci-2,jj,jk)
+
+        ENDDO
+        ENDDO
+
+        spgu1(nlci-2,:)=0.
+
+        do jk=1,jpkm1
+        do jj=1,jpj
+        spgu1(nlci-2,jj)=spgu1(nlci-2,jj)+fse3u(nlci-2,jj,jk)*ua(nlci-2,jj,jk)*umask(nlci-2,jj,jk)
+        enddo
+        enddo
+
+        DO jj=1,jpj
+        IF (umask(nlci-2,jj,1).NE.0.) THEN
+         spgu1(nlci-2,jj)=spgu1(nlci-2,jj)/hu(nlci-2,jj)
+        ENDIF
+        enddo
+
+        DO jk=1,jpkm1
+        DO jj=1,jpj
+         ua(nlci-2,jj,jk) = (ua(nlci-2,jj,jk)+spgu(nlci-2,jj)-spgu1(nlci-2,jj))*umask(nlci-2,jj,jk)
+        ENDDO
+        ENDDO
+
+        Do jk=1,jpkm1
+        Do jj=1,jpj-1
+           va(nlci-1,jj,jk) = (vatemp(nlci-1,jj,jk)/(rhox*e1v(nlci-1,jj)))*vmask(nlci-1,jj,jk)
+#if defined key_partial_steps
+           va(nlci-1,jj,jk) = va(nlci-1,jj,jk) / fse3v(nlci-1,jj,jk)
+#endif
+        End Do
+        End Do
+
+        sshn(nlci-1,:)=sshn(nlci-2,:)
+        sshb(nlci-1,:)=sshb(nlci-2,:)        
+        ENDIF
+
+        If ((nbondj == -1).OR.(nbondj == 2)) THEN
+
+        DO ji=1,jpi
+          laplacv(ji,2) = timeref * (vatemp2d(ji,2)/(rhox*e1v(ji,2)))
+        ENDDO
+
+        DO jk=1,jpkm1
+        DO ji=1,jpi
+          va(ji,1:2,jk) = (vatemp(ji,1:2,jk)/(rhox*e1v(ji,1:2)))
+#if defined key_partial_steps
+           va(ji,1:2,jk) = va(ji,1:2,jk) / fse3v(ji,1:2,jk)
+#endif
+        ENDDO
+        ENDDO
+
+        DO jk=1,jpkm1
+        DO ji=1,jpi
+          va(ji,2,jk) = (va(ji,2,jk) - z2dt * znugdt * laplacv(ji,2))*vmask(ji,2,jk)
+        ENDDO
+        ENDDO
+
+        spgv(:,2)=0.
+
+        do jk=1,jpkm1
+        do ji=1,jpi
+        spgv(ji,2)=spgv(ji,2)+fse3v(ji,2,jk)*va(ji,2,jk)
+        enddo
+        enddo
+
+        DO ji=1,jpi
+        IF (vmask(ji,2,1).NE.0.) THEN
+         spgv(ji,2)=spgv(ji,2)/hv(ji,2)
+        ENDIF
+        enddo
+
+        DO jk=1,jpkm1
+        DO ji=1,jpi
+          va(ji,2,jk)=0.25*(va(ji,1,jk)+2.*va(ji,2,jk)+va(ji,3,jk))
+           va(ji,2,jk)=va(ji,2,jk)*vmask(ji,2,jk)
+        ENDDO
+        ENDDO
+
+        spgv1(:,2)=0.
+
+        do jk=1,jpkm1
+        do ji=1,jpi
+        spgv1(ji,2)=spgv1(ji,2)+fse3v(ji,2,jk)*va(ji,2,jk)*vmask(ji,2,jk)
+        enddo
+        enddo
+
+        DO ji=1,jpi
+        IF (vmask(ji,2,1).NE.0.) THEN
+         spgv1(ji,2)=spgv1(ji,2)/hv(ji,2)
+        ENDIF
+        enddo
+
+        DO jk=1,jpkm1
+        DO ji=1,jpi
+         va(ji,2,jk) = (va(ji,2,jk)+spgv(ji,2)-spgv1(ji,2))*vmask(ji,2,jk)
+        ENDDO
+        ENDDO
+
+        DO jk=1,jpkm1
+        DO ji=1,jpi
+        ua(ji,2,jk) = (uatemp(ji,2,jk)/(rhoy*e2u(ji,2)))*umask(ji,2,jk) 
+#if defined key_partial_steps
+           ua(ji,2,jk) = ua(ji,2,jk) / fse3u(ji,2,jk)
+#endif                
+        ENDDO
+        ENDDO
+
+        sshn(:,2)=sshn(:,3)
+        sshb(:,2)=sshb(:,3)
+        ENDIF
+
+        If ((nbondj == 1).OR.(nbondj == 2)) THEN
+
+        DO ji=1,jpi
+          laplacv(ji,nlcj-2) = timeref * (vatemp2d(ji,nlcj-2)/(rhox*e1v(ji,nlcj-2)))
+        ENDDO
+
+        DO jk=1,jpkm1
+        DO ji=1,jpi
+          va(ji,nlcj-2:nlcj-1,jk) = (vatemp(ji,nlcj-2:nlcj-1,jk)/(rhox*e1v(ji,nlcj-2:nlcj-1)))
+#if defined key_partial_steps
+           va(ji,nlcj-2:nlcj-1,jk) = va(ji,nlcj-2:nlcj-1,jk) / fse3v(ji,nlcj-2:nlcj-1,jk)
+#endif
+        ENDDO
+        ENDDO
+
+        DO jk=1,jpkm1
+        DO ji=1,jpi
+          va(ji,nlcj-2,jk) = (va(ji,nlcj-2,jk)-z2dt * znugdt * laplacv(ji,nlcj-2))*vmask(ji,nlcj-2,jk)
+        ENDDO
+        ENDDO
+
+
+        spgv(:,nlcj-2)=0.
+
+        do jk=1,jpkm1
+        do ji=1,jpi
+        spgv(ji,nlcj-2)=spgv(ji,nlcj-2)+fse3v(ji,nlcj-2,jk)*va(ji,nlcj-2,jk)
+        enddo
+        enddo
+
+        DO ji=1,jpi
+        IF (vmask(ji,nlcj-2,1).NE.0.) THEN
+         spgv(ji,nlcj-2)=spgv(ji,nlcj-2)/hv(ji,nlcj-2)
+        ENDIF
+        enddo
+
+        DO jk=1,jpkm1
+        DO ji=1,jpi
+           va(ji,nlcj-2,jk)=0.25*(va(ji,nlcj-3,jk)+2.*va(ji,nlcj-2,jk)+va(ji,nlcj-1,jk))
+           va(ji,nlcj-2,jk) = va(ji,nlcj-2,jk) * vmask(ji,nlcj-2,jk)
+        ENDDO
+        ENDDO
+
+        spgv1(:,nlcj-2)=0.
+
+        do jk=1,jpkm1
+        do ji=1,jpi
+        spgv1(ji,nlcj-2)=spgv1(ji,nlcj-2)+fse3v(ji,nlcj-2,jk)*va(ji,nlcj-2,jk)
+        enddo
+        enddo
+
+        DO ji=1,jpi
+        IF (vmask(ji,nlcj-2,1).NE.0.) THEN
+         spgv1(ji,nlcj-2)=spgv1(ji,nlcj-2)/hv(ji,nlcj-2)
+        ENDIF
+        enddo
+
+        DO jk=1,jpkm1
+        DO ji=1,jpi
+        va(ji,nlcj-2,jk) = (va(ji,nlcj-2,jk)+spgv(ji,nlcj-2)-spgv1(ji,nlcj-2))*vmask(ji,nlcj-2,jk)
+        ENDDO
+        ENDDO
+
+        DO jk=1,jpkm1
+        DO ji=1,jpi
+          ua(ji,nlcj-1,jk) = (uatemp(ji,nlcj-1,jk)/(rhoy*e2u(ji,nlcj-1)))*umask(ji,nlcj-1,jk)
+#if defined key_partial_steps
+           ua(ji,nlcj-1,jk) = ua(ji,nlcj-1,jk) / fse3u(ji,nlcj-1,jk)
+#endif          
+        ENDDO
+        ENDDO
+        
+        sshn(:,nlcj-1)=sshn(:,nlcj-2)
+        sshb(:,nlcj-1)=sshb(:,nlcj-2)                
+        ENDIF
+            
+!
+      Return
+      End Subroutine Agrif_dyn
+
+
+       subroutine interpu(tabres,i1,i2,j1,j2,k1,k2)
+       Implicit none
+#  include "domzgr_substitute.h90"       
+       integer i1,i2,j1,j2,k1,k2
+       integer ji,jj,jk
+       real,dimension(i1:i2,j1:j2,k1:k2) :: tabres
+
+       do jk=k1,k2
+       DO jj=j1,j2
+       DO ji=i1,i2
+         tabres(ji,jj,jk) = e2u(ji,jj) * un(ji,jj,jk)
+#if defined key_partial_steps
+          tabres(ji,jj,jk) = tabres(ji,jj,jk) * fse3u(ji,jj,jk)
+#endif
+       ENDDO
+       ENDDO
+       ENDDO
+       end subroutine interpu
+
+       subroutine interpu2d(tabres,i1,i2,j1,j2)
+       Implicit none
+       integer i1,i2,j1,j2
+       integer ji,jj
+       real,dimension(i1:i2,j1:j2) :: tabres
+
+       DO jj=j1,j2
+       DO ji=i1,i2
+         tabres(ji,jj) = e2u(ji,jj) * ((gcx(ji+1,jj) - gcx(ji,jj))/e1u(ji,jj)) &
+                                       *umask(ji,jj,1)
+       ENDDO
+       ENDDO
+       end subroutine interpu2d
+
+       subroutine interpv(tabres,i1,i2,j1,j2,k1,k2)
+       Implicit none
+#  include "domzgr_substitute.h90"       
+       integer i1,i2,j1,j2,k1,k2
+       integer ji,jj,jk
+       real,dimension(i1:i2,j1:j2,k1:k2) :: tabres
+
+       do jk=k1,k2
+       DO jj=j1,j2
+       DO ji=i1,i2
+         tabres(ji,jj,jk) = e1v(ji,jj) * vn(ji,jj,jk)
+#if defined key_partial_steps
+          tabres(ji,jj,jk) = tabres(ji,jj,jk) * fse3v(ji,jj,jk)
+#endif           
+       ENDDO
+       ENDDO
+       ENDDO
+       end subroutine interpv
+
+       subroutine interpv2d(tabres,i1,i2,j1,j2)
+       Implicit none
+       integer i1,i2,j1,j2
+       integer ji,jj
+       real,dimension(i1:i2,j1:j2) :: tabres
+
+       DO jj=j1,j2
+       DO ji=i1,i2
+         tabres(ji,jj) = e1v(ji,jj) * ((gcx(ji,jj+1) - gcx(ji,jj))/e2v(ji,jj)) &
+                                       * vmask(ji,jj,1)
+       ENDDO
+       ENDDO
+       end subroutine interpv2d
+
+#else
+      CONTAINS
+      subroutine Agrif_OPA_Interp_empty
+
+      end subroutine Agrif_OPA_Interp_empty
+#endif
+      End Module agrif_opa_interp
+
Index: /trunk/NEMO/NST_SRC/agrif_opa_sponge.F90
===================================================================
--- /trunk/NEMO/NST_SRC/agrif_opa_sponge.F90	(revision 390)
+++ /trunk/NEMO/NST_SRC/agrif_opa_sponge.F90	(revision 390)
@@ -0,0 +1,442 @@
+#define SPONGE
+
+      Module agrif_opa_sponge
+#if defined key_AGRIF
+      USE par_oce
+      USE oce
+      USE dom_oce
+      
+      Contains
+
+
+      Subroutine Agrif_Sponge_Tra( kt )
+
+      implicit none
+
+      INTEGER :: kt
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: tabtemp, tbdiff, sbdiff
+      INTEGER :: ji,jj,jk
+      REAL(wp) :: viscsponge
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: umasktemp,vmasktemp
+      INTEGER :: spongearea
+      integer ipt,jpt
+      real,dimension(:,:),pointer :: e1tparent,e2tparent
+      REAL(wp), DIMENSION(jpi,jpj) :: localviscsponge
+      real(wp) :: timecoeff
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: ztu ,ztv, zsu ,zsv
+      REAL(wp) :: zta, zsa, zabe1, zabe2, zbtr
+
+#include "domzgr_substitute.h90"
+
+        
+#if defined SPONGE
+
+      timecoeff = real(Agrif_NbStepint())/Agrif_rhot()
+
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = .TRUE.
+      tabtemp = 0.
+      Call Agrif_Bc_Variable(tabtemp, ta,calledweight=timecoeff,procname=interptn)
+      Agrif_UseSpecialValue = .FALSE.
+
+      tbdiff(:,:,:) = tb(:,:,:) - tabtemp(:,:,:)
+
+      tabtemp = 0.
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = .TRUE.
+      Call Agrif_Bc_Variable(tabtemp, sa,calledweight=timecoeff,procname=interpsn)
+      Agrif_UseSpecialValue = .FALSE.
+
+      sbdiff(:,:,:) = sb(:,:,:) - tabtemp(:,:,:)
+       
+      viscsponge = rdt
+
+      spongearea = 2 + 2 * Agrif_irhox()
+
+      localviscsponge = 0.
+      umasktemp = 0.
+      vmasktemp = 0.
+
+      IF ((nbondi == -1).OR.(nbondi == 2)) THEN
+
+        DO ji = 2, spongearea
+          localviscsponge(ji,:) = viscsponge * (spongearea-ji)/real(spongearea-2)
+        ENDDO
+
+        DO jk = 1, jpkm1
+          umasktemp(2:spongearea-1,:,jk) = umask(2:spongearea-1,:,jk) &
+           * 0.5 * (localviscsponge(2:spongearea-1,:) + localviscsponge(3:spongearea,:))
+        ENDDO
+
+       DO jk = 1, jpkm1
+         vmasktemp(2:spongearea,1:jpjm1,jk) = vmask(2:spongearea,1:jpjm1,jk) &
+          * 0.5 * (localviscsponge(2:spongearea,1:jpjm1) + localviscsponge(2:spongearea,2:jpj))
+       ENDDO
+
+      ENDIF
+
+      IF ((nbondi == 1).OR.(nbondi == 2)) THEN
+
+        DO ji = nlci-spongearea + 1,nlci-1
+          localviscsponge(ji,:) = viscsponge * (ji - (nlci-spongearea+1))/real(spongearea-2)
+        ENDDO
+
+       DO jk = 1, jpkm1
+        umasktemp(nlci-spongearea + 1:nlci-2,:,jk) = umask(nlci-spongearea + 1:nlci-2,:,jk) &
+         * 0.5 * (localviscsponge(nlci-spongearea + 1:nlci-2,:) + localviscsponge(nlci-spongearea + 2:nlci-1,:))
+       ENDDO
+
+       DO jk = 1, jpkm1
+        vmasktemp(nlci-spongearea + 1:nlci-1,1:jpjm1,jk) = vmask(nlci-spongearea + 1:nlci-1,1:jpjm1,jk) &
+          * 0.5 * (localviscsponge(nlci-spongearea + 1:nlci-1,1:jpjm1) + localviscsponge(nlci-spongearea + 1:nlci-1,2:jpj))
+       ENDDO
+
+      ENDIF
+
+
+
+      IF ((nbondj == -1).OR.(nbondj == 2)) THEN
+
+        DO jj = 2, spongearea
+        localviscsponge(:,jj) = viscsponge * (spongearea-jj)/real(spongearea-2)
+        ENDDO
+
+      DO jk = 1, jpkm1
+      vmasktemp(:,2:spongearea-1,jk) = vmask(:,2:spongearea-1,jk) &
+         * 0.5 * (localviscsponge(:,2:spongearea-1) + localviscsponge(:,3:spongearea))
+        ENDDO
+
+      DO jk = 1, jpkm1
+       umasktemp(1:jpim1,2:spongearea,jk) = umask(1:jpim1,2:spongearea,jk) &
+         * 0.5 * (localviscsponge(1:jpim1,2:spongearea) + localviscsponge(2:jpi,2:spongearea))
+      ENDDO
+
+      ENDIF
+
+      IF ((nbondj == 1).OR.(nbondj == 2)) THEN
+
+        DO jj = nlcj-spongearea + 1,nlcj-1
+       localviscsponge(:,jj) = viscsponge * (jj - (nlcj-spongearea+1))/real(spongearea-2)
+       ENDDO
+
+      DO jk = 1, jpkm1
+       vmasktemp(:,nlcj-spongearea + 1:nlcj-2,jk) = vmask(:,nlcj-spongearea + 1:nlcj-2,jk) &
+          * 0.5 * (localviscsponge(:,nlcj-spongearea + 1:nlcj-2) + localviscsponge(:,nlcj-spongearea + 2:nlcj-1))
+       ENDDO
+
+      DO jk = 1, jpkm1
+        umasktemp(1:jpim1,nlcj-spongearea + 1:nlcj-1,jk) = umask(1:jpim1,nlcj-spongearea + 1:nlcj-1,jk) &
+         * 0.5 * (localviscsponge(1:jpim1,nlcj-spongearea + 1:nlcj-1) + localviscsponge(2:jpi,nlcj-spongearea + 1:nlcj-1))
+      ENDDO
+
+      ENDIF
+
+      IF (.Not. spongedoneT) THEN
+         zspe1ur(:,:) = e2u(:,:) / e1u(:,:)
+         zspe2vr(:,:) = e1v(:,:) / e2v(:,:)
+         zspbtr2(:,:) = 1. / ( e1t(:,:) * e2t(:,:))
+         
+         spongedoneT = .TRUE.
+      ENDIF
+
+        DO jk = 1, jpkm1
+          DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+#if defined key_s_coord || defined key_partial_steps
+               zabe1 = umasktemp(ji,jj,jk) * zspe1ur(ji,jj) * fse3u(ji,jj,jk)
+               zabe2 = vmasktemp(ji,jj,jk) * zspe2vr(ji,jj) * fse3v(ji,jj,jk)
+#else
+               zabe1 = umasktemp(ji,jj,jk) * zspe1ur(ji,jj)
+               zabe2 = vmasktemp(ji,jj,jk) * zspe2vr(ji,jj)
+#endif
+               ztu(ji,jj,jk) = zabe1 * ( tbdiff(ji+1,jj  ,jk) - tbdiff(ji,jj,jk) )
+               zsu(ji,jj,jk) = zabe1 * ( sbdiff(ji+1,jj  ,jk) - sbdiff(ji,jj,jk) )
+               ztv(ji,jj,jk) = zabe2 * ( tbdiff(ji  ,jj+1,jk) - tbdiff(ji,jj,jk) )
+               zsv(ji,jj,jk) = zabe2 * ( sbdiff(ji  ,jj+1,jk) - sbdiff(ji,jj,jk) )
+            ENDDO
+          ENDDO
+
+         DO jj = 2,jpjm1
+            DO ji = 2,jpim1
+#if defined key_s_coord || defined key_partial_steps
+               zbtr = zspbtr2(ji,jj) / fse3t(ji,jj,jk)
+#else
+               zbtr = zspbtr2(ji,jj)
+#endif
+               ! horizontal diffusive trends
+               zta = zbtr * (  ztu(ji,jj,jk) - ztu(ji-1,jj,jk)   &
+                  &          + ztv(ji,jj,jk) - ztv(ji,jj-1,jk)  )
+               zsa = zbtr * (  zsu(ji,jj,jk) - zsu(ji-1,jj,jk)   &
+                  &          + zsv(ji,jj,jk) - zsv(ji,jj-1,jk)  )
+               ! add it to the general tracer trends
+               ta(ji,jj,jk) = (ta(ji,jj,jk) + zta)
+               sa(ji,jj,jk) = (sa(ji,jj,jk) + zsa)
+            END DO
+         END DO
+
+        ENDDO
+
+#endif
+
+      Return
+      End Subroutine Agrif_Sponge_Tra
+      
+      Subroutine Agrif_Sponge_dyn( kt )
+
+      implicit none
+
+      INTEGER :: kt
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: tabtemp, ubdiff, vbdiff,rotdiff,hdivdiff
+      INTEGER :: ji,jj,jk
+      REAL(wp) :: viscsponge
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: umasktemp,vmasktemp
+      INTEGER :: spongearea
+      integer ipt,jpt
+      real,dimension(:,:),pointer :: e1tparent,e2tparent
+      REAL(wp), DIMENSION(jpi,jpj) :: localviscsponge
+      real(wp) :: timecoeff
+      REAL(wp):: ze2u, ze1v, zua, zva
+
+#include "domzgr_substitute.h90"
+
+#if defined SPONGE
+
+      timecoeff = real(Agrif_NbStepint())/Agrif_rhot()
+
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = .TRUE.
+      tabtemp = 0.
+      Call Agrif_Bc_Variable(tabtemp, ua,calledweight=timecoeff,procname=interpun)
+      Agrif_UseSpecialValue = .FALSE.
+
+      ubdiff(:,:,:) = ub(:,:,:) - tabtemp(:,:,:)
+
+      tabtemp = 0.
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = .TRUE.
+      Call Agrif_Bc_Variable(tabtemp, va,calledweight=timecoeff,procname=interpvn)
+      Agrif_UseSpecialValue = .FALSE.
+
+      vbdiff(:,:,:) = vb(:,:,:) - tabtemp(:,:,:)
+       
+      viscsponge = rdt
+
+      spongearea = 2 + 2 * Agrif_irhox()
+
+      localviscsponge = 0.
+      umasktemp = 0.
+      vmasktemp = 0.
+
+      IF ((nbondi == -1).OR.(nbondi == 2)) THEN
+
+        DO ji = 2, spongearea
+          localviscsponge(ji,:) = viscsponge * (spongearea-ji)/real(spongearea-2)
+        ENDDO
+
+        DO jk = 1, jpkm1
+          umasktemp(2:spongearea-1,:,jk) = umask(2:spongearea-1,:,jk) &
+           * 0.5 * (localviscsponge(2:spongearea-1,:) + localviscsponge(3:spongearea,:))
+        ENDDO
+
+       DO jk = 1, jpkm1
+         vmasktemp(2:spongearea,1:jpjm1,jk) = vmask(2:spongearea,1:jpjm1,jk) &
+          * 0.5 * (localviscsponge(2:spongearea,1:jpjm1) + localviscsponge(2:spongearea,2:jpj))
+       ENDDO
+
+      ENDIF
+
+      IF ((nbondi == 1).OR.(nbondi == 2)) THEN
+
+        DO ji = nlci-spongearea + 1,nlci-1
+          localviscsponge(ji,:) = viscsponge * (ji - (nlci-spongearea+1))/real(spongearea-2)
+        ENDDO
+
+       DO jk = 1, jpkm1
+        umasktemp(nlci-spongearea + 1:nlci-2,:,jk) = umask(nlci-spongearea + 1:nlci-2,:,jk) &
+         * 0.5 * (localviscsponge(nlci-spongearea + 1:nlci-2,:) + localviscsponge(nlci-spongearea + 2:nlci-1,:))
+       ENDDO
+
+       DO jk = 1, jpkm1
+        vmasktemp(nlci-spongearea + 1:nlci-1,1:jpjm1,jk) = vmask(nlci-spongearea + 1:nlci-1,1:jpjm1,jk) &
+          * 0.5 * (localviscsponge(nlci-spongearea + 1:nlci-1,1:jpjm1) + localviscsponge(nlci-spongearea + 1:nlci-1,2:jpj))
+       ENDDO
+
+      ENDIF
+
+
+
+      IF ((nbondj == -1).OR.(nbondj == 2)) THEN
+
+        DO jj = 2, spongearea
+        localviscsponge(:,jj) = viscsponge * (spongearea-jj)/real(spongearea-2)
+        ENDDO
+
+      DO jk = 1, jpkm1
+      vmasktemp(:,2:spongearea-1,jk) = vmask(:,2:spongearea-1,jk) &
+         * 0.5 * (localviscsponge(:,2:spongearea-1) + localviscsponge(:,3:spongearea))
+        ENDDO
+
+      DO jk = 1, jpkm1
+       umasktemp(1:jpim1,2:spongearea,jk) = umask(1:jpim1,2:spongearea,jk) &
+         * 0.5 * (localviscsponge(1:jpim1,2:spongearea) + localviscsponge(2:jpi,2:spongearea))
+      ENDDO
+
+      ENDIF
+
+      IF ((nbondj == 1).OR.(nbondj == 2)) THEN
+
+        DO jj = nlcj-spongearea + 1,nlcj-1
+       localviscsponge(:,jj) = viscsponge * (jj - (nlcj-spongearea+1))/real(spongearea-2)
+       ENDDO
+
+      DO jk = 1, jpkm1
+       vmasktemp(:,nlcj-spongearea + 1:nlcj-2,jk) = vmask(:,nlcj-spongearea + 1:nlcj-2,jk) &
+          * 0.5 * (localviscsponge(:,nlcj-spongearea + 1:nlcj-2) + localviscsponge(:,nlcj-spongearea + 2:nlcj-1))
+       ENDDO
+
+      DO jk = 1, jpkm1
+        umasktemp(1:jpim1,nlcj-spongearea + 1:nlcj-1,jk) = umask(1:jpim1,nlcj-spongearea + 1:nlcj-1,jk) &
+         * 0.5 * (localviscsponge(1:jpim1,nlcj-spongearea + 1:nlcj-1) + localviscsponge(2:jpi,nlcj-spongearea + 1:nlcj-1))
+      ENDDO
+
+      ENDIF
+      
+      ubdiff = ubdiff * umasktemp
+      vbdiff = vbdiff * vmasktemp
+      
+      hdivdiff = 0.
+      rotdiff = 0.
+
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+
+         !                                             ! --------
+         ! Horizontal divergence                       !   div
+         !                                             ! --------
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1   ! vector opt.
+#if defined key_s_coord || defined key_partial_steps
+               hdivdiff(ji,jj,jk) =   &
+                  (  e2u(ji,jj)*fse3u(ji,jj,jk) * & 
+                  ubdiff(ji,jj,jk) - e2u(ji-1,jj  )* &
+                  fse3u(ji-1,jj  ,jk)  * ubdiff(ji-1,jj  ,jk)       &
+                   + e1v(ji,jj)*fse3v(ji,jj,jk) * &
+                  vbdiff(ji,jj,jk) - e1v(ji  ,jj-1)* &
+                  fse3v(ji  ,jj-1,jk)  * vbdiff(ji  ,jj-1,jk)  )    &
+                  / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+#else
+               hdivdiff(ji,jj,jk) = (  e2u(ji,jj) * ubdiff(ji,jj,jk) &
+               - e2u(ji-1,jj  ) * ubdiff(ji-1,jj  ,jk)      &
+     &               + e1v(ji,jj) * vbdiff(ji,jj,jk) - & 
+     &              e1v(ji  ,jj-1) * vbdiff(ji  ,jj-1,jk)  )   &
+     &            / ( e1t(ji,jj) * e2t(ji,jj) )
+#endif
+            END DO
+         END DO
+         
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1   ! vector opt.
+               rotdiff(ji,jj,jk) = (  e2v(ji+1,jj  ) * vbdiff(ji+1,jj  ,jk) - e2v(ji,jj) * vbdiff(ji,jj,jk)    &
+                  &              - e1u(ji  ,jj+1) * ubdiff(ji  ,jj+1,jk) + e1u(ji,jj) * ubdiff(ji,jj,jk)  ) &
+                  &           * fmask(ji,jj,jk) / ( e1f(ji,jj) * e2f(ji,jj) )
+            END DO
+         END DO
+                  
+         ENDDO
+         
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1   ! vector opt.
+#if defined key_s_coord || defined key_partial_steps
+               ze2u = rotdiff (ji,jj,jk)*fse3f(ji,jj,jk)
+               ze1v = hdivdiff(ji,jj,jk)
+               ! horizontal diffusive trends
+               zua = - ( ze2u - rotdiff (ji,jj-1,jk)* &
+               fse3f(ji,jj-1,jk) ) / ( e2u(ji,jj) * fse3u(ji,jj,jk) )   &
+                     + ( hdivdiff(ji+1,jj,jk) - ze1v      &
+               ) / e1u(ji,jj)
+
+               zva = + ( ze2u - rotdiff (ji-1,jj,jk)* &
+               fse3f(ji-1,jj,jk) ) / ( e1v(ji,jj) * fse3v(ji,jj,jk) )   &
+                     + ( hdivdiff(ji,jj+1,jk) - ze1v    &
+                    ) / e2v(ji,jj)
+#else
+               ! horizontal diffusive trends
+               ze2u = rotdiff (ji,jj,jk)
+               ze1v = hdivdiff(ji,jj,jk)
+               zua = - (                ze2u                  - &
+               rotdiff (ji,jj-1,jk) ) / e2u(ji,jj)   &
+                     + ( hdivdiff(ji+1,jj,jk) -     &
+                ze1v                  ) / e1u(ji,jj)
+
+               zva = + (                ze2u                  - &
+               rotdiff (ji-1,jj,jk) ) / e1v(ji,jj)   &
+                     + ( hdivdiff(ji,jj+1,jk) -       &
+                ze1v                  ) / e2v(ji,jj)
+#endif
+
+               ! add it to the general momentum trends
+
+               ua(ji,jj,jk) = ua(ji,jj,jk) + zua
+               va(ji,jj,jk) = va(ji,jj,jk) + zva
+            END DO
+         END DO
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+
+#endif
+
+      Return
+      End Subroutine Agrif_Sponge_dyn
+
+       subroutine interptn(tabres,i1,i2,j1,j2,k1,k2)
+       Implicit none
+#  include "domzgr_substitute.h90"       
+       integer i1,i2,j1,j2,k1,k2
+       real,dimension(i1:i2,j1:j2,k1:k2) :: tabres
+
+       tabres(i1:i2,j1:j2,k1:k2) = tn(i1:i2,j1:j2,k1:k2)
+
+       end subroutine interptn    
+       
+       subroutine interpsn(tabres,i1,i2,j1,j2,k1,k2)
+       Implicit none
+#  include "domzgr_substitute.h90"       
+       integer i1,i2,j1,j2,k1,k2
+       real,dimension(i1:i2,j1:j2,k1:k2) :: tabres
+
+       tabres(i1:i2,j1:j2,k1:k2) = sn(i1:i2,j1:j2,k1:k2)
+
+       end subroutine interpsn  
+                 
+ 
+       subroutine interpun(tabres,i1,i2,j1,j2,k1,k2)
+       Implicit none
+#  include "domzgr_substitute.h90"       
+       integer i1,i2,j1,j2,k1,k2
+       real,dimension(i1:i2,j1:j2,k1:k2) :: tabres
+
+       tabres(i1:i2,j1:j2,k1:k2) = un(i1:i2,j1:j2,k1:k2)
+
+       end subroutine interpun 
+       
+       subroutine interpvn(tabres,i1,i2,j1,j2,k1,k2)
+       Implicit none
+#  include "domzgr_substitute.h90"       
+       integer i1,i2,j1,j2,k1,k2
+       real,dimension(i1:i2,j1:j2,k1:k2) :: tabres
+
+       tabres(i1:i2,j1:j2,k1:k2) = vn(i1:i2,j1:j2,k1:k2)
+
+       end subroutine interpvn 
+
+#else
+       CONTAINS
+       subroutine agrif_opa_sponge_empty
+       end subroutine agrif_opa_sponge_empty
+#endif
+                    
+       End Module agrif_opa_sponge
Index: /trunk/NEMO/NST_SRC/agrif_opa_update.F90
===================================================================
--- /trunk/NEMO/NST_SRC/agrif_opa_update.F90	(revision 390)
+++ /trunk/NEMO/NST_SRC/agrif_opa_update.F90	(revision 390)
@@ -0,0 +1,425 @@
+#define TWO_WAY
+
+      Module agrif_opa_update
+#if defined key_AGRIF
+      USE par_oce
+      USE oce
+      USE dom_oce
+      
+      Integer, Parameter :: nbclineupdate = 3
+      Integer :: nbcline
+
+      Contains
+
+      Subroutine Agrif_Update_Tra( kt )
+!
+!     Modules used:
+!
+
+      implicit none
+!
+!     Declarations:
+      INTEGER :: kt
+!
+!
+!     Variables
+!
+      Real :: tabtemp(jpi,jpj,jpk)
+!
+!     Begin
+!
+
+      IF ((Agrif_NbStepint() .NE. (Agrif_irhot()-1)).AND.(kt /= 0)) Return
+#if defined TWO_WAY
+      Agrif_UseSpecialValueInUpdate = .TRUE.
+      Agrif_SpecialValueFineGrid = 0.
+      IF (mod(nbcline,nbclineupdate) == 0) THEN
+      Call Agrif_Update_Variable(tabtemp,tn, procname=updateT)
+      Call Agrif_Update_Variable(tabtemp,sn, procname=updateS)
+      ELSE
+      Call Agrif_Update_Variable(tabtemp,tn,locupdate=(/0,2/), procname=updateT)
+      Call Agrif_Update_Variable(tabtemp,sn,locupdate=(/0,2/), procname=updateS)
+      ENDIF
+
+
+      Agrif_UseSpecialValueInUpdate = .FALSE.
+#endif
+
+      Return
+      End subroutine Agrif_Update_Tra
+
+      Subroutine Agrif_Update_Dyn( kt )
+!
+!     Modules used:
+!
+!
+!     Declarations:
+!
+      INTEGER :: kt
+!
+!     Variables
+!
+      Real :: tabtemp(jpi,jpj,jpk)
+      Real :: tabtemp2d(jpi,jpj)
+!
+!     Begin
+!
+!
+       return
+       
+      IF ((Agrif_NbStepint() .NE. (Agrif_irhot()-1)).AND.(kt /= 0)) Return
+#if defined TWO_WAY
+
+      IF (mod(nbcline,nbclineupdate) == 0) THEN
+      Call Agrif_Update_Variable(tabtemp,un,procname = updateU)
+      Call Agrif_Update_Variable(tabtemp,vn,procname = updateV)
+      ELSE
+      Call Agrif_Update_Variable(tabtemp,un,locupdate=(/0,1/),procname = updateU)
+      Call Agrif_Update_Variable(tabtemp,vn,locupdate=(/0,1/),procname = updateV)         
+      ENDIF
+
+      Call Agrif_Update_Variable(tabtemp2d,e1u,procname = updateU2d)
+      Call Agrif_Update_Variable(tabtemp2d,e2v,procname = updateV2d)  
+      
+      nbcline = nbcline + 1
+
+       Agrif_UseSpecialValueInUpdate = .TRUE.
+       Agrif_SpecialValueFineGrid = 0.
+       Call Agrif_Update_Variable(tabtemp2d,sshn,procname = updateSSH)
+       Agrif_UseSpecialValueInUpdate = .FALSE.
+
+
+      Call Agrif_ChildGrid_To_ParentGrid()
+      Call recompute_diags( kt )
+      Call Agrif_ParentGrid_To_ChildGrid()
+
+#endif
+!
+      Return
+      End subroutine Agrif_Update_Dyn
+
+      Subroutine recompute_diags(kt)
+      Use divcur
+      Use wzvmod
+      Use cla_div
+      Use  ocfzpt
+      Implicit None
+      INTEGER kt
+      
+      ta = hdivb
+      sa = rotb
+      CALL oc_fz_pt
+      Call div_cur(kt)
+
+      hdivb = ta
+      rotb  = sa
+
+      IF( n_cla == 1 ) CALL div_cla( kt )
+      Call wzv( kt )
+      
+      End Subroutine recompute_diags
+
+       subroutine updateT(tabres,i1,i2,j1,j2,k1,k2,before)
+       Implicit none
+#  include "domzgr_substitute.h90"
+       integer i1,i2,j1,j2,k1,k2
+       integer ji,jj,jk
+       real,dimension(i1:i2,j1:j2,k1:k2) :: tabres
+       LOGICAL :: before
+
+       IF (before) THEN
+       
+         DO jk=k1,k2
+           DO jj=j1,j2
+             DO ji=i1,i2
+               tabres(ji,jj,jk) = tn(ji,jj,jk)
+             ENDDO
+           ENDDO
+         ENDDO
+         
+       ELSE
+
+         DO jk=k1,k2
+           DO jj=j1,j2
+             DO ji=i1,i2
+               IF (tabres(ji,jj,jk).NE.0.) THEN
+               tn(ji,jj,jk) = tabres(ji,jj,jk) * tmask(ji,jj,jk)
+               ENDIF
+             ENDDO
+            ENDDO
+          ENDDO
+       ENDIF
+
+       end subroutine updateT
+
+       
+       subroutine updateS(tabres,i1,i2,j1,j2,k1,k2,before)
+       Implicit none
+#  include "domzgr_substitute.h90"
+       integer i1,i2,j1,j2,k1,k2
+       integer ji,jj,jk
+       real,dimension(i1:i2,j1:j2,k1:k2) :: tabres
+       LOGICAL :: before
+
+
+       IF (before) THEN
+       
+         DO jk=k1,k2
+           DO jj=j1,j2
+             DO ji=i1,i2
+               tabres(ji,jj,jk) = sn(ji,jj,jk)
+             ENDDO
+           ENDDO
+         ENDDO
+         
+       ELSE
+
+         DO jk=k1,k2
+           DO jj=j1,j2
+             DO ji=i1,i2
+               IF (tabres(ji,jj,jk).NE.0.) THEN
+               sn(ji,jj,jk) = tabres(ji,jj,jk) * tmask(ji,jj,jk)
+               ENDIF
+             ENDDO
+           ENDDO
+         ENDDO
+       ENDIF
+
+       end subroutine updateS
+
+       subroutine updateu(tabres,i1,i2,j1,j2,k1,k2,before)
+       Implicit none
+#  include "domzgr_substitute.h90"
+       integer i1,i2,j1,j2,k1,k2
+       integer ji,jj,jk
+       real,dimension(i1:i2,j1:j2,k1:k2) :: tabres
+       LOGICAL :: before
+       REAL(wp) :: rhoy
+
+
+       IF (before) THEN
+       
+       rhoy = Agrif_Rhoy()
+       
+         DO jk=k1,k2
+           DO jj=j1,j2
+             DO ji=i1,i2
+               tabres(ji,jj,jk) = e2u(ji,jj) * un(ji,jj,jk)
+#if defined key_partial_steps
+               tabres(ji,jj,jk) = tabres(ji,jj,jk) * fse3u(ji,jj,jk)
+#endif
+             ENDDO
+           ENDDO
+         ENDDO
+ 
+         tabres = rhoy * tabres
+ 
+       ELSE
+
+         DO jk=k1,k2
+           DO jj=j1,j2
+             DO ji=i1,i2
+               un(ji,jj,jk) = tabres(ji,jj,jk) / (e2u(ji,jj))
+               un(ji,jj,jk) = un(ji,jj,jk) * umask(ji,jj,jk)
+#if defined key_partial_steps
+               un(ji,jj,jk) = un(ji,jj,jk) / fse3u(ji,jj,jk)
+#endif
+       ENDDO
+       ENDDO
+       ENDDO
+       ENDIF
+
+       end subroutine updateu
+
+       subroutine updatev(tabres,i1,i2,j1,j2,k1,k2,before)
+       Implicit none
+#  include "domzgr_substitute.h90"
+       integer i1,i2,j1,j2,k1,k2
+       integer ji,jj,jk
+       real,dimension(i1:i2,j1:j2,k1:k2) :: tabres
+       LOGICAL :: before
+       REAL(wp) :: rhox
+
+
+       IF (before) THEN
+       
+       rhox = Agrif_Rhox()
+       
+         DO jk=k1,k2
+           DO jj=j1,j2
+             DO ji=i1,i2
+               tabres(ji,jj,jk) = e1v(ji,jj) * vn(ji,jj,jk)
+#if defined key_partial_steps
+               tabres(ji,jj,jk) = tabres(ji,jj,jk) * fse3v(ji,jj,jk)
+#endif
+             ENDDO
+           ENDDO
+         ENDDO
+ 
+        tabres = rhox * tabres
+ 
+       ELSE
+
+         DO jk=k1,k2
+           DO jj=j1,j2
+             DO ji=i1,i2
+               vn(ji,jj,jk) = tabres(ji,jj,jk) / (e1v(ji,jj))
+               vn(ji,jj,jk) = vn(ji,jj,jk) * vmask(ji,jj,jk)
+#if defined key_partial_steps
+               vn(ji,jj,jk) = vn(ji,jj,jk) / fse3v(ji,jj,jk)
+#endif
+       ENDDO
+       ENDDO
+       ENDDO
+       ENDIF
+
+       end subroutine updatev
+
+       subroutine updateu2d(tabres,i1,i2,j1,j2,before)
+       Implicit none
+#  include "domzgr_substitute.h90"
+       integer i1,i2,j1,j2
+       integer ji,jj,jk
+       real,dimension(i1:i2,j1:j2) :: tabres
+       LOGICAL :: before
+       REAL(wp) :: rhoy
+       REAL(wp) :: hinv
+
+
+       IF (before) THEN
+       
+       rhoy = Agrif_Rhoy()
+       
+           DO jk = 1,jpkm1
+             DO jj=j1,j2
+             DO ji=i1,i2
+                tabres(ji,jj) = tabres(ji,jj) + fse3u(ji,jj,jk) * un(ji,jj,jk)
+             ENDDO
+             ENDDO
+           ENDDO
+           
+           DO jj=j1,j2
+           DO ji=i1,i2
+             tabres(ji,jj) = tabres(ji,jj) * e2u(ji,jj)
+           ENDDO
+           ENDDO
+   
+          tabres = rhoy * tabres
+   
+       ELSE
+
+           DO jj=j1,j2
+             DO ji=i1,i2
+               IF (umask(ji,jj,1) .NE. 0.) THEN             
+               spgu(ji,jj) = 0.
+               Do jk=1,jpk
+                spgu(ji,jj) = spgu(ji,jj) + fse3u(ji,jj,jk) * un(ji,jj,jk)
+               EndDo
+               spgu(ji,jj) = spgu(ji,jj) * e2u(ji,jj)
+               hinv = (tabres(ji,jj)-spgu(ji,jj))/(hu(ji,jj)*e2u(ji,jj))
+               Do jk=1,jpk              
+               un(ji,jj,jk) = un(ji,jj,jk) + hinv
+               un(ji,jj,jk) = un(ji,jj,jk) * umask(ji,jj,jk)            
+               EndDo
+               ENDIF
+             ENDDO
+           ENDDO
+       ENDIF
+
+       end subroutine updateu2d
+
+       subroutine updatev2d(tabres,i1,i2,j1,j2,before)
+       Implicit none
+       integer i1,i2,j1,j2
+       integer ji,jj,jk
+       real,dimension(i1:i2,j1:j2) :: tabres
+       LOGICAL :: before
+       REAL(wp) :: rhox
+       REAL(wp) :: hinv
+
+
+       IF (before) THEN
+       
+       rhox = Agrif_Rhox()
+       
+           tabres = 0.
+           
+           DO jk = 1,jpkm1
+             DO jj=j1,j2
+             DO ji=i1,i2
+                tabres(ji,jj) = tabres(ji,jj) + fse3v(ji,jj,jk) * vn(ji,jj,jk)
+             ENDDO
+             ENDDO
+           ENDDO
+           
+           DO jj=j1,j2
+           DO ji=i1,i2
+              tabres(ji,jj) = tabres(ji,jj) * e1v(ji,jj)
+           ENDDO
+           ENDDO
+   
+         tabres = rhox * tabres
+   
+       ELSE
+
+           DO jj=j1,j2
+             DO ji=i1,i2
+               IF (vmask(ji,jj,1) .NE. 0.) THEN             
+               spgv(ji,jj) = 0.
+               Do jk=1,jpk
+                spgv(ji,jj) = spgv(ji,jj) + fse3v(ji,jj,jk) * vn(ji,jj,jk)
+               EndDo
+               spgv(ji,jj) = spgv(ji,jj) * e1v(ji,jj)
+               hinv = (tabres(ji,jj)-spgv(ji,jj))/(hv(ji,jj)*e1v(ji,jj))
+
+               Do jk=1,jpk             
+               vn(ji,jj,jk) = vn(ji,jj,jk) + hinv
+               vn(ji,jj,jk) = vn(ji,jj,jk) * vmask(ji,jj,jk)
+               EndDo
+               ENDIF
+           ENDDO
+           ENDDO
+           
+       ENDIF
+
+       end subroutine updatev2d
+
+       subroutine updateSSH(tabres,i1,i2,j1,j2,before)
+       Implicit none
+#  include "domzgr_substitute.h90"
+       integer i1,i2,j1,j2
+       integer ji,jj
+       real,dimension(i1:i2,j1:j2) :: tabres
+       LOGICAL :: before
+       REAL(wp) :: rhox, rhoy
+
+
+       IF (before) THEN
+       rhox = Agrif_Rhox()
+       rhoy = Agrif_Rhoy()
+       
+           DO jj=j1,j2
+             DO ji=i1,i2
+               tabres(ji,jj) = e1t(ji,jj) * e2t(ji,jj) * sshn(ji,jj)
+             ENDDO
+           ENDDO
+   
+         tabres = rhox * rhoy * tabres
+ 
+       ELSE
+           DO jj=j1,j2
+             DO ji=i1,i2
+               sshn(ji,jj) = tabres(ji,jj) / (e1t(ji,jj) * e2t(ji,jj))
+               sshn(ji,jj) = sshn(ji,jj) * tmask(ji,jj,1)
+       ENDDO
+       ENDDO
+       ENDIF
+
+       end subroutine updateSSH
+       
+#else
+       CONTAINS
+       subroutine agrif_opa_update_empty
+       end subroutine agrif_opa_update_empty
+#endif
+       End Module agrif_opa_update
Index: /trunk/NEMO/NST_SRC/agrif_user.F90
===================================================================
--- /trunk/NEMO/NST_SRC/agrif_user.F90	(revision 390)
+++ /trunk/NEMO/NST_SRC/agrif_user.F90	(revision 390)
@@ -0,0 +1,340 @@
+#if defined key_AGRIF
+      SUBROUTINE Agrif_InitWorkspace
+!
+!     Modules used:
+!
+      Use par_oce
+      Use dom_oce
+      USE Agrif_Util
+!
+!     Declarations:
+!      
+      IMPLICIT NONE
+!
+!     Variables      
+!
+
+!
+!     Begin
+!
+      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
+         jpizoom = 1
+         jpjzoom = 1
+         nperio = 0
+         jperio = 0
+      endif
+
+
+      Return
+      End Subroutine Agrif_InitWorkspace
+
+!
+      SUBROUTINE Agrif_InitValues
+!     ------------------------------------------------------------------
+!     You should declare the variable which has to be interpolated here
+!     -----------------------------------------------------------------
+!
+!     Modules used:
+!  
+      USE Agrif_Util
+      USE oce
+      USE dom_oce
+      USE opa
+#if   defined key_tradmp   ||   defined key_esopa
+      USE tradmp
+#endif
+      USE sol_oce
+      USE in_out_manager
+#if defined key_ice_lim
+      USE ice_oce
+#endif
+#if defined key_AGRIF
+     USE agrif_opa_update
+     USE agrif_opa_interp
+     USE agrif_opa_sponge
+#endif
+!
+!     Declarations:
+!      
+      Implicit none
+!
+!     Variables
+!
+      REAL(wp) tabtemp(jpi,jpj,jpk)
+! 
+      LOGICAL check_namelist
+!
+!
+!     Begin
+!
+#if defined key_orca_r025 || defined key_orca_r05 || defined key_orca_r2 || defined key_orca_r4
+      jp_cfg = -1  ! set special value for jp_cfg on fine grids
+      cp_cfg = "default"
+#endif
+
+      Call opa_init  ! Initializations of each fine grid
+!
+!     Specific fine grid Initializations
+!
+#if defined key_tradmp || defined key_esopa
+! no tracer damping on fine grids
+      lk_tradmp = .FALSE.
+#endif
+!      
+!     Declaration of the type of variable which have to be interpolated
+!
+      Call Agrif_Set_type(un,(/1,2,0/),(/2,3,0/))
+      Call Agrif_Set_type(vn,(/2,1,0/),(/3,2,0/))
+
+      Call Agrif_Set_type(ua,(/1,2,0/),(/2,3,0/))
+      Call Agrif_Set_type(va,(/2,1,0/),(/3,2,0/))
+
+      Call Agrif_Set_type(e1u,(/1,2/),(/2,3/))
+      Call Agrif_Set_type(e2v,(/2,1/),(/3,2/))
+            
+      Call Agrif_Set_type(tn,(/2,2,0/),(/3,3,0/))
+      Call Agrif_Set_type(sn,(/2,2,0/),(/3,3,0/)) 
+
+      Call Agrif_Set_type(tb,(/2,2,0/),(/3,3,0/))
+      Call Agrif_Set_type(sb,(/2,2,0/),(/3,3,0/)) 
+      
+      Call Agrif_Set_type(ta,(/2,2,0/),(/3,3,0/))
+      Call Agrif_Set_type(sa,(/2,2,0/),(/3,3,0/))       
+            
+      Call Agrif_Set_type(sshn,(/2,2/),(/3,3/))
+      Call Agrif_Set_type(gcb,(/2,2/),(/3,3/))
+
+!
+!     Space directions for each variables
+!
+      Call Agrif_Set_raf(un,(/'x','y','N'/))
+      Call Agrif_Set_raf(vn,(/'x','y','N'/))
+      
+      Call Agrif_Set_raf(ua,(/'x','y','N'/))
+      Call Agrif_Set_raf(va,(/'x','y','N'/))
+
+      Call Agrif_Set_raf(e1u,(/'x','y'/))
+      Call Agrif_Set_raf(e2v,(/'x','y'/))
+
+      Call Agrif_Set_raf(tn,(/'x','y','N'/))
+      Call Agrif_Set_raf(sn,(/'x','y','N'/))
+      
+      Call Agrif_Set_raf(tb,(/'x','y','N'/))
+      Call Agrif_Set_raf(sb,(/'x','y','N'/))
+      
+      Call Agrif_Set_raf(ta,(/'x','y','N'/))
+      Call Agrif_Set_raf(sa,(/'x','y','N'/))      
+            
+      Call Agrif_Set_raf(sshn,(/'x','y'/))
+      Call Agrif_Set_raf(gcb,(/'x','y'/))
+
+!
+!     type of interpolation
+
+      Call Agrif_Set_bcinterp(tn,interp=AGRIF_linear)
+      Call Agrif_Set_bcinterp(sn,interp=AGRIF_linear)
+      
+      Call Agrif_Set_bcinterp(ta,interp=AGRIF_linear)
+      Call Agrif_Set_bcinterp(sa,interp=AGRIF_linear)
+               
+      Call Agrif_Set_bcinterp(un,interp1=Agrif_linear,interp2=AGRIF_ppm)
+      Call Agrif_Set_bcinterp(vn,interp1=AGRIF_ppm,interp2=Agrif_linear)
+
+      Call Agrif_Set_bcinterp(ua,interp1=Agrif_linear,interp2=AGRIF_ppm)
+      Call Agrif_Set_bcinterp(va,interp1=AGRIF_ppm,interp2=Agrif_linear)
+      
+      Call Agrif_Set_bcinterp(e1u,interp1=Agrif_linear,interp2=AGRIF_ppm)
+      Call Agrif_Set_bcinterp(e2v,interp1=AGRIF_ppm,interp2=Agrif_linear)
+
+!
+!     Location of interpolation
+!
+      Call Agrif_Set_bc(un,(/0,1/))
+      Call Agrif_Set_bc(vn,(/0,1/))
+      
+      Call Agrif_Set_bc(e1u,(/0,0/))
+      Call Agrif_Set_bc(e2v,(/0,0/))
+
+      Call Agrif_Set_bc(tn,(/0,1/))
+      Call Agrif_Set_bc(sn,(/0,1/))
+
+      Call Agrif_Set_bc(ta,(/-3*Agrif_irhox(),0/))
+      Call Agrif_Set_bc(sa,(/-3*Agrif_irhox(),0/))
+
+      Call Agrif_Set_bc(ua,(/-2*Agrif_irhox(),0/))
+      Call Agrif_Set_bc(va,(/-2*Agrif_irhox(),0/))
+
+!     Update type
+      
+      Call Agrif_Set_Updatetype(tn, update = AGRIF_Update_Average)
+      Call Agrif_Set_Updatetype(sn, update = AGRIF_Update_Average)
+      
+      Call Agrif_Set_Updatetype(tb, update = AGRIF_Update_Average)
+      Call Agrif_Set_Updatetype(sb, update = AGRIF_Update_Average)
+
+      Call Agrif_Set_Updatetype(sshn, update = AGRIF_Update_Average)
+      Call Agrif_Set_Updatetype(gcb,update = AGRIF_Update_Average)
+
+      Call Agrif_Set_Updatetype(un,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average)
+      Call Agrif_Set_Updatetype(vn,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy)
+
+      Call Agrif_Set_Updatetype(e1u,update1 = Agrif_Update_Copy, update2=Agrif_Update_Average)
+      Call Agrif_Set_Updatetype(e2v,update1 = Agrif_Update_Average, update2=Agrif_Update_Copy)
+
+! First interpolations of potentially non zero fields
+
+       Agrif_SpecialValue=0.
+       Agrif_UseSpecialValue = .TRUE.
+       Call Agrif_Bc_variable(tabtemp,tn,calledweight=1.)
+       Call Agrif_Bc_variable(tabtemp,sn,calledweight=1.)
+       Call Agrif_Bc_variable(tabtemp,un,calledweight=1.,procname=interpu)
+       Call Agrif_Bc_variable(tabtemp,vn,calledweight=1.,procname=interpv)
+
+       Call Agrif_Bc_variable(tabtemp,ta,calledweight=1.,procname=interptn)
+       Call Agrif_Bc_variable(tabtemp,sa,calledweight=1.,procname=interpsn)
+
+       Call Agrif_Bc_variable(tabtemp,ua,calledweight=1.,procname=interpun)
+       Call Agrif_Bc_variable(tabtemp,va,calledweight=1.,procname=interpvn)
+       Agrif_UseSpecialValue = .FALSE.
+!
+
+!
+      check_namelist = .true.
+!      
+      IF( check_namelist ) then     
+!
+! check time steps           
+!
+       If( nint(Agrif_Rhot()) * nint(rdt) .ne. Agrif_Parent(rdt) ) then
+              Write(*,*) 'incompatible time step between grids'
+              Write(*,*) 'parent grid value : ',Agrif_Parent(rdt)
+              Write(*,*) 'child  grid value : ',nint(rdt)
+              Write(*,*) 'value on parent grid should be : ',rdt*Agrif_Rhot()
+              stop
+       Endif
+           
+       If( Agrif_IRhot() * (Agrif_Parent(nitend)- &
+       Agrif_Parent(nit000)+1) .ne. (nitend-nit000+1) ) then
+            Write(*,*) 'incompatible run length between grids'
+            Write(*,*) 'parent grid value : ',(Agrif_Parent(nitend)- &
+            Agrif_Parent(nit000)+1),' time step'
+            Write(*,*) 'child  grid value : ', &
+            (nitend-nit000+1),' time step'
+            Write(*,*) 'value on child grid should be : ', &
+            Agrif_IRhot() * (Agrif_Parent(nitend)- &
+            Agrif_Parent(nit000)+1)
+           stop
+       Endif           
+!
+!
+#if defined key_partial_steps                                  
+!
+! check parameters for partial steps 
+!
+       If( Agrif_Parent(e3zps_min) .ne. e3zps_min ) then
+            Write(*,*) 'incompatible e3zps_min between grids'
+            Write(*,*) 'parent grid :',Agrif_Parent(e3zps_min)
+            Write(*,*) 'child grid  :',e3zps_min
+            Write(*,*) 'those values should be identical'
+            stop
+       Endif          
+!          
+       If( Agrif_Parent(e3zps_rat) .ne. e3zps_rat ) then
+            Write(*,*) 'incompatible e3zps_rat between grids'
+            Write(*,*) 'parent grid :',Agrif_Parent(e3zps_rat)
+            Write(*,*) 'child grid  :',e3zps_rat
+            Write(*,*) 'those values should be identical'                  
+            stop
+       Endif                  
+#endif        
+!            
+      ENDIF
+!
+!
+
+      Call Agrif_Update_tra(0)
+      Call Agrif_Update_dyn(0)
+      
+      nbcline = 0
+
+      Return
+      End Subroutine Agrif_InitValues
+!
+      SUBROUTINE Agrif_detect(g,sizex)
+!
+!     Modules used:
+!  
+      Use Agrif_Types
+!
+!
+!     Declarations:
+!      
+!
+!     Variables      
+!
+      Integer, Dimension(2) :: sizex
+      Integer, Dimension(sizex(1),sizex(2))   :: g 
+!
+!     Begin
+!
+!
+
+!
+      Return
+      End Subroutine Agrif_detect
+      
+#if defined key_mpp_mpi
+!
+!     **************************************************************************
+!!!   Subroutine Agrif_InvLoc
+!     **************************************************************************
+!
+      Subroutine Agrif_InvLoc(indloc,nprocloc,i,indglob)
+!  
+!     Description:
+!
+      USE dom_oce
+
+!     Declarations:
+!  
+!!      Implicit none
+!
+      Integer :: indglob,indloc,nprocloc,i
+!
+!
+      SELECT CASE(i)
+
+      CASE(1)
+        indglob = indloc + nimppt(nprocloc+1) - 1
+
+      CASE(2)
+        indglob = indloc + njmppt(nprocloc+1) - 1 
+
+      CASE(3)
+        indglob = indloc
+
+      CASE(4)
+        indglob = indloc
+
+      END SELECT
+!
+!
+      End Subroutine Agrif_InvLoc
+#endif
+
+             
+#else
+      subroutine Subcalledbyagrif
+         write(*,*) 'Impossible to bet here'
+      end subroutine Subcalledbyagrif
+#endif
