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 8168)
+++ branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/divcur.F90	(revision 8197)
@@ -344,5 +344,5 @@
 
    ! TODO - remove kt only used for validation
-   SUBROUTINE dyn_vrt_dia_3d( utend, vtend, id_dia_vor_int, id_dia_vor_mn, kt)
+   SUBROUTINE dyn_vrt_dia_3d( utend, vtend, id_dia_vor, kt)
 
       !!----------------------------------------------------------------------
@@ -357,14 +357,12 @@
       !!
       !!----------------------------------------------------------------------
-      REAL,    INTENT(in) :: utend(jpi,jpj,jpk) ! contribution to du/dt
-      REAL,    INTENT(in) :: vtend(jpi,jpj,jpk) ! contribution to dv/dt
-      INTEGER, INTENT(in) :: id_dia_vor_int  ! identifier for the vertical integral vorticity diagnostic
-      INTEGER, INTENT(in) :: id_dia_vor_mn   ! identifier for the vertical mean vorticity diagnostic
-      INTEGER             ::   kt   ! ocean time-step index
+      REAL             :: utend(jpi,jpj,jpk) ! contribution to du/dt
+      REAL             :: vtend(jpi,jpj,jpk) ! contribution to dv/dt
+      CHARACTER(len=3) :: id_dia_vor         ! identifier for the diagnostic
+      INTEGER          :: kt                 ! ocean time-step index TODO remove after validation
       !
       !!----------------------------------------------------------------------
       !
       INTEGER  ::   ji, jj, jk     ! dummy loop indices
-      INTEGER  ::   ji_min, ji_max ! dummy loop indices for dynspg_flt
       !
       REAL(wp), POINTER, DIMENSION(:,:) :: u_int   ! u vertical integral
@@ -374,12 +372,4 @@
       CALL wrk_alloc(jpi, jpj, v_int)
 
-      ji_min = 1
-      ji_max = jpi
-
-      IF ( id_dia_vor_int == 71 .OR. id_dia_vor_mn == 72 ) THEN
-          ji_min = fs_2
-          ji_max = fs_jpim1
-      END IF
-
       u_int(:,:) = 0.0_wp
       v_int(:,:) = 0.0_wp
@@ -388,27 +378,39 @@
       ! Calculate the vertical integrals of utend & of vtend
       !
+      ! TODO remove - for validation only
+      IF ( kt == 1 ) THEN
+          WRITE(numout, *) 'dyn_vrt_dia_3d id:', id_dia_vor,       &
+                 &         ':bathy:', bathy(17,12),                &
+                 &         ':mbathy:', mbathy(17,12)
+      END IF
       
-      DO jk = 1,jpk
-          DO jj = 1,jpj
-              DO ji = ji_min,ji_max
-                  u_int(ji,jj) = u_int(ji,jj) + utend(ji,jj,jk)*fse3u(ji,jj,jk)
-                  v_int(ji,jj) = v_int(ji,jj) + vtend(ji,jj,jk)*fse3v(ji,jj,jk)
+      DO jk = 1, jpkm1
+          DO jj = 2, jpjm1
+              DO ji = fs_2, fs_jpim1
+                  u_int(ji,jj) = u_int(ji,jj) + ( utend(ji,jj,jk) * fse3u(ji,jj,jk) &
+                                 &                 * e1u(ji,jj) * umask(ji,jj,jk) )
+                  v_int(ji,jj) = v_int(ji,jj) + ( vtend(ji,jj,jk) * fse3v(ji,jj,jk) &
+                                 &                 * e2v(ji,jj) * vmask(ji,jj,jk) )
 
                   ! TODO remove - for validation only
-                  IF ( kt == 1 .AND. ji == 17 .AND. jj == 12 .AND. id_dia_vor_int == 11 ) THEN
-                      WRITE(numout, *) 'dyn_vrt_dia_3d id:', id_dia_vor_int,   &
-                             &         ':ji:', ji,                             &
-                             &         ':jj:', jj,                             &
-                             &         ':jk:', jk,                             &
-                             &         ':u_int:', u_int(ji,jj),                &
-                             &         ':u_tend:', utend(ji,jj,jk),            &
-                             &         ':fse3u:', fse3u(ji,jj,jk)
-                      WRITE(numout, *) 'dyn_vrt_dia_3d id:', id_dia_vor_int,   &
-                             &         ':ji:', ji,                             &
-                             &         ':jj:', jj,                             &
-                             &         ':jk:', jk,                             &
-                             &         ':v_int:', v_int(ji,jj),                &
-                             &         ':v_tend:', vtend(ji,jj,jk),            &
-                             &         ':fse3v:', fse3v(ji,jj,jk)
+                  IF ( kt == 1 .AND. ji == 17 .AND. jj == 12 ) THEN
+                      WRITE(numout, *) 'dyn_vrt_dia_3d id:', id_dia_vor,       &
+                             &         ' :ji: ',     ji,                       &
+                             &         ' :jj: ',     jj,                       &
+                             &         ' :jk: ',     jk,                       &
+                             &         ' :u_int:',   u_int(ji,jj),             &
+                             &         ' :u_tend: ', utend(ji,jj,jk),          &
+                             &         ' :e1u: ',    e1u(ji,jj),               &
+                             &         ' :umask: ',  umask(ji,jj,jk),          &
+                             &         ' :fse3u: ',  fse3u(ji,jj,jk)
+                      WRITE(numout, *) 'dyn_vrt_dia_3d id:', id_dia_vor,       &
+                             &         ' :ji: ',     ji,                       &
+                             &         ' :jj: ',     jj,                       &
+                             &         ' :jk: ',     jk,                       &
+                             &         ' :v_int:',   v_int(ji,jj),             &
+                             &         ' :v_tend: ', vtend(ji,jj,jk),          &
+                             &         ' :e2v: ',    e2v(ji,jj),               &
+                             &         ' :vmask: ',  vmask(ji,jj,jk),          &
+                             &         ' :fse3v: ',  fse3v(ji,jj,jk)
                   END IF
               END DO
@@ -416,5 +418,5 @@
       END DO
 
-      CALL dyn_vrt_dia_2d(u_int, v_int, id_dia_vor_int, id_dia_vor_mn, kt)
+      CALL dyn_vrt_dia_2d(u_int, v_int, id_dia_vor, kt)
 
       CALL wrk_dealloc(jpi, jpj, u_int)
@@ -425,5 +427,5 @@
 
    ! TODO - remove kt only used for validation
-   SUBROUTINE dyn_vrt_dia_2d( u_int, v_int, id_dia_vor_int, id_dia_vor_mn, kt)
+   SUBROUTINE dyn_vrt_dia_2d( u_int, v_int, id_dia_vor, kt)
 
       !!----------------------------------------------------------------------
@@ -438,14 +440,13 @@
       !!                means
       !!             d) Call iom_put for the vertical integral vorticity
-      !!                tendencies (using id_dia_vor_int)
+      !!                tendencies (using cid_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 :: kt              ! ocean time-step index
+      !!                tendencies (using cid_dia_vor_mn)
+      !!
+      !!----------------------------------------------------------------------
+      REAL             :: u_int(jpi,jpj)  ! u vertical integral
+      REAL             :: v_int(jpi,jpj)  ! v vertical integral
+      CHARACTER(len=3) :: id_dia_vor      ! identifier for the vorticity diagnostic
+      INTEGER          :: kt              ! ocean time-step index TODO remove after validation
       !
       !!----------------------------------------------------------------------
@@ -469,34 +470,28 @@
       CALL lbc_lnk( v_int, 'V', 1. )
 
-      WRITE ( cid_dia_vor_int, "(A16,I2)" ) "dia_vor_int-",  id_dia_vor_int
-      WRITE ( cid_dia_vor_mn,  "(A17,I2)" ) "dia_vor_mean-", id_dia_vor_mn
+      WRITE ( cid_dia_vor_int, "(A16,A3)" ) "dia_vor_int-",  id_dia_vor
+      WRITE ( cid_dia_vor_mn,  "(A17,A3)" ) "dia_vor_mean-", id_dia_vor
 
       !
       ! Calculate the vorticity tendencies for the vertical integrals.
-      ! 1/e1e2 * ((e2*d(vtend)/dx) - (e1*d(utend)/dy))
-      !
-
-      DO jj = 1,jpjm1
-          DO ji = 1,jpim1
-              vor_int(ji,jj) = ( v_int(ji+1,jj) * e2v(ji+1,jj)     &
-                  &            - v_int(ji,jj)   * e2v(ji,jj)       &
-                  &            + u_int(ji,jj)   * e1u(ji,jj)       &
-                  &            - u_int(ji,jj+1) * e1u(ji,jj+1) )   &
-                  &           / ( e1f(ji,jj)    * e2f(ji,jj) )
+      ! 1/e1e2 * ((d(vtend)/dx) - (d(utend)/dy))
+      !
+
+      DO jj = 2, jpjm1
+          DO ji = fs_2, fs_jpim1
+              vor_int(ji,jj) = (   ( v_int(ji+1,jj) - v_int(ji,jj) )     &
+                  &              - ( u_int(ji,jj+1) - u_int(ji,jj) ) )   &
+                  &            / ( e1f(ji,jj)    * e2f(ji,jj) )
 
               ! TODO remove - for validation only
-              IF ( kt == 1 .AND. ji == 17 .AND. jj == 12 .AND. id_dia_vor_int == 11 ) THEN
-                  WRITE(numout, *) 'dyn_vrt_dia_2d id:', id_dia_vor_int, &
+              IF ( kt == 1 .AND. ji == 17 .AND. jj == 12 ) THEN
+                  WRITE(numout, *) 'dyn_vrt_dia_2d id:', id_dia_vor,     &
                        &           ':ji:', ji,                           &
                        &           ':jj:', jj,                           &
                        &           ':vor_int:', vor_int(ji,jj),          &
                        &           ':v_int(i+1):', v_int(ji+1,jj),       &
-                       &           ':e2v(j+1):', e2v(ji+1,jj),           &
                        &           ':v_int:', v_int(ji,jj),              &
-                       &           ':e2v:', e2v(ji,jj),                  &
                        &           ':u_int:', u_int(ji,jj),              &
-                       &           ':e1u:', e1u(ji,jj),                  &
                        &           ':u_int(j+1):', u_int(ji,jj+1),       &
-                       &           ':e1u(j+1):', e1u(ji,jj+1),           &
                        &           ':e1f:', e1f(ji,jj),                  &
                        &           ':e2f:', e2f(ji,jj)
@@ -505,4 +500,6 @@
       END DO
 
+      ! Multiply by the surface mask
+      vor_int(:,:) = vor_int(:,:) * fmask(:,:,1)
 
       !
@@ -512,11 +509,11 @@
       !
 
-      DO jj = 1, jpj
-          DO ji = 1, jpi
+      DO jj = 2, jpjm1
+          DO ji = fs_2, fs_jpim1
               ikbu = mbku(ji,jj)
               ikbv = mbkv(ji,jj)
 
               IF (ikbu .ne. 0.0_wp) THEN      ! Don't divide by 0!
-                  u_mn(ji,jj) = u_int(ji,jj) / ikbu
+                  u_mn(ji,jj) = u_int(ji,jj) / gdepw_n(ji,jj,ikbu+1)
               ELSE
                   u_mn(ji,jj) = 0.0_wp
@@ -524,5 +521,5 @@
 
               IF (ikbv .ne. 0.0_wp) THEN      ! Don't divide by 0!
-                  v_mn(ji,jj) = v_int(ji,jj) / ikbv
+                  v_mn(ji,jj) = v_int(ji,jj) / gdepw_n(ji,jj,ikbv+1)
               ELSE
                   v_mn(ji,jj) = 0.0_wp
@@ -530,11 +527,11 @@
 
               ! TODO remove - for validation only
-              IF ( kt == 1 .AND. ji == 17 .AND. jj == 12 .AND. id_dia_vor_int == 11 ) THEN
-                  WRITE(numout, *) 'dyn_vrt_dia_2d id:', id_dia_vor_int, &
-                       &           ':ikbu:', ikbu,                       &
-                       &           ':u_int:', u_int(ji,jj),              &
-                       &           ':u_mn:', u_mn(ji,jj),                &
-                       &           ':ikbv:', ikbv,                       &
-                       &           ':v_int:', v_int(ji,jj),              &
+              IF ( kt == 1 .AND. ji == 17 .AND. jj == 12 ) THEN
+                  WRITE(numout, *) 'dyn_vrt_dia_2d id:', id_dia_vor,          &
+                       &           ':gdepw_n(ikbu):', gdepw_n(ji,jj,ikbu+1),  &
+                       &           ':u_int:', u_int(ji,jj),                   &
+                       &           ':u_mn:', u_mn(ji,jj),                     &
+                       &           ':gdepw_n(ikbv):', gdepw_n(ji,jj,ikbv+1),  &
+                       &           ':v_int:', v_int(ji,jj),                   &
                        &           ':v_mn:', v_mn(ji,jj)
               END IF
@@ -544,29 +541,23 @@
       !
       ! Calculate the vorticity tendencies for the vertical means
-      ! 1/e1e2 * ((e2*d(v_mn)/dx) - (e1*d(u_mn)/dy))
-      !
-
-      DO jj = 1,jpjm1
-          DO ji = 1,jpim1
-              vor_mn(ji,jj) = ( v_mn(ji+1,jj) * e2v(ji+1,jj)     &
-                  &           - v_mn(ji,jj)   * e2v(ji,jj)       &
-                  &           + u_mn(ji,jj)   * e1u(ji,jj)       &
-                  &           - u_mn(ji,jj+1) * e1u(ji,jj+1) )   &
+      ! 1/e1e2 * ((d(v_mn)/dx) - (d(u_mn)/dy))
+      !
+
+      DO jj = 2, jpjm1
+          DO ji = fs_2, fs_jpim1
+              vor_mn(ji,jj) = (   ( v_mn(ji+1,jj) - v_mn(ji,jj) )        &
+                  &             - ( u_mn(ji,jj+1) - u_mn(ji,jj) ) )      &
                   &          / ( e1f(ji,jj)   * e2f(ji,jj) )
 
               ! TODO remove - for validation only
-              IF ( kt == 1 .AND. ji == 17 .AND. jj == 12 .AND. id_dia_vor_int == 11 ) THEN
-                  WRITE(numout, *) 'dyn_vrt_dia_2d id:', id_dia_vor_int, &
+              IF ( kt == 1 .AND. ji == 17 .AND. jj == 12 ) THEN
+                  WRITE(numout, *) 'dyn_vrt_dia_2d id:', id_dia_vor,     &
                        &           ':ji:', ji,                           &
                        &           ':jj:', jj,                           &
                        &           ':vor_mn:', vor_mn(ji,jj),            &
                        &           ':v_mn(i+1):', v_mn(ji+1,jj),         &
-                       &           ':e2v(j+1):', e2v(ji+1,jj),           &
                        &           ':v_mn:', v_mn(ji,jj),                &
-                       &           ':e2v:', e2v(ji,jj),                  &
                        &           ':u_mn:', u_mn(ji,jj),                &
-                       &           ':e1u:', e1u(ji,jj),                  &
                        &           ':u_mn(j+1):', u_mn(ji,jj+1),         &
-                       &           ':e1u(j+1):', e1u(ji,jj+1),           &
                        &           ':e1f:', e1f(ji,jj),                  &
                        &           ':e2f:', e2f(ji,jj)
@@ -575,4 +566,7 @@
       END DO
 
+      ! Multiply by the surface mask
+      vor_mn(:,:) = vor_mn(:,:) * fmask(:,:,1)
+
 
       ! Call iom_put for the vertical integral vorticity tendencies
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 8168)
+++ branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 8197)
@@ -379,6 +379,5 @@
       INTEGER, INTENT(in) ::   kt    ! ocean time-step index
       !!
-      INTEGER  ::   id_dia_vrt_hpg_int  = 11   ! TODO remove once flags set properly
-      INTEGER  ::   id_dia_vrt_hpg_mean = 12   ! TODO remove once flags set properly
+      CHARACTER(len=3) :: id_vrt_dia_hpg = "hpg" ! TODO remove once flags set properly
       INTEGER  ::   ji, jj, jk                 ! dummy loop indices
       REAL(wp) ::   zcoef0, zuap, zvap, znad   ! temporary scalars
@@ -416,5 +415,5 @@
             zvap = -zcoef0 * ( rhd   (ji,jj+1,1) + rhd   (ji,jj,1) + 2._wp * znad )   &
                &           * ( fsde3w(ji,jj+1,1) - fsde3w(ji,jj,1) ) / e2v(ji,jj)
-            ! combine gradient and corerction
+            ! combine gradient and correction
             zuhpg(ji,jj,1) = zhpi(ji,jj,1) + zuap
             zvhpg(ji,jj,1) = zhpj(ji,jj,1) + zvap
@@ -441,5 +440,5 @@
                zvap = -zcoef0 * ( rhd   (ji  ,jj+1,jk) + rhd   (ji,jj,jk) + 2._wp * znad )   &
                   &           * ( fsde3w(ji  ,jj+1,jk) - fsde3w(ji,jj,jk) ) / e2v(ji,jj)
-               ! combine gradient and corerction
+               ! combine gradient and correction
                zuhpg(ji,jj,jk) = zhpi(ji,jj,jk) + zuap
                zvhpg(ji,jj,jk) = zhpj(ji,jj,jk) + zvap
@@ -452,7 +451,7 @@
       !
       ! calculate dia_vor_int & dia_vor_mn if required
-      IF ( ( id_dia_vrt_hpg_int == 11 ) .or. ( id_dia_vrt_hpg_mean == 12 ) ) THEN
+      IF ( id_vrt_dia_hpg == "hpg" ) THEN
           ! TODO - remove kt only used for validation
-          CALL dyn_vrt_dia_3d(zuhpg, zvhpg, id_dia_vrt_hpg_int, id_dia_vrt_hpg_mean, kt)
+          CALL dyn_vrt_dia_3d(zuhpg, zvhpg, id_vrt_dia_hpg, kt)
       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 8168)
+++ branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynkeg.F90	(revision 8197)
@@ -75,6 +75,5 @@
       INTEGER, INTENT( in ) ::   kscheme    ! =0/1   type of KEG scheme 
       !
-      INTEGER  ::  id_dia_vrt_keg_int  = 21 ! TODO remove once flags set properly
-      INTEGER  ::  id_dia_vrt_keg_mean = 22 ! TODO remove once flags set properly
+      CHARACTER(len=3) :: id_vrt_dia_keg = "keg" ! TODO remove once flags set properly
       INTEGER  ::  ji, jj, jk               ! dummy loop indices
       REAL(wp) ::  zu, zv                   ! temporary scalars
@@ -148,7 +147,7 @@
       END DO
       !
-      IF ( ( id_dia_vrt_keg_int == 21 ) .or. ( id_dia_vrt_keg_mean == 22 ) ) THEN
+      IF ( id_vrt_dia_keg == "keg" ) THEN
           ! TODO - remove kt only used for validation
-          CALL dyn_vrt_dia_3d(zhkei, zhkej, id_dia_vrt_keg_int, id_dia_vrt_keg_mean, kt)
+          CALL dyn_vrt_dia_3d(zhkei, zhkej, id_vrt_dia_keg, kt)
       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 8168)
+++ branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_bilap.F90	(revision 8197)
@@ -76,6 +76,5 @@
       INTEGER, INTENT(in) ::   kt   ! ocean time-step index
       !
-      INTEGER  :: id_dia_vrt_ldf_int  = 31     ! TODO remove once flags set properly
-      INTEGER  :: id_dia_vrt_ldf_mean = 32     ! TODO remove once flags set properly
+      CHARACTER(len=3) :: id_vrt_dia_ldf = "ldf"  ! TODO remove once flags set properly
       INTEGER  ::   ji, jj, jk                  ! dummy loop indices
       REAL(wp) ::   zbt, ze2u, ze2v             ! temporary scalar
@@ -193,5 +192,6 @@
                ze2u = e2u(ji,jj) * fse3u(ji,jj,jk)
                ze2v = e1v(ji,jj) * fse3v(ji,jj,jk)
-               ! horizontal biharmonic diffusive trends
+               ! horizontal biharmonic diffusive trends multiplied by the
+               ! eddy viscosity coef. (at u- and v-points)
                zua(ji,jj,jk) = ( - ( zuf(ji  ,jj,jk) - zuf(ji,jj-1,jk) ) / ze2u   &
                   &  + ( zut(ji+1,jj,jk) - zut(ji,jj  ,jk) ) / e1u(ji,jj) )       &
@@ -209,7 +209,7 @@
       END DO                                           !   End of slab
       !                                                ! ===============
-      IF ( ( id_dia_vrt_ldf_int == 31 ) .or. ( id_dia_vrt_ldf_mean == 32 ) ) THEN
+      IF ( id_vrt_dia_ldf == "ldf" ) THEN
           ! TODO - remove kt only used for validation
-          CALL dyn_vrt_dia_3d(zua, zva, id_dia_vrt_ldf_int, id_dia_vrt_ldf_mean, kt)
+          CALL dyn_vrt_dia_3d(zua, zva, id_vrt_dia_ldf, kt)
       END IF
       !
Index: branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_flt.F90
===================================================================
--- branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_flt.F90	(revision 8168)
+++ branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_flt.F90	(revision 8197)
@@ -48,4 +48,5 @@
    USE lib_fortran
    USE timing          ! Timing
+   USE divcur          ! for dyn_vrt_dia_3d
 #if defined key_agrif
    USE agrif_opa_interp
@@ -108,4 +109,5 @@
       INTEGER, INTENT(  out) ::   kindic   ! solver convergence flag (<0 if not converge)
       !
+      CHARACTER(len=3) ::  id_vrt_dia_spg = "spg" ! TODO remove once flags set properly
       INTEGER  ::   ji, jj, jk   ! dummy loop indices
       REAL(wp) ::   z2dt, z2dtg, zgcb, zbtd, ztdgu, ztdgv   ! local scalars
@@ -130,4 +132,8 @@
          !                                                        ! gcx, gcxb
       ENDIF
+
+      IF ( l_trddyn .OR. ( id_vrt_dia_spg == "spg" ) )   THEN
+         CALL wrk_alloc( jpi, jpj, jpk, ztrdu, ztrdv )
+      END IF
 
       ! Local constant initialization
@@ -184,6 +190,6 @@
          END DO
          !
-         IF( l_trddyn )   THEN                      ! temporary save of spg trends
-            CALL wrk_alloc( jpi, jpj, jpk, ztrdu, ztrdv )
+                                          ! temporary save of spg trends
+         IF ( l_trddyn .OR. ( id_vrt_dia_spg == "spg" ) )   THEN
             DO jk = 1, jpkm1              ! unweighted time stepping 
                DO jj = 2, jpjm1
@@ -328,23 +334,25 @@
 #endif      
 
-      IF( l_trddyn )   THEN                     
+      IF ( l_trddyn .OR. ( id_vrt_dia_spg == "spg" ) )   THEN                     
          ztrdu(:,:,:) = ua(:,:,:)                 ! save the after velocity before the filtered SPG
          ztrdv(:,:,:) = va(:,:,:)
          !
-         CALL wrk_alloc( jpi, jpj, zpw )
-         !
-         zpw(:,:) = - z2dt * gcx(:,:)
-         CALL iom_put( "ssh_flt" , zpw )          ! output equivalent ssh modification due to implicit filter
-         !
-         !                                        ! save surface pressure flux: -pw at z=0
-         zpw(:,:) = - rau0 * grav * sshn(:,:) * wn(:,:,1) * tmask(:,:,1)
-         CALL iom_put( "pw0_exp" , zpw )
-         zpw(:,:) = wn(:,:,1)
-         CALL iom_put( "w0" , zpw )
-         zpw(:,:) =  rau0 * z2dtg * gcx(:,:) * wn(:,:,1) * tmask(:,:,1)
-         CALL iom_put( "pw0_flt" , zpw )
-         !
-         CALL wrk_dealloc( jpi, jpj, zpw ) 
-         !                                   
+         IF ( l_trddyn ) THEN
+            CALL wrk_alloc( jpi, jpj, zpw )
+            !
+            zpw(:,:) = - z2dt * gcx(:,:)
+            CALL iom_put( "ssh_flt" , zpw )          ! output equivalent ssh modification due to implicit filter
+            !
+            !                                        ! save surface pressure flux: -pw at z=0
+            zpw(:,:) = - rau0 * grav * sshn(:,:) * wn(:,:,1) * tmask(:,:,1)
+            CALL iom_put( "pw0_exp" , zpw )
+            zpw(:,:) = wn(:,:,1)
+            CALL iom_put( "w0" , zpw )
+            zpw(:,:) =  rau0 * z2dtg * gcx(:,:) * wn(:,:,1) * tmask(:,:,1)
+            CALL iom_put( "pw0_flt" , zpw )
+            !
+            CALL wrk_dealloc( jpi, jpj, zpw ) 
+            !                                   
+         ENDIF
       ENDIF
       
@@ -363,8 +371,16 @@
       END DO
 
-      IF( l_trddyn )   THEN                      ! save the explicit SPG trends for further diagnostics
+      IF ( l_trddyn .OR. ( id_vrt_dia_spg == "spg" ) )   THEN                      ! save the explicit SPG trends for further diagnostics
          ztrdu(:,:,:) = ( ua(:,:,:) - ztrdu(:,:,:) ) / z2dt
          ztrdv(:,:,:) = ( va(:,:,:) - ztrdv(:,:,:) ) / z2dt
-         CALL trd_dyn( ztrdu, ztrdv, jpdyn_spgflt, kt )
+         !
+         IF ( l_trddyn ) THEN
+            CALL trd_dyn( ztrdu, ztrdv, jpdyn_spgflt, kt )
+         END IF
+         !
+         IF ( id_vrt_dia_spg == "spg" ) THEN
+            ! TODO remove kt after validation
+            CALL dyn_vrt_dia_3d( ztrdu, ztrdv, id_vrt_dia_spg, kt )
+         END IF
          !
          CALL wrk_dealloc( jpi, jpj, jpk, ztrdu, ztrdv ) 
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 8168)
+++ branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90	(revision 8197)
@@ -561,6 +561,5 @@
       REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pva    ! total v-trend
       !!
-      INTEGER  :: id_dia_vrt_vor_int = 51                         ! TODO remove once flags set properly
-      INTEGER  :: id_dia_vrt_vor_mn  = 52                         ! TODO remove once flags set properly
+      CHARACTER(len=3) :: id_vrt_dia_vor = "vor"                  ! TODO remove once flags set properly
       INTEGER  ::   ji, jj, jk                                    ! dummy loop indices
       INTEGER  ::   ierr                                          ! local integer
@@ -707,7 +706,7 @@
       END DO                                           !   End of slab
       !                                                ! ===============
-      IF ( ( id_dia_vrt_vor_int == 51 ) .or. ( id_dia_vrt_vor_mn == 52 ) ) THEN
+      IF ( id_vrt_dia_vor == "vor" ) THEN
           ! TODO - remove kt only used for validation
-          CALL dyn_vrt_dia_3d(zua, zva, id_dia_vrt_vor_int, id_dia_vrt_vor_mn, kt)
+          CALL dyn_vrt_dia_3d(zua, zva, id_vrt_dia_vor, kt)
       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 8168)
+++ branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynzad.F90	(revision 8197)
@@ -60,6 +60,5 @@
       INTEGER, INTENT(in) ::   kt   ! ocean time-step inedx
       !
-      INTEGER  ::   id_dia_vrt_zad_int  = 61  ! TODO remove once flags set properly
-      INTEGER  ::   id_dia_vrt_zad_mean = 62  ! TODO remove once flags set properly
+      CHARACTER(len=3) :: id_vrt_dia_zad = "zad" ! TODO remove once flags set properly
       INTEGER  ::   ji, jj, jk                ! dummy loop indices
       REAL(wp), POINTER, DIMENSION(:,:,:) ::  zwuw , zwvw
@@ -145,7 +144,7 @@
          &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
       !
-      IF ( ( id_dia_vrt_zad_int == 61 ) .or. ( id_dia_vrt_zad_mean == 62 ) ) THEN
+      IF ( id_vrt_dia_zad == "zad" ) THEN
           ! TODO - remove kt only used for validation
-          CALL dyn_vrt_dia_3d(zua, zva, id_dia_vrt_zad_int, id_dia_vrt_zad_mean, kt)
+          CALL dyn_vrt_dia_3d(zua, zva, id_vrt_dia_zad, kt)
       END IF
       !
Index: branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_imp.F90
===================================================================
--- branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_imp.F90	(revision 8168)
+++ branches/UKMO/GO6_dyn_vrt_diag/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_imp.F90	(revision 8197)
@@ -67,8 +67,7 @@
       REAL(wp), INTENT(in) ::  p2dt   ! vertical profile of tracer time-step
       !!
+      CHARACTER(len=3) ::   id_vrt_dia_zdf = "zdf" ! TODO remove once flags set properly
       INTEGER  ::   ji, jj, jk   ! dummy loop indices
       INTEGER  ::   ikbu, ikbv   ! local integers
-      INTEGER  ::   id_dia_vrt_zdf_int = 71 ! TODO remove once flags set properly
-      INTEGER  ::   id_dia_vrt_zdf_mn  = 72 ! TODO remove once flags set properly
       REAL(wp) ::   z1_p2dt, zcoef, zzwi, zzws, zrhs   ! local scalars
       REAL(wp) ::   ze3ua, ze3va
@@ -262,6 +261,5 @@
       END DO
 
-      IF ( ( .NOT. lk_dynspg_ts ) .OR.            &
-           &    ( ( id_dia_vrt_zdf_int == 71 ) .OR. ( id_dia_vrt_zdf_mn == 72 ) ) ) THEN
+      IF ( ( .NOT. lk_dynspg_ts ) .OR. ( id_vrt_dia_zdf == "zdf" ) ) THEN
       ! Normalization to obtain the general momentum trend ua
           DO jk = 1, jpkm1
@@ -367,6 +365,5 @@
       END DO
 
-      IF ( ( .NOT. lk_dynspg_ts ) .OR.            &
-           &    ( ( id_dia_vrt_zdf_int == 71 ) .OR. ( id_dia_vrt_zdf_mn == 72 ) ) ) THEN
+      IF ( ( .NOT. lk_dynspg_ts ) .OR. ( id_vrt_dia_zdf == "zdf" ) ) THEN
       ! Normalization to obtain the general momentum trend va
           DO jk = 1, jpkm1
@@ -377,7 +374,7 @@
              END DO
           END DO
-          IF ( ( id_dia_vrt_zdf_int == 71 ) .OR. (id_dia_vrt_zdf_mn == 72) ) THEN
+          IF ( id_vrt_dia_zdf == "zdf" ) THEN
               ! TODO - remove kt only used for validation
-              CALL dyn_vrt_dia_3d(zua, zva, id_dia_vrt_zdf_int, id_dia_vrt_zdf_mn, kt)
+              CALL dyn_vrt_dia_3d(zua, zva, id_vrt_dia_zdf, kt)
           END IF
           IF ( .NOT. lk_dynspg_ts ) THEN
