Index: NEMO/trunk/src/NST/agrif_oce_interp.F90
===================================================================
--- NEMO/trunk/src/NST/agrif_oce_interp.F90	(revision 9759)
+++ NEMO/trunk/src/NST/agrif_oce_interp.F90	(revision 9806)
@@ -94,6 +94,6 @@
       !
       ! prevent smoothing in ghost cells
-      i1 =  1   ;   i2 = jpi
-      j1 =  1   ;   j2 = jpj
+      i1 =  1   ;   i2 = nlci
+      j1 =  1   ;   j2 = nlcj
       IF( nbondj == -1 .OR. nbondj == 2 )   j1 = 2 + nbghostcells
       IF( nbondj == +1 .OR. nbondj == 2 )   j2 = nlcj - nbghostcells - 1
@@ -645,5 +645,5 @@
       INTEGER  ::   ji, jj, jk, jn, iref, jref, ibdy, jbdy   ! dummy loop indices
       INTEGER  ::   imin, imax, jmin, jmax, N_in, N_out
-      REAL(wp) ::   zrhox, z1, z2, z3, z4, z5, z6, z7
+      REAL(wp) ::   zrho, z1, z2, z3, z4, z5, z6, z7
       LOGICAL :: western_side, eastern_side,northern_side,southern_side
       ! vertical interpolation:
@@ -718,14 +718,4 @@
          IF ( .NOT.lk_agrif_clp ) THEN 
             !
-            zrhox = Agrif_Rhox()
-            z1 = ( zrhox - 1. ) * 0.5
-            z3 = ( zrhox - 1. ) / ( zrhox + 1. )
-            z6 = 2. * ( zrhox - 1. ) / ( zrhox + 1. )
-            z7 =    - ( zrhox - 1. ) / ( zrhox + 3. )
-            !
-            z2 = 1. - z1
-            z4 = 1. - z3
-            z5 = 1. - z6 - z7
-            !
             imin = i1 ; imax = i2
             jmin = j1 ; jmax = j2
@@ -734,11 +724,18 @@
             IF((nbondj == -1).OR.(nbondj == 2)) jmin = 2 + nbghostcells
             IF((nbondj == +1).OR.(nbondj == 2)) jmax = nlcj - nbghostcells - 1
-            IF((nbondi == -1).OR.(nbondi == 2)) imin = 1 + nbghostcells
+            IF((nbondi == -1).OR.(nbondi == 2)) imin = 2 + nbghostcells
             IF((nbondi == +1).OR.(nbondi == 2)) imax = nlci - nbghostcells - 1      
             !
             IF( eastern_side ) THEN
+               zrho = Agrif_Rhox()
+               z1 = ( zrho - 1._wp ) * 0.5_wp                    
+               z3 = ( zrho - 1._wp ) / ( zrho + 1._wp )         
+               z6 = 2._wp * ( zrho - 1._wp ) / ( zrho + 1._wp )
+               z7 =       - ( zrho - 1._wp ) / ( zrho + 3._wp )
+               z2 = 1._wp - z1 ; z4 = 1._wp - z3 ; z5 = 1._wp - z6 - z7
+               !
                ibdy = nlci-nbghostcells
                DO jn = 1, jpts
-                  tsa(ibdy+1,jmin:jmax,k1:k2,jn) = z1 * ptab_child(ibdy+1,jmin:jmax,k1:k2,jn) + z2 * ptab_child(ibdy,jmin:jmax,k1:k2,jn)
+                  tsa(ibdy+1,jmin:jmax,1:jpkm1,jn) = z1 * ptab_child(ibdy+1,jmin:jmax,1:jpkm1,jn) + z2 * ptab_child(ibdy,jmin:jmax,1:jpkm1,jn)
                   DO jk = 1, jpkm1
                      DO jj = jmin,jmax
@@ -755,12 +752,19 @@
                   END DO
                   ! Restore ghost points:
-                  tsa(ibdy+1,jmin:jmax,k1:k2,jn) = ptab_child(ibdy+1,jmin:jmax,k1:k2,jn) * tmask(ibdy+1,jmin:jmax,k1:k2)
+                  tsa(ibdy+1,jmin:jmax,1:jpkm1,jn) = ptab_child(ibdy+1,jmin:jmax,1:jpkm1,jn) * tmask(ibdy+1,jmin:jmax,1:jpkm1)
                END DO
             ENDIF
             ! 
             IF( northern_side ) THEN
+               zrho = Agrif_Rhoy()
+               z1 = ( zrho - 1._wp ) * 0.5_wp                    
+               z3 = ( zrho - 1._wp ) / ( zrho + 1._wp )         
+               z6 = 2._wp * ( zrho - 1._wp ) / ( zrho + 1._wp )
+               z7 =       - ( zrho - 1._wp ) / ( zrho + 3._wp )
+               z2 = 1._wp - z1 ; z4 = 1._wp - z3 ; z5 = 1._wp - z6 - z7
+               !
                jbdy = nlcj-nbghostcells         
                DO jn = 1, jpts
-                  tsa(imin:imax,jbdy+1,k1:k2,jn) = z1 * ptab_child(imin:imax,jbdy+1,k1:k2,jn) + z2 * ptab_child(imin:imax,jbdy,k1:k2,jn)
+                  tsa(imin:imax,jbdy+1,1:jpkm1,jn) = z1 * ptab_child(imin:imax,jbdy+1,1:jpkm1,jn) + z2 * ptab_child(imin:imax,jbdy,1:jpkm1,jn)
                   DO jk = 1, jpkm1
                      DO ji = imin,imax
@@ -777,12 +781,19 @@
                   END DO
                   ! Restore ghost points:
-                  tsa(imin:imax,jbdy+1,k1:k2,jn) = ptab_child(imin:imax,jbdy+1,k1:k2,jn) * tmask(imin:imax,jbdy+1,k1:k2)
+                  tsa(imin:imax,jbdy+1,1:jpkm1,jn) = ptab_child(imin:imax,jbdy+1,1:jpkm1,jn) * tmask(imin:imax,jbdy+1,1:jpkm1)
                END DO
             ENDIF
             !
-            IF( western_side ) THEN    
+            IF( western_side ) THEN
+               zrho = Agrif_Rhox()
+               z1 = ( zrho - 1._wp ) * 0.5_wp                    
+               z3 = ( zrho - 1._wp ) / ( zrho + 1._wp )         
+               z6 = 2._wp * ( zrho - 1._wp ) / ( zrho + 1._wp )
+               z7 =       - ( zrho - 1._wp ) / ( zrho + 3._wp )
+               z2 = 1._wp - z1 ; z4 = 1._wp - z3 ; z5 = 1._wp - z6 - z7
+               !    
                ibdy = 1+nbghostcells       
                DO jn = 1, jpts
-                  tsa(ibdy-1,jmin:jmax,k1:k2,jn) = z1 * ptab_child(ibdy-1,jmin:jmax,k1:k2,jn) + z2 * ptab_child(ibdy,jmin:jmax,k1:k2,jn)
+                  tsa(ibdy-1,jmin:jmax,1:jpkm1,jn) = z1 * ptab_child(ibdy-1,jmin:jmax,1:jpkm1,jn) + z2 * ptab_child(ibdy,jmin:jmax,1:jpkm1,jn)
                   DO jk = 1, jpkm1
                      DO jj = jmin,jmax
@@ -792,5 +803,6 @@
                            tsa(ibdy,jj,jk,jn)=(z4*tsa(ibdy-1,jj,jk,jn)+z3*tsa(ibdy+1,jj,jk,jn))*tmask(ibdy,jj,jk)        
                            IF( un(ibdy,jj,jk) < 0._wp ) THEN
-                              tsa(ibdy,jj,jk,jn)=(z6*tsa(ibdy+1,jj,jk,jn)+z5*tsa(ibdy-1,jj,jk,jn)+z7*tsa(ibdy+2,jj,jk,jn))*tmask(ibdy,jj,jk)
+                              tsa(ibdy,jj,jk,jn)=( z6*tsa(ibdy+1,jj,jk,jn)+z5*tsa(ibdy-1,jj,jk,jn) &
+                                                 + z7*tsa(ibdy+2,jj,jk,jn) ) * tmask(ibdy,jj,jk)
                            ENDIF
                         ENDIF
@@ -798,14 +810,21 @@
                   END DO
                   ! Restore ghost points:
-                  tsa(ibdy-1,jmin:jmax,k1:k2,jn) = ptab_child(ibdy-1,jmin:jmax,k1:k2,jn) * tmask(ibdy-1,jmin:jmax,k1:k2)
+                  tsa(ibdy-1,jmin:jmax,1:jpkm1,jn) = ptab_child(ibdy-1,jmin:jmax,1:jpkm1,jn) * tmask(ibdy-1,jmin:jmax,1:jpkm1)
                END DO
             ENDIF
             !
-            IF( southern_side ) THEN  
+            IF( southern_side ) THEN
+               zrho = Agrif_Rhoy()
+               z1 = ( zrho - 1._wp ) * 0.5_wp                    
+               z3 = ( zrho - 1._wp ) / ( zrho + 1._wp )         
+               z6 = 2._wp * ( zrho - 1._wp ) / ( zrho + 1._wp )
+               z7 =       - ( zrho - 1._wp ) / ( zrho + 3._wp )
+               z2 = 1._wp - z1 ; z4 = 1._wp - z3 ; z5 = 1._wp - z6 - z7
+               !  
                jbdy=1+nbghostcells        
                DO jn = 1, jpts
-                  tsa(imin:imax,jbdy-1,k1:k2,jn) = z1 * ptab_child(imin:imax,jbdy-1,k1:k2,jn) + z2 * ptab_child(imin:imax,jbdy,k1:k2,jn)
-                  DO jk = 1, jpk      
-                     DO ji=imin,imax
+                  tsa(imin:imax,jbdy-1,1:jpkm1,jn) = z1 * ptab_child(imin:imax,jbdy-1,1:jpkm1,jn) + z2 * ptab_child(imin:imax,jbdy,1:jpkm1,jn)
+                  DO jk = 1, jpkm1      
+                     DO ji = imin,imax
                         IF( vmask(ji,jbdy,jk) == 0._wp ) THEN
                            tsa(ji,jbdy,jk,jn)=tsa(ji,jbdy-1,jk,jn) * tmask(ji,jbdy,jk)
@@ -813,5 +832,6 @@
                            tsa(ji,jbdy,jk,jn)=(z4*tsa(ji,jbdy-1,jk,jn)+z3*tsa(ji,jbdy+1,jk,jn))*tmask(ji,jbdy,jk)
                            IF( vn(ji,jbdy,jk) < 0._wp ) THEN
-                              tsa(ji,jbdy,jk,jn)=(z6*tsa(ji,jbdy+1,jk,jn)+z5*tsa(ji,jbdy-1,jk,jn)+z7*tsa(ji,jbdy+2,jk,jn))*tmask(ji,jbdy,jk)
+                              tsa(ji,jbdy,jk,jn)=( z6*tsa(ji,jbdy+1,jk,jn)+z5*tsa(ji,jbdy-1,jk,jn) & 
+                                                 + z7*tsa(ji,jbdy+2,jk,jn) ) * tmask(ji,jbdy,jk)
                            ENDIF
                         ENDIF
@@ -819,5 +839,5 @@
                   END DO
                   ! Restore ghost points:
-                  tsa(imin:imax,jbdy-1,k1:k2,jn) = tsa(imin:imax,jbdy-1,k1:k2,jn) * tmask(imin:imax,jbdy-1,k1:k2)
+                  tsa(imin:imax,jbdy-1,1:jpkm1,jn) = ptab_child(imin:imax,jbdy-1,1:jpkm1,jn) * tmask(imin:imax,jbdy-1,1:jpkm1)
                END DO
             ENDIF
