Index: /LMDZ5/trunk/libf/phylmd/clesphys.h
===================================================================
--- /LMDZ5/trunk/libf/phylmd/clesphys.h	(revision 1752)
+++ /LMDZ5/trunk/libf/phylmd/clesphys.h	(revision 1753)
@@ -12,5 +12,5 @@
        LOGICAL cycle_diurne,soil_model,new_oliq,ok_orodr,ok_orolf 
        LOGICAL ok_limitvrai
-       INTEGER nbapp_rad, iflag_con
+       INTEGER nbapp_rad, iflag_con,iflag_ener_conserv
        REAL co2_ppm, co2_ppm0, solaire
        REAL(kind=8) RCO2, RCH4, RN2O, RCFC11, RCFC12  
@@ -79,4 +79,5 @@
        COMMON/clesphys/cycle_diurne, soil_model, new_oliq,              &
      &     ok_orodr, ok_orolf, ok_limitvrai, nbapp_rad, iflag_con       &
+     &     , iflag_ener_conserv                                         &
      &     , co2_ppm, solaire                                           &
      &     , RCO2, RCH4, RN2O, RCFC11, RCFC12                           &
Index: /LMDZ5/trunk/libf/phylmd/conf_phys_m.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/conf_phys_m.F90	(revision 1752)
+++ /LMDZ5/trunk/libf/phylmd/conf_phys_m.F90	(revision 1753)
@@ -169,4 +169,5 @@
   LOGICAL,SAVE :: ok_orodr_omp, ok_orolf_omp, ok_limitvrai_omp
   INTEGER, SAVE :: nbapp_rad_omp, iflag_con_omp
+  INTEGER, SAVE :: iflag_ener_conserv_omp
   LOGICAL,SAVE :: ok_strato_omp
   LOGICAL,SAVE :: ok_hines_omp
@@ -653,4 +654,14 @@
        CALL getin('iflag_con',iflag_con_omp)
 
+!Config  Key  = iflag_ener_conserv
+!Config  Desc = Flag de convection
+!Config  Def  = 1
+!Config  Help = Flag  pour la convection les options suivantes existent :
+!Config         -1 pour Kinetic energy correction
+!Config         1  conservation kinetic and enthalpy
+       iflag_ener_conserv_omp = -1
+       CALL getin('iflag_ener_conserv',iflag_ener_conserv_omp)
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 !!
@@ -1637,4 +1648,5 @@
     nbapp_rad = nbapp_rad_omp
     iflag_con = iflag_con_omp
+    iflag_ener_conserv = iflag_ener_conserv_omp
 
     epmax = epmax_omp
@@ -1845,4 +1857,5 @@
   write(lunout,*)'nbapp_rad=',nbapp_rad
   write(lunout,*)'iflag_con=',iflag_con
+  write(lunout,*)'iflag_ener_conserv=',iflag_ener_conserv
   write(lunout,*)' epmax = ', epmax
   write(lunout,*)' ok_adj_ema = ', ok_adj_ema
Index: /LMDZ5/trunk/libf/phylmd/phys_output_mod.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/phys_output_mod.F90	(revision 1752)
+++ /LMDZ5/trunk/libf/phylmd/phys_output_mod.F90	(revision 1753)
@@ -156,4 +156,8 @@
   type(ctrl_out),save :: o_LWdnSFCclr   = ctrl_out((/ 1, 4, 10, 10, 5, 10 /),'LWdnSFCclr')
   type(ctrl_out),save :: o_bils         = ctrl_out((/ 1, 2, 10, 5, 10, 10 /),'bils')
+  type(ctrl_out),save :: o_bils_ec         = ctrl_out((/ 1, 2, 10, 5, 10, 10 /),'bils_ec')
+  type(ctrl_out),save :: o_bils_kinetic         = ctrl_out((/ 1, 2, 10, 5, 10, 10 /),'bils_kinetic')
+  type(ctrl_out),save :: o_bils_enthalp         = ctrl_out((/ 1, 2, 10, 5, 10, 10 /),'bils_enthalp')
+  type(ctrl_out),save :: o_bils_latent         = ctrl_out((/ 1, 2, 10, 5, 10, 10 /),'bils_latent')
   type(ctrl_out),save :: o_sens         = ctrl_out((/ 1, 1, 10, 10, 5, 10 /),'sens')
   type(ctrl_out),save :: o_fder         = ctrl_out((/ 1, 2, 10, 10, 10, 10 /),'fder')
@@ -1038,4 +1042,8 @@
           CALL histdef2d(iff,clef_stations(iff),o_LWdnSFCclr%flag,o_LWdnSFCclr%name, "Down. CS IR rad. at surface", "W/m2")
           CALL histdef2d(iff,clef_stations(iff),o_bils%flag,o_bils%name, "Surf. total heat flux", "W/m2")
+          CALL histdef2d(iff,clef_stations(iff),o_bils_ec%flag,o_bils_ec%name, "Surf. total heat flux", "W/m2")
+          CALL histdef2d(iff,clef_stations(iff),o_bils_kinetic%flag,o_bils_kinetic%name, "Surf. total heat flux", "W/m2")
+          CALL histdef2d(iff,clef_stations(iff),o_bils_enthalp%flag,o_bils_enthalp%name, "Surf. total heat flux", "W/m2")
+          CALL histdef2d(iff,clef_stations(iff),o_bils_latent%flag,o_bils_latent%name, "Surf. total heat flux", "W/m2")
           CALL histdef2d(iff,clef_stations(iff),o_sens%flag,o_sens%name, "Sensible heat flux", "W/m2")
           CALL histdef2d(iff,clef_stations(iff),o_fder%flag,o_fder%name, "Heat flux derivation", "W/m2")
Index: /LMDZ5/trunk/libf/phylmd/phys_output_var_mod.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/phys_output_var_mod.F90	(revision 1752)
+++ /LMDZ5/trunk/libf/phylmd/phys_output_var_mod.F90	(revision 1753)
@@ -15,4 +15,9 @@
 !$OMP THREADPRIVATE(snow_o, zfra_o)
       INTEGER, save, ALLOCATABLE ::  itau_con(:)       ! Nombre de pas ou rflag <= 1
+      REAL, ALLOCATABLE :: bils_ec(:) ! Contribution of energy conservation
+      REAL, ALLOCATABLE :: bils_kinetic(:) ! bilan de chaleur au sol, kinetic
+      REAL, ALLOCATABLE :: bils_enthalp(:) ! bilan de chaleur au sol
+      REAL, ALLOCATABLE :: bils_latent(:) ! bilan de chaleur au sol
+
 !$OMP THREADPRIVATE(itau_con)
 
@@ -27,4 +32,5 @@
       allocate(snow_o(klon), zfra_o(klon))
       allocate(itau_con(klon))
+      allocate (bils_ec(klon),bils_kinetic(klon),bils_enthalp(klon),bils_latent(klon))
 
 END SUBROUTINE phys_output_var_init
@@ -36,4 +42,5 @@
 
       deallocate(snow_o,zfra_o,itau_con)
+      deallocate (bils_ec,bils_kinetic,bils_enthalp,bils_latent)
 
 END SUBROUTINE phys_output_var_end
Index: /LMDZ5/trunk/libf/phylmd/phys_output_write.h
===================================================================
--- /LMDZ5/trunk/libf/phylmd/phys_output_write.h	(revision 1752)
+++ /LMDZ5/trunk/libf/phylmd/phys_output_write.h	(revision 1753)
@@ -358,4 +358,24 @@
       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
      $o_bils%name,itau_w,bils)
+       ENDIF
+
+       IF (o_bils_ec%flag(iff)<=lev_files(iff)) THEN
+      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+     $o_bils_ec%name,itau_w,bils_ec)
+       ENDIF
+
+       IF (o_bils_kinetic%flag(iff)<=lev_files(iff)) THEN
+      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+     $o_bils_kinetic%name,itau_w,bils_kinetic)
+       ENDIF
+
+       IF (o_bils_latent%flag(iff)<=lev_files(iff)) THEN
+      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+     $o_bils_latent%name,itau_w,bils_latent)
+       ENDIF
+
+       IF (o_bils_enthalp%flag(iff)<=lev_files(iff)) THEN
+      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+     $o_bils_enthalp%name,itau_w,bils_enthalp)
        ENDIF
 
@@ -2021,5 +2041,5 @@
 
        IF (o_dtec%flag(iff)<=lev_files(iff)) THEN
-      zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)
+      zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)/pdtphys
       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
      $o_dtec%name,itau_w,zx_tmp_fi3d)
Index: /LMDZ5/trunk/libf/phylmd/physiq.F
===================================================================
--- /LMDZ5/trunk/libf/phylmd/physiq.F	(revision 1752)
+++ /LMDZ5/trunk/libf/phylmd/physiq.F	(revision 1753)
@@ -722,4 +722,5 @@
 
       REAL bils(klon) ! bilan de chaleur au sol
+
       REAL wfbilo(klon,nbsrf) ! bilan d'eau, pour chaque
 C                             ! type de sous-surface et pondere par la fraction
@@ -751,5 +752,5 @@
       SAVE lmt_pas                ! frequence de mise a jour
 c$OMP THREADPRIVATE(lmt_pas) 
-      real zmasse(klon, llm) 
+      real zmasse(klon, llm),exner(klon, llm) 
 C     (column-density of mass of air in a cell, in kg m-2)
       real, parameter:: dobson_u = 2.1415e-05 ! Dobson unit, in kg m-2
@@ -3748,20 +3749,17 @@
 c Accumuler les variables a stocker dans les fichiers histoire:
 c
-c+jld ec_conser
-      DO k = 1, klev
-      DO i = 1, klon
-        ZRCPD = RCPD*(1.0+RVTMP2*q_seri(i,k))
-        d_t_ec(i,k)=0.5/ZRCPD
-     $      *(u(i,k)**2+v(i,k)**2-u_seri(i,k)**2-v_seri(i,k)**2)
-      ENDDO
-      ENDDO
-
-      DO k = 1, klev
-      DO i = 1, klon
-        t_seri(i,k)=t_seri(i,k)+d_t_ec(i,k)
-        d_t_ec(i,k) = d_t_ec(i,k)/dtime
-       END DO 
-      END DO 
-c-jld ec_conser
+
+!================================================================
+! Conversion of kinetic and potential energy into heat, for
+! parameterisation of subgrid-scale motions
+!================================================================
+
+      d_t_ec(:,:)=0.
+      forall (k=1: llm) exner(:, k) = (pplay(:, k)/paprs(:,1))**RKAPPA
+      CALL ener_conserv(klon,klev,pdtphys,u,v,t,qx(:,:,ivap),
+     s        u_seri,v_seri,t_seri,q_seri,
+     s        zmasse,exner,d_t_ec)
+      t_seri(:,:)=t_seri(:,:)+d_t_ec(:,:)
+
 cIM
       IF (ip_ebil_phy.ge.1) THEN 
@@ -3833,5 +3831,5 @@
       END IF
 
-c=============================================================
+
 c
 c Convertir les incrementations en tendances
