Index: branches/2015/dev_r5803_UKMO_AGRIF_Vert_interp/NEMOGCM/NEMO/NST_SRC/agrif_opa_update.F90
===================================================================
--- branches/2015/dev_r5803_UKMO_AGRIF_Vert_interp/NEMOGCM/NEMO/NST_SRC/agrif_opa_update.F90	(revision 6928)
+++ branches/2015/dev_r5803_UKMO_AGRIF_Vert_interp/NEMOGCM/NEMO/NST_SRC/agrif_opa_update.F90	(revision 6929)
@@ -1,3 +1,3 @@
-#define TWO_WAY        /* TWO WAY NESTING */
+#undef TWO_WAY        /* TWO WAY NESTING */
 #undef DECAL_FEEDBACK /* SEPARATION of INTERFACES*/
  
@@ -121,4 +121,6 @@
       ! 
       IF (MOD(nbcline,nbclineupdate) == 0) THEN
+         WRITE(numout,*) 'TG print 1'
+         CALL FLUSH(numout)
 # if ! defined DECAL_FEEDBACK
          CALL Agrif_Update_Variable(tsn_id, procname=updateTS)
@@ -126,5 +128,9 @@
          CALL Agrif_Update_Variable(tsn_id, locupdate=(/1,0/),procname=updateTS)
 # endif
-      ELSE
+         WRITE(numout,*) 'TG print 2'
+         CALL FLUSH(numout)
+      ELSE
+         WRITE(numout,*) 'TG print 3'
+         CALL FLUSH(numout)
 # if ! defined DECAL_FEEDBACK
          CALL Agrif_Update_Variable(tsn_id,locupdate=(/0,2/), procname=updateTS)
@@ -132,4 +138,6 @@
          CALL Agrif_Update_Variable(tsn_id,locupdate=(/1,2/), procname=updateTS)
 # endif
+         WRITE(numout,*) 'TG print 4'
+         CALL FLUSH(numout)
       ENDIF
       !
@@ -300,5 +308,5 @@
 ! VERTICAL REFINEMENT BEGIN
          ptab_child(:,:,:,:) = 0.
-         
+
          DO jj=j1,j2
          DO ji=i1,i2
@@ -314,14 +322,14 @@
              IF (tmask(ji,jj,jk) == 0) EXIT ! TODO: Will not work with ISF
              N_out = N_out + 1
-             h_out(N_out) = e3t_n(ji,jj,jk)!Parent grid scale factors. Could multiply by e1e2t here instead of division above
+             h_out(N_out) = e3t_n(ji,jj,jk) !Parent grid scale factors. Could multiply by e1e2t here instead of division above
            ENDDO
            IF (N_in > 0) THEN
              h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in))
 ! Should be able to remove the next IF/ELSEIF statement once scale factors are dealt with properly
-             IF abs(h_diff > 1.e-8) THEN
+!             IF abs(h_diff > 1.e-8) THEN
 !               N_in = N_in + 1
 !               h_in(N_in) = h_diff
 !               tabin(N_in,:) = tabin(N_in-1,:)
-             ELSEIF (h_diff < 0) THEN
+             IF (h_diff < 0) THEN
              print *,'CHECK YOUR bathy T points ...',ji,jj,h_diff,sum(h_in(1:N_in)),sum(h_out(1:N_out))
              print *,'Nval = ',N_out,mbathy(ji,jj)
@@ -372,13 +380,15 @@
       ENDIF
       ! 
+      WRITE(numout,*) 'I got to end of updateTS before=',before
+      CALL FLUSH(numout)
    END SUBROUTINE updateTS
 
-   SUBROUTINE updateu( ptab, i1, i2, j1, j2, k1, k2, before )
+   SUBROUTINE updateu( ptab, i1, i2, j1, j2, k1, k2, n1, n2, before )
       !!---------------------------------------------
       !!           *** ROUTINE updateu ***
       !!---------------------------------------------
       !!
-      INTEGER, INTENT(in) :: i1, i2, j1, j2, k1, k2
-      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: ptab
+      INTEGER, INTENT(in) :: i1, i2, j1, j2, k1, k2, n1, n2
+      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,2), INTENT(inout) :: ptab
       LOGICAL                               , INTENT(in   ) :: before
       !
@@ -386,5 +396,5 @@
       REAL(wp) ::   zrhoy
 ! VERTICAL REFINEMENT BEGIN
-      REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk) :: ptab_child
+      REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk,2) :: ptab_child
       REAL(wp) :: h_in(k1:k2)
       REAL(wp) :: h_out(1:jpk)
@@ -395,4 +405,6 @@
       !!---------------------------------------------
       ! 
+      WRITE(numout,*) 'TG print 5: Start of updateu before = ',before
+      CALL FLUSH(numout)
       IF( before ) THEN
          zrhoy = Agrif_Rhoy()
@@ -400,21 +412,21 @@
             DO jj=j1,j2
                DO ji=i1,i2
-                  ptab(ji,jj,jk) = e2u(ji,jj) * e3u_n(ji,jj,jk) * un(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-         ptab = zrhoy * ptab
+                  ptab(ji,jj,jk,1) = zrhoy * e2u(ji,jj) * e3u_n(ji,jj,jk) * un(ji,jj,jk)
+                  ptab(ji,jj,jk,2) = umask(ji,jj,jk) * zrhoy * e2u(ji,jj) * e3u_n(ji,jj,jk) 
+               END DO
+            END DO
+         END DO
       ELSE
 ! VERTICAL REFINEMENT BEGIN
-         ptab_child(:,:,:) = 0.
+         ptab_child(:,:,:,:) = 0.
          
          DO jj=j1,j2
          DO ji=i1,i2
            N_in = 0
-           DO jk=k1,k2
-             IF (update_scales_u(ji,jj,jk) == 0) EXIT
+           DO jk=k1,k2 !k2=jpk of child grid
+             IF (ptab(ji,jj,jk,2) == 0) EXIT
              N_in = N_in + 1
-             tabin(jk) = ptab(ji,jj,jk)/update_scales_u(ji,jj,jk)
-             h_in(N_in) = update_scales_u(ji,jj,jk)
+             tabin(jk) = ptab(ji,jj,jk)/ptab(ji,jj,jk,2)
+             h_in(N_in) = ptab(ji,jj,jk,2)/e2u(ji,jj)
            ENDDO
            N_out = 0
@@ -426,13 +438,14 @@
            IF (N_in * N_out > 0) THEN
              h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in))
+! Should be able to remove the next IF/ELSEIF statement once scale factors are dealt with properly
              if (h_diff < 0.) then
              print *,'CHECK YOUR BATHY ...'
              stop
-             else ! Extends with 0
-             N_in = N_in + 1
-             tabin(N_in) = 0.
-             h_in(N_in) = h_diff
+!             else ! Extends with 0
+!             N_in = N_in + 1
+!             tabin(N_in) = 0.
+!             h_in(N_in) = h_diff
              endif
-             CALL reconstructandremap(tabin(1:N_in),h_in(1:N_in),ptab_child(ji,jj,1:N_out),h_out(1:N_out),N_in,N_out)
+             CALL reconstructandremap(tabin(1:N_in),h_in(1:N_in),ptab_child(ji,jj,1:N_out,1),h_out(1:N_out),N_in,N_out)
           ENDIF
          ENDDO
@@ -448,12 +461,13 @@
             DO jj=j1,j2
                DO ji=i1,i2
-                  ptab_child(ji,jj,jk) = ptab_child(ji,jj,jk) / e2u(ji,jj)
+!Following line now replaced by division higher up I think
+!                  ptab_child(ji,jj,jk) = ptab_child(ji,jj,jk) / e2u(ji,jj)
                   !
                   IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN ! Add asselin part
                      ub(ji,jj,jk) = ub(ji,jj,jk) & 
-                           & + atfp * ( ptab_child(ji,jj,jk) - un(ji,jj,jk) ) * umask(ji,jj,jk)
+                           & + atfp * ( ptab_child(ji,jj,jk,1) - un(ji,jj,jk) ) * umask(ji,jj,jk)
                   ENDIF
                   !
-                  un(ji,jj,jk) = ptab_child(ji,jj,jk) * umask(ji,jj,jk)
+                  un(ji,jj,jk) = ptab_child(ji,jj,jk,1) * umask(ji,jj,jk)
                END DO
             END DO
@@ -461,19 +475,21 @@
       ENDIF
       ! 
+      WRITE(numout,*) 'TG print 6: End of updateu before = ',before
+      CALL FLUSH(numout)
    END SUBROUTINE updateu
 
-   SUBROUTINE updatev( ptab, i1, i2, j1, j2, k1, k2, before )
+   SUBROUTINE updatev( ptab, i1, i2, j1, j2, k1, k2, n1, n2, before )
       !!---------------------------------------------
       !!           *** ROUTINE updatev ***
       !!---------------------------------------------
       !!
-      INTEGER :: i1,i2,j1,j2,k1,k2
+      INTEGER :: i1,i2,j1,j2,k1,k2,n1,n2
       INTEGER :: ji,jj,jk
-      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2) :: ptab
+      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,2) :: ptab
       LOGICAL :: before
       !!
       REAL(wp) :: zrhox
 ! VERTICAL REFINEMENT BEGIN
-      REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk) :: ptab_child
+      REAL(wp), DIMENSION(i1:i2,j1:j2,1:jpk,2) :: ptab_child
       REAL(wp) :: h_in(k1:k2)
       REAL(wp) :: h_out(1:jpk)
@@ -484,4 +500,6 @@
       !!---------------------------------------------      
       !
+      WRITE(numout,*) 'TG print 7: Start of updatev before = ',before
+      CALL FLUSH(numout)
       IF (before) THEN
          zrhox = Agrif_Rhox()
@@ -489,10 +507,9 @@
             DO jj=j1,j2
                DO ji=i1,i2
-                  ptab(ji,jj,jk) = e1v(ji,jj) * vn(ji,jj,jk)
-                  ptab(ji,jj,jk) = ptab(ji,jj,jk) * e3v_n(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-         ptab = zrhox * ptab
+                  ptab(ji,jj,jk,1) = zrhox * e1v(ji,jj) * e3v_n(ji,jj,jk) * vn(ji,jj,jk)
+                  ptab(ji,jj,jk,2) = vmask(ji,jj,jk) * zrhox * e1v(ji,jj) * e3v_n(ji,jj,jk) 
+               END DO
+            END DO
+         END DO
       ELSE
 ! VERTICAL REFINEMENT BEGIN
@@ -505,6 +522,6 @@
              IF (update_scales_v(ji,jj,jk) == 0) EXIT
              N_in = N_in + 1
-             tabin(jk) = ptab(ji,jj,jk)/update_scales_v(ji,jj,jk)
-             h_in(N_in) = update_scales_v(ji,jj,jk)
+             tabin(jk) = ptab(ji,jj,1)/ptab(ji,jj,jk,2)
+             h_in(N_in) = ptab(ji,jj,jk,2)/e1v(ji,jj)
            ENDDO
            N_out = 0
@@ -516,13 +533,14 @@
            IF (N_in * N_out > 0) THEN
              h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in))
+! Should be able to remove the next IF/ELSEIF statement once scale factors are dealt with properly
              if (h_diff < 0.) then
              print *,'CHECK YOUR BATHY ...'
              stop
-             else ! Extends with 0
-             N_in = N_in + 1
-             tabin(N_in) = 0.
-             h_in(N_in) = h_diff
+!             else ! Extends with 0
+!             N_in = N_in + 1
+!             tabin(N_in) = 0.
+!             h_in(N_in) = h_diff
              endif
-             CALL reconstructandremap(tabin(1:N_in),h_in(1:N_in),ptab_child(ji,jj,1:N_out),h_out(1:N_out),N_in,N_out)
+             CALL reconstructandremap(tabin(1:N_in),h_in(1:N_in),ptab_child(ji,jj,1:N_out,1),h_out(1:N_out),N_in,N_out)
           ENDIF
          ENDDO
@@ -538,16 +556,18 @@
             DO jj=j1,j2
                DO ji=i1,i2
-                  ptab_child(ji,jj,jk) = ptab_child(ji,jj,jk) / e1v(ji,jj)
+!Following line now replaced by division higher up I think
+!                  ptab_child(ji,jj,jk) = ptab_child(ji,jj,jk) / e1v(ji,jj)
                   !
                   IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN ! Add asselin part
                      vb(ji,jj,jk) = vb(ji,jj,jk) & 
-                           & + atfp * ( ptab_child(ji,jj,jk) - vn(ji,jj,jk) ) * vmask(ji,jj,jk)
+                           & + atfp * ( ptab_child(ji,jj,jk,1) - vn(ji,jj,jk) ) * vmask(ji,jj,jk)
                   ENDIF
                   !
-                  vn(ji,jj,jk) = ptab_child(ji,jj,jk) * vmask(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-      ENDIF
+                  vn(ji,jj,jk) = ptab_child(ji,jj,jk,1) * vmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+      ENDIF
+      WRITE(numout,*) 'TG print 8: End of updatev before = ',before
       ! 
    END SUBROUTINE updatev
Index: branches/2015/dev_r5803_UKMO_AGRIF_Vert_interp/NEMOGCM/NEMO/NST_SRC/agrif_user.F90
===================================================================
--- branches/2015/dev_r5803_UKMO_AGRIF_Vert_interp/NEMOGCM/NEMO/NST_SRC/agrif_user.F90	(revision 6928)
+++ branches/2015/dev_r5803_UKMO_AGRIF_Vert_interp/NEMOGCM/NEMO/NST_SRC/agrif_user.F90	(revision 6929)
@@ -380,6 +380,6 @@
    CALL agrif_declare_variable((/1,2,0,0/),(/2,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),un_interp_id)
    CALL agrif_declare_variable((/2,1,0,0/),(/3,2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),vn_interp_id)
-   CALL agrif_declare_variable((/1,2,0/),(/2,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),un_update_id)
-   CALL agrif_declare_variable((/2,1,0/),(/3,2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vn_update_id)
+   CALL agrif_declare_variable((/1,2,0,0/),(/2,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),un_update_id)
+   CALL agrif_declare_variable((/2,1,0,0/),(/3,2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,2/),vn_update_id)
    CALL agrif_declare_variable((/1,2,0/),(/2,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),un_sponge_id)
    CALL agrif_declare_variable((/2,1,0/),(/3,2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vn_sponge_id)
