Index: /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/CONFIG/SHARED/field_def.xml
===================================================================
--- /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/CONFIG/SHARED/field_def.xml	(revision 7062)
+++ /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/CONFIG/SHARED/field_def.xml	(revision 7063)
@@ -677,5 +677,5 @@
         <field id="sophtbtr_ind"      long_name="Barotropic Heat Transport: Indian"             unit="PW"       grid_ref="gznl_T_2D" />
         <field id="sophtbtr_ipc"      long_name="Barotropic Heat Transport: Pacific+Indian"     unit="PW"       grid_ref="gznl_T_2D" />
-        <field id="sophteiv"          long_name="Heat Transport from mesoscale eddy oveection"                     unit="PW"       grid_ref="gznl_T_2D" />
+        <field id="sophteiv"          long_name="Heat Transport from mesoscale eddy advection"                     unit="PW"       grid_ref="gznl_T_2D" />
         <field id="sophteiv_atl"      long_name="Heat Transport from mesoscale eddy advection: Atlantic"           unit="PW"       grid_ref="gznl_T_2D" />
         <field id="sophteiv_pac"      long_name="Heat Transport from mesoscale eddy advection: Pacific"            unit="PW"       grid_ref="gznl_T_2D" />
@@ -782,5 +782,5 @@
       <field id="ketrd_convP2K" long_name="ke-trend: conversion (potential to kinetic)"      unit="W/s^3"                        />
       <field id="KE"            long_name="kinetic energy: u(n)*u(n+1)/2"                    unit="W/s^2"                        />   
-      <field id="ketrd_eiv"     long_name="Kinetic energy trend from mesoscale eddy advection"   unit="W/s^2"                        />   
+      <field id="ketrd_eiv"     long_name="Kinetic energy trend from mesoscale eddy advection"   unit="W/s^2" grid_ref="grid_T_2D" />   
 
       <!-- variables available with ln_PE_trd -->
@@ -802,4 +802,5 @@
       <field id="alphaPE"       long_name="partial deriv. of PEanom wrt T"       unit="degree_C-1"                       />   
       <field id="betaPE"        long_name="partial deriv. of PEanom wrt S"       unit="1e3"                          />   
+      <field id="petrd_zdfp_e3t"    unit="W/m^2" grid_ref="grid_T_3D"  > petrd_zdfp * e3t </field>
     </field_group>
 
@@ -1014,4 +1015,5 @@
        <field id="INTPBSI"     long_name="Vertically integrated of biogenic Si production"     unit="mol/m2/s"                       />
        <field id="INTPCAL"     long_name="Vertically integrated of calcite production"         unit="mol/m2/s"                       />
+       <field id="pe_trd"      long_name="Tendency of ocean potential energy content"          unit="W/m2"                           />
 
        <!-- PISCES light : variables available with key_pisces_reduced -->
Index: /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/DIA/diaar5.F90
===================================================================
--- /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/DIA/diaar5.F90	(revision 7062)
+++ /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/DIA/diaar5.F90	(revision 7063)
@@ -24,4 +24,6 @@
    USE phycst         ! physical constant
    USE in_out_manager  ! I/O manager
+   USE zdfddm
+   USE zdf_oce
 
    IMPLICIT NONE
@@ -42,4 +44,5 @@
    !! * Substitutions
 #  include "domzgr_substitute.h90"
+#  include "zdfddm_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
@@ -75,6 +78,8 @@
       INTEGER  ::   ji, jj, jk                      ! dummy loop arguments
       REAL(wp) ::   zvolssh, zvol, zssh_steric, zztmp, zarho, ztemp, zsal, zmass
+      REAL(wp) ::   zaw, zbw, zrw
       !
       REAL(wp), POINTER, DIMENSION(:,:)     :: zarea_ssh , zbotpres       ! 2D workspace 
+      REAL(wp), POINTER, DIMENSION(:,:)     :: pe                         ! 2D workspace 
       REAL(wp), POINTER, DIMENSION(:,:,:)   :: zrhd , zrhop               ! 3D workspace
       REAL(wp), POINTER, DIMENSION(:,:,:,:) :: ztsn                       ! 4D workspace
@@ -82,5 +87,5 @@
       IF( nn_timing == 1 )   CALL timing_start('dia_ar5')
  
-      CALL wrk_alloc( jpi , jpj              , zarea_ssh , zbotpres )
+      CALL wrk_alloc( jpi , jpj              , zarea_ssh , zbotpres, pe )
       CALL wrk_alloc( jpi , jpj , jpk        , zrhd      , zrhop    )
       CALL wrk_alloc( jpi , jpj , jpk , jpts , ztsn                 )
Index: /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_flt.F90
===================================================================
--- /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_flt.F90	(revision 7062)
+++ /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_flt.F90	(revision 7063)
@@ -166,4 +166,7 @@
             !
          ENDIF
+        IF( l_trddyn )   THEN                      ! Put here so code doesn't crash when doing KE trend but needs to be done properly
+            CALL wrk_alloc( jpi, jpj, jpk, ztrdu, ztrdv )
+         ENDIF
          !
       ELSE                       ! fixed volume  (add the surface pressure gradient + unweighted time stepping)
Index: /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_eiv.F90
===================================================================
--- /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_eiv.F90	(revision 7062)
+++ /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_eiv.F90	(revision 7063)
@@ -29,4 +29,6 @@
    USE timing          ! Timing
    USE diaptr         ! Heat/Salt transport diagnostics
+   USE trddyn
+   USE trd_oce
 
    IMPLICIT NONE
@@ -241,5 +243,5 @@
     ENDIF
 
-    IF( ln_trddyn .AND. ln_KE_trd ) CALL trd_dyn(u_eiv, v_eiv, jptrd_eivke, kt )
+    IF( ln_KE_trd ) CALL trd_dyn(u_eiv, v_eiv, jpdyn_eivke, kt )
 # endif  
 
Index: /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRD/trdini.F90
===================================================================
--- /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRD/trdini.F90	(revision 7062)
+++ /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRD/trdini.F90	(revision 7063)
@@ -91,5 +91,5 @@
 !!gm end
       !
-      IF( lk_vvl .AND. ( l_trdtra .OR. l_trddyn ) )  CALL ctl_stop( 'trend diagnostics with variable volume not validated' )
+!      IF( lk_vvl .AND. ( l_trdtra .OR. l_trddyn ) )  CALL ctl_stop( 'trend diagnostics with variable volume not validated' )
       
 !!gm  : Potential BUG : 3D output only for vector invariant form!  add a ctl_stop or code the flux form case
Index: /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRD/trdken.F90
===================================================================
--- /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRD/trdken.F90	(revision 7062)
+++ /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRD/trdken.F90	(revision 7063)
@@ -105,4 +105,6 @@
       ENDIF
       !
+      zke(:,:,jpk) = 0._wp
+      zke(1,:, : ) = 0._wp
       zke(:,1, : ) = 0._wp
       DO jk = 1, jpkm1
@@ -200,4 +202,5 @@
             ! S = isoneutral slope.
             ! Most terms are on W grid so work on this grid
+            CALL wrk_alloc( jpi, jpj, zke2d )
             zke2d(:,:) = 0._wp
             DO jk = 1,jpk
@@ -207,9 +210,10 @@
                           &                      * ( wslpi(ji, jj, jk) * wslpi(ji,jj,jk)    &
                           &                      +   wslpj(ji, jj, jk) * wslpj(ji,jj,jk) )  &
-                          &                      *   bn2(ji,jj,jk) * fse3w(ji, jj, jk)
+                          &                      *   rn2(ji,jj,jk) * fse3w(ji, jj, jk)
                   ENDDO
                ENDDO
             ENDDO
-            iom_put("ketrd_eiv", zke2d)
+            CALL iom_put("ketrd_eiv", zke2d)
+            CALL wrk_dealloc( jpi, jpj, zke2d )
          !
       END SELECT
Index: /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRD/trdpen.F90
===================================================================
--- /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRD/trdpen.F90	(revision 7062)
+++ /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRD/trdpen.F90	(revision 7063)
@@ -150,5 +150,5 @@
       rab_pe(:,:,:,:) = 0._wp
       !
-      IF ( lk_vvl               )   CALL ctl_stop('trd_pen_init : PE trends not coded for variable volume')
+!      IF ( lk_vvl               )   CALL ctl_stop('trd_pen_init : PE trends not coded for variable volume')
       !
       nkstp     = nit000 - 1
