Index: /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/ice_2.F90
===================================================================
--- /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/ice_2.F90	(revision 2803)
+++ /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/ice_2.F90	(revision 2804)
@@ -117,11 +117,12 @@
 
    !!* moment used in the advection scheme
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sxice, syice, sxxice, syyice, sxyice   !: for ice  volume
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sxsn,  sysn,  sxxsn,  syysn,  sxysn    !: for snow volume                  
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sxa,   sya,   sxxa,   syya,   sxya     !: for ice cover area               
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sxc0,  syc0,  sxxc0,  syyc0,  sxyc0    !: for heat content of snow         
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sxc1,  syc1,  sxxc1,  syyc1,  sxyc1    !: for heat content of 1st ice layer
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sxc2,  syc2,  sxxc2,  syyc2,  sxyc2    !: for heat content of 2nd ice layer
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sxst,  syst,  sxxst,  syyst,  sxyst    !: for heat content of brine pockets
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   s0ice, sxice, syice, sxxice, syyice, sxyice   !: for ice  volume
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   s0sn , sxsn,  sysn,  sxxsn,  syysn,  sxysn    !: for snow volume                  
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   s0a  , sxa,   sya,   sxxa,   syya,   sxya     !: for ice cover area               
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   s0c0 , sxc0,  syc0,  sxxc0,  syyc0,  sxyc0    !: for heat content of snow         
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   s0c1 , sxc1,  syc1,  sxxc1,  syyc1,  sxyc1    !: for heat content of 1st ice layer
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   s0c2 , sxc2,  syc2,  sxxc2,  syyc2,  sxyc2    !: for heat content of 2nd ice layer
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   s0st , sxst,  syst,  sxxst,  syyst,  sxyst    !: for heat content of brine pockets
+
    !!----------------------------------------------------------------------
    CONTAINS
@@ -164,17 +165,17 @@
 
       !* moment used in the advection scheme
-      ALLOCATE(sxice (jpi,jpj) , syice (jpi,jpj) , sxxice(jpi,jpj) ,     &
+      ALLOCATE(s0ice (jpi,jpj) , sxice (jpi,jpj) , syice (jpi,jpj) , sxxice(jpi,jpj) ,     &
          &     syyice(jpi,jpj) , sxyice(jpi,jpj) ,                       &
-         &     sxsn  (jpi,jpj) , sysn  (jpi,jpj) , sxxsn (jpi,jpj) ,     &
+         &     s0sn  (jpi,jpj) , sxsn  (jpi,jpj) , sysn  (jpi,jpj) , sxxsn (jpi,jpj) ,     &
          &     syysn (jpi,jpj) , sxysn (jpi,jpj)                   , STAT=ierr(6) )
-      ALLOCATE(sxa   (jpi,jpj) , sya   (jpi,jpj) , sxxa  (jpi,jpj) ,     &
+      ALLOCATE(s0a   (jpi,jpj) , sxa   (jpi,jpj) , sya   (jpi,jpj) , sxxa  (jpi,jpj) ,     &
          &     syya  (jpi,jpj) , sxya  (jpi,jpj) ,                       & 
-         &     sxc0  (jpi,jpj) , syc0  (jpi,jpj) , sxxc0 (jpi,jpj) ,     &
+         &     s0c0  (jpi,jpj) , sxc0  (jpi,jpj) , syc0  (jpi,jpj) , sxxc0 (jpi,jpj) ,     &
          &     syyc0 (jpi,jpj) , sxyc0 (jpi,jpj)                   , STAT=ierr(7))
-      ALLOCATE(sxc1  (jpi,jpj) , syc1  (jpi,jpj) , sxxc1 (jpi,jpj) ,     &
+      ALLOCATE(s0c1  (jpi,jpj) , sxc1  (jpi,jpj) , syc1  (jpi,jpj) , sxxc1 (jpi,jpj) ,     &
          &     syyc1 (jpi,jpj) , sxyc1 (jpi,jpj) ,                       &
-         &     sxc2  (jpi,jpj) , syc2  (jpi,jpj) , sxxc2 (jpi,jpj) ,     &
+         &     s0c2  (jpi,jpj) , sxc2  (jpi,jpj) , syc2  (jpi,jpj) , sxxc2 (jpi,jpj) ,     &
          &     syyc2 (jpi,jpj) , sxyc2 (jpi,jpj)                   , STAT=ierr(8))
-      ALLOCATE(sxst  (jpi,jpj) , syst  (jpi,jpj) , sxxst (jpi,jpj) ,     &
+      ALLOCATE(s0st  (jpi,jpj) , sxst  (jpi,jpj) , syst  (jpi,jpj) , sxxst (jpi,jpj) ,     &
          &     syyst (jpi,jpj) , sxyst (jpi,jpj)                   , STAT=ierr(9))
          !
Index: /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/iceini_2.F90
===================================================================
--- /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/iceini_2.F90	(revision 2803)
+++ /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/iceini_2.F90	(revision 2804)
@@ -23,5 +23,6 @@
    USE par_ice_2        ! LIM2 parameters
    USE thd_ice_2        ! LIM2 thermodynamical variables
-   USE limrhg           ! LIM2 rheology
+   USE limrhg           ! LIM2 EVP rheology
+   USE limrhg_2         ! LIM2 VP rheology
    USE ice_2            ! LIM2 ice variable
    USE limmsh_2         ! LIM2 mesh
@@ -65,4 +66,6 @@
 #if ! defined key_lim2_vp
       ierr = ierr + lim_rhg_alloc  ()
+#else
+      ierr = ierr + lim_rhg_alloc_2()      
 #endif
       IF( lk_mpp    )   CALL mpp_sum( ierr )
Index: /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/limadv_2.F90
===================================================================
--- /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/limadv_2.F90	(revision 2803)
+++ /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/limadv_2.F90	(revision 2804)
@@ -60,7 +60,7 @@
       !!--------------------------------------------------------------------
       USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY:   zf0  => wrk_2d_11 , zfx   => wrk_2d_12 , zfy    => wrk_2d_13 , zbet => wrk_2d_14   ! 2D workspace
-      USE wrk_nemo, ONLY:   zfm  => wrk_2d_15 , zfxx  => wrk_2d_16 , zfyy   => wrk_2d_17 , zfxy => wrk_2d_18   !  -      -
-      USE wrk_nemo, ONLY:   zalg => wrk_2d_19 , zalg1 => wrk_2d_20 , zalg1q => wrk_2d_21                       !  -      -
+      USE wrk_nemo, ONLY:   zf0  => wrk_2d_18 , zfx   => wrk_2d_19 , zfy    => wrk_2d_20 , zbet => wrk_2d_21   ! 2D workspace
+      USE wrk_nemo, ONLY:   zfm  => wrk_2d_22 , zfxx  => wrk_2d_23 , zfyy   => wrk_2d_24 , zfxy => wrk_2d_25   !  -      -
+      USE wrk_nemo, ONLY:   zalg => wrk_2d_26 , zalg1 => wrk_2d_27 , zalg1q => wrk_2d_28                       !  -      -
       !
       REAL(wp)                    , INTENT(in   ) ::   pdf                ! reduction factor for the time step
@@ -78,5 +78,5 @@
       !---------------------------------------------------------------------
 
-      IF( wrk_in_use(2, 11,12,13,14,15,16,17,18,19,20,21) ) THEN
+      IF( wrk_in_use(2, 18,19,20,21,22,23,24,25,26,27,28) ) THEN
          CALL ctl_stop( 'lim_adv_x_2 : requested workspace arrays unavailable.' )   ;   RETURN
       ENDIF
@@ -225,5 +225,5 @@
       ENDIF
       !
-      IF( wrk_not_released(2, 11,12,13,14,15,16,17,18,19,20,21) )   &
+      IF( wrk_not_released(2, 18,19,20,21,22,23,24,25,26,27,28) )   &
           CALL ctl_stop( 'lim_adv_x_2 : failed to release workspace arrays.' )
       !
@@ -246,7 +246,7 @@
       !!---------------------------------------------------------------------
       USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY:   zf0  => wrk_2d_11 , zfx   => wrk_2d_12 , zfy    => wrk_2d_13 , zbet => wrk_2d_14   ! 2D workspace
-      USE wrk_nemo, ONLY:   zfm  => wrk_2d_15 , zfxx  => wrk_2d_16 , zfyy   => wrk_2d_17 , zfxy => wrk_2d_18   !  -      -
-      USE wrk_nemo, ONLY:   zalg => wrk_2d_19 , zalg1 => wrk_2d_20 , zalg1q => wrk_2d_21                       !  -      -
+      USE wrk_nemo, ONLY:   zf0  => wrk_2d_18 , zfx   => wrk_2d_19 , zfy    => wrk_2d_20 , zbet => wrk_2d_21   ! 2D workspace
+      USE wrk_nemo, ONLY:   zfm  => wrk_2d_22 , zfxx  => wrk_2d_23 , zfyy   => wrk_2d_24 , zfxy => wrk_2d_25   !  -      -
+      USE wrk_nemo, ONLY:   zalg => wrk_2d_26 , zalg1 => wrk_2d_27 , zalg1q => wrk_2d_28                       !  -      -
       !!
       REAL(wp)                    , INTENT(in   ) ::   pdf                ! reduction factor for the time step
@@ -264,7 +264,7 @@
       !---------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 11,12,13,14,15,16,17,18,19,20,21) ) THEN
+      IF( wrk_in_use(2, 18,19,20,21,22,23,24,25,26,27,28) ) THEN
          CALL ctl_stop( 'lim_adv_y_2 : requested workspace arrays unavailable.' )   ;   RETURN
-      END IF
+      ENDIF
 
       ! Limitation of moments.
@@ -414,7 +414,6 @@
       ENDIF
       !
-      IF( wrk_not_released(2, 11,12,13,14,15,16,17,18,19,20,21) ) THEN
-        CALL ctl_stop( 'lim_adv_y_2 : failed to release workspace arrays.' )
-      END IF
+      IF( wrk_not_released(2, 18,19,20,21,22,23,24,25,26,27,28) )   &
+          CALL ctl_stop( 'lim_adv_y_2 : failed to release workspace arrays.' )
       !
    END SUBROUTINE lim_adv_y_2
Index: /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/limhdf_2.F90
===================================================================
--- /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/limhdf_2.F90	(revision 2803)
+++ /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/limhdf_2.F90	(revision 2804)
@@ -52,6 +52,6 @@
       !!-------------------------------------------------------------------
       USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY:   zflu => wrk_2d_11, zdiv  => wrk_2d_13, zrlx  => wrk_2d_15 
-      USE wrk_nemo, ONLY:   zflv => wrk_2d_12, zdiv0 => wrk_2d_14, ztab0 => wrk_2d_16
+      USE wrk_nemo, ONLY:   zflu => wrk_2d_17, zdiv  => wrk_2d_18, zrlx  => wrk_2d_19 
+      USE wrk_nemo, ONLY:   zflv => wrk_2d_20, zdiv0 => wrk_2d_21, ztab0 => wrk_2d_22
       !
       REAL(wp), DIMENSION(jpi,jpj), INTENT( inout ) ::   ptab   ! Field on which the diffusion is applied  
@@ -63,5 +63,5 @@
       !!-------------------------------------------------------------------
 
-      IF( wrk_in_use(2, 11,12,13,14,15,16) ) THEN
+      IF( wrk_in_use(2, 17,18,19,20,21,22) ) THEN
          CALL ctl_stop( 'lim_hdf_2 : requested workspace arrays unavailable.' )   ;   RETURN
       END IF
@@ -149,5 +149,5 @@
       ENDIF
       !
-      IF( wrk_not_released(2, 11,12,13,14,15,16) )   CALL ctl_stop('lim_hdf_2: failed to release workspace arrays')
+      IF( wrk_not_released(2, 17,18,19,20,21,22) )   CALL ctl_stop('lim_hdf_2: failed to release workspace arrays')
       !
    END SUBROUTINE lim_hdf_2
Index: /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/limrhg_2.F90
===================================================================
--- /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/limrhg_2.F90	(revision 2803)
+++ /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/limrhg_2.F90	(revision 2804)
@@ -29,4 +29,7 @@
    USE in_out_manager ! I/O manager
    USE prtctl         ! Print control
+#if defined key_agrif
+   USE agrif_lim2_interp ! nesting
+#endif
 
    IMPLICIT NONE
@@ -147,4 +150,8 @@
 !i    zviszeta(:,jpj+1) = 0._wp    ;    zviseta(:,jpj+1) = 0._wp
 
+#if defined key_agrif
+      ! load the boundary value of velocity in special array zuive and zvice
+      CALL Agrif_dyn_lim2_load
+#endif
 
       ! Ice mass, ice strength, and wind stress at the center            |
@@ -551,4 +558,10 @@
             CALL lbc_lnk( zv_n(:,1:jpj), 'I', -1. )
 
+#if defined key_agrif
+            ! copy the boundary value from u_ice_nst and v_ice_nst to u_ice and v_ice
+            ! before next interations
+            CALL Agrif_dyn_lim2_copy(zu_n,zv_n)
+#endif
+
             ! Test of Convergence
             DO jj = k_j1+1 , k_jpj-1
Index: /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/limtrp_2.F90
===================================================================
--- /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/limtrp_2.F90	(revision 2803)
+++ /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_2/limtrp_2.F90	(revision 2804)
@@ -28,4 +28,8 @@
    USE lib_mpp         ! MPP library
 
+# if defined key_agrif
+   USE agrif_lim2_interp ! nesting
+# endif
+
    IMPLICIT NONE
    PRIVATE
@@ -64,8 +68,8 @@
       !!---------------------------------------------------------------------
       USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY: zui_u  => wrk_2d_1, zvi_v => wrk_2d_2, zsm  => wrk_2d_3
-      USE wrk_nemo, ONLY: zs0ice => wrk_2d_4, zs0sn => wrk_2d_5, zs0a => wrk_2d_6
-      USE wrk_nemo, ONLY: zs0c0 => wrk_2d_7,  zs0c1 => wrk_2d_8, zs0c2 => wrk_2d_9, &
-                          zs0st => wrk_2d_10
+      USE wrk_nemo, ONLY: zui_u  => wrk_2d_1, zvi_v => wrk_2d_2
+      USE wrk_nemo, ONLY: zsmice => wrk_2d_3, zsmsn => wrk_2d_4, zsma => wrk_2d_5
+      USE wrk_nemo, ONLY: zsmc0 => wrk_2d_6,  zsmc1 => wrk_2d_7, zsmc2 => wrk_2d_8, &
+                          zsmst => wrk_2d_9
       !!
       INTEGER, INTENT(in) ::   kt     ! number of iteration
@@ -79,5 +83,5 @@
       !---------------------------------------------------------------------
 
-      IF( wrk_in_use(2, 1,2,3,4,5,6,7,8,9,10) ) THEN
+      IF( wrk_in_use(2, 1,2,3,4,5,6,7,8,9) ) THEN
          CALL ctl_stop('lim_trp_2 : requested workspace arrays unavailable')   ;   RETURN
       ENDIF
@@ -85,6 +89,12 @@
       IF( kt == nit000  )   CALL lim_trp_init_2      ! Initialization (first time-step only)
 
-      zsm(:,:) = area(:,:)
-      
+      zsmice(:,:) = area(:,:)
+      zsmsn (:,:) = area(:,:)
+      zsma  (:,:) = area(:,:)
+      zsmc0 (:,:) = area(:,:)
+      zsmc1 (:,:) = area(:,:)
+      zsmc2 (:,:) = area(:,:)
+      zsmst (:,:) = area(:,:)
+     
       IF( ln_limdyn ) THEN
          !-------------------------------------!
@@ -121,11 +131,11 @@
          ! content of properties
          ! ---------------------
-         zs0sn (:,:) =  hsnm(:,:)              * area  (:,:)  ! Snow volume.
-         zs0ice(:,:) =  hicm(:,:)              * area  (:,:)  ! Ice volume.
-         zs0a  (:,:) =  ( 1.0 - frld(:,:) )    * area  (:,:)  ! Surface covered by ice.
-         zs0c0 (:,:) =  tbif(:,:,1) / rt0_snow * zs0sn (:,:)  ! Heat content of the snow layer.
-         zs0c1 (:,:) =  tbif(:,:,2) / rt0_ice  * zs0ice(:,:)  ! Heat content of the first ice layer.
-         zs0c2 (:,:) =  tbif(:,:,3) / rt0_ice  * zs0ice(:,:)  ! Heat content of the second ice layer.
-         zs0st (:,:) =  qstoif(:,:) / xlic     * zs0a  (:,:)  ! Heat reservoir for brine pockets.
+         s0sn (:,:) =  hsnm(:,:)              * area  (:,:)  ! Snow volume.
+         s0ice(:,:) =  hicm(:,:)              * area  (:,:)  ! Ice volume.
+         s0a  (:,:) =  ( 1.0 - frld(:,:) )    * area  (:,:)  ! Surface covered by ice.
+         s0c0 (:,:) =  tbif(:,:,1) / rt0_snow * s0sn (:,:)  ! Heat content of the snow layer.
+         s0c1 (:,:) =  tbif(:,:,2) / rt0_ice  * s0ice(:,:)  ! Heat content of the first ice layer.
+         s0c2 (:,:) =  tbif(:,:,3) / rt0_ice  * s0ice(:,:)  ! Heat content of the second ice layer.
+         s0st (:,:) =  qstoif(:,:) / xlic     * s0a  (:,:)  ! Heat reservoir for brine pockets.
          
  
@@ -137,35 +147,47 @@
          IF( MOD( ( kt - 1) / nn_fsbc , 2 ) == 0) THEN        !==  odd ice time step:  adv_x then adv_y  ==!
             DO jk = 1, initad
-               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0ice, sxice, sxxice, syice, syyice, sxyice )
-               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0ice, sxice, sxxice, syice, syyice, sxyice )
-               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0sn , sxsn , sxxsn , sysn , syysn , sxysn  )
-               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0sn , sxsn , sxxsn , sysn , syysn , sxysn  )
-               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0a  , sxa  , sxxa  , sya  , syya  , sxya   )
-               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0a  , sxa  , sxxa  , sya  , syya  , sxya   )
-               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0c0 , sxc0 , sxxc0 , syc0 , syyc0 , sxyc0  )
-               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0c0 , sxc0 , sxxc0 , syc0 , syyc0 , sxyc0  )
-               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0c1 , sxc1 , sxxc1 , syc1 , syyc1 , sxyc1  )
-               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0c1 , sxc1 , sxxc1 , syc1 , syyc1 , sxyc1  )
-               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0c2 , sxc2 , sxxc2 , syc2 , syyc2 , sxyc2  )
-               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0c2 , sxc2 , sxxc2 , syc2 , syyc2 , sxyc2  )
-               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0st , sxst , sxxst , syst , syyst , sxyst  )
-               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0st , sxst , sxxst , syst , syyst , sxyst  )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsmice, s0ice, sxice, sxxice, syice, syyice, sxyice )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsmsn , s0sn , sxsn , sxxsn , sysn , syysn , sxysn  )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsma  , s0a  , sxa  , sxxa  , sya  , syya  , sxya   )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsmc0 , s0c0 , sxc0 , sxxc0 , syc0 , syyc0 , sxyc0  )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsmc1 , s0c1 , sxc1 , sxxc1 , syc1 , syyc1 , sxyc1  )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsmc2 , s0c2 , sxc2 , sxxc2 , syc2 , syyc2 , sxyc2  )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsmst , s0st , sxst , sxxst , syst , syyst , sxyst  )
+# if defined key_agrif
+               CALL Agrif_sadv_lim2(kt)
+# endif
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsmice, s0ice, sxice, sxxice, syice, syyice, sxyice )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsmsn , s0sn , sxsn , sxxsn , sysn , syysn , sxysn  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsma  , s0a  , sxa  , sxxa  , sya  , syya  , sxya   )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsmc0 , s0c0 , sxc0 , sxxc0 , syc0 , syyc0 , sxyc0  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsmc1 , s0c1 , sxc1 , sxxc1 , syc1 , syyc1 , sxyc1  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsmc2 , s0c2 , sxc2 , sxxc2 , syc2 , syyc2 , sxyc2  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsmst , s0st , sxst , sxxst , syst , syyst , sxyst  )
+# if defined key_agrif
+               CALL Agrif_sadv_lim2(kt)
+# endif
             END DO
          ELSE                                                 !==  even ice time step:  adv_x then adv_y  ==!
             DO jk = 1, initad
-               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0ice, sxice, sxxice, syice, syyice, sxyice )
-               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0ice, sxice, sxxice, syice, syyice, sxyice )
-               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0sn , sxsn , sxxsn , sysn , syysn , sxysn  )
-               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0sn , sxsn , sxxsn , sysn , syysn , sxysn  )
-               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0a  , sxa  , sxxa  , sya  , syya  , sxya   )
-               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0a  , sxa  , sxxa  , sya  , syya  , sxya   )
-               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0c0 , sxc0 , sxxc0 , syc0 , syyc0 , sxyc0  )
-               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0c0 , sxc0 , sxxc0 , syc0 , syyc0 , sxyc0  )
-               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0c1 , sxc1 , sxxc1 , syc1 , syyc1 , sxyc1  )
-               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0c1 , sxc1 , sxxc1 , syc1 , syyc1 , sxyc1  )
-               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0c2 , sxc2 , sxxc2 , syc2 , syyc2 , sxyc2  )
-               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0c2 , sxc2 , sxxc2 , syc2 , syyc2 , sxyc2  )
-               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0st , sxst , sxxst , syst , syyst , sxyst  )
-               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0st , sxst , sxxst , syst , syyst , sxyst  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone, zsmice, s0ice, sxice, sxxice, syice, syyice, sxyice )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone, zsmsn , s0sn , sxsn , sxxsn , sysn , syysn , sxysn  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone, zsma  , s0a  , sxa  , sxxa  , sya  , syya  , sxya   )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone, zsmc0 , s0c0 , sxc0 , sxxc0 , syc0 , syyc0 , sxyc0  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone, zsmc1 , s0c1 , sxc1 , sxxc1 , syc1 , syyc1 , sxyc1  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone, zsmc2 , s0c2 , sxc2 , sxxc2 , syc2 , syyc2 , sxyc2  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone, zsmst , s0st , sxst , sxxst , syst , syyst , sxyst  )
+# if defined key_agrif
+               CALL Agrif_sadv_lim2(kt)
+# endif
+               CALL lim_adv_x_2( zusnit, zui_u, rzero , zsmice, s0ice, sxice, sxxice, syice, syyice, sxyice )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero , zsmsn , s0sn , sxsn , sxxsn , sysn , syysn , sxysn  )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero , zsma  , s0a  , sxa  , sxxa  , sya  , syya  , sxya   )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero , zsmc0 , s0c0 , sxc0 , sxxc0 , syc0 , syyc0 , sxyc0  )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero , zsmc1 , s0c1 , sxc1 , sxxc1 , syc1 , syyc1 , sxyc1  )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero , zsmc2 , s0c2 , sxc2 , sxxc2 , syc2 , syyc2 , sxyc2  )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero , zsmst , s0st , sxst , sxxst , syst , syyst , sxyst  )
+# if defined key_agrif
+               CALL Agrif_sadv_lim2(kt)
+# endif
             END DO
          ENDIF
@@ -174,11 +196,11 @@
          ! ------------------------------------------
 !!gm Define in limmsh one for all area = 1 /area  (CPU time saved !)
-         zs0ice(:,:) = zs0ice(:,:) / area(:,:)
-         zs0sn (:,:) = zs0sn (:,:) / area(:,:)
-         zs0a  (:,:) = zs0a  (:,:) / area(:,:)
-         zs0c0 (:,:) = zs0c0 (:,:) / area(:,:)
-         zs0c1 (:,:) = zs0c1 (:,:) / area(:,:)
-         zs0c2 (:,:) = zs0c2 (:,:) / area(:,:)
-         zs0st (:,:) = zs0st (:,:) / area(:,:)
+         s0ice(:,:) = s0ice(:,:) / area(:,:)
+         s0sn (:,:) = s0sn (:,:) / area(:,:)
+         s0a  (:,:) = s0a  (:,:) / area(:,:)
+         s0c0 (:,:) = s0c0 (:,:) / area(:,:)
+         s0c1 (:,:) = s0c1 (:,:) / area(:,:)
+         s0c2 (:,:) = s0c2 (:,:) / area(:,:)
+         s0st (:,:) = s0st (:,:) / area(:,:)
 
 
@@ -191,8 +213,8 @@
          DO jj = 1, jpjm1          ! NB: has not to be defined on jpj line and jpi row
             DO ji = 1 , fs_jpim1   ! vector opt.
-               pahu(ji,jj) = ( 1.0 - MAX( rzero, SIGN( rone, -zs0a(ji  ,jj) ) ) )   &
-                  &        * ( 1.0 - MAX( rzero, SIGN( rone, -zs0a(ji+1,jj) ) ) ) * ahiu(ji,jj)
-               pahv(ji,jj) = ( 1.0 - MAX( rzero, SIGN( rone, -zs0a(ji,jj  ) ) ) )   &
-                  &        * ( 1.0 - MAX( rzero, SIGN( rone,- zs0a(ji,jj+1) ) ) ) * ahiv(ji,jj)
+               pahu(ji,jj) = ( 1.0 - MAX( rzero, SIGN( rone, -s0a(ji  ,jj) ) ) )   &
+                  &        * ( 1.0 - MAX( rzero, SIGN( rone, -s0a(ji+1,jj) ) ) ) * ahiu(ji,jj)
+               pahv(ji,jj) = ( 1.0 - MAX( rzero, SIGN( rone, -s0a(ji,jj  ) ) ) )   &
+                  &        * ( 1.0 - MAX( rzero, SIGN( rone,- s0a(ji,jj+1) ) ) ) * ahiv(ji,jj)
             END DO
          END DO
@@ -200,6 +222,6 @@
 !        DO jj = 1, jpjm1          ! NB: has not to be defined on jpj line and jpi row
 !           DO ji = 1 , fs_jpim1   ! vector opt.
-!              IF( MIN( zs0a(ji,jj) , zs0a(ji+1,jj) ) == 0.e0 )   pahu(ji,jj) = 0._wp
-!              IF( MIN( zs0a(ji,jj) , zs0a(ji,jj+1) ) == 0.e0 )   pahv(ji,jj) = 0._wp
+!              IF( MIN( s0a(ji,jj) , s0a(ji+1,jj) ) == 0.e0 )   pahu(ji,jj) = 0._wp
+!              IF( MIN( s0a(ji,jj) , s0a(ji,jj+1) ) == 0.e0 )   pahv(ji,jj) = 0._wp
 !           END DO
 !        END DO
@@ -208,20 +230,20 @@
          ! diffusion
          ! ---------
-         CALL lim_hdf_2( zs0ice )
-         CALL lim_hdf_2( zs0sn  )
-         CALL lim_hdf_2( zs0a   )
-         CALL lim_hdf_2( zs0c0  )
-         CALL lim_hdf_2( zs0c1  )
-         CALL lim_hdf_2( zs0c2  )
-         CALL lim_hdf_2( zs0st  )
+         CALL lim_hdf_2( s0ice )
+         CALL lim_hdf_2( s0sn  )
+         CALL lim_hdf_2( s0a   )
+         CALL lim_hdf_2( s0c0  )
+         CALL lim_hdf_2( s0c1  )
+         CALL lim_hdf_2( s0c2  )
+         CALL lim_hdf_2( s0st  )
 
 !!gm see comment this can be skipped
-         zs0ice(:,:) = MAX( rzero, zs0ice(:,:) * area(:,:) )    !!bug:  useless
-         zs0sn (:,:) = MAX( rzero, zs0sn (:,:) * area(:,:) )    !!bug:  cf /area  just below
-         zs0a  (:,:) = MAX( rzero, zs0a  (:,:) * area(:,:) )    !! caution: the suppression of the 2 changes 
-         zs0c0 (:,:) = MAX( rzero, zs0c0 (:,:) * area(:,:) )    !! the last digit of the results
-         zs0c1 (:,:) = MAX( rzero, zs0c1 (:,:) * area(:,:) )
-         zs0c2 (:,:) = MAX( rzero, zs0c2 (:,:) * area(:,:) )
-         zs0st (:,:) = MAX( rzero, zs0st (:,:) * area(:,:) )
+         s0ice(:,:) = MAX( rzero, s0ice(:,:) * area(:,:) )    !!bug:  useless
+         s0sn (:,:) = MAX( rzero, s0sn (:,:) * area(:,:) )    !!bug:  cf /area  just below
+         s0a  (:,:) = MAX( rzero, s0a  (:,:) * area(:,:) )    !! caution: the suppression of the 2 changes 
+         s0c0 (:,:) = MAX( rzero, s0c0 (:,:) * area(:,:) )    !! the last digit of the results
+         s0c1 (:,:) = MAX( rzero, s0c1 (:,:) * area(:,:) )
+         s0c2 (:,:) = MAX( rzero, s0c2 (:,:) * area(:,:) )
+         s0st (:,:) = MAX( rzero, s0st (:,:) * area(:,:) )
 
 
@@ -234,38 +256,38 @@
                !
                ! Recover mean values over the grid squares.
-               zs0sn (ji,jj) = MAX( rzero, zs0sn (ji,jj)/area(ji,jj) )
-               zs0ice(ji,jj) = MAX( rzero, zs0ice(ji,jj)/area(ji,jj) )
-               zs0a  (ji,jj) = MAX( rzero, zs0a  (ji,jj)/area(ji,jj) )
-               zs0c0 (ji,jj) = MAX( rzero, zs0c0 (ji,jj)/area(ji,jj) )
-               zs0c1 (ji,jj) = MAX( rzero, zs0c1 (ji,jj)/area(ji,jj) )
-               zs0c2 (ji,jj) = MAX( rzero, zs0c2 (ji,jj)/area(ji,jj) )
-               zs0st (ji,jj) = MAX( rzero, zs0st (ji,jj)/area(ji,jj) )
+               s0sn (ji,jj) = MAX( rzero, s0sn (ji,jj)/area(ji,jj) )
+               s0ice(ji,jj) = MAX( rzero, s0ice(ji,jj)/area(ji,jj) )
+               s0a  (ji,jj) = MAX( rzero, s0a  (ji,jj)/area(ji,jj) )
+               s0c0 (ji,jj) = MAX( rzero, s0c0 (ji,jj)/area(ji,jj) )
+               s0c1 (ji,jj) = MAX( rzero, s0c1 (ji,jj)/area(ji,jj) )
+               s0c2 (ji,jj) = MAX( rzero, s0c2 (ji,jj)/area(ji,jj) )
+               s0st (ji,jj) = MAX( rzero, s0st (ji,jj)/area(ji,jj) )
 
                ! Recover in situ values.
-               zindb         = MAX( rzero, SIGN( rone, zs0a(ji,jj) - epsi06 ) )
+               zindb         = MAX( rzero, SIGN( rone, s0a(ji,jj) - epsi06 ) )
                zacrith       = 1.0 - ( zindhe * acrit(1) + ( 1.0 - zindhe ) * acrit(2) )
-               zs0a (ji,jj)  = zindb * MIN( zs0a(ji,jj), zacrith )
-               hsnif(ji,jj)  = zindb * ( zs0sn(ji,jj) /MAX( zs0a(ji,jj), epsi16 ) )
-               hicif(ji,jj)  = zindb * ( zs0ice(ji,jj)/MAX( zs0a(ji,jj), epsi16 ) )
+               s0a (ji,jj)  = zindb * MIN( s0a(ji,jj), zacrith )
+               hsnif(ji,jj)  = zindb * ( s0sn(ji,jj) /MAX( s0a(ji,jj), epsi16 ) )
+               hicif(ji,jj)  = zindb * ( s0ice(ji,jj)/MAX( s0a(ji,jj), epsi16 ) )
                zindsn        = MAX( rzero, SIGN( rone, hsnif(ji,jj) - epsi06 ) )
                zindic        = MAX( rzero, SIGN( rone, hicif(ji,jj) - epsi03 ) )
                zindb         = MAX( zindsn, zindic )
-               zs0a (ji,jj)  = zindb * zs0a(ji,jj)
-               frld (ji,jj)  = 1.0 - zs0a(ji,jj)
+               s0a (ji,jj)  = zindb * s0a(ji,jj)
+               frld (ji,jj)  = 1.0 - s0a(ji,jj)
                hsnif(ji,jj)  = zindsn * hsnif(ji,jj)
                hicif(ji,jj)  = zindic * hicif(ji,jj)
-               zusvosn       = 1.0/MAX( hsnif(ji,jj) * zs0a(ji,jj), epsi16 )
-               zusvoic       = 1.0/MAX( hicif(ji,jj) * zs0a(ji,jj), epsi16 )
+               zusvosn       = 1.0/MAX( hsnif(ji,jj) * s0a(ji,jj), epsi16 )
+               zusvoic       = 1.0/MAX( hicif(ji,jj) * s0a(ji,jj), epsi16 )
                zignm         = MAX( rzero,  SIGN( rone, hsndif - hsnif(ji,jj) ) )
                zrtt          = 173.15 * rone 
                ztsn          =          zignm   * tbif(ji,jj,1)  &
-                              + ( 1.0 - zignm ) * MIN( MAX( zrtt, rt0_snow * zusvosn * zs0c0(ji,jj)) , tfu(ji,jj) ) 
-               ztic1          = MIN( MAX( zrtt, rt0_ice * zusvoic * zs0c1(ji,jj) ) , tfu(ji,jj) )
-               ztic2          = MIN( MAX( zrtt, rt0_ice * zusvoic * zs0c2(ji,jj) ) , tfu(ji,jj) )
+                              + ( 1.0 - zignm ) * MIN( MAX( zrtt, rt0_snow * zusvosn * s0c0(ji,jj)) , tfu(ji,jj) ) 
+               ztic1          = MIN( MAX( zrtt, rt0_ice * zusvoic * s0c1(ji,jj) ) , tfu(ji,jj) )
+               ztic2          = MIN( MAX( zrtt, rt0_ice * zusvoic * s0c2(ji,jj) ) , tfu(ji,jj) )
  
                tbif(ji,jj,1) = zindsn * ztsn  + ( 1.0 - zindsn ) * tfu(ji,jj)               
                tbif(ji,jj,2) = zindic * ztic1 + ( 1.0 - zindic ) * tfu(ji,jj)
                tbif(ji,jj,3) = zindic * ztic2 + ( 1.0 - zindic ) * tfu(ji,jj)
-               qstoif(ji,jj) = zindb  * xlic * zs0st(ji,jj) /  MAX( zs0a(ji,jj), epsi16 )
+               qstoif(ji,jj) = zindb  * xlic * s0st(ji,jj) /  MAX( s0a(ji,jj), epsi16 )
             END DO
          END DO
@@ -273,5 +295,12 @@
       ENDIF
       !
-      IF( wrk_not_released(2, 1,2,3,4,5,6,7,8,9,10) )   CALL ctl_stop('lim_trp_2 : failed to release workspace arrays')
+# if defined key_agrif
+!RB : less precise but could be enough 
+!     and avoid above calls to Agrif_sadv_lim2
+              CALL Agrif_adv_lim2(kt)
+# endif
+      !
+      IF( wrk_not_released(2, 1,2,3,4,5,6,7,8,9) )   &
+         &   CALL ctl_stop('lim_trp_2 : failed to release workspace arrays')
       !
    END SUBROUTINE lim_trp_2
Index: /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_3/limrhg.F90
===================================================================
--- /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_3/limrhg.F90	(revision 2803)
+++ /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/LIM_SRC_3/limrhg.F90	(revision 2804)
@@ -34,4 +34,7 @@
    USE dom_ice_2        ! LIM2: ice domain
 #endif
+#if defined key_agrif && defined key_lim2
+   USE agrif_lim2_interp
+#endif
 
    IMPLICIT NONE
@@ -92,5 +95,5 @@
          &      zdd(jpi,jpj) , zdt   (jpi,jpj) , zds   (jpi,jpj) ,                     &
          &      zs1(jpi,jpj) , zs2   (jpi,jpj) , zs12  (jpi,jpj) , zresr(jpi,jpj), STAT=ierr(2) )
-         !
+        !
       lim_rhg_alloc = MAXVAL(ierr)
       !
@@ -506,5 +509,7 @@
 
             CALL lbc_lnk( u_ice(:,:), 'U', -1. )
-
+#if defined key_agrif
+           CALL agrif_dyn_lim(jter ,nevp , 'U')
+#endif
 !CDIR NOVERRCHK
             DO jj = k_j1+1, k_jpj-1
@@ -531,5 +536,7 @@
 
             CALL lbc_lnk( v_ice(:,:), 'V', -1. )
-
+#if defined key_agrif
+           CALL agrif_dyn_lim(jter ,nevp , 'U')
+#endif
          ELSE 
 !CDIR NOVERRCHK
@@ -557,5 +564,7 @@
 
             CALL lbc_lnk( v_ice(:,:), 'V', -1. )
-
+#if defined key_agrif
+            CALL agrif_dyn_lim(jter ,nevp , 'V')
+#endif
 !CDIR NOVERRCHK
             DO jj = k_j1+1, k_jpj-1
@@ -585,5 +594,7 @@
 
             CALL lbc_lnk( u_ice(:,:), 'U', -1. )
-
+#if defined key_agrif
+            CALL agrif_dyn_lim(jter ,nevp , 'U')
+#endif
          ENDIF
 
@@ -625,4 +636,8 @@
       CALL lbc_lnk( u_ice(:,:), 'U', -1. ) 
       CALL lbc_lnk( v_ice(:,:), 'V', -1. ) 
+#if defined key_agrif_lim2
+      CALL agrif_dyn_lim(nevp ,nevp , 'U')
+      CALL agrif_dyn_lim(nevp ,nevp , 'V')
+#endif
 
       DO jj = k_j1+1, k_jpj-1 
Index: /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_ice.F90
===================================================================
--- /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_ice.F90	(revision 2804)
+++ /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_ice.F90	(revision 2804)
@@ -0,0 +1,49 @@
+MODULE agrif_ice
+   !!======================================================================
+   !!                       ***  MODULE agrif_ice  ***
+   !! AGRIF :   define in memory AGRIF variables for sea-ice
+   !!----------------------------------------------------------------------
+   !! History :  3.3  ! 2011-07  (R. Benshila)  Original code
+   !!----------------------------------------------------------------------
+#if defined key_agrif && defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_agrif'                                              AGRIF zoom
+   !!----------------------------------------------------------------------
+   USE par_oce      ! ocean parameters
+   
+   IMPLICIT NONE
+   PRIVATE 
+
+   PUBLIC agrif_ice_alloc ! routine called by nemo_init in nemogcm.F90
+
+   INTEGER, PUBLIC :: u_ice_id, v_ice_id, adv_ice_id, sadv_ice_id
+   REAL(wp), PUBLIC :: childfreq = 0. ! child time position in sea-ice model
+# if defined key_lim2_vp
+   REAL(wp), DIMENSION(:,:), ALLOCATABLE, PUBLIC :: u_ice_nst, v_ice_nst
+# else
+   REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, PUBLIC :: u_ice_oe, v_ice_oe
+   REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, PUBLIC :: u_ice_sn, v_ice_sn
+# endif
+
+   !!----------------------------------------------------------------------
+   !! NEMO/NST 3.3.1 , NEMO Consortium (2011)
+   !! $Id$
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS 
+
+   INTEGER FUNCTION agrif_ice_alloc()
+      !!----------------------------------------------------------------------
+      !!                ***  FUNCTION agrif_ice_alloc  ***
+      !!----------------------------------------------------------------------
+# if defined key_lim2_vp
+      ALLOCATE( u_ice_nst(jpi,jpj) , v_ice_nst(jpi,jpj) , STAT = agrif_ice_alloc ) 
+# else
+      ALLOCATE( u_ice_oe(4,jpj,2) , v_ice_oe(4,jpj,2) ,    &
+         &      u_ice_sn(jpi,4,2) , v_ice_sn(jpi,4,2) ,   STAT = agrif_ice_alloc ) 
+# endif
+   END FUNCTION agrif_ice_alloc
+
+#endif
+   !!======================================================================
+END MODULE agrif_ice
Index: /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_lim2_interp.F90
===================================================================
--- /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_lim2_interp.F90	(revision 2804)
+++ /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_lim2_interp.F90	(revision 2804)
@@ -0,0 +1,701 @@
+MODULE agrif_lim2_interp
+   !!======================================================================
+   !!                       ***  MODULE agrif_lim2_update ***
+   !! Nesting module :  update surface ocean boundary condition over ice
+   !!                   from a child grif
+   !! Sea-Ice model  :  LIM 2.0 Sea ice model time-stepping
+   !!======================================================================
+   !! History :  2.0   !  04-2008  (F. Dupont)  initial version
+   !!            3.3   !  09-2010  (R. Benshila, C. Herbaut) update and EVP
+   !!----------------------------------------------------------------------
+#if defined key_agrif && defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'  :                                 LIM 2.0 sea-ice model
+   !!   'key_agrif' :                                 AGRIF library
+   !!----------------------------------------------------------------------
+   !!   agrif_update_lim2  : update sea-ice model on boundaries or total
+   !!                        sea-ice area
+   !!----------------------------------------------------------------------
+   USE ice_2
+   USE dom_ice_2
+   USE par_oce
+   USE dom_oce
+   USE agrif_ice
+
+   IMPLICIT NONE
+   PRIVATE
+
+# if defined key_lim2_vp
+   PUBLIC Agrif_dyn_lim2_load, Agrif_dyn_lim2_copy
+# else
+   PUBLIC Agrif_dyn_lim
+# endif
+   PUBLIC Agrif_adv_lim2
+   PUBLIC Agrif_sadv_lim2
+   PUBLIC interp_adv_ice, interp_sadv_ice
+   PUBLIC interp_u_ice, interp_v_ice
+
+   !!---------------------------------------------------------------------
+   !! NEMO/NST 3.2 , LOCEAN-IPSL (2010)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+# if defined key_lim2_vp
+   SUBROUTINE agrif_dyn_lim2_load
+      !!-----------------------------------------------------------------------
+      !!              *** ROUTINE agrif_dyn_lim2_load ***
+      !!
+      !! need a special routine for dealing with exchanging data
+      !! between the child and parent grid during ice step
+      !!
+      !!-----------------------------------------------------------------------
+      !
+      IF (Agrif_Root()) RETURN
+
+      Agrif_SpecialValue=-9999.
+      Agrif_UseSpecialValue = .TRUE.
+      u_ice_nst(:,:) = 0.
+      v_ice_nst(:,:) = 0.
+      CALL Agrif_Bc_variable( u_ice_nst, u_ice_id ,procname=interp_u_ice, calledweight=0. )
+      CALL Agrif_Bc_variable( v_ice_nst, v_ice_id ,procname=interp_v_ice, calledweight=0. )
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = .FALSE.
+      !
+   END SUBROUTINE agrif_dyn_lim2_load
+
+
+   SUBROUTINE agrif_dyn_lim2_copy(pu_n,pv_n)
+      !!-----------------------------------------------------------------------
+      !!                 *** ROUTINE agrif_dyn_lim2_copy ***
+      !!-----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,0:jpj+1), INTENT(inout) :: pu_n, pv_n
+      !!
+      REAL(wp) :: zrhox, zrhoy
+      INTEGER :: ji,jj
+      !!-----------------------------------------------------------------------
+      !
+      IF (Agrif_Root()) RETURN
+
+      zrhox = Agrif_Rhox()
+      zrhoy = Agrif_Rhoy()
+
+      IF((nbondi == -1).OR.(nbondi == 2)) THEN
+            DO jj=2,jpj
+               pu_n(3,jj) = u_ice_nst(3,jj)/(zrhoy*e2f(2,jj-1))*tmu(3,jj)
+            END DO
+            DO jj=2,jpj
+               pv_n(3,jj) = v_ice_nst(3,jj)/(zrhox*e1f(2,jj-1))*tmu(3,jj)
+            END DO
+      ENDIF
+
+      IF((nbondi == 1).OR.(nbondi == 2)) THEN
+            DO jj=2,jpj
+               pu_n(nlci-1,jj) = u_ice_nst(nlci-1,jj)/(zrhoy*e2f(nlci-2,jj-1))*tmu(nlci-1,jj)
+            END DO
+            DO jj=2,jpj
+               pv_n(nlci-1,jj) = v_ice_nst(nlci-1,jj)/(zrhox*e1f(nlci-2,jj-1))*tmu(nlci-1,jj)
+            END DO
+      ENDIF
+
+      IF((nbondj == -1).OR.(nbondj == 2)) THEN
+            DO ji=2,jpi
+               pv_n(ji,3) = v_ice_nst(ji,3)/(zrhox*e1f(ji-1,2))*tmu(ji,3)
+            END DO
+            DO ji=2,jpi
+               pu_n(ji,3) = u_ice_nst(ji,3)/(zrhoy*e2f(ji-1,2))*tmu(ji,3)
+            END DO
+      ENDIF
+
+      IF((nbondj == 1).OR.(nbondj == 2)) THEN
+            DO ji=2,jpi
+               pv_n(ji,nlcj-1) = v_ice_nst(ji,nlcj-1)/(zrhox*e1f(ji-1,nlcj-2))*tmu(ji,nlcj-1)
+            END DO
+            DO ji=2,jpi
+               pu_n(ji,nlcj-1) = u_ice_nst(ji,nlcj-1)/(zrhoy*e2f(ji-1,nlcj-2))*tmu(ji,nlcj-1)
+            END DO
+      ENDIF
+      !
+   END SUBROUTINE agrif_dyn_lim2_copy
+
+#else
+
+   SUBROUTINE agrif_dyn_lim( kiter, kitermax, cd_type )
+      !!-----------------------------------------------------------------------
+      !!                    *** ROUTINE dyn_lim ***
+      !!-----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kiter, kitermax
+      CHARACTER(len=1), INTENT( in ) :: cd_type
+      !!
+      INTEGER :: ji,jj
+      REAL(wp) :: alpha, beta, zrhox, zrhoy
+      REAL(wp), DIMENSION(:,:), ALLOCATABLE :: zuice, zvice
+      !!-----------------------------------------------------------------------
+      !
+      IF (Agrif_Root()) RETURN
+   
+      IF( childfreq == 1. .AND. ( kiter == 0 .OR. kiter == 1 ) .AND. cd_type == 'V') THEN
+        !
+        ALLOCATE( zuice(jpi,jpj) , zvice(jpi,jpj) )
+        ! switch old values
+         IF(kiter > 0 ) THEN
+            u_ice_oe(:,:,1) =  u_ice_oe(:,:,2)
+            v_ice_oe(:,:,1) =  v_ice_oe(:,:,2)
+            u_ice_sn(:,:,1) =  u_ice_sn(:,:,2)
+            v_ice_sn(:,:,1) =  v_ice_sn(:,:,2)
+         ENDIF
+         ! interpolation of boundaries
+         Agrif_SpecialValue=-9999.
+         Agrif_UseSpecialValue = .TRUE.
+         zuice = 0.
+         zvice = 0.
+         CALL Agrif_Bc_variable(zuice,u_ice_id,procname=interp_u_ice, calledweight=1.)
+         CALL Agrif_Bc_variable(zvice,v_ice_id,procname=interp_v_ice, calledweight=1.)
+         Agrif_SpecialValue=0.
+         Agrif_UseSpecialValue = .FALSE.
+         !  
+         zrhox = agrif_rhox() ;    zrhoy = agrif_rhoy()      
+         zuice(:,:) =  zuice(:,:)/(zrhoy*e2u(:,:))*umask(:,:,1)
+         zvice(:,:) =  zvice(:,:)/(zrhox*e1v(:,:))*vmask(:,:,1)
+         ! fill  boundaries
+         DO jj = 1, jpj
+         DO ji = 1, 2
+            u_ice_oe(ji,jj,2) = zuice(ji,jj) ;  u_ice_oe(ji+2,jj,2) =  zuice(nlci+ji-3,jj)
+         END DO
+         END DO
+         DO jj = 1, jpj
+            v_ice_oe(  2,jj,2) = zvice(  2,jj) ;  v_ice_oe(  4,jj,2) =  zvice(       nlci-1,jj)
+         END DO
+         DO ji = 1, jpi
+            u_ice_sn( ji,2,2) = zuice(ji,  2) ;  u_ice_sn( ji,4,2) =  zuice(ji,       nlcj-1)
+         END DO
+         DO jj = 1, 2
+         DO ji = 1, jpi
+            v_ice_sn(ji,jj,2) = zvice(ji,jj) ;  v_ice_sn(ji,jj+2,2) =  zvice(ji,nlcj+jj-3)
+         END DO
+         END DO
+         !
+         IF(kiter == 0 ) THEN
+            u_ice_oe(:,:,1) =  u_ice_oe(:,:,2)
+            v_ice_oe(:,:,1) =  v_ice_oe(:,:,2)
+            u_ice_sn(:,:,1) =  u_ice_sn(:,:,2)
+            v_ice_sn(:,:,1) =  v_ice_sn(:,:,2)
+         ENDIF
+         !`
+         DEALLOCATE( zuice, zvice )
+         !
+      ENDIF 
+
+      alpha = (childfreq ) / Agrif_Rhot()
+      beta  = REAL(kiter,wp) / kitermax
+      beta = alpha * beta
+!RB   beta = 1 to put constant values on boundaries during EVP time-splitting    
+!      beta=1
+      SELECT CASE(cd_type)
+      CASE('U')
+         CALL ParcoursU(beta)
+      CASE('V')
+         CALL ParcoursV(beta)
+      END SELECT
+      !
+   END SUBROUTINE agrif_dyn_lim
+
+
+   SUBROUTINE ParcoursU( pbeta )
+      !!-----------------------------------------------------------------------
+      !!                    *** ROUTINE parcoursU ***
+      !!-----------------------------------------------------------------------
+      REAL(wp), INTENT(in) :: pbeta
+      !!
+      INTEGER :: ji, jj
+      !!-----------------------------------------------------------------------
+      !
+      IF((nbondi == -1).OR.(nbondi == 2)) THEN
+         DO jj=1,jpj
+         DO ji=1,2
+            u_ice(ji,jj) = (1-pbeta) * u_ice_oe(ji,jj,1) + pbeta * u_ice_oe(ji,jj,2)
+         END DO
+         END DO
+         DO jj=1,jpj
+            u_ice(2,jj) = 0.25*(u_ice(1,jj)+2.*u_ice(2,jj)+u_ice(3,jj))
+            u_ice(2,jj) = u_ice(2,jj) * umask(2,jj,1)
+         END DO
+      ENDIF
+
+      IF((nbondi == 1).OR.(nbondi == 2)) THEN
+         DO jj=1,jpj
+         DO ji=1,2
+            u_ice(nlci+ji-3,jj) = (1-pbeta) * u_ice_oe(ji+2,jj,1) + pbeta * u_ice_oe(ji+2,jj,2)
+         END DO
+         END DO
+         DO jj=1,jpj
+            u_ice(nlci-2,jj) = 0.25*(u_ice(nlci-3,jj)+2.*u_ice(nlci-2,jj)+u_ice(nlci-1,jj))
+            u_ice(nlci-2,jj) = u_ice(nlci-2,jj) * umask(nlci-2,jj,1)
+         END DO
+      ENDIF
+
+      IF((nbondj == -1).OR.(nbondj == 2)) THEN
+         DO ji=1,jpi
+            u_ice(ji,2) = (1-pbeta) * u_ice_sn(ji,2,1) + pbeta * u_ice_sn(ji,2,2)
+            u_ice(ji,2) = u_ice(ji,2)*umask(ji,2,1)
+         END DO
+      ENDIF
+
+      IF((nbondj == 1).OR.(nbondj == 2)) THEN
+         DO ji=1,jpi
+            u_ice(ji,nlcj-1) = (1-pbeta) * u_ice_sn(ji,4,1) + pbeta * u_ice_sn(ji,4,2)
+            u_ice(ji,nlcj-1) = u_ice(ji,nlcj-1)*umask(ji,nlcj-1,1)
+         END DO
+      ENDIF
+      !
+   END SUBROUTINE ParcoursU
+
+
+   SUBROUTINE ParcoursV( pbeta )
+      !!-----------------------------------------------------------------------
+      !!                    *** ROUTINE parcoursV ***
+      !!-----------------------------------------------------------------------
+      REAL(wp), INTENT(in) :: pbeta
+      !!
+      INTEGER :: ji, jj
+      !!-----------------------------------------------------------------------
+      !
+      IF((nbondi == -1).OR.(nbondi == 2)) THEN
+        DO jj=1,jpj
+            v_ice(2,jj) = (1-pbeta) * v_ice_oe(2,jj,1) + pbeta * v_ice_oe(2,jj,2)
+            v_ice(2,jj) = v_ice(2,jj) * vmask(2,jj,1)
+         END DO
+      ENDIF
+
+      IF((nbondi == 1).OR.(nbondi == 2)) THEN
+        DO jj=1,jpj
+            v_ice(nlci-1,jj) = (1-pbeta) * v_ice_oe(4,jj,1) + pbeta * v_ice_oe(4,jj,2)
+            v_ice(nlci-1,jj) = v_ice(nlci-1,jj)*vmask(nlci-1,jj,1)
+         END DO
+      ENDIF
+
+      IF((nbondj == -1).OR.(nbondj == 2)) THEN
+         DO jj=1,2
+         DO ji=1,jpi
+            v_ice(ji,jj) = (1-pbeta) * v_ice_sn(ji,jj,1) + pbeta * v_ice_sn(ji,jj,2)
+         END DO
+         END DO
+         DO ji=1,jpi
+            v_ice(ji,2)=0.25*(v_ice(ji,1)+2.*v_ice(ji,2)+v_ice(ji,3))
+            v_ice(ji,2)=v_ice(ji,2)*vmask(ji,2,1)
+         END DO
+      ENDIF
+
+      IF((nbondj == 1).OR.(nbondj == 2)) THEN
+         DO jj=1,2
+         DO ji=1,jpi
+            v_ice(ji,nlcj+jj-3) = (1-pbeta) * v_ice_sn(ji,jj+2,1) + pbeta * v_ice_sn(ji,jj+2,2)
+         END DO
+         END DO
+         DO ji=1,jpi
+            v_ice(ji,nlcj-2)=0.25*(v_ice(ji,nlcj-3)+2.*v_ice(ji,nlcj-2)+v_ice(ji,nlcj-1))
+            v_ice(ji,nlcj-2) = v_ice(ji,nlcj-2) * vmask(ji,nlcj-2,1)
+         END DO
+      ENDIF
+      !
+   END SUBROUTINE ParcoursV
+# endif
+
+   SUBROUTINE agrif_adv_lim2( kt )
+      !!-----------------------------------------------------------------------
+      !!                  *** ROUTINE agrif_adv_lim2 ***
+      !!-----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kt
+      !!
+      INTEGER :: jk
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: ztab 
+      !!-----------------------------------------------------------------------      
+      !
+      IF (Agrif_Root()) RETURN
+
+      ALLOCATE( ztab(jpi,jpj,7) )
+
+      ztab(:,:,:) = 0.
+      Agrif_SpecialValue=-9999.
+      Agrif_UseSpecialValue = .TRUE.
+      CALL Agrif_Bc_variable( ztab, adv_ice_id ,procname=interp_adv_ice, calledweight=1. )
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = .FALSE.
+      !
+
+      CALL parcoursT( ztab(:,:, 1), frld  )
+      CALL parcoursT( ztab(:,:, 2), hicif )
+      CALL parcoursT( ztab(:,:, 3), hsnif )
+      CALL parcoursT( ztab(:,:, 4), tbif(:,:,1) )
+      CALL parcoursT( ztab(:,:, 5), tbif(:,:,2) )
+      CALL parcoursT( ztab(:,:, 6), tbif(:,:,3) )
+      CALL parcoursT( ztab(:,:, 7), qstoif )
+      !
+      DEALLOCATE( ztab )
+      !
+   END SUBROUTINE agrif_adv_lim2
+
+
+   SUBROUTINE agrif_sadv_lim2( kt )
+      !!-----------------------------------------------------------------------
+      !!                  *** ROUTINE agrif_sadv_lim2 ***
+      !!-----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kt
+      !!
+      INTEGER :: jk
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: ztab
+      !!-----------------------------------------------------------------------      
+      !
+      IF (Agrif_Root()) RETURN
+
+      ALLOCATE( ztab(jpi,jpj,42) )
+
+      ztab(:,:,:) = 0.
+      Agrif_SpecialValue=-9999.
+      Agrif_UseSpecialValue = .TRUE.
+      CALL Agrif_Bc_variable( ztab, sadv_ice_id ,procname=interp_sadv_ice, calledweight=1. )
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = .FALSE.
+      !
+      DO jk = 1, 42
+         ztab(:,:,jk) = ztab(:,:,jk) * area(:,:)
+      END DO
+
+      CALL parcoursT( ztab(:,:, 1), sxice  )
+      CALL parcoursT( ztab(:,:, 2), syice  )
+      CALL parcoursT( ztab(:,:, 3), sxxice )
+      CALL parcoursT( ztab(:,:, 4), syyice )
+      CALL parcoursT( ztab(:,:, 5), sxyice )
+      CALL parcoursT( ztab(:,:, 6), sxa    )
+      CALL parcoursT( ztab(:,:, 7), sya    )
+      CALL parcoursT( ztab(:,:, 8), sxxa   )
+      CALL parcoursT( ztab(:,:, 9), syya   )
+      CALL parcoursT( ztab(:,:,10), sxya   )
+      CALL parcoursT( ztab(:,:,11), sxsn   )
+      CALL parcoursT( ztab(:,:,12), sysn   )
+      CALL parcoursT( ztab(:,:,13), sxxsn  )
+      CALL parcoursT( ztab(:,:,14), syysn  )
+      CALL parcoursT( ztab(:,:,15), sxysn  )
+      CALL parcoursT( ztab(:,:,16), sxc0   )
+      CALL parcoursT( ztab(:,:,17), syc0   )
+      CALL parcoursT( ztab(:,:,18), sxxc0  )
+      CALL parcoursT( ztab(:,:,19), syyc0  )
+      CALL parcoursT( ztab(:,:,20), sxyc0  )
+      CALL parcoursT( ztab(:,:,21), sxc1   )
+      CALL parcoursT( ztab(:,:,22), syc1   )
+      CALL parcoursT( ztab(:,:,23), sxxc1  )
+      CALL parcoursT( ztab(:,:,24), syyc1  )
+      CALL parcoursT( ztab(:,:,25), sxyc1  )
+      CALL parcoursT( ztab(:,:,26), sxc2   )
+      CALL parcoursT( ztab(:,:,27), syc2   )
+      CALL parcoursT( ztab(:,:,28), sxxc2  )
+      CALL parcoursT( ztab(:,:,29), syyc2  )
+      CALL parcoursT( ztab(:,:,30), sxyc2  )
+      CALL parcoursT( ztab(:,:,31), sxst   )
+      CALL parcoursT( ztab(:,:,32), syst   )
+      CALL parcoursT( ztab(:,:,33), sxxst  )
+      CALL parcoursT( ztab(:,:,34), syyst  )
+      CALL parcoursT( ztab(:,:,35), sxyst  )
+
+      CALL parcoursT( ztab(:,:,36), s0ice  )
+      CALL parcoursT( ztab(:,:,37), s0a  )
+      CALL parcoursT( ztab(:,:,38), s0sn  )
+      CALL parcoursT( ztab(:,:,39), s0c0  )
+      CALL parcoursT( ztab(:,:,40), s0c1  )
+      CALL parcoursT( ztab(:,:,41), s0c2  )
+      CALL parcoursT( ztab(:,:,42), s0st  )
+      !
+      DEALLOCATE( ztab )
+      !
+   END SUBROUTINE agrif_sadv_lim2
+
+
+   SUBROUTINE parcoursT ( pinterp, pfinal )
+      !!-----------------------------------------------------------------------
+      !!                    *** ROUTINE parcoursT ***
+      !!-----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in)    :: pinterp
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pfinal
+      !!
+      INTEGER :: ji, jj
+      REAL(wp) :: zrho
+      REAL(wp) :: zbound, zvbord
+      REAL(wp) :: alpha1, alpha2, alpha3, alpha4
+      REAL(wp) :: alpha5, alpha6, alpha7
+      REAL(wp), DIMENSION(:,:), ALLOCATABLE :: zui_u, zvi_v
+      !!-----------------------------------------------------------------------
+      !
+      ALLOCATE( zui_u(jpi,jpj) ,zvi_v(jpi,jpj) )
+
+      zrho = Agrif_Rhox()
+      alpha1 = ( zrho -1. ) / 2.
+      alpha2 = 1. - alpha1
+      alpha3 = ( zrho - 1 ) / ( zrho + 1 )
+      alpha4 = 1. - alpha3
+      alpha6 = 2. * ( zrho -1. ) / ( zrho + 1. )
+      alpha7 = -( zrho -1 ) / ( zrho + 3 )
+      alpha5 = 1. - alpha6 - alpha7
+
+      zui_u = 0.e0
+      zvi_v = 0.e0
+      ! zvbord factor between 1 and 2 to take into account slip or no-slip boundary conditions.        
+      zbound=0.
+      zvbord = 1.0 + ( 1.0 - zbound )
+#if defined key_lim2_vp
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+            zui_u(ji,jj) = ( u_ice(ji+1,jj  ) + u_ice(ji+1,jj+1) ) / ( MAX( tmu(ji+1,jj  ) + tmu(ji+1,jj+1), zvbord ) )
+            zvi_v(ji,jj) = ( v_ice(ji  ,jj+1) + v_ice(ji+1,jj+1) ) / ( MAX( tmu(ji  ,jj+1) + tmu(ji+1,jj+1), zvbord ) )
+         END DO
+      END DO
+#else
+      zui_u(:,:) = u_ice(:,:)
+      zvi_v(:,:) = v_ice(:,:)
+#endif
+
+      IF((nbondi == 1).OR.(nbondi == 2)) THEN
+         pfinal (nlci,:) = alpha1 * pinterp(nlci,:) + alpha2 * pinterp(nlci-1,:)
+         DO jj=1,jpj
+            IF (umask(nlci-2,jj,1).EQ.0.) THEN
+               pfinal (nlci-1,jj) = pfinal (nlci,jj) * tms(nlci-1,jj)
+            ELSE
+               pfinal (nlci-1,jj)=(alpha4*pfinal (nlci,jj)+alpha3*pfinal (nlci-2,jj))*tms(nlci-1,jj)
+               IF (zui_u(nlci-2,jj).GT.0.) THEN
+         	  pfinal(nlci-1,jj)=( alpha6*pfinal (nlci-2,jj)+alpha5*pfinal (nlci,jj)  &
+         			    + alpha7*pfinal (nlci-3,jj) ) * tms(nlci-1,jj)
+               ENDIF
+            ENDIF
+         END DO
+      ENDIF
+
+      IF((nbondj == 1).OR.(nbondj == 2)) THEN
+         pfinal (:,nlcj) = alpha1 * pinterp(:,nlcj) + alpha2 * pinterp(:,nlcj-1)
+         DO ji=1,jpi
+            IF (vmask(ji,nlcj-2,1).EQ.0.) THEN
+               pfinal (ji,nlcj-1) =  pfinal(ji,nlcj) * tms(ji,nlcj-1)
+            ELSE
+               pfinal (ji,nlcj-1)=(alpha4*pfinal (ji,nlcj)+alpha3*pfinal (ji,nlcj-2))*tms(ji,nlcj-1)
+               IF (zvi_v(ji,nlcj-2) .GT. 0.) THEN
+         	  pfinal (ji,nlcj-1)=( alpha6*pfinal (ji,nlcj-2)+alpha5*pfinal (ji,nlcj)  &
+         			    + alpha7*pfinal (ji,nlcj-3) ) * tms(ji,nlcj-1)
+               ENDIF
+            ENDIF
+         END DO
+      ENDIF
+
+      IF((nbondi == -1).OR.(nbondi == 2)) THEN
+         pfinal (1,:) = alpha1 * pinterp(1,:) + alpha2 * pinterp(2,:)
+         DO jj=1,jpj
+            IF (umask(2,jj,1).EQ.0.) THEN
+               pfinal (2,jj) = pfinal (1,jj) * tms(2,jj)
+            ELSE
+               pfinal (2,jj)=(alpha4*pfinal (1,jj)+alpha3*pfinal (3,jj))*tms(2,jj)	   
+              IF (zui_u(2,jj).LT.0.) THEN
+         	  pfinal (2,jj)=(alpha6*pfinal (3,jj)+alpha5*pfinal (1,jj)+alpha7*pfinal (4,jj))*tms(2,jj)
+               ENDIF
+            ENDIF
+         END DO
+      ENDIF
+
+      IF((nbondj == -1).OR.(nbondj == 2)) THEN
+         pfinal (:,1) = alpha1 * pinterp(:,1) + alpha2 * pinterp(:,2)
+         DO ji=1,jpi
+            IF (vmask(ji,2,1).EQ.0.) THEN
+               pfinal (ji,2) = pfinal (ji,1) * tms(ji,2)
+            ELSE
+               pfinal (ji,2)=(alpha4*pfinal (ji,1)+alpha3*pfinal (ji,3))*tms(ji,2)	   
+               IF (zvi_v(ji,2) .LT. 0.) THEN
+         	  pfinal (ji,2)=(alpha6*pfinal (ji,3)+alpha5*pfinal (ji,1)+alpha7*pfinal (ji,4))*tms(ji,2)
+               ENDIF
+            ENDIF
+         END DO
+      ENDIF
+
+      pfinal (:,:) = pfinal (:,:) * tms(:,:)
+      ! 
+   END SUBROUTINE parcoursT
+
+
+   SUBROUTINE interp_u_ice( tabres, i1, i2, j1, j2 )
+      !!-----------------------------------------------------------------------
+      !!                     *** ROUTINE interp_u_ice ***
+      !!-----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: i1, i2, j1, j2
+      REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) :: tabres
+      !!
+      INTEGER :: ji,jj
+      !!-----------------------------------------------------------------------
+      !
+#if defined key_lim2_vp
+      DO jj=MAX(j1,2),j2
+         DO ji=MAX(i1,2),i2
+            IF( tmu(ji,jj) == 0. ) THEN
+               tabres(ji,jj) = -9999.
+            ELSE
+               tabres(ji,jj) = e2f(ji-1,jj-1) * u_ice(ji,jj)
+            ENDIF
+         END DO
+      END DO
+#else
+      DO jj= j1, j2
+         DO ji= i1, i2
+            IF( umask(ji,jj,1) == 0. ) THEN
+               tabres(ji,jj) = -9999.
+            ELSE
+               tabres(ji,jj) = e2u(ji,jj) * u_ice(ji,jj)
+            ENDIF
+         END DO
+      END DO
+#endif
+   END SUBROUTINE interp_u_ice
+
+
+   SUBROUTINE interp_v_ice( tabres, i1, i2, j1, j2 )
+      !!-----------------------------------------------------------------------
+      !!                    *** ROUTINE interp_v_ice ***
+      !!-----------------------------------------------------------------------      
+      INTEGER, INTENT(in) :: i1, i2, j1, j2
+      REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) :: tabres
+      !!
+      INTEGER :: ji, jj
+      !!-----------------------------------------------------------------------
+      !
+#if defined key_lim2_vp
+      DO jj=MAX(j1,2),j2
+         DO ji=MAX(i1,2),i2
+            IF( tmu(ji,jj) == 0. ) THEN
+               tabres(ji,jj) = -9999.
+            ELSE
+               tabres(ji,jj) = e1f(ji-1,jj-1) * v_ice(ji,jj)
+            ENDIF
+         END DO
+      END DO
+#else
+      DO jj= j1 ,j2
+         DO ji = i1, i2
+            IF( vmask(ji,jj,1) == 0. ) THEN
+               tabres(ji,jj) = -9999.
+            ELSE
+               tabres(ji,jj) = e1v(ji,jj) * v_ice(ji,jj)
+            ENDIF
+         END DO
+      END DO
+#endif
+   END SUBROUTINE interp_v_ice
+
+
+   SUBROUTINE interp_adv_ice( tabres, i1, i2, j1, j2 )
+      !!-----------------------------------------------------------------------
+      !!                    *** ROUTINE interp_adv_ice ***                           
+      !!
+      !! ** Purpose : fill an array with  ice variables
+      !!              to be advected
+      !!              put -9999 where no ice for correct extrapolation             
+      !!-----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: i1, i2, j1, j2
+      REAL(wp), DIMENSION(i1:i2,j1:j2,7), INTENT(inout) :: tabres
+      !!
+      INTEGER :: ji, jj, jk
+      !!-----------------------------------------------------------------------
+      !
+      DO jj=j1,j2
+         DO ji=i1,i2
+            IF( tms(ji,jj) == 0. ) THEN
+               tabres(ji,jj,:) = -9999. 
+            ELSE
+               tabres(ji,jj, 1) = frld  (ji,jj)
+               tabres(ji,jj, 2) = hicif (ji,jj)
+               tabres(ji,jj, 3) = hsnif (ji,jj)
+               tabres(ji,jj, 4) = tbif  (ji,jj,1)
+               tabres(ji,jj, 5) = tbif  (ji,jj,2)
+               tabres(ji,jj, 6) = tbif  (ji,jj,3)
+               tabres(ji,jj, 7) = qstoif(ji,jj)
+            ENDIF
+         END DO
+      END DO
+      !
+   END SUBROUTINE interp_adv_ice
+
+
+   SUBROUTINE interp_sadv_ice( tabres, i1, i2, j1, j2 )
+      !!-----------------------------------------------------------------------
+      !!                 *** ROUTINE interp_sadv_ice ***   
+      !!
+      !! ** Purpose : fill an array with superior moements of ice variables
+      !!              to be advected
+      !!              put -9990 where no ice for correct extrapolation             
+      !!-----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: i1, i2, j1, j2
+      REAL(wp), DIMENSION(i1:i2,j1:j2,42), INTENT(inout) :: tabres
+      !!
+      INTEGER :: ji, jj, jk
+      REAL(wp) :: z1_area
+      !!-----------------------------------------------------------------------
+      !
+      DO jj=j1,j2
+         DO ji=i1,i2
+            IF( tms(ji,jj) == 0. ) THEN
+               tabres(ji,jj,:) = -9999. 
+            ELSE
+               z1_area = 1. / area(ji,jj)
+               tabres(ji,jj, 1) = sxice (ji,jj) * z1_area
+               tabres(ji,jj, 2) = syice (ji,jj) * z1_area  
+               tabres(ji,jj, 3) = sxxice(ji,jj) * z1_area
+               tabres(ji,jj, 4) = syyice(ji,jj) * z1_area
+               tabres(ji,jj, 5) = sxyice(ji,jj) * z1_area
+               tabres(ji,jj, 6) = sxa   (ji,jj) * z1_area
+               tabres(ji,jj, 7) = sya   (ji,jj) * z1_area
+               tabres(ji,jj, 8) = sxxa  (ji,jj) * z1_area
+               tabres(ji,jj, 9) = syya  (ji,jj) * z1_area
+               tabres(ji,jj,10) = sxya  (ji,jj) * z1_area
+               tabres(ji,jj,11) = sxsn  (ji,jj) * z1_area
+               tabres(ji,jj,12) = sysn  (ji,jj) * z1_area
+               tabres(ji,jj,13) = sxxsn (ji,jj) * z1_area
+               tabres(ji,jj,14) = syysn (ji,jj) * z1_area
+               tabres(ji,jj,15) = sxysn (ji,jj) * z1_area
+               tabres(ji,jj,16) = sxc0  (ji,jj) * z1_area
+               tabres(ji,jj,17) = syc0  (ji,jj) * z1_area
+               tabres(ji,jj,18) = sxxc0 (ji,jj) * z1_area
+               tabres(ji,jj,19) = syyc0 (ji,jj) * z1_area
+               tabres(ji,jj,20) = sxyc0 (ji,jj) * z1_area
+               tabres(ji,jj,21) = sxc1  (ji,jj) * z1_area
+               tabres(ji,jj,22) = syc1  (ji,jj) * z1_area
+               tabres(ji,jj,23) = sxxc1 (ji,jj) * z1_area
+               tabres(ji,jj,24) = syyc1 (ji,jj) * z1_area
+               tabres(ji,jj,25) = sxyc1 (ji,jj) * z1_area
+               tabres(ji,jj,26) = sxc2  (ji,jj) * z1_area
+               tabres(ji,jj,27) = syc2  (ji,jj) * z1_area
+               tabres(ji,jj,28) = sxxc2 (ji,jj) * z1_area
+               tabres(ji,jj,29) = syyc2 (ji,jj) * z1_area
+               tabres(ji,jj,30) = sxyc2 (ji,jj) * z1_area
+               tabres(ji,jj,31) = sxst  (ji,jj) * z1_area
+               tabres(ji,jj,32) = syst  (ji,jj) * z1_area
+               tabres(ji,jj,33) = sxxst (ji,jj) * z1_area
+               tabres(ji,jj,34) = syyst (ji,jj) * z1_area
+               tabres(ji,jj,35) = sxyst (ji,jj) * z1_area
+
+               tabres(ji,jj,36) = s0ice (ji,jj)! * z1_area
+               tabres(ji,jj,37) = s0a   (ji,jj)! * z1_area
+               tabres(ji,jj,38) = s0sn  (ji,jj)! * z1_area
+               tabres(ji,jj,39) = s0c0  (ji,jj)! * z1_area
+               tabres(ji,jj,40) = s0c1  (ji,jj)! * z1_area
+               tabres(ji,jj,41) = s0c2  (ji,jj)! * z1_area
+               tabres(ji,jj,42) = s0st  (ji,jj)! * z1_area
+            ENDIF
+         END DO
+      END DO
+      !
+   END SUBROUTINE interp_sadv_ice
+
+#else
+CONTAINS
+   SUBROUTINE agrif_lim2_interp_empty
+      !!---------------------------------------------
+      !!   *** ROUTINE agrif_lim2_interp_empty ***
+      !!---------------------------------------------
+      WRITE(*,*)  'agrif_lim2_interp : You should not have seen this print! error?'
+   END SUBROUTINE agrif_lim2_interp_empty
+#endif
+END MODULE agrif_lim2_interp
Index: /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_lim2_update.F90
===================================================================
--- /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_lim2_update.F90	(revision 2804)
+++ /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_lim2_update.F90	(revision 2804)
@@ -0,0 +1,361 @@
+#define TWO_WAY
+
+MODULE agrif_lim2_update
+   !!======================================================================
+   !!                       ***  MODULE agrif_lim2_update ***
+   !! Nesting module :  update surface ocean boundary condition over ice
+   !!                   from a child grif
+   !! Sea-Ice model  :  LIM 2.0 Sea ice model time-stepping
+   !!======================================================================
+   !! History :  2.0   !  04-2008  (F. Dupont)  initial version
+   !!            3.2   !  09-2010  (R. Benshila, C. Herbaut) update and EVP
+   !!----------------------------------------------------------------------
+#if defined key_agrif && defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'  :                                 LIM 2.0 sea-ice model
+   !!   'key_agrif' :                                 AGRIF library 
+   !!----------------------------------------------------------------------
+   !!   agrif_update_lim2  : update sea-ice model on boundaries or total
+   !!                        sea-ice area
+   !!----------------------------------------------------------------------
+   USE ice_2
+   USE dom_ice_2
+   USE sbc_oce
+   USE dom_oce
+   USE agrif_oce
+   USE agrif_ice 
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC agrif_update_lim2
+
+   !!----------------------------------------------------------------------
+   !! NEMO/NST 3.2 , LOCEAN-IPSL (2010)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE agrif_update_lim2 ( kt )
+      !!----------------------------------------------------------------------
+      !!   *** ROUTINE agrif_update_lim2 ***
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kt
+      !!
+      REAL(wp), DIMENSION(:,:)  , ALLOCATABLE :: zvel
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: zadv, zsadv
+      !!----------------------------------------------------------------------
+      !
+      IF((Agrif_NbStepint() .NE. (Agrif_irhot()-1)).AND.(kt /= 0)) RETURN
+
+      Agrif_UseSpecialValueInUpdate = .TRUE.
+      Agrif_SpecialValueFineGrid = 0.
+
+# if defined TWO_WAY
+      ALLOCATE( zvel(jpi,jpj), zadv(jpi,jpj,7), zsadv(jpi,jpj,42) )
+
+      IF( MOD(nbcline,nbclineupdate) == 0) THEN
+         CALL Agrif_Update_Variable( zadv , adv_ice_id , procname = update_adv_ice  )
+         CALL Agrif_Update_Variable( zsadv, sadv_ice_id, procname = update_sadv_ice )
+         CALL Agrif_Update_Variable( zvel , u_ice_id   , procname = update_u_ice    )
+         CALL Agrif_Update_Variable( zvel , v_ice_id   , procname = update_v_ice    )
+      ELSE
+         CALL Agrif_Update_Variable( zadv , adv_ice_id , locupdate=(/0,2/), procname = update_adv_ice  )
+         CALL Agrif_Update_Variable( zsadv, sadv_ice_id, locupdate=(/0,2/), procname = update_sadv_ice ) 
+         CALL Agrif_Update_Variable( zvel , u_ice_id   , locupdate=(/0,1/), procname = update_u_ice    )
+         CALL Agrif_Update_Variable( zvel , v_ice_id   , locupdate=(/0,1/), procname = update_v_ice    )
+      ENDIF
+
+      DEALLOCATE( zvel, zadv, zsadv )
+# endif
+      !
+   END SUBROUTINE agrif_update_lim2
+
+
+   SUBROUTINE update_adv_ice( tabres, i1, i2, j1, j2, before )
+      !!-----------------------------------------------------------------------
+      !!                         *** ROUTINE update_adv_ice ***
+      !!-----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: i1, i2, j1, j2
+      REAL(wp), DIMENSION(i1:i2,j1:j2,7), INTENT(inout) :: tabres
+      LOGICAL, INTENT(in) :: before
+      !!
+      INTEGER :: ji, jj
+      REAL(wp) :: zrhox, zrhoy
+      REAL(wp) :: z1_area
+      !!-----------------------------------------------------------------------
+      !
+      IF( before ) THEN
+         zrhox = Agrif_Rhox()
+         zrhoy = Agrif_Rhoy()
+         DO jj=j1,j2
+            DO ji=i1,i2
+               tabres(ji,jj, 1) = frld  (ji,jj) * area(ji,jj)
+               tabres(ji,jj, 2) = hicif (ji,jj) * area(ji,jj)
+               tabres(ji,jj, 3) = hsnif (ji,jj) * area(ji,jj)
+               tabres(ji,jj, 4) = tbif  (ji,jj,1) * area(ji,jj)
+               tabres(ji,jj, 5) = tbif  (ji,jj,2) * area(ji,jj)
+               tabres(ji,jj, 6) = tbif  (ji,jj,3) * area(ji,jj)
+               tabres(ji,jj, 7) = qstoif(ji,jj) * area(ji,jj)
+            END DO
+         END DO
+         tabres = zrhox * zrhoy * tabres
+      ELSE
+         DO jj=j1,j2
+            DO ji=i1,i2
+               z1_area = 1. / area(ji,jj) * tms(ji,jj)
+               frld  (ji,jj)   = tabres(ji,jj, 1) * z1_area
+               hicif (ji,jj)   = tabres(ji,jj, 2) * z1_area
+               hsnif (ji,jj)   = tabres(ji,jj, 3) * z1_area
+               tbif  (ji,jj,1) = tabres(ji,jj, 4) * z1_area
+               tbif  (ji,jj,2) = tabres(ji,jj, 5) * z1_area
+               tbif  (ji,jj,3) = tabres(ji,jj, 6) * z1_area
+               qstoif(ji,jj)   = tabres(ji,jj, 7) * z1_area
+            END DO
+         END DO
+      ENDIF
+
+   END SUBROUTINE update_adv_ice
+
+#if defined key_lim2_vp
+   SUBROUTINE update_u_ice( tabres, i1, i2, j1, j2, before )
+      !!-----------------------------------------------------------------------
+      !!                        *** ROUTINE update_u_ice ***
+      !!-----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: i1, i2, j1, j2
+      REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) :: tabres
+      LOGICAL, INTENT(in) :: before
+      !!
+      INTEGER :: ji, jj
+      REAL(wp) :: zrhoy
+      !!-----------------------------------------------------------------------
+      !
+      IF( before ) THEN
+         zrhoy = Agrif_Rhoy()
+         DO jj=MAX(j1,2),j2
+            DO ji=MAX(i1,2),i2
+               tabres(ji,jj) = e2f(ji-1,jj-1) * u_ice(ji,jj)
+            END DO
+         END DO
+         tabres = zrhoy * tabres
+      ELSE
+         DO jj= MAX(j1,2),j2
+            DO ji=MAX(i1,2),i2
+               u_ice(ji,jj) = tabres(ji,jj) / (e2f(ji-1,jj-1))
+               u_ice(ji,jj) = u_ice(ji,jj) * tmu(ji,jj)
+            END DO
+         END DO
+      ENDIF
+      !
+   END SUBROUTINE update_u_ice
+
+
+   SUBROUTINE update_v_ice( tabres, i1, i2, j1, j2, before )
+      !!-----------------------------------------------------------------------
+      !!                    *** ROUTINE update_v_ice ***
+      !!-----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: i1,i2,j1,j2
+      REAL(wp), DIMENSION(i1:i2,j1:j2),  INTENT(inout) :: tabres
+      LOGICAL, INTENT(in) :: before
+      !!
+      INTEGER :: ji, jj
+      REAL(wp) :: zrhox
+      !!-----------------------------------------------------------------------
+      !
+      IF( before ) THEN
+         zrhox = Agrif_Rhox()
+         DO jj=MAX(j1,2),j2
+            DO ji=MAX(i1,2),i2
+               tabres(ji,jj) = e1f(ji-1,jj-1) * v_ice(ji,jj)
+            END DO
+         END DO
+         tabres = zrhox * tabres
+      ELSE
+         DO jj=j1,j2
+            DO ji=i1,i2
+               v_ice(ji,jj) = tabres(ji,jj) / (e1f(ji-1,jj-1))
+               v_ice(ji,jj) = v_ice(ji,jj) * tmu(ji,jj)
+            END DO
+         END DO
+      ENDIF
+      !
+   END SUBROUTINE update_v_ice
+#else
+   SUBROUTINE update_u_ice( tabres, i1, i2, j1, j2, before )
+      !!-----------------------------------------------------------------------
+      !!                        *** ROUTINE update_u_ice ***
+      !!-----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: i1, i2, j1, j2
+      REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) :: tabres
+      LOGICAL, INTENT(in) :: before
+      !!
+      INTEGER :: ji, jj
+      REAL(wp) :: zrhoy
+      !!-----------------------------------------------------------------------
+      !
+      IF( before ) THEN
+         zrhoy = Agrif_Rhoy()
+         DO jj=MAX(j1,2),j2
+            DO ji=MAX(i1,2),i2
+               tabres(ji,jj) = e2u(ji,jj) * u_ice(ji,jj)
+            END DO
+         END DO
+         tabres = zrhoy * tabres
+      ELSE
+         DO jj=MAX(j1,2),j2
+            DO ji=MAX(i1,2),i2
+               u_ice(ji,jj) = tabres(ji,jj) / (e2u(ji,jj))
+               u_ice(ji,jj) = u_ice(ji,jj) * tmu(ji,jj)
+            END DO
+         END DO
+      ENDIF
+      ! 
+   END SUBROUTINE update_u_ice
+
+
+   SUBROUTINE update_v_ice( tabres, i1, i2, j1, j2, before )
+      !!-----------------------------------------------------------------------
+      !!                    *** ROUTINE update_v_ice ***
+      !!-----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: i1,i2,j1,j2
+      REAL(wp), DIMENSION(i1:i2,j1:j2),  INTENT(inout) :: tabres
+      LOGICAL, INTENT(in) :: before
+      !!
+      INTEGER :: ji, jj
+      REAL(wp) :: zrhox
+      !!-----------------------------------------------------------------------
+      !
+      IF( before ) THEN
+         zrhox = Agrif_Rhox()
+         DO jj=MAX(j1,2),j2
+            DO ji=MAX(i1,2),i2
+               tabres(ji,jj) = e1v(ji,jj) * v_ice(ji,jj)
+            END DO
+         END DO
+         tabres = zrhox * tabres
+      ELSE
+         DO jj=j1,j2
+            DO ji=i1,i2
+               v_ice(ji,jj) = tabres(ji,jj) / (e1v(ji,jj))
+               v_ice(ji,jj) = v_ice(ji,jj) * tmv(ji,jj)
+            END DO
+         END DO
+      ENDIF
+      !
+   END SUBROUTINE update_v_ice
+#endif
+
+   SUBROUTINE update_sadv_ice( tabres, i1, i2, j1, j2, before )
+      !!-----------------------------------------------------------------------
+      !!                     *** ROUTINE update_sadv_ice ***
+      !!-----------------------------------------------------------------------
+      !!
+      INTEGER, INTENT(in) :: i1, i2, j1, j2
+      REAL(wp), DIMENSION(i1:i2,j1:j2,42), INTENT(inout) :: tabres
+      LOGICAL, INTENT(in) :: before
+      !!
+      INTEGER :: ji, jj
+      REAL(wp) :: zrhox, zrhoy, zarea, z1_area
+      !!-----------------------------------------------------------------------
+      !
+      IF( before ) THEN
+         zrhox = Agrif_Rhox()
+         zrhoy = Agrif_Rhoy()
+         DO jj=j1,j2
+            DO ji=i1,i2
+               zarea = area(ji,jj)
+               tabres(ji,jj, 1) = sxice (ji,jj) * zarea
+               tabres(ji,jj, 2) = syice (ji,jj) * zarea  
+               tabres(ji,jj, 3) = sxxice(ji,jj) * zarea
+               tabres(ji,jj, 4) = syyice(ji,jj) * zarea
+               tabres(ji,jj, 5) = sxyice(ji,jj) * zarea
+               tabres(ji,jj, 6) = sxa   (ji,jj) * zarea
+               tabres(ji,jj, 7) = sya   (ji,jj) * zarea
+               tabres(ji,jj, 8) = sxxa  (ji,jj) * zarea
+               tabres(ji,jj, 9) = syya  (ji,jj) * zarea
+               tabres(ji,jj,10) = sxya  (ji,jj) * zarea
+               tabres(ji,jj,11) = sxsn  (ji,jj) * zarea
+               tabres(ji,jj,12) = sysn  (ji,jj) * zarea
+               tabres(ji,jj,13) = sxxsn (ji,jj) * zarea
+               tabres(ji,jj,14) = syysn (ji,jj) * zarea
+               tabres(ji,jj,15) = sxysn (ji,jj) * zarea
+               tabres(ji,jj,16) = sxc0  (ji,jj) * zarea
+               tabres(ji,jj,17) = syc0  (ji,jj) * zarea
+               tabres(ji,jj,18) = sxxc0 (ji,jj) * zarea
+               tabres(ji,jj,19) = syyc0 (ji,jj) * zarea
+               tabres(ji,jj,20) = sxyc0 (ji,jj) * zarea
+               tabres(ji,jj,21) = sxc1  (ji,jj) * zarea
+               tabres(ji,jj,22) = syc1  (ji,jj) * zarea
+               tabres(ji,jj,23) = sxxc1 (ji,jj) * zarea
+               tabres(ji,jj,24) = syyc1 (ji,jj) * zarea
+               tabres(ji,jj,25) = sxyc1 (ji,jj) * zarea
+               tabres(ji,jj,26) = sxc2  (ji,jj) * zarea
+               tabres(ji,jj,27) = syc2  (ji,jj) * zarea
+               tabres(ji,jj,28) = sxxc2 (ji,jj) * zarea
+               tabres(ji,jj,29) = syyc2 (ji,jj) * zarea
+               tabres(ji,jj,30) = sxyc2 (ji,jj) * zarea
+               tabres(ji,jj,31) = sxst  (ji,jj) * zarea
+               tabres(ji,jj,32) = syst  (ji,jj) * zarea
+               tabres(ji,jj,33) = sxxst (ji,jj) * zarea
+               tabres(ji,jj,34) = syyst (ji,jj) * zarea
+               tabres(ji,jj,35) = sxyst (ji,jj) * zarea
+            END DO
+         END DO
+         tabres = zrhox * zrhoy * tabres
+      ELSE
+         DO jj=j1,j2
+            DO ji=i1,i2
+               z1_area = 1. / area(ji,jj) * tms(ji,jj)
+               sxice (ji,jj) =  tabres(ji,jj, 1) * z1_area
+               syice (ji,jj) = tabres(ji,jj, 2) * z1_area  
+               sxxice(ji,jj) = tabres(ji,jj, 3) * z1_area
+               syyice(ji,jj) = tabres(ji,jj, 4) * z1_area
+               sxyice(ji,jj) = tabres(ji,jj, 5) * z1_area
+               sxa   (ji,jj) = tabres(ji,jj, 6) * z1_area
+               sya   (ji,jj) = tabres(ji,jj, 7) * z1_area
+               sxxa  (ji,jj) = tabres(ji,jj, 8) * z1_area
+               syya  (ji,jj) = tabres(ji,jj, 9) * z1_area
+               sxya  (ji,jj) = tabres(ji,jj,10) * z1_area
+               sxsn  (ji,jj) = tabres(ji,jj,11) * z1_area
+               sysn  (ji,jj) = tabres(ji,jj,12) * z1_area
+               sxxsn (ji,jj) = tabres(ji,jj,13) * z1_area
+               syysn (ji,jj) = tabres(ji,jj,14) * z1_area
+               sxysn (ji,jj) = tabres(ji,jj,15) * z1_area
+               sxc0  (ji,jj) = tabres(ji,jj,16) * z1_area
+               syc0  (ji,jj) = tabres(ji,jj,17) * z1_area
+               sxxc0 (ji,jj) = tabres(ji,jj,18) * z1_area
+               syyc0 (ji,jj) = tabres(ji,jj,19) * z1_area
+               sxyc0 (ji,jj) = tabres(ji,jj,20) * z1_area
+               sxc1  (ji,jj) = tabres(ji,jj,21) * z1_area
+               syc1  (ji,jj) = tabres(ji,jj,22) * z1_area
+               sxxc1 (ji,jj) = tabres(ji,jj,23) * z1_area
+               syyc1 (ji,jj) = tabres(ji,jj,24) * z1_area
+               sxyc1 (ji,jj) = tabres(ji,jj,25) * z1_area
+               sxc2  (ji,jj) = tabres(ji,jj,26) * z1_area
+               syc2  (ji,jj) = tabres(ji,jj,27) * z1_area
+               sxxc2 (ji,jj) = tabres(ji,jj,28) * z1_area
+               syyc2 (ji,jj) = tabres(ji,jj,29) * z1_area
+               sxyc2 (ji,jj) = tabres(ji,jj,30) * z1_area
+               sxst  (ji,jj) = tabres(ji,jj,31) * z1_area
+               syst  (ji,jj) = tabres(ji,jj,32) * z1_area
+               sxxst (ji,jj) = tabres(ji,jj,33) * z1_area
+               syyst (ji,jj) = tabres(ji,jj,34) * z1_area
+               sxyst (ji,jj) = tabres(ji,jj,35) * z1_area
+            END DO
+         END DO
+      ENDIF
+
+   END SUBROUTINE update_sadv_ice
+
+#else
+CONTAINS
+   SUBROUTINE agrif_lim2_update_empty
+      !!---------------------------------------------
+      !!   *** ROUTINE agrif_lim2_update_empty ***
+      !!---------------------------------------------
+      WRITE(*,*)  'agrif_lim2_update : You should not have seen this print! error?'
+   END SUBROUTINE agrif_lim2_update_empty
+#endif
+END MODULE agrif_lim2_update
Index: /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_oce.F90
===================================================================
--- /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_oce.F90	(revision 2803)
+++ /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_oce.F90	(revision 2804)
@@ -29,4 +29,5 @@
    REAL(wp), PUBLIC ::   visc_dyn                  !: sponge coeff. for dynamics
 
+   INTEGER, PUBLIC :: nbcline = 0
    LOGICAL , PUBLIC :: spongedoneT = .FALSE.   !: tracer   sponge layer indicator
    LOGICAL , PUBLIC :: spongedoneU = .FALSE.   !: dynamics sponge layer indicator
@@ -35,8 +36,8 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE,  DIMENSION(:,:) ::   spe1ur2, spe2vr2, spbtr3   !: ???
    
-   INTEGER :: tn_id, sn_id, tb_id, sb_id, ta_id, sa_id
-   INTEGER :: un_id, vn_id, ua_id, va_id
-   INTEGER :: e1u_id, e2v_id, sshn_id, gcb_id
-   INTEGER :: trn_id, trb_id, tra_id
+   INTEGER, PUBLIC :: tn_id, sn_id, tb_id, sb_id, ta_id, sa_id
+   INTEGER, PUBLIC :: un_id, vn_id, ua_id, va_id
+   INTEGER, PUBLIC :: e1u_id, e2v_id, sshn_id, gcb_id
+   INTEGER, PUBLIC :: trn_id, trb_id, tra_id
 
    !!----------------------------------------------------------------------
Index: /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_opa_update.F90
===================================================================
--- /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_opa_update.F90	(revision 2803)
+++ /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_opa_update.F90	(revision 2804)
@@ -16,6 +16,4 @@
    PUBLIC Agrif_Update_Tra, Agrif_Update_Dyn
 
-   INTEGER, PUBLIC :: nbcline = 0
-
    !!----------------------------------------------------------------------
    !! NEMO/NST 3.3 , NEMO Consortium (2010)
Index: /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_user.F90
===================================================================
--- /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_user.F90	(revision 2803)
+++ /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/NST_SRC/agrif_user.F90	(revision 2804)
@@ -84,5 +84,8 @@
 # if ! defined key_offline
       CALL Agrif_InitValues_cont
-# endif       
+#  if defined key_lim2
+!      CALL Agrif_InitValues_cont_lim2
+#  endif       
+# endif
 # if defined key_top
       CALL Agrif_InitValues_cont_top
@@ -279,4 +282,111 @@
 
    END SUBROUTINE agrif_declare_var
+
+
+#  if defined key_lim2
+   SUBROUTINE Agrif_InitValues_cont_lim2
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE Agrif_InitValues_cont_lim2 ***
+      !!
+      !! ** Purpose :: Initialisation of variables to be interpolated for LIM2
+      !!----------------------------------------------------------------------
+      USE Agrif_Util
+      USE ice_2
+      USE in_out_manager
+      USE agrif_lim2_update
+      USE agrif_lim2_interp
+      USE lib_mpp 
+      !
+      IMPLICIT NONE
+      !
+      REAL(wp), DIMENSION(:,:)  , ALLOCATABLE :: zvel
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: zadv, zsadv
+      !!----------------------------------------------------------------------
+
+      ALLOCATE( zvel(jpi,jpj), zadv(jpi,jpj,7), zsadv(jpi,jpj,42) )
+      
+      ! 1. Declaration of the type of variable which have to be interpolated
+      !---------------------------------------------------------------------
+      CALL agrif_declare_var_lim2
+
+      ! 2. First interpolations of potentially non zero fields
+      !-------------------------------------------------------
+      Agrif_SpecialValue=-9999.
+      Agrif_UseSpecialValue = .TRUE.
+      Call Agrif_Bc_variable(zadv ,adv_ice_id ,calledweight=1.,procname=interp_adv_ice )    
+      Call Agrif_Bc_variable(zsadv,sadv_ice_id,calledweight=1.,procname=interp_sadv_ice)    
+      Call Agrif_Bc_variable(zvel ,u_ice_id   ,calledweight=1.,procname=interp_u_ice   )
+      Call Agrif_Bc_variable(zvel ,v_ice_id   ,calledweight=1.,procname=interp_v_ice   )
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = .FALSE.
+
+      ! 3. Some controls
+      !-----------------
+       
+#   if ! defined key_lim2_vp
+      childfreq = 1.
+      CALL agrif_dyn_lim(0 ,1 , 'V')
+      CALL agrif_dyn_lim(0 ,1 , 'U')
+      childfreq = 0.
+#   endif
+!RB mandatory but why ???
+      IF( nbclineupdate /= nn_fsbc .AND. nn_ice == 2 )THEN
+         CALL ctl_warn ('With ice model on child grid, nbclineupdate is set to nn_fsbc')
+         nbclineupdate = nn_fsbc
+       ENDIF
+      CALL Agrif_Update_lim2(0)
+      !
+      DEALLOCATE( zvel, zadv, zsadv )
+      !
+   END SUBROUTINE Agrif_InitValues_cont_lim2
+
+
+   SUBROUTINE agrif_declare_var_lim2
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE agrif_declare_var_lim2 ***
+      !!
+      !! ** Purpose :: Declaration of variables to be interpolated for LIM2
+      !!----------------------------------------------------------------------
+      USE agrif_util
+      USE ice_2
+
+      IMPLICIT NONE
+      !!----------------------------------------------------------------------
+   
+      ! 1. Declaration of the type of variable which have to be interpolated
+      !---------------------------------------------------------------------
+      CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj, 7/),adv_ice_id )         
+      CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,42/),sadv_ice_id)         
+#   if defined key_lim2_vp
+      CALL agrif_declare_variable((/1,1/),(/3,3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),u_ice_id)
+      CALL agrif_declare_variable((/1,1/),(/3,3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),v_ice_id)
+#   else
+      CALL agrif_declare_variable((/1,2/),(/2,3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),u_ice_id)
+      CALL agrif_declare_variable((/2,1/),(/3,2/),(/'x','y'/),(/1,1/),(/jpi,jpj/),v_ice_id)
+#   endif
+          
+      ! 2. Type of interpolation
+      !-------------------------
+      CALL Agrif_Set_bcinterp(adv_ice_id ,interp=AGRIF_linear)   
+      CALL Agrif_Set_bcinterp(sadv_ice_id,interp=AGRIF_linear)   
+      Call Agrif_Set_bcinterp(u_ice_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
+      Call Agrif_Set_bcinterp(v_ice_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
+
+      ! 3. Location of interpolation
+      !-----------------------------
+      Call Agrif_Set_bc(adv_ice_id ,(/0,1/))
+      Call Agrif_Set_bc(sadv_ice_id,(/0,1/))
+      Call Agrif_Set_bc(u_ice_id,(/0,1/))
+      Call Agrif_Set_bc(v_ice_id,(/0,1/))
+
+      ! 5. Update type
+      !--------------- 
+      Call Agrif_Set_Updatetype(adv_ice_id , update = AGRIF_Update_Average)
+      Call Agrif_Set_Updatetype(sadv_ice_id, update = AGRIF_Update_Average)
+      Call Agrif_Set_Updatetype(u_ice_id,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average)
+      Call Agrif_Set_Updatetype(v_ice_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy)
+
+   END SUBROUTINE agrif_declare_var_lim2
+#  endif
 # endif
    
@@ -459,4 +569,5 @@
       !!----------------------------------------------------------------------
       USE agrif_oce 
+      USE agrif_ice 
       USE in_out_manager
       USE lib_mpp
@@ -486,5 +597,8 @@
       visc_dyn      = rn_sponge_dyn
       !
-      IF( agrif_oce_alloc()  > 0 )   CALL ctl_warn('agrif sol_oce_alloc: allocation of arrays failed')
+      IF( agrif_oce_alloc()  > 0 )   CALL ctl_stop('agrif agrif_oce_alloc: allocation of arrays failed')
+# if defined key_lim2
+      IF( agrif_ice_alloc()  > 0 )   CALL ctl_stop('agrif agrif_ice_alloc: allocation of arrays failed')
+# endif
       !
     END SUBROUTINE agrif_nemo_init
Index: /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim_2.F90
===================================================================
--- /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim_2.F90	(revision 2803)
+++ /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim_2.F90	(revision 2804)
@@ -48,4 +48,9 @@
    USE prtctl           ! Print control
 
+#if defined key_agrif
+   USE agrif_ice
+   USE agrif_lim2_update
+#endif
+
    IMPLICIT NONE
    PRIVATE
@@ -110,4 +115,7 @@
          !
          CALL ice_init_2
+#if defined key_agrif
+         IF( .NOT. Agrif_Root() ) CALL Agrif_InitValues_cont_lim2  ! AGRIF: set the meshes
+# endif
       ENDIF
 
@@ -115,4 +123,8 @@
       IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN     !  Ice time-step only  !
          !                                     !----------------------!
+#if defined key_agrif
+         IF( .NOT. Agrif_Root() ) childfreq = MOD(childfreq,Agrif_rhot()) + 1
+#endif
+         !  
          !  Bulk Formulea !
          !----------------!
@@ -197,4 +209,5 @@
          IF( .NOT. lk_c1d ) THEN                       ! Ice dynamics & transport (except in 1D case)
                            CALL lim_dyn_2      ( kt )      ! Ice dynamics    ( rheology/dynamics )
+
                            CALL lim_trp_2      ( kt )      ! Ice transport   ( Advection/diffusion )
            IF( ln_limdmp ) CALL lim_dmp_2      ( kt )      ! Ice damping 
@@ -223,4 +236,7 @@
       !                                        !  at all ocean time step  !
       !                                        !--------------------------!
+#if defined key_agrif && defined key_lim2
+      IF( .NOT. Agrif_Root() )   CALL agrif_update_lim2( kt )
+#endif
       !                                               
       !                                              ! Update surface ocean stresses (only in ice-dynamic case)
Index: /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90
===================================================================
--- /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 2803)
+++ /branches/2011/dev_r2802_LOCEAN10_agrif_lim/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 2804)
@@ -115,4 +115,7 @@
 #if defined key_agrif
       CALL Agrif_Declare_Var       ! AGRIF: set the meshes
+# if defined key_lim2
+      CALL Agrif_Declare_Var_lim2  ! AGRIF: set the meshes
+# endif
 # if defined key_top
       CALL Agrif_Declare_Var_Top   ! AGRIF: set the meshes
