Index: NEMO/trunk/src/OCE/OBS/diaobs.F90
===================================================================
--- NEMO/trunk/src/OCE/OBS/diaobs.F90	(revision 14978)
+++ NEMO/trunk/src/OCE/OBS/diaobs.F90	(revision 14982)
@@ -99,4 +99,5 @@
    CHARACTER(len=8), PUBLIC, DIMENSION(:), ALLOCATABLE ::   cobstypesprof, cobstypessurf   !: Profile & surface obs types
 
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -623,5 +624,5 @@
       INTEGER :: jtype             ! Data loop variable
       INTEGER :: jvar              ! Variable number
-      INTEGER :: ji, jj            ! Loop counters
+      INTEGER :: ji, jj, jk        ! Loop counters
       REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE :: &
          & zprofvar                ! Model values for variables in a prof ob
@@ -634,4 +635,5 @@
          & zglam,    &             ! Model longitudes for prof variables
          & zgphi                   ! Model latitudes for prof variables
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: zdept, zdepw
 
       !-----------------------------------------------------------------------
@@ -650,4 +652,10 @@
 
       IF ( nproftypes > 0 ) THEN
+
+         ALLOCATE( zdept(jpi,jpj,jpk), zdepw(jpi,jpj,jpk) )
+         DO jk = 1, jpk
+            zdept(:,:,jk) = gdept(:,:,jk,Kmm)
+            zdepw(:,:,jk) = gdepw(:,:,jk,Kmm)
+         END DO
 
          DO jtype = 1, nproftypes
@@ -687,5 +695,5 @@
                   &               nit000, idaystp, jvar,                   &
                   &               zprofvar(:,:,:,jvar),                    &
-                  &               gdept(:,:,:,Kmm), gdepw(:,:,:,Kmm),      &
+                  &               zdept(:,:,:), zdepw(:,:,:),      &
                   &               zprofmask(:,:,:,jvar),                   &
                   &               zglam(:,:,jvar), zgphi(:,:,jvar),        &
@@ -697,4 +705,6 @@
 
          END DO
+
+         DEALLOCATE( zdept, zdepw )
 
       ENDIF
Index: NEMO/trunk/src/OCE/OBS/obs_prep.F90
===================================================================
--- NEMO/trunk/src/OCE/OBS/obs_prep.F90	(revision 14978)
+++ NEMO/trunk/src/OCE/OBS/obs_prep.F90	(revision 14982)
@@ -33,4 +33,5 @@
    PUBLIC   calc_month_len   ! Calculate the number of days in the months of a year
 
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -1074,5 +1075,5 @@
          & gdepw_1d,      &
          & gdepw_0,       &                       
-         & gdepw,         &
+         & gdepw, r3t,    &
          & gdept,         &
          & ln_zco,        &
@@ -1128,4 +1129,5 @@
          & zglam, &           ! Model longitude at grid points
          & zgphi              ! Model latitude at grid points
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zdepw
       INTEGER, DIMENSION(2,2,kprofno) :: &
          & igrdi, &           ! Grid i,j
@@ -1186,6 +1188,8 @@
       CALL obs_int_comm_2d( 2, 2, kprofno, kpi, kpj, igrdi, igrdj, plam, zglam )
       CALL obs_int_comm_2d( 2, 2, kprofno, kpi, kpj, igrdi, igrdj, pphi, zgphi )
-      CALL obs_int_comm_3d( 2, 2, kprofno, kpi, kpj, kpk, igrdi, igrdj, gdepw(:,:,:,Kmm), &
-        &                     zgdepw )
+      DO jk = 1, jpk
+         zdepw(:,:,jk) = gdepw(:,:,jk,Kmm)
+      END DO
+      CALL obs_int_comm_3d( 2, 2, kprofno, kpi, kpj, kpk, igrdi, igrdj, zdepw(:,:,:), zgdepw )
 
       DO jobs = 1, kprofno
Index: NEMO/trunk/src/OCE/TRA/tradmp.F90
===================================================================
--- NEMO/trunk/src/OCE/TRA/tradmp.F90	(revision 14978)
+++ NEMO/trunk/src/OCE/TRA/tradmp.F90	(revision 14982)
@@ -53,4 +53,5 @@
    !! * Substitutions
 #  include "do_loop_substitute.h90"
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -96,4 +97,5 @@
       INTEGER ::   ji, jj, jk, jn   ! dummy loop indices
       REAL(wp), DIMENSION(A2D(nn_hls),jpk,jpts)     ::  zts_dta
+      REAL(wp), DIMENSION(:,:,:)  , ALLOCATABLE ::  zwrk
       REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::  ztrdts
       !!----------------------------------------------------------------------
@@ -102,6 +104,10 @@
       !
       IF( l_trdtra .OR. iom_use('hflx_dmp_cea') .OR. iom_use('sflx_dmp_cea') ) THEN   !* Save ta and sa trends
-         ALLOCATE( ztrdts(jpi,jpj,jpk,jpts) )
-         ztrdts(:,:,:,:) = pts(:,:,:,:,Krhs)
+         ALLOCATE( ztrdts(A2D(nn_hls),jpk,jpts) )
+         DO jn = 1, jpts
+            DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpk )
+               ztrdts(ji,jj,jk,jn) = pts(ji,jj,jk,jn,Krhs)
+            END_3D
+         END DO
       ENDIF
       !                           !==  input T-S data at kt  ==!
@@ -141,10 +147,23 @@
       !
       ! outputs (clem trunk)
-      IF( iom_use('hflx_dmp_cea') )       &
-         &   CALL iom_put('hflx_dmp_cea', &
-         &   SUM( ( pts(:,:,:,jp_tem,Krhs) - ztrdts(:,:,:,jp_tem) ) * e3t(:,:,:,Kmm), dim=3 ) * rcp * rho0 ) ! W/m2
-      IF( iom_use('sflx_dmp_cea') )       &
-         &   CALL iom_put('sflx_dmp_cea', &
-         &   SUM( ( pts(:,:,:,jp_sal,Krhs) - ztrdts(:,:,:,jp_sal) ) * e3t(:,:,:,Kmm), dim=3 ) * rho0 )       ! g/m2/s
+      IF( iom_use('hflx_dmp_cea') .OR. iom_use('sflx_dmp_cea') ) THEN
+         ALLOCATE( zwrk(A2D(nn_hls),jpk) )          ! Needed to handle expressions containing e3t when using key_qco or key_linssh
+         zwrk(:,:,:) = 0._wp
+
+         IF( iom_use('hflx_dmp_cea') ) THEN
+            DO_3D( 0, 0, 0, 0, 1, jpk )
+               zwrk(ji,jj,jk) = ( pts(ji,jj,jk,jp_tem,Krhs) - ztrdts(ji,jj,jk,jp_tem) ) * e3t(ji,jj,jk,Kmm)
+            END_3D
+            CALL iom_put('hflx_dmp_cea', SUM( zwrk(:,:,:), dim=3 ) * rcp * rho0 ) ! W/m2
+         ENDIF
+         IF( iom_use('sflx_dmp_cea') ) THEN
+            DO_3D( 0, 0, 0, 0, 1, jpk )
+               zwrk(ji,jj,jk) = ( pts(ji,jj,jk,jp_sal,Krhs) - ztrdts(ji,jj,jk,jp_sal) ) * e3t(ji,jj,jk,Kmm)
+            END_3D
+            CALL iom_put('sflx_dmp_cea', SUM( zwrk(:,:,:), dim=3 ) * rho0 )       ! g/m2/s
+         ENDIF
+
+         DEALLOCATE( zwrk )
+      ENDIF
       !
       IF( l_trdtra )   THEN       ! trend diagnostic
Index: NEMO/trunk/src/OCE/ZDF/zdfric.F90
===================================================================
--- NEMO/trunk/src/OCE/ZDF/zdfric.F90	(revision 14978)
+++ NEMO/trunk/src/OCE/ZDF/zdfric.F90	(revision 14982)
@@ -51,4 +51,5 @@
    !! * Substitutions
 #  include "do_loop_substitute.h90"
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
