Index: /LMDZ4/branches/LMDZ4-dev/libf/phylmd/phys_output_mod.F90
===================================================================
--- /LMDZ4/branches/LMDZ4-dev/libf/phylmd/phys_output_mod.F90	(revision 1118)
+++ /LMDZ4/branches/LMDZ4-dev/libf/phylmd/phys_output_mod.F90	(revision 1119)
@@ -714,4 +714,9 @@
  CALL histdef2d(iff,o_fbase%flag,o_fbase%name, "Cld base mass flux", "kg/m2/s")
  CALL histdef2d(iff,o_prw%flag,o_prw%name, "Precipitable water", "kg/m2")
+ CALL histdef2d(iff,o_cape_max%flag,o_cape_max%name,"CAPE max.", "J/kg")
+ CALL histdef3d(iff,o_upwd%flag,o_upwd%name,"saturated updraft", "kg/m2/s")
+ CALL histdef3d(iff,o_Ma%flag,o_Ma%name,"undilute adiab updraft","kg/m2/s")
+ CALL histdef3d(iff,o_dnwd%flag,o_dnwd%name,"saturated downdraft","kg/m2/s")
+ CALL histdef3d(iff,o_dnwd0%flag,o_dnwd0%name,"unsat. downdraft", "kg/m2/s")
      ENDIF !iflag_con .GE. 3
 
@@ -768,15 +773,28 @@
      CALL histdef2d(iff,o_slab_bils%flag, o_slab_bils%name,"Bilan au sol sur ocean slab", "W/m2")
 
- IF (iflag_con.GE.3) THEN
- CALL histdef2d(iff,o_ale_bl%flag,o_ale_bl%name, "ALE BL", "m2/s2") 
- CALL histdef2d(iff,o_alp_bl%flag,o_alp_bl%name, "ALP BL", "m2/s2") 
- CALL histdef2d(iff,o_ale_wk%flag,o_ale_wk%name, "ALE WK", "m2/s2") 
- CALL histdef2d(iff,o_alp_wk%flag,o_alp_wk%name, "ALP WK", "m2/s2") 
-
- CALL histdef2d(iff,o_ale%flag,o_ale%name, "ALE", "m2/s2")
- CALL histdef2d(iff,o_alp%flag,o_alp%name, "ALP", "W/m2")
- CALL histdef2d(iff,o_cin%flag,o_cin%name, "Convective INhibition", "m2/s2")
- CALL histdef2d(iff,o_wape%flag,o_WAPE%name, "WAPE", "m2/s2")
- ENDIF !(iflag_con.GE.3)
+ IF (iflag_con.EQ.3) THEN
+ CALL histdef2d(iff,o_ale%flag,o_ale%name,"ALE","m2/s2")
+ CALL histdef2d(iff,o_alp%flag,o_alp%name,"ALP","W/m2")
+ CALL histdef2d(iff,o_cin%flag,o_cin%name,"Convective INhibition","m2/s2")
+ IF (iflag_coupl.EQ.1) THEN
+  CALL histdef2d(iff,o_ale_bl%flag,o_ale_bl%name,"ALE BL","m2/s2") 
+  CALL histdef2d(iff,o_alp_bl%flag,o_alp_bl%name,"ALP BL","m2/s2") 
+ ENDIF !iflag_coupl.EQ.1
+ IF (iflag_wake.EQ.1) THEN
+  CALL histdef2d(iff,o_ale_wk%flag,o_ale_wk%name,"ALE WK","m2/s2") 
+  CALL histdef2d(iff,o_alp_wk%flag,o_alp_wk%name,"ALP WK","m2/s2") 
+  CALL histdef2d(iff,o_wape%flag,o_WAPE%name,"WAPE","m2/s2")
+  CALL histdef2d(iff,o_wake_h%flag,o_wake_h%name,"wake_h", "-")
+  CALL histdef2d(iff,o_wake_s%flag,o_wake_s%name,"wake_s", "-")
+  CALL histdef3d(iff,o_dtwak%flag,o_dtwak%name,"Wake dT","K/s")
+  CALL histdef3d(iff,o_dqwak%flag,o_dqwak%name,"Wake dQ","(kg/kg)/s")
+  CALL histdef3d(iff,o_wake_deltat%flag,o_wake_deltat%name,"wake_deltat", " ")
+  CALL histdef3d(iff,o_wake_deltaq%flag,o_wake_deltaq%name,"wake_deltaq", " ")
+  CALL histdef3d(iff,o_wake_omg%flag,o_wake_omg%name,"wake_omg", " ")
+  CALL histdef3d(iff,o_ftd%flag,o_ftd%name,"tend temp due aux descentes precip","-")
+  CALL histdef3d(iff,o_fqd%flag,o_fqd%name,"tend vap eau due aux descentes precip","-")
+ ENDIF !iflag_wake.EQ.1
+  CALL histdef3d(iff,o_Vprecip%flag,o_Vprecip%name,"precipitation vertical profile","-")
+ ENDIF !(iflag_con.EQ.3)
 
  CALL histdef2d(iff,o_weakinv%flag,o_weakinv%name, "Weak inversion", "-")
@@ -790,7 +808,4 @@
  CALL histdef2d(iff,o_LWdownOR%flag,o_LWdownOR%name, "Sfce incident LW radiation OR", "W/m2")
  CALL histdef2d(iff,o_snowl%flag,o_snowl%name, "Solid Large-scale Precip.", "kg/(m2*s)")
- IF (iflag_con.GE.3) THEN
- CALL histdef2d(iff,o_cape_max%flag,o_cape_max%name, "CAPE max.", "J/kg")
- ENDIF !(iflag_con.GE.3) 
  CALL histdef2d(iff,o_solldown%flag,o_solldown%name, "Down. IR rad. at surface", "W/m2")
  CALL histdef2d(iff,o_dtsvdfo%flag,o_dtsvdfo%name, "Boundary-layer dTs(o)", "K/s")
@@ -815,7 +830,4 @@
  CALL histdef3d(iff,o_rhum%flag,o_rhum%name, "Relative humidity", "-")
  CALL histdef3d(iff,o_ozone%flag,o_ozone%name, "Ozone concentration", "ppmv")
- IF(iflag_con.GE.3) THEN
-  CALL histdef3d(iff,o_upwd%flag,o_upwd%name, "saturated updraft", "kg/m2/s")
- ENDIF !iflag_con.GE.3
  CALL histdef3d(iff,o_dtphy%flag,o_dtphy%name, "Physics dT", "K/s")
  CALL histdef3d(iff,o_dqphy%flag,o_dqphy%name, "Physics dQ", "(kg/kg)/s")
@@ -836,10 +848,5 @@
  CALL histdef3d(iff,o_kz%flag,o_kz%name, "Kz melange", "m2/s")
  CALL histdef3d(iff,o_kz_max%flag,o_kz_max%name, "Kz melange max", "m2/s" )
- CALL histdef3d(iff,o_clwcon%flag,o_clwcon%name, "Convective Cloud Liquid water content", "kg/kg") 
- IF(iflag_con.GE.3) THEN
- CALL histdef3d(iff,o_Ma%flag,o_Ma%name, "undilute adiab updraft", "kg/m2/s")
- CALL histdef3d(iff,o_dnwd%flag,o_dnwd%name, "saturated downdraft", "kg/m2/s")
- CALL histdef3d(iff,o_dnwd0%flag,o_dnwd0%name, "unsat. downdraft", "kg/m2/s")
- ENDIF !(iflag_con.GE.3) 
+ CALL histdef3d(iff,o_clwcon%flag,o_clwcon%name, "Convective Cloud Liquid water content", "kg/kg")  
  CALL histdef3d(iff,o_dtdyn%flag,o_dtdyn%name, "Dynamics dT", "K/s")
  CALL histdef3d(iff,o_dqdyn%flag,o_dqdyn%name, "Dynamics dQ", "(kg/kg)/s")
@@ -849,19 +856,4 @@
  CALL histdef3d(iff,o_ducon%flag,o_ducon%name, "Convection du", "m/s2")
  CALL histdef3d(iff,o_dqcon%flag,o_dqcon%name, "Convection dQ", "(kg/kg)/s")
- IF(iflag_con.EQ.3) THEN
- IF (iflag_wake == 1) THEN
-   CALL histdef2d(iff,o_wake_h%flag,o_wake_h%name, "wake_h", "-")
-   CALL histdef2d(iff,o_wake_s%flag,o_wake_s%name, "wake_s", "-")
-   CALL histdef3d(iff,o_dtwak%flag,o_dtwak%name, "Wake dT", "K/s")
-   CALL histdef3d(iff,o_dqwak%flag,o_dqwak%name, "Wake dQ", "(kg/kg)/s")
-   CALL histdef3d(iff,o_wake_deltat%flag,o_wake_deltat%name, "wake_deltat", " ")
-   CALL histdef3d(iff,o_wake_deltaq%flag,o_wake_deltaq%name, "wake_deltaq", " ")
-   CALL histdef3d(iff,o_wake_omg%flag,o_wake_omg%name, "wake_omg", " ")
- ENDIF
-   CALL histdef3d(iff,o_Vprecip%flag,o_Vprecip%name, "precipitation vertical profile", "-")
-   CALL histdef3d(iff,o_ftd%flag,o_ftd%name, "tend temp due aux descentes precip", "-")
-   CALL histdef3d(iff,o_fqd%flag,o_fqd%name,"tend vap eau due aux descentes precip", "-")
- ENDIF !(iflag_con.EQ.3)
-
  CALL histdef3d(iff,o_dtlsc%flag,o_dtlsc%name, "Condensation dT", "K/s")
  CALL histdef3d(iff,o_dtlschr%flag,o_dtlschr%name,"Large-scale condensational heating rate","K/s")
Index: /LMDZ4/branches/LMDZ4-dev/libf/phylmd/phys_output_write.h
===================================================================
--- /LMDZ4/branches/LMDZ4-dev/libf/phylmd/phys_output_write.h	(revision 1118)
+++ /LMDZ4/branches/LMDZ4-dev/libf/phylmd/phys_output_write.h	(revision 1119)
@@ -511,4 +511,21 @@
       CALL histwrite_phy(nid_files(iff),o_prw%name,itau_w,prw)
         ENDIF
+      IF (o_cape_max%flag(iff)<=lev_files(iff)) THEN
+       CALL histwrite_phy(nid_files(iff),o_cape_max%name,itau_w,cape)
+      ENDIF
+      IF (o_upwd%flag(iff)<=lev_files(iff)) THEN
+       CALL histwrite_phy(nid_files(iff),o_upwd%name,itau_w,upwd)
+      ENDIF
+      IF (o_Ma%flag(iff)<=lev_files(iff)) THEN
+       CALL histwrite_phy(nid_files(iff),o_Ma%name,itau_w,Ma)
+      ENDIF
+
+      IF (o_dnwd%flag(iff)<=lev_files(iff)) THEN
+       CALL histwrite_phy(nid_files(iff),o_dnwd%name,itau_w,dnwd)
+      ENDIF
+
+      IF (o_dnwd0%flag(iff)<=lev_files(iff)) THEN
+       CALL histwrite_phy(nid_files(iff),o_dnwd0%name,itau_w,dnwd0)
+      ENDIF
       ENDIF !iflag_con .GE. 3
 
@@ -619,5 +636,14 @@
       IF (type_ocean=='force ') THEN
 
-      IF (iflag_con.GE.3) THEN
+      IF (iflag_con.EQ.3) THEN
+       IF (o_ale%flag(iff)<=lev_files(iff)) THEN
+       CALL histwrite_phy(nid_files(iff),o_ale%name,itau_w,ale)
+       ENDIF
+       IF (o_alp%flag(iff)<=lev_files(iff)) THEN
+       CALL histwrite_phy(nid_files(iff),o_alp%name,itau_w,alp)
+       ENDIF
+       IF (o_cin%flag(iff)<=lev_files(iff)) THEN
+       CALL histwrite_phy(nid_files(iff),o_cin%name,itau_w,cin)
+       ENDIF
       IF (iflag_coupl.EQ.1) THEN
        IF (o_ale_bl%flag(iff)<=lev_files(iff)) THEN
@@ -628,6 +654,5 @@
        ENDIF
       ENDIF !iflag_coupl.EQ.1
-      ENDIF !(iflag_con.GE.3)
-      IF (iflag_con.EQ.3) THEN
+
       IF (iflag_wake.EQ.1) THEN
        IF (o_ale_wk%flag(iff)<=lev_files(iff)) THEN
@@ -638,13 +663,4 @@
        ENDIF
 
-       IF (o_ale%flag(iff)<=lev_files(iff)) THEN
-       CALL histwrite_phy(nid_files(iff),o_ale%name,itau_w,ale)
-       ENDIF
-       IF (o_alp%flag(iff)<=lev_files(iff)) THEN
-       CALL histwrite_phy(nid_files(iff),o_alp%name,itau_w,alp)
-       ENDIF
-       IF (o_cin%flag(iff)<=lev_files(iff)) THEN
-       CALL histwrite_phy(nid_files(iff),o_cin%name,itau_w,cin)
-       ENDIF
        IF (o_wape%flag(iff)<=lev_files(iff)) THEN
        CALL histwrite_phy(nid_files(iff),o_WAPE%name,itau_w,wake_pe)
@@ -669,11 +685,18 @@
 
         IF (o_wake_omg%flag(iff)<=lev_files(iff)) THEN
-       CALL histwrite_phy(nid_files(iff),
-     s                    o_wake_omg%name,itau_w,wake_omg)
-        ENDIF
-      ENDIF
-
-        IF (o_Vprecip%flag(iff)<=lev_files(iff)) THEN
-       CALL histwrite_phy(nid_files(iff),o_Vprecip%name,itau_w,Vprecip)
+       CALL histwrite_phy(nid_files(iff),o_wake_omg%name,itau_w,
+     .wake_omg)
+        ENDIF
+        IF (o_dtwak%flag(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),o_dtwak%name,itau_w,
+     .zx_tmp_fi3d)
+        ENDIF
+
+        IF (o_dqwak%flag(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),o_dqwak%name,itau_w,
+     .zx_tmp_fi3d)
         ENDIF
 
@@ -685,4 +708,9 @@
        CALL histwrite_phy(nid_files(iff),o_fqd%name,itau_w,fqd)
         ENDIF
+      ENDIF
+
+       IF (o_Vprecip%flag(iff)<=lev_files(iff)) THEN
+        CALL histwrite_phy(nid_files(iff),o_Vprecip%name,itau_w,Vprecip)
+       ENDIF
 
       ENDIF !(iflag_con.EQ.3) 
@@ -690,8 +718,8 @@
       ELSE IF (type_ocean=='slab  ') THEN
 
-      IF ( o_slab_bils%flag(iff)<=lev_files(iff)) 
+       IF ( o_slab_bils%flag(iff)<=lev_files(iff))
      $     CALL histwrite_phy(
      $     nid_files(iff),o_slab_bils%name,itau_w,slab_wfbils)
-
+      
       ENDIF !type_ocean == force/slab
 
@@ -768,10 +796,4 @@
       CALL histwrite_phy(nid_files(iff),o_snowl%name,itau_w,snow_lsc)
       ENDIF
-
-      IF (iflag_con.GE.3) THEN
-      IF (o_cape_max%flag(iff)<=lev_files(iff)) THEN
-      CALL histwrite_phy(nid_files(iff),o_cape_max%name,itau_w,cape)
-      ENDIF
-      ENDIF !(iflag_con.GE.3)
 
       IF (o_solldown%flag(iff)<=lev_files(iff)) THEN
@@ -885,10 +907,4 @@
       CALL histwrite_phy(nid_files(iff),o_ozone%name,itau_w,zx_tmp_fi3d)
       ENDIF
-
-      IF(iflag_con.GE.3) THEN
-       IF (o_upwd%flag(iff)<=lev_files(iff)) THEN
-      CALL histwrite_phy(nid_files(iff),o_upwd%name,itau_w,upwd)
-       ENDIF
-      ENDIF !(iflag_con.GE.3)
 
        IF (o_dtphy%flag(iff)<=lev_files(iff)) THEN
@@ -963,18 +979,4 @@
        ENDIF
 
-      IF(iflag_con.GE.3) THEN
-       IF (o_Ma%flag(iff)<=lev_files(iff)) THEN
-      CALL histwrite_phy(nid_files(iff),o_Ma%name,itau_w,Ma)
-       ENDIF
-
-       IF (o_dnwd%flag(iff)<=lev_files(iff)) THEN
-      CALL histwrite_phy(nid_files(iff),o_dnwd%name,itau_w,dnwd)
-       ENDIF
-
-       IF (o_dnwd0%flag(iff)<=lev_files(iff)) THEN
-      CALL histwrite_phy(nid_files(iff),o_dnwd0%name,itau_w,dnwd0)
-       ENDIF
-      ENDIF !(iflag_con.GE.3)
-
        IF (o_dtdyn%flag(iff)<=lev_files(iff)) THEN
       CALL histwrite_phy(nid_files(iff),o_dtdyn%name,itau_w,d_t_dyn)
@@ -1007,21 +1009,4 @@
       CALL histwrite_phy(nid_files(iff),o_dqcon%name,itau_w,zx_tmp_fi3d)
        ENDIF
-
-      IF(iflag_con.GE.3) THEN
-       IF (iflag_wake == 1) THEN
-         IF (o_dtwak%flag(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),
-     &                       o_dtwak%name,itau_w,zx_tmp_fi3d)
-         ENDIF
-
-        IF (o_dqwak%flag(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),
-     &                     o_dqwak%name,itau_w,zx_tmp_fi3d)
-        ENDIF
-       ENDIF
-      ENDIF !(iflag_con.GE.3) 
 
        IF (o_dtlsc%flag(iff)<=lev_files(iff)) THEN
