Index: /LMDZ4/trunk/libf/phylmd/phys_output_mod.F90
===================================================================
--- /LMDZ4/trunk/libf/phylmd/phys_output_mod.F90	(revision 1099)
+++ /LMDZ4/trunk/libf/phylmd/phys_output_mod.F90	(revision 1100)
@@ -584,4 +584,9 @@
  CALL histdef2d(iff,flag_fbase,"fbase","Cld base mass flux","kg/m2/s")
  CALL histdef2d(iff,flag_prw,"prw","Precipitable water","kg/m2")
+ CALL histdef2d(iff,flag_cape_max,"cape_max","CAPE max.", "J/kg")
+ CALL histdef3d(iff,flag_upwd,"upwd","saturated updraft", "kg/m2/s")
+ CALL histdef3d(iff,flag_Ma,"Ma","undilute adiab updraft","kg/m2/s")
+ CALL histdef3d(iff,flag_dnwd,"dnwd","saturated downdraft","kg/m2/s")
+ CALL histdef3d(iff,flag_dnwd0,"dnwd0","unsat. downdraft", "kg/m2/s")
      ENDIF !iflag_con .GE. 3
 
@@ -632,15 +637,28 @@
       CALL histdef2d(iff,flag_slab_bils, "slab_wbils_oce","Bilan au sol sur ocean slab", "W/m2")
 
- IF (iflag_con.GE.3) THEN
- CALL histdef2d(iff,flag_ale_bl,"ale_bl","ALE BL","m2/s2") 
- CALL histdef2d(iff,flag_alp_bl,"alp_bl","ALP BL","m2/s2") 
- CALL histdef2d(iff,flag_ale_wk,"ale_wk","ALE WK","m2/s2") 
- CALL histdef2d(iff,flag_alp_wk,"alp_wk","ALP WK","m2/s2") 
-
+ IF (iflag_con.EQ.3) THEN
  CALL histdef2d(iff,flag_ale,"ale","ALE","m2/s2")
  CALL histdef2d(iff,flag_alp,"alp","ALP","W/m2")
  CALL histdef2d(iff,flag_cin,"cin","Convective INhibition","m2/s2")
- CALL histdef2d(iff,flag_wape,"WAPE","WAPE","m2/s2")
- ENDIF !(iflag_con.GE.3)
+ IF (iflag_coupl.EQ.1) THEN
+  CALL histdef2d(iff,flag_ale_bl,"ale_bl","ALE BL","m2/s2") 
+  CALL histdef2d(iff,flag_alp_bl,"alp_bl","ALP BL","m2/s2") 
+ ENDIF !iflag_coupl.EQ.1
+ IF (iflag_wake.EQ.1) THEN
+  CALL histdef2d(iff,flag_ale_wk,"ale_wk","ALE WK","m2/s2") 
+  CALL histdef2d(iff,flag_alp_wk,"alp_wk","ALP WK","m2/s2") 
+  CALL histdef2d(iff,flag_wape,"WAPE","WAPE","m2/s2")
+  CALL histdef2d(iff,flag_wake_h,"wake_h","wake_h", "-")
+  CALL histdef2d(iff,flag_wake_s,"wake_s","wake_s", "-")
+  CALL histdef3d(iff,flag_dtwak,"dtwak","Wake dT","K/s")
+  CALL histdef3d(iff,flag_dqwak,"dqwak","Wake dQ","(kg/kg)/s")
+  CALL histdef3d(iff,flag_wake_deltat,"wake_deltat","wake_deltat", " ")
+  CALL histdef3d(iff,flag_wake_deltaq,"wake_deltaq","wake_deltaq", " ")
+  CALL histdef3d(iff,flag_wake_omg,"wake_omg","wake_omg", " ")
+  CALL histdef3d(iff,flag_ftd,"ftd","tend temp due aux descentes precip","-")
+  CALL histdef3d(iff,flag_fqd,"fqd","tend vap eau due aux descentes precip","-")
+ ENDIF !iflag_wake.EQ.1
+  CALL histdef3d(iff,flag_Vprecip,"Vprecip","precipitation vertical profile","-")
+ ENDIF !(iflag_con.EQ.3)
 
  CALL histdef2d(iff,flag_weakinv, "weakinv","Weak inversion", "-")
@@ -654,7 +672,4 @@
  CALL histdef2d(iff,flag_LWdownOR,"LWdownOR","Sfce incident LW radiation OR","W/m2")
  CALL histdef2d(iff,flag_snowl,"snowl","Solid Large-scale Precip.","kg/(m2*s)")
- IF (iflag_con.GE.3) THEN
- CALL histdef2d(iff,flag_cape_max,"cape_max","CAPE max.", "J/kg")
- ENDIF !(iflag_con.GE.3) 
  CALL histdef2d(iff,flag_solldown,"solldown","Down. IR rad. at surface","W/m2")
  CALL histdef2d(iff,flag_dtsvdfo,"dtsvdfo","Boundary-layer dTs(o)","K/s")
@@ -679,7 +694,4 @@
  CALL histdef3d(iff,flag_rhum,"rhum","Relative humidity","-")
  CALL histdef3d(iff,flag_ozone,"ozone","Ozone concentration", "ppmv")
- IF(iflag_con.GE.3) THEN
-  CALL histdef3d(iff,flag_upwd,"upwd","saturated updraft", "kg/m2/s")
- ENDIF !iflag_con.GE.3
  CALL histdef3d(iff,flag_dtphy,"dtphy","Physics dT","K/s")
  CALL histdef3d(iff,flag_dqphy,"dqphy","Physics dQ", "(kg/kg)/s")
@@ -701,9 +713,4 @@
  CALL histdef3d(iff,flag_kz_max,"kz_max","Kz melange max","m2/s" )
  CALL histdef3d(iff,flag_clwcon,"clwcon","Convective Cloud Liquid water content", "kg/kg") 
- IF(iflag_con.GE.3) THEN
- CALL histdef3d(iff,flag_Ma,"Ma","undilute adiab updraft","kg/m2/s")
- CALL histdef3d(iff,flag_dnwd,"dnwd","saturated downdraft","kg/m2/s")
- CALL histdef3d(iff,flag_dnwd0,"dnwd0","unsat. downdraft", "kg/m2/s")
- ENDIF !(iflag_con.GE.3) 
  CALL histdef3d(iff,flag_dtdyn,"dtdyn","Dynamics dT","K/s")
  CALL histdef3d(iff,flag_dqdyn,"dqdyn","Dynamics dQ", "(kg/kg)/s")
@@ -713,18 +720,4 @@
  CALL histdef3d(iff,flag_ducon,"ducon","Convection du","m/s2")
  CALL histdef3d(iff,flag_dqcon,"dqcon","Convection dQ", "(kg/kg)/s")
- IF(iflag_con.GE.3) THEN
- IF (iflag_wake == 1) THEN
-   CALL histdef2d(iff,flag_wake_h,"wake_h","wake_h", "-")
-   CALL histdef2d(iff,flag_wake_s,"wake_s","wake_s", "-")
-   CALL histdef3d(iff,flag_dtwak,"dtwak","Wake dT","K/s")
-   CALL histdef3d(iff,flag_dqwak,"dqwak","Wake dQ","(kg/kg)/s")
-   CALL histdef3d(iff,flag_wake_deltat,"wake_deltat","wake_deltat", " ")
-   CALL histdef3d(iff,flag_wake_deltaq,"wake_deltaq","wake_deltaq", " ")
-   CALL histdef3d(iff,flag_wake_omg,"wake_omg","wake_omg", " ")
- ENDIF
-   CALL histdef3d(iff,flag_Vprecip,"Vprecip","precipitation vertical profile","-")
-   CALL histdef3d(iff,flag_ftd,"ftd","tend temp due aux descentes precip","-")
-   CALL histdef3d(iff,flag_fqd,"fqd","tend vap eau due aux descentes precip","-")
- ENDIF !(iflag_con.GE.3)
 
  CALL histdef3d(iff,flag_dtlsc,"dtlsc","Condensation dT", "K/s")
Index: /LMDZ4/trunk/libf/phylmd/phys_output_write.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/phys_output_write.h	(revision 1099)
+++ /LMDZ4/trunk/libf/phylmd/phys_output_write.h	(revision 1100)
@@ -510,4 +510,23 @@
       CALL histwrite_phy(nid_files(iff),"prw",itau_w,prw)
         ENDIF
+!!! IM beg
+      IF (flag_cape_max(iff)<=lev_files(iff)) THEN
+       CALL histwrite_phy(nid_files(iff),"cape_max",itau_w,cape)
+      ENDIF
+      IF (flag_upwd(iff)<=lev_files(iff)) THEN
+       CALL histwrite_phy(nid_files(iff),"upwd",itau_w,upwd)
+      ENDIF
+      IF (flag_Ma(iff)<=lev_files(iff)) THEN
+       CALL histwrite_phy(nid_files(iff),"Ma",itau_w,Ma)
+      ENDIF
+
+      IF (flag_dnwd(iff)<=lev_files(iff)) THEN
+       CALL histwrite_phy(nid_files(iff),"dnwd",itau_w,dnwd)
+      ENDIF
+
+      IF (flag_dnwd0(iff)<=lev_files(iff)) THEN
+       CALL histwrite_phy(nid_files(iff),"dnwd0",itau_w,dnwd0)
+      ENDIF
+!!! IM end
       ENDIF !iflag_con .GE. 3
 
@@ -616,5 +635,14 @@
       IF (type_ocean=='force ') THEN
 
-      IF (iflag_con.GE.3) THEN
+      IF (iflag_con.EQ.3) THEN
+       IF (flag_ale(iff)<=lev_files(iff)) THEN
+       CALL histwrite_phy(nid_files(iff),"ale",itau_w,ale)
+       ENDIF
+       IF (flag_alp(iff)<=lev_files(iff)) THEN
+       CALL histwrite_phy(nid_files(iff),"alp",itau_w,alp)
+       ENDIF
+       IF (flag_cin(iff)<=lev_files(iff)) THEN
+       CALL histwrite_phy(nid_files(iff),"cin",itau_w,cin)
+       ENDIF
       IF (iflag_coupl.EQ.1) THEN
        IF (flag_ale_bl(iff)<=lev_files(iff)) THEN
@@ -634,13 +662,4 @@
        ENDIF
 
-       IF (flag_ale(iff)<=lev_files(iff)) THEN
-       CALL histwrite_phy(nid_files(iff),"ale",itau_w,ale)
-       ENDIF
-       IF (flag_alp(iff)<=lev_files(iff)) THEN
-       CALL histwrite_phy(nid_files(iff),"alp",itau_w,alp)
-       ENDIF
-       IF (flag_cin(iff)<=lev_files(iff)) THEN
-       CALL histwrite_phy(nid_files(iff),"cin",itau_w,cin)
-       ENDIF
        IF (flag_wape(iff)<=lev_files(iff)) THEN
        CALL histwrite_phy(nid_files(iff),"WAPE",itau_w,wake_pe)
@@ -667,8 +686,14 @@
        CALL histwrite_phy(nid_files(iff),"wake_omg",itau_w,wake_omg)
         ENDIF
-      ENDIF
-
-        IF (flag_Vprecip(iff)<=lev_files(iff)) THEN
-       CALL histwrite_phy(nid_files(iff),"Vprecip",itau_w,Vprecip)
+!!!IM beg
+        IF (flag_dtwak(iff)<=lev_files(iff)) THEN
+          zx_tmp_fi3d(1:klon,1:klev)=d_t_wake(1:klon,1:klev)
+     &                                        /pdtphys
+          CALL histwrite_phy(nid_files(iff),"dtwak",itau_w,zx_tmp_fi3d)
+        ENDIF
+
+        IF (flag_dqwak(iff)<=lev_files(iff)) THEN
+         zx_tmp_fi3d(1:klon,1:klev)=d_q_wake(1:klon,1:klev)/pdtphys
+         CALL histwrite_phy(nid_files(iff),"dqwak",itau_w,zx_tmp_fi3d)
         ENDIF
 
@@ -680,6 +705,12 @@
        CALL histwrite_phy(nid_files(iff),"fqd",itau_w,fqd)
         ENDIF
-
-      ENDIF !(iflag_con.GE.3) 
+!!!IM end
+      ENDIF
+
+       IF (flag_Vprecip(iff)<=lev_files(iff)) THEN
+        CALL histwrite_phy(nid_files(iff),"Vprecip",itau_w,Vprecip)
+       ENDIF
+
+      ENDIF !(iflag_con.EQ.3) 
  
       ELSE IF (type_ocean=='slab  ') THEN
@@ -759,10 +790,4 @@
       CALL histwrite_phy(nid_files(iff),"snowl",itau_w,snow_lsc)
       ENDIF
-
-      IF (iflag_con.GE.3) THEN
-      IF (flag_cape_max(iff)<=lev_files(iff)) THEN
-      CALL histwrite_phy(nid_files(iff),"cape_max",itau_w,cape)
-      ENDIF
-      ENDIF !(iflag_con.GE.3)
 
       IF (flag_solldown(iff)<=lev_files(iff)) THEN
@@ -854,10 +879,4 @@
       CALL histwrite_phy(nid_files(iff),"ozone",itau_w,zx_tmp_fi3d)
       ENDIF
-
-      IF(iflag_con.GE.3) THEN
-       IF (flag_upwd(iff)<=lev_files(iff)) THEN
-      CALL histwrite_phy(nid_files(iff),"upwd",itau_w,upwd)
-       ENDIF
-      ENDIF !(iflag_con.GE.3)
 
        IF (flag_dtphy(iff)<=lev_files(iff)) THEN
@@ -933,18 +952,4 @@
        ENDIF
 
-      IF(iflag_con.GE.3) THEN
-       IF (flag_Ma(iff)<=lev_files(iff)) THEN
-      CALL histwrite_phy(nid_files(iff),"Ma",itau_w,Ma)
-       ENDIF
-
-       IF (flag_dnwd(iff)<=lev_files(iff)) THEN
-      CALL histwrite_phy(nid_files(iff),"dnwd",itau_w,dnwd)
-       ENDIF
-
-       IF (flag_dnwd0(iff)<=lev_files(iff)) THEN
-      CALL histwrite_phy(nid_files(iff),"dnwd0",itau_w,dnwd0)
-       ENDIF
-      ENDIF !(iflag_con.GE.3)
-
        IF (flag_dtdyn(iff)<=lev_files(iff)) THEN
       CALL histwrite_phy(nid_files(iff),"dtdyn",itau_w,d_t_dyn)
@@ -977,19 +982,4 @@
       CALL histwrite_phy(nid_files(iff),"dqcon",itau_w,zx_tmp_fi3d)
        ENDIF
-
-      IF(iflag_con.GE.3) THEN
-       IF (iflag_wake == 1) THEN
-         IF (flag_dtwak(iff)<=lev_files(iff)) THEN
-           zx_tmp_fi3d(1:klon,1:klev)=d_t_wake(1:klon,1:klev)           &
-     &                                        /pdtphys
-           CALL histwrite_phy(nid_files(iff),"dtwak",itau_w,zx_tmp_fi3d)
-         ENDIF
-
-        IF (flag_dqwak(iff)<=lev_files(iff)) THEN
-        zx_tmp_fi3d(1:klon,1:klev)=d_q_wake(1:klon,1:klev)/pdtphys
-        CALL histwrite_phy(nid_files(iff),"dqwak",itau_w,zx_tmp_fi3d)
-        ENDIF
-       ENDIF
-      ENDIF !(iflag_con.GE.3) 
 
        IF (flag_dtlsc(iff)<=lev_files(iff)) THEN
