Index: /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/divcur.F90
===================================================================
--- /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/divcur.F90	(revision 7844)
+++ /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/divcur.F90	(revision 7845)
@@ -35,11 +35,12 @@
    USE wrk_nemo        ! Memory Allocation
    USE timing          ! Timing
-   USE iom             ! I/O Manager for dyn_vrt_dia
+   USE iom             ! I/O Manager for dyn_vrt_dia_2d
 
    IMPLICIT NONE
    PRIVATE
 
-   PUBLIC   div_cur     ! routine called by step.F90 and istate.F90
-   PUBLIC   dyn_vrt_dia ! routine called by various modules
+   PUBLIC   div_cur        ! routine called by step.F90 and istate.F90
+   PUBLIC   dyn_vrt_dia_3d ! routine called by various modules
+   PUBLIC   dyn_vrt_dia_2d ! routine called by various modules
 
    !! * Substitutions
@@ -342,22 +343,15 @@
 
 
-   SUBROUTINE dyn_vrt_dia( utend, vtend, id_dia_vor_int, id_dia_vor_mn)
-
-      !!----------------------------------------------------------------------
-      !!
-      !! ** Purpose :  compute the integral and mean vorticity tendencies.
+   SUBROUTINE dyn_vrt_dia_3d( utend, vtend, id_dia_vor_int, id_dia_vor_mn)
+
+      !!----------------------------------------------------------------------
+      !!
+      !! ** Purpose :  compute the vertical integrals of utend and vtend, and
+      !!               then pass to dyn_vrt_dia_2d to calculate vorticity
+      !!               tendencies.
       !!
       !! ** Action : a) Calculate the vertical integrals of utend & of vtend
       !!                (u_int & v_int)
-      !!             b) Calculate the vorticity tendencies for the vertical
-      !!                integrals.
-      !!             c) Calculate the vertical means, u_mn, v_mn from u_int
-      !!                and v_int by dividing by the depth
-      !!             d) Calculate the vorticity tendencies for the vertical
-      !!                means
-      !!             e) Call iom_put for the vertical integral vorticity
-      !!                tendencies (using id_dia_vor_int)
-      !!             f) Call iom_put for the vertical mean vorticity
-      !!                tendencies (using id_dia_vor_mn)
+      !!             b) Call dyn_vrt_dia_2d with vertical integrals
       !!
       !!----------------------------------------------------------------------
@@ -370,19 +364,10 @@
       !
       INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      INTEGER  ::   ikbu, ikbv   ! dummy loop indices
       !
       REAL(wp), POINTER, DIMENSION(:,:) :: u_int   ! u vertical integral
       REAL(wp), POINTER, DIMENSION(:,:) :: v_int   ! v vertical integral
-      REAL(wp), POINTER, DIMENSION(:,:) :: u_mn    ! u vertical means
-      REAL(wp), POINTER, DIMENSION(:,:) :: v_mn    ! u vertical means
-      REAL(wp), POINTER, DIMENSION(:,:) :: vor_int ! vort trend of vert integrals
-      REAL(wp), POINTER, DIMENSION(:,:) :: vor_mn  ! vort trend of vert means
 
       CALL wrk_alloc(jpi, jpj, u_int)
       CALL wrk_alloc(jpi, jpj, v_int)
-      CALL wrk_alloc(jpi, jpj, u_mn)
-      CALL wrk_alloc(jpi, jpj, v_mn)
-      CALL wrk_alloc(jpi, jpj, vor_int)
-      CALL wrk_alloc(jpi, jpj, vor_mn)
 
       u_int(:,:) = 0.0_wp
@@ -402,4 +387,53 @@
       END DO
 
+      CALL lbc_lnk( u_int, 'U', 1. )
+      CALL lbc_lnk( v_int, 'V', 1. )
+
+      CALL dyn_vrt_dia_2d(u_int, v_int, id_dia_vor_int, id_dia_vor_mn)
+
+      CALL wrk_dealloc(jpi, jpj, u_int)
+      CALL wrk_dealloc(jpi, jpj, v_int)
+
+   END SUBROUTINE dyn_vrt_dia_3d
+
+
+   SUBROUTINE dyn_vrt_dia_2d( u_int, v_int, id_dia_vor_int, id_dia_vor_mn)
+
+      !!----------------------------------------------------------------------
+      !!
+      !! ** Purpose :  compute the integral and mean vorticity tendencies.
+      !!
+      !! ** Action : a) Calculate the vorticity tendencies for the vertical
+      !!                integrals.
+      !!             b) Calculate the vertical means, u_mn, v_mn from u_int
+      !!                and v_int by dividing by the depth
+      !!             c) Calculate the vorticity tendencies for the vertical
+      !!                means
+      !!             d) Call iom_put for the vertical integral vorticity
+      !!                tendencies (using id_dia_vor_int)
+      !!             e) Call iom_put for the vertical mean vorticity
+      !!                tendencies (using id_dia_vor_mn)
+      !!
+      !!----------------------------------------------------------------------
+      REAL :: u_int(jpi,jpj)     ! u vertical integral
+      REAL :: v_int(jpi,jpj)     ! v vertical integral
+      INTEGER :: id_dia_vor_int  ! identifier for the vertical integral vorticity diagnostic
+      INTEGER :: id_dia_vor_mn   ! identifier for the vertical mean vorticity diagnostic
+      !
+      !!----------------------------------------------------------------------
+      !
+      INTEGER  ::   ji, jj       ! dummy loop indices
+      INTEGER  ::   ikbu, ikbv   ! dummy loop indices
+      !
+      REAL(wp), POINTER, DIMENSION(:,:) :: u_mn    ! u vertical means
+      REAL(wp), POINTER, DIMENSION(:,:) :: v_mn    ! u vertical means
+      REAL(wp), POINTER, DIMENSION(:,:) :: vor_int ! vort trend of vert integrals
+      REAL(wp), POINTER, DIMENSION(:,:) :: vor_mn  ! vort trend of vert means
+
+      CALL wrk_alloc(jpi, jpj, u_mn)
+      CALL wrk_alloc(jpi, jpj, v_mn)
+      CALL wrk_alloc(jpi, jpj, vor_int)
+      CALL wrk_alloc(jpi, jpj, vor_mn)
+
       !
       ! Calculate the vorticity tendencies for the vertical integrals.
@@ -469,6 +503,4 @@
       ENDIF
 
-      CALL wrk_dealloc(jpi, jpj, u_int)
-      CALL wrk_dealloc(jpi, jpj, v_int)
       CALL wrk_dealloc(jpi, jpj, u_mn)
       CALL wrk_dealloc(jpi, jpj, v_mn)
@@ -476,5 +508,5 @@
       CALL wrk_dealloc(jpi, jpj, vor_mn)
 
-   END SUBROUTINE dyn_vrt_dia
+   END SUBROUTINE dyn_vrt_dia_2d
 
 
Index: /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90
===================================================================
--- /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 7844)
+++ /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 7845)
@@ -36,5 +36,5 @@
    USE trd_oce         ! trends: ocean variables
    USE trddyn          ! trend manager: dynamics
-   USE divcur          ! for dyn_vrt_dia
+   USE divcur          ! for dyn_vrt_dia_3d
    !
    USE in_out_manager  ! I/O manager
@@ -445,5 +445,5 @@
       ! calculate dia_vor_int & dia_vor_mn if required
       IF ( ( id_dia_vrt_hpg_int == 1 ) .or. ( id_dia_vrt_hpg_mean == 1 ) ) THEN
-          CALL dyn_vrt_dia(zhpi, zhpj, id_dia_vrt_hpg_int, id_dia_vrt_hpg_mean)
+          CALL dyn_vrt_dia_3d(zhpi, zhpj, id_dia_vrt_hpg_int, id_dia_vrt_hpg_mean)
       END IF
       !
Index: /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynkeg.F90
===================================================================
--- /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynkeg.F90	(revision 7844)
+++ /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynkeg.F90	(revision 7845)
@@ -17,5 +17,5 @@
    USE trd_oce         ! trends: ocean variables
    USE trddyn          ! trend manager: dynamics
-   USE divcur          ! for dyn_vrt_dia
+   USE divcur          ! for dyn_vrt_dia_3d
    !
    USE in_out_manager  ! I/O manager
@@ -149,5 +149,5 @@
       !
       IF ( ( id_dia_vrt_keg_int == 1 ) .or. ( id_dia_vrt_keg_mean == 1 ) ) THEN
-          CALL dyn_vrt_dia(zhkei, zhkej, id_dia_vrt_keg_int, id_dia_vrt_keg_mean)
+          CALL dyn_vrt_dia_3d(zhkei, zhkej, id_dia_vrt_keg_int, id_dia_vrt_keg_mean)
       END IF
       !
Index: /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_bilap.F90
===================================================================
--- /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_bilap.F90	(revision 7844)
+++ /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_bilap.F90	(revision 7845)
@@ -19,5 +19,5 @@
    USE dom_oce         ! ocean space and time domain
    USE ldfdyn_oce      ! ocean dynamics: lateral physics
-   USE divcur          ! for dyn_vrt_dia
+   USE divcur          ! for dyn_vrt_dia_3d
    !
    USE in_out_manager  ! I/O manager
@@ -210,5 +210,5 @@
       !                                                ! ===============
       IF ( ( id_dia_vrt_ldf_int == 1 ) .or. ( id_dia_vrt_ldf_mean == 1 ) ) THEN
-          CALL dyn_vrt_dia(zua, zva, id_dia_vrt_ldf_int, id_dia_vrt_ldf_mean)
+          CALL dyn_vrt_dia_3d(zua, zva, id_dia_vrt_ldf_int, id_dia_vrt_ldf_mean)
       END IF
       !
Index: /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90
===================================================================
--- /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90	(revision 7844)
+++ /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90	(revision 7845)
@@ -41,4 +41,5 @@
    USE timing          ! Timing    
    USE sbcapr          ! surface boundary condition: atmospheric pressure
+   USE divcur          ! for dyn_vrt_dia_2d
    USE dynadv, ONLY: ln_dynadv_vec
 #if defined key_agrif
@@ -144,4 +145,6 @@
       INTEGER  ::   ji, jj, jk, jn   		! dummy loop indices
       INTEGER  ::   ikbu, ikbv, noffset    	! local integers
+      INTEGER  ::   id_dia_vrt_spg_int  = 1	! TODO remove once flags set properly
+      INTEGER  ::   id_dia_vrt_spg_mean = 1	! TODO remove once flags set properly
       REAL(wp) ::   zraur, z1_2dt_b, z2dt_bf  	! local scalars
       REAL(wp) ::   zx1, zy1, zx2, zy2         !   -      -
@@ -450,4 +453,10 @@
          ENDIF 
       ENDIF
+      !
+                                                ! Calculate dia_vor_int &
+                                                ! dia_vor_mn if required
+      IF ( ( id_dia_vrt_spg_int == 1 ) .or. (id_dia_vrt_spg_mean == 1 ) ) THEN
+          CALL dyn_vrt_dia_2d(zu_frc, zv_frc, di_dia_vrt_spg_int, id_dia_vrt_spg_mean)
+      END IF
       !                                   !* Right-Hand-Side of the barotropic ssh equation
       !                                   ! -----------------------------------------------
Index: /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90
===================================================================
--- /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90	(revision 7844)
+++ /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90	(revision 7845)
@@ -38,5 +38,5 @@
    USE wrk_nemo       ! Memory Allocation
    USE timing         ! Timing
-   USE divcur         ! For dyn_vrt_dia
+   USE divcur         ! For dyn_vrt_dia_3d
 
 
@@ -708,5 +708,5 @@
       !                                                ! ===============
       IF ( ( id_dia_vrt_vor_int == 1 ) .or. ( id_dia_vrt_vor_mn == 1 ) ) THEN
-          CALL dyn_vrt_dia(zua, zva, id_dia_vrt_vor_int, id_dia_vrt_vor_mn)
+          CALL dyn_vrt_dia_3d(zua, zva, id_dia_vrt_vor_int, id_dia_vrt_vor_mn)
       END IF
       !
Index: /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynzad.F90
===================================================================
--- /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynzad.F90	(revision 7844)
+++ /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynzad.F90	(revision 7845)
@@ -18,5 +18,5 @@
    USE trd_oce        ! trends: ocean variables
    USE trddyn         ! trend manager: dynamics
-   USE divcur         ! for dyn_vrt_dia
+   USE divcur         ! for dyn_vrt_dia_3d
    !
    USE in_out_manager ! I/O manager
@@ -146,5 +146,5 @@
       !
       IF ( ( id_dia_vrt_zad_int == 1 ) .or. ( id_dia_vrt_zad_mean == 1 ) ) THEN
-          CALL dyn_vrt_dia(zua, zva, id_dia_vrt_zad_int, id_dia_vrt_zad_mean)
+          CALL dyn_vrt_dia_3d(zua, zva, id_dia_vrt_zad_int, id_dia_vrt_zad_mean)
       END IF
       !
Index: /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf.F90
===================================================================
--- /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf.F90	(revision 7844)
+++ /branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf.F90	(revision 7845)
@@ -27,4 +27,5 @@
    USE wrk_nemo        ! Memory Allocation
    USE timing          ! Timing
+   USE divcur          ! for dyn_vrt_dia_3d
 
    IMPLICIT NONE
@@ -58,4 +59,6 @@
       INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
       !
+      INTEGER :: id_dia_vrt_zdf_int  = 1 ! TODO remove once flags set properly
+      INTEGER :: id_dia_vrt_zdf_mean = 1 ! TODO remove once flags set properly
       REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrdu, ztrdv
       !!---------------------------------------------------------------------
@@ -68,5 +71,5 @@
       ENDIF
 
-      IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
+      IF ( ( l_trddyn ) .or. ( id_dia_vrt_zdf_int == 1 ) .or. ( id_dia_vrt_zdf_mean == 1 ) ) THEN                      ! temporary save of ta and sa trends
          CALL wrk_alloc( jpi, jpj, jpk, ztrdu, ztrdv ) 
          ztrdu(:,:,:) = ua(:,:,:)
@@ -88,7 +91,13 @@
       END SELECT
 
-      IF( l_trddyn )   THEN                      ! save the vertical diffusive trends for further diagnostics
+      IF ( ( l_trddyn ) .or. ( id_dia_vrt_zdf_int == 1 ) .or. ( id_dia_vrt_zdf_mean == 1 ) ) THEN                      ! save the vertical diffusive trends for further diagnostics
          ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
          ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+
+         ! Calculate dia_vor_int & dia_vor_mn if required.
+         IF ( ( id_dia_vrt_zdf_int == 1 ) .or. ( id_dia_vrt_zdf_mean == 1 ) ) THEN
+             CALL dyn_vrt_dia_3d(ztrdu, ztrdv, id_dia_vrt_zdf_int, id_dia_vrt_zdf_mean)
+         END IF
+
          CALL trd_dyn( ztrdu, ztrdv, jpdyn_zdf, kt )
          CALL wrk_dealloc( jpi, jpj, jpk, ztrdu, ztrdv ) 
