Index: /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_interp.F90
===================================================================
--- /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_interp.F90	(revision 11624)
+++ /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_interp.F90	(revision 11625)
@@ -662,6 +662,6 @@
       INTEGER  ::   N_in, N_out
       ! vertical interpolation:
-      REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk,n1:n2) :: ptab_child
-      REAL(wp), DIMENSION(k1:k2,n1:n2-1) :: tabin
+      REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk,1:jpts) :: ptab_child
+      REAL(wp), DIMENSION(k1:k2,1:jpts) :: tabin
       REAL(wp), DIMENSION(k1:k2) :: h_in
       REAL(wp), DIMENSION(1:jpk) :: h_out
@@ -693,4 +693,5 @@
          DO jj=j1,j2
             DO ji=i1,i2
+               ptab_child(ji,jj,:,:) = 0._wp
                N_in = 0
                DO jk=k1,k2 !k2 = jpk of parent grid
@@ -706,5 +707,5 @@
                   h_out(jk) = e3t_a(ji,jj,jk)
                ENDDO
-               IF (N_in > 0) THEN
+               IF (N_in*N_out > 0) THEN
                   CALL reconstructandremap(tabin(1:N_in,1:jpts),h_in(1:N_in),ptab_child(ji,jj,1:N_out,1:jpts),h_out(1:N_out),N_in,N_out,jpts)
                ENDIF
Index: /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_sponge.F90
===================================================================
--- /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_sponge.F90	(revision 11624)
+++ /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_sponge.F90	(revision 11625)
@@ -329,7 +329,7 @@
          !
 # if defined key_vertical
-         tabres_child(:,:,:,:) = 0.
          DO jj=j1,j2
             DO ji=i1,i2
+               tabres_child(ji,jj,:,:) = 0._wp 
                N_in = 0
                DO jk=k1,k2 !k2 = jpk of parent grid
@@ -345,5 +345,5 @@
                   h_out(jk) = e3t_b(ji,jj,jk) !Child grid scale factors. Could multiply by e1e2t here instead of division above
                ENDDO
-               IF (N_in > 0) THEN
+               IF (N_in*N_out > 0) THEN
                   CALL reconstructandremap(tabin(1:N_in,1:jpts),h_in(1:N_in),tabres_child(ji,jj,1:N_out,1:jpts),h_out(1:N_out),N_in,N_out,jpts)
                ENDIF
@@ -438,5 +438,5 @@
       !
       IF( before ) THEN
-         DO jk=1,jpkm1
+         DO jk=k1,k2
             DO jj=j1,j2
                DO ji=i1,i2
@@ -591,5 +591,5 @@
       
       IF( before ) THEN 
-         DO jk=1,jpkm1
+         DO jk=k1,k2
             DO jj=j1,j2
                DO ji=i1,i2
Index: /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_update.F90
===================================================================
--- /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_update.F90	(revision 11624)
+++ /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_oce_update.F90	(revision 11625)
@@ -288,5 +288,5 @@
       REAL(wp) :: h_in(k1:k2)
       REAL(wp) :: h_out(1:jpk)
-      REAL(wp) :: tabin(k1:k2,jpts)
+      REAL(wp) :: tabin(k1:k2,1:jpts)
       REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk,1:jpts) :: tabres_child
       !!---------------------------------------------
@@ -330,5 +330,5 @@
                   h_out(N_out) = e3t_n(ji,jj,jk) 
                ENDDO
-               IF (N_in > 0) THEN !Remove this?
+               IF (N_in*N_out > 0) THEN !Remove this?
                   CALL reconstructandremap(tabin(1:N_in,1:jpts),h_in(1:N_in),tabres_child(ji,jj,1:N_out,1:jpts),h_out(1:N_out),N_in,N_out,jpts)
                ENDIF
Index: /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_top_interp.F90
===================================================================
--- /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_top_interp.F90	(revision 11624)
+++ /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_top_interp.F90	(revision 11625)
@@ -62,6 +62,6 @@
 
       ! vertical interpolation:
-      REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk,n1:n2) :: ptab_child
-      REAL(wp), DIMENSION(k1:k2,n1:n2-1) :: tabin
+      REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk,1:jptra) :: ptab_child
+      REAL(wp), DIMENSION(k1:k2,1:jptra) :: tabin
       REAL(wp), DIMENSION(k1:k2) :: h_in
       REAL(wp), DIMENSION(1:jpk) :: h_out
@@ -93,4 +93,5 @@
          DO jj=j1,j2
             DO ji=i1,i2
+               ptab_child(ji,jj,:) = 0._wp
                N_in = 0
                DO jk=k1,k2 !k2 = jpk of parent grid
Index: /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_top_sponge.F90
===================================================================
--- /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_top_sponge.F90	(revision 11624)
+++ /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_top_sponge.F90	(revision 11625)
@@ -68,9 +68,9 @@
       INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices
       REAL(wp) ::   zabe1, zabe2
-      REAL(wp), DIMENSION(i1:i2,j1:j2)             ::   ztu, ztv
-      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,n1:n2) ::   trbdiff
+      REAL(wp), DIMENSION(i1:i2,j1:j2)               ::   ztu, ztv
+      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,1:jptra) ::   trbdiff
       ! vertical interpolation:
-      REAL(wp), DIMENSION(i1:i2,j1:j2,jpk,n1:n2) ::tabres_child
-      REAL(wp), DIMENSION(k1:k2,n1:n2-1) :: tabin
+      REAL(wp), DIMENSION(i1:i2,j1:j2,jpk,1:jptra) ::tabres_child
+      REAL(wp), DIMENSION(k1:k2,1:jptra) :: tabin
       REAL(wp), DIMENSION(k1:k2) :: h_in
       REAL(wp), DIMENSION(1:jpk) :: h_out
Index: /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_top_update.F90
===================================================================
--- /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_top_update.F90	(revision 11624)
+++ /NEMO/branches/2019/dev_r11233_AGRIF-05_jchanut_vert_coord_interp/src/NST/agrif_top_update.F90	(revision 11625)
@@ -70,5 +70,5 @@
       INTEGER  :: N_in, N_out
       REAL(wp) :: h_diff
-      REAL(wp) :: tabin(k1:k2,n1:n2)
+      REAL(wp) :: tabin(k1:k2,1:jptra)
       REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk,1:jptra) :: tabres_child
       !!---------------------------------------------
