Index: /LMDZ5/branches/testing/DefLists/context_lmdz.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/context_lmdz.xml	(revision 2056)
+++ /LMDZ5/branches/testing/DefLists/context_lmdz.xml	(revision 2056)
@@ -0,0 +1,43 @@
+<!-- Context LMDZ -->
+<context id="LMDZ" calendar_type="D360" start_date="1980-01-01 00:00:00">
+  
+  <!-- Define available variables -->
+  <field_definition src="./field_def_lmdz.xml"/> 
+  
+  <!-- Define output files
+       Each file contains the list of variables and their output levels -->
+  
+  <file_definition src="./file_def_histday_lmdz.xml"/>
+  <file_definition src="./file_def_histhf_lmdz.xml"/>
+  <file_definition src="./file_def_histins_lmdz.xml"/>
+  <file_definition src="./file_def_histLES_lmdz.xml"/>
+  <file_definition src="./file_def_histmth_lmdz.xml"/> 
+  <file_definition src="./file_def_histstn_lmdz.xml"/>
+  <file_definition src="./file_def_histmthNMC_lmdz.xml"/>
+  <file_definition src="./file_def_histdayNMC_lmdz.xml"/>
+  <file_definition src="./file_def_histhfNMC_lmdz.xml"/>
+  
+  <!-- Define domains and groups of domains -->
+  <domain_definition>
+    <domain id="dom_glo" data_dim="2" />
+  </domain_definition>
+  
+  <!-- Need to define a grid? Do it here -->
+  <grid_definition>
+    <grid_group id="vertical" axis_ref="presnivs" />
+  </grid_definition>
+  
+  <!-- Define groups of vertical axes -->
+  <axis_definition>
+    <axis id="presnivs" standard_name="Vertical levels" unit="Pa">
+    </axis>
+    <axis id="Ahyb" standard_name="Ahyb comp of Hyb Cord" unit="Pa">
+    </axis>
+    <axis id="Bhyb" standard_name="Bhyb comp of Hyb Cord" unit="">
+    </axis>
+    <axis id="Alt" standard_name="Height approx for scale heigh of 8km at levels" unit="km">
+    </axis>
+    <axis id="plev" standard_name="model_level_number" unit="Pa">
+    </axis>
+  </axis_definition>
+</context>
Index: /LMDZ5/branches/testing/DefLists/field_def_lmdz.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/field_def_lmdz.xml	(revision 2056)
+++ /LMDZ5/branches/testing/DefLists/field_def_lmdz.xml	(revision 2056)
@@ -0,0 +1,529 @@
+<field_definition level="1" prec="4" operation="average" freq_op="1ts" enabled=".FALSE.">
+    
+    <field_group id="fields_1D" grid_ref="vertical">
+        <field id="Ap"   long_name="Hybrid coordinate: pressure part"    unit="Pa" />
+        <field id="Bp"   long_name="Hybrid coordinate: sigma part"    unit="-" />
+        <field id="Alt"  long_name="Pseudo-altitude (for an 8km scale height)"    unit="km" />
+    </field_group>
+    
+    <field_group id="fields_2D" domain_ref="dom_glo">
+        <field id="phis"    long_name="Surface geop.height"     unit="m2/s2" />
+        <field id="aire"    long_name="Grid area"               unit="-"    />
+        <field id="contfracATM"     long_name="% sfce ter+lic"  unit="-"    />
+        <field id="contfracOR"      long_name="% sfce terre OR" unit="-" />
+        <field id="aireTER"         long_name="Grid area CONT"  unit="-" />
+        <field id="flat"    long_name="Latent heat flux"        unit="W/m2" />
+        <field id="slp"     long_name="Sea Level Pressure"      unit="Pa" />
+        <field id="tsol"    long_name="Surface Temperature"     unit="K" />
+        <field id="t2m"        long_name="Temperature 2m" unit="K" />
+        <field id="t2m_min"    long_name="Temp 2m min"    unit="K" />
+        <field id="t2m_max"    long_name="Temp 2m max"    unit="K" />
+        <field id="t2m_ter"    long_name="Temp 2m ter"    unit="K" />
+        <field id="t2m_lic"    long_name="Temp 2m lic"    unit="K" />
+        <field id="t2m_oce"    long_name="Temp 2m oce"    unit="K" />
+        <field id="t2m_sic"    long_name="Temp 2m sic"    unit="K" />
+        <field id="wind10m"    long_name="10-m wind speed"      unit="m/s" />
+        <field id="wind10max"  long_name="10m wind speed max"   unit="m/s" />
+        <field id="sicf"    long_name="Sea-ice fraction"        unit="-" />
+        <field id="q2m"     long_name="Specific humidity 2m"    unit="kg/kg" />
+        <field id="ustar"   long_name="Friction velocity"       unit="m/s" />
+        <field id="u10m"    long_name="Vent zonal 10m"          unit="m/s" />
+        <field id="v10m"    long_name="Vent meridien 10m"       unit="m/s" />
+        <field id="psol"    long_name="Surface Pressure"        unit="Pa" />
+        <field id="qsurf"   long_name="Surface Air humidity"    unit="kg/kg" />
+        <field id="ustar_ter"    long_name="Friction velocity ter"    unit="m/s" />
+        <field id="ustar_lic"    long_name="Friction velocity lic"    unit="m/s" />
+        <field id="ustar_oce"    long_name="Friction velocity oce"    unit="m/s" />
+        <field id="ustar_sic"    long_name="Friction velocity sic"    unit="m/s" />
+        <field id="wstar_ter"    long_name="Friction velocity ter"    unit="m/s" />
+        <field id="wstar_lic"    long_name="Friction velocity lic"    unit="m/s" />
+        <field id="wstar_oce"    long_name="Friction velocity oce"    unit="m/s" />
+        <field id="wstar_sic"    long_name="Friction velocity sic"    unit="m/s" />
+        <field id="wstar"       long_name="w* convective velocity "    unit="m/s" />
+        <field id="u10m_ter"    long_name="Vent Zonal 10m ter"    unit="m/s" />
+        <field id="u10m_lic"    long_name="Vent Zonal 10m lic"    unit="m/s" />
+        <field id="u10m_oce"    long_name="Vent Zonal 10m oce"    unit="m/s" />
+        <field id="u10m_sic"    long_name="Vent Zonal 10m sic"    unit="m/s" />
+        <field id="v10m_ter"    long_name="Vent meredien 10m ter"    unit="m/s" />
+        <field id="v10m_lic"    long_name="Vent meredien 10m lic"    unit="m/s" />
+        <field id="v10m_oce"    long_name="Vent meredien 10m oce"    unit="m/s" />
+        <field id="v10m_sic"    long_name="Vent meredien 10m sic"    unit="m/s" />
+        <field id="qsol"        long_name="Soil watter content"         unit="mm" />
+        <field id="ndayrain"    long_name="Number of dayrain(liq+sol)"  unit="-" />
+        <field id="precip"      long_name="Precip Totale liq+sol"       unit="kg/(s*m2)" />
+        <field id="plul"    long_name="Large-scale Precip."     unit="kg/(s*m2)" />
+        <field id="pluc"    long_name="Convective Precip."      unit="kg/(s*m2)" />
+        <field id="snow"    long_name="Snow fall"               unit="kg/(s*m2)" />
+        <field id="evap"    long_name="Evaporat"                unit="kg/(s*m2)" />
+        <field id="evap_ter"    long_name="evaporation at surface ter"    unit="kg/(s*m2)" />
+        <field id="evap_lic"    long_name="evaporation at surface lic"    unit="kg/(s*m2)" />
+        <field id="evap_oce"    long_name="evaporation at surface oce"    unit="kg/(s*m2)" />
+        <field id="evap_sic"    long_name="evaporation at surface sic"    unit="kg/(s*m2)" />
+        <field id="msnow"    long_name="Surface snow amount"    unit="kg/m2" />
+        <field id="fsnow"    long_name="Surface snow area fraction"    unit="-" />
+        <field id="tops"    long_name="Solar rad. at TOA"    unit="W/m2" />
+        <field id="tops0"    long_name="CS Solar rad. at TOA"    unit="W/m2" />
+        <field id="topl"    long_name="IR rad. at TOA"    unit="W/m2" />
+        <field id="topl0"    long_name="IR rad. at TOA"    unit="W/m2" />
+        <field id="SWupTOA"    long_name="SWup at TOA"    unit="W/m2" />
+        <field id="SWupTOAclr"    long_name="SWup clear sky at TOA"    unit="W/m2" />
+        <field id="SWdnTOA"    long_name="SWdn at TOA"    unit="W/m2" />
+        <field id="SWdnTOAclr"    long_name="SWdn clear sky at TOA"    unit="W/m2" />
+        <field id="nettop"    long_name="Net dn radiatif flux at TOA"    unit="W/m2" />
+        <field id="SWup200"    long_name="SWup at 200mb"    unit="W/m2" />
+        <field id="SWup200clr"    long_name="SWup clear sky at 200mb"    unit="W/m2" />
+        <field id="SWdn200"    long_name="SWdn at 200mb"    unit="W/m2" />
+        <field id="SWdn200clr"    long_name="SWdn clear sky at 200mb"    unit="W/m2" />
+        <field id="LWup200"    long_name="LWup at 200mb"    unit="W/m2" />
+        <field id="LWup200clr"    long_name="LWup clear sky at 200mb"    unit="W/m2" />
+        <field id="LWdn200"    long_name="LWdn at 200mb"    unit="W/m2" />
+        <field id="LWdn200clr"    long_name="LWdn clear sky at 200mb"    unit="W/m2" />
+        <field id="sols"    long_name="Solar rad. at surf."    unit="W/m2" />
+        <field id="sols0"    long_name="Solar rad. at surf."    unit="W/m2" />
+        <field id="soll"    long_name="IR rad. at surface"    unit="W/m2" />
+        <field id="soll0"    long_name="IR rad. at surface"    unit="W/m2" />
+        <field id="radsol"    long_name="Rayonnement au sol"    unit="W/m2" />
+        <field id="SWupSFC"    long_name="SWup at surface"    unit="W/m2" />
+        <field id="SWupSFCclr"    long_name="SWup clear sky at surface"    unit="W/m2" />
+        <field id="SWdnSFC"    long_name="SWdn at surface"    unit="W/m2" />
+        <field id="SWdnSFCclr"    long_name="SWdn clear sky at surface"    unit="W/m2" />
+        <field id="LWupSFC"    long_name="Upwd. IR rad. at surface"    unit="W/m2" />
+        <field id="LWupSFCclr"    long_name="CS Upwd. IR rad. at surface"    unit="W/m2" />
+        <field id="LWdnSFC"    long_name="Down. IR rad. at surface"    unit="W/m2" />
+        <field id="LWdnSFCclr"    long_name="Down. CS IR rad. at surface"    unit="W/m2" />
+        <field id="bils"    long_name="Surf. total heat flux"    unit="W/m2" />
+        <field id="bils_tke"    long_name="Surf. total heat flux"    unit="W/m2" />
+        <field id="bils_diss"    long_name="Surf. total heat flux"    unit="W/m2" />
+        <field id="bils_ec"    long_name="Surf. total heat flux"    unit="W/m2" />
+        <field id="bils_kinetic"    long_name="Surf. total heat flux"    unit="W/m2" />
+        <field id="bils_enthalp"    long_name="Surf. total heat flux"    unit="W/m2" />
+        <field id="bils_latent"    long_name="Surf. total heat flux"    unit="W/m2" />
+        <field id="sens"    long_name="Sensible heat flux"    unit="W/m2" />
+        <field id="fder"    long_name="Heat flux derivation"    unit="W/m2" />
+        <field id="ffonte"    long_name="Thermal flux for snow melting"    unit="W/m2" />
+        <field id="fqcalving"    long_name="Ice Calving"    unit="kg/m2/s" />
+        <field id="fqfonte"    long_name="Land ice melt"    unit="kg/m2/s" />
+        <field id="taux"    long_name="Zonal wind stress"    unit="Pa" />
+        <field id="tauy"    long_name="Meridional wind stress"    unit="Pa" />
+        <field id="taux_ter"    long_name="Zonal wind stress ter"    unit="Pa" />
+        <field id="taux_lic"    long_name="Zonal wind stress lic"    unit="Pa" />
+        <field id="taux_oce"    long_name="Zonal wind stress oce"    unit="Pa" />
+        <field id="taux_sic"    long_name="Zonal wind stress sic"    unit="Pa" />
+        <field id="tauy_ter"    long_name="Meridional wind stress ter"    unit="Pa" />
+        <field id="tauy_lic"    long_name="Meridional wind stress lic"    unit="Pa" />
+        <field id="tauy_oce"    long_name="Meridional wind stress oce"    unit="Pa" />
+        <field id="tauy_sic"    long_name="Meridional wind stress sic"    unit="Pa" />
+        <field id="pourc_ter"    long_name="% ter"    unit="%" />
+        <field id="pourc_lic"    long_name="% lic"    unit="%" />
+        <field id="pourc_oce"    long_name="% oce"    unit="%" />
+        <field id="pourc_sic"    long_name="% sic"    unit="%" />
+        <field id="fract_ter"    long_name="Fraction ter"    unit="1" />
+        <field id="fract_lic"    long_name="Fraction lic"    unit="1" />
+        <field id="fract_oce"    long_name="Fraction oce"    unit="1" />
+        <field id="fract_sic"    long_name="Fraction sic"    unit="1" />
+        <field id="tsol_ter"    long_name="Temperature ter"    unit="K" />
+        <field id="tsol_lic"    long_name="Temperature lic"    unit="K" />
+        <field id="tsol_oce"    long_name="Temperature oce"    unit="K" />
+        <field id="tsol_sic"    long_name="Temperature sic"    unit="K" />
+        <field id="evappot_ter"    long_name="Temperature ter"    unit="K" />
+        <field id="evappot_lic"    long_name="Temperature lic"    unit="K" />
+        <field id="evappot_oce"    long_name="Temperature oce"    unit="K" />
+        <field id="evappot_sic"    long_name="Temperature sic"    unit="K" />
+        <field id="sens_ter"    long_name="Sensible heat flux ter"    unit="W/m2" />
+        <field id="sens_lic"    long_name="Sensible heat flux lic"    unit="W/m2" />
+        <field id="sens_oce"    long_name="Sensible heat flux oce"    unit="W/m2" />
+        <field id="sens_sic"    long_name="Sensible heat flux sic"    unit="W/m2" />
+        <field id="lat_ter"    long_name="Latent heat flux ter"    unit="W/m2" />
+        <field id="lat_lic"    long_name="Latent heat flux lic"    unit="W/m2" />
+        <field id="lat_oce"    long_name="Latent heat flux oce"    unit="W/m2" />
+        <field id="lat_sic"    long_name="Latent heat flux sic"    unit="W/m2" />
+        <field id="flw_ter"    long_name="LW ter"    unit="W/m2" />
+        <field id="flw_lic"    long_name="LW lic"    unit="W/m2" />
+        <field id="flw_oce"    long_name="LW oce"    unit="W/m2" />
+        <field id="flw_sic"    long_name="LW sic"    unit="W/m2" />
+        <field id="fsw_ter"    long_name="SW ter"    unit="W/m2" />
+        <field id="fsw_lic"    long_name="SW lic"    unit="W/m2" />
+        <field id="fsw_oce"    long_name="SW oce"    unit="W/m2" />
+        <field id="fsw_sic"    long_name="SW sic"    unit="W/m2" />
+        <field id="wbils_ter"    long_name="Bilan sol ter"    unit="W/m2" />
+        <field id="wbils_lic"    long_name="Bilan sol lic"    unit="W/m2" />
+        <field id="wbils_oce"    long_name="Bilan sol oce"    unit="W/m2" />
+        <field id="wbils_sic"    long_name="Bilan sol sic"    unit="W/m2" />
+        <field id="wbilo_ter"    long_name="Bilan eau ter"    unit="kg/(m2*s)" />
+        <field id="wbilo_lic"    long_name="Bilan eau lic"    unit="kg/(m2*s)" />
+        <field id="wbilo_oce"    long_name="Bilan eau oce"    unit="kg/(m2*s)" />
+        <field id="wbilo_sic"    long_name="Bilan eau sic"    unit="kg/(m2*s)" />
+        <field id="cdrm"    long_name="Momentum drag coef."    unit="-" />
+        <field id="cdrh"    long_name="Heat drag coef."    unit="-" />
+        <field id="cldl"    long_name="Low-level cloudiness"    unit="-" />
+        <field id="cldm"    long_name="Mid-level cloudiness"    unit="-" />
+        <field id="cldh"    long_name="High-level cloudiness"    unit="-" />
+        <field id="cldt"    long_name="Total cloudiness"    unit="-" />
+        <field id="cldq"    long_name="Cloud liquid water path"    unit="kg/m2" />
+        <field id="lwp"    long_name="Cloud water path"    unit="kg/m2" />
+        <field id="iwp"    long_name="Cloud ice water path"    unit="kg/m2" />
+        <field id="ue"    long_name="Zonal energy transport"    unit="-" />
+        <field id="ve"    long_name="Merid energy transport"    unit="-" />
+        <field id="uq"    long_name="Zonal humidity transport"    unit="-" />
+        <field id="vq"    long_name="Merid humidity transport"    unit="-" />
+        <field id="cape"    long_name="Conv avlbl pot ener"    unit="J/kg" />
+        <field id="pbase"    long_name="Cld base pressure"    unit="Pa" />
+        <field id="ptop"    long_name="Cld top pressure"    unit="Pa" />
+        <field id="fbase"    long_name="Cld base mass flux"    unit="kg/m2/s" />
+        <field id="plcl"    long_name="Lifting Condensation Level"    unit="hPa" />
+        <field id="plfc"    long_name="Level of Free Convection"    unit="hPa" />
+        <field id="wbeff"    long_name="Conv. updraft velocity at LFC (inf100)"    unit="m/s" />
+        <field id="prw"    long_name="Precipitable water"    unit="kg/m2" />
+        <field id="s_pblh"    long_name="Boundary Layer Height"    unit="m" />
+        <field id="s_pblt"    long_name="t at Boundary Layer Height"    unit="K" />
+        <field id="s_lcl"    long_name="Condensation level"    unit="m" />
+        <field id="s_therm"    long_name="Exces du thermique"    unit="K" />
+        <field id="slab_bils_oce"    long_name="Bilan au sol sur ocean slab"    unit="W/m2" />
+        <field id="ale_bl"    long_name="ALE BL"    unit="m2/s2" />
+        <field id="alp_bl"    long_name="ALP BL"    unit="m2/s2" />
+        <field id="ale_wk"    long_name="ALE WK"    unit="m2/s2" />
+        <field id="alp_wk"    long_name="ALP WK"    unit="m2/s2" />
+        <field id="ale"    long_name="ALE"    unit="m2/s2" />
+        <field id="alp"    long_name="ALP"    unit="W/m2" />
+        <field id="cin"    long_name="Convective INhibition"    unit="m2/s2" />
+        <field id="wape"    long_name="-"    unit="-" />
+        <field id="n2"    long_name="Nombre de panaches de type 2"    unit="-" />
+        <field id="s2"    long_name="Surface moyenne des panaches de type 2"    unit="m2" />
+        <field id="proba_notrig"    long_name="Probabilité de non-déclenchement"    unit="-" />
+        <field id="random_notrig"    long_name="Tirage aléatoire de non-déclenchement"    unit="-" />
+        <field id="ale_bl_stat"    long_name="ALE_BL_STAT"    unit="m2/s2" />
+        <field id="ale_bl_trig"    long_name="ALE_BL_STAT + Condition P>Pseuil"    unit="m2/s2" />
+        <field id="alp_bl_det"    long_name="ALP_BL_DET"    unit="W/m2" />
+        <field id="alp_bl_fluct_m"    long_name="ALP_BL_FLUCT_M"    unit="W/m2" />
+        <field id="alp_bl_fluct_tke"    long_name="ALP_BL_FLUCT_TKE"    unit="W/m2" />
+        <field id="alp_bl_conv"    long_name="ALP_BL_CONV"    unit="W/m2" />
+        <field id="alp_bl_stat"    long_name="ALP_BL_STAT"    unit="W/m2" />
+        <field id="u850"    long_name="Zonal wind 1hPa"    unit="m/s" />
+        <field id="u700"    long_name="Zonal wind 2hPa"    unit="m/s" />
+        <field id="u500"    long_name="Zonal wind 3hPa"    unit="m/s" />
+        <field id="u200"    long_name="Zonal wind 4hPa"    unit="m/s" />
+        <field id="u100"    long_name="Zonal wind 5hPa"    unit="m/s" />
+        <field id="u50"     long_name="Zonal wind 6hPa"    unit="m/s" />
+        <field id="u10"     long_name="Zonal wind 7hPa"    unit="m/s" />
+        <field id="v850"    long_name="Meridional wind 1hPa"    unit="m/s" />
+        <field id="v700"    long_name="Meridional wind 2hPa"    unit="m/s" />
+        <field id="v500"    long_name="Meridional wind 3hPa"    unit="m/s" />
+        <field id="v200"    long_name="Meridional wind 4hPa"    unit="m/s" />
+        <field id="v100"    long_name="Meridional wind 5hPa"    unit="m/s" />
+        <field id="v50"     long_name="Meridional wind 6hPa"    unit="m/s" />
+        <field id="v10"    long_name="Meridional wind 7hPa"    unit="m/s" />
+        <field id="w850"    long_name="Vertical wind 1hPa"    unit="Pa/s" />
+        <field id="w700"    long_name="Vertical wind 2hPa"    unit="Pa/s" />
+        <field id="w500"    long_name="Vertical wind 3hPa"    unit="Pa/s" />
+        <field id="w200"    long_name="Vertical wind 4hPa"    unit="Pa/s" />
+        <field id="w100"    long_name="Vertical wind 5hPa"    unit="Pa/s" />
+        <field id="w50"    long_name="Vertical wind 6hPa"    unit="Pa/s" />
+        <field id="w10"    long_name="Vertical wind 7hPa"    unit="Pa/s" />
+        <field id="t850"    long_name="Temperature 1hPa"    unit="K" />
+        <field id="t700"    long_name="Temperature 2hPa"    unit="K" />
+        <field id="t500"    long_name="Temperature 3hPa"    unit="K" />
+        <field id="t200"    long_name="Temperature 4hPa"    unit="K" />
+        <field id="t100"    long_name="Temperature 5hPa"    unit="K" />
+        <field id="t50"    long_name="Temperature 6hPa"    unit="K" />
+        <field id="t10"    long_name="Temperature 7hPa"    unit="K" />
+        <field id="q850"    long_name="Specific humidity 1hPa"    unit="kg/kg" />
+        <field id="q700"    long_name="Specific humidity 2hPa"    unit="kg/kg" />
+        <field id="q500"    long_name="Specific humidity 3hPa"    unit="kg/kg" />
+        <field id="q200"    long_name="Specific humidity 4hPa"    unit="kg/kg" />
+        <field id="q100"    long_name="Specific humidity 5hPa"    unit="kg/kg" />
+        <field id="q50"    long_name="Specific humidity 6hPa"    unit="kg/kg" />
+        <field id="q10"    long_name="Specific humidity 7hPa"    unit="kg/kg" />
+        <field id="z850"    long_name="Geopotential height 1hPa"    unit="m" />
+        <field id="z700"    long_name="Geopotential height 2hPa"    unit="m" />
+        <field id="z500"    long_name="Geopotential height 3hPa"    unit="m" />
+        <field id="z200"    long_name="Geopotential height 4hPa"    unit="m" />
+        <field id="z100"    long_name="Geopotential height 5hPa"    unit="m" />
+        <field id="z50"    long_name="Geopotential height 6hPa"    unit="m" />
+        <field id="z10"    long_name="Geopotential height 7hPa"    unit="m" />
+        <field id="t_oce_sic"    long_name="Temp mixte oce-sic"    unit="K" />
+        <field id="weakinv"    long_name="Weak inversion"    unit="-" />
+        <field id="dthmin"    long_name="dTheta mini"    unit="K/m" />
+        <field id="u10_ter"    long_name="-"    unit="-" />
+        <field id="u10_lic"    long_name="-"    unit="-" />
+        <field id="u10_oce"    long_name="-"    unit="-" />
+        <field id="u10_sic"    long_name="-"    unit="-" />
+        <field id="v10_ter"    long_name="-"    unit="-" />
+        <field id="v10_lic"    long_name="-"    unit="-" />
+        <field id="v10_oce"    long_name="-"    unit="-" />
+        <field id="v10_sic"    long_name="-"    unit="-" />
+        <field id="rh2m"    long_name="Relative humidity at 2m"    unit="%" />
+        <field id="rh2m_min"    long_name="Min Relative humidity at 2m"    unit="%" />
+        <field id="rh2m_max"    long_name="Max Relative humidity at 2m"    unit="%" />
+        <field id="qsat2m"    long_name="Saturant humidity at 2m"    unit="%" />
+        <field id="tpot"    long_name="Surface air potential temperature"    unit="K" />
+        <field id="tpote"    long_name="Surface air equivalent potential temperature"    unit="K" />
+        <field id="SWnetOR"    long_name="Sfce net SW radiation OR"    unit="W/m2" />
+        <field id="SWdownOR"    long_name="Sfce incident SW radiation OR"    unit="W/m2" />
+        <field id="LWdownOR"    long_name="Sfce incident LW radiation OR"    unit="W/m2" />
+        <field id="snowl"    long_name="Solid Large-scale Precip."    unit="kg/(m2*s)" />
+        <field id="cape_max"    long_name="CAPE max."    unit="J/kg" />
+        <field id="solldown"    long_name="Down. IR rad. at surface"    unit="W/m2" />
+        <field id="dtsvdfo"    long_name="Boundary-layer dTs(o)"    unit="K/s" />
+        <field id="dtsvdft"    long_name="Boundary-layer dTs(t)"    unit="K/s" />
+        <field id="dtsvdfg"    long_name="Boundary-layer dTs(g)"    unit="K/s" />
+        <field id="dtsvdfi"    long_name="Boundary-layer dTs(g)"    unit="K/s" />
+        <field id="rugs"    long_name="rugosity"    unit="-" />
+        <field id="topswad"    long_name="ADE at TOA"    unit="W/m2" />
+        <field id="topswad0"    long_name="ADE clear-sky at TOA"    unit="W/m2" />
+        <field id="topswai"    long_name="AIE at TOA"    unit="W/m2" />
+        <field id="solswad"    long_name="ADE at SRF"    unit="W/m2" />
+        <field id="solswad0"    long_name="ADE clear-sky at SRF"    unit="W/m2" />
+        <field id="solswai"    long_name="AIE at SFR"    unit="W/m2" />
+        <field id="OD550_ASBCM"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
+        <field id="OD550_ASPOMM"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
+        <field id="OD550_ASSO4M"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
+        <field id="OD550_CSSO4M"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
+        <field id="OD550_SSSSM"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
+        <field id="OD550_ASSSM"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
+        <field id="OD550_CSSSM"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
+        <field id="OD550_CIDUSTM"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
+        <field id="OD550_AIBCM"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
+        <field id="OD550_AIPOMM"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
+        <field id="OD550_STRAT"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
+        <field id="od550aer"    long_name="Total aerosol optical depth at 550nm"    unit="-" />
+        <field id="od865aer"    long_name="Total aerosol optical depth at 870nm"    unit="-" />
+        <field id="absvisaer"    long_name="Absorption aerosol visible optical depth"    unit="-" />
+        <field id="od550lt1aer"    long_name="Fine mode optical depth"    unit="-" />
+        <field id="sconcso4"    long_name="Surface Concentration of Sulfate "    unit="kg/m3" />
+        <field id="sconcoa"    long_name="Surface Concentration of Organic Aerosol "    unit="kg/m3" />
+        <field id="sconcbc"    long_name="Surface Concentration of Black Carbon "    unit="kg/m3" />
+        <field id="sconcss"    long_name="Surface Concentration of Sea Salt "    unit="kg/m3" />
+        <field id="sconcdust"    long_name="Surface Concentration of Dust "    unit="kg/m3" />
+        <field id="loadso4"    long_name="Column Load of Sulfate "    unit="kg/m2" />
+        <field id="loadoa"    long_name="Column Load of Organic Aerosol "    unit="kg/m2" />
+        <field id="loadbc"    long_name="Column Load of Black Carbon "    unit="kg/m2" />
+        <field id="loadss"    long_name="Column Load of Sea Salt "    unit="kg/m2" />
+        <field id="loaddust"    long_name="Column Load of Dust "    unit="kg/m2" />
+        <field id="swtoaas_nat"    long_name="Natural aerosol radiative forcing all-sky at TOA"    unit="W/m2" />
+        <field id="swsrfas_nat"    long_name="Natural aerosol radiative forcing all-sky at SRF"    unit="W/m2" />
+        <field id="swtoacs_nat"    long_name="Natural aerosol radiative forcing clear-sky at TOA"    unit="W/m2" />
+        <field id="swsrfcs_nat"    long_name="Natural aerosol radiative forcing clear-sky at SRF"    unit="W/m2" />
+        <field id="swtoaas_ant"    long_name="Anthropogenic aerosol radiative forcing all-sky at TOA"    unit="W/m2" />
+        <field id="swsrfas_ant"    long_name="Anthropogenic aerosol radiative forcing all-sky at SRF"    unit="W/m2" />
+        <field id="swtoacs_ant"    long_name="Anthropogenic aerosol radiative forcing clear-sky at TOA"    unit="W/m2" />
+        <field id="swsrfcs_ant"    long_name="Anthropogenic aerosol radiative forcing clear-sky at SRF"    unit="W/m2" />
+        <field id="swtoacf_nat"    long_name="Natural aerosol impact on cloud radiative forcing at TOA"    unit="W/m2" />
+        <field id="swsrfcf_nat"    long_name="Natural aerosol impact on cloud radiative forcing  at SRF"    unit="W/m2" />
+        <field id="swtoacf_ant"    long_name="Anthropogenic aerosol impact on cloud radiative forcing at TOA"    unit="W/m2" />
+        <field id="swsrfcf_ant"    long_name="Anthropogenic aerosol impact on cloud radiative forcing at SRF"    unit="W/m2" />
+        <field id="swtoacf_zero"    long_name="Cloud radiative forcing (allsky-clearsky fluxes) at TOA"    unit="W/m2" />
+        <field id="swsrfcf_zero"    long_name="Cloud radiative forcing (allsky-clearsky fluxes) at SRF"    unit="W/m2" />
+        <field id="cldncl"    long_name="CDNC at top of liquid water cloud"    unit="m-3" />
+        <field id="reffclwtop"    long_name="Droplet effective radius at top of liquid water cloud"    unit="m" />
+        <field id="cldnvi"    long_name="Column Integrated Cloud Droplet Number"    unit="m-2" />
+        <field id="lcc"    long_name="Cloud liquid fraction at top of cloud"    unit="1" />
+        <field id="wvapp"    long_name="-"    unit="-" />
+        <field id="albe_ter"    long_name="Albedo VIS surf. ter"    unit="-" />
+        <field id="albe_lic"    long_name="Albedo VIS surf. lic"    unit="-" />
+        <field id="albe_oce"    long_name="Albedo VIS surf. oce"    unit="-" />
+        <field id="albe_sic"    long_name="Albedo VIS surf. sic"    unit="-" />
+        <field id="ages_ter"    long_name="Snow age ter"    unit="day" />
+        <field id="ages_lic"    long_name="Snow age lic"    unit="day" />
+        <field id="ages_oce"    long_name="Snow age oce"    unit="day" />
+        <field id="ages_sic"    long_name="Snow age sic"    unit="day" />
+        <field id="rugs_ter"    long_name="Surface roughness ter"    unit="m" />
+        <field id="rugs_lic"    long_name="Surface roughness lic"    unit="m" />
+        <field id="rugs_oce"    long_name="Surface roughness oce"    unit="m" />
+        <field id="rugs_sic"    long_name="Surface roughness sic"    unit="m" />
+        <field id="alb1"    long_name="Surface VIS albedo"    unit="-" />
+        <field id="alb2"    long_name="Surface Near IR albedo"    unit="-" />
+        <field id="ftime_con"    long_name="Fraction of time convection Occurs"    unit="-" />
+        <field id="wake_h"    long_name="wake_h"    unit="-" />
+        <field id="wake_s"    long_name="wake_s"    unit="-" />
+        <field id="plulth"    long_name="Rainfall therm."    unit="K/s" />
+        <field id="plulst"    long_name="Rainfall strat."    unit="K/s" />
+        <field id="lmaxth"    long_name="Upper level thermals"    unit="-" />
+        <field id="ftime_th"    long_name="Fraction of time Shallow convection occurs"    unit="-" />
+        <field id="f0_th"    long_name="Thermal closure mass flux"    unit="K/s" />
+        <field id="zmax_th"    long_name="Thermal plume height"    unit="K/s" />
+        <field id="rsut4co2"    long_name="TOA Out SW in 4xCO2 atmosphere"    unit="W/m2" />
+        <field id="rlut4co2"    long_name="TOA Out LW in 4xCO2 atmosphere"    unit="W/m2" />
+        <field id="rsutcs4co2"    long_name="TOA Out CS SW in 4xCO2 atmosphere"    unit="W/m2" />
+        <field id="rlutcs4co2"    long_name="TOA Out CS LW in 4xCO2 atmosphere"    unit="W/m2" />
+    </field_group>
+
+    <field_group id="fields_3D" domain_ref="dom_glo" axis_ref="presnivs">
+        <field id="tke"    long_name="TKE"    unit="m2/s2" />
+        <field id="tke_ter"    long_name="Max Turb. Kinetic Energy ter"    unit="-" />
+        <field id="tke_lic"    long_name="Max Turb. Kinetic Energy lic"    unit="-" />
+        <field id="tke_oce"    long_name="Max Turb. Kinetic Energy oce"    unit="-" />
+        <field id="tke_sic"    long_name="Max Turb. Kinetic Energy sic"    unit="-" />
+        <field id="tke_max_ter"    long_name="Max Turb. Kinetic Energy ter"    unit="-" />
+        <field id="tke_max_lic"    long_name="Max Turb. Kinetic Energy lic"    unit="-" />
+        <field id="tke_max_oce"    long_name="Max Turb. Kinetic Energy oce"    unit="-" />
+        <field id="tke_max_sic"    long_name="Max Turb. Kinetic Energy sic"    unit="-" />
+        <field id="cldtau"    long_name="Cloud optical thickness"    unit="1" />
+        <field id="cldemi"    long_name="Cloud optical emissivity"    unit="1" />
+        <field id="tke_max"    long_name="TKE max"    unit="m2/s2" />
+        <field id="kz"    long_name="Kz melange"    unit="m2/s" />
+        <field id="kz_max"    long_name="Kz melange max"    unit="m2/s" />
+        <field id="concso4"    long_name="Concentration of Sulfate "    unit="kg/m3" />
+        <field id="concoa"    long_name="Concentration of Organic Aerosol "    unit="kg/m3" />
+        <field id="concbc"    long_name="Concentration of Black Carbon "    unit="kg/m3" />
+        <field id="concss"    long_name="Concentration of Sea Salt "    unit="kg/m3" />
+        <field id="concdust"    long_name="Concentration of Dust "    unit="kg/m3" />
+        <field id="ec550aer"    long_name="Extinction at 550nm"    unit="m^-1" />
+        <field id="lwcon"    long_name="Cloud liquid water content"    unit="kg/kg" />
+        <field id="iwcon"    long_name="Cloud ice water content"    unit="kg/kg" />
+        <field id="temp"    long_name="Air temperature"    unit="K" />
+        <field id="theta"    long_name="Potential air temperature"    unit="K" />
+        <field id="ovap"    long_name="Specific humidity"    unit="kg/kg" />
+        <field id="ovapinit"    long_name="Specific humidity (begin of timestep)"    unit="kg/kg" />
+        <field id="oliq"    long_name="Condensed water"    unit="kg/kg" />
+        <field id="geop"    long_name="Geopotential height"    unit="m2/s2" />
+        <field id="vitu"    long_name="Zonal wind"    unit="m/s" />
+        <field id="vitv"    long_name="Meridional wind"    unit="m/s" />
+        <field id="vitw"    long_name="Vertical wind"    unit="Pa/s" />
+        <field id="pres"    long_name="Air pressure"    unit="Pa" />
+        <field id="paprs"    long_name="Air pressure Inter-Couches"    unit="Pa" />
+        <field id="mass"    long_name="Masse Couches"    unit="kg/m2" />
+        <field id="zfull"    long_name="Altitude of full pressure levels"    unit="m" />
+        <field id="zhalf"    long_name="Altitude of half pressure levels"    unit="m" />
+        <field id="rneb"    long_name="Cloud fraction"    unit="-" />
+        <field id="rnebcon"    long_name="Convective Cloud Fraction"    unit="-" />
+        <field id="rnebls"    long_name="LS Cloud fraction"    unit="-" />
+        <field id="rhum"    long_name="Relative humidity"    unit="-" />
+        <field id="ozone"    long_name="Ozone mole fraction"    unit="-" />
+        <field id="ozone_daylight"    long_name="Daylight ozone mole fraction"    unit="-" />
+        <field id="upwd"    long_name="saturated updraft"    unit="kg/m2/s" />
+        <field id="dtphy"    long_name="Physics dT"    unit="K/s" />
+        <field id="dqphy"    long_name="Physics dQ"    unit="(kg/kg)/s" />
+        <field id="pr_con_l"    long_name="Convective precipitation lic"    unit="-" />
+        <field id="pr_con_i"    long_name="Convective precipitation ice"    unit="-" />
+        <field id="pr_lsc_l"    long_name="Large scale precipitation lic"    unit="-" />
+        <field id="pr_lsc_i"    long_name="Large scale precipitation ice"    unit="-" />
+        <field id="re"    long_name="Cloud droplet effective radius"    unit="um" />
+        <field id="fl"    long_name="Denominator of Cloud droplet effective radius"    unit="-" />
+        <field id="scdnc"    long_name="Cloud droplet number concentration"    unit="m-3" />
+        <field id="reffclws"    long_name="Stratiform Cloud Droplet Effective Radius (aerosol diags.)"    unit="m" />
+        <field id="reffclwc"    long_name="Convective Cloud Droplet Effective Radius (aerosol diags.)"    unit="m" />
+        <field id="lcc3d"    long_name="Cloud liquid fraction"    unit="1" />
+        <field id="lcc3dcon"    long_name="Convective cloud liquid fraction"    unit="1" />
+        <field id="lcc3dstra"    long_name="Stratiform cloud liquid fraction"    unit="1" />
+        <field id="clwcon"    long_name="Convective Cloud Liquid water content"    unit="kg/kg" />
+        <field id="Ma"    long_name="undilute adiab updraft"    unit="kg/m2/s" />
+        <field id="dnwd"    long_name="saturated downdraft"    unit="kg/m2/s" />
+        <field id="dnwd0"    long_name="unsat. downdraft"    unit="kg/m2/s" />
+        <field id="mc"    long_name="Convective mass flux"    unit="kg/m2/s" />
+        <field id="dtdyn"    long_name="Dynamics dT"    unit="K/s" />
+        <field id="dqdyn"    long_name="Dynamics dQ"    unit="(kg/kg)/s" />
+        <field id="dudyn"    long_name="Dynamics dU"    unit="m/s2" />
+        <field id="dvdyn"    long_name="Dynamics dV"    unit="m/s2" />
+        <field id="dtcon"    long_name="Convection dT"    unit="K/s" />
+        <field id="ducon"    long_name="Convection du"    unit="m/s2" />
+        <field id="dvcon"    long_name="Convection dv"    unit="m/s2" />
+        <field id="dqcon"    long_name="Convection dQ"    unit="(kg/kg)/s" />
+        <field id="dtwak"    long_name="Wake dT"    unit="K/s" />
+        <field id="dqwak"    long_name="Wake dQ"    unit="(kg/kg)/s" />
+        <field id="wake_deltat"    long_name="wake_deltat"    unit="-" />
+        <field id="wake_deltaq"    long_name="wake_deltaq"    unit="-" />
+        <field id="wake_omg"    long_name="wake_omg"    unit="-" />
+        <field id="wdtrainA"    long_name="precipitation from AA"    unit="-" />
+        <field id="wdtrainM"    long_name="precipitation from mixture"    unit="-" />
+        <field id="Vprecip"    long_name="precipitation vertical profile"    unit="-" />
+        <field id="ftd"    long_name="tend temp due aux descentes precip"    unit="-" />
+        <field id="fqd"    long_name="tend vap eau due aux descentes precip"    unit="-" />
+        <field id="dtlsc"    long_name="Condensation dT"    unit="K/s" />
+        <field id="dtlschr"    long_name="Large-scale condensational heating rate"    unit="K/s" />
+        <field id="dqlsc"    long_name="Condensation dQ"    unit="(kg/kg)/s" />
+        <field id="beta_prec"    long_name="LS Conversion rate to prec"    unit="(kg/kg)/s" />
+        <field id="dtvdf"    long_name="Boundary-layer dT"    unit="K/s" />
+        <field id="dtdis"    long_name="TKE dissipation dT"    unit="K/s" />
+        <field id="dqvdf"    long_name="Boundary-layer dQ"    unit="(kg/kg)/s" />
+        <field id="dteva"    long_name="Reevaporation dT"    unit="K/s" />
+        <field id="dqeva"    long_name="Reevaporation dQ"    unit="(kg/kg)/s" />
+        <field id="dqlscth"    long_name="dQ therm."    unit="(kg/kg)/s" />
+        <field id="dqlscst"    long_name="dQ strat."    unit="(kg/kg)/s" />
+        <field id="dtlscth"    long_name="dQ therm."    unit="K/s" />
+        <field id="dtlscst"    long_name="dQ strat."    unit="K/s" />
+        <field id="ptconvth"    long_name="POINTS CONVECTIFS therm."    unit="-" />
+        <field id="ptconv"    long_name="POINTS CONVECTIFS"    unit="-" />
+        <field id="ratqs"    long_name="RATQS"    unit="-" />
+        <field id="dtthe"    long_name="Thermal dT"    unit="K/s" />
+        <field id="f_th"    long_name="Thermal plume mass flux"    unit="kg/(m2*s)" />
+        <field id="e_th"    long_name="Thermal plume entrainment"    unit="K/s" />
+        <field id="w_th"    long_name="Thermal plume vertical velocity"    unit="m/s" />
+        <field id="lambda_th"    long_name="Thermal plume vertical velocity"    unit="m/s" />
+        <field id="q_th"    long_name="Thermal plume total humidity"    unit="kg/kg" />
+        <field id="a_th"    long_name="Thermal plume fraction"    unit="-" />
+        <field id="d_th"    long_name="Thermal plume detrainment"    unit="K/s" />
+        <field id="dqthe"    long_name="Thermal dQ"    unit="(kg/kg)/s" />
+        <field id="dtajs"    long_name="Dry adjust. dT"    unit="K/s" />
+        <field id="dqajs"    long_name="Dry adjust. dQ"    unit="(kg/kg)/s" />
+        <field id="dtswr"    long_name="SW radiation dT"    unit="K/s" />
+        <field id="dtsw0"    long_name="CS SW radiation dT"    unit="K/s" />
+        <field id="dtlwr"    long_name="LW radiation dT"    unit="K/s" />
+        <field id="dtlw0"    long_name="CS LW radiation dT"    unit="K/s" />
+        <field id="dtec"    long_name="Cinetic dissip dT"    unit="K/s" />
+        <field id="duvdf"    long_name="Boundary-layer dU"    unit="m/s2" />
+        <field id="dvvdf"    long_name="Boundary-layer dV"    unit="m/s2" />
+        <field id="duoro"    long_name="Orography dU"    unit="m/s2" />
+        <field id="dvoro"    long_name="Orography dV"    unit="m/s2" />
+        <field id="dulif"    long_name="Orography dU"    unit="m/s2" />
+        <field id="dvlif"    long_name="Orography dV"    unit="m/s2" />
+        <field id="duhin"    long_name="Hines GWD dU"    unit="m/s2" />
+        <field id="dvhin"    long_name="Hines GWD dV"    unit="m/s2" />
+        <field id="dtoro"    long_name="Orography dT"    unit="K/s" />
+        <field id="dtlif"    long_name="Orography dT"    unit="K/s" />
+        <field id="dthin"    long_name="Hines GWD dT"    unit="K/s" />
+        <field id="rsu"    long_name="SW upward radiation"    unit="W m-2" />
+        <field id="rsd"    long_name="SW downward radiation"    unit="W m-2" />
+        <field id="rlu"    long_name="LW upward radiation"    unit="W m-2" />
+        <field id="rld"    long_name="LW downward radiation"    unit="W m-2" />
+        <field id="rsucs"    long_name="SW CS upward radiation"    unit="W m-2" />
+        <field id="rsdcs"    long_name="SW CS downward radiation"    unit="W m-2" />
+        <field id="rlucs"    long_name="LW CS upward radiation"    unit="W m-2" />
+        <field id="rldcs"    long_name="LW CS downward radiation"    unit="W m-2" />
+        <field id="tnt"    long_name="Tendency of air temperature"    unit="K s-1" />
+        <field id="tntc"    long_name="Tendency of air temperature due to Moist Convection"    unit="K s-1" />
+        <field id="tntr"    long_name="Air temperature tendency due to Radiative heating"    unit="K s-1" />
+        <field id="tntscpbl"    long_name="Air temperature tendency due to St cloud and precipitation and BL mixing"    unit="K s-1" />
+        <field id="tnhus"    long_name="Tendency of specific humidity"    unit="s-1" />
+        <field id="tnhusc"    long_name="Tendency of specific humidity due to convection"    unit="s-1" />
+        <field id="tnhusscpbl"    long_name="Tendency of Specific humidity due to ST cl, precip and BL mixing"    unit="s-1" />
+        <field id="evu"    long_name="Eddy viscosity coefficient for Momentum Variables"    unit="m2 s-1" />
+        <field id="h2o"    long_name="Mass Fraction of Water"    unit="1" />
+        <field id="mcd"    long_name="Downdraft COnvective Mass Flux"    unit="kg/(m2*s)" />
+        <field id="dmc"    long_name="Deep COnvective Mass Flux"    unit="kg/(m2*s)" />
+        <field id="ref_liq"    long_name="Effective radius of convective cloud liquid water particle"    unit="m" />
+        <field id="ref_ice"    long_name="Effective radius of startiform cloud ice particle"    unit="m" />
+        <field id="rsu4co2"    long_name="Upwelling SW 4xCO2 atmosphere"    unit="W/m2" />
+        <field id="rlu4co2"    long_name="Upwelling LW 4xCO2 atmosphere"    unit="W/m2" />
+        <field id="rsucs4co2"    long_name="Upwelling CS SW 4xCO2 atmosphere"    unit="W/m2" />
+        <field id="rlucs4co2"    long_name="Upwelling CS LW 4xCO2 atmosphere"    unit="W/m2" />
+        <field id="rsd4co2"    long_name="Downwelling SW 4xCO2 atmosphere"    unit="W/m2" />
+        <field id="rld4co2"    long_name="Downwelling LW 4xCO2 atmosphere"    unit="W/m2" />
+        <field id="rsdcs4co2"    long_name="Downwelling CS SW 4xCO2 atmosphere"    unit="W/m2" />
+        <field id="rldcs4co2"    long_name="Downwelling CS LW 4xCO2 atmosphere"    unit="W/m2" />
+    </field_group>
+    
+    <field_group  id="fields_NMC" domain_ref="dom_glo" axis_ref="plev">
+      <field id="tnondef" long_name="Undefined value of T" unit="K" />
+      <field id="ta" long_name="Air temperature" unit="K" />
+      <field id="zg" long_name="Geopotential height" unit="m" />
+      <field id="hus" long_name="Specific humidity" unit="1" />
+      <field id="hur" long_name="Relative humidity" unit="%" />
+      <field id="ua" long_name="Eastward wind" unit="m s-1" />
+      <field id="va" long_name="Northward wind" unit="m s-1" />
+      <field id="wap" long_name="Lagrangian tendency of air pressure" unit="Pa s-1" />
+      <field id="psbg" long_name="Pressure sfce below ground" unit="%" />
+      <field id="tro3" long_name="Ozone mole fraction" unit="1e-9" />
+      <field id="tro3_daylight" long_name="Daylight ozone mole fraction" unit="1e-9" />
+      <field id="uv" long_name="uv" unit="m2/s2" />
+      <!-- a field called "vq" is already defined...
+      <field id="vq" long_name="vq" unit="m/s * (kg/kg)" /> -->
+      <field id="vT" long_name="vT" unit="mK/s" />
+      <field id="wq" long_name="wq" unit="(Pa/s)*(kg/kg)" />
+      <field id="vphi" long_name="vphi" unit="m2/s" />
+      <field id="wT" long_name="wT" unit="K*Pa/s" />
+      <field id="uxu" long_name="u2" unit="m2/s2" />
+      <field id="vxv" long_name="v2" unit="m2/s2" />
+      <field id="TxT" long_name="T2" unit="K2" />
+    </field_group>
+    
+</field_definition>
Index: /LMDZ5/branches/testing/DefLists/file_def_histLES_lmdz.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/file_def_histLES_lmdz.xml	(revision 2056)
+++ /LMDZ5/branches/testing/DefLists/file_def_histLES_lmdz.xml	(revision 2056)
@@ -0,0 +1,515 @@
+<file_definition>
+    <file_group id="defile">
+        <file id="histLES" name="XhistLES" output_freq="1h" output_level="5" enabled=".FALSE.">
+            
+            <!-- VARS 1D -->
+            <field_group operation="once">
+              <field field_ref="Ap" level="1" />
+              <field field_ref="Bp" level="1" />
+              <field field_ref="Alt" level="1" />
+            </field_group>
+        
+            <!-- VARS 2D -->
+            <field_group operation="average" freq_op="1ts">
+                <field field_ref="phis" level="1" />
+                <field field_ref="aire" level="1" operation="once" />
+                <field field_ref="contfracATM" level="10" operation="once" />
+                <field field_ref="contfracOR" level="10" />
+                <field field_ref="aireTER" level="10" />
+                <field field_ref="flat" level="5" />
+                <field field_ref="slp" level="10" />
+                <field field_ref="tsol" level="10" />
+                <field field_ref="t2m" level="10" />
+                <field field_ref="t2m_min" level="10" operation="minimum" />
+                <field field_ref="t2m_max" level="10" operation="maximum" />
+                <field field_ref="t2m_ter" level="10" />
+                <field field_ref="t2m_lic" level="10" />
+                <field field_ref="t2m_oce" level="10" />
+                <field field_ref="t2m_sic" level="10" />
+                <field field_ref="wind10m" level="10" />
+                <field field_ref="wind10max" level="10" operation="maximum" />
+                <field field_ref="sicf" level="10" />
+                <field field_ref="q2m" level="10" />
+                <field field_ref="ustar" level="10" />
+                <field field_ref="u10m" level="10" />
+                <field field_ref="v10m" level="10" />
+                <field field_ref="psol" level="10" />
+                <field field_ref="qsurf" level="10" />
+                <field field_ref="ustar_ter" level="10" />
+                <field field_ref="ustar_lic" level="10" />
+                <field field_ref="ustar_oce" level="10" />
+                <field field_ref="ustar_sic" level="10" />
+                <field field_ref="wstar_ter" level="10" />
+                <field field_ref="wstar_lic" level="10" />
+                <field field_ref="wstar_oce" level="10" />
+                <field field_ref="wstar_sic" level="10" />
+                <field field_ref="wstar" level="10" />
+                <field field_ref="u10m_ter" level="10" />
+                <field field_ref="u10m_lic" level="10" />
+                <field field_ref="u10m_oce" level="10" />
+                <field field_ref="u10m_sic" level="10" />
+                <field field_ref="v10m_ter" level="10" />
+                <field field_ref="v10m_lic" level="10" />
+                <field field_ref="v10m_oce" level="10" />
+                <field field_ref="v10m_sic" level="10" />
+                <field field_ref="qsol" level="10" />
+                <field field_ref="ndayrain" level="10" operation="instant" />
+                <field field_ref="precip" level="5" />
+                <field field_ref="plul" level="10" />
+                <field field_ref="pluc" level="5" />
+                <field field_ref="snow" level="5" />
+                <field field_ref="evap" level="10" />
+                <field field_ref="evap_ter" level="10" />
+                <field field_ref="evap_lic" level="10" />
+                <field field_ref="evap_oce" level="10" />
+                <field field_ref="evap_sic" level="10" />
+                <field field_ref="msnow" level="10" />
+                <field field_ref="fsnow" level="10" />
+                <field field_ref="tops" level="10" />
+                <field field_ref="tops0" level="10" />
+                <field field_ref="topl" level="10" />
+                <field field_ref="topl0" level="10" />
+                <field field_ref="SWupTOA" level="10" />
+                <field field_ref="SWupTOAclr" level="10" />
+                <field field_ref="SWdnTOA" level="10" />
+                <field field_ref="SWdnTOAclr" level="10" />
+                <field field_ref="nettop" level="10" />
+                <field field_ref="SWup200" level="10" />
+                <field field_ref="SWup200clr" level="10" />
+                <field field_ref="SWdn200" level="10" />
+                <field field_ref="SWdn200clr" level="10" />
+                <field field_ref="LWup200" level="10" />
+                <field field_ref="LWup200clr" level="10" />
+                <field field_ref="LWdn200" level="10" />
+                <field field_ref="LWdn200clr" level="10" />
+                <field field_ref="sols" level="10" />
+                <field field_ref="sols0" level="10" />
+                <field field_ref="soll" level="10" />
+                <field field_ref="soll0" level="10" />
+                <field field_ref="radsol" level="10" />
+                <field field_ref="SWupSFC" level="5" />
+                <field field_ref="SWupSFCclr" level="5" />
+                <field field_ref="SWdnSFC" level="5" />
+                <field field_ref="SWdnSFCclr" level="5" />
+                <field field_ref="LWupSFC" level="5" />
+                <field field_ref="LWupSFCclr" level="5" />
+                <field field_ref="LWdnSFC" level="5" />
+                <field field_ref="LWdnSFCclr" level="5" />
+                <field field_ref="bils" level="10" />
+                <field field_ref="bils_tke" level="10" />
+                <field field_ref="bils_diss" level="10" />
+                <field field_ref="bils_ec" level="10" />
+                <field field_ref="bils_kinetic" level="10" />
+                <field field_ref="bils_enthalp" level="10" />
+                <field field_ref="bils_latent" level="10" />
+                <field field_ref="sens" level="5" />
+                <field field_ref="fder" level="10" />
+                <field field_ref="ffonte" level="10" />
+                <field field_ref="fqcalving" level="10" />
+                <field field_ref="fqfonte" level="10" />
+                <field field_ref="taux" level="10" />
+                <field field_ref="tauy" level="10" />
+                <field field_ref="taux_ter" level="10" />
+                <field field_ref="taux_lic" level="10" />
+                <field field_ref="taux_oce" level="10" />
+                <field field_ref="taux_sic" level="10" />
+                <field field_ref="tauy_ter" level="10" />
+                <field field_ref="tauy_lic" level="10" />
+                <field field_ref="tauy_oce" level="10" />
+                <field field_ref="tauy_sic" level="10" />
+                <field field_ref="pourc_ter" level="10" />
+                <field field_ref="pourc_lic" level="10" />
+                <field field_ref="pourc_oce" level="10" />
+                <field field_ref="pourc_sic" level="10" />
+                <field field_ref="fract_ter" level="10" />
+                <field field_ref="fract_lic" level="10" />
+                <field field_ref="fract_oce" level="10" />
+                <field field_ref="fract_sic" level="10" />
+                <field field_ref="tsol_ter" level="10" />
+                <field field_ref="tsol_lic" level="10" />
+                <field field_ref="tsol_oce" level="10" />
+                <field field_ref="tsol_sic" level="10" />
+                <field field_ref="evappot_ter" level="10" />
+                <field field_ref="evappot_lic" level="10" />
+                <field field_ref="evappot_oce" level="10" />
+                <field field_ref="evappot_sic" level="10" />
+                <field field_ref="sens_ter" level="10" />
+                <field field_ref="sens_lic" level="10" />
+                <field field_ref="sens_oce" level="10" />
+                <field field_ref="sens_sic" level="10" />
+                <field field_ref="lat_ter" level="10" />
+                <field field_ref="lat_lic" level="10" />
+                <field field_ref="lat_oce" level="10" />
+                <field field_ref="lat_sic" level="10" />
+                <field field_ref="flw_ter" level="10" />
+                <field field_ref="flw_lic" level="10" />
+                <field field_ref="flw_oce" level="10" />
+                <field field_ref="flw_sic" level="10" />
+                <field field_ref="fsw_ter" level="10" />
+                <field field_ref="fsw_lic" level="10" />
+                <field field_ref="fsw_oce" level="10" />
+                <field field_ref="fsw_sic" level="10" />
+                <field field_ref="wbils_ter" level="10" />
+                <field field_ref="wbils_lic" level="10" />
+                <field field_ref="wbils_oce" level="10" />
+                <field field_ref="wbils_sic" level="10" />
+                <field field_ref="wbilo_ter" level="10" />
+                <field field_ref="wbilo_lic" level="10" />
+                <field field_ref="wbilo_oce" level="10" />
+                <field field_ref="wbilo_sic" level="10" />
+                <field field_ref="cdrm" level="10" />
+                <field field_ref="cdrh" level="10" />
+                <field field_ref="cldl" level="10" />
+                <field field_ref="cldm" level="10" />
+                <field field_ref="cldh" level="10" />
+                <field field_ref="cldt" level="5" />
+                <field field_ref="cldq" level="10" />
+                <field field_ref="lwp" level="10" />
+                <field field_ref="iwp" level="10" />
+                <field field_ref="ue" level="10" />
+                <field field_ref="ve" level="10" />
+                <field field_ref="uq" level="10" />
+                <field field_ref="vq" level="10" />
+                <field field_ref="cape" level="10" />
+                <field field_ref="pbase" level="10" />
+                <field field_ref="ptop" level="10" />
+                <field field_ref="fbase" level="10" />
+                <field field_ref="plcl" level="10" />
+                <field field_ref="plfc" level="10" />
+                <field field_ref="wbeff" level="10" />
+                <field field_ref="prw" level="10" />
+                <field field_ref="s_pblh" level="10" />
+                <field field_ref="s_pblt" level="10" />
+                <field field_ref="s_lcl" level="10" />
+                <field field_ref="s_therm" level="10" />
+                <field field_ref="slab_bils_oce" level="10" />
+                <field field_ref="ale_bl" level="10" />
+                <field field_ref="alp_bl" level="10" />
+                <field field_ref="ale_wk" level="10" />
+                <field field_ref="alp_wk" level="10" />
+                <field field_ref="ale" level="10" />
+                <field field_ref="alp" level="10" />
+                <field field_ref="cin" level="10" />
+                <field field_ref="wape" level="10" />
+                <field field_ref="n2" level="10" />
+                <field field_ref="s2" level="10" />
+                <field field_ref="proba_notrig" level="10" />
+                <field field_ref="random_notrig" level="10" />
+                <field field_ref="ale_bl_stat" level="10" />
+                <field field_ref="ale_bl_trig" level="10" />
+                <field field_ref="alp_bl_det" level="10" />
+                <field field_ref="alp_bl_fluct_m" level="10" />
+                <field field_ref="alp_bl_fluct_tke" level="10" />
+                <field field_ref="alp_bl_conv" level="10" />
+                <field field_ref="alp_bl_stat" level="10" />
+
+                <field_group operation="instant">
+                    <field field_ref="u850" level="10" />
+                    <field field_ref="u700" level="10" />
+                    <field field_ref="u500" level="10" />
+                    <field field_ref="u200" level="10" />
+                    <field field_ref="u100" level="10" />
+                    <field field_ref="u50" level="10" />
+                    <field field_ref="u10" level="10" />
+                    <field field_ref="v850" level="10" />
+                    <field field_ref="v700" level="10" />
+                    <field field_ref="v500" level="10" />
+                    <field field_ref="v200" level="10" />
+                    <field field_ref="v100" level="10" />
+                    <field field_ref="v50" level="10" />
+                    <field field_ref="v10" level="10" />
+                    <field field_ref="w850" level="10" />
+                    <field field_ref="w700" level="10" />
+                    <field field_ref="w500" level="10" />
+                    <field field_ref="w200" level="10" />
+                    <field field_ref="w100" level="10" />
+                    <field field_ref="w50" level="10" />
+                    <field field_ref="w10" level="10" />
+                    <field field_ref="t850" level="10" />
+                    <field field_ref="t700" level="10" />
+                    <field field_ref="t500" level="10" />
+                    <field field_ref="t200" level="10" />
+                    <field field_ref="t100" level="10" />
+                    <field field_ref="t50" level="10" />
+                    <field field_ref="t10" level="10" />
+                    <field field_ref="q850" level="10" />
+                    <field field_ref="q700" level="10" />
+                    <field field_ref="q500" level="10" />
+                    <field field_ref="q200" level="10" />
+                    <field field_ref="q100" level="10" />
+                    <field field_ref="q50" level="10" />
+                    <field field_ref="q10" level="10" />
+                    <field field_ref="z850" level="10" />
+                    <field field_ref="z700" level="10" />
+                    <field field_ref="z500" level="10" />
+                    <field field_ref="z200" level="10" />
+                    <field field_ref="z100" level="10" />
+                    <field field_ref="z50" level="10" />
+                    <field field_ref="z10" level="10" />
+                </field_group>
+
+                <field field_ref="t_oce_sic" level="10" />
+                <field field_ref="weakinv" level="10" />
+                <field field_ref="dthmin" level="10" />
+                <field field_ref="u10_ter" level="10" />
+                <field field_ref="u10_lic" level="10" />
+                <field field_ref="u10_oce" level="10" />
+                <field field_ref="u10_sic" level="10" />
+                <field field_ref="v10_ter" level="10" />
+                <field field_ref="v10_lic" level="10" />
+                <field field_ref="v10_oce" level="10" />
+                <field field_ref="v10_sic" level="10" />
+                <field field_ref="rh2m" level="10" />
+                <field field_ref="rh2m_min" level="10" operation="minimum" />
+                <field field_ref="rh2m_max" level="10" operation="maximum" />
+                <field field_ref="qsat2m" level="10" />
+                <field field_ref="tpot" level="10" />
+                <field field_ref="tpote" level="10" />
+                <field field_ref="tke" level="10" />
+                <field field_ref="tke_ter" level="10" />
+                <field field_ref="tke_lic" level="10" />
+                <field field_ref="tke_oce" level="10" />
+                <field field_ref="tke_sic" level="10" />
+                <field field_ref="tke_max_ter" level="10" operation="maximum" />
+                <field field_ref="tke_max_lic" level="10" operation="maximum" />
+                <field field_ref="tke_max_oce" level="10" operation="maximum" />
+                <field field_ref="tke_max_sic" level="10" operation="maximum" />
+                <field field_ref="SWnetOR" level="10" />
+                <field field_ref="SWdownOR" level="10" />
+                <field field_ref="LWdownOR" level="10" />
+                <field field_ref="snowl" level="10" />
+                <field field_ref="cape_max" level="10" operation="maximum" />
+                <field field_ref="solldown" level="10" />
+                <field field_ref="dtsvdfo" level="10" />
+                <field field_ref="dtsvdft" level="10" />
+                <field field_ref="dtsvdfg" level="10" />
+                <field field_ref="dtsvdfi" level="10" />
+                <field field_ref="rugs" level="10" />
+                <field field_ref="topswad" level="10" />
+                <field field_ref="topswad0" level="10" />
+                <field field_ref="topswai" level="10" />
+                <field field_ref="solswad" level="10" />
+                <field field_ref="solswad0" level="10" />
+                <field field_ref="solswai" level="10" />
+                <field field_ref="OD550_ASBCM" level="10" />
+                <field field_ref="OD550_ASPOMM" level="10" />
+                <field field_ref="OD550_ASSO4M" level="10" />
+                <field field_ref="OD550_CSSO4M" level="10" />
+                <field field_ref="OD550_SSSSM" level="10" />
+                <field field_ref="OD550_ASSSM" level="10" />
+                <field field_ref="OD550_CSSSM" level="10" />
+                <field field_ref="OD550_CIDUSTM" level="10" />
+                <field field_ref="OD550_AIBCM" level="10" />
+                <field field_ref="OD550_AIPOMM" level="10" />
+                <field field_ref="OD550_STRAT" level="10" />
+                <field field_ref="od550aer" level="10" />
+                <field field_ref="od865aer" level="10" />
+                <field field_ref="absvisaer" level="10" />
+                <field field_ref="od550lt1aer" level="10" />
+                <field field_ref="sconcso4" level="10" />
+                <field field_ref="sconcoa" level="10" />
+                <field field_ref="sconcbc" level="10" />
+                <field field_ref="sconcss" level="10" />
+                <field field_ref="sconcdust" level="10" />
+                <field field_ref="loadso4" level="10" />
+                <field field_ref="loadoa" level="10" />
+                <field field_ref="loadbc" level="10" />
+                <field field_ref="loadss" level="10" />
+                <field field_ref="loaddust" level="10" />
+                <field field_ref="swtoaas_nat" level="10" />
+                <field field_ref="swsrfas_nat" level="10" />
+                <field field_ref="swtoacs_nat" level="10" />
+                <field field_ref="swsrfcs_nat" level="10" />
+                <field field_ref="swtoaas_ant" level="10" />
+                <field field_ref="swsrfas_ant" level="10" />
+                <field field_ref="swtoacs_ant" level="10" />
+                <field field_ref="swsrfcs_ant" level="10" />
+                <field field_ref="swtoacf_nat" level="10" />
+                <field field_ref="swsrfcf_nat" level="10" />
+                <field field_ref="swtoacf_ant" level="10" />
+                <field field_ref="swsrfcf_ant" level="10" />
+                <field field_ref="swtoacf_zero" level="10" />
+                <field field_ref="swsrfcf_zero" level="10" />
+                <field field_ref="cldncl" level="10" />
+                <field field_ref="reffclwtop" level="10" />
+                <field field_ref="cldnvi" level="10" />
+                <field field_ref="lcc" level="10" />
+                <field field_ref="wvapp" level="10" />
+                <field field_ref="ozone_daylight" level="10" />
+                <field field_ref="albe_ter" level="10" />
+                <field field_ref="albe_lic" level="10" />
+                <field field_ref="albe_oce" level="10" />
+                <field field_ref="albe_sic" level="10" />
+                <field field_ref="ages_ter" level="10" />
+                <field field_ref="ages_lic" level="10" />
+                <field field_ref="ages_oce" level="10" />
+                <field field_ref="ages_sic" level="10" />
+                <field field_ref="rugs_ter" level="10" />
+                <field field_ref="rugs_lic" level="10" />
+                <field field_ref="rugs_oce" level="10" />
+                <field field_ref="rugs_sic" level="10" />
+                <field field_ref="alb1" level="10" />
+                <field field_ref="alb2" level="10" />
+                <field field_ref="ftime_con" level="10" operation="instant" />
+                <field field_ref="wake_h" level="10" />
+                <field field_ref="wake_s" level="10" />
+                <field field_ref="plulth" level="10" />
+                <field field_ref="plulst" level="10" />
+                <field field_ref="lmaxth" level="10" />
+                <field field_ref="ftime_th" level="10" />
+                <field field_ref="f0_th" level="10" />
+                <field field_ref="zmax_th" level="10" />
+                <field field_ref="rsut4co2" level="10" />
+                <field field_ref="rlut4co2" level="10" />
+                <field field_ref="rsutcs4co2" level="10" />
+                <field field_ref="rlutcs4co2" level="10" />
+            </field_group>
+
+            <!-- VARS 3D -->
+            <field_group operation="average" freq_op="1ts" axis_ref="presnivs">
+                <field field_ref="cldtau" level="10" />
+                <field field_ref="cldemi" level="10" />
+                <field field_ref="tke_max" level="10" operation="maximum" />
+                <field field_ref="kz" level="10" />
+                <field field_ref="kz_max" level="10" operation="maximum" />
+                <field field_ref="concso4" level="10" />
+                <field field_ref="concoa" level="10" />
+                <field field_ref="concbc" level="10" />
+                <field field_ref="concss" level="10" />
+                <field field_ref="concdust" level="10" />
+                <field field_ref="ec550aer" level="10" />
+                <field field_ref="lwcon" level="10" />
+                <field field_ref="iwcon" level="10" />
+                <field field_ref="temp" level="10" />
+                <field field_ref="theta" level="10" />
+                <field field_ref="ovap" level="10" />
+                <field field_ref="ovapinit" level="10" />
+                <field field_ref="oliq" level="10" />
+                <field field_ref="geop" level="10" />
+                <field field_ref="vitu" level="10" />
+                <field field_ref="vitv" level="10" />
+                <field field_ref="vitw" level="10" />
+                <field field_ref="pres" level="10" />
+                <field field_ref="paprs" level="10" />
+                <field field_ref="mass" level="10" />
+                <field field_ref="zfull" level="10" />
+                <field field_ref="zhalf" level="10" />
+                <field field_ref="rneb" level="10" />
+                <field field_ref="rnebcon" level="10" />
+                <field field_ref="rnebls" level="10" />
+                <field field_ref="rhum" level="10" />
+                <field field_ref="ozone" level="10" />
+                <field field_ref="upwd" level="10" />
+                <field field_ref="dtphy" level="10" />
+                <field field_ref="dqphy" level="10" />
+                <field field_ref="pr_con_l" level="10" />
+                <field field_ref="pr_con_i" level="10" />
+                <field field_ref="pr_lsc_l" level="10" />
+                <field field_ref="pr_lsc_i" level="10" />
+                <field field_ref="re" level="10" />
+                <field field_ref="fl" level="10" />
+                <field field_ref="scdnc" level="10" />
+                <field field_ref="reffclws" level="10" />
+                <field field_ref="reffclwc" level="10" />
+                <field field_ref="lcc3d" level="10" />
+                <field field_ref="lcc3dcon" level="10" />
+                <field field_ref="lcc3dstra" level="10" />
+                <field field_ref="clwcon" level="10" />
+                <field field_ref="Ma" level="10" />
+                <field field_ref="dnwd" level="10" />
+                <field field_ref="dnwd0" level="10" />
+                <field field_ref="mc" level="10" />
+                <field field_ref="dtdyn" level="10" />
+                <field field_ref="dqdyn" level="10" />
+                <field field_ref="dudyn" level="10" />
+                <field field_ref="dvdyn" level="10" />
+                <field field_ref="dtcon" level="10" />
+                <field field_ref="ducon" level="10" />
+                <field field_ref="dvcon" level="10" />
+                <field field_ref="dqcon" level="10" />
+                <field field_ref="dtwak" level="10" />
+                <field field_ref="dqwak" level="10" />
+                <field field_ref="wake_deltat" level="10" />
+                <field field_ref="wake_deltaq" level="10" />
+                <field field_ref="wake_omg" level="10" />
+                <field field_ref="wdtrainA" level="1" />
+                <field field_ref="wdtrainM" level="1" />
+                <field field_ref="Vprecip" level="10" />
+                <field field_ref="ftd" level="10" />
+                <field field_ref="fqd" level="10" />
+                <field field_ref="dtlsc" level="10" />
+                <field field_ref="dtlschr" level="10" />
+                <field field_ref="dqlsc" level="10" />
+                <field field_ref="beta_prec" level="10" />
+                <field field_ref="dtvdf" level="10" />
+                <field field_ref="dtdis" level="10" />
+                <field field_ref="dqvdf" level="10" />
+                <field field_ref="dteva" level="10" />
+                <field field_ref="dqeva" level="10" />
+                <field field_ref="dqlscth" level="10" />
+                <field field_ref="dqlscst" level="10" />
+                <field field_ref="dtlscth" level="10" />
+                <field field_ref="dtlscst" level="10" />
+                <field field_ref="ptconvth" level="10" />
+                <field field_ref="ptconv" level="10" />
+                <field field_ref="ratqs" level="10" />
+                <field field_ref="dtthe" level="10" />
+                <field field_ref="f_th" level="10" />
+                <field field_ref="e_th" level="10" />
+                <field field_ref="w_th" level="10" />
+                <field field_ref="lambda_th" level="10" />
+                <field field_ref="q_th" level="10" />
+                <field field_ref="a_th" level="10" />
+                <field field_ref="d_th" level="10" />
+                <field field_ref="dqthe" level="10" />
+                <field field_ref="dtajs" level="10" />
+                <field field_ref="dqajs" level="10" />
+                <field field_ref="dtswr" level="10" />
+                <field field_ref="dtsw0" level="10" />
+                <field field_ref="dtlwr" level="10" />
+                <field field_ref="dtlw0" level="10" />
+                <field field_ref="dtec" level="10" />
+                <field field_ref="duvdf" level="10" />
+                <field field_ref="dvvdf" level="10" />
+                <field field_ref="duoro" level="10" />
+                <field field_ref="dvoro" level="10" />
+                <field field_ref="dulif" level="10" />
+                <field field_ref="dvlif" level="10" />
+                <field field_ref="duhin" level="10" />
+                <field field_ref="dvhin" level="10" />
+                <field field_ref="dtoro" level="10" />
+                <field field_ref="dtlif" level="10" />
+                <field field_ref="dthin" level="10" />
+                <field field_ref="rsu" level="10" />
+                <field field_ref="rsd" level="10" />
+                <field field_ref="rlu" level="10" />
+                <field field_ref="rld" level="10" />
+                <field field_ref="rsucs" level="10" />
+                <field field_ref="rsdcs" level="10" />
+                <field field_ref="rlucs" level="10" />
+                <field field_ref="rldcs" level="10" />
+                <field field_ref="tnt" level="10" />
+                <field field_ref="tntc" level="10" />
+                <field field_ref="tntr" level="10" />
+                <field field_ref="tntscpbl" level="10" />
+                <field field_ref="tnhus" level="10" />
+                <field field_ref="tnhusc" level="10" />
+                <field field_ref="tnhusscpbl" level="10" />
+                <field field_ref="evu" level="10" />
+                <field field_ref="h2o" level="10" />
+                <field field_ref="mcd" level="10" />
+                <field field_ref="dmc" level="10" />
+                <field field_ref="ref_liq" level="10" />
+                <field field_ref="ref_ice" level="10" />
+                <field field_ref="rsu4co2" level="10" />
+                <field field_ref="rlu4co2" level="10" />
+                <field field_ref="rsucs4co2" level="10" />
+                <field field_ref="rlucs4co2" level="10" />
+                <field field_ref="rsd4co2" level="10" />
+                <field field_ref="rld4co2" level="10" />
+                <field field_ref="rsdcs4co2" level="10" />
+                <field field_ref="rldcs4co2" level="10" />
+            </field_group>
+        </file>
+    </file_group>
+</file_definition>
Index: /LMDZ5/branches/testing/DefLists/file_def_histdayNMC_lmdz.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/file_def_histdayNMC_lmdz.xml	(revision 2056)
+++ /LMDZ5/branches/testing/DefLists/file_def_histdayNMC_lmdz.xml	(revision 2056)
@@ -0,0 +1,30 @@
+<file_definition>
+    <file_group id="defile">
+        <file id="histdayNMC" name="XhistdayNMC" output_freq="1d" output_level="5" enabled=".FALSE.">
+
+            <!-- VARS 3D -->
+            <field_group operation="instant" freq_op="1ts" >
+                <field field_ref="tnondef" level="5" />
+                <field field_ref="ta" level="1" />
+                <field field_ref="zg" level="5" />
+                <field field_ref="hus" level="5" />
+                <field field_ref="hur" level="5" />
+                <field field_ref="ua" level="5" />
+                <field field_ref="va" level="5" />
+                <field field_ref="wap" level="5" />
+                <field field_ref="psbg" level="5" />
+                <field field_ref="tro3" level="5" />
+                <field field_ref="tro3_daylight" level="5" />
+                <field field_ref="uv" level="6" />
+                <!-- <field field_ref="vq" level="6" /> -->
+                <field field_ref="vT" level="6" />
+                <field field_ref="wq" level="6" />
+                <field field_ref="vphi" level="6" />
+                <field field_ref="wT" level="6" />
+                <field field_ref="uxu" level="6" />
+                <field field_ref="vxv" level="6" />
+                <field field_ref="TxT" level="6" />
+            </field_group>
+        </file>
+    </file_group>
+</file_definition>
Index: /LMDZ5/branches/testing/DefLists/file_def_histday_lmdz.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/file_def_histday_lmdz.xml	(revision 2056)
+++ /LMDZ5/branches/testing/DefLists/file_def_histday_lmdz.xml	(revision 2056)
@@ -0,0 +1,515 @@
+<file_definition>
+    <file_group id="defile">
+        <file id="histday" name="Xhistday" output_freq="1d" output_level="5" enabled=".FALSE.">
+            
+            <!-- VARS 1D -->
+            <field_group operation="once">
+              <field field_ref="Ap" level="1" />
+              <field field_ref="Bp" level="1" />
+              <field field_ref="Alt" level="1" />
+            </field_group>
+        
+            <!-- VARS 2D -->
+            <field_group operation="average" freq_op="1ts">
+                <field field_ref="phis" level="1" />
+                <field field_ref="aire" level="1" operation="once" />
+                <field field_ref="contfracATM" level="1" operation="once" />
+                <field field_ref="contfracOR" level="1" />
+                <field field_ref="aireTER" level="10" />
+                <field field_ref="flat" level="1" />
+                <field field_ref="slp" level="1" />
+                <field field_ref="tsol" level="1" />
+                <field field_ref="t2m" level="1" />
+                <field field_ref="t2m_min" level="1" operation="minimum" />
+                <field field_ref="t2m_max" level="1" operation="maximum" />
+                <field field_ref="t2m_ter" level="6" />
+                <field field_ref="t2m_lic" level="6" />
+                <field field_ref="t2m_oce" level="6" />
+                <field field_ref="t2m_sic" level="6" />
+                <field field_ref="wind10m" level="1" />
+                <field field_ref="wind10max" level="1" operation="maximum" />
+                <field field_ref="sicf" level="1" />
+                <field field_ref="q2m" level="1" />
+                <field field_ref="ustar" level="1" />
+                <field field_ref="u10m" level="1" />
+                <field field_ref="v10m" level="1" />
+                <field field_ref="psol" level="1" />
+                <field field_ref="qsurf" level="10" />
+                <field field_ref="ustar_ter" level="6" />
+                <field field_ref="ustar_lic" level="6" />
+                <field field_ref="ustar_oce" level="6" />
+                <field field_ref="ustar_sic" level="6" />
+                <field field_ref="wstar_ter" level="6" />
+                <field field_ref="wstar_lic" level="6" />
+                <field field_ref="wstar_oce" level="6" />
+                <field field_ref="wstar_sic" level="6" />
+                <field field_ref="wstar" level="5" />
+                <field field_ref="u10m_ter" level="6" />
+                <field field_ref="u10m_lic" level="6" />
+                <field field_ref="u10m_oce" level="6" />
+                <field field_ref="u10m_sic" level="6" />
+                <field field_ref="v10m_ter" level="6" />
+                <field field_ref="v10m_lic" level="6" />
+                <field field_ref="v10m_oce" level="6" />
+                <field field_ref="v10m_sic" level="6" />
+                <field field_ref="qsol" level="10" />
+                <field field_ref="ndayrain" level="10" operation="instant" />
+                <field field_ref="precip" level="1" />
+                <field field_ref="plul" level="1" />
+                <field field_ref="pluc" level="1" />
+                <field field_ref="snow" level="1" />
+                <field field_ref="evap" level="1" />
+                <field field_ref="evap_ter" level="6" />
+                <field field_ref="evap_lic" level="6" />
+                <field field_ref="evap_oce" level="6" />
+                <field field_ref="evap_sic" level="6" />
+                <field field_ref="msnow" level="10" />
+                <field field_ref="fsnow" level="10" />
+                <field field_ref="tops" level="1" />
+                <field field_ref="tops0" level="5" />
+                <field field_ref="topl" level="1" />
+                <field field_ref="topl0" level="5" />
+                <field field_ref="SWupTOA" level="4" />
+                <field field_ref="SWupTOAclr" level="4" />
+                <field field_ref="SWdnTOA" level="4" />
+                <field field_ref="SWdnTOAclr" level="4" />
+                <field field_ref="nettop" level="4" />
+                <field field_ref="SWup200" level="10" />
+                <field field_ref="SWup200clr" level="1" />
+                <field field_ref="SWdn200" level="10" />
+                <field field_ref="SWdn200clr" level="1" />
+                <field field_ref="LWup200" level="10" />
+                <field field_ref="LWup200clr" level="10" />
+                <field field_ref="LWdn200" level="10" />
+                <field field_ref="LWdn200clr" level="10" />
+                <field field_ref="sols" level="1" />
+                <field field_ref="sols0" level="5" />
+                <field field_ref="soll" level="1" />
+                <field field_ref="soll0" level="5" />
+                <field field_ref="radsol" level="7" />
+                <field field_ref="SWupSFC" level="4" />
+                <field field_ref="SWupSFCclr" level="4" />
+                <field field_ref="SWdnSFC" level="1" />
+                <field field_ref="SWdnSFCclr" level="4" />
+                <field field_ref="LWupSFC" level="4" />
+                <field field_ref="LWupSFCclr" level="4" />
+                <field field_ref="LWdnSFC" level="4" />
+                <field field_ref="LWdnSFCclr" level="4" />
+                <field field_ref="bils" level="2" />
+                <field field_ref="bils_tke" level="2" />
+                <field field_ref="bils_diss" level="2" />
+                <field field_ref="bils_ec" level="2" />
+                <field field_ref="bils_kinetic" level="2" />
+                <field field_ref="bils_enthalp" level="2" />
+                <field field_ref="bils_latent" level="2" />
+                <field field_ref="sens" level="1" />
+                <field field_ref="fder" level="2" />
+                <field field_ref="ffonte" level="10" />
+                <field field_ref="fqcalving" level="10" />
+                <field field_ref="fqfonte" level="10" />
+                <field field_ref="taux" level="10" />
+                <field field_ref="tauy" level="10" />
+                <field field_ref="taux_ter" level="6" />
+                <field field_ref="taux_lic" level="6" />
+                <field field_ref="taux_oce" level="6" />
+                <field field_ref="taux_sic" level="6" />
+                <field field_ref="tauy_ter" level="6" />
+                <field field_ref="tauy_lic" level="6" />
+                <field field_ref="tauy_oce" level="6" />
+                <field field_ref="tauy_sic" level="6" />
+                <field field_ref="pourc_ter" level="7" />
+                <field field_ref="pourc_lic" level="7" />
+                <field field_ref="pourc_oce" level="7" />
+                <field field_ref="pourc_sic" level="7" />
+                <field field_ref="fract_ter" level="6" />
+                <field field_ref="fract_lic" level="6" />
+                <field field_ref="fract_oce" level="6" />
+                <field field_ref="fract_sic" level="6" />
+                <field field_ref="tsol_ter" level="6" />
+                <field field_ref="tsol_lic" level="6" />
+                <field field_ref="tsol_oce" level="6" />
+                <field field_ref="tsol_sic" level="6" />
+                <field field_ref="evappot_ter" level="6" />
+                <field field_ref="evappot_lic" level="6" />
+                <field field_ref="evappot_oce" level="6" />
+                <field field_ref="evappot_sic" level="6" />
+                <field field_ref="sens_ter" level="6" />
+                <field field_ref="sens_lic" level="6" />
+                <field field_ref="sens_oce" level="6" />
+                <field field_ref="sens_sic" level="6" />
+                <field field_ref="lat_ter" level="6" />
+                <field field_ref="lat_lic" level="6" />
+                <field field_ref="lat_oce" level="6" />
+                <field field_ref="lat_sic" level="6" />
+                <field field_ref="flw_ter" level="10" />
+                <field field_ref="flw_lic" level="10" />
+                <field field_ref="flw_oce" level="10" />
+                <field field_ref="flw_sic" level="10" />
+                <field field_ref="fsw_ter" level="10" />
+                <field field_ref="fsw_lic" level="10" />
+                <field field_ref="fsw_oce" level="10" />
+                <field field_ref="fsw_sic" level="10" />
+                <field field_ref="wbils_ter" level="10" />
+                <field field_ref="wbils_lic" level="10" />
+                <field field_ref="wbils_oce" level="10" />
+                <field field_ref="wbils_sic" level="10" />
+                <field field_ref="wbilo_ter" level="10" />
+                <field field_ref="wbilo_lic" level="10" />
+                <field field_ref="wbilo_oce" level="10" />
+                <field field_ref="wbilo_sic" level="10" />
+                <field field_ref="cdrm" level="10" />
+                <field field_ref="cdrh" level="10" />
+                <field field_ref="cldl" level="1" />
+                <field field_ref="cldm" level="1" />
+                <field field_ref="cldh" level="1" />
+                <field field_ref="cldt" level="1" />
+                <field field_ref="cldq" level="1" />
+                <field field_ref="lwp" level="5" />
+                <field field_ref="iwp" level="5" />
+                <field field_ref="ue" level="10" />
+                <field field_ref="ve" level="10" />
+                <field field_ref="uq" level="10" />
+                <field field_ref="vq" level="10" />
+                <field field_ref="cape" level="10" />
+                <field field_ref="pbase" level="5" />
+                <field field_ref="ptop" level="5" />
+                <field field_ref="fbase" level="10" />
+                <field field_ref="plcl" level="10" />
+                <field field_ref="plfc" level="10" />
+                <field field_ref="wbeff" level="10" />
+                <field field_ref="prw" level="1" />
+                <field field_ref="s_pblh" level="10" />
+                <field field_ref="s_pblt" level="10" />
+                <field field_ref="s_lcl" level="10" />
+                <field field_ref="s_therm" level="10" />
+                <field field_ref="slab_bils_oce" level="1" />
+                <field field_ref="ale_bl" level="1" />
+                <field field_ref="alp_bl" level="1" />
+                <field field_ref="ale_wk" level="1" />
+                <field field_ref="alp_wk" level="1" />
+                <field field_ref="ale" level="1" />
+                <field field_ref="alp" level="1" />
+                <field field_ref="cin" level="1" />
+                <field field_ref="wape" level="1" />
+                <field field_ref="n2" level="1" />
+                <field field_ref="s2" level="1" />
+                <field field_ref="proba_notrig" level="1" />
+                <field field_ref="random_notrig" level="1" />
+                <field field_ref="ale_bl_stat" level="1" />
+                <field field_ref="ale_bl_trig" level="1" />
+                <field field_ref="alp_bl_det" level="1" />
+                <field field_ref="alp_bl_fluct_m" level="1" />
+                <field field_ref="alp_bl_fluct_tke" level="1" />
+                <field field_ref="alp_bl_conv" level="1" />
+                <field field_ref="alp_bl_stat" level="1" />
+
+                <field_group operation="instant">
+                    <field field_ref="u850" level="7" />
+                    <field field_ref="u700" level="7" />
+                    <field field_ref="u500" level="7" />
+                    <field field_ref="u200" level="7" />
+                    <field field_ref="u100" level="7" />
+                    <field field_ref="u50" level="7" />
+                    <field field_ref="u10" level="7" />
+                    <field field_ref="v850" level="7" />
+                    <field field_ref="v700" level="7" />
+                    <field field_ref="v500" level="7" />
+                    <field field_ref="v200" level="7" />
+                    <field field_ref="v100" level="7" />
+                    <field field_ref="v50" level="7" />
+                    <field field_ref="v10" level="7" />
+                    <field field_ref="w850" level="7" />
+                    <field field_ref="w700" level="7" />
+                    <field field_ref="w500" level="7" />
+                    <field field_ref="w200" level="7" />
+                    <field field_ref="w100" level="7" />
+                    <field field_ref="w50" level="7" />
+                    <field field_ref="w10" level="7" />
+                    <field field_ref="t850" level="7" />
+                    <field field_ref="t700" level="7" />
+                    <field field_ref="t500" level="7" />
+                    <field field_ref="t200" level="7" />
+                    <field field_ref="t100" level="7" />
+                    <field field_ref="t50" level="7" />
+                    <field field_ref="t10" level="7" />
+                    <field field_ref="q850" level="7" />
+                    <field field_ref="q700" level="7" />
+                    <field field_ref="q500" level="7" />
+                    <field field_ref="q200" level="7" />
+                    <field field_ref="q100" level="7" />
+                    <field field_ref="q50" level="7" />
+                    <field field_ref="q10" level="7" />
+                    <field field_ref="z850" level="7" />
+                    <field field_ref="z700" level="7" />
+                    <field field_ref="z500" level="7" />
+                    <field field_ref="z200" level="7" />
+                    <field field_ref="z100" level="7" />
+                    <field field_ref="z50" level="7" />
+                    <field field_ref="z10" level="7" />
+                </field_group>
+
+                <field field_ref="t_oce_sic" level="10" />
+                <field field_ref="weakinv" level="1" />
+                <field field_ref="dthmin" level="1" />
+                <field field_ref="u10_ter" level="4" />
+                <field field_ref="u10_lic" level="4" />
+                <field field_ref="u10_oce" level="4" />
+                <field field_ref="u10_sic" level="4" />
+                <field field_ref="v10_ter" level="4" />
+                <field field_ref="v10_lic" level="4" />
+                <field field_ref="v10_oce" level="4" />
+                <field field_ref="v10_sic" level="4" />
+                <field field_ref="rh2m" level="5" />
+                <field field_ref="rh2m_min" level="5" operation="minimum" />
+                <field field_ref="rh2m_max" level="5" operation="maximum" />
+                <field field_ref="qsat2m" level="5" />
+                <field field_ref="tpot" level="5" />
+                <field field_ref="tpote" level="5" />
+                <field field_ref="tke" level="10" />
+                <field field_ref="tke_ter" level="4" />
+                <field field_ref="tke_lic" level="4" />
+                <field field_ref="tke_oce" level="4" />
+                <field field_ref="tke_sic" level="4" />
+                <field field_ref="tke_max_ter" level="4" operation="maximum" />
+                <field field_ref="tke_max_lic" level="4" operation="maximum" />
+                <field field_ref="tke_max_oce" level="4" operation="maximum" />
+                <field field_ref="tke_max_sic" level="4" operation="maximum" />
+                <field field_ref="SWnetOR" level="10" />
+                <field field_ref="SWdownOR" level="10" />
+                <field field_ref="LWdownOR" level="10" />
+                <field field_ref="snowl" level="1" />
+                <field field_ref="cape_max" level="1" operation="maximum" />
+                <field field_ref="solldown" level="1" />
+                <field field_ref="dtsvdfo" level="10" />
+                <field field_ref="dtsvdft" level="10" />
+                <field field_ref="dtsvdfg" level="10" />
+                <field field_ref="dtsvdfi" level="10" />
+                <field field_ref="rugs" level="10" />
+                <field field_ref="topswad" level="10" />
+                <field field_ref="topswad0" level="10" />
+                <field field_ref="topswai" level="10" />
+                <field field_ref="solswad" level="10" />
+                <field field_ref="solswad0" level="10" />
+                <field field_ref="solswai" level="10" />
+                <field field_ref="OD550_ASBCM" level="6" />
+                <field field_ref="OD550_ASPOMM" level="6" />
+                <field field_ref="OD550_ASSO4M" level="6" />
+                <field field_ref="OD550_CSSO4M" level="6" />
+                <field field_ref="OD550_SSSSM" level="6" />
+                <field field_ref="OD550_ASSSM" level="6" />
+                <field field_ref="OD550_CSSSM" level="6" />
+                <field field_ref="OD550_CIDUSTM" level="6" />
+                <field field_ref="OD550_AIBCM" level="6" />
+                <field field_ref="OD550_AIPOMM" level="6" />
+                <field field_ref="OD550_STRAT" level="2" />
+                <field field_ref="od550aer" level="6" />
+                <field field_ref="od865aer" level="6" />
+                <field field_ref="absvisaer" level="6" />
+                <field field_ref="od550lt1aer" level="6" />
+                <field field_ref="sconcso4" level="6" />
+                <field field_ref="sconcoa" level="6" />
+                <field field_ref="sconcbc" level="6" />
+                <field field_ref="sconcss" level="6" />
+                <field field_ref="sconcdust" level="6" />
+                <field field_ref="loadso4" level="6" />
+                <field field_ref="loadoa" level="6" />
+                <field field_ref="loadbc" level="6" />
+                <field field_ref="loadss" level="6" />
+                <field field_ref="loaddust" level="6" />
+                <field field_ref="swtoaas_nat" level="6" />
+                <field field_ref="swsrfas_nat" level="6" />
+                <field field_ref="swtoacs_nat" level="6" />
+                <field field_ref="swsrfcs_nat" level="6" />
+                <field field_ref="swtoaas_ant" level="6" />
+                <field field_ref="swsrfas_ant" level="6" />
+                <field field_ref="swtoacs_ant" level="6" />
+                <field field_ref="swsrfcs_ant" level="6" />
+                <field field_ref="swtoacf_nat" level="6" />
+                <field field_ref="swsrfcf_nat" level="6" />
+                <field field_ref="swtoacf_ant" level="6" />
+                <field field_ref="swsrfcf_ant" level="6" />
+                <field field_ref="swtoacf_zero" level="6" />
+                <field field_ref="swsrfcf_zero" level="6" />
+                <field field_ref="cldncl" level="6" />
+                <field field_ref="reffclwtop" level="6" />
+                <field field_ref="cldnvi" level="6" />
+                <field field_ref="lcc" level="6" />
+                <field field_ref="wvapp" level="10" />
+                <field field_ref="ozone_daylight" level="10" />
+                <field field_ref="albe_ter" level="7" />
+                <field field_ref="albe_lic" level="7" />
+                <field field_ref="albe_oce" level="7" />
+                <field field_ref="albe_sic" level="7" />
+                <field field_ref="ages_ter" level="10" />
+                <field field_ref="ages_lic" level="10" />
+                <field field_ref="ages_oce" level="10" />
+                <field field_ref="ages_sic" level="10" />
+                <field field_ref="rugs_ter" level="6" />
+                <field field_ref="rugs_lic" level="6" />
+                <field field_ref="rugs_oce" level="6" />
+                <field field_ref="rugs_sic" level="6" />
+                <field field_ref="alb1" level="10" />
+                <field field_ref="alb2" level="10" />
+                <field field_ref="ftime_con" level="10" operation="instant" />
+                <field field_ref="wake_h" level="5" />
+                <field field_ref="wake_s" level="5" />
+                <field field_ref="plulth" level="10" />
+                <field field_ref="plulst" level="10" />
+                <field field_ref="lmaxth" level="10" />
+                <field field_ref="ftime_th" level="10" />
+                <field field_ref="f0_th" level="10" />
+                <field field_ref="zmax_th" level="4" />
+                <field field_ref="rsut4co2" level="10" />
+                <field field_ref="rlut4co2" level="10" />
+                <field field_ref="rsutcs4co2" level="10" />
+                <field field_ref="rlutcs4co2" level="10" />
+            </field_group>
+
+            <!-- VARS 3D -->
+            <field_group operation="average" freq_op="1ts" axis_ref="presnivs">
+                <field field_ref="cldtau" level="5" />
+                <field field_ref="cldemi" level="5" />
+                <field field_ref="tke_max" level="10" operation="maximum" />
+                <field field_ref="kz" level="10" />
+                <field field_ref="kz_max" level="10" operation="maximum" />
+                <field field_ref="concso4" level="6" />
+                <field field_ref="concoa" level="6" />
+                <field field_ref="concbc" level="6" />
+                <field field_ref="concss" level="6" />
+                <field field_ref="concdust" level="6" />
+                <field field_ref="ec550aer" level="6" />
+                <field field_ref="lwcon" level="5" />
+                <field field_ref="iwcon" level="5" />
+                <field field_ref="temp" level="3" />
+                <field field_ref="theta" level="3" />
+                <field field_ref="ovap" level="3" />
+                <field field_ref="ovapinit" level="10" />
+                <field field_ref="oliq" level="3" />
+                <field field_ref="geop" level="3" />
+                <field field_ref="vitu" level="3" />
+                <field field_ref="vitv" level="3" />
+                <field field_ref="vitw" level="3" />
+                <field field_ref="pres" level="3" />
+                <field field_ref="paprs" level="3" />
+                <field field_ref="mass" level="3" />
+                <field field_ref="zfull" level="3" />
+                <field field_ref="zhalf" level="3" />
+                <field field_ref="rneb" level="5" />
+                <field field_ref="rnebcon" level="5" />
+                <field field_ref="rnebls" level="5" />
+                <field field_ref="rhum" level="5" />
+                <field field_ref="ozone" level="10" />
+                <field field_ref="upwd" level="10" />
+                <field field_ref="dtphy" level="10" />
+                <field field_ref="dqphy" level="10" />
+                <field field_ref="pr_con_l" level="10" />
+                <field field_ref="pr_con_i" level="10" />
+                <field field_ref="pr_lsc_l" level="10" />
+                <field field_ref="pr_lsc_i" level="10" />
+                <field field_ref="re" level="10" />
+                <field field_ref="fl" level="10" />
+                <field field_ref="scdnc" level="6" />
+                <field field_ref="reffclws" level="6" />
+                <field field_ref="reffclwc" level="6" />
+                <field field_ref="lcc3d" level="6" />
+                <field field_ref="lcc3dcon" level="6" />
+                <field field_ref="lcc3dstra" level="6" />
+                <field field_ref="clwcon" level="10" />
+                <field field_ref="Ma" level="10" />
+                <field field_ref="dnwd" level="10" />
+                <field field_ref="dnwd0" level="10" />
+                <field field_ref="mc" level="5" />
+                <field field_ref="dtdyn" level="10" />
+                <field field_ref="dqdyn" level="10" />
+                <field field_ref="dudyn" level="10" />
+                <field field_ref="dvdyn" level="10" />
+                <field field_ref="dtcon" level="10" />
+                <field field_ref="ducon" level="10" />
+                <field field_ref="dvcon" level="10" />
+                <field field_ref="dqcon" level="10" />
+                <field field_ref="dtwak" level="5" />
+                <field field_ref="dqwak" level="5" />
+                <field field_ref="wake_deltat" level="5" />
+                <field field_ref="wake_deltaq" level="5" />
+                <field field_ref="wake_omg" level="5" />
+                <field field_ref="wdtrainA" level="1" />
+                <field field_ref="wdtrainM" level="1" />
+                <field field_ref="Vprecip" level="10" />
+                <field field_ref="ftd" level="5" />
+                <field field_ref="fqd" level="5" />
+                <field field_ref="dtlsc" level="10" />
+                <field field_ref="dtlschr" level="10" />
+                <field field_ref="dqlsc" level="10" />
+                <field field_ref="beta_prec" level="10" />
+                <field field_ref="dtvdf" level="10" />
+                <field field_ref="dtdis" level="10" />
+                <field field_ref="dqvdf" level="10" />
+                <field field_ref="dteva" level="10" />
+                <field field_ref="dqeva" level="10" />
+                <field field_ref="dqlscth" level="10" />
+                <field field_ref="dqlscst" level="10" />
+                <field field_ref="dtlscth" level="10" />
+                <field field_ref="dtlscst" level="10" />
+                <field field_ref="ptconvth" level="10" />
+                <field field_ref="ptconv" level="10" />
+                <field field_ref="ratqs" level="10" />
+                <field field_ref="dtthe" level="10" />
+                <field field_ref="f_th" level="10" />
+                <field field_ref="e_th" level="10" />
+                <field field_ref="w_th" level="10" />
+                <field field_ref="lambda_th" level="10" />
+                <field field_ref="q_th" level="10" />
+                <field field_ref="a_th" level="10" />
+                <field field_ref="d_th" level="10" />
+                <field field_ref="dqthe" level="10" />
+                <field field_ref="dtajs" level="10" />
+                <field field_ref="dqajs" level="10" />
+                <field field_ref="dtswr" level="10" />
+                <field field_ref="dtsw0" level="10" />
+                <field field_ref="dtlwr" level="10" />
+                <field field_ref="dtlw0" level="10" />
+                <field field_ref="dtec" level="10" />
+                <field field_ref="duvdf" level="10" />
+                <field field_ref="dvvdf" level="10" />
+                <field field_ref="duoro" level="10" />
+                <field field_ref="dvoro" level="10" />
+                <field field_ref="dulif" level="10" />
+                <field field_ref="dvlif" level="10" />
+                <field field_ref="duhin" level="10" />
+                <field field_ref="dvhin" level="10" />
+                <field field_ref="dtoro" level="10" />
+                <field field_ref="dtlif" level="10" />
+                <field field_ref="dthin" level="10" />
+                <field field_ref="rsu" level="10" />
+                <field field_ref="rsd" level="10" />
+                <field field_ref="rlu" level="10" />
+                <field field_ref="rld" level="10" />
+                <field field_ref="rsucs" level="10" />
+                <field field_ref="rsdcs" level="10" />
+                <field field_ref="rlucs" level="10" />
+                <field field_ref="rldcs" level="10" />
+                <field field_ref="tnt" level="10" />
+                <field field_ref="tntc" level="10" />
+                <field field_ref="tntr" level="10" />
+                <field field_ref="tntscpbl" level="10" />
+                <field field_ref="tnhus" level="10" />
+                <field field_ref="tnhusc" level="10" />
+                <field field_ref="tnhusscpbl" level="10" />
+                <field field_ref="evu" level="10" />
+                <field field_ref="h2o" level="10" />
+                <field field_ref="mcd" level="10" />
+                <field field_ref="dmc" level="10" />
+                <field field_ref="ref_liq" level="10" />
+                <field field_ref="ref_ice" level="10" />
+                <field field_ref="rsu4co2" level="10" />
+                <field field_ref="rlu4co2" level="10" />
+                <field field_ref="rsucs4co2" level="10" />
+                <field field_ref="rlucs4co2" level="10" />
+                <field field_ref="rsd4co2" level="10" />
+                <field field_ref="rld4co2" level="10" />
+                <field field_ref="rsdcs4co2" level="10" />
+                <field field_ref="rldcs4co2" level="10" />
+            </field_group>
+        </file>
+    </file_group>
+</file_definition>
Index: /LMDZ5/branches/testing/DefLists/file_def_histhfNMC_lmdz.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/file_def_histhfNMC_lmdz.xml	(revision 2056)
+++ /LMDZ5/branches/testing/DefLists/file_def_histhfNMC_lmdz.xml	(revision 2056)
@@ -0,0 +1,30 @@
+<file_definition>
+    <file_group id="defile">
+        <file id="histhfNMC" name="XhisthfNMC" output_freq="6h" output_level="5" enabled=".FALSE.">
+
+            <!-- VARS 3D -->
+            <field_group operation="instant" freq_op="1ts" >
+                <field field_ref="tnondef" level="5" />
+                <field field_ref="ta" level="1" />
+                <field field_ref="zg" level="5" />
+                <field field_ref="hus" level="5" />
+                <field field_ref="hur" level="5" />
+                <field field_ref="ua" level="5" />
+                <field field_ref="va" level="5" />
+                <field field_ref="wap" level="5" />
+                <field field_ref="psbg" level="5" />
+                <field field_ref="tro3" level="5" />
+                <field field_ref="tro3_daylight" level="5" />
+                <field field_ref="uv" level="6" />
+                <!-- <field field_ref="vq" level="6" /> -->
+                <field field_ref="vT" level="6" />
+                <field field_ref="wq" level="6" />
+                <field field_ref="vphi" level="6" />
+                <field field_ref="wT" level="6" />
+                <field field_ref="uxu" level="6" />
+                <field field_ref="vxv" level="6" />
+                <field field_ref="TxT" level="6" />
+            </field_group>
+        </file>
+    </file_group>
+</file_definition>
Index: /LMDZ5/branches/testing/DefLists/file_def_histhf_lmdz.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/file_def_histhf_lmdz.xml	(revision 2056)
+++ /LMDZ5/branches/testing/DefLists/file_def_histhf_lmdz.xml	(revision 2056)
@@ -0,0 +1,515 @@
+<file_definition>
+    <file_group id="defile">
+        <file id="histhf" name="Xhisthf" output_freq="1h" output_level="5" enabled=".FALSE.">
+            
+            <!-- VARS 1D -->
+            <field_group operation="once">
+              <field field_ref="Ap" level="1" />
+              <field field_ref="Bp" level="1" />
+              <field field_ref="Alt" level="1" />
+            </field_group>
+        
+            <!-- VARS 2D -->
+            <field_group operation="average" freq_op="1ts">
+                <field field_ref="phis" level="5" />
+                <field field_ref="aire" level="10" operation="once" />
+                <field field_ref="contfracATM" level="10" operation="once" />
+                <field field_ref="contfracOR" level="10" />
+                <field field_ref="aireTER" level="10" />
+                <field field_ref="flat" level="10" />
+                <field field_ref="slp" level="10" />
+                <field field_ref="tsol" level="5" />
+                <field field_ref="t2m" level="5" />
+                <field field_ref="t2m_min" level="10" operation="minimum" />
+                <field field_ref="t2m_max" level="10" operation="maximum" />
+                <field field_ref="t2m_ter" level="10" />
+                <field field_ref="t2m_lic" level="10" />
+                <field field_ref="t2m_oce" level="10" />
+                <field field_ref="t2m_sic" level="10" />
+                <field field_ref="wind10m" level="10" />
+                <field field_ref="wind10max" level="10" operation="maximum" />
+                <field field_ref="sicf" level="10" />
+                <field field_ref="q2m" level="5" />
+                <field field_ref="ustar" level="5" />
+                <field field_ref="u10m" level="5" />
+                <field field_ref="v10m" level="5" />
+                <field field_ref="psol" level="5" />
+                <field field_ref="qsurf" level="10" />
+                <field field_ref="ustar_ter" level="10" />
+                <field field_ref="ustar_lic" level="10" />
+                <field field_ref="ustar_oce" level="10" />
+                <field field_ref="ustar_sic" level="10" />
+                <field field_ref="wstar_ter" level="10" />
+                <field field_ref="wstar_lic" level="10" />
+                <field field_ref="wstar_oce" level="10" />
+                <field field_ref="wstar_sic" level="10" />
+                <field field_ref="wstar" level="10" />
+                <field field_ref="u10m_ter" level="10" />
+                <field field_ref="u10m_lic" level="10" />
+                <field field_ref="u10m_oce" level="10" />
+                <field field_ref="u10m_sic" level="10" />
+                <field field_ref="v10m_ter" level="10" />
+                <field field_ref="v10m_lic" level="10" />
+                <field field_ref="v10m_oce" level="10" />
+                <field field_ref="v10m_sic" level="10" />
+                <field field_ref="qsol" level="10" />
+                <field field_ref="ndayrain" level="10" operation="instant" />
+                <field field_ref="precip" level="10" />
+                <field field_ref="plul" level="10" />
+                <field field_ref="pluc" level="10" />
+                <field field_ref="snow" level="10" />
+                <field field_ref="evap" level="10" />
+                <field field_ref="evap_ter" level="10" />
+                <field field_ref="evap_lic" level="10" />
+                <field field_ref="evap_oce" level="10" />
+                <field field_ref="evap_sic" level="10" />
+                <field field_ref="msnow" level="10" />
+                <field field_ref="fsnow" level="10" />
+                <field field_ref="tops" level="10" />
+                <field field_ref="tops0" level="10" />
+                <field field_ref="topl" level="5" />
+                <field field_ref="topl0" level="10" />
+                <field field_ref="SWupTOA" level="10" />
+                <field field_ref="SWupTOAclr" level="10" />
+                <field field_ref="SWdnTOA" level="10" />
+                <field field_ref="SWdnTOAclr" level="10" />
+                <field field_ref="nettop" level="10" />
+                <field field_ref="SWup200" level="10" />
+                <field field_ref="SWup200clr" level="10" />
+                <field field_ref="SWdn200" level="10" />
+                <field field_ref="SWdn200clr" level="10" />
+                <field field_ref="LWup200" level="10" />
+                <field field_ref="LWup200clr" level="10" />
+                <field field_ref="LWdn200" level="10" />
+                <field field_ref="LWdn200clr" level="10" />
+                <field field_ref="sols" level="10" />
+                <field field_ref="sols0" level="10" />
+                <field field_ref="soll" level="10" />
+                <field field_ref="soll0" level="10" />
+                <field field_ref="radsol" level="10" />
+                <field field_ref="SWupSFC" level="10" />
+                <field field_ref="SWupSFCclr" level="10" />
+                <field field_ref="SWdnSFC" level="10" />
+                <field field_ref="SWdnSFCclr" level="10" />
+                <field field_ref="LWupSFC" level="10" />
+                <field field_ref="LWupSFCclr" level="10" />
+                <field field_ref="LWdnSFC" level="10" />
+                <field field_ref="LWdnSFCclr" level="10" />
+                <field field_ref="bils" level="5" />
+                <field field_ref="bils_tke" level="5" />
+                <field field_ref="bils_diss" level="5" />
+                <field field_ref="bils_ec" level="5" />
+                <field field_ref="bils_kinetic" level="5" />
+                <field field_ref="bils_enthalp" level="5" />
+                <field field_ref="bils_latent" level="5" />
+                <field field_ref="sens" level="10" />
+                <field field_ref="fder" level="10" />
+                <field field_ref="ffonte" level="10" />
+                <field field_ref="fqcalving" level="10" />
+                <field field_ref="fqfonte" level="10" />
+                <field field_ref="taux" level="10" />
+                <field field_ref="tauy" level="10" />
+                <field field_ref="taux_ter" level="10" />
+                <field field_ref="taux_lic" level="10" />
+                <field field_ref="taux_oce" level="10" />
+                <field field_ref="taux_sic" level="10" />
+                <field field_ref="tauy_ter" level="10" />
+                <field field_ref="tauy_lic" level="10" />
+                <field field_ref="tauy_oce" level="10" />
+                <field field_ref="tauy_sic" level="10" />
+                <field field_ref="pourc_ter" level="10" />
+                <field field_ref="pourc_lic" level="10" />
+                <field field_ref="pourc_oce" level="10" />
+                <field field_ref="pourc_sic" level="10" />
+                <field field_ref="fract_ter" level="10" />
+                <field field_ref="fract_lic" level="10" />
+                <field field_ref="fract_oce" level="10" />
+                <field field_ref="fract_sic" level="10" />
+                <field field_ref="tsol_ter" level="10" />
+                <field field_ref="tsol_lic" level="10" />
+                <field field_ref="tsol_oce" level="10" />
+                <field field_ref="tsol_sic" level="10" />
+                <field field_ref="evappot_ter" level="10" />
+                <field field_ref="evappot_lic" level="10" />
+                <field field_ref="evappot_oce" level="10" />
+                <field field_ref="evappot_sic" level="10" />
+                <field field_ref="sens_ter" level="7" />
+                <field field_ref="sens_lic" level="7" />
+                <field field_ref="sens_oce" level="7" />
+                <field field_ref="sens_sic" level="7" />
+                <field field_ref="lat_ter" level="7" />
+                <field field_ref="lat_lic" level="7" />
+                <field field_ref="lat_oce" level="7" />
+                <field field_ref="lat_sic" level="7" />
+                <field field_ref="flw_ter" level="10" />
+                <field field_ref="flw_lic" level="10" />
+                <field field_ref="flw_oce" level="10" />
+                <field field_ref="flw_sic" level="10" />
+                <field field_ref="fsw_ter" level="10" />
+                <field field_ref="fsw_lic" level="10" />
+                <field field_ref="fsw_oce" level="10" />
+                <field field_ref="fsw_sic" level="10" />
+                <field field_ref="wbils_ter" level="10" />
+                <field field_ref="wbils_lic" level="10" />
+                <field field_ref="wbils_oce" level="10" />
+                <field field_ref="wbils_sic" level="10" />
+                <field field_ref="wbilo_ter" level="10" />
+                <field field_ref="wbilo_lic" level="10" />
+                <field field_ref="wbilo_oce" level="10" />
+                <field field_ref="wbilo_sic" level="10" />
+                <field field_ref="cdrm" level="10" />
+                <field field_ref="cdrh" level="7" />
+                <field field_ref="cldl" level="10" />
+                <field field_ref="cldm" level="10" />
+                <field field_ref="cldh" level="10" />
+                <field field_ref="cldt" level="10" />
+                <field field_ref="cldq" level="10" />
+                <field field_ref="lwp" level="10" />
+                <field field_ref="iwp" level="10" />
+                <field field_ref="ue" level="10" />
+                <field field_ref="ve" level="10" />
+                <field field_ref="uq" level="10" />
+                <field field_ref="vq" level="10" />
+                <field field_ref="cape" level="10" />
+                <field field_ref="pbase" level="10" />
+                <field field_ref="ptop" level="10" />
+                <field field_ref="fbase" level="10" />
+                <field field_ref="plcl" level="10" />
+                <field field_ref="plfc" level="10" />
+                <field field_ref="wbeff" level="10" />
+                <field field_ref="prw" level="10" />
+                <field field_ref="s_pblh" level="10" />
+                <field field_ref="s_pblt" level="10" />
+                <field field_ref="s_lcl" level="10" />
+                <field field_ref="s_therm" level="10" />
+                <field field_ref="slab_bils_oce" level="10" />
+                <field field_ref="ale_bl" level="10" />
+                <field field_ref="alp_bl" level="10" />
+                <field field_ref="ale_wk" level="10" />
+                <field field_ref="alp_wk" level="10" />
+                <field field_ref="ale" level="10" />
+                <field field_ref="alp" level="10" />
+                <field field_ref="cin" level="10" />
+                <field field_ref="wape" level="10" />
+                <field field_ref="n2" level="6" />
+                <field field_ref="s2" level="6" />
+                <field field_ref="proba_notrig" level="6" />
+                <field field_ref="random_notrig" level="6" />
+                <field field_ref="ale_bl_stat" level="6" />
+                <field field_ref="ale_bl_trig" level="6" />
+                <field field_ref="alp_bl_det" level="10" />
+                <field field_ref="alp_bl_fluct_m" level="10" />
+                <field field_ref="alp_bl_fluct_tke" level="10" />
+                <field field_ref="alp_bl_conv" level="10" />
+                <field field_ref="alp_bl_stat" level="10" />
+
+                <field_group operation="instant">
+                    <field field_ref="u850" level="10" />
+                    <field field_ref="u700" level="10" />
+                    <field field_ref="u500" level="10" />
+                    <field field_ref="u200" level="10" />
+                    <field field_ref="u100" level="10" />
+                    <field field_ref="u50" level="10" />
+                    <field field_ref="u10" level="10" />
+                    <field field_ref="v850" level="10" />
+                    <field field_ref="v700" level="10" />
+                    <field field_ref="v500" level="10" />
+                    <field field_ref="v200" level="10" />
+                    <field field_ref="v100" level="10" />
+                    <field field_ref="v50" level="10" />
+                    <field field_ref="v10" level="10" />
+                    <field field_ref="w850" level="10" />
+                    <field field_ref="w700" level="10" />
+                    <field field_ref="w500" level="10" />
+                    <field field_ref="w200" level="10" />
+                    <field field_ref="w100" level="10" />
+                    <field field_ref="w50" level="10" />
+                    <field field_ref="w10" level="10" />
+                    <field field_ref="t850" level="10" />
+                    <field field_ref="t700" level="10" />
+                    <field field_ref="t500" level="10" />
+                    <field field_ref="t200" level="10" />
+                    <field field_ref="t100" level="10" />
+                    <field field_ref="t50" level="10" />
+                    <field field_ref="t10" level="10" />
+                    <field field_ref="q850" level="10" />
+                    <field field_ref="q700" level="10" />
+                    <field field_ref="q500" level="10" />
+                    <field field_ref="q200" level="10" />
+                    <field field_ref="q100" level="10" />
+                    <field field_ref="q50" level="10" />
+                    <field field_ref="q10" level="10" />
+                    <field field_ref="z850" level="10" />
+                    <field field_ref="z700" level="10" />
+                    <field field_ref="z500" level="10" />
+                    <field field_ref="z200" level="10" />
+                    <field field_ref="z100" level="10" />
+                    <field field_ref="z50" level="10" />
+                    <field field_ref="z10" level="10" />
+                </field_group>
+
+                <field field_ref="t_oce_sic" level="10" />
+                <field field_ref="weakinv" level="10" />
+                <field field_ref="dthmin" level="10" />
+                <field field_ref="u10_ter" level="10" />
+                <field field_ref="u10_lic" level="10" />
+                <field field_ref="u10_oce" level="10" />
+                <field field_ref="u10_sic" level="10" />
+                <field field_ref="v10_ter" level="10" />
+                <field field_ref="v10_lic" level="10" />
+                <field field_ref="v10_oce" level="10" />
+                <field field_ref="v10_sic" level="10" />
+                <field field_ref="rh2m" level="10" />
+                <field field_ref="rh2m_min" level="10" operation="minimum" />
+                <field field_ref="rh2m_max" level="10" operation="maximum" />
+                <field field_ref="qsat2m" level="10" />
+                <field field_ref="tpot" level="10" />
+                <field field_ref="tpote" level="10" />
+                <field field_ref="tke" level="10" />
+                <field field_ref="tke_ter" level="10" />
+                <field field_ref="tke_lic" level="10" />
+                <field field_ref="tke_oce" level="10" />
+                <field field_ref="tke_sic" level="10" />
+                <field field_ref="tke_max_ter" level="10" operation="maximum" />
+                <field field_ref="tke_max_lic" level="10" operation="maximum" />
+                <field field_ref="tke_max_oce" level="10" operation="maximum" />
+                <field field_ref="tke_max_sic" level="10" operation="maximum" />
+                <field field_ref="SWnetOR" level="10" />
+                <field field_ref="SWdownOR" level="10" />
+                <field field_ref="LWdownOR" level="10" />
+                <field field_ref="snowl" level="10" />
+                <field field_ref="cape_max" level="10" operation="maximum" />
+                <field field_ref="solldown" level="10" />
+                <field field_ref="dtsvdfo" level="10" />
+                <field field_ref="dtsvdft" level="10" />
+                <field field_ref="dtsvdfg" level="10" />
+                <field field_ref="dtsvdfi" level="10" />
+                <field field_ref="rugs" level="10" />
+                <field field_ref="topswad" level="10" />
+                <field field_ref="topswad0" level="10" />
+                <field field_ref="topswai" level="10" />
+                <field field_ref="solswad" level="10" />
+                <field field_ref="solswad0" level="10" />
+                <field field_ref="solswai" level="10" />
+                <field field_ref="OD550_ASBCM" level="10" />
+                <field field_ref="OD550_ASPOMM" level="10" />
+                <field field_ref="OD550_ASSO4M" level="10" />
+                <field field_ref="OD550_CSSO4M" level="10" />
+                <field field_ref="OD550_SSSSM" level="10" />
+                <field field_ref="OD550_ASSSM" level="10" />
+                <field field_ref="OD550_CSSSM" level="10" />
+                <field field_ref="OD550_CIDUSTM" level="10" />
+                <field field_ref="OD550_AIBCM" level="10" />
+                <field field_ref="OD550_AIPOMM" level="10" />
+                <field field_ref="OD550_STRAT" level="10" />
+                <field field_ref="od550aer" level="10" />
+                <field field_ref="od865aer" level="10" />
+                <field field_ref="absvisaer" level="10" />
+                <field field_ref="od550lt1aer" level="10" />
+                <field field_ref="sconcso4" level="10" />
+                <field field_ref="sconcoa" level="10" />
+                <field field_ref="sconcbc" level="10" />
+                <field field_ref="sconcss" level="10" />
+                <field field_ref="sconcdust" level="10" />
+                <field field_ref="loadso4" level="10" />
+                <field field_ref="loadoa" level="10" />
+                <field field_ref="loadbc" level="10" />
+                <field field_ref="loadss" level="10" />
+                <field field_ref="loaddust" level="10" />
+                <field field_ref="swtoaas_nat" level="10" />
+                <field field_ref="swsrfas_nat" level="10" />
+                <field field_ref="swtoacs_nat" level="10" />
+                <field field_ref="swsrfcs_nat" level="10" />
+                <field field_ref="swtoaas_ant" level="10" />
+                <field field_ref="swsrfas_ant" level="10" />
+                <field field_ref="swtoacs_ant" level="10" />
+                <field field_ref="swsrfcs_ant" level="10" />
+                <field field_ref="swtoacf_nat" level="10" />
+                <field field_ref="swsrfcf_nat" level="10" />
+                <field field_ref="swtoacf_ant" level="10" />
+                <field field_ref="swsrfcf_ant" level="10" />
+                <field field_ref="swtoacf_zero" level="10" />
+                <field field_ref="swsrfcf_zero" level="10" />
+                <field field_ref="cldncl" level="10" />
+                <field field_ref="reffclwtop" level="10" />
+                <field field_ref="cldnvi" level="10" />
+                <field field_ref="lcc" level="10" />
+                <field field_ref="wvapp" level="10" />
+                <field field_ref="ozone_daylight" level="10" />
+                <field field_ref="albe_ter" level="7" />
+                <field field_ref="albe_lic" level="7" />
+                <field field_ref="albe_oce" level="7" />
+                <field field_ref="albe_sic" level="7" />
+                <field field_ref="ages_ter" level="10" />
+                <field field_ref="ages_lic" level="10" />
+                <field field_ref="ages_oce" level="10" />
+                <field field_ref="ages_sic" level="10" />
+                <field field_ref="rugs_ter" level="10" />
+                <field field_ref="rugs_lic" level="10" />
+                <field field_ref="rugs_oce" level="10" />
+                <field field_ref="rugs_sic" level="10" />
+                <field field_ref="alb1" level="10" />
+                <field field_ref="alb2" level="10" />
+                <field field_ref="ftime_con" level="10" operation="instant" />
+                <field field_ref="wake_h" level="10" />
+                <field field_ref="wake_s" level="10" />
+                <field field_ref="plulth" level="10" />
+                <field field_ref="plulst" level="10" />
+                <field field_ref="lmaxth" level="10" />
+                <field field_ref="ftime_th" level="10" />
+                <field field_ref="f0_th" level="10" />
+                <field field_ref="zmax_th" level="5" />
+                <field field_ref="rsut4co2" level="10" />
+                <field field_ref="rlut4co2" level="10" />
+                <field field_ref="rsutcs4co2" level="10" />
+                <field field_ref="rlutcs4co2" level="10" />
+            </field_group>
+
+            <!-- VARS 3D -->
+            <field_group operation="average" freq_op="1ts" axis_ref="presnivs">
+                <field field_ref="cldtau" level="10" />
+                <field field_ref="cldemi" level="10" />
+                <field field_ref="tke_max" level="10" operation="maximum" />
+                <field field_ref="kz" level="10" />
+                <field field_ref="kz_max" level="10" operation="maximum" />
+                <field field_ref="concso4" level="10" />
+                <field field_ref="concoa" level="10" />
+                <field field_ref="concbc" level="10" />
+                <field field_ref="concss" level="10" />
+                <field field_ref="concdust" level="10" />
+                <field field_ref="ec550aer" level="10" />
+                <field field_ref="lwcon" level="10" />
+                <field field_ref="iwcon" level="10" />
+                <field field_ref="temp" level="10" />
+                <field field_ref="theta" level="10" />
+                <field field_ref="ovap" level="10" />
+                <field field_ref="ovapinit" level="10" />
+                <field field_ref="oliq" level="10" />
+                <field field_ref="geop" level="10" />
+                <field field_ref="vitu" level="6" />
+                <field field_ref="vitv" level="6" />
+                <field field_ref="vitw" level="6" />
+                <field field_ref="pres" level="10" />
+                <field field_ref="paprs" level="10" />
+                <field field_ref="mass" level="10" />
+                <field field_ref="zfull" level="10" />
+                <field field_ref="zhalf" level="10" />
+                <field field_ref="rneb" level="10" />
+                <field field_ref="rnebcon" level="10" />
+                <field field_ref="rnebls" level="10" />
+                <field field_ref="rhum" level="10" />
+                <field field_ref="ozone" level="10" />
+                <field field_ref="upwd" level="10" />
+                <field field_ref="dtphy" level="10" />
+                <field field_ref="dqphy" level="10" />
+                <field field_ref="pr_con_l" level="10" />
+                <field field_ref="pr_con_i" level="10" />
+                <field field_ref="pr_lsc_l" level="10" />
+                <field field_ref="pr_lsc_i" level="10" />
+                <field field_ref="re" level="10" />
+                <field field_ref="fl" level="10" />
+                <field field_ref="scdnc" level="10" />
+                <field field_ref="reffclws" level="10" />
+                <field field_ref="reffclwc" level="10" />
+                <field field_ref="lcc3d" level="10" />
+                <field field_ref="lcc3dcon" level="10" />
+                <field field_ref="lcc3dstra" level="10" />
+                <field field_ref="clwcon" level="10" />
+                <field field_ref="Ma" level="10" />
+                <field field_ref="dnwd" level="10" />
+                <field field_ref="dnwd0" level="10" />
+                <field field_ref="mc" level="10" />
+                <field field_ref="dtdyn" level="10" />
+                <field field_ref="dqdyn" level="10" />
+                <field field_ref="dudyn" level="10" />
+                <field field_ref="dvdyn" level="10" />
+                <field field_ref="dtcon" level="10" />
+                <field field_ref="ducon" level="10" />
+                <field field_ref="dvcon" level="10" />
+                <field field_ref="dqcon" level="10" />
+                <field field_ref="dtwak" level="10" />
+                <field field_ref="dqwak" level="10" />
+                <field field_ref="wake_deltat" level="10" />
+                <field field_ref="wake_deltaq" level="10" />
+                <field field_ref="wake_omg" level="10" />
+                <field field_ref="wdtrainA" level="4" />
+                <field field_ref="wdtrainM" level="4" />
+                <field field_ref="Vprecip" level="10" />
+                <field field_ref="ftd" level="10" />
+                <field field_ref="fqd" level="10" />
+                <field field_ref="dtlsc" level="10" />
+                <field field_ref="dtlschr" level="10" />
+                <field field_ref="dqlsc" level="10" />
+                <field field_ref="beta_prec" level="10" />
+                <field field_ref="dtvdf" level="10" />
+                <field field_ref="dtdis" level="10" />
+                <field field_ref="dqvdf" level="10" />
+                <field field_ref="dteva" level="10" />
+                <field field_ref="dqeva" level="10" />
+                <field field_ref="dqlscth" level="10" />
+                <field field_ref="dqlscst" level="10" />
+                <field field_ref="dtlscth" level="10" />
+                <field field_ref="dtlscst" level="10" />
+                <field field_ref="ptconvth" level="10" />
+                <field field_ref="ptconv" level="10" />
+                <field field_ref="ratqs" level="10" />
+                <field field_ref="dtthe" level="10" />
+                <field field_ref="f_th" level="10" />
+                <field field_ref="e_th" level="10" />
+                <field field_ref="w_th" level="10" />
+                <field field_ref="lambda_th" level="10" />
+                <field field_ref="q_th" level="10" />
+                <field field_ref="a_th" level="10" />
+                <field field_ref="d_th" level="10" />
+                <field field_ref="dqthe" level="10" />
+                <field field_ref="dtajs" level="10" />
+                <field field_ref="dqajs" level="10" />
+                <field field_ref="dtswr" level="10" />
+                <field field_ref="dtsw0" level="10" />
+                <field field_ref="dtlwr" level="10" />
+                <field field_ref="dtlw0" level="10" />
+                <field field_ref="dtec" level="10" />
+                <field field_ref="duvdf" level="10" />
+                <field field_ref="dvvdf" level="10" />
+                <field field_ref="duoro" level="10" />
+                <field field_ref="dvoro" level="10" />
+                <field field_ref="dulif" level="10" />
+                <field field_ref="dvlif" level="10" />
+                <field field_ref="duhin" level="10" />
+                <field field_ref="dvhin" level="10" />
+                <field field_ref="dtoro" level="10" />
+                <field field_ref="dtlif" level="10" />
+                <field field_ref="dthin" level="10" />
+                <field field_ref="rsu" level="10" />
+                <field field_ref="rsd" level="10" />
+                <field field_ref="rlu" level="10" />
+                <field field_ref="rld" level="10" />
+                <field field_ref="rsucs" level="10" />
+                <field field_ref="rsdcs" level="10" />
+                <field field_ref="rlucs" level="10" />
+                <field field_ref="rldcs" level="10" />
+                <field field_ref="tnt" level="10" />
+                <field field_ref="tntc" level="10" />
+                <field field_ref="tntr" level="10" />
+                <field field_ref="tntscpbl" level="10" />
+                <field field_ref="tnhus" level="10" />
+                <field field_ref="tnhusc" level="10" />
+                <field field_ref="tnhusscpbl" level="10" />
+                <field field_ref="evu" level="10" />
+                <field field_ref="h2o" level="10" />
+                <field field_ref="mcd" level="10" />
+                <field field_ref="dmc" level="10" />
+                <field field_ref="ref_liq" level="10" />
+                <field field_ref="ref_ice" level="10" />
+                <field field_ref="rsu4co2" level="10" />
+                <field field_ref="rlu4co2" level="10" />
+                <field field_ref="rsucs4co2" level="10" />
+                <field field_ref="rlucs4co2" level="10" />
+                <field field_ref="rsd4co2" level="10" />
+                <field field_ref="rld4co2" level="10" />
+                <field field_ref="rsdcs4co2" level="10" />
+                <field field_ref="rldcs4co2" level="10" />
+            </field_group>
+        </file>
+    </file_group>
+</file_definition>
Index: /LMDZ5/branches/testing/DefLists/file_def_histins_lmdz.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/file_def_histins_lmdz.xml	(revision 2056)
+++ /LMDZ5/branches/testing/DefLists/file_def_histins_lmdz.xml	(revision 2056)
@@ -0,0 +1,515 @@
+<file_definition>
+    <file_group id="defile">
+        <file id="histins" name="Xhistins" output_freq="6h" output_level="4" enabled=".FALSE.">
+            
+            <!-- VARS 1D -->
+            <field_group operation="once">
+              <field field_ref="Ap" level="1" />
+              <field field_ref="Bp" level="1" />
+              <field field_ref="Alt" level="1" />
+            </field_group>
+        
+            <!-- VARS 2D -->
+            <field_group operation="instant" freq_op="1ts">
+                <field field_ref="phis" level="10" />
+                <field field_ref="aire" level="10" operation="once" />
+                <field field_ref="contfracATM" level="1" operation="once" />
+                <field field_ref="contfracOR" level="1" />
+                <field field_ref="aireTER" level="1" />
+                <field field_ref="flat" level="10" />
+                <field field_ref="slp" level="1" />
+                <field field_ref="tsol" level="1" />
+                <field field_ref="t2m" level="1" />
+                <field field_ref="t2m_min" level="10" operation="minimum" />
+                <field field_ref="t2m_max" level="10" operation="maximum" />
+                <field field_ref="t2m_ter" level="10" />
+                <field field_ref="t2m_lic" level="10" />
+                <field field_ref="t2m_oce" level="10" />
+                <field field_ref="t2m_sic" level="10" />
+                <field field_ref="wind10m" level="1" />
+                <field field_ref="wind10max" level="10" operation="maximum" />
+                <field field_ref="sicf" level="10" />
+                <field field_ref="q2m" level="1" />
+                <field field_ref="ustar" level="1" />
+                <field field_ref="u10m" level="1" />
+                <field field_ref="v10m" level="1" />
+                <field field_ref="psol" level="1" />
+                <field field_ref="qsurf" level="10" />
+                <field field_ref="ustar_ter" level="10" />
+                <field field_ref="ustar_lic" level="10" />
+                <field field_ref="ustar_oce" level="10" />
+                <field field_ref="ustar_sic" level="10" />
+                <field field_ref="wstar_ter" level="10" />
+                <field field_ref="wstar_lic" level="10" />
+                <field field_ref="wstar_oce" level="10" />
+                <field field_ref="wstar_sic" level="10" />
+                <field field_ref="wstar" level="10" />
+                <field field_ref="u10m_ter" level="10" />
+                <field field_ref="u10m_lic" level="10" />
+                <field field_ref="u10m_oce" level="10" />
+                <field field_ref="u10m_sic" level="10" />
+                <field field_ref="v10m_ter" level="10" />
+                <field field_ref="v10m_lic" level="10" />
+                <field field_ref="v10m_oce" level="10" />
+                <field field_ref="v10m_sic" level="10" />
+                <field field_ref="qsol" level="10" />
+                <field field_ref="ndayrain" level="10" operation="instant"  />
+                <field field_ref="precip" level="1" />
+                <field field_ref="plul" level="1" />
+                <field field_ref="pluc" level="1" />
+                <field field_ref="snow" level="10" />
+                <field field_ref="evap" level="10" />
+                <field field_ref="evap_ter" level="10" />
+                <field field_ref="evap_lic" level="10" />
+                <field field_ref="evap_oce" level="10" />
+                <field field_ref="evap_sic" level="10" />
+                <field field_ref="msnow" level="10" />
+                <field field_ref="fsnow" level="10" />
+                <field field_ref="tops" level="10" />
+                <field field_ref="tops0" level="10" />
+                <field field_ref="topl" level="10" />
+                <field field_ref="topl0" level="10" />
+                <field field_ref="SWupTOA" level="10" />
+                <field field_ref="SWupTOAclr" level="10" />
+                <field field_ref="SWdnTOA" level="10" />
+                <field field_ref="SWdnTOAclr" level="10" />
+                <field field_ref="nettop" level="10" />
+                <field field_ref="SWup200" level="10" />
+                <field field_ref="SWup200clr" level="10" />
+                <field field_ref="SWdn200" level="10" />
+                <field field_ref="SWdn200clr" level="10" />
+                <field field_ref="LWup200" level="10" />
+                <field field_ref="LWup200clr" level="10" />
+                <field field_ref="LWdn200" level="10" />
+                <field field_ref="LWdn200clr" level="10" />
+                <field field_ref="sols" level="10" />
+                <field field_ref="sols0" level="10" />
+                <field field_ref="soll" level="10" />
+                <field field_ref="soll0" level="10" />
+                <field field_ref="radsol" level="10" />
+                <field field_ref="SWupSFC" level="10" />
+                <field field_ref="SWupSFCclr" level="10" />
+                <field field_ref="SWdnSFC" level="10" />
+                <field field_ref="SWdnSFCclr" level="10" />
+                <field field_ref="LWupSFC" level="10" />
+                <field field_ref="LWupSFCclr" level="10" />
+                <field field_ref="LWdnSFC" level="10" />
+                <field field_ref="LWdnSFCclr" level="10" />
+                <field field_ref="bils" level="10" />
+                <field field_ref="bils_tke" level="10" />
+                <field field_ref="bils_diss" level="10" />
+                <field field_ref="bils_ec" level="10" />
+                <field field_ref="bils_kinetic" level="10" />
+                <field field_ref="bils_enthalp" level="10" />
+                <field field_ref="bils_latent" level="10" />
+                <field field_ref="sens" level="10" />
+                <field field_ref="fder" level="10" />
+                <field field_ref="ffonte" level="10" />
+                <field field_ref="fqcalving" level="10" />
+                <field field_ref="fqfonte" level="10" />
+                <field field_ref="taux" level="10" />
+                <field field_ref="tauy" level="10" />
+                <field field_ref="taux_ter" level="10" />
+                <field field_ref="taux_lic" level="10" />
+                <field field_ref="taux_oce" level="10" />
+                <field field_ref="taux_sic" level="10" />
+                <field field_ref="tauy_ter" level="10" />
+                <field field_ref="tauy_lic" level="10" />
+                <field field_ref="tauy_oce" level="10" />
+                <field field_ref="tauy_sic" level="10" />
+                <field field_ref="pourc_ter" level="10" />
+                <field field_ref="pourc_lic" level="10" />
+                <field field_ref="pourc_oce" level="10" />
+                <field field_ref="pourc_sic" level="10" />
+                <field field_ref="fract_ter" level="10" />
+                <field field_ref="fract_lic" level="10" />
+                <field field_ref="fract_oce" level="10" />
+                <field field_ref="fract_sic" level="10" />
+                <field field_ref="tsol_ter" level="10" />
+                <field field_ref="tsol_lic" level="10" />
+                <field field_ref="tsol_oce" level="10" />
+                <field field_ref="tsol_sic" level="10" />
+                <field field_ref="evappot_ter" level="10" />
+                <field field_ref="evappot_lic" level="10" />
+                <field field_ref="evappot_oce" level="10" />
+                <field field_ref="evappot_sic" level="10" />
+                <field field_ref="sens_ter" level="10" />
+                <field field_ref="sens_lic" level="10" />
+                <field field_ref="sens_oce" level="10" />
+                <field field_ref="sens_sic" level="10" />
+                <field field_ref="lat_ter" level="10" />
+                <field field_ref="lat_lic" level="10" />
+                <field field_ref="lat_oce" level="10" />
+                <field field_ref="lat_sic" level="10" />
+                <field field_ref="flw_ter" level="10" />
+                <field field_ref="flw_lic" level="10" />
+                <field field_ref="flw_oce" level="10" />
+                <field field_ref="flw_sic" level="10" />
+                <field field_ref="fsw_ter" level="10" />
+                <field field_ref="fsw_lic" level="10" />
+                <field field_ref="fsw_oce" level="10" />
+                <field field_ref="fsw_sic" level="10" />
+                <field field_ref="wbils_ter" level="10" />
+                <field field_ref="wbils_lic" level="10" />
+                <field field_ref="wbils_oce" level="10" />
+                <field field_ref="wbils_sic" level="10" />
+                <field field_ref="wbilo_ter" level="10" />
+                <field field_ref="wbilo_lic" level="10" />
+                <field field_ref="wbilo_oce" level="10" />
+                <field field_ref="wbilo_sic" level="10" />
+                <field field_ref="cdrm" level="10" />
+                <field field_ref="cdrh" level="10" />
+                <field field_ref="cldl" level="10" />
+                <field field_ref="cldm" level="10" />
+                <field field_ref="cldh" level="10" />
+                <field field_ref="cldt" level="2" />
+                <field field_ref="cldq" level="10" />
+                <field field_ref="lwp" level="10" />
+                <field field_ref="iwp" level="10" />
+                <field field_ref="ue" level="10" />
+                <field field_ref="ve" level="10" />
+                <field field_ref="uq" level="10" />
+                <field field_ref="vq" level="10" />
+                <field field_ref="cape" level="10" />
+                <field field_ref="pbase" level="10" />
+                <field field_ref="ptop" level="10" />
+                <field field_ref="fbase" level="10" />
+                <field field_ref="plcl" level="10" />
+                <field field_ref="plfc" level="10" />
+                <field field_ref="wbeff" level="10" />
+                <field field_ref="prw" level="10" />
+                <field field_ref="s_pblh" level="10" />
+                <field field_ref="s_pblt" level="10" />
+                <field field_ref="s_lcl" level="10" />
+                <field field_ref="s_therm" level="10" />
+                <field field_ref="slab_bils_oce" level="10" />
+                <field field_ref="ale_bl" level="1" />
+                <field field_ref="alp_bl" level="1" />
+                <field field_ref="ale_wk" level="1" />
+                <field field_ref="alp_wk" level="1" />
+                <field field_ref="ale" level="1" />
+                <field field_ref="alp" level="1" />
+                <field field_ref="cin" level="1" />
+                <field field_ref="wape" level="1" />
+                <field field_ref="n2" level="1" />
+                <field field_ref="s2" level="1" />
+                <field field_ref="proba_notrig" level="1" />
+                <field field_ref="random_notrig" level="1" />
+                <field field_ref="ale_bl_stat" level="1" />
+                <field field_ref="ale_bl_trig" level="1" />
+                <field field_ref="alp_bl_det" level="1" />
+                <field field_ref="alp_bl_fluct_m" level="1" />
+                <field field_ref="alp_bl_fluct_tke" level="1" />
+                <field field_ref="alp_bl_conv" level="1" />
+                <field field_ref="alp_bl_stat" level="1" />
+
+                <field_group operation="instant">
+                    <field field_ref="u850" level="7" />
+                    <field field_ref="u700" level="7" />
+                    <field field_ref="u500" level="7" />
+                    <field field_ref="u200" level="7" />
+                    <field field_ref="u100" level="7" />
+                    <field field_ref="u50" level="7" />
+                    <field field_ref="u10" level="7" />
+                    <field field_ref="v850" level="7" />
+                    <field field_ref="v700" level="7" />
+                    <field field_ref="v500" level="7" />
+                    <field field_ref="v200" level="7" />
+                    <field field_ref="v100" level="7" />
+                    <field field_ref="v50" level="7" />
+                    <field field_ref="v10" level="7" />
+                    <field field_ref="w850" level="7" />
+                    <field field_ref="w700" level="7" />
+                    <field field_ref="w500" level="7" />
+                    <field field_ref="w200" level="7" />
+                    <field field_ref="w100" level="7" />
+                    <field field_ref="w50" level="7" />
+                    <field field_ref="w10" level="7" />
+                    <field field_ref="t850" level="7" />
+                    <field field_ref="t700" level="7" />
+                    <field field_ref="t500" level="7" />
+                    <field field_ref="t200" level="7" />
+                    <field field_ref="t100" level="7" />
+                    <field field_ref="t50" level="7" />
+                    <field field_ref="t10" level="7" />
+                    <field field_ref="q850" level="7" />
+                    <field field_ref="q700" level="7" />
+                    <field field_ref="q500" level="7" />
+                    <field field_ref="q200" level="7" />
+                    <field field_ref="q100" level="7" />
+                    <field field_ref="q50" level="7" />
+                    <field field_ref="q10" level="7" />
+                    <field field_ref="z850" level="7" />
+                    <field field_ref="z700" level="7" />
+                    <field field_ref="z500" level="7" />
+                    <field field_ref="z200" level="7" />
+                    <field field_ref="z100" level="7" />
+                    <field field_ref="z50" level="7" />
+                    <field field_ref="z10" level="7" />
+                </field_group>
+
+                <field field_ref="t_oce_sic" level="10" />
+                <field field_ref="weakinv" level="10" />
+                <field field_ref="dthmin" level="10" />
+                <field field_ref="u10_ter" level="10" />
+                <field field_ref="u10_lic" level="10" />
+                <field field_ref="u10_oce" level="10" />
+                <field field_ref="u10_sic" level="10" />
+                <field field_ref="v10_ter" level="10" />
+                <field field_ref="v10_lic" level="10" />
+                <field field_ref="v10_oce" level="10" />
+                <field field_ref="v10_sic" level="10" />
+                <field field_ref="rh2m" level="10" />
+                <field field_ref="rh2m_min" level="10" operation="minimum"  />
+                <field field_ref="rh2m_max" level="10" operation="maximum"  />
+                <field field_ref="qsat2m" level="10" />
+                <field field_ref="tpot" level="10" />
+                <field field_ref="tpote" level="10" />
+                <field field_ref="tke" level="10" />
+                <field field_ref="tke_ter" level="10" />
+                <field field_ref="tke_lic" level="10" />
+                <field field_ref="tke_oce" level="10" />
+                <field field_ref="tke_sic" level="10" />
+                <field field_ref="tke_max_ter" level="10" operation="maximum" />
+                <field field_ref="tke_max_lic" level="10" operation="maximum" />
+                <field field_ref="tke_max_oce" level="10" operation="maximum" />
+                <field field_ref="tke_max_sic" level="10" operation="maximum" />
+                <field field_ref="SWnetOR" level="2" />
+                <field field_ref="SWdownOR" level="2" />
+                <field field_ref="LWdownOR" level="2" />
+                <field field_ref="snowl" level="10" />
+                <field field_ref="cape_max" level="10" operation="maximum" />
+                <field field_ref="solldown" level="10" />
+                <field field_ref="dtsvdfo" level="10" />
+                <field field_ref="dtsvdft" level="10" />
+                <field field_ref="dtsvdfg" level="10" />
+                <field field_ref="dtsvdfi" level="10" />
+                <field field_ref="rugs" level="10" />
+                <field field_ref="topswad" level="10" />
+                <field field_ref="topswad0" level="10" />
+                <field field_ref="topswai" level="10" />
+                <field field_ref="solswad" level="10" />
+                <field field_ref="solswad0" level="10" />
+                <field field_ref="solswai" level="10" />
+                <field field_ref="OD550_ASBCM" level="10" />
+                <field field_ref="OD550_ASPOMM" level="10" />
+                <field field_ref="OD550_ASSO4M" level="10" />
+                <field field_ref="OD550_CSSO4M" level="10" />
+                <field field_ref="OD550_SSSSM" level="10" />
+                <field field_ref="OD550_ASSSM" level="10" />
+                <field field_ref="OD550_CSSSM" level="10" />
+                <field field_ref="OD550_CIDUSTM" level="10" />
+                <field field_ref="OD550_AIBCM" level="10" />
+                <field field_ref="OD550_AIPOMM" level="10" />
+                <field field_ref="OD550_STRAT" level="10" />
+                <field field_ref="od550aer" level="10" />
+                <field field_ref="od865aer" level="10" />
+                <field field_ref="absvisaer" level="10" />
+                <field field_ref="od550lt1aer" level="10" />
+                <field field_ref="sconcso4" level="10" />
+                <field field_ref="sconcoa" level="10" />
+                <field field_ref="sconcbc" level="10" />
+                <field field_ref="sconcss" level="10" />
+                <field field_ref="sconcdust" level="10" />
+                <field field_ref="loadso4" level="10" />
+                <field field_ref="loadoa" level="10" />
+                <field field_ref="loadbc" level="10" />
+                <field field_ref="loadss" level="10" />
+                <field field_ref="loaddust" level="10" />
+                <field field_ref="swtoaas_nat" level="10" />
+                <field field_ref="swsrfas_nat" level="10" />
+                <field field_ref="swtoacs_nat" level="10" />
+                <field field_ref="swsrfcs_nat" level="10" />
+                <field field_ref="swtoaas_ant" level="10" />
+                <field field_ref="swsrfas_ant" level="10" />
+                <field field_ref="swtoacs_ant" level="10" />
+                <field field_ref="swsrfcs_ant" level="10" />
+                <field field_ref="swtoacf_nat" level="10" />
+                <field field_ref="swsrfcf_nat" level="10" />
+                <field field_ref="swtoacf_ant" level="10" />
+                <field field_ref="swsrfcf_ant" level="10" />
+                <field field_ref="swtoacf_zero" level="10" />
+                <field field_ref="swsrfcf_zero" level="10" />
+                <field field_ref="cldncl" level="10" />
+                <field field_ref="reffclwtop" level="10" />
+                <field field_ref="cldnvi" level="10" />
+                <field field_ref="lcc" level="10" />
+                <field field_ref="wvapp" level="10" />
+                <field field_ref="ozone_daylight" level="10" />
+                <field field_ref="albe_ter" level="10" />
+                <field field_ref="albe_lic" level="10" />
+                <field field_ref="albe_oce" level="10" />
+                <field field_ref="albe_sic" level="10" />
+                <field field_ref="ages_ter" level="10" />
+                <field field_ref="ages_lic" level="10" />
+                <field field_ref="ages_oce" level="10" />
+                <field field_ref="ages_sic" level="10" />
+                <field field_ref="rugs_ter" level="10" />
+                <field field_ref="rugs_lic" level="10" />
+                <field field_ref="rugs_oce" level="10" />
+                <field field_ref="rugs_sic" level="10" />
+                <field field_ref="alb1" level="10" />
+                <field field_ref="alb2" level="10" />
+                <field field_ref="ftime_con" level="10" operation="instant" />
+                <field field_ref="wake_h" level="10" />
+                <field field_ref="wake_s" level="10" />
+                <field field_ref="plulth" level="10" />
+                <field field_ref="plulst" level="10" />
+                <field field_ref="lmaxth" level="10" />
+                <field field_ref="ftime_th" level="10" />
+                <field field_ref="f0_th" level="10" />
+                <field field_ref="zmax_th" level="4" />
+                <field field_ref="rsut4co2" level="10" />
+                <field field_ref="rlut4co2" level="10" />
+                <field field_ref="rsutcs4co2" level="10" />
+                <field field_ref="rlutcs4co2" level="10" />
+            </field_group>
+
+            <!-- VARS 3D -->
+            <field_group operation="instant" freq_op="1ts" axis_ref="presnivs">
+                <field field_ref="cldtau" level="10" />
+                <field field_ref="cldemi" level="10" />
+                <field field_ref="tke_max" level="10" operation="maximum" />
+                <field field_ref="kz" level="10" />
+                <field field_ref="kz_max" level="10" operation="maximum" />
+                <field field_ref="concso4" level="10" />
+                <field field_ref="concoa" level="10" />
+                <field field_ref="concbc" level="10" />
+                <field field_ref="concss" level="10" />
+                <field field_ref="concdust" level="10" />
+                <field field_ref="ec550aer" level="10" />
+                <field field_ref="lwcon" level="10" />
+                <field field_ref="iwcon" level="10" />
+                <field field_ref="temp" level="4" />
+                <field field_ref="theta" level="4" />
+                <field field_ref="ovap" level="4" />
+                <field field_ref="ovapinit" level="10" />
+                <field field_ref="oliq" level="4" />
+                <field field_ref="geop" level="10" />
+                <field field_ref="vitu" level="4" />
+                <field field_ref="vitv" level="4" />
+                <field field_ref="vitw" level="10" />
+                <field field_ref="pres" level="10" />
+                <field field_ref="paprs" level="10" />
+                <field field_ref="mass" level="10" />
+                <field field_ref="zfull" level="10" />
+                <field field_ref="zhalf" level="10" />
+                <field field_ref="rneb" level="10" />
+                <field field_ref="rnebcon" level="10" />
+                <field field_ref="rnebls" level="10" />
+                <field field_ref="rhum" level="10" />
+                <field field_ref="ozone" level="10" />
+                <field field_ref="upwd" level="10" />
+                <field field_ref="dtphy" level="10" />
+                <field field_ref="dqphy" level="10" />
+                <field field_ref="pr_con_l" level="10" />
+                <field field_ref="pr_con_i" level="10" />
+                <field field_ref="pr_lsc_l" level="10" />
+                <field field_ref="pr_lsc_i" level="10" />
+                <field field_ref="re" level="10" />
+                <field field_ref="fl" level="10" />
+                <field field_ref="scdnc" level="10" />
+                <field field_ref="reffclws" level="10" />
+                <field field_ref="reffclwc" level="10" />
+                <field field_ref="lcc3d" level="10" />
+                <field field_ref="lcc3dcon" level="10" />
+                <field field_ref="lcc3dstra" level="10" />
+                <field field_ref="clwcon" level="10" />
+                <field field_ref="Ma" level="10" />
+                <field field_ref="dnwd" level="10" />
+                <field field_ref="dnwd0" level="10" />
+                <field field_ref="mc" level="10" />
+                <field field_ref="dtdyn" level="10" />
+                <field field_ref="dqdyn" level="10" />
+                <field field_ref="dudyn" level="10" />
+                <field field_ref="dvdyn" level="10" />
+                <field field_ref="dtcon" level="10" />
+                <field field_ref="ducon" level="10" />
+                <field field_ref="dvcon" level="10" />
+                <field field_ref="dqcon" level="10" />
+                <field field_ref="dtwak" level="10" />
+                <field field_ref="dqwak" level="10" />
+                <field field_ref="wake_deltat" level="10" />
+                <field field_ref="wake_deltaq" level="10" />
+                <field field_ref="wake_omg" level="10" />
+                <field field_ref="wdtrainA" level="4" />
+                <field field_ref="wdtrainM" level="4" />
+                <field field_ref="Vprecip" level="10" />
+                <field field_ref="ftd" level="10" />
+                <field field_ref="fqd" level="10" />
+                <field field_ref="dtlsc" level="10" />
+                <field field_ref="dtlschr" level="10" />
+                <field field_ref="dqlsc" level="10" />
+                <field field_ref="beta_prec" level="10" />
+                <field field_ref="dtvdf" level="10" />
+                <field field_ref="dtdis" level="10" />
+                <field field_ref="dqvdf" level="10" />
+                <field field_ref="dteva" level="10" />
+                <field field_ref="dqeva" level="10" />
+                <field field_ref="dqlscth" level="10" />
+                <field field_ref="dqlscst" level="10" />
+                <field field_ref="dtlscth" level="10" />
+                <field field_ref="dtlscst" level="10" />
+                <field field_ref="ptconvth" level="10" />
+                <field field_ref="ptconv" level="10" />
+                <field field_ref="ratqs" level="10" />
+                <field field_ref="dtthe" level="10" />
+                <field field_ref="f_th" level="10" />
+                <field field_ref="e_th" level="10" />
+                <field field_ref="w_th" level="10" />
+                <field field_ref="lambda_th" level="10" />
+                <field field_ref="q_th" level="10" />
+                <field field_ref="a_th" level="10" />
+                <field field_ref="d_th" level="10" />
+                <field field_ref="dqthe" level="10" />
+                <field field_ref="dtajs" level="10" />
+                <field field_ref="dqajs" level="10" />
+                <field field_ref="dtswr" level="10" />
+                <field field_ref="dtsw0" level="10" />
+                <field field_ref="dtlwr" level="10" />
+                <field field_ref="dtlw0" level="10" />
+                <field field_ref="dtec" level="10" />
+                <field field_ref="duvdf" level="10" />
+                <field field_ref="dvvdf" level="10" />
+                <field field_ref="duoro" level="10" />
+                <field field_ref="dvoro" level="10" />
+                <field field_ref="dulif" level="10" />
+                <field field_ref="dvlif" level="10" />
+                <field field_ref="duhin" level="10" />
+                <field field_ref="dvhin" level="10" />
+                <field field_ref="dtoro" level="10" />
+                <field field_ref="dtlif" level="10" />
+                <field field_ref="dthin" level="10" />
+                <field field_ref="rsu" level="10" />
+                <field field_ref="rsd" level="10" />
+                <field field_ref="rlu" level="10" />
+                <field field_ref="rld" level="10" />
+                <field field_ref="rsucs" level="10" />
+                <field field_ref="rsdcs" level="10" />
+                <field field_ref="rlucs" level="10" />
+                <field field_ref="rldcs" level="10" />
+                <field field_ref="tnt" level="10" />
+                <field field_ref="tntc" level="10" />
+                <field field_ref="tntr" level="10" />
+                <field field_ref="tntscpbl" level="10" />
+                <field field_ref="tnhus" level="10" />
+                <field field_ref="tnhusc" level="10" />
+                <field field_ref="tnhusscpbl" level="10" />
+                <field field_ref="evu" level="10" />
+                <field field_ref="h2o" level="10" />
+                <field field_ref="mcd" level="10" />
+                <field field_ref="dmc" level="10" />
+                <field field_ref="ref_liq" level="10" />
+                <field field_ref="ref_ice" level="10" />
+                <field field_ref="rsu4co2" level="10" />
+                <field field_ref="rlu4co2" level="10" />
+                <field field_ref="rsucs4co2" level="10" />
+                <field field_ref="rlucs4co2" level="10" />
+                <field field_ref="rsd4co2" level="10" />
+                <field field_ref="rld4co2" level="10" />
+                <field field_ref="rsdcs4co2" level="10" />
+                <field field_ref="rldcs4co2" level="10" />
+            </field_group>
+        </file>
+    </file_group>
+</file_definition>
Index: /LMDZ5/branches/testing/DefLists/file_def_histmthNMC_lmdz.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/file_def_histmthNMC_lmdz.xml	(revision 2056)
+++ /LMDZ5/branches/testing/DefLists/file_def_histmthNMC_lmdz.xml	(revision 2056)
@@ -0,0 +1,30 @@
+<file_definition>
+    <file_group id="defile">
+        <file id="histmthNMC" name="XhistmthNMC" output_freq="5d" output_level="5" enabled=".FALSE.">
+
+            <!-- VARS 3D -->
+            <field_group operation="instant" freq_op="1ts" >
+                <field field_ref="tnondef" level="5" />
+                <field field_ref="ta" level="1" />
+                <field field_ref="zg" level="5" />
+                <field field_ref="hus" level="5" />
+                <field field_ref="hur" level="5" />
+                <field field_ref="ua" level="5" />
+                <field field_ref="va" level="5" />
+                <field field_ref="wap" level="5" />
+                <field field_ref="psbg" level="5" />
+                <field field_ref="tro3" level="5" />
+                <field field_ref="tro3_daylight" level="5" />
+                <field field_ref="uv" level="6" />
+                <!-- <field field_ref="vq" level="6" /> -->
+                <field field_ref="vT" level="6" />
+                <field field_ref="wq" level="6" />
+                <field field_ref="vphi" level="6" />
+                <field field_ref="wT" level="6" />
+                <field field_ref="uxu" level="6" />
+                <field field_ref="vxv" level="6" />
+                <field field_ref="TxT" level="6" />
+            </field_group>
+        </file>
+    </file_group>
+</file_definition>
Index: /LMDZ5/branches/testing/DefLists/file_def_histmth_lmdz.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/file_def_histmth_lmdz.xml	(revision 2056)
+++ /LMDZ5/branches/testing/DefLists/file_def_histmth_lmdz.xml	(revision 2056)
@@ -0,0 +1,517 @@
+<file_definition>
+        <file_group id="defile">
+        <file id="histmth" name="Xhistmth" output_freq="5d" output_level="10"  enabled=".FALSE.">
+
+            <!-- VARS 1D -->
+            <field_group operation="once">
+              <field field_ref="Ap" level="1" />
+              <field field_ref="Bp" level="1" />
+              <field field_ref="Alt" level="1" />
+            </field_group>
+        
+            <!-- VARS 2D -->
+            <field_group operation="average" freq_op="1ts">
+                <field field_ref="phis"         level="1" />
+                <field field_ref="aire"         level="1"   operation="once"/>
+                <field field_ref="contfracATM"  level="10"  operation="once"/>
+                <field field_ref="contfracOR"   level="10" />
+                <field field_ref="aireTER"      level="10" />
+                <field field_ref="flat"         level="5" />
+                <field field_ref="slp"          level="1" />
+                <field field_ref="tsol"         level="1" />
+                <field field_ref="t2m"          level="1" />
+                <field field_ref="t2m_min" level="1" operation="minimum" />
+                <field field_ref="t2m_max" level="1" operation="maximum" />
+                <field field_ref="t2m_ter" level="10" />
+                <field field_ref="t2m_lic" level="10" />
+                <field field_ref="t2m_oce" level="10" />
+                <field field_ref="t2m_sic" level="10" />
+                <field field_ref="wind10m" level="1" />
+                <field field_ref="wind10max" level="10" operation="maximum" />
+                <field field_ref="sicf"      level="1" />
+                <field field_ref="q2m"       level="1" />
+                <field field_ref="ustar"     level="1" />
+                <field field_ref="u10m"      level="1" />
+                <field field_ref="v10m"      level="1" />
+                <field field_ref="psol"      level="1" />
+                <field field_ref="qsurf"     level="1" />
+                <field field_ref="ustar_ter" level="10" />
+                <field field_ref="ustar_lic" level="10" />
+                <field field_ref="ustar_oce" level="10" />
+                <field field_ref="ustar_sic" level="10" />
+                <field field_ref="wstar_ter" level="10" />
+                <field field_ref="wstar_lic" level="10" />
+                <field field_ref="wstar_oce" level="10" />
+                <field field_ref="wstar_sic" level="10" />
+                <field field_ref="wstar"    level="5" />
+                <field field_ref="u10m_ter" level="10" />
+                <field field_ref="u10m_lic" level="10" />
+                <field field_ref="u10m_oce" level="10" />
+                <field field_ref="u10m_sic" level="10" />
+                <field field_ref="v10m_ter" level="10" />
+                <field field_ref="v10m_lic" level="10" />
+                <field field_ref="v10m_oce" level="10" />
+                <field field_ref="v10m_sic" level="10" />
+                <field field_ref="qsol"     level="1" />
+                <field field_ref="ndayrain" level="1" operation="instant" />
+                <field field_ref="precip"   level="1" />
+                <field field_ref="plul"     level="1" />
+                <field field_ref="pluc"     level="1" />
+                <field field_ref="snow"     level="1" />
+                <field field_ref="evap"     level="1" />
+                <field field_ref="evap_ter" level="1" />
+                <field field_ref="evap_lic" level="1" />
+                <field field_ref="evap_oce" level="1" />
+                <field field_ref="evap_sic" level="1" />
+                <field field_ref="msnow"    level="1" />
+                <field field_ref="fsnow"    level="1" />
+                <field field_ref="tops"     level="1" />
+                <field field_ref="tops0"    level="1" />
+                <field field_ref="topl"     level="1" />
+                <field field_ref="topl0"    level="1" />
+                <field field_ref="SWupTOA"  level="1" />
+                <field field_ref="SWupTOAclr"   level="1" />
+                <field field_ref="SWdnTOA"      level="1" />
+                <field field_ref="SWdnTOAclr"   level="1" />
+                <field field_ref="nettop"       level="1" />
+                <field field_ref="SWup200"      level="1" />
+                <field field_ref="SWup200clr"   level="10" />
+                <field field_ref="SWdn200"      level="1" />
+                <field field_ref="SWdn200clr"   level="10" />
+                <field field_ref="LWup200"      level="1" />
+                <field field_ref="LWup200clr"   level="1" />
+                <field field_ref="LWdn200"      level="1" />
+                <field field_ref="LWdn200clr"   level="1" />
+                <field field_ref="sols"  level="1" />
+                <field field_ref="sols0" level="1" />
+                <field field_ref="soll" level="1" />
+                <field field_ref="soll0" level="1" />
+                <field field_ref="radsol" level="1" />
+                <field field_ref="SWupSFC" level="1" />
+                <field field_ref="SWupSFCclr" level="1" />
+                <field field_ref="SWdnSFC" level="1" />
+                <field field_ref="SWdnSFCclr" level="1" />
+                <field field_ref="LWupSFC" level="1" />
+                <field field_ref="LWupSFCclr" level="1" />
+                <field field_ref="LWdnSFC" level="1" />
+                <field field_ref="LWdnSFCclr" level="1" />
+                <field field_ref="bils" level="1" />
+                <field field_ref="bils_tke" level="1" />
+                <field field_ref="bils_diss" level="1" />
+                <field field_ref="bils_ec" level="1" />
+                <field field_ref="bils_kinetic" level="1" />
+                <field field_ref="bils_enthalp" level="1" />
+                <field field_ref="bils_latent" level="1" />
+                <field field_ref="sens" level="1" />
+                <field field_ref="fder" level="1" />
+                <field field_ref="ffonte" level="1" />
+                <field field_ref="fqcalving" level="1" />
+                <field field_ref="fqfonte" level="1" />
+                <field field_ref="taux" level="1" />
+                <field field_ref="tauy" level="1" />
+                <field field_ref="taux_ter" level="1" />
+                <field field_ref="taux_lic" level="1" />
+                <field field_ref="taux_oce" level="1" />
+                <field field_ref="taux_sic" level="1" />
+                <field field_ref="tauy_ter" level="1" />
+                <field field_ref="tauy_lic" level="1" />
+                <field field_ref="tauy_oce" level="1" />
+                <field field_ref="tauy_sic" level="1" />
+                <field field_ref="pourc_ter" level="1" />
+                <field field_ref="pourc_lic" level="1" />
+                <field field_ref="pourc_oce" level="1" />
+                <field field_ref="pourc_sic" level="1" />
+                <field field_ref="fract_ter" level="1" />
+                <field field_ref="fract_lic" level="1" />
+                <field field_ref="fract_oce" level="1" />
+                <field field_ref="fract_sic" level="1" />
+                <field field_ref="tsol_ter" level="1" />
+                <field field_ref="tsol_lic" level="1" />
+                <field field_ref="tsol_oce" level="1" />
+                <field field_ref="tsol_sic" level="1" />
+                <field field_ref="evappot_ter" level="1" />
+                <field field_ref="evappot_lic" level="4" />
+                <field field_ref="evappot_oce" level="4" />
+                <field field_ref="evappot_sic" level="4" />
+                <field field_ref="sens_ter" level="1" />
+                <field field_ref="sens_lic" level="1" />
+                <field field_ref="sens_oce" level="1" />
+                <field field_ref="sens_sic" level="1" />
+                <field field_ref="lat_ter" level="1" />
+                <field field_ref="lat_lic" level="1" />
+                <field field_ref="lat_oce" level="1" />
+                <field field_ref="lat_sic" level="1" />
+                <field field_ref="flw_ter" level="1" />
+                <field field_ref="flw_lic" level="1" />
+                <field field_ref="flw_oce" level="1" />
+                <field field_ref="flw_sic" level="1" />
+                <field field_ref="fsw_ter" level="1" />
+                <field field_ref="fsw_lic" level="1" />
+                <field field_ref="fsw_oce" level="1" />
+                <field field_ref="fsw_sic" level="1" />
+                <field field_ref="wbils_ter" level="1" />
+                <field field_ref="wbils_lic" level="1" />
+                <field field_ref="wbils_oce" level="1" />
+                <field field_ref="wbils_sic" level="1" />
+                <field field_ref="wbilo_ter" level="1" />
+                <field field_ref="wbilo_lic" level="1" />
+                <field field_ref="wbilo_oce" level="1" />
+                <field field_ref="wbilo_sic" level="1" />
+                <field field_ref="cdrm" level="1" />
+                <field field_ref="cdrh" level="1" />
+                <field field_ref="cldl" level="1" />
+                <field field_ref="cldm" level="1" />
+                <field field_ref="cldh" level="1" />
+                <field field_ref="cldt" level="1" />
+                <field field_ref="cldq" level="1" />
+                <field field_ref="lwp" level="1" />
+                <field field_ref="iwp" level="1" />
+                <field field_ref="ue" level="1" />
+                <field field_ref="ve" level="1" />
+                <field field_ref="uq" level="1" />
+                <field field_ref="vq" level="1" />
+                <field field_ref="cape" level="1" />
+                <field field_ref="pbase" level="1" />
+                <field field_ref="ptop" level="1" />
+                <field field_ref="fbase" level="1" />
+                <field field_ref="plcl" level="1" />
+                <field field_ref="plfc" level="1" />
+                <field field_ref="wbeff" level="1" />
+                <field field_ref="prw" level="1" />
+                <field field_ref="s_pblh" level="1" />
+                <field field_ref="s_pblt" level="1" />
+                <field field_ref="s_lcl" level="1" />
+                <field field_ref="s_therm" level="1" />
+                <field field_ref="slab_bils_oce" level="1" />
+                <field field_ref="ale_bl" level="1" />
+                <field field_ref="alp_bl" level="1" />
+                <field field_ref="ale_wk" level="1" />
+                <field field_ref="alp_wk" level="1" />
+                <field field_ref="ale" level="1" />
+                <field field_ref="alp" level="1" />
+                <field field_ref="cin" level="1" />
+                <field field_ref="wape" level="1" />
+                <field field_ref="n2" level="1" />
+                <field field_ref="s2" level="1" />
+                <field field_ref="proba_notrig" level="1" />
+                <field field_ref="random_notrig" level="1" />
+                <field field_ref="ale_bl_stat" level="1" />
+                <field field_ref="ale_bl_trig" level="1" />
+                <field field_ref="alp_bl_det" level="1" />
+                <field field_ref="alp_bl_fluct_m" level="1" />
+                <field field_ref="alp_bl_fluct_tke" level="1" />
+                <field field_ref="alp_bl_conv" level="1" />
+                <field field_ref="alp_bl_stat" level="1" />
+
+                <field_group operation="instant">
+                    <field field_ref="u850" level="1" />
+                    <field field_ref="u700" level="1" />
+                    <field field_ref="u500" level="1" />
+                    <field field_ref="u200" level="1" />
+                    <field field_ref="u100" level="1" />
+                    <field field_ref="u50" level="1" />
+                    <field field_ref="u10" level="1" />
+                    <field field_ref="v850" level="1" />
+                    <field field_ref="v700" level="1" />
+                    <field field_ref="v500" level="1" />
+                    <field field_ref="v200" level="1" />
+                    <field field_ref="v100" level="1" />
+                    <field field_ref="v50" level="1" />
+                    <field field_ref="v10" level="1" />
+                    <field field_ref="w850" level="1" />
+                    <field field_ref="w700" level="1" />
+                    <field field_ref="w500" level="1" />
+                    <field field_ref="w200" level="1" />
+                    <field field_ref="w100" level="1" />
+                    <field field_ref="w50" level="1" />
+                    <field field_ref="w10" level="1" />
+                    <field field_ref="t850" level="1" />
+                    <field field_ref="t700" level="1" />
+                    <field field_ref="t500" level="1" />
+                    <field field_ref="t200" level="1" />
+                    <field field_ref="t100" level="1" />
+                    <field field_ref="t50" level="1" />
+                    <field field_ref="t10" level="1" />
+                    <field field_ref="q850" level="1" />
+                    <field field_ref="q700" level="1" />
+                    <field field_ref="q500" level="1" />
+                    <field field_ref="q200" level="1" />
+                    <field field_ref="q100" level="1" />
+                    <field field_ref="q50" level="1" />
+                    <field field_ref="q10" level="1" />
+                    <field field_ref="z850" level="1" />
+                    <field field_ref="z700" level="1" />
+                    <field field_ref="z500" level="1" />
+                    <field field_ref="z200" level="1" />
+                    <field field_ref="z100" level="1" />
+                    <field field_ref="z50" level="1" />
+                    <field field_ref="z10" level="1" />
+                </field_group>
+
+                <field field_ref="t_oce_sic" level="1" />
+                <field field_ref="weakinv" level="10" />
+                <field field_ref="dthmin" level="10" />
+                <field field_ref="u10_ter" level="10" />
+                <field field_ref="u10_lic" level="10" />
+                <field field_ref="u10_oce" level="10" />
+                <field field_ref="u10_sic" level="10" />
+                <field field_ref="v10_ter" level="10" />
+                <field field_ref="v10_lic" level="10" />
+                <field field_ref="v10_oce" level="10" />
+                <field field_ref="v10_sic" level="10" />
+                <field field_ref="rh2m" level="5" />
+                <field field_ref="rh2m_min" level="10" operation="minimum" />
+                <field field_ref="rh2m_max" level="10" operation="maximum" />
+                <field field_ref="qsat2m" level="10" />
+                <field field_ref="tpot" level="10" />
+                <field field_ref="tpote" level="10" />
+                <field field_ref="tke" level="4" />
+                <field field_ref="tke_ter" level="10" />
+                <field field_ref="tke_lic" level="10" />
+                <field field_ref="tke_oce" level="10" />
+                <field field_ref="tke_sic" level="10" />
+                <field field_ref="tke_max_ter" level="10" operation="maximum" />
+                <field field_ref="tke_max_lic" level="10" operation="maximum" />
+                <field field_ref="tke_max_oce" level="10" operation="maximum" />
+                <field field_ref="tke_max_sic" level="10" operation="maximum" />
+                <field field_ref="SWnetOR" level="10" />
+                <field field_ref="SWdownOR" level="10" />
+                <field field_ref="LWdownOR" level="10" />
+                <field field_ref="snowl" level="10" />
+                <field field_ref="cape_max" level="10" operation="maximum" />
+                <field field_ref="solldown" level="10" />
+                <field field_ref="dtsvdfo" level="10" />
+                <field field_ref="dtsvdft" level="10" />
+                <field field_ref="dtsvdfg" level="10" />
+                <field field_ref="dtsvdfi" level="10" />
+                <field field_ref="rugs" level="10" />
+                <field field_ref="topswad" level="2" />
+                <field field_ref="topswad0" level="2" />
+                <field field_ref="topswai" level="2" />
+                <field field_ref="solswad" level="2" />
+                <field field_ref="solswad0" level="2" />
+                <field field_ref="solswai" level="2" />
+                <field field_ref="OD550_ASBCM" level="2" />
+                <field field_ref="OD550_ASPOMM" level="2" />
+                <field field_ref="OD550_ASSO4M" level="2" />
+                <field field_ref="OD550_CSSO4M" level="2" />
+                <field field_ref="OD550_SSSSM" level="2" />
+                <field field_ref="OD550_ASSSM" level="2" />
+                <field field_ref="OD550_CSSSM" level="2" />
+                <field field_ref="OD550_CIDUSTM" level="2" />
+                <field field_ref="OD550_AIBCM" level="2" />
+                <field field_ref="OD550_AIPOMM" level="2" />
+                <field field_ref="OD550_STRAT" level="2" />
+                <field field_ref="od550aer" level="2" />
+                <field field_ref="od865aer" level="2" />
+                <field field_ref="absvisaer" level="2" />
+                <field field_ref="od550lt1aer" level="2" />
+                <field field_ref="sconcso4" level="2" />
+                <field field_ref="sconcoa" level="2" />
+                <field field_ref="sconcbc" level="2" />
+                <field field_ref="sconcss" level="2" />
+                <field field_ref="sconcdust" level="2" />
+                <field field_ref="loadso4" level="2" />
+                <field field_ref="loadoa" level="2" />
+                <field field_ref="loadbc" level="2" />
+                <field field_ref="loadss" level="2" />
+                <field field_ref="loaddust" level="2" />
+                <field field_ref="swtoaas_nat" level="4" />
+                <field field_ref="swsrfas_nat" level="4" />
+                <field field_ref="swtoacs_nat" level="4" />
+                <field field_ref="swsrfcs_nat" level="4" />
+                <field field_ref="swtoaas_ant" level="4" />
+                <field field_ref="swsrfas_ant" level="4" />
+                <field field_ref="swtoacs_ant" level="4" />
+                <field field_ref="swsrfcs_ant" level="4" />
+                <field field_ref="swtoacf_nat" level="4" />
+                <field field_ref="swsrfcf_nat" level="4" />
+                <field field_ref="swtoacf_ant" level="4" />
+                <field field_ref="swsrfcf_ant" level="4" />
+                <field field_ref="swtoacf_zero" level="4" />
+                <field field_ref="swsrfcf_zero" level="4" />
+                <field field_ref="cldncl" level="2" />
+                <field field_ref="reffclwtop" level="2" />
+                <field field_ref="cldnvi" level="2" />
+                <field field_ref="lcc" level="2" />
+                <field field_ref="wvapp" level="2" />
+                <field field_ref="ozone_daylight" level="2" />
+                <field field_ref="albe_ter" level="3" />
+                <field field_ref="albe_lic" level="3" />
+                <field field_ref="albe_oce" level="3" />
+                <field field_ref="albe_sic" level="3" />
+                <field field_ref="ages_ter" level="10" />
+                <field field_ref="ages_lic" level="3" />
+                <field field_ref="ages_oce" level="10" />
+                <field field_ref="ages_sic" level="3" />
+                <field field_ref="rugs_ter" level="3" />
+                <field field_ref="rugs_lic" level="3" />
+                <field field_ref="rugs_oce" level="3" />
+                <field field_ref="rugs_sic" level="3" />
+                <field field_ref="alb1" level="3" />
+                <field field_ref="alb2" level="3" />
+                <field field_ref="ftime_con" level="4" operation="instant" />
+                <field field_ref="wake_h" level="4" />
+                <field field_ref="wake_s" level="4" />
+                <field field_ref="plulth" level="10" />
+                <field field_ref="plulst" level="10" />
+                <field field_ref="lmaxth" level="10" />
+                <field field_ref="ftime_th" level="4" />
+                <field field_ref="f0_th" level="4" />
+                <field field_ref="zmax_th" level="4" />
+                <field field_ref="rsut4co2" level="5" />
+                <field field_ref="rlut4co2" level="5" />
+                <field field_ref="rsutcs4co2" level="5" />
+                <field field_ref="rlutcs4co2" level="5" />
+            </field_group>
+
+            <!-- VARS 3D -->
+            <field_group operation="average" freq_op="1ts" axis_ref="presnivs">
+                <field field_ref="cldtau" level="10" />
+                <field field_ref="cldemi" level="10" />
+                <field field_ref="tke_max" level="4" operation="maximum" />
+                <field field_ref="kz" level="4" />
+                <field field_ref="kz_max" level="4" operation="maximum" />
+                <field field_ref="concso4" level="2" />
+                <field field_ref="concoa" level="2" />
+                <field field_ref="concbc" level="2" />
+                <field field_ref="concss" level="2" />
+                <field field_ref="concdust" level="2" />
+                <field field_ref="ec550aer" level="2" />
+                <field field_ref="lwcon" level="2" />
+                <field field_ref="iwcon" level="2" />
+                <field field_ref="temp" level="2" />
+                <field field_ref="theta" level="2" />
+                <field field_ref="ovap" level="2" />
+                <field field_ref="ovapinit" level="2" />
+                <field field_ref="oliq" level="2" />
+                <field field_ref="geop" level="2" />
+                <field field_ref="vitu" level="2" />
+                <field field_ref="vitv" level="2" />
+                <field field_ref="vitw" level="2" />
+                <field field_ref="pres" level="2" />
+                <field field_ref="paprs" level="2" />
+                <field field_ref="mass" level="2" />
+                <field field_ref="zfull" level="2" />
+                <field field_ref="zhalf" level="2" />
+                <field field_ref="rneb" level="2" />
+                <field field_ref="rnebcon" level="2" />
+                <field field_ref="rnebls" level="2" />
+                <field field_ref="rhum" level="2" />
+                <field field_ref="ozone" level="2" />
+                <field field_ref="upwd" level="2" />
+                <field field_ref="dtphy" level="2" />
+                <field field_ref="dqphy" level="2" />
+                <field field_ref="pr_con_l" level="2" />
+                <field field_ref="pr_con_i" level="2" />
+                <field field_ref="pr_lsc_l" level="2" />
+                <field field_ref="pr_lsc_i" level="2" />
+                <field field_ref="re" level="5" />
+                <field field_ref="fl" level="5" />
+                <field field_ref="scdnc" level="2" />
+                <field field_ref="reffclws" level="2" />
+                <field field_ref="reffclwc" level="2" />
+                <field field_ref="lcc3d" level="2" />
+                <field field_ref="lcc3dcon" level="2" />
+                <field field_ref="lcc3dstra" level="2" />
+                <field field_ref="clwcon" level="4" />
+                <field field_ref="Ma" level="4" />
+                <field field_ref="dnwd" level="4" />
+                <field field_ref="dnwd0" level="4" />
+                <field field_ref="mc" level="4" />
+                <field field_ref="dtdyn" level="4" />
+                <field field_ref="dqdyn" level="4" />
+                <field field_ref="dudyn" level="4" />
+                <field field_ref="dvdyn" level="4" />
+                <field field_ref="dtcon" level="4" />
+                <field field_ref="ducon" level="4" />
+                <field field_ref="dvcon" level="4" />
+                <field field_ref="dqcon" level="4" />
+                <field field_ref="dtwak" level="4" />
+                <field field_ref="dqwak" level="4" />
+                <field field_ref="wake_deltat" level="4" />
+                <field field_ref="wake_deltaq" level="4" />
+                <field field_ref="wake_omg" level="4" />
+                <field field_ref="wdtrainA" level="4" />
+                <field field_ref="wdtrainM" level="4" />
+                <field field_ref="Vprecip" level="10" />
+                <field field_ref="ftd" level="4" />
+                <field field_ref="fqd" level="4" />
+                <field field_ref="dtlsc" level="4" />
+                <field field_ref="dtlschr" level="4" />
+                <field field_ref="dqlsc" level="4" />
+                <field field_ref="beta_prec" level="4" />
+                <field field_ref="dtvdf" level="4" />
+                <field field_ref="dtdis" level="4" />
+                <field field_ref="dqvdf" level="4" />
+                <field field_ref="dteva" level="4" />
+                <field field_ref="dqeva" level="4" />
+                <field field_ref="dqlscth" level="10" />
+                <field field_ref="dqlscst" level="10" />
+                <field field_ref="dtlscth" level="10" />
+                <field field_ref="dtlscst" level="10" />
+                <field field_ref="ptconvth" level="10" />
+                <field field_ref="ptconv" level="4" />
+                <field field_ref="ratqs" level="4" />
+                <field field_ref="dtthe" level="4" />
+                <field field_ref="f_th" level="4" />
+                <field field_ref="e_th" level="4" />
+                <field field_ref="w_th" level="4" />
+                <field field_ref="lambda_th" level="10" />
+                <field field_ref="q_th" level="4" />
+                <field field_ref="a_th" level="4" />
+                <field field_ref="d_th" level="4" />
+                <field field_ref="dqthe" level="4" />
+                <field field_ref="dtajs" level="4" />
+                <field field_ref="dqajs" level="4" />
+                <field field_ref="dtswr" level="4" />
+                <field field_ref="dtsw0" level="4" />
+                <field field_ref="dtlwr" level="4" />
+                <field field_ref="dtlw0" level="4" />
+                <field field_ref="dtec"  level="4" />
+                <field field_ref="duvdf" level="4" />
+                <field field_ref="dvvdf" level="4" />
+                <field field_ref="duoro" level="4" />
+                <field field_ref="dvoro" level="4" />
+                <field field_ref="dulif" level="4" />
+                <field field_ref="dvlif" level="4" />
+                <field field_ref="duhin" level="4" />
+                <field field_ref="dvhin" level="4" />
+                <field field_ref="dtoro" level="4" />
+                <field field_ref="dtlif" level="4" />
+                <field field_ref="dthin" level="4" />
+                <field field_ref="rsu" level="4" />
+                <field field_ref="rsd" level="4" />
+                <field field_ref="rlu" level="4" />
+                <field field_ref="rld" level="4" />
+                <field field_ref="rsucs" level="4" />
+                <field field_ref="rsdcs" level="4" />
+                <field field_ref="rlucs" level="4" />
+                <field field_ref="rldcs" level="4" />
+                <field field_ref="tnt"  level="4" />
+                <field field_ref="tntc" level="4" />
+                <field field_ref="tntr" level="4" />
+                <field field_ref="tntscpbl" level="4" />
+                <field field_ref="tnhus"    level="4" />
+                <field field_ref="tnhusc"   level="4" />
+                <field field_ref="tnhusscpbl" level="4" />
+                <field field_ref="evu" level="4" />
+                <field field_ref="h2o" level="4" />
+                <field field_ref="mcd" level="4" />
+                <field field_ref="dmc" level="4" />
+                <field field_ref="ref_liq" level="4" />
+                <field field_ref="ref_ice" level="4" />
+                <field field_ref="rsu4co2" level="5" />
+                <field field_ref="rlu4co2" level="5" />
+                <field field_ref="rsucs4co2" level="5" />
+                <field field_ref="rlucs4co2" level="5" />
+                <field field_ref="rsd4co2" level="5" />
+                <field field_ref="rld4co2" level="5" />
+                <field field_ref="rsdcs4co2" level="5" />
+                <field field_ref="rldcs4co2" level="5" />
+            </field_group>
+        </file>
+
+        </file_group>
+    </file_definition>
+   
Index: /LMDZ5/branches/testing/DefLists/file_def_histstn_lmdz.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/file_def_histstn_lmdz.xml	(revision 2056)
+++ /LMDZ5/branches/testing/DefLists/file_def_histstn_lmdz.xml	(revision 2056)
@@ -0,0 +1,515 @@
+<file_definition>
+    <file_group id="defile">
+        <file id="histstn" name="Xhiststn" output_freq="1h" output_level="5" enabled=".FALSE.">
+
+            <!-- VARS 1D -->
+            <field_group operation="once">
+              <field field_ref="Ap" level="1" />
+              <field field_ref="Bp" level="1" />
+              <field field_ref="Alt" level="1" />
+            </field_group>
+        
+            <!-- VARS 2D -->
+            <field_group operation="average" freq_op="1ts">
+                <field field_ref="phis" level="1" />
+                <field field_ref="aire" level="1" operation="once" />
+                <field field_ref="contfracATM" level="10" operation="once" />
+                <field field_ref="contfracOR" level="10" />
+                <field field_ref="aireTER" level="10" />
+                <field field_ref="flat" level="10" />
+                <field field_ref="slp" level="10" />
+                <field field_ref="tsol" level="10" />
+                <field field_ref="t2m" level="10" />
+                <field field_ref="t2m_min" level="10" operation="minimum" />
+                <field field_ref="t2m_max" level="10" operation="maximum" />
+                <field field_ref="t2m_ter" level="10" />
+                <field field_ref="t2m_lic" level="10" />
+                <field field_ref="t2m_oce" level="10" />
+                <field field_ref="t2m_sic" level="10" />
+                <field field_ref="wind10m" level="10" />
+                <field field_ref="wind10max" level="10" />
+                <field field_ref="sicf" level="10" />
+                <field field_ref="q2m" level="10" />
+                <field field_ref="ustar" level="10" />
+                <field field_ref="u10m" level="10" />
+                <field field_ref="v10m" level="10" />
+                <field field_ref="psol" level="10" />
+                <field field_ref="qsurf" level="10" />
+                <field field_ref="ustar_ter" level="10" />
+                <field field_ref="ustar_lic" level="10" />
+                <field field_ref="ustar_oce" level="10" />
+                <field field_ref="ustar_sic" level="10" />
+                <field field_ref="wstar_ter" level="10" />
+                <field field_ref="wstar_lic" level="10" />
+                <field field_ref="wstar_oce" level="10" />
+                <field field_ref="wstar_sic" level="10" />
+                <field field_ref="wstar" level="10" />
+                <field field_ref="u10m_ter" level="10" />
+                <field field_ref="u10m_lic" level="10" />
+                <field field_ref="u10m_oce" level="10" />
+                <field field_ref="u10m_sic" level="10" />
+                <field field_ref="v10m_ter" level="10" />
+                <field field_ref="v10m_lic" level="10" />
+                <field field_ref="v10m_oce" level="10" />
+                <field field_ref="v10m_sic" level="10" />
+                <field field_ref="qsol" level="10" />
+                <field field_ref="ndayrain" level="10" operation="instant" />
+                <field field_ref="precip" level="10" />
+                <field field_ref="plul" level="10" />
+                <field field_ref="pluc" level="10" />
+                <field field_ref="snow" level="10" />
+                <field field_ref="evap" level="10" />
+                <field field_ref="evap_ter" level="10" />
+                <field field_ref="evap_lic" level="10" />
+                <field field_ref="evap_oce" level="10" />
+                <field field_ref="evap_sic" level="10" />
+                <field field_ref="msnow" level="10" />
+                <field field_ref="fsnow" level="10" />
+                <field field_ref="tops" level="10" />
+                <field field_ref="tops0" level="10" />
+                <field field_ref="topl" level="10" />
+                <field field_ref="topl0" level="10" />
+                <field field_ref="SWupTOA" level="10" />
+                <field field_ref="SWupTOAclr" level="10" />
+                <field field_ref="SWdnTOA" level="10" />
+                <field field_ref="SWdnTOAclr" level="10" />
+                <field field_ref="nettop" level="10" />
+                <field field_ref="SWup200" level="10" />
+                <field field_ref="SWup200clr" level="10" />
+                <field field_ref="SWdn200" level="10" />
+                <field field_ref="SWdn200clr" level="10" />
+                <field field_ref="LWup200" level="10" />
+                <field field_ref="LWup200clr" level="10" />
+                <field field_ref="LWdn200" level="10" />
+                <field field_ref="LWdn200clr" level="10" />
+                <field field_ref="sols" level="10" />
+                <field field_ref="sols0" level="10" />
+                <field field_ref="soll" level="10" />
+                <field field_ref="soll0" level="10" />
+                <field field_ref="radsol" level="10" />
+                <field field_ref="SWupSFC" level="10" />
+                <field field_ref="SWupSFCclr" level="10" />
+                <field field_ref="SWdnSFC" level="10" />
+                <field field_ref="SWdnSFCclr" level="10" />
+                <field field_ref="LWupSFC" level="10" />
+                <field field_ref="LWupSFCclr" level="10" />
+                <field field_ref="LWdnSFC" level="10" />
+                <field field_ref="LWdnSFCclr" level="10" />
+                <field field_ref="bils" level="10" />
+                <field field_ref="bils_tke" level="10" />
+                <field field_ref="bils_diss" level="10" />
+                <field field_ref="bils_ec" level="10" />
+                <field field_ref="bils_kinetic" level="10" />
+                <field field_ref="bils_enthalp" level="10" />
+                <field field_ref="bils_latent" level="10" />
+                <field field_ref="sens" level="10" />
+                <field field_ref="fder" level="10" />
+                <field field_ref="ffonte" level="10" />
+                <field field_ref="fqcalving" level="10" />
+                <field field_ref="fqfonte" level="10" />
+                <field field_ref="taux" level="10" />
+                <field field_ref="tauy" level="10" />
+                <field field_ref="taux_ter" level="10" />
+                <field field_ref="taux_lic" level="10" />
+                <field field_ref="taux_oce" level="10" />
+                <field field_ref="taux_sic" level="10" />
+                <field field_ref="tauy_ter" level="10" />
+                <field field_ref="tauy_lic" level="10" />
+                <field field_ref="tauy_oce" level="10" />
+                <field field_ref="tauy_sic" level="10" />
+                <field field_ref="pourc_ter" level="10" />
+                <field field_ref="pourc_lic" level="10" />
+                <field field_ref="pourc_oce" level="10" />
+                <field field_ref="pourc_sic" level="10" />
+                <field field_ref="fract_ter" level="10" />
+                <field field_ref="fract_lic" level="10" />
+                <field field_ref="fract_oce" level="10" />
+                <field field_ref="fract_sic" level="10" />
+                <field field_ref="tsol_ter" level="10" />
+                <field field_ref="tsol_lic" level="10" />
+                <field field_ref="tsol_oce" level="10" />
+                <field field_ref="tsol_sic" level="10" />
+                <field field_ref="evappot_ter" level="10" />
+                <field field_ref="evappot_lic" level="10" />
+                <field field_ref="evappot_oce" level="10" />
+                <field field_ref="evappot_sic" level="10" />
+                <field field_ref="sens_ter" level="10" />
+                <field field_ref="sens_lic" level="10" />
+                <field field_ref="sens_oce" level="10" />
+                <field field_ref="sens_sic" level="10" />
+                <field field_ref="lat_ter" level="10" />
+                <field field_ref="lat_lic" level="10" />
+                <field field_ref="lat_oce" level="10" />
+                <field field_ref="lat_sic" level="10" />
+                <field field_ref="flw_ter" level="10" />
+                <field field_ref="flw_lic" level="10" />
+                <field field_ref="flw_oce" level="10" />
+                <field field_ref="flw_sic" level="10" />
+                <field field_ref="fsw_ter" level="10" />
+                <field field_ref="fsw_lic" level="10" />
+                <field field_ref="fsw_oce" level="10" />
+                <field field_ref="fsw_sic" level="10" />
+                <field field_ref="wbils_ter" level="10" />
+                <field field_ref="wbils_lic" level="10" />
+                <field field_ref="wbils_oce" level="10" />
+                <field field_ref="wbils_sic" level="10" />
+                <field field_ref="wbilo_ter" level="10" />
+                <field field_ref="wbilo_lic" level="10" />
+                <field field_ref="wbilo_oce" level="10" />
+                <field field_ref="wbilo_sic" level="10" />
+                <field field_ref="cdrm" level="10" />
+                <field field_ref="cdrh" level="10" />
+                <field field_ref="cldl" level="10" />
+                <field field_ref="cldm" level="10" />
+                <field field_ref="cldh" level="10" />
+                <field field_ref="cldt" level="10" />
+                <field field_ref="cldq" level="10" />
+                <field field_ref="lwp" level="10" />
+                <field field_ref="iwp" level="10" />
+                <field field_ref="ue" level="10" />
+                <field field_ref="ve" level="10" />
+                <field field_ref="uq" level="10" />
+                <field field_ref="vq" level="10" />
+                <field field_ref="cape" level="10" />
+                <field field_ref="pbase" level="10" />
+                <field field_ref="ptop" level="10" />
+                <field field_ref="fbase" level="10" />
+                <field field_ref="plcl" level="10" />
+                <field field_ref="plfc" level="10" />
+                <field field_ref="wbeff" level="10" />
+                <field field_ref="prw" level="10" />
+                <field field_ref="s_pblh" level="10" />
+                <field field_ref="s_pblt" level="10" />
+                <field field_ref="s_lcl" level="10" />
+                <field field_ref="s_therm" level="10" />
+                <field field_ref="slab_bils_oce" level="10" />
+                <field field_ref="ale_bl" level="10" />
+                <field field_ref="alp_bl" level="10" />
+                <field field_ref="ale_wk" level="10" />
+                <field field_ref="alp_wk" level="10" />
+                <field field_ref="ale" level="10" />
+                <field field_ref="alp" level="10" />
+                <field field_ref="cin" level="10" />
+                <field field_ref="wape" level="10" />
+                <field field_ref="n2" level="10" />
+                <field field_ref="s2" level="10" />
+                <field field_ref="proba_notrig" level="10" />
+                <field field_ref="random_notrig" level="10" />
+                <field field_ref="ale_bl_stat" level="10" />
+                <field field_ref="ale_bl_trig" level="10" />
+                <field field_ref="alp_bl_det" level="10" />
+                <field field_ref="alp_bl_fluct_m" level="10" />
+                <field field_ref="alp_bl_fluct_tke" level="10" />
+                <field field_ref="alp_bl_conv" level="10" />
+                <field field_ref="alp_bl_stat" level="10" />
+
+                <field_group operation="instant">
+                    <field field_ref="u850" level="10" />
+                    <field field_ref="u700" level="10" />
+                    <field field_ref="u500" level="10" />
+                    <field field_ref="u200" level="10" />
+                    <field field_ref="u100" level="10" />
+                    <field field_ref="u50" level="10" />
+                    <field field_ref="u10" level="10" />
+                    <field field_ref="v850" level="10" />
+                    <field field_ref="v700" level="10" />
+                    <field field_ref="v500" level="10" />
+                    <field field_ref="v200" level="10" />
+                    <field field_ref="v100" level="10" />
+                    <field field_ref="v50" level="10" />
+                    <field field_ref="v10" level="10" />
+                    <field field_ref="w850" level="10" />
+                    <field field_ref="w700" level="10" />
+                    <field field_ref="w500" level="10" />
+                    <field field_ref="w200" level="10" />
+                    <field field_ref="w100" level="10" />
+                    <field field_ref="w50" level="10" />
+                    <field field_ref="w10" level="10" />
+                    <field field_ref="t850" level="10" />
+                    <field field_ref="t700" level="10" />
+                    <field field_ref="t500" level="10" />
+                    <field field_ref="t200" level="10" />
+                    <field field_ref="t100" level="10" />
+                    <field field_ref="t50" level="10" />
+                    <field field_ref="t10" level="10" />
+                    <field field_ref="q850" level="10" />
+                    <field field_ref="q700" level="10" />
+                    <field field_ref="q500" level="10" />
+                    <field field_ref="q200" level="10" />
+                    <field field_ref="q100" level="10" />
+                    <field field_ref="q50" level="10" />
+                    <field field_ref="q10" level="10" />
+                    <field field_ref="z850" level="10" />
+                    <field field_ref="z700" level="10" />
+                    <field field_ref="z500" level="10" />
+                    <field field_ref="z200" level="10" />
+                    <field field_ref="z100" level="10" />
+                    <field field_ref="z50" level="10" />
+                    <field field_ref="z10" level="10" />
+                </field_group>
+
+                <field field_ref="t_oce_sic" level="10" />
+                <field field_ref="weakinv" level="10" />
+                <field field_ref="dthmin" level="10" />
+                <field field_ref="u10_ter" level="10" />
+                <field field_ref="u10_lic" level="10" />
+                <field field_ref="u10_oce" level="10" />
+                <field field_ref="u10_sic" level="10" />
+                <field field_ref="v10_ter" level="10" />
+                <field field_ref="v10_lic" level="10" />
+                <field field_ref="v10_oce" level="10" />
+                <field field_ref="v10_sic" level="10" />
+                <field field_ref="rh2m" level="10" />
+                <field field_ref="rh2m_min" level="10" operation="minimum" />
+                <field field_ref="rh2m_max" level="10" operation="maximum" />
+                <field field_ref="qsat2m" level="10" />
+                <field field_ref="tpot" level="10" />
+                <field field_ref="tpote" level="10" />
+                <field field_ref="tke" level="10" />
+                <field field_ref="tke_ter" level="10" />
+                <field field_ref="tke_lic" level="10" />
+                <field field_ref="tke_oce" level="10" />
+                <field field_ref="tke_sic" level="10" />
+                <field field_ref="tke_max_ter" level="10" operation="maximum" />
+                <field field_ref="tke_max_lic" level="10" operation="maximum" />
+                <field field_ref="tke_max_oce" level="10" operation="maximum" />
+                <field field_ref="tke_max_sic" level="10" operation="maximum" />
+                <field field_ref="SWnetOR" level="10" />
+                <field field_ref="SWdownOR" level="10" />
+                <field field_ref="LWdownOR" level="10" />
+                <field field_ref="snowl" level="10" />
+                <field field_ref="cape_max" level="10" operation="maximum" />
+                <field field_ref="solldown" level="10" />
+                <field field_ref="dtsvdfo" level="10" />
+                <field field_ref="dtsvdft" level="10" />
+                <field field_ref="dtsvdfg" level="10" />
+                <field field_ref="dtsvdfi" level="10" />
+                <field field_ref="rugs" level="10" />
+                <field field_ref="topswad" level="10" />
+                <field field_ref="topswad0" level="10" />
+                <field field_ref="topswai" level="10" />
+                <field field_ref="solswad" level="10" />
+                <field field_ref="solswad0" level="10" />
+                <field field_ref="solswai" level="10" />
+                <field field_ref="OD550_ASBCM" level="10" />
+                <field field_ref="OD550_ASPOMM" level="10" />
+                <field field_ref="OD550_ASSO4M" level="10" />
+                <field field_ref="OD550_CSSO4M" level="10" />
+                <field field_ref="OD550_SSSSM" level="10" />
+                <field field_ref="OD550_ASSSM" level="10" />
+                <field field_ref="OD550_CSSSM" level="10" />
+                <field field_ref="OD550_CIDUSTM" level="10" />
+                <field field_ref="OD550_AIBCM" level="10" />
+                <field field_ref="OD550_AIPOMM" level="10" />
+                <field field_ref="OD550_STRAT" level="10" />
+                <field field_ref="od550aer" level="10" />
+                <field field_ref="od865aer" level="10" />
+                <field field_ref="absvisaer" level="10" />
+                <field field_ref="od550lt1aer" level="10" />
+                <field field_ref="sconcso4" level="10" />
+                <field field_ref="sconcoa" level="10" />
+                <field field_ref="sconcbc" level="10" />
+                <field field_ref="sconcss" level="10" />
+                <field field_ref="sconcdust" level="10" />
+                <field field_ref="loadso4" level="10" />
+                <field field_ref="loadoa" level="10" />
+                <field field_ref="loadbc" level="10" />
+                <field field_ref="loadss" level="10" />
+                <field field_ref="loaddust" level="10" />
+                <field field_ref="swtoaas_nat" level="10" />
+                <field field_ref="swsrfas_nat" level="10" />
+                <field field_ref="swtoacs_nat" level="10" />
+                <field field_ref="swsrfcs_nat" level="10" />
+                <field field_ref="swtoaas_ant" level="10" />
+                <field field_ref="swsrfas_ant" level="10" />
+                <field field_ref="swtoacs_ant" level="10" />
+                <field field_ref="swsrfcs_ant" level="10" />
+                <field field_ref="swtoacf_nat" level="10" />
+                <field field_ref="swsrfcf_nat" level="10" />
+                <field field_ref="swtoacf_ant" level="10" />
+                <field field_ref="swsrfcf_ant" level="10" />
+                <field field_ref="swtoacf_zero" level="10" />
+                <field field_ref="swsrfcf_zero" level="10" />
+                <field field_ref="cldncl" level="10" />
+                <field field_ref="reffclwtop" level="10" />
+                <field field_ref="cldnvi" level="10" />
+                <field field_ref="lcc" level="10" />
+                <field field_ref="wvapp" level="10" />
+                <field field_ref="ozone_daylight" level="10" />
+                <field field_ref="albe_ter" level="10" />
+                <field field_ref="albe_lic" level="10" />
+                <field field_ref="albe_oce" level="10" />
+                <field field_ref="albe_sic" level="10" />
+                <field field_ref="ages_ter" level="10" />
+                <field field_ref="ages_lic" level="10" />
+                <field field_ref="ages_oce" level="10" />
+                <field field_ref="ages_sic" level="10" />
+                <field field_ref="rugs_ter" level="10" />
+                <field field_ref="rugs_lic" level="10" />
+                <field field_ref="rugs_oce" level="10" />
+                <field field_ref="rugs_sic" level="10" />
+                <field field_ref="alb1" level="10" />
+                <field field_ref="alb2" level="10" />
+                <field field_ref="ftime_con" level="10" operation="instant" />
+                <field field_ref="wake_h" level="10" />
+                <field field_ref="wake_s" level="10" />
+                <field field_ref="plulth" level="10" />
+                <field field_ref="plulst" level="10" />
+                <field field_ref="lmaxth" level="10" />
+                <field field_ref="ftime_th" level="10" />
+                <field field_ref="f0_th" level="10" />
+                <field field_ref="zmax_th" level="10" />
+                <field field_ref="rsut4co2" level="10" />
+                <field field_ref="rlut4co2" level="10" />
+                <field field_ref="rsutcs4co2" level="10" />
+                <field field_ref="rlutcs4co2" level="10" />
+            </field_group>
+
+            <!-- VARS 3D -->
+            <field_group operation="average" freq_op="1ts" axis_ref="presnivs">
+                <field field_ref="cldtau" level="10" />
+                <field field_ref="cldemi" level="10" />
+                <field field_ref="tke_max" level="10" operation="maximum" />
+                <field field_ref="kz" level="10" />
+                <field field_ref="kz_max" level="10" operation="maximum" />
+                <field field_ref="concso4" level="10" />
+                <field field_ref="concoa" level="10" />
+                <field field_ref="concbc" level="10" />
+                <field field_ref="concss" level="10" />
+                <field field_ref="concdust" level="10" />
+                <field field_ref="ec550aer" level="10" />
+                <field field_ref="lwcon" level="10" />
+                <field field_ref="iwcon" level="10" />
+                <field field_ref="temp" level="10" />
+                <field field_ref="theta" level="10" />
+                <field field_ref="ovap" level="10" />
+                <field field_ref="ovapinit" level="10" />
+                <field field_ref="oliq" level="10" />
+                <field field_ref="geop" level="10" />
+                <field field_ref="vitu" level="10" />
+                <field field_ref="vitv" level="10" />
+                <field field_ref="vitw" level="10" />
+                <field field_ref="pres" level="10" />
+                <field field_ref="paprs" level="10" />
+                <field field_ref="mass" level="10" />
+                <field field_ref="zfull" level="10" />
+                <field field_ref="zhalf" level="10" />
+                <field field_ref="rneb" level="10" />
+                <field field_ref="rnebcon" level="10" />
+                <field field_ref="rnebls" level="10" />
+                <field field_ref="rhum" level="10" />
+                <field field_ref="ozone" level="10" />
+                <field field_ref="upwd" level="10" />
+                <field field_ref="dtphy" level="10" />
+                <field field_ref="dqphy" level="10" />
+                <field field_ref="pr_con_l" level="10" />
+                <field field_ref="pr_con_i" level="10" />
+                <field field_ref="pr_lsc_l" level="10" />
+                <field field_ref="pr_lsc_i" level="10" />
+                <field field_ref="re" level="10" />
+                <field field_ref="fl" level="10" />
+                <field field_ref="scdnc" level="10" />
+                <field field_ref="reffclws" level="10" />
+                <field field_ref="reffclwc" level="10" />
+                <field field_ref="lcc3d" level="10" />
+                <field field_ref="lcc3dcon" level="10" />
+                <field field_ref="lcc3dstra" level="10" />
+                <field field_ref="clwcon" level="10" />
+                <field field_ref="Ma" level="10" />
+                <field field_ref="dnwd" level="10" />
+                <field field_ref="dnwd0" level="10" />
+                <field field_ref="mc" level="10" />
+                <field field_ref="dtdyn" level="10" />
+                <field field_ref="dqdyn" level="10" />
+                <field field_ref="dudyn" level="10" />
+                <field field_ref="dvdyn" level="10" />
+                <field field_ref="dtcon" level="10" />
+                <field field_ref="ducon" level="10" />
+                <field field_ref="dvcon" level="10" />
+                <field field_ref="dqcon" level="10" />
+                <field field_ref="dtwak" level="10" />
+                <field field_ref="dqwak" level="10" />
+                <field field_ref="wake_deltat" level="10" />
+                <field field_ref="wake_deltaq" level="10" />
+                <field field_ref="wake_omg" level="10" />
+                <field field_ref="wdtrainA" level="10" />
+                <field field_ref="wdtrainM" level="10" />
+                <field field_ref="Vprecip" level="10" />
+                <field field_ref="ftd" level="10" />
+                <field field_ref="fqd" level="10" />
+                <field field_ref="dtlsc" level="10" />
+                <field field_ref="dtlschr" level="10" />
+                <field field_ref="dqlsc" level="10" />
+                <field field_ref="beta_prec" level="10" />
+                <field field_ref="dtvdf" level="10" />
+                <field field_ref="dtdis" level="10" />
+                <field field_ref="dqvdf" level="10" />
+                <field field_ref="dteva" level="10" />
+                <field field_ref="dqeva" level="10" />
+                <field field_ref="dqlscth" level="10" />
+                <field field_ref="dqlscst" level="10" />
+                <field field_ref="dtlscth" level="10" />
+                <field field_ref="dtlscst" level="10" />
+                <field field_ref="ptconvth" level="10" />
+                <field field_ref="ptconv" level="10" />
+                <field field_ref="ratqs" level="10" />
+                <field field_ref="dtthe" level="10" />
+                <field field_ref="f_th" level="10" />
+                <field field_ref="e_th" level="10" />
+                <field field_ref="w_th" level="10" />
+                <field field_ref="lambda_th" level="10" />
+                <field field_ref="q_th" level="10" />
+                <field field_ref="a_th" level="10" />
+                <field field_ref="d_th" level="10" />
+                <field field_ref="dqthe" level="10" />
+                <field field_ref="dtajs" level="10" />
+                <field field_ref="dqajs" level="10" />
+                <field field_ref="dtswr" level="10" />
+                <field field_ref="dtsw0" level="10" />
+                <field field_ref="dtlwr" level="10" />
+                <field field_ref="dtlw0" level="10" />
+                <field field_ref="dtec" level="10" />
+                <field field_ref="duvdf" level="10" />
+                <field field_ref="dvvdf" level="10" />
+                <field field_ref="duoro" level="10" />
+                <field field_ref="dvoro" level="10" />
+                <field field_ref="dulif" level="10" />
+                <field field_ref="dvlif" level="10" />
+                <field field_ref="duhin" level="10" />
+                <field field_ref="dvhin" level="10" />
+                <field field_ref="dtoro" level="10" />
+                <field field_ref="dtlif" level="10" />
+                <field field_ref="dthin" level="10" />
+                <field field_ref="rsu" level="10" />
+                <field field_ref="rsd" level="10" />
+                <field field_ref="rlu" level="10" />
+                <field field_ref="rld" level="10" />
+                <field field_ref="rsucs" level="10" />
+                <field field_ref="rsdcs" level="10" />
+                <field field_ref="rlucs" level="10" />
+                <field field_ref="rldcs" level="10" />
+                <field field_ref="tnt" level="10" />
+                <field field_ref="tntc" level="10" />
+                <field field_ref="tntr" level="10" />
+                <field field_ref="tntscpbl" level="10" />
+                <field field_ref="tnhus" level="10" />
+                <field field_ref="tnhusc" level="10" />
+                <field field_ref="tnhusscpbl" level="10" />
+                <field field_ref="evu" level="10" />
+                <field field_ref="h2o" level="10" />
+                <field field_ref="mcd" level="10" />
+                <field field_ref="dmc" level="10" />
+                <field field_ref="ref_liq" level="10" />
+                <field field_ref="ref_ice" level="10" />
+                <field field_ref="rsu4co2" level="10" />
+                <field field_ref="rlu4co2" level="10" />
+                <field field_ref="rsucs4co2" level="10" />
+                <field field_ref="rlucs4co2" level="10" />
+                <field field_ref="rsd4co2" level="10" />
+                <field field_ref="rld4co2" level="10" />
+                <field field_ref="rsdcs4co2" level="10" />
+                <field field_ref="rldcs4co2" level="10" />
+            </field_group>
+        </file>
+    </file_group>
+</file_definition>
Index: /LMDZ5/branches/testing/DefLists/iodef.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/iodef.xml	(revision 2055)
+++ /LMDZ5/branches/testing/DefLists/iodef.xml	(revision 2056)
@@ -1,39 +1,4 @@
 <?xml version="1.0"?>
 <simulation> 
-	<context id="LMDZ" calendar_type="D360" start_date="1980-01-01 00:00:00">
-
-		<!-- Définition des variables -->
-		<field_definition src="./iodef_fields.xml"/> 
-   		
-		<!-- Définition des fichiers de sortie
-                Chaque fichier contient la liste de toutes les variables 
-                et leur niveau de sortie pour ce fichier, afin de coller 
-                à l'utilisation des niveaux de sortie que fait LMDZ. -->
- 
-		<file_definition src="./iodef_file_histday.xml"/>
-		<file_definition src="./iodef_file_histhf.xml"/>
-		<file_definition src="./iodef_file_histins.xml"/>
-		<file_definition src="./iodef_file_histLES.xml"/>
-		<file_definition src="./iodef_file_histmth.xml"/> 
-		<file_definition src="./iodef_file_histstn.xml"/>
-
-		<!-- Définition des domaines et groupes de domaines -->
-	 	<domain_definition>
-	 		<domain id="dom_glo" data_dim="2" />
-		</domain_definition>
-		
-		<!-- Définition des groupes d'axes verticaux
-                (LMDZ va ensuite déclarer dans chaque groupe un axe différent par fichier) -->
-		<axis_definition>
-			<axis_group id="presnivs" standard_name="Vertical levels" unit="Pa">
-			</axis_group>
-			<axis_group id="Ahyb" standard_name="Ahyb comp of Hyb Cord" unit="Pa">
-			</axis_group>
-			<axis_group id="Bhyb" standard_name="Bhyb comp of Hyb Cord" unit="">
-			</axis_group>
-			<axis_group id="Alt" standard_name="Height approx for scale heigh of 8km at levels" unit="Km">
-			</axis_group>
-		</axis_definition>
-	</context>
 	
 	<context  id="xios">
@@ -50,3 +15,8 @@
 		</variable_definition>
 	</context>
+	
+
+	<context id="LMDZ" src="./context_lmdz.xml"/>
+
+
 </simulation>
Index: /LMDZ5/branches/testing/DefLists/iodef_dev.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/iodef_dev.xml	(revision 2055)
+++ /LMDZ5/branches/testing/DefLists/iodef_dev.xml	(revision 2056)
@@ -2,55 +2,105 @@
 <simulation> 
     <context id="LMDZ" calendar_type="D360" start_date="1980-01-01 00:00:00">
-        <!-- Définition des variables -->
-        <field_definition prec="4" operation="average" freq_op="1ts" enabled=".TRUE.">
+        <!-- Definition of model variables -->
+        <field_definition prec="4" 
+                          freq_op="1ts"
+                          enabled=".TRUE.">
+            
+            <!-- 2D variables -->
             <field_group id="fields_2D" domain_ref="dom_glo">
-                <field id="u"           long_name="Eastward Zonal Wind"                 unit="m/s" />
-                <field id="v"           long_name="Northward Meridional Wind"           unit="m/s" />
-                <field id="ps"          long_name="Surface Pressure"                    unit="m/s" />
+                <field id="ps"
+                       long_name="Surface Pressure" 
+                       unit="m/s" />
             </field_group>
 
-            <field_group id="fields_3D" domain_ref="dom_glo">
-                <field id="temperature" long_name="Atmospheric temperature"             unit="K" />
+            <!-- 3D variables -->
+            <field_group id="fields_3D"
+                         domain_ref="dom_glo">
+                <field id="temperature"
+                       long_name="Atmospheric temperature"
+                       unit="K" />
+                <field id="temp_newton"
+                       long_name="Relaxation temperature"
+                       unit="K" />
+                <field id="u"
+                       long_name="Eastward Zonal Wind"
+                       unit="m/s" />
+                <field id="v" 
+                       long_name="Northward Meridional Wind" 
+                       unit="m/s" />
             </field_group>
         </field_definition>
 
-        <!-- Définition des fichiers de sortie -->
+        <!-- Définition of output files -->
 
         <file_definition>
-            <file_group id="defile">
-                <file id="histins" name="Xhistins" output_freq="1ts" enabled=".TRUE.">
+            <!-- <file_group id="defile"> -->
+                <file id="histins"
+                      name="Xhistins"
+                      output_freq="12ts" 
+                      enabled=".TRUE."> <!-- NB: output_freq in physics ts-->
+                    
                     <!-- VARS 2D -->
-                    <field_group operation="instant" freq_op="1ts">
+                    <field_group operation="instant"
+                                 freq_op="1ts">
                         <field field_ref="ps" />
                     </field_group>
+                    <!-- <field_group field_group_ref="fields_2D"
+                                 operation="instant" /> doesn't work ?!? -->
 
                     <!-- VARS 3D -->
-                    <field_group operation="instant" freq_op="1ts" axis_ref="presnivs_histins">
+                    <field_group operation="instant"
+                                 freq_op="1ts"
+                                 axis_ref="presnivs">
+                        <field field_ref="temperature" />
+                        <field field_ref="temp_newton" operation="once" />
+                        <field field_ref="u" />
+                        <field field_ref="v" />
+                    </field_group>
+                    <!-- <field_group field_group_ref="fields_3D"
+                                 operation="instant" /> doesn't work ?!? -->
+                </file>
+
+                <file id="diurnalave"
+                      name="Xdiurnalave"
+                      output_freq="1d"
+                      enabled=".true.">
+                    <!-- VARS 2D -->
+                    <field_group operation="average"
+                                 freq_op="1ts">
+                        <field field_ref="ps" />
+                    </field_group>
+                    <!-- VARS 3D -->
+                    <field_group operation="average"
+                                 freq_op="1ts"
+                                 axis_ref="presnivs">
                         <field field_ref="temperature" />
                         <field field_ref="u" />
                         <field field_ref="v" />
-                    </field_group>
+                    </field_group>                     
                 </file>
-            </file_group>
+            <!-- </file_group> -->
         </file_definition>
 
 
-
-
-        <!-- Définition des domaines et groupes de domaines -->
+        <!-- Definition of domains and groups of domains -->
         <domain_definition>
             <domain id="dom_glo" data_dim="2" />
         </domain_definition>
         
-        <!-- Définition des axes verticaux -->
+        <!-- Definition of vertical axes 
+             NB: these must be defined and set in code via
+             wxios_add_vaxis -->
         <axis_definition>
-            <axis_group id="presnivs" standard_name="Vertical levels" unit="Pa">
+            <!--
+            <axis_group id="presnivs" 
+                        standard_name="Pseudo-pressure of model vertical levels" 
+                        unit="Pa">
             </axis_group>
-            <axis_group id="Ahyb" standard_name="Ahyb comp of Hyb Cord" unit="Pa">
-            </axis_group>
-            <axis_group id="Bhyb" standard_name="Bhyb comp of Hyb Cord" unit="">
-            </axis_group>
-            <axis_group id="Alt" standard_name="Height approx for scale heigh of 8km at levels" unit="Km">
-            </axis_group>
+            -->
+            <axis id="presnivs" 
+                        standard_name="Pseudo-pressure of model vertical levels" 
+                        unit="Pa">
+            </axis>
         </axis_definition>
     </context>
@@ -65,5 +115,5 @@
             <variable_group id="parameters" >
                 <variable id="using_server" type="boolean">true</variable>
-                <variable id="info_level" type="int">100</variable>
+                <variable id="info_level" type="int">10</variable>
             </variable_group>
         </variable_definition>
Index: DZ5/branches/testing/DefLists/iodef_fields.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/iodef_fields.xml	(revision 2055)
+++ 	(revision )
@@ -1,500 +1,0 @@
-<field_definition level="1" prec="4" operation="average" freq_op="1ts" enabled=".FALSE.">
-    <field_group id="fields_2D" domain_ref="dom_glo">
-        <field id="Ap"      long_name="-"    unit="-" />
-        <field id="Bp"      long_name="-"    unit="-" />
-        <field id="Alt"     long_name="-"    unit="-" />
-        <field id="phis"    long_name="Surface geop.height"     unit="m2/s2" />
-        <field id="aire"    long_name="Grid area"               unit="-"    />
-        <field id="contfracATM"     long_name="% sfce ter+lic"  unit="-"    />
-        <field id="contfracOR"      long_name="% sfce terre OR" unit="-" />
-        <field id="aireTER"         long_name="Grid area CONT"  unit="-" />
-        <field id="flat"    long_name="Latent heat flux"        unit="W/m2" />
-        <field id="slp"     long_name="Sea Level Pressure"      unit="Pa" />
-        <field id="tsol"    long_name="Surface Temperature"     unit="K" />
-        <field id="t2m"        long_name="Temperature 2m" unit="K" />
-        <field id="t2m_min"    long_name="Temp 2m min"    unit="K" />
-        <field id="t2m_max"    long_name="Temp 2m max"    unit="K" />
-        <field id="t2m_ter"    long_name="Temp 2m ter"    unit="K" />
-        <field id="t2m_lic"    long_name="Temp 2m lic"    unit="K" />
-        <field id="t2m_oce"    long_name="Temp 2m oce"    unit="K" />
-        <field id="t2m_sic"    long_name="Temp 2m sic"    unit="K" />
-        <field id="wind10m"    long_name="10-m wind speed"      unit="m/s" />
-        <field id="wind10max"  long_name="10m wind speed max"   unit="m/s" />
-        <field id="sicf"    long_name="Sea-ice fraction"        unit="-" />
-        <field id="q2m"     long_name="Specific humidity 2m"    unit="kg/kg" />
-        <field id="ustar"   long_name="Friction velocity"       unit="m/s" />
-        <field id="u10m"    long_name="Vent zonal 10m"          unit="m/s" />
-        <field id="v10m"    long_name="Vent meridien 10m"       unit="m/s" />
-        <field id="psol"    long_name="Surface Pressure"        unit="Pa" />
-        <field id="qsurf"   long_name="Surface Air humidity"    unit="kg/kg" />
-        <field id="ustar_ter"    long_name="Friction velocity ter"    unit="m/s" />
-        <field id="ustar_lic"    long_name="Friction velocity lic"    unit="m/s" />
-        <field id="ustar_oce"    long_name="Friction velocity oce"    unit="m/s" />
-        <field id="ustar_sic"    long_name="Friction velocity sic"    unit="m/s" />
-        <field id="wstar_ter"    long_name="Friction velocity ter"    unit="m/s" />
-        <field id="wstar_lic"    long_name="Friction velocity lic"    unit="m/s" />
-        <field id="wstar_oce"    long_name="Friction velocity oce"    unit="m/s" />
-        <field id="wstar_sic"    long_name="Friction velocity sic"    unit="m/s" />
-        <field id="wstar"       long_name="w* convective velocity "    unit="m/s" />
-        <field id="u10m_ter"    long_name="Vent Zonal 10m ter"    unit="m/s" />
-        <field id="u10m_lic"    long_name="Vent Zonal 10m lic"    unit="m/s" />
-        <field id="u10m_oce"    long_name="Vent Zonal 10m oce"    unit="m/s" />
-        <field id="u10m_sic"    long_name="Vent Zonal 10m sic"    unit="m/s" />
-        <field id="v10m_ter"    long_name="Vent meredien 10m ter"    unit="m/s" />
-        <field id="v10m_lic"    long_name="Vent meredien 10m lic"    unit="m/s" />
-        <field id="v10m_oce"    long_name="Vent meredien 10m oce"    unit="m/s" />
-        <field id="v10m_sic"    long_name="Vent meredien 10m sic"    unit="m/s" />
-        <field id="qsol"        long_name="Soil watter content"         unit="mm" />
-        <field id="ndayrain"    long_name="Number of dayrain(liq+sol)"  unit="-" />
-        <field id="precip"      long_name="Precip Totale liq+sol"       unit="kg/(s*m2)" />
-        <field id="plul"    long_name="Large-scale Precip."     unit="kg/(s*m2)" />
-        <field id="pluc"    long_name="Convective Precip."      unit="kg/(s*m2)" />
-        <field id="snow"    long_name="Snow fall"               unit="kg/(s*m2)" />
-        <field id="evap"    long_name="Evaporat"                unit="kg/(s*m2)" />
-        <field id="evap_ter"    long_name="evaporation at surface ter"    unit="kg/(s*m2)" />
-        <field id="evap_lic"    long_name="evaporation at surface lic"    unit="kg/(s*m2)" />
-        <field id="evap_oce"    long_name="evaporation at surface oce"    unit="kg/(s*m2)" />
-        <field id="evap_sic"    long_name="evaporation at surface sic"    unit="kg/(s*m2)" />
-        <field id="msnow"    long_name="Surface snow amount"    unit="kg/m2" />
-        <field id="fsnow"    long_name="Surface snow area fraction"    unit="-" />
-        <field id="tops"    long_name="Solar rad. at TOA"    unit="W/m2" />
-        <field id="tops0"    long_name="CS Solar rad. at TOA"    unit="W/m2" />
-        <field id="topl"    long_name="IR rad. at TOA"    unit="W/m2" />
-        <field id="topl0"    long_name="IR rad. at TOA"    unit="W/m2" />
-        <field id="SWupTOA"    long_name="SWup at TOA"    unit="W/m2" />
-        <field id="SWupTOAclr"    long_name="SWup clear sky at TOA"    unit="W/m2" />
-        <field id="SWdnTOA"    long_name="SWdn at TOA"    unit="W/m2" />
-        <field id="SWdnTOAclr"    long_name="SWdn clear sky at TOA"    unit="W/m2" />
-        <field id="nettop"    long_name="Net dn radiatif flux at TOA"    unit="W/m2" />
-        <field id="SWup200"    long_name="SWup at 200mb"    unit="W/m2" />
-        <field id="SWup200clr"    long_name="SWup clear sky at 200mb"    unit="W/m2" />
-        <field id="SWdn200"    long_name="SWdn at 200mb"    unit="W/m2" />
-        <field id="SWdn200clr"    long_name="SWdn clear sky at 200mb"    unit="W/m2" />
-        <field id="LWup200"    long_name="LWup at 200mb"    unit="W/m2" />
-        <field id="LWup200clr"    long_name="LWup clear sky at 200mb"    unit="W/m2" />
-        <field id="LWdn200"    long_name="LWdn at 200mb"    unit="W/m2" />
-        <field id="LWdn200clr"    long_name="LWdn clear sky at 200mb"    unit="W/m2" />
-        <field id="sols"    long_name="Solar rad. at surf."    unit="W/m2" />
-        <field id="sols0"    long_name="Solar rad. at surf."    unit="W/m2" />
-        <field id="soll"    long_name="IR rad. at surface"    unit="W/m2" />
-        <field id="soll0"    long_name="IR rad. at surface"    unit="W/m2" />
-        <field id="radsol"    long_name="Rayonnement au sol"    unit="W/m2" />
-        <field id="SWupSFC"    long_name="SWup at surface"    unit="W/m2" />
-        <field id="SWupSFCclr"    long_name="SWup clear sky at surface"    unit="W/m2" />
-        <field id="SWdnSFC"    long_name="SWdn at surface"    unit="W/m2" />
-        <field id="SWdnSFCclr"    long_name="SWdn clear sky at surface"    unit="W/m2" />
-        <field id="LWupSFC"    long_name="Upwd. IR rad. at surface"    unit="W/m2" />
-        <field id="LWupSFCclr"    long_name="CS Upwd. IR rad. at surface"    unit="W/m2" />
-        <field id="LWdnSFC"    long_name="Down. IR rad. at surface"    unit="W/m2" />
-        <field id="LWdnSFCclr"    long_name="Down. CS IR rad. at surface"    unit="W/m2" />
-        <field id="bils"    long_name="Surf. total heat flux"    unit="W/m2" />
-        <field id="bils_tke"    long_name="Surf. total heat flux"    unit="W/m2" />
-        <field id="bils_diss"    long_name="Surf. total heat flux"    unit="W/m2" />
-        <field id="bils_ec"    long_name="Surf. total heat flux"    unit="W/m2" />
-        <field id="bils_kinetic"    long_name="Surf. total heat flux"    unit="W/m2" />
-        <field id="bils_enthalp"    long_name="Surf. total heat flux"    unit="W/m2" />
-        <field id="bils_latent"    long_name="Surf. total heat flux"    unit="W/m2" />
-        <field id="sens"    long_name="Sensible heat flux"    unit="W/m2" />
-        <field id="fder"    long_name="Heat flux derivation"    unit="W/m2" />
-        <field id="ffonte"    long_name="Thermal flux for snow melting"    unit="W/m2" />
-        <field id="fqcalving"    long_name="Ice Calving"    unit="kg/m2/s" />
-        <field id="fqfonte"    long_name="Land ice melt"    unit="kg/m2/s" />
-        <field id="taux"    long_name="Zonal wind stress"    unit="Pa" />
-        <field id="tauy"    long_name="Meridional wind stress"    unit="Pa" />
-        <field id="taux_ter"    long_name="Zonal wind stress ter"    unit="Pa" />
-        <field id="taux_lic"    long_name="Zonal wind stress lic"    unit="Pa" />
-        <field id="taux_oce"    long_name="Zonal wind stress oce"    unit="Pa" />
-        <field id="taux_sic"    long_name="Zonal wind stress sic"    unit="Pa" />
-        <field id="tauy_ter"    long_name="Meridional wind stress ter"    unit="Pa" />
-        <field id="tauy_lic"    long_name="Meridional wind stress lic"    unit="Pa" />
-        <field id="tauy_oce"    long_name="Meridional wind stress oce"    unit="Pa" />
-        <field id="tauy_sic"    long_name="Meridional wind stress sic"    unit="Pa" />
-        <field id="pourc_ter"    long_name="% ter"    unit="%" />
-        <field id="pourc_lic"    long_name="% lic"    unit="%" />
-        <field id="pourc_oce"    long_name="% oce"    unit="%" />
-        <field id="pourc_sic"    long_name="% sic"    unit="%" />
-        <field id="fract_ter"    long_name="Fraction ter"    unit="1" />
-        <field id="fract_lic"    long_name="Fraction lic"    unit="1" />
-        <field id="fract_oce"    long_name="Fraction oce"    unit="1" />
-        <field id="fract_sic"    long_name="Fraction sic"    unit="1" />
-        <field id="tsol_ter"    long_name="Temperature ter"    unit="K" />
-        <field id="tsol_lic"    long_name="Temperature lic"    unit="K" />
-        <field id="tsol_oce"    long_name="Temperature oce"    unit="K" />
-        <field id="tsol_sic"    long_name="Temperature sic"    unit="K" />
-        <field id="evappot_ter"    long_name="Temperature ter"    unit="K" />
-        <field id="evappot_lic"    long_name="Temperature lic"    unit="K" />
-        <field id="evappot_oce"    long_name="Temperature oce"    unit="K" />
-        <field id="evappot_sic"    long_name="Temperature sic"    unit="K" />
-        <field id="sens_ter"    long_name="Sensible heat flux ter"    unit="W/m2" />
-        <field id="sens_lic"    long_name="Sensible heat flux lic"    unit="W/m2" />
-        <field id="sens_oce"    long_name="Sensible heat flux oce"    unit="W/m2" />
-        <field id="sens_sic"    long_name="Sensible heat flux sic"    unit="W/m2" />
-        <field id="lat_ter"    long_name="Latent heat flux ter"    unit="W/m2" />
-        <field id="lat_lic"    long_name="Latent heat flux lic"    unit="W/m2" />
-        <field id="lat_oce"    long_name="Latent heat flux oce"    unit="W/m2" />
-        <field id="lat_sic"    long_name="Latent heat flux sic"    unit="W/m2" />
-        <field id="flw_ter"    long_name="LW ter"    unit="W/m2" />
-        <field id="flw_lic"    long_name="LW lic"    unit="W/m2" />
-        <field id="flw_oce"    long_name="LW oce"    unit="W/m2" />
-        <field id="flw_sic"    long_name="LW sic"    unit="W/m2" />
-        <field id="fsw_ter"    long_name="SW ter"    unit="W/m2" />
-        <field id="fsw_lic"    long_name="SW lic"    unit="W/m2" />
-        <field id="fsw_oce"    long_name="SW oce"    unit="W/m2" />
-        <field id="fsw_sic"    long_name="SW sic"    unit="W/m2" />
-        <field id="wbils_ter"    long_name="Bilan sol ter"    unit="W/m2" />
-        <field id="wbils_lic"    long_name="Bilan sol lic"    unit="W/m2" />
-        <field id="wbils_oce"    long_name="Bilan sol oce"    unit="W/m2" />
-        <field id="wbils_sic"    long_name="Bilan sol sic"    unit="W/m2" />
-        <field id="wbilo_ter"    long_name="Bilan eau ter"    unit="kg/(m2*s)" />
-        <field id="wbilo_lic"    long_name="Bilan eau lic"    unit="kg/(m2*s)" />
-        <field id="wbilo_oce"    long_name="Bilan eau oce"    unit="kg/(m2*s)" />
-        <field id="wbilo_sic"    long_name="Bilan eau sic"    unit="kg/(m2*s)" />
-        <field id="cdrm"    long_name="Momentum drag coef."    unit="-" />
-        <field id="cdrh"    long_name="Heat drag coef."    unit="-" />
-        <field id="cldl"    long_name="Low-level cloudiness"    unit="-" />
-        <field id="cldm"    long_name="Mid-level cloudiness"    unit="-" />
-        <field id="cldh"    long_name="High-level cloudiness"    unit="-" />
-        <field id="cldt"    long_name="Total cloudiness"    unit="-" />
-        <field id="cldq"    long_name="Cloud liquid water path"    unit="kg/m2" />
-        <field id="lwp"    long_name="Cloud water path"    unit="kg/m2" />
-        <field id="iwp"    long_name="Cloud ice water path"    unit="kg/m2" />
-        <field id="ue"    long_name="Zonal energy transport"    unit="-" />
-        <field id="ve"    long_name="Merid energy transport"    unit="-" />
-        <field id="uq"    long_name="Zonal humidity transport"    unit="-" />
-        <field id="vq"    long_name="Merid humidity transport"    unit="-" />
-        <field id="cape"    long_name="Conv avlbl pot ener"    unit="J/kg" />
-        <field id="pbase"    long_name="Cld base pressure"    unit="Pa" />
-        <field id="ptop"    long_name="Cld top pressure"    unit="Pa" />
-        <field id="fbase"    long_name="Cld base mass flux"    unit="kg/m2/s" />
-        <field id="plcl"    long_name="Lifting Condensation Level"    unit="hPa" />
-        <field id="plfc"    long_name="Level of Free Convection"    unit="hPa" />
-        <field id="wbeff"    long_name="Conv. updraft velocity at LFC (inf100)"    unit="m/s" />
-        <field id="prw"    long_name="Precipitable water"    unit="kg/m2" />
-        <field id="s_pblh"    long_name="Boundary Layer Height"    unit="m" />
-        <field id="s_pblt"    long_name="t at Boundary Layer Height"    unit="K" />
-        <field id="s_lcl"    long_name="Condensation level"    unit="m" />
-        <field id="s_therm"    long_name="Exces du thermique"    unit="K" />
-        <field id="slab_bils_oce"    long_name="Bilan au sol sur ocean slab"    unit="W/m2" />
-        <field id="ale_bl"    long_name="ALE BL"    unit="m2/s2" />
-        <field id="alp_bl"    long_name="ALP BL"    unit="m2/s2" />
-        <field id="ale_wk"    long_name="ALE WK"    unit="m2/s2" />
-        <field id="alp_wk"    long_name="ALP WK"    unit="m2/s2" />
-        <field id="ale"    long_name="ALE"    unit="m2/s2" />
-        <field id="alp"    long_name="ALP"    unit="W/m2" />
-        <field id="cin"    long_name="Convective INhibition"    unit="m2/s2" />
-        <field id="wape"    long_name="-"    unit="-" />
-        <field id="n2"    long_name="Nombre de panaches de type 2"    unit="-" />
-        <field id="s2"    long_name="Surface moyenne des panaches de type 2"    unit="m2" />
-        <field id="proba_notrig"    long_name="Probabilité de non-déclenchement"    unit="-" />
-        <field id="random_notrig"    long_name="Tirage aléatoire de non-déclenchement"    unit="-" />
-        <field id="ale_bl_stat"    long_name="ALE_BL_STAT"    unit="m2/s2" />
-        <field id="ale_bl_trig"    long_name="ALE_BL_STAT + Condition P>Pseuil"    unit="m2/s2" />
-        <field id="alp_bl_det"    long_name="ALP_BL_DET"    unit="W/m2" />
-        <field id="alp_bl_fluct_m"    long_name="ALP_BL_FLUCT_M"    unit="W/m2" />
-        <field id="alp_bl_fluct_tke"    long_name="ALP_BL_FLUCT_TKE"    unit="W/m2" />
-        <field id="alp_bl_conv"    long_name="ALP_BL_CONV"    unit="W/m2" />
-        <field id="alp_bl_stat"    long_name="ALP_BL_STAT"    unit="W/m2" />
-        <field id="u850"    long_name="Zonal wind 1hPa"    unit="m/s" />
-        <field id="u700"    long_name="Zonal wind 2hPa"    unit="m/s" />
-        <field id="u500"    long_name="Zonal wind 3hPa"    unit="m/s" />
-        <field id="u200"    long_name="Zonal wind 4hPa"    unit="m/s" />
-        <field id="u100"    long_name="Zonal wind 5hPa"    unit="m/s" />
-        <field id="u50"     long_name="Zonal wind 6hPa"    unit="m/s" />
-        <field id="u10"     long_name="Zonal wind 7hPa"    unit="m/s" />
-        <field id="v850"    long_name="Meridional wind 1hPa"    unit="m/s" />
-        <field id="v700"    long_name="Meridional wind 2hPa"    unit="m/s" />
-        <field id="v500"    long_name="Meridional wind 3hPa"    unit="m/s" />
-        <field id="v200"    long_name="Meridional wind 4hPa"    unit="m/s" />
-        <field id="v100"    long_name="Meridional wind 5hPa"    unit="m/s" />
-        <field id="v50"     long_name="Meridional wind 6hPa"    unit="m/s" />
-        <field id="v10"    long_name="Meridional wind 7hPa"    unit="m/s" />
-        <field id="w850"    long_name="Vertical wind 1hPa"    unit="Pa/s" />
-        <field id="w700"    long_name="Vertical wind 2hPa"    unit="Pa/s" />
-        <field id="w500"    long_name="Vertical wind 3hPa"    unit="Pa/s" />
-        <field id="w200"    long_name="Vertical wind 4hPa"    unit="Pa/s" />
-        <field id="w100"    long_name="Vertical wind 5hPa"    unit="Pa/s" />
-        <field id="w50"    long_name="Vertical wind 6hPa"    unit="Pa/s" />
-        <field id="w10"    long_name="Vertical wind 7hPa"    unit="Pa/s" />
-        <field id="t850"    long_name="Temperature 1hPa"    unit="K" />
-        <field id="t700"    long_name="Temperature 2hPa"    unit="K" />
-        <field id="t500"    long_name="Temperature 3hPa"    unit="K" />
-        <field id="t200"    long_name="Temperature 4hPa"    unit="K" />
-        <field id="t100"    long_name="Temperature 5hPa"    unit="K" />
-        <field id="t50"    long_name="Temperature 6hPa"    unit="K" />
-        <field id="t10"    long_name="Temperature 7hPa"    unit="K" />
-        <field id="q850"    long_name="Specific humidity 1hPa"    unit="kg/kg" />
-        <field id="q700"    long_name="Specific humidity 2hPa"    unit="kg/kg" />
-        <field id="q500"    long_name="Specific humidity 3hPa"    unit="kg/kg" />
-        <field id="q200"    long_name="Specific humidity 4hPa"    unit="kg/kg" />
-        <field id="q100"    long_name="Specific humidity 5hPa"    unit="kg/kg" />
-        <field id="q50"    long_name="Specific humidity 6hPa"    unit="kg/kg" />
-        <field id="q10"    long_name="Specific humidity 7hPa"    unit="kg/kg" />
-        <field id="z850"    long_name="Geopotential height 1hPa"    unit="m" />
-        <field id="z700"    long_name="Geopotential height 2hPa"    unit="m" />
-        <field id="z500"    long_name="Geopotential height 3hPa"    unit="m" />
-        <field id="z200"    long_name="Geopotential height 4hPa"    unit="m" />
-        <field id="z100"    long_name="Geopotential height 5hPa"    unit="m" />
-        <field id="z50"    long_name="Geopotential height 6hPa"    unit="m" />
-        <field id="z10"    long_name="Geopotential height 7hPa"    unit="m" />
-        <field id="t_oce_sic"    long_name="Temp mixte oce-sic"    unit="K" />
-        <field id="weakinv"    long_name="Weak inversion"    unit="-" />
-        <field id="dthmin"    long_name="dTheta mini"    unit="K/m" />
-        <field id="u10_ter"    long_name="-"    unit="-" />
-        <field id="u10_lic"    long_name="-"    unit="-" />
-        <field id="u10_oce"    long_name="-"    unit="-" />
-        <field id="u10_sic"    long_name="-"    unit="-" />
-        <field id="v10_ter"    long_name="-"    unit="-" />
-        <field id="v10_lic"    long_name="-"    unit="-" />
-        <field id="v10_oce"    long_name="-"    unit="-" />
-        <field id="v10_sic"    long_name="-"    unit="-" />
-        <field id="rh2m"    long_name="Relative humidity at 2m"    unit="%" />
-        <field id="rh2m_min"    long_name="Min Relative humidity at 2m"    unit="%" />
-        <field id="rh2m_max"    long_name="Max Relative humidity at 2m"    unit="%" />
-        <field id="qsat2m"    long_name="Saturant humidity at 2m"    unit="%" />
-        <field id="tpot"    long_name="Surface air potential temperature"    unit="K" />
-        <field id="tpote"    long_name="Surface air equivalent potential temperature"    unit="K" />
-        <field id="tke"    long_name="TKE"    unit="m2/s2" />
-        <field id="tke_ter"    long_name="Max Turb. Kinetic Energy ter"    unit="-" />
-        <field id="tke_lic"    long_name="Max Turb. Kinetic Energy lic"    unit="-" />
-        <field id="tke_oce"    long_name="Max Turb. Kinetic Energy oce"    unit="-" />
-        <field id="tke_sic"    long_name="Max Turb. Kinetic Energy sic"    unit="-" />
-        <field id="tke_max_ter"    long_name="Max Turb. Kinetic Energy ter"    unit="-" />
-        <field id="tke_max_lic"    long_name="Max Turb. Kinetic Energy lic"    unit="-" />
-        <field id="tke_max_oce"    long_name="Max Turb. Kinetic Energy oce"    unit="-" />
-        <field id="tke_max_sic"    long_name="Max Turb. Kinetic Energy sic"    unit="-" />
-        <field id="SWnetOR"    long_name="Sfce net SW radiation OR"    unit="W/m2" />
-        <field id="SWdownOR"    long_name="Sfce incident SW radiation OR"    unit="W/m2" />
-        <field id="LWdownOR"    long_name="Sfce incident LW radiation OR"    unit="W/m2" />
-        <field id="snowl"    long_name="Solid Large-scale Precip."    unit="kg/(m2*s)" />
-        <field id="cape_max"    long_name="CAPE max."    unit="J/kg" />
-        <field id="solldown"    long_name="Down. IR rad. at surface"    unit="W/m2" />
-        <field id="dtsvdfo"    long_name="Boundary-layer dTs(o)"    unit="K/s" />
-        <field id="dtsvdft"    long_name="Boundary-layer dTs(t)"    unit="K/s" />
-        <field id="dtsvdfg"    long_name="Boundary-layer dTs(g)"    unit="K/s" />
-        <field id="dtsvdfi"    long_name="Boundary-layer dTs(g)"    unit="K/s" />
-        <field id="rugs"    long_name="rugosity"    unit="-" />
-        <field id="topswad"    long_name="ADE at TOA"    unit="W/m2" />
-        <field id="topswad0"    long_name="ADE clear-sky at TOA"    unit="W/m2" />
-        <field id="topswai"    long_name="AIE at TOA"    unit="W/m2" />
-        <field id="solswad"    long_name="ADE at SRF"    unit="W/m2" />
-        <field id="solswad0"    long_name="ADE clear-sky at SRF"    unit="W/m2" />
-        <field id="solswai"    long_name="AIE at SFR"    unit="W/m2" />
-        <field id="OD550_ASBCM"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
-        <field id="OD550_ASPOMM"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
-        <field id="OD550_ASSO4M"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
-        <field id="OD550_CSSO4M"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
-        <field id="OD550_SSSSM"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
-        <field id="OD550_ASSSM"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
-        <field id="OD550_CSSSM"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
-        <field id="OD550_CIDUSTM"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
-        <field id="OD550_AIBCM"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
-        <field id="OD550_AIPOMM"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
-        <field id="OD550_STRAT"    long_name="Aerosol Optical depth at 550 nm "    unit="1" />
-        <field id="od550aer"    long_name="Total aerosol optical depth at 550nm"    unit="-" />
-        <field id="od865aer"    long_name="Total aerosol optical depth at 870nm"    unit="-" />
-        <field id="absvisaer"    long_name="Absorption aerosol visible optical depth"    unit="-" />
-        <field id="od550lt1aer"    long_name="Fine mode optical depth"    unit="-" />
-        <field id="sconcso4"    long_name="Surface Concentration of Sulfate "    unit="kg/m3" />
-        <field id="sconcoa"    long_name="Surface Concentration of Organic Aerosol "    unit="kg/m3" />
-        <field id="sconcbc"    long_name="Surface Concentration of Black Carbon "    unit="kg/m3" />
-        <field id="sconcss"    long_name="Surface Concentration of Sea Salt "    unit="kg/m3" />
-        <field id="sconcdust"    long_name="Surface Concentration of Dust "    unit="kg/m3" />
-        <field id="loadso4"    long_name="Column Load of Sulfate "    unit="kg/m2" />
-        <field id="loadoa"    long_name="Column Load of Organic Aerosol "    unit="kg/m2" />
-        <field id="loadbc"    long_name="Column Load of Black Carbon "    unit="kg/m2" />
-        <field id="loadss"    long_name="Column Load of Sea Salt "    unit="kg/m2" />
-        <field id="loaddust"    long_name="Column Load of Dust "    unit="kg/m2" />
-        <field id="swtoaas_nat"    long_name="Natural aerosol radiative forcing all-sky at TOA"    unit="W/m2" />
-        <field id="swsrfas_nat"    long_name="Natural aerosol radiative forcing all-sky at SRF"    unit="W/m2" />
-        <field id="swtoacs_nat"    long_name="Natural aerosol radiative forcing clear-sky at TOA"    unit="W/m2" />
-        <field id="swsrfcs_nat"    long_name="Natural aerosol radiative forcing clear-sky at SRF"    unit="W/m2" />
-        <field id="swtoaas_ant"    long_name="Anthropogenic aerosol radiative forcing all-sky at TOA"    unit="W/m2" />
-        <field id="swsrfas_ant"    long_name="Anthropogenic aerosol radiative forcing all-sky at SRF"    unit="W/m2" />
-        <field id="swtoacs_ant"    long_name="Anthropogenic aerosol radiative forcing clear-sky at TOA"    unit="W/m2" />
-        <field id="swsrfcs_ant"    long_name="Anthropogenic aerosol radiative forcing clear-sky at SRF"    unit="W/m2" />
-        <field id="swtoacf_nat"    long_name="Natural aerosol impact on cloud radiative forcing at TOA"    unit="W/m2" />
-        <field id="swsrfcf_nat"    long_name="Natural aerosol impact on cloud radiative forcing  at SRF"    unit="W/m2" />
-        <field id="swtoacf_ant"    long_name="Anthropogenic aerosol impact on cloud radiative forcing at TOA"    unit="W/m2" />
-        <field id="swsrfcf_ant"    long_name="Anthropogenic aerosol impact on cloud radiative forcing at SRF"    unit="W/m2" />
-        <field id="swtoacf_zero"    long_name="Cloud radiative forcing (allsky-clearsky fluxes) at TOA"    unit="W/m2" />
-        <field id="swsrfcf_zero"    long_name="Cloud radiative forcing (allsky-clearsky fluxes) at SRF"    unit="W/m2" />
-        <field id="cldncl"    long_name="CDNC at top of liquid water cloud"    unit="m-3" />
-        <field id="reffclwtop"    long_name="Droplet effective radius at top of liquid water cloud"    unit="m" />
-        <field id="cldnvi"    long_name="Column Integrated Cloud Droplet Number"    unit="m-2" />
-        <field id="lcc"    long_name="Cloud liquid fraction at top of cloud"    unit="1" />
-        <field id="wvapp"    long_name="-"    unit="-" />
-        <field id="albe_ter"    long_name="Albedo VIS surf. ter"    unit="-" />
-        <field id="albe_lic"    long_name="Albedo VIS surf. lic"    unit="-" />
-        <field id="albe_oce"    long_name="Albedo VIS surf. oce"    unit="-" />
-        <field id="albe_sic"    long_name="Albedo VIS surf. sic"    unit="-" />
-        <field id="ages_ter"    long_name="Snow age ter"    unit="day" />
-        <field id="ages_lic"    long_name="Snow age lic"    unit="day" />
-        <field id="ages_oce"    long_name="Snow age oce"    unit="day" />
-        <field id="ages_sic"    long_name="Snow age sic"    unit="day" />
-        <field id="rugs_ter"    long_name="Surface roughness ter"    unit="m" />
-        <field id="rugs_lic"    long_name="Surface roughness lic"    unit="m" />
-        <field id="rugs_oce"    long_name="Surface roughness oce"    unit="m" />
-        <field id="rugs_sic"    long_name="Surface roughness sic"    unit="m" />
-        <field id="alb1"    long_name="Surface VIS albedo"    unit="-" />
-        <field id="alb2"    long_name="Surface Near IR albedo"    unit="-" />
-        <field id="ftime_con"    long_name="Fraction of time convection Occurs"    unit="-" />
-        <field id="wake_h"    long_name="wake_h"    unit="-" />
-        <field id="wake_s"    long_name="wake_s"    unit="-" />
-        <field id="plulth"    long_name="Rainfall therm."    unit="K/s" />
-        <field id="plulst"    long_name="Rainfall strat."    unit="K/s" />
-        <field id="lmaxth"    long_name="Upper level thermals"    unit="-" />
-        <field id="ftime_th"    long_name="Fraction of time Shallow convection occurs"    unit="-" />
-        <field id="f0_th"    long_name="Thermal closure mass flux"    unit="K/s" />
-        <field id="zmax_th"    long_name="Thermal plume height"    unit="K/s" />
-        <field id="rsut4co2"    long_name="TOA Out SW in 4xCO2 atmosphere"    unit="W/m2" />
-        <field id="rlut4co2"    long_name="TOA Out LW in 4xCO2 atmosphere"    unit="W/m2" />
-        <field id="rsutcs4co2"    long_name="TOA Out CS SW in 4xCO2 atmosphere"    unit="W/m2" />
-        <field id="rlutcs4co2"    long_name="TOA Out CS LW in 4xCO2 atmosphere"    unit="W/m2" />
-    </field_group>
-
-    <field_group id="fields_3D" domain_ref="dom_glo">
-        <field id="cldtau"    long_name="Cloud optical thickness"    unit="1" />
-        <field id="cldemi"    long_name="Cloud optical emissivity"    unit="1" />
-        <field id="tke_max"    long_name="TKE max"    unit="m2/s2" />
-        <field id="kz"    long_name="Kz melange"    unit="m2/s" />
-        <field id="kz_max"    long_name="Kz melange max"    unit="m2/s" />
-        <field id="concso4"    long_name="Concentration of Sulfate "    unit="kg/m3" />
-        <field id="concoa"    long_name="Concentration of Organic Aerosol "    unit="kg/m3" />
-        <field id="concbc"    long_name="Concentration of Black Carbon "    unit="kg/m3" />
-        <field id="concss"    long_name="Concentration of Sea Salt "    unit="kg/m3" />
-        <field id="concdust"    long_name="Concentration of Dust "    unit="kg/m3" />
-        <field id="ec550aer"    long_name="Extinction at 550nm"    unit="m^-1" />
-        <field id="lwcon"    long_name="Cloud liquid water content"    unit="kg/kg" />
-        <field id="iwcon"    long_name="Cloud ice water content"    unit="kg/kg" />
-        <field id="temp"    long_name="Air temperature"    unit="K" />
-        <field id="theta"    long_name="Potential air temperature"    unit="K" />
-        <field id="ovap"    long_name="Specific humidity"    unit="kg/kg" />
-        <field id="ovapinit"    long_name="Specific humidity (begin of timestep)"    unit="kg/kg" />
-        <field id="oliq"    long_name="Condensed water"    unit="kg/kg" />
-        <field id="geop"    long_name="Geopotential height"    unit="m2/s2" />
-        <field id="vitu"    long_name="Zonal wind"    unit="m/s" />
-        <field id="vitv"    long_name="Meridional wind"    unit="m/s" />
-        <field id="vitw"    long_name="Vertical wind"    unit="Pa/s" />
-        <field id="pres"    long_name="Air pressure"    unit="Pa" />
-        <field id="paprs"    long_name="Air pressure Inter-Couches"    unit="Pa" />
-        <field id="mass"    long_name="Masse Couches"    unit="kg/m2" />
-        <field id="zfull"    long_name="Altitude of full pressure levels"    unit="m" />
-        <field id="zhalf"    long_name="Altitude of half pressure levels"    unit="m" />
-        <field id="rneb"    long_name="Cloud fraction"    unit="-" />
-        <field id="rnebcon"    long_name="Convective Cloud Fraction"    unit="-" />
-        <field id="rnebls"    long_name="LS Cloud fraction"    unit="-" />
-        <field id="rhum"    long_name="Relative humidity"    unit="-" />
-        <field id="ozone"    long_name="Ozone mole fraction"    unit="-" />
-        <field id="ozone_daylight"    long_name="Daylight ozone mole fraction"    unit="-" />
-        <field id="upwd"    long_name="saturated updraft"    unit="kg/m2/s" />
-        <field id="dtphy"    long_name="Physics dT"    unit="K/s" />
-        <field id="dqphy"    long_name="Physics dQ"    unit="(kg/kg)/s" />
-        <field id="pr_con_l"    long_name="Convective precipitation lic"    unit="-" />
-        <field id="pr_con_i"    long_name="Convective precipitation ice"    unit="-" />
-        <field id="pr_lsc_l"    long_name="Large scale precipitation lic"    unit="-" />
-        <field id="pr_lsc_i"    long_name="Large scale precipitation ice"    unit="-" />
-        <field id="re"    long_name="Cloud droplet effective radius"    unit="um" />
-        <field id="fl"    long_name="Denominator of Cloud droplet effective radius"    unit="-" />
-        <field id="scdnc"    long_name="Cloud droplet number concentration"    unit="m-3" />
-        <field id="reffclws"    long_name="Stratiform Cloud Droplet Effective Radius (aerosol diags.)"    unit="m" />
-        <field id="reffclwc"    long_name="Convective Cloud Droplet Effective Radius (aerosol diags.)"    unit="m" />
-        <field id="lcc3d"    long_name="Cloud liquid fraction"    unit="1" />
-        <field id="lcc3dcon"    long_name="Convective cloud liquid fraction"    unit="1" />
-        <field id="lcc3dstra"    long_name="Stratiform cloud liquid fraction"    unit="1" />
-        <field id="clwcon"    long_name="Convective Cloud Liquid water content"    unit="kg/kg" />
-        <field id="Ma"    long_name="undilute adiab updraft"    unit="kg/m2/s" />
-        <field id="dnwd"    long_name="saturated downdraft"    unit="kg/m2/s" />
-        <field id="dnwd0"    long_name="unsat. downdraft"    unit="kg/m2/s" />
-        <field id="mc"    long_name="Convective mass flux"    unit="kg/m2/s" />
-        <field id="dtdyn"    long_name="Dynamics dT"    unit="K/s" />
-        <field id="dqdyn"    long_name="Dynamics dQ"    unit="(kg/kg)/s" />
-        <field id="dudyn"    long_name="Dynamics dU"    unit="m/s2" />
-        <field id="dvdyn"    long_name="Dynamics dV"    unit="m/s2" />
-        <field id="dtcon"    long_name="Convection dT"    unit="K/s" />
-        <field id="ducon"    long_name="Convection du"    unit="m/s2" />
-        <field id="dvcon"    long_name="Convection dv"    unit="m/s2" />
-        <field id="dqcon"    long_name="Convection dQ"    unit="(kg/kg)/s" />
-        <field id="dtwak"    long_name="Wake dT"    unit="K/s" />
-        <field id="dqwak"    long_name="Wake dQ"    unit="(kg/kg)/s" />
-        <field id="wake_deltat"    long_name="wake_deltat"    unit="-" />
-        <field id="wake_deltaq"    long_name="wake_deltaq"    unit="-" />
-        <field id="wake_omg"    long_name="wake_omg"    unit="-" />
-        <field id="wdtrainA"    long_name="precipitation from AA"    unit="-" />
-        <field id="wdtrainM"    long_name="precipitation from mixture"    unit="-" />
-        <field id="Vprecip"    long_name="precipitation vertical profile"    unit="-" />
-        <field id="ftd"    long_name="tend temp due aux descentes precip"    unit="-" />
-        <field id="fqd"    long_name="tend vap eau due aux descentes precip"    unit="-" />
-        <field id="dtlsc"    long_name="Condensation dT"    unit="K/s" />
-        <field id="dtlschr"    long_name="Large-scale condensational heating rate"    unit="K/s" />
-        <field id="dqlsc"    long_name="Condensation dQ"    unit="(kg/kg)/s" />
-        <field id="beta_prec"    long_name="LS Conversion rate to prec"    unit="(kg/kg)/s" />
-        <field id="dtvdf"    long_name="Boundary-layer dT"    unit="K/s" />
-        <field id="dtdis"    long_name="TKE dissipation dT"    unit="K/s" />
-        <field id="dqvdf"    long_name="Boundary-layer dQ"    unit="(kg/kg)/s" />
-        <field id="dteva"    long_name="Reevaporation dT"    unit="K/s" />
-        <field id="dqeva"    long_name="Reevaporation dQ"    unit="(kg/kg)/s" />
-        <field id="dqlscth"    long_name="dQ therm."    unit="(kg/kg)/s" />
-        <field id="dqlscst"    long_name="dQ strat."    unit="(kg/kg)/s" />
-        <field id="dtlscth"    long_name="dQ therm."    unit="K/s" />
-        <field id="dtlscst"    long_name="dQ strat."    unit="K/s" />
-        <field id="ptconvth"    long_name="POINTS CONVECTIFS therm."    unit="-" />
-        <field id="ptconv"    long_name="POINTS CONVECTIFS"    unit="-" />
-        <field id="ratqs"    long_name="RATQS"    unit="-" />
-        <field id="dtthe"    long_name="Thermal dT"    unit="K/s" />
-        <field id="f_th"    long_name="Thermal plume mass flux"    unit="kg/(m2*s)" />
-        <field id="e_th"    long_name="Thermal plume entrainment"    unit="K/s" />
-        <field id="w_th"    long_name="Thermal plume vertical velocity"    unit="m/s" />
-        <field id="lambda_th"    long_name="Thermal plume vertical velocity"    unit="m/s" />
-        <field id="q_th"    long_name="Thermal plume total humidity"    unit="kg/kg" />
-        <field id="a_th"    long_name="Thermal plume fraction"    unit="-" />
-        <field id="d_th"    long_name="Thermal plume detrainment"    unit="K/s" />
-        <field id="dqthe"    long_name="Thermal dQ"    unit="(kg/kg)/s" />
-        <field id="dtajs"    long_name="Dry adjust. dT"    unit="K/s" />
-        <field id="dqajs"    long_name="Dry adjust. dQ"    unit="(kg/kg)/s" />
-        <field id="dtswr"    long_name="SW radiation dT"    unit="K/s" />
-        <field id="dtsw0"    long_name="CS SW radiation dT"    unit="K/s" />
-        <field id="dtlwr"    long_name="LW radiation dT"    unit="K/s" />
-        <field id="dtlw0"    long_name="CS LW radiation dT"    unit="K/s" />
-        <field id="dtec"    long_name="Cinetic dissip dT"    unit="K/s" />
-        <field id="duvdf"    long_name="Boundary-layer dU"    unit="m/s2" />
-        <field id="dvvdf"    long_name="Boundary-layer dV"    unit="m/s2" />
-        <field id="duoro"    long_name="Orography dU"    unit="m/s2" />
-        <field id="dvoro"    long_name="Orography dV"    unit="m/s2" />
-        <field id="dulif"    long_name="Orography dU"    unit="m/s2" />
-        <field id="dvlif"    long_name="Orography dV"    unit="m/s2" />
-        <field id="duhin"    long_name="Hines GWD dU"    unit="m/s2" />
-        <field id="dvhin"    long_name="Hines GWD dV"    unit="m/s2" />
-        <field id="dtoro"    long_name="Orography dT"    unit="K/s" />
-        <field id="dtlif"    long_name="Orography dT"    unit="K/s" />
-        <field id="dthin"    long_name="Hines GWD dT"    unit="K/s" />
-        <field id="rsu"    long_name="SW upward radiation"    unit="W m-2" />
-        <field id="rsd"    long_name="SW downward radiation"    unit="W m-2" />
-        <field id="rlu"    long_name="LW upward radiation"    unit="W m-2" />
-        <field id="rld"    long_name="LW downward radiation"    unit="W m-2" />
-        <field id="rsucs"    long_name="SW CS upward radiation"    unit="W m-2" />
-        <field id="rsdcs"    long_name="SW CS downward radiation"    unit="W m-2" />
-        <field id="rlucs"    long_name="LW CS upward radiation"    unit="W m-2" />
-        <field id="rldcs"    long_name="LW CS downward radiation"    unit="W m-2" />
-        <field id="tnt"    long_name="Tendency of air temperature"    unit="K s-1" />
-        <field id="tntc"    long_name="Tendency of air temperature due to Moist Convection"    unit="K s-1" />
-        <field id="tntr"    long_name="Air temperature tendency due to Radiative heating"    unit="K s-1" />
-        <field id="tntscpbl"    long_name="Air temperature tendency due to St cloud and precipitation and BL mixing"    unit="K s-1" />
-        <field id="tnhus"    long_name="Tendency of specific humidity"    unit="s-1" />
-        <field id="tnhusc"    long_name="Tendency of specific humidity due to convection"    unit="s-1" />
-        <field id="tnhusscpbl"    long_name="Tendency of Specific humidity due to ST cl, precip and BL mixing"    unit="s-1" />
-        <field id="evu"    long_name="Eddy viscosity coefficient for Momentum Variables"    unit="m2 s-1" />
-        <field id="h2o"    long_name="Mass Fraction of Water"    unit="1" />
-        <field id="mcd"    long_name="Downdraft COnvective Mass Flux"    unit="kg/(m2*s)" />
-        <field id="dmc"    long_name="Deep COnvective Mass Flux"    unit="kg/(m2*s)" />
-        <field id="ref_liq"    long_name="Effective radius of convective cloud liquid water particle"    unit="m" />
-        <field id="ref_ice"    long_name="Effective radius of startiform cloud ice particle"    unit="m" />
-        <field id="rsu4co2"    long_name="Upwelling SW 4xCO2 atmosphere"    unit="W/m2" />
-        <field id="rlu4co2"    long_name="Upwelling LW 4xCO2 atmosphere"    unit="W/m2" />
-        <field id="rsucs4co2"    long_name="Upwelling CS SW 4xCO2 atmosphere"    unit="W/m2" />
-        <field id="rlucs4co2"    long_name="Upwelling CS LW 4xCO2 atmosphere"    unit="W/m2" />
-        <field id="rsd4co2"    long_name="Downwelling SW 4xCO2 atmosphere"    unit="W/m2" />
-        <field id="rld4co2"    long_name="Downwelling LW 4xCO2 atmosphere"    unit="W/m2" />
-        <field id="rsdcs4co2"    long_name="Downwelling CS SW 4xCO2 atmosphere"    unit="W/m2" />
-        <field id="rldcs4co2"    long_name="Downwelling CS LW 4xCO2 atmosphere"    unit="W/m2" />
-    </field_group>
-</field_definition>
Index: DZ5/branches/testing/DefLists/iodef_file_histLES.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/iodef_file_histLES.xml	(revision 2055)
+++ 	(revision )
@@ -1,510 +1,0 @@
-<file_definition>
-    <file_group id="defile">
-        <file id="histLES" name="XhistLES" output_freq="1h" output_level="5" enabled=".FALSE.">
-            <!-- VARS 2D -->
-            <field_group operation="average" freq_op="1ts">
-                <field field_ref="Ap" level="1" />
-                <field field_ref="Bp" level="1" />
-                <field field_ref="Alt" level="1" />
-                <field field_ref="phis" level="1" />
-                <field field_ref="aire" level="1" operation="once" />
-                <field field_ref="contfracATM" level="10" operation="once" />
-                <field field_ref="contfracOR" level="10" />
-                <field field_ref="aireTER" level="10" />
-                <field field_ref="flat" level="5" />
-                <field field_ref="slp" level="10" />
-                <field field_ref="tsol" level="10" />
-                <field field_ref="t2m" level="10" />
-                <field field_ref="t2m_min" level="10" operation="minimum" />
-                <field field_ref="t2m_max" level="10" operation="maximum" />
-                <field field_ref="t2m_ter" level="10" />
-                <field field_ref="t2m_lic" level="10" />
-                <field field_ref="t2m_oce" level="10" />
-                <field field_ref="t2m_sic" level="10" />
-                <field field_ref="wind10m" level="10" />
-                <field field_ref="wind10max" level="10" />
-                <field field_ref="sicf" level="10" />
-                <field field_ref="q2m" level="10" />
-                <field field_ref="ustar" level="10" />
-                <field field_ref="u10m" level="10" />
-                <field field_ref="v10m" level="10" />
-                <field field_ref="psol" level="10" />
-                <field field_ref="qsurf" level="10" />
-                <field field_ref="ustar_ter" level="10" />
-                <field field_ref="ustar_lic" level="10" />
-                <field field_ref="ustar_oce" level="10" />
-                <field field_ref="ustar_sic" level="10" />
-                <field field_ref="wstar_ter" level="10" />
-                <field field_ref="wstar_lic" level="10" />
-                <field field_ref="wstar_oce" level="10" />
-                <field field_ref="wstar_sic" level="10" />
-                <field field_ref="wstar" level="10" />
-                <field field_ref="u10m_ter" level="10" />
-                <field field_ref="u10m_lic" level="10" />
-                <field field_ref="u10m_oce" level="10" />
-                <field field_ref="u10m_sic" level="10" />
-                <field field_ref="v10m_ter" level="10" />
-                <field field_ref="v10m_lic" level="10" />
-                <field field_ref="v10m_oce" level="10" />
-                <field field_ref="v10m_sic" level="10" />
-                <field field_ref="qsol" level="10" />
-                <field field_ref="ndayrain" level="10" operation="instant" />
-                <field field_ref="precip" level="5" />
-                <field field_ref="plul" level="10" />
-                <field field_ref="pluc" level="5" />
-                <field field_ref="snow" level="5" />
-                <field field_ref="evap" level="10" />
-                <field field_ref="evap_ter" level="10" />
-                <field field_ref="evap_lic" level="10" />
-                <field field_ref="evap_oce" level="10" />
-                <field field_ref="evap_sic" level="10" />
-                <field field_ref="msnow" level="10" />
-                <field field_ref="fsnow" level="10" />
-                <field field_ref="tops" level="10" />
-                <field field_ref="tops0" level="10" />
-                <field field_ref="topl" level="10" />
-                <field field_ref="topl0" level="10" />
-                <field field_ref="SWupTOA" level="10" />
-                <field field_ref="SWupTOAclr" level="10" />
-                <field field_ref="SWdnTOA" level="10" />
-                <field field_ref="SWdnTOAclr" level="10" />
-                <field field_ref="nettop" level="10" />
-                <field field_ref="SWup200" level="10" />
-                <field field_ref="SWup200clr" level="10" />
-                <field field_ref="SWdn200" level="10" />
-                <field field_ref="SWdn200clr" level="10" />
-                <field field_ref="LWup200" level="10" />
-                <field field_ref="LWup200clr" level="10" />
-                <field field_ref="LWdn200" level="10" />
-                <field field_ref="LWdn200clr" level="10" />
-                <field field_ref="sols" level="10" />
-                <field field_ref="sols0" level="10" />
-                <field field_ref="soll" level="10" />
-                <field field_ref="soll0" level="10" />
-                <field field_ref="radsol" level="10" />
-                <field field_ref="SWupSFC" level="5" />
-                <field field_ref="SWupSFCclr" level="5" />
-                <field field_ref="SWdnSFC" level="5" />
-                <field field_ref="SWdnSFCclr" level="5" />
-                <field field_ref="LWupSFC" level="5" />
-                <field field_ref="LWupSFCclr" level="5" />
-                <field field_ref="LWdnSFC" level="5" />
-                <field field_ref="LWdnSFCclr" level="5" />
-                <field field_ref="bils" level="10" />
-                <field field_ref="bils_tke" level="10" />
-                <field field_ref="bils_diss" level="10" />
-                <field field_ref="bils_ec" level="10" />
-                <field field_ref="bils_kinetic" level="10" />
-                <field field_ref="bils_enthalp" level="10" />
-                <field field_ref="bils_latent" level="10" />
-                <field field_ref="sens" level="5" />
-                <field field_ref="fder" level="10" />
-                <field field_ref="ffonte" level="10" />
-                <field field_ref="fqcalving" level="10" />
-                <field field_ref="fqfonte" level="10" />
-                <field field_ref="taux" level="10" />
-                <field field_ref="tauy" level="10" />
-                <field field_ref="taux_ter" level="10" />
-                <field field_ref="taux_lic" level="10" />
-                <field field_ref="taux_oce" level="10" />
-                <field field_ref="taux_sic" level="10" />
-                <field field_ref="tauy_ter" level="10" />
-                <field field_ref="tauy_lic" level="10" />
-                <field field_ref="tauy_oce" level="10" />
-                <field field_ref="tauy_sic" level="10" />
-                <field field_ref="pourc_ter" level="10" />
-                <field field_ref="pourc_lic" level="10" />
-                <field field_ref="pourc_oce" level="10" />
-                <field field_ref="pourc_sic" level="10" />
-                <field field_ref="fract_ter" level="10" />
-                <field field_ref="fract_lic" level="10" />
-                <field field_ref="fract_oce" level="10" />
-                <field field_ref="fract_sic" level="10" />
-                <field field_ref="tsol_ter" level="10" />
-                <field field_ref="tsol_lic" level="10" />
-                <field field_ref="tsol_oce" level="10" />
-                <field field_ref="tsol_sic" level="10" />
-                <field field_ref="evappot_ter" level="10" />
-                <field field_ref="evappot_lic" level="10" />
-                <field field_ref="evappot_oce" level="10" />
-                <field field_ref="evappot_sic" level="10" />
-                <field field_ref="sens_ter" level="10" />
-                <field field_ref="sens_lic" level="10" />
-                <field field_ref="sens_oce" level="10" />
-                <field field_ref="sens_sic" level="10" />
-                <field field_ref="lat_ter" level="10" />
-                <field field_ref="lat_lic" level="10" />
-                <field field_ref="lat_oce" level="10" />
-                <field field_ref="lat_sic" level="10" />
-                <field field_ref="flw_ter" level="10" />
-                <field field_ref="flw_lic" level="10" />
-                <field field_ref="flw_oce" level="10" />
-                <field field_ref="flw_sic" level="10" />
-                <field field_ref="fsw_ter" level="10" />
-                <field field_ref="fsw_lic" level="10" />
-                <field field_ref="fsw_oce" level="10" />
-                <field field_ref="fsw_sic" level="10" />
-                <field field_ref="wbils_ter" level="10" />
-                <field field_ref="wbils_lic" level="10" />
-                <field field_ref="wbils_oce" level="10" />
-                <field field_ref="wbils_sic" level="10" />
-                <field field_ref="wbilo_ter" level="10" />
-                <field field_ref="wbilo_lic" level="10" />
-                <field field_ref="wbilo_oce" level="10" />
-                <field field_ref="wbilo_sic" level="10" />
-                <field field_ref="cdrm" level="10" />
-                <field field_ref="cdrh" level="10" />
-                <field field_ref="cldl" level="10" />
-                <field field_ref="cldm" level="10" />
-                <field field_ref="cldh" level="10" />
-                <field field_ref="cldt" level="5" />
-                <field field_ref="cldq" level="10" />
-                <field field_ref="lwp" level="10" />
-                <field field_ref="iwp" level="10" />
-                <field field_ref="ue" level="10" />
-                <field field_ref="ve" level="10" />
-                <field field_ref="uq" level="10" />
-                <field field_ref="vq" level="10" />
-                <field field_ref="cape" level="10" />
-                <field field_ref="pbase" level="10" />
-                <field field_ref="ptop" level="10" />
-                <field field_ref="fbase" level="10" />
-                <field field_ref="plcl" level="10" />
-                <field field_ref="plfc" level="10" />
-                <field field_ref="wbeff" level="10" />
-                <field field_ref="prw" level="10" />
-                <field field_ref="s_pblh" level="10" />
-                <field field_ref="s_pblt" level="10" />
-                <field field_ref="s_lcl" level="10" />
-                <field field_ref="s_therm" level="10" />
-                <field field_ref="slab_bils_oce" level="10" />
-                <field field_ref="ale_bl" level="10" />
-                <field field_ref="alp_bl" level="10" />
-                <field field_ref="ale_wk" level="10" />
-                <field field_ref="alp_wk" level="10" />
-                <field field_ref="ale" level="10" />
-                <field field_ref="alp" level="10" />
-                <field field_ref="cin" level="10" />
-                <field field_ref="wape" level="10" />
-                <field field_ref="n2" level="10" />
-                <field field_ref="s2" level="10" />
-                <field field_ref="proba_notrig" level="10" />
-                <field field_ref="random_notrig" level="10" />
-                <field field_ref="ale_bl_stat" level="10" />
-                <field field_ref="ale_bl_trig" level="10" />
-                <field field_ref="alp_bl_det" level="10" />
-                <field field_ref="alp_bl_fluct_m" level="10" />
-                <field field_ref="alp_bl_fluct_tke" level="10" />
-                <field field_ref="alp_bl_conv" level="10" />
-                <field field_ref="alp_bl_stat" level="10" />
-
-                <field_group operation="instant">
-                    <field field_ref="u850" level="10" />
-                    <field field_ref="u700" level="10" />
-                    <field field_ref="u500" level="10" />
-                    <field field_ref="u200" level="10" />
-                    <field field_ref="u100" level="10" />
-                    <field field_ref="u50" level="10" />
-                    <field field_ref="u10" level="10" />
-                    <field field_ref="v850" level="10" />
-                    <field field_ref="v700" level="10" />
-                    <field field_ref="v500" level="10" />
-                    <field field_ref="v200" level="10" />
-                    <field field_ref="v100" level="10" />
-                    <field field_ref="v50" level="10" />
-                    <field field_ref="v10" level="10" />
-                    <field field_ref="w850" level="10" />
-                    <field field_ref="w700" level="10" />
-                    <field field_ref="w500" level="10" />
-                    <field field_ref="w200" level="10" />
-                    <field field_ref="w100" level="10" />
-                    <field field_ref="w50" level="10" />
-                    <field field_ref="w10" level="10" />
-                    <field field_ref="t850" level="10" />
-                    <field field_ref="t700" level="10" />
-                    <field field_ref="t500" level="10" />
-                    <field field_ref="t200" level="10" />
-                    <field field_ref="t100" level="10" />
-                    <field field_ref="t50" level="10" />
-                    <field field_ref="t10" level="10" />
-                    <field field_ref="q850" level="10" />
-                    <field field_ref="q700" level="10" />
-                    <field field_ref="q500" level="10" />
-                    <field field_ref="q200" level="10" />
-                    <field field_ref="q100" level="10" />
-                    <field field_ref="q50" level="10" />
-                    <field field_ref="q10" level="10" />
-                    <field field_ref="z850" level="10" />
-                    <field field_ref="z700" level="10" />
-                    <field field_ref="z500" level="10" />
-                    <field field_ref="z200" level="10" />
-                    <field field_ref="z100" level="10" />
-                    <field field_ref="z50" level="10" />
-                    <field field_ref="z10" level="10" />
-                </field_group>
-
-                <field field_ref="t_oce_sic" level="10" />
-                <field field_ref="weakinv" level="10" />
-                <field field_ref="dthmin" level="10" />
-                <field field_ref="u10_ter" level="10" />
-                <field field_ref="u10_lic" level="10" />
-                <field field_ref="u10_oce" level="10" />
-                <field field_ref="u10_sic" level="10" />
-                <field field_ref="v10_ter" level="10" />
-                <field field_ref="v10_lic" level="10" />
-                <field field_ref="v10_oce" level="10" />
-                <field field_ref="v10_sic" level="10" />
-                <field field_ref="rh2m" level="10" />
-                <field field_ref="rh2m_min" level="10" operation="minimum" />
-                <field field_ref="rh2m_max" level="10" operation="maximum" />
-                <field field_ref="qsat2m" level="10" />
-                <field field_ref="tpot" level="10" />
-                <field field_ref="tpote" level="10" />
-                <field field_ref="tke" level="10" />
-                <field field_ref="tke_ter" level="10" />
-                <field field_ref="tke_lic" level="10" />
-                <field field_ref="tke_oce" level="10" />
-                <field field_ref="tke_sic" level="10" />
-                <field field_ref="tke_max_ter" level="10" operation="maximum" />
-                <field field_ref="tke_max_lic" level="10" operation="maximum" />
-                <field field_ref="tke_max_oce" level="10" operation="maximum" />
-                <field field_ref="tke_max_sic" level="10" operation="maximum" />
-                <field field_ref="SWnetOR" level="10" />
-                <field field_ref="SWdownOR" level="10" />
-                <field field_ref="LWdownOR" level="10" />
-                <field field_ref="snowl" level="10" />
-                <field field_ref="cape_max" level="10" operation="maximum" />
-                <field field_ref="solldown" level="10" />
-                <field field_ref="dtsvdfo" level="10" />
-                <field field_ref="dtsvdft" level="10" />
-                <field field_ref="dtsvdfg" level="10" />
-                <field field_ref="dtsvdfi" level="10" />
-                <field field_ref="rugs" level="10" />
-                <field field_ref="topswad" level="10" />
-                <field field_ref="topswad0" level="10" />
-                <field field_ref="topswai" level="10" />
-                <field field_ref="solswad" level="10" />
-                <field field_ref="solswad0" level="10" />
-                <field field_ref="solswai" level="10" />
-                <field field_ref="OD550_ASBCM" level="10" />
-                <field field_ref="OD550_ASPOMM" level="10" />
-                <field field_ref="OD550_ASSO4M" level="10" />
-                <field field_ref="OD550_CSSO4M" level="10" />
-                <field field_ref="OD550_SSSSM" level="10" />
-                <field field_ref="OD550_ASSSM" level="10" />
-                <field field_ref="OD550_CSSSM" level="10" />
-                <field field_ref="OD550_CIDUSTM" level="10" />
-                <field field_ref="OD550_AIBCM" level="10" />
-                <field field_ref="OD550_AIPOMM" level="10" />
-                <field field_ref="OD550_STRAT" level="10" />
-                <field field_ref="od550aer" level="10" />
-                <field field_ref="od865aer" level="10" />
-                <field field_ref="absvisaer" level="10" />
-                <field field_ref="od550lt1aer" level="10" />
-                <field field_ref="sconcso4" level="10" />
-                <field field_ref="sconcoa" level="10" />
-                <field field_ref="sconcbc" level="10" />
-                <field field_ref="sconcss" level="10" />
-                <field field_ref="sconcdust" level="10" />
-                <field field_ref="loadso4" level="10" />
-                <field field_ref="loadoa" level="10" />
-                <field field_ref="loadbc" level="10" />
-                <field field_ref="loadss" level="10" />
-                <field field_ref="loaddust" level="10" />
-                <field field_ref="swtoaas_nat" level="10" />
-                <field field_ref="swsrfas_nat" level="10" />
-                <field field_ref="swtoacs_nat" level="10" />
-                <field field_ref="swsrfcs_nat" level="10" />
-                <field field_ref="swtoaas_ant" level="10" />
-                <field field_ref="swsrfas_ant" level="10" />
-                <field field_ref="swtoacs_ant" level="10" />
-                <field field_ref="swsrfcs_ant" level="10" />
-                <field field_ref="swtoacf_nat" level="10" />
-                <field field_ref="swsrfcf_nat" level="10" />
-                <field field_ref="swtoacf_ant" level="10" />
-                <field field_ref="swsrfcf_ant" level="10" />
-                <field field_ref="swtoacf_zero" level="10" />
-                <field field_ref="swsrfcf_zero" level="10" />
-                <field field_ref="cldncl" level="10" />
-                <field field_ref="reffclwtop" level="10" />
-                <field field_ref="cldnvi" level="10" />
-                <field field_ref="lcc" level="10" />
-                <field field_ref="wvapp" level="10" />
-                <field field_ref="albe_ter" level="10" />
-                <field field_ref="albe_lic" level="10" />
-                <field field_ref="albe_oce" level="10" />
-                <field field_ref="albe_sic" level="10" />
-                <field field_ref="ages_ter" level="10" />
-                <field field_ref="ages_lic" level="10" />
-                <field field_ref="ages_oce" level="10" />
-                <field field_ref="ages_sic" level="10" />
-                <field field_ref="rugs_ter" level="10" />
-                <field field_ref="rugs_lic" level="10" />
-                <field field_ref="rugs_oce" level="10" />
-                <field field_ref="rugs_sic" level="10" />
-                <field field_ref="alb1" level="10" />
-                <field field_ref="alb2" level="10" />
-                <field field_ref="ftime_con" level="10" operation="instant" />
-                <field field_ref="wake_h" level="10" />
-                <field field_ref="wake_s" level="10" />
-                <field field_ref="plulth" level="10" />
-                <field field_ref="plulst" level="10" />
-                <field field_ref="lmaxth" level="10" />
-                <field field_ref="ftime_th" level="10" />
-                <field field_ref="f0_th" level="10" />
-                <field field_ref="zmax_th" level="10" />
-                <field field_ref="rsut4co2" level="10" />
-                <field field_ref="rlut4co2" level="10" />
-                <field field_ref="rsutcs4co2" level="10" />
-                <field field_ref="rlutcs4co2" level="10" />
-            </field_group>
-
-            <!-- VARS 3D -->
-            <field_group operation="average" freq_op="1ts" axis_ref="presnivs_histLES">
-                <field field_ref="cldtau" level="10" />
-                <field field_ref="cldemi" level="10" />
-                <field field_ref="tke_max" level="10" operation="maximum" />
-                <field field_ref="kz" level="10" />
-                <field field_ref="kz_max" level="10" operation="maximum" />
-                <field field_ref="concso4" level="10" />
-                <field field_ref="concoa" level="10" />
-                <field field_ref="concbc" level="10" />
-                <field field_ref="concss" level="10" />
-                <field field_ref="concdust" level="10" />
-                <field field_ref="ec550aer" level="10" />
-                <field field_ref="lwcon" level="10" />
-                <field field_ref="iwcon" level="10" />
-                <field field_ref="temp" level="10" />
-                <field field_ref="theta" level="10" />
-                <field field_ref="ovap" level="10" />
-                <field field_ref="ovapinit" level="10" />
-                <field field_ref="oliq" level="10" />
-                <field field_ref="geop" level="10" />
-                <field field_ref="vitu" level="10" />
-                <field field_ref="vitv" level="10" />
-                <field field_ref="vitw" level="10" />
-                <field field_ref="pres" level="10" />
-                <field field_ref="paprs" level="10" />
-                <field field_ref="mass" level="10" />
-                <field field_ref="zfull" level="10" />
-                <field field_ref="zhalf" level="10" />
-                <field field_ref="rneb" level="10" />
-                <field field_ref="rnebcon" level="10" />
-                <field field_ref="rnebls" level="10" />
-                <field field_ref="rhum" level="10" />
-                <field field_ref="ozone" level="10" />
-                <field field_ref="ozone_daylight" level="10" />
-                <field field_ref="upwd" level="10" />
-                <field field_ref="dtphy" level="10" />
-                <field field_ref="dqphy" level="10" />
-                <field field_ref="pr_con_l" level="10" />
-                <field field_ref="pr_con_i" level="10" />
-                <field field_ref="pr_lsc_l" level="10" />
-                <field field_ref="pr_lsc_i" level="10" />
-                <field field_ref="re" level="10" />
-                <field field_ref="fl" level="10" />
-                <field field_ref="scdnc" level="10" />
-                <field field_ref="reffclws" level="10" />
-                <field field_ref="reffclwc" level="10" />
-                <field field_ref="lcc3d" level="10" />
-                <field field_ref="lcc3dcon" level="10" />
-                <field field_ref="lcc3dstra" level="10" />
-                <field field_ref="clwcon" level="10" />
-                <field field_ref="Ma" level="10" />
-                <field field_ref="dnwd" level="10" />
-                <field field_ref="dnwd0" level="10" />
-                <field field_ref="mc" level="10" />
-                <field field_ref="dtdyn" level="10" />
-                <field field_ref="dqdyn" level="10" />
-                <field field_ref="dudyn" level="10" />
-                <field field_ref="dvdyn" level="10" />
-                <field field_ref="dtcon" level="10" />
-                <field field_ref="ducon" level="10" />
-                <field field_ref="dvcon" level="10" />
-                <field field_ref="dqcon" level="10" />
-                <field field_ref="dtwak" level="10" />
-                <field field_ref="dqwak" level="10" />
-                <field field_ref="wake_deltat" level="10" />
-                <field field_ref="wake_deltaq" level="10" />
-                <field field_ref="wake_omg" level="10" />
-                <field field_ref="wdtrainA" level="1" />
-                <field field_ref="wdtrainM" level="1" />
-                <field field_ref="Vprecip" level="10" />
-                <field field_ref="ftd" level="10" />
-                <field field_ref="fqd" level="10" />
-                <field field_ref="dtlsc" level="10" />
-                <field field_ref="dtlschr" level="10" />
-                <field field_ref="dqlsc" level="10" />
-                <field field_ref="beta_prec" level="10" />
-                <field field_ref="dtvdf" level="10" />
-                <field field_ref="dtdis" level="10" />
-                <field field_ref="dqvdf" level="10" />
-                <field field_ref="dteva" level="10" />
-                <field field_ref="dqeva" level="10" />
-                <field field_ref="dqlscth" level="10" />
-                <field field_ref="dqlscst" level="10" />
-                <field field_ref="dtlscth" level="10" />
-                <field field_ref="dtlscst" level="10" />
-                <field field_ref="ptconvth" level="10" />
-                <field field_ref="ptconv" level="10" />
-                <field field_ref="ratqs" level="10" />
-                <field field_ref="dtthe" level="10" />
-                <field field_ref="f_th" level="10" />
-                <field field_ref="e_th" level="10" />
-                <field field_ref="w_th" level="10" />
-                <field field_ref="lambda_th" level="10" />
-                <field field_ref="q_th" level="10" />
-                <field field_ref="a_th" level="10" />
-                <field field_ref="d_th" level="10" />
-                <field field_ref="dqthe" level="10" />
-                <field field_ref="dtajs" level="10" />
-                <field field_ref="dqajs" level="10" />
-                <field field_ref="dtswr" level="10" />
-                <field field_ref="dtsw0" level="10" />
-                <field field_ref="dtlwr" level="10" />
-                <field field_ref="dtlw0" level="10" />
-                <field field_ref="dtec" level="10" />
-                <field field_ref="duvdf" level="10" />
-                <field field_ref="dvvdf" level="10" />
-                <field field_ref="duoro" level="10" />
-                <field field_ref="dvoro" level="10" />
-                <field field_ref="dulif" level="10" />
-                <field field_ref="dvlif" level="10" />
-                <field field_ref="duhin" level="10" />
-                <field field_ref="dvhin" level="10" />
-                <field field_ref="dtoro" level="10" />
-                <field field_ref="dtlif" level="10" />
-                <field field_ref="dthin" level="10" />
-                <field field_ref="rsu" level="10" />
-                <field field_ref="rsd" level="10" />
-                <field field_ref="rlu" level="10" />
-                <field field_ref="rld" level="10" />
-                <field field_ref="rsucs" level="10" />
-                <field field_ref="rsdcs" level="10" />
-                <field field_ref="rlucs" level="10" />
-                <field field_ref="rldcs" level="10" />
-                <field field_ref="tnt" level="10" />
-                <field field_ref="tntc" level="10" />
-                <field field_ref="tntr" level="10" />
-                <field field_ref="tntscpbl" level="10" />
-                <field field_ref="tnhus" level="10" />
-                <field field_ref="tnhusc" level="10" />
-                <field field_ref="tnhusscpbl" level="10" />
-                <field field_ref="evu" level="10" />
-                <field field_ref="h2o" level="10" />
-                <field field_ref="mcd" level="10" />
-                <field field_ref="dmc" level="10" />
-                <field field_ref="ref_liq" level="10" />
-                <field field_ref="ref_ice" level="10" />
-                <field field_ref="rsu4co2" level="10" />
-                <field field_ref="rlu4co2" level="10" />
-                <field field_ref="rsucs4co2" level="10" />
-                <field field_ref="rlucs4co2" level="10" />
-                <field field_ref="rsd4co2" level="10" />
-                <field field_ref="rld4co2" level="10" />
-                <field field_ref="rsdcs4co2" level="10" />
-                <field field_ref="rldcs4co2" level="10" />
-            </field_group>
-        </file>
-    </file_group>
-</file_definition>
Index: DZ5/branches/testing/DefLists/iodef_file_histday.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/iodef_file_histday.xml	(revision 2055)
+++ 	(revision )
@@ -1,510 +1,0 @@
-<file_definition>
-    <file_group id="defile">
-        <file id="histday" name="Xhistday" output_freq="1d" output_level="5" enabled=".FALSE.">
-            <!-- VARS 2D -->
-            <field_group operation="average" freq_op="1ts">
-                <field field_ref="Ap" level="1" />
-                <field field_ref="Bp" level="1" />
-                <field field_ref="Alt" level="1" />
-                <field field_ref="phis" level="1" />
-                <field field_ref="aire" level="1"        operation="once" />
-                <field field_ref="contfracATM" level="1" operation="once" />
-                <field field_ref="contfracOR" level="1" />
-                <field field_ref="aireTER" level="10" />
-                <field field_ref="flat" level="1" />
-                <field field_ref="slp" level="1" />
-                <field field_ref="tsol" level="1" />
-                <field field_ref="t2m" level="1" />
-                <field field_ref="t2m_min" level="1" operation="minimum" />
-                <field field_ref="t2m_max" level="1" operation="maximum" />
-                <field field_ref="t2m_ter" level="6" />
-                <field field_ref="t2m_lic" level="6" />
-                <field field_ref="t2m_oce" level="6" />
-                <field field_ref="t2m_sic" level="6" />
-                <field field_ref="wind10m" level="1" />
-                <field field_ref="wind10max" level="1" />
-                <field field_ref="sicf" level="1" />
-                <field field_ref="q2m" level="1" />
-                <field field_ref="ustar" level="1" />
-                <field field_ref="u10m" level="1" />
-                <field field_ref="v10m" level="1" />
-                <field field_ref="psol" level="1" />
-                <field field_ref="qsurf" level="10" />
-                <field field_ref="ustar_ter" level="6" />
-                <field field_ref="ustar_lic" level="6" />
-                <field field_ref="ustar_oce" level="6" />
-                <field field_ref="ustar_sic" level="6" />
-                <field field_ref="wstar_ter" level="6" />
-                <field field_ref="wstar_lic" level="6" />
-                <field field_ref="wstar_oce" level="6" />
-                <field field_ref="wstar_sic" level="6" />
-                <field field_ref="wstar" level="5" />
-                <field field_ref="u10m_ter" level="6" />
-                <field field_ref="u10m_lic" level="6" />
-                <field field_ref="u10m_oce" level="6" />
-                <field field_ref="u10m_sic" level="6" />
-                <field field_ref="v10m_ter" level="6" />
-                <field field_ref="v10m_lic" level="6" />
-                <field field_ref="v10m_oce" level="6" />
-                <field field_ref="v10m_sic" level="6" />
-                <field field_ref="qsol" level="10" />
-                <field field_ref="ndayrain" level="10" operation="instant" />
-                <field field_ref="precip" level="1" />
-                <field field_ref="plul" level="1" />
-                <field field_ref="pluc" level="1" />
-                <field field_ref="snow" level="1" />
-                <field field_ref="evap" level="1" />
-                <field field_ref="evap_ter" level="6" />
-                <field field_ref="evap_lic" level="6" />
-                <field field_ref="evap_oce" level="6" />
-                <field field_ref="evap_sic" level="6" />
-                <field field_ref="msnow" level="10" />
-                <field field_ref="fsnow" level="10" />
-                <field field_ref="tops" level="1" />
-                <field field_ref="tops0" level="5" />
-                <field field_ref="topl" level="1" />
-                <field field_ref="topl0" level="5" />
-                <field field_ref="SWupTOA" level="4" />
-                <field field_ref="SWupTOAclr" level="4" />
-                <field field_ref="SWdnTOA" level="4" />
-                <field field_ref="SWdnTOAclr" level="4" />
-                <field field_ref="nettop" level="4" />
-                <field field_ref="SWup200" level="10" />
-                <field field_ref="SWup200clr" level="1" />
-                <field field_ref="SWdn200" level="10" />
-                <field field_ref="SWdn200clr" level="1" />
-                <field field_ref="LWup200" level="10" />
-                <field field_ref="LWup200clr" level="10" />
-                <field field_ref="LWdn200" level="10" />
-                <field field_ref="LWdn200clr" level="10" />
-                <field field_ref="sols" level="1" />
-                <field field_ref="sols0" level="5" />
-                <field field_ref="soll" level="1" />
-                <field field_ref="soll0" level="5" />
-                <field field_ref="radsol" level="7" />
-                <field field_ref="SWupSFC" level="4" />
-                <field field_ref="SWupSFCclr" level="4" />
-                <field field_ref="SWdnSFC" level="1" />
-                <field field_ref="SWdnSFCclr" level="4" />
-                <field field_ref="LWupSFC" level="4" />
-                <field field_ref="LWupSFCclr" level="4" />
-                <field field_ref="LWdnSFC" level="4" />
-                <field field_ref="LWdnSFCclr" level="4" />
-                <field field_ref="bils" level="2" />
-                <field field_ref="bils_tke" level="2" />
-                <field field_ref="bils_diss" level="2" />
-                <field field_ref="bils_ec" level="2" />
-                <field field_ref="bils_kinetic" level="2" />
-                <field field_ref="bils_enthalp" level="2" />
-                <field field_ref="bils_latent" level="2" />
-                <field field_ref="sens" level="1" />
-                <field field_ref="fder" level="2" />
-                <field field_ref="ffonte" level="10" />
-                <field field_ref="fqcalving" level="10" />
-                <field field_ref="fqfonte" level="10" />
-                <field field_ref="taux" level="10" />
-                <field field_ref="tauy" level="10" />
-                <field field_ref="taux_ter" level="6" />
-                <field field_ref="taux_lic" level="6" />
-                <field field_ref="taux_oce" level="6" />
-                <field field_ref="taux_sic" level="6" />
-                <field field_ref="tauy_ter" level="6" />
-                <field field_ref="tauy_lic" level="6" />
-                <field field_ref="tauy_oce" level="6" />
-                <field field_ref="tauy_sic" level="6" />
-                <field field_ref="pourc_ter" level="7" />
-                <field field_ref="pourc_lic" level="7" />
-                <field field_ref="pourc_oce" level="7" />
-                <field field_ref="pourc_sic" level="7" />
-                <field field_ref="fract_ter" level="6" />
-                <field field_ref="fract_lic" level="6" />
-                <field field_ref="fract_oce" level="6" />
-                <field field_ref="fract_sic" level="6" />
-                <field field_ref="tsol_ter" level="6" />
-                <field field_ref="tsol_lic" level="6" />
-                <field field_ref="tsol_oce" level="6" />
-                <field field_ref="tsol_sic" level="6" />
-                <field field_ref="evappot_ter" level="6" />
-                <field field_ref="evappot_lic" level="6" />
-                <field field_ref="evappot_oce" level="6" />
-                <field field_ref="evappot_sic" level="6" />
-                <field field_ref="sens_ter" level="6" />
-                <field field_ref="sens_lic" level="6" />
-                <field field_ref="sens_oce" level="6" />
-                <field field_ref="sens_sic" level="6" />
-                <field field_ref="lat_ter" level="6" />
-                <field field_ref="lat_lic" level="6" />
-                <field field_ref="lat_oce" level="6" />
-                <field field_ref="lat_sic" level="6" />
-                <field field_ref="flw_ter" level="10" />
-                <field field_ref="flw_lic" level="10" />
-                <field field_ref="flw_oce" level="10" />
-                <field field_ref="flw_sic" level="10" />
-                <field field_ref="fsw_ter" level="10" />
-                <field field_ref="fsw_lic" level="10" />
-                <field field_ref="fsw_oce" level="10" />
-                <field field_ref="fsw_sic" level="10" />
-                <field field_ref="wbils_ter" level="10" />
-                <field field_ref="wbils_lic" level="10" />
-                <field field_ref="wbils_oce" level="10" />
-                <field field_ref="wbils_sic" level="10" />
-                <field field_ref="wbilo_ter" level="10" />
-                <field field_ref="wbilo_lic" level="10" />
-                <field field_ref="wbilo_oce" level="10" />
-                <field field_ref="wbilo_sic" level="10" />
-                <field field_ref="cdrm" level="10" />
-                <field field_ref="cdrh" level="10" />
-                <field field_ref="cldl" level="1" />
-                <field field_ref="cldm" level="1" />
-                <field field_ref="cldh" level="1" />
-                <field field_ref="cldt" level="1" />
-                <field field_ref="cldq" level="1" />
-                <field field_ref="lwp" level="5" />
-                <field field_ref="iwp" level="5" />
-                <field field_ref="ue" level="10" />
-                <field field_ref="ve" level="10" />
-                <field field_ref="uq" level="10" />
-                <field field_ref="vq" level="10" />
-                <field field_ref="cape" level="10" />
-                <field field_ref="pbase" level="5" />
-                <field field_ref="ptop" level="5" />
-                <field field_ref="fbase" level="10" />
-                <field field_ref="plcl" level="10" />
-                <field field_ref="plfc" level="10" />
-                <field field_ref="wbeff" level="10" />
-                <field field_ref="prw" level="1" />
-                <field field_ref="s_pblh" level="10" />
-                <field field_ref="s_pblt" level="10" />
-                <field field_ref="s_lcl" level="10" />
-                <field field_ref="s_therm" level="10" />
-                <field field_ref="slab_bils_oce" level="1" />
-                <field field_ref="ale_bl" level="1" />
-                <field field_ref="alp_bl" level="1" />
-                <field field_ref="ale_wk" level="1" />
-                <field field_ref="alp_wk" level="1" />
-                <field field_ref="ale" level="1" />
-                <field field_ref="alp" level="1" />
-                <field field_ref="cin" level="1" />
-                <field field_ref="wape" level="1" />
-                <field field_ref="n2" level="1" />
-                <field field_ref="s2" level="1" />
-                <field field_ref="proba_notrig" level="1" />
-                <field field_ref="random_notrig" level="1" />
-                <field field_ref="ale_bl_stat" level="1" />
-                <field field_ref="ale_bl_trig" level="1" />
-                <field field_ref="alp_bl_det" level="1" />
-                <field field_ref="alp_bl_fluct_m" level="1" />
-                <field field_ref="alp_bl_fluct_tke" level="1" />
-                <field field_ref="alp_bl_conv" level="1" />
-                <field field_ref="alp_bl_stat" level="1" />
-
-                <field_group operation="instant">
-                    <field field_ref="u850" level="7" />
-                    <field field_ref="u700" level="7" />
-                    <field field_ref="u500" level="7" />
-                    <field field_ref="u200" level="7" />
-                    <field field_ref="u100" level="7" />
-                    <field field_ref="u50" level="7" />
-                    <field field_ref="u10" level="7" />
-                    <field field_ref="v850" level="7" />
-                    <field field_ref="v700" level="7" />
-                    <field field_ref="v500" level="7" />
-                    <field field_ref="v200" level="7" />
-                    <field field_ref="v100" level="7" />
-                    <field field_ref="v50" level="7" />
-                    <field field_ref="v10" level="7" />
-                    <field field_ref="w850" level="7" />
-                    <field field_ref="w700" level="7" />
-                    <field field_ref="w500" level="7" />
-                    <field field_ref="w200" level="7" />
-                    <field field_ref="w100" level="7" />
-                    <field field_ref="w50" level="7" />
-                    <field field_ref="w10" level="7" />
-                    <field field_ref="t850" level="7" />
-                    <field field_ref="t700" level="7" />
-                    <field field_ref="t500" level="7" />
-                    <field field_ref="t200" level="7" />
-                    <field field_ref="t100" level="7" />
-                    <field field_ref="t50" level="7" />
-                    <field field_ref="t10" level="7" />
-                    <field field_ref="q850" level="7" />
-                    <field field_ref="q700" level="7" />
-                    <field field_ref="q500" level="7" />
-                    <field field_ref="q200" level="7" />
-                    <field field_ref="q100" level="7" />
-                    <field field_ref="q50" level="7" />
-                    <field field_ref="q10" level="7" />
-                    <field field_ref="z850" level="7" />
-                    <field field_ref="z700" level="7" />
-                    <field field_ref="z500" level="7" />
-                    <field field_ref="z200" level="7" />
-                    <field field_ref="z100" level="7" />
-                    <field field_ref="z50" level="7" />
-                    <field field_ref="z10" level="7" />
-                </field_group>
-
-                <field field_ref="t_oce_sic" level="10" />
-                <field field_ref="weakinv" level="1" />
-                <field field_ref="dthmin" level="1" />
-                <field field_ref="u10_ter" level="4" />
-                <field field_ref="u10_lic" level="4" />
-                <field field_ref="u10_oce" level="4" />
-                <field field_ref="u10_sic" level="4" />
-                <field field_ref="v10_ter" level="4" />
-                <field field_ref="v10_lic" level="4" />
-                <field field_ref="v10_oce" level="4" />
-                <field field_ref="v10_sic" level="4" />
-                <field field_ref="rh2m" level="5" />
-                <field field_ref="rh2m_min" level="5" operation="minimum" />
-                <field field_ref="rh2m_max" level="5" operation="maximum" />
-                <field field_ref="qsat2m" level="5" />
-                <field field_ref="tpot" level="5" />
-                <field field_ref="tpote" level="5" />
-                <field field_ref="tke" level="10" />
-                <field field_ref="tke_ter" level="4" />
-                <field field_ref="tke_lic" level="4" />
-                <field field_ref="tke_oce" level="4" />
-                <field field_ref="tke_sic" level="4" />
-                <field field_ref="tke_max_ter" level="4" operation="maximum" />
-                <field field_ref="tke_max_lic" level="4" operation="maximum" />
-                <field field_ref="tke_max_oce" level="4" operation="maximum" />
-                <field field_ref="tke_max_sic" level="4" operation="maximum" />
-                <field field_ref="SWnetOR" level="10" />
-                <field field_ref="SWdownOR" level="10" />
-                <field field_ref="LWdownOR" level="10" />
-                <field field_ref="snowl" level="1" />
-                <field field_ref="cape_max" level="1" operation="maximum" />
-                <field field_ref="solldown" level="1" />
-                <field field_ref="dtsvdfo" level="10" />
-                <field field_ref="dtsvdft" level="10" />
-                <field field_ref="dtsvdfg" level="10" />
-                <field field_ref="dtsvdfi" level="10" />
-                <field field_ref="rugs" level="10" />
-                <field field_ref="topswad" level="10" />
-                <field field_ref="topswad0" level="10" />
-                <field field_ref="topswai" level="10" />
-                <field field_ref="solswad" level="10" />
-                <field field_ref="solswad0" level="10" />
-                <field field_ref="solswai" level="10" />
-                <field field_ref="OD550_ASBCM" level="6" />
-                <field field_ref="OD550_ASPOMM" level="6" />
-                <field field_ref="OD550_ASSO4M" level="6" />
-                <field field_ref="OD550_CSSO4M" level="6" />
-                <field field_ref="OD550_SSSSM" level="6" />
-                <field field_ref="OD550_ASSSM" level="6" />
-                <field field_ref="OD550_CSSSM" level="6" />
-                <field field_ref="OD550_CIDUSTM" level="6" />
-                <field field_ref="OD550_AIBCM" level="6" />
-                <field field_ref="OD550_AIPOMM" level="6" />
-                <field field_ref="OD550_STRAT" level="2" />
-                <field field_ref="od550aer" level="6" />
-                <field field_ref="od865aer" level="6" />
-                <field field_ref="absvisaer" level="6" />
-                <field field_ref="od550lt1aer" level="6" />
-                <field field_ref="sconcso4" level="6" />
-                <field field_ref="sconcoa" level="6" />
-                <field field_ref="sconcbc" level="6" />
-                <field field_ref="sconcss" level="6" />
-                <field field_ref="sconcdust" level="6" />
-                <field field_ref="loadso4" level="6" />
-                <field field_ref="loadoa" level="6" />
-                <field field_ref="loadbc" level="6" />
-                <field field_ref="loadss" level="6" />
-                <field field_ref="loaddust" level="6" />
-                <field field_ref="swtoaas_nat" level="6" />
-                <field field_ref="swsrfas_nat" level="6" />
-                <field field_ref="swtoacs_nat" level="6" />
-                <field field_ref="swsrfcs_nat" level="6" />
-                <field field_ref="swtoaas_ant" level="6" />
-                <field field_ref="swsrfas_ant" level="6" />
-                <field field_ref="swtoacs_ant" level="6" />
-                <field field_ref="swsrfcs_ant" level="6" />
-                <field field_ref="swtoacf_nat" level="6" />
-                <field field_ref="swsrfcf_nat" level="6" />
-                <field field_ref="swtoacf_ant" level="6" />
-                <field field_ref="swsrfcf_ant" level="6" />
-                <field field_ref="swtoacf_zero" level="6" />
-                <field field_ref="swsrfcf_zero" level="6" />
-                <field field_ref="cldncl" level="6" />
-                <field field_ref="reffclwtop" level="6" />
-                <field field_ref="cldnvi" level="6" />
-                <field field_ref="lcc" level="6" />
-                <field field_ref="wvapp" level="10" />
-                <field field_ref="albe_ter" level="7" />
-                <field field_ref="albe_lic" level="7" />
-                <field field_ref="albe_oce" level="7" />
-                <field field_ref="albe_sic" level="7" />
-                <field field_ref="ages_ter" level="10" />
-                <field field_ref="ages_lic" level="10" />
-                <field field_ref="ages_oce" level="10" />
-                <field field_ref="ages_sic" level="10" />
-                <field field_ref="rugs_ter" level="6" />
-                <field field_ref="rugs_lic" level="6" />
-                <field field_ref="rugs_oce" level="6" />
-                <field field_ref="rugs_sic" level="6" />
-                <field field_ref="alb1" level="10" />
-                <field field_ref="alb2" level="10" />
-                <field field_ref="ftime_con" level="10" operation="instant" />
-                <field field_ref="wake_h" level="5" />
-                <field field_ref="wake_s" level="5" />
-                <field field_ref="plulth" level="10" />
-                <field field_ref="plulst" level="10" />
-                <field field_ref="lmaxth" level="10" />
-                <field field_ref="ftime_th" level="10" />
-                <field field_ref="f0_th" level="10" />
-                <field field_ref="zmax_th" level="4" />
-                <field field_ref="rsut4co2" level="10" />
-                <field field_ref="rlut4co2" level="10" />
-                <field field_ref="rsutcs4co2" level="10" />
-                <field field_ref="rlutcs4co2" level="10" />
-            </field_group>
-
-            <!-- VARS 3D -->
-            <field_group operation="average" freq_op="1ts" axis_ref="presnivs_histday">
-                <field field_ref="cldtau" level="5" />
-                <field field_ref="cldemi" level="5" />
-                <field field_ref="tke_max" level="10" operation="maximum" />
-                <field field_ref="kz" level="10" />
-                <field field_ref="kz_max" level="10" operation="maximum" />
-                <field field_ref="concso4" level="6" />
-                <field field_ref="concoa" level="6" />
-                <field field_ref="concbc" level="6" />
-                <field field_ref="concss" level="6" />
-                <field field_ref="concdust" level="6" />
-                <field field_ref="ec550aer" level="6" />
-                <field field_ref="lwcon" level="5" />
-                <field field_ref="iwcon" level="5" />
-                <field field_ref="temp" level="3" />
-                <field field_ref="theta" level="3" />
-                <field field_ref="ovap" level="3" />
-                <field field_ref="ovapinit" level="10" />
-                <field field_ref="oliq" level="3" />
-                <field field_ref="geop" level="3" />
-                <field field_ref="vitu" level="3" />
-                <field field_ref="vitv" level="3" />
-                <field field_ref="vitw" level="3" />
-                <field field_ref="pres" level="3" />
-                <field field_ref="paprs" level="3" />
-                <field field_ref="mass" level="3" />
-                <field field_ref="zfull" level="3" />
-                <field field_ref="zhalf" level="3" />
-                <field field_ref="rneb" level="5" />
-                <field field_ref="rnebcon" level="5" />
-                <field field_ref="rnebls" level="5" />
-                <field field_ref="rhum" level="5" />
-                <field field_ref="ozone" level="10" />
-                <field field_ref="ozone_daylight" level="10" />
-                <field field_ref="upwd" level="10" />
-                <field field_ref="dtphy" level="10" />
-                <field field_ref="dqphy" level="10" />
-                <field field_ref="pr_con_l" level="10" />
-                <field field_ref="pr_con_i" level="10" />
-                <field field_ref="pr_lsc_l" level="10" />
-                <field field_ref="pr_lsc_i" level="10" />
-                <field field_ref="re" level="10" />
-                <field field_ref="fl" level="10" />
-                <field field_ref="scdnc" level="6" />
-                <field field_ref="reffclws" level="6" />
-                <field field_ref="reffclwc" level="6" />
-                <field field_ref="lcc3d" level="6" />
-                <field field_ref="lcc3dcon" level="6" />
-                <field field_ref="lcc3dstra" level="6" />
-                <field field_ref="clwcon" level="10" />
-                <field field_ref="Ma" level="10" />
-                <field field_ref="dnwd" level="10" />
-                <field field_ref="dnwd0" level="10" />
-                <field field_ref="mc" level="5" />
-                <field field_ref="dtdyn" level="10" />
-                <field field_ref="dqdyn" level="10" />
-                <field field_ref="dudyn" level="10" />
-                <field field_ref="dvdyn" level="10" />
-                <field field_ref="dtcon" level="10" />
-                <field field_ref="ducon" level="10" />
-                <field field_ref="dvcon" level="10" />
-                <field field_ref="dqcon" level="10" />
-                <field field_ref="dtwak" level="5" />
-                <field field_ref="dqwak" level="5" />
-                <field field_ref="wake_deltat" level="5" />
-                <field field_ref="wake_deltaq" level="5" />
-                <field field_ref="wake_omg" level="5" />
-                <field field_ref="wdtrainA" level="1" />
-                <field field_ref="wdtrainM" level="1" />
-                <field field_ref="Vprecip" level="10" />
-                <field field_ref="ftd" level="5" />
-                <field field_ref="fqd" level="5" />
-                <field field_ref="dtlsc" level="10" />
-                <field field_ref="dtlschr" level="10" />
-                <field field_ref="dqlsc" level="10" />
-                <field field_ref="beta_prec" level="10" />
-                <field field_ref="dtvdf" level="10" />
-                <field field_ref="dtdis" level="10" />
-                <field field_ref="dqvdf" level="10" />
-                <field field_ref="dteva" level="10" />
-                <field field_ref="dqeva" level="10" />
-                <field field_ref="dqlscth" level="10" />
-                <field field_ref="dqlscst" level="10" />
-                <field field_ref="dtlscth" level="10" />
-                <field field_ref="dtlscst" level="10" />
-                <field field_ref="ptconvth" level="10" />
-                <field field_ref="ptconv" level="10" />
-                <field field_ref="ratqs" level="10" />
-                <field field_ref="dtthe" level="10" />
-                <field field_ref="f_th" level="10" />
-                <field field_ref="e_th" level="10" />
-                <field field_ref="w_th" level="10" />
-                <field field_ref="lambda_th" level="10" />
-                <field field_ref="q_th" level="10" />
-                <field field_ref="a_th" level="10" />
-                <field field_ref="d_th" level="10" />
-                <field field_ref="dqthe" level="10" />
-                <field field_ref="dtajs" level="10" />
-                <field field_ref="dqajs" level="10" />
-                <field field_ref="dtswr" level="10" />
-                <field field_ref="dtsw0" level="10" />
-                <field field_ref="dtlwr" level="10" />
-                <field field_ref="dtlw0" level="10" />
-                <field field_ref="dtec" level="10" />
-                <field field_ref="duvdf" level="10" />
-                <field field_ref="dvvdf" level="10" />
-                <field field_ref="duoro" level="10" />
-                <field field_ref="dvoro" level="10" />
-                <field field_ref="dulif" level="10" />
-                <field field_ref="dvlif" level="10" />
-                <field field_ref="duhin" level="10" />
-                <field field_ref="dvhin" level="10" />
-                <field field_ref="dtoro" level="10" />
-                <field field_ref="dtlif" level="10" />
-                <field field_ref="dthin" level="10" />
-                <field field_ref="rsu" level="10" />
-                <field field_ref="rsd" level="10" />
-                <field field_ref="rlu" level="10" />
-                <field field_ref="rld" level="10" />
-                <field field_ref="rsucs" level="10" />
-                <field field_ref="rsdcs" level="10" />
-                <field field_ref="rlucs" level="10" />
-                <field field_ref="rldcs" level="10" />
-                <field field_ref="tnt" level="10" />
-                <field field_ref="tntc" level="10" />
-                <field field_ref="tntr" level="10" />
-                <field field_ref="tntscpbl" level="10" />
-                <field field_ref="tnhus" level="10" />
-                <field field_ref="tnhusc" level="10" />
-                <field field_ref="tnhusscpbl" level="10" />
-                <field field_ref="evu" level="10" />
-                <field field_ref="h2o" level="10" />
-                <field field_ref="mcd" level="10" />
-                <field field_ref="dmc" level="10" />
-                <field field_ref="ref_liq" level="10" />
-                <field field_ref="ref_ice" level="10" />
-                <field field_ref="rsu4co2" level="10" />
-                <field field_ref="rlu4co2" level="10" />
-                <field field_ref="rsucs4co2" level="10" />
-                <field field_ref="rlucs4co2" level="10" />
-                <field field_ref="rsd4co2" level="10" />
-                <field field_ref="rld4co2" level="10" />
-                <field field_ref="rsdcs4co2" level="10" />
-                <field field_ref="rldcs4co2" level="10" />
-            </field_group>
-        </file>
-    </file_group>
-</file_definition>
Index: DZ5/branches/testing/DefLists/iodef_file_histhf.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/iodef_file_histhf.xml	(revision 2055)
+++ 	(revision )
@@ -1,510 +1,0 @@
-<file_definition>
-    <file_group id="defile">
-        <file id="histhf" name="Xhisthf" output_freq="1h" output_level="5" enabled=".FALSE.">
-            <!-- VARS 2D -->
-            <field_group operation="average" freq_op="1ts">
-                <field field_ref="Ap" level="1" />
-                <field field_ref="Bp" level="1" />
-                <field field_ref="Alt" level="1" />
-                <field field_ref="phis" level="5" />
-                <field field_ref="aire" level="10" operation="once" />
-                <field field_ref="contfracATM" level="10" operation="once" />
-                <field field_ref="contfracOR" level="10" />
-                <field field_ref="aireTER" level="10" />
-                <field field_ref="flat" level="10" />
-                <field field_ref="slp" level="10" />
-                <field field_ref="tsol" level="5" />
-                <field field_ref="t2m" level="5" />
-                <field field_ref="t2m_min" level="10" operation="minimum" />
-                <field field_ref="t2m_max" level="10" operation="maximum" />
-                <field field_ref="t2m_ter" level="10" />
-                <field field_ref="t2m_lic" level="10" />
-                <field field_ref="t2m_oce" level="10" />
-                <field field_ref="t2m_sic" level="10" />
-                <field field_ref="wind10m" level="10" />
-                <field field_ref="wind10max" level="10" />
-                <field field_ref="sicf" level="10" />
-                <field field_ref="q2m" level="5" />
-                <field field_ref="ustar" level="5" />
-                <field field_ref="u10m" level="5" />
-                <field field_ref="v10m" level="5" />
-                <field field_ref="psol" level="5" />
-                <field field_ref="qsurf" level="10" />
-                <field field_ref="ustar_ter" level="10" />
-                <field field_ref="ustar_lic" level="10" />
-                <field field_ref="ustar_oce" level="10" />
-                <field field_ref="ustar_sic" level="10" />
-                <field field_ref="wstar_ter" level="10" />
-                <field field_ref="wstar_lic" level="10" />
-                <field field_ref="wstar_oce" level="10" />
-                <field field_ref="wstar_sic" level="10" />
-                <field field_ref="wstar" level="10" />
-                <field field_ref="u10m_ter" level="10" />
-                <field field_ref="u10m_lic" level="10" />
-                <field field_ref="u10m_oce" level="10" />
-                <field field_ref="u10m_sic" level="10" />
-                <field field_ref="v10m_ter" level="10" />
-                <field field_ref="v10m_lic" level="10" />
-                <field field_ref="v10m_oce" level="10" />
-                <field field_ref="v10m_sic" level="10" />
-                <field field_ref="qsol" level="10" />
-                <field field_ref="ndayrain" level="10" operation="instant" />
-                <field field_ref="precip" level="10" />
-                <field field_ref="plul" level="10" />
-                <field field_ref="pluc" level="10" />
-                <field field_ref="snow" level="10" />
-                <field field_ref="evap" level="10" />
-                <field field_ref="evap_ter" level="10" />
-                <field field_ref="evap_lic" level="10" />
-                <field field_ref="evap_oce" level="10" />
-                <field field_ref="evap_sic" level="10" />
-                <field field_ref="msnow" level="10" />
-                <field field_ref="fsnow" level="10" />
-                <field field_ref="tops" level="10" />
-                <field field_ref="tops0" level="10" />
-                <field field_ref="topl" level="5" />
-                <field field_ref="topl0" level="10" />
-                <field field_ref="SWupTOA" level="10" />
-                <field field_ref="SWupTOAclr" level="10" />
-                <field field_ref="SWdnTOA" level="10" />
-                <field field_ref="SWdnTOAclr" level="10" />
-                <field field_ref="nettop" level="10" />
-                <field field_ref="SWup200" level="10" />
-                <field field_ref="SWup200clr" level="10" />
-                <field field_ref="SWdn200" level="10" />
-                <field field_ref="SWdn200clr" level="10" />
-                <field field_ref="LWup200" level="10" />
-                <field field_ref="LWup200clr" level="10" />
-                <field field_ref="LWdn200" level="10" />
-                <field field_ref="LWdn200clr" level="10" />
-                <field field_ref="sols" level="10" />
-                <field field_ref="sols0" level="10" />
-                <field field_ref="soll" level="10" />
-                <field field_ref="soll0" level="10" />
-                <field field_ref="radsol" level="10" />
-                <field field_ref="SWupSFC" level="10" />
-                <field field_ref="SWupSFCclr" level="10" />
-                <field field_ref="SWdnSFC" level="10" />
-                <field field_ref="SWdnSFCclr" level="10" />
-                <field field_ref="LWupSFC" level="10" />
-                <field field_ref="LWupSFCclr" level="10" />
-                <field field_ref="LWdnSFC" level="10" />
-                <field field_ref="LWdnSFCclr" level="10" />
-                <field field_ref="bils" level="5" />
-                <field field_ref="bils_tke" level="5" />
-                <field field_ref="bils_diss" level="5" />
-                <field field_ref="bils_ec" level="5" />
-                <field field_ref="bils_kinetic" level="5" />
-                <field field_ref="bils_enthalp" level="5" />
-                <field field_ref="bils_latent" level="5" />
-                <field field_ref="sens" level="10" />
-                <field field_ref="fder" level="10" />
-                <field field_ref="ffonte" level="10" />
-                <field field_ref="fqcalving" level="10" />
-                <field field_ref="fqfonte" level="10" />
-                <field field_ref="taux" level="10" />
-                <field field_ref="tauy" level="10" />
-                <field field_ref="taux_ter" level="10" />
-                <field field_ref="taux_lic" level="10" />
-                <field field_ref="taux_oce" level="10" />
-                <field field_ref="taux_sic" level="10" />
-                <field field_ref="tauy_ter" level="10" />
-                <field field_ref="tauy_lic" level="10" />
-                <field field_ref="tauy_oce" level="10" />
-                <field field_ref="tauy_sic" level="10" />
-                <field field_ref="pourc_ter" level="10" />
-                <field field_ref="pourc_lic" level="10" />
-                <field field_ref="pourc_oce" level="10" />
-                <field field_ref="pourc_sic" level="10" />
-                <field field_ref="fract_ter" level="10" />
-                <field field_ref="fract_lic" level="10" />
-                <field field_ref="fract_oce" level="10" />
-                <field field_ref="fract_sic" level="10" />
-                <field field_ref="tsol_ter" level="10" />
-                <field field_ref="tsol_lic" level="10" />
-                <field field_ref="tsol_oce" level="10" />
-                <field field_ref="tsol_sic" level="10" />
-                <field field_ref="evappot_ter" level="10" />
-                <field field_ref="evappot_lic" level="10" />
-                <field field_ref="evappot_oce" level="10" />
-                <field field_ref="evappot_sic" level="10" />
-                <field field_ref="sens_ter" level="7" />
-                <field field_ref="sens_lic" level="7" />
-                <field field_ref="sens_oce" level="7" />
-                <field field_ref="sens_sic" level="7" />
-                <field field_ref="lat_ter" level="7" />
-                <field field_ref="lat_lic" level="7" />
-                <field field_ref="lat_oce" level="7" />
-                <field field_ref="lat_sic" level="7" />
-                <field field_ref="flw_ter" level="10" />
-                <field field_ref="flw_lic" level="10" />
-                <field field_ref="flw_oce" level="10" />
-                <field field_ref="flw_sic" level="10" />
-                <field field_ref="fsw_ter" level="10" />
-                <field field_ref="fsw_lic" level="10" />
-                <field field_ref="fsw_oce" level="10" />
-                <field field_ref="fsw_sic" level="10" />
-                <field field_ref="wbils_ter" level="10" />
-                <field field_ref="wbils_lic" level="10" />
-                <field field_ref="wbils_oce" level="10" />
-                <field field_ref="wbils_sic" level="10" />
-                <field field_ref="wbilo_ter" level="10" />
-                <field field_ref="wbilo_lic" level="10" />
-                <field field_ref="wbilo_oce" level="10" />
-                <field field_ref="wbilo_sic" level="10" />
-                <field field_ref="cdrm" level="10" />
-                <field field_ref="cdrh" level="7" />
-                <field field_ref="cldl" level="10" />
-                <field field_ref="cldm" level="10" />
-                <field field_ref="cldh" level="10" />
-                <field field_ref="cldt" level="10" />
-                <field field_ref="cldq" level="10" />
-                <field field_ref="lwp" level="10" />
-                <field field_ref="iwp" level="10" />
-                <field field_ref="ue" level="10" />
-                <field field_ref="ve" level="10" />
-                <field field_ref="uq" level="10" />
-                <field field_ref="vq" level="10" />
-                <field field_ref="cape" level="10" />
-                <field field_ref="pbase" level="10" />
-                <field field_ref="ptop" level="10" />
-                <field field_ref="fbase" level="10" />
-                <field field_ref="plcl" level="10" />
-                <field field_ref="plfc" level="10" />
-                <field field_ref="wbeff" level="10" />
-                <field field_ref="prw" level="10" />
-                <field field_ref="s_pblh" level="10" />
-                <field field_ref="s_pblt" level="10" />
-                <field field_ref="s_lcl" level="10" />
-                <field field_ref="s_therm" level="10" />
-                <field field_ref="slab_bils_oce" level="10" />
-                <field field_ref="ale_bl" level="10" />
-                <field field_ref="alp_bl" level="10" />
-                <field field_ref="ale_wk" level="10" />
-                <field field_ref="alp_wk" level="10" />
-                <field field_ref="ale" level="10" />
-                <field field_ref="alp" level="10" />
-                <field field_ref="cin" level="10" />
-                <field field_ref="wape" level="10" />
-                <field field_ref="n2" level="6" />
-                <field field_ref="s2" level="6" />
-                <field field_ref="proba_notrig" level="6" />
-                <field field_ref="random_notrig" level="6" />
-                <field field_ref="ale_bl_stat" level="6" />
-                <field field_ref="ale_bl_trig" level="6" />
-                <field field_ref="alp_bl_det" level="10" />
-                <field field_ref="alp_bl_fluct_m" level="10" />
-                <field field_ref="alp_bl_fluct_tke" level="10" />
-                <field field_ref="alp_bl_conv" level="10" />
-                <field field_ref="alp_bl_stat" level="10" />
-
-                <field_group operation="instant">
-                    <field field_ref="u850" level="10" />
-                    <field field_ref="u700" level="10" />
-                    <field field_ref="u500" level="10" />
-                    <field field_ref="u200" level="10" />
-                    <field field_ref="u100" level="10" />
-                    <field field_ref="u50" level="10" />
-                    <field field_ref="u10" level="10" />
-                    <field field_ref="v850" level="10" />
-                    <field field_ref="v700" level="10" />
-                    <field field_ref="v500" level="10" />
-                    <field field_ref="v200" level="10" />
-                    <field field_ref="v100" level="10" />
-                    <field field_ref="v50" level="10" />
-                    <field field_ref="v10" level="10" />
-                    <field field_ref="w850" level="10" />
-                    <field field_ref="w700" level="10" />
-                    <field field_ref="w500" level="10" />
-                    <field field_ref="w200" level="10" />
-                    <field field_ref="w100" level="10" />
-                    <field field_ref="w50" level="10" />
-                    <field field_ref="w10" level="10" />
-                    <field field_ref="t850" level="10" />
-                    <field field_ref="t700" level="10" />
-                    <field field_ref="t500" level="10" />
-                    <field field_ref="t200" level="10" />
-                    <field field_ref="t100" level="10" />
-                    <field field_ref="t50" level="10" />
-                    <field field_ref="t10" level="10" />
-                    <field field_ref="q850" level="10" />
-                    <field field_ref="q700" level="10" />
-                    <field field_ref="q500" level="10" />
-                    <field field_ref="q200" level="10" />
-                    <field field_ref="q100" level="10" />
-                    <field field_ref="q50" level="10" />
-                    <field field_ref="q10" level="10" />
-                    <field field_ref="z850" level="10" />
-                    <field field_ref="z700" level="10" />
-                    <field field_ref="z500" level="10" />
-                    <field field_ref="z200" level="10" />
-                    <field field_ref="z100" level="10" />
-                    <field field_ref="z50" level="10" />
-                    <field field_ref="z10" level="10" />
-                </field_group>
-
-                <field field_ref="t_oce_sic" level="10" />
-                <field field_ref="weakinv" level="10" />
-                <field field_ref="dthmin" level="10" />
-                <field field_ref="u10_ter" level="10" />
-                <field field_ref="u10_lic" level="10" />
-                <field field_ref="u10_oce" level="10" />
-                <field field_ref="u10_sic" level="10" />
-                <field field_ref="v10_ter" level="10" />
-                <field field_ref="v10_lic" level="10" />
-                <field field_ref="v10_oce" level="10" />
-                <field field_ref="v10_sic" level="10" />
-                <field field_ref="rh2m" level="10" />
-                <field field_ref="rh2m_min" level="10" operation="minimum" />
-                <field field_ref="rh2m_max" level="10" operation="maximum" />
-                <field field_ref="qsat2m" level="10" />
-                <field field_ref="tpot" level="10" />
-                <field field_ref="tpote" level="10" />
-                <field field_ref="tke" level="10" />
-                <field field_ref="tke_ter" level="10" />
-                <field field_ref="tke_lic" level="10" />
-                <field field_ref="tke_oce" level="10" />
-                <field field_ref="tke_sic" level="10" />
-                <field field_ref="tke_max_ter" level="10" operation="maximum" />
-                <field field_ref="tke_max_lic" level="10" operation="maximum" />
-                <field field_ref="tke_max_oce" level="10" operation="maximum" />
-                <field field_ref="tke_max_sic" level="10" operation="maximum" />
-                <field field_ref="SWnetOR" level="10" />
-                <field field_ref="SWdownOR" level="10" />
-                <field field_ref="LWdownOR" level="10" />
-                <field field_ref="snowl" level="10" />
-                <field field_ref="cape_max" level="10" operation="maximum" />
-                <field field_ref="solldown" level="10" />
-                <field field_ref="dtsvdfo" level="10" />
-                <field field_ref="dtsvdft" level="10" />
-                <field field_ref="dtsvdfg" level="10" />
-                <field field_ref="dtsvdfi" level="10" />
-                <field field_ref="rugs" level="10" />
-                <field field_ref="topswad" level="10" />
-                <field field_ref="topswad0" level="10" />
-                <field field_ref="topswai" level="10" />
-                <field field_ref="solswad" level="10" />
-                <field field_ref="solswad0" level="10" />
-                <field field_ref="solswai" level="10" />
-                <field field_ref="OD550_ASBCM" level="10" />
-                <field field_ref="OD550_ASPOMM" level="10" />
-                <field field_ref="OD550_ASSO4M" level="10" />
-                <field field_ref="OD550_CSSO4M" level="10" />
-                <field field_ref="OD550_SSSSM" level="10" />
-                <field field_ref="OD550_ASSSM" level="10" />
-                <field field_ref="OD550_CSSSM" level="10" />
-                <field field_ref="OD550_CIDUSTM" level="10" />
-                <field field_ref="OD550_AIBCM" level="10" />
-                <field field_ref="OD550_AIPOMM" level="10" />
-                <field field_ref="OD550_STRAT" level="10" />
-                <field field_ref="od550aer" level="10" />
-                <field field_ref="od865aer" level="10" />
-                <field field_ref="absvisaer" level="10" />
-                <field field_ref="od550lt1aer" level="10" />
-                <field field_ref="sconcso4" level="10" />
-                <field field_ref="sconcoa" level="10" />
-                <field field_ref="sconcbc" level="10" />
-                <field field_ref="sconcss" level="10" />
-                <field field_ref="sconcdust" level="10" />
-                <field field_ref="loadso4" level="10" />
-                <field field_ref="loadoa" level="10" />
-                <field field_ref="loadbc" level="10" />
-                <field field_ref="loadss" level="10" />
-                <field field_ref="loaddust" level="10" />
-                <field field_ref="swtoaas_nat" level="10" />
-                <field field_ref="swsrfas_nat" level="10" />
-                <field field_ref="swtoacs_nat" level="10" />
-                <field field_ref="swsrfcs_nat" level="10" />
-                <field field_ref="swtoaas_ant" level="10" />
-                <field field_ref="swsrfas_ant" level="10" />
-                <field field_ref="swtoacs_ant" level="10" />
-                <field field_ref="swsrfcs_ant" level="10" />
-                <field field_ref="swtoacf_nat" level="10" />
-                <field field_ref="swsrfcf_nat" level="10" />
-                <field field_ref="swtoacf_ant" level="10" />
-                <field field_ref="swsrfcf_ant" level="10" />
-                <field field_ref="swtoacf_zero" level="10" />
-                <field field_ref="swsrfcf_zero" level="10" />
-                <field field_ref="cldncl" level="10" />
-                <field field_ref="reffclwtop" level="10" />
-                <field field_ref="cldnvi" level="10" />
-                <field field_ref="lcc" level="10" />
-                <field field_ref="wvapp" level="10" />
-                <field field_ref="albe_ter" level="7" />
-                <field field_ref="albe_lic" level="7" />
-                <field field_ref="albe_oce" level="7" />
-                <field field_ref="albe_sic" level="7" />
-                <field field_ref="ages_ter" level="10" />
-                <field field_ref="ages_lic" level="10" />
-                <field field_ref="ages_oce" level="10" />
-                <field field_ref="ages_sic" level="10" />
-                <field field_ref="rugs_ter" level="10" />
-                <field field_ref="rugs_lic" level="10" />
-                <field field_ref="rugs_oce" level="10" />
-                <field field_ref="rugs_sic" level="10" />
-                <field field_ref="alb1" level="10" />
-                <field field_ref="alb2" level="10" />
-                <field field_ref="ftime_con" level="10" operation="instant" />
-                <field field_ref="wake_h" level="10" />
-                <field field_ref="wake_s" level="10" />
-                <field field_ref="plulth" level="10" />
-                <field field_ref="plulst" level="10" />
-                <field field_ref="lmaxth" level="10" />
-                <field field_ref="ftime_th" level="10" />
-                <field field_ref="f0_th" level="10" />
-                <field field_ref="zmax_th" level="5" />
-                <field field_ref="rsut4co2" level="10" />
-                <field field_ref="rlut4co2" level="10" />
-                <field field_ref="rsutcs4co2" level="10" />
-                <field field_ref="rlutcs4co2" level="10" />
-            </field_group>
-
-            <!-- VARS 3D -->
-            <field_group operation="average" freq_op="1ts" axis_ref="presnivs_histhf">
-                <field field_ref="cldtau" level="10" />
-                <field field_ref="cldemi" level="10" />
-                <field field_ref="tke_max" level="10" operation="maximum" />
-                <field field_ref="kz" level="10" />
-                <field field_ref="kz_max" level="10" operation="maximum" />
-                <field field_ref="concso4" level="10" />
-                <field field_ref="concoa" level="10" />
-                <field field_ref="concbc" level="10" />
-                <field field_ref="concss" level="10" />
-                <field field_ref="concdust" level="10" />
-                <field field_ref="ec550aer" level="10" />
-                <field field_ref="lwcon" level="10" />
-                <field field_ref="iwcon" level="10" />
-                <field field_ref="temp" level="10" />
-                <field field_ref="theta" level="10" />
-                <field field_ref="ovap" level="10" />
-                <field field_ref="ovapinit" level="10" />
-                <field field_ref="oliq" level="10" />
-                <field field_ref="geop" level="10" />
-                <field field_ref="vitu" level="6" />
-                <field field_ref="vitv" level="6" />
-                <field field_ref="vitw" level="6" />
-                <field field_ref="pres" level="10" />
-                <field field_ref="paprs" level="10" />
-                <field field_ref="mass" level="10" />
-                <field field_ref="zfull" level="10" />
-                <field field_ref="zhalf" level="10" />
-                <field field_ref="rneb" level="10" />
-                <field field_ref="rnebcon" level="10" />
-                <field field_ref="rnebls" level="10" />
-                <field field_ref="rhum" level="10" />
-                <field field_ref="ozone" level="10" />
-                <field field_ref="ozone_daylight" level="10" />
-                <field field_ref="upwd" level="10" />
-                <field field_ref="dtphy" level="10" />
-                <field field_ref="dqphy" level="10" />
-                <field field_ref="pr_con_l" level="10" />
-                <field field_ref="pr_con_i" level="10" />
-                <field field_ref="pr_lsc_l" level="10" />
-                <field field_ref="pr_lsc_i" level="10" />
-                <field field_ref="re" level="10" />
-                <field field_ref="fl" level="10" />
-                <field field_ref="scdnc" level="10" />
-                <field field_ref="reffclws" level="10" />
-                <field field_ref="reffclwc" level="10" />
-                <field field_ref="lcc3d" level="10" />
-                <field field_ref="lcc3dcon" level="10" />
-                <field field_ref="lcc3dstra" level="10" />
-                <field field_ref="clwcon" level="10" />
-                <field field_ref="Ma" level="10" />
-                <field field_ref="dnwd" level="10" />
-                <field field_ref="dnwd0" level="10" />
-                <field field_ref="mc" level="10" />
-                <field field_ref="dtdyn" level="10" />
-                <field field_ref="dqdyn" level="10" />
-                <field field_ref="dudyn" level="10" />
-                <field field_ref="dvdyn" level="10" />
-                <field field_ref="dtcon" level="10" />
-                <field field_ref="ducon" level="10" />
-                <field field_ref="dvcon" level="10" />
-                <field field_ref="dqcon" level="10" />
-                <field field_ref="dtwak" level="10" />
-                <field field_ref="dqwak" level="10" />
-                <field field_ref="wake_deltat" level="10" />
-                <field field_ref="wake_deltaq" level="10" />
-                <field field_ref="wake_omg" level="10" />
-                <field field_ref="wdtrainA" level="4" />
-                <field field_ref="wdtrainM" level="4" />
-                <field field_ref="Vprecip" level="10" />
-                <field field_ref="ftd" level="10" />
-                <field field_ref="fqd" level="10" />
-                <field field_ref="dtlsc" level="10" />
-                <field field_ref="dtlschr" level="10" />
-                <field field_ref="dqlsc" level="10" />
-                <field field_ref="beta_prec" level="10" />
-                <field field_ref="dtvdf" level="10" />
-                <field field_ref="dtdis" level="10" />
-                <field field_ref="dqvdf" level="10" />
-                <field field_ref="dteva" level="10" />
-                <field field_ref="dqeva" level="10" />
-                <field field_ref="dqlscth" level="10" />
-                <field field_ref="dqlscst" level="10" />
-                <field field_ref="dtlscth" level="10" />
-                <field field_ref="dtlscst" level="10" />
-                <field field_ref="ptconvth" level="10" />
-                <field field_ref="ptconv" level="10" />
-                <field field_ref="ratqs" level="10" />
-                <field field_ref="dtthe" level="10" />
-                <field field_ref="f_th" level="10" />
-                <field field_ref="e_th" level="10" />
-                <field field_ref="w_th" level="10" />
-                <field field_ref="lambda_th" level="10" />
-                <field field_ref="q_th" level="10" />
-                <field field_ref="a_th" level="10" />
-                <field field_ref="d_th" level="10" />
-                <field field_ref="dqthe" level="10" />
-                <field field_ref="dtajs" level="10" />
-                <field field_ref="dqajs" level="10" />
-                <field field_ref="dtswr" level="10" />
-                <field field_ref="dtsw0" level="10" />
-                <field field_ref="dtlwr" level="10" />
-                <field field_ref="dtlw0" level="10" />
-                <field field_ref="dtec" level="10" />
-                <field field_ref="duvdf" level="10" />
-                <field field_ref="dvvdf" level="10" />
-                <field field_ref="duoro" level="10" />
-                <field field_ref="dvoro" level="10" />
-                <field field_ref="dulif" level="10" />
-                <field field_ref="dvlif" level="10" />
-                <field field_ref="duhin" level="10" />
-                <field field_ref="dvhin" level="10" />
-                <field field_ref="dtoro" level="10" />
-                <field field_ref="dtlif" level="10" />
-                <field field_ref="dthin" level="10" />
-                <field field_ref="rsu" level="10" />
-                <field field_ref="rsd" level="10" />
-                <field field_ref="rlu" level="10" />
-                <field field_ref="rld" level="10" />
-                <field field_ref="rsucs" level="10" />
-                <field field_ref="rsdcs" level="10" />
-                <field field_ref="rlucs" level="10" />
-                <field field_ref="rldcs" level="10" />
-                <field field_ref="tnt" level="10" />
-                <field field_ref="tntc" level="10" />
-                <field field_ref="tntr" level="10" />
-                <field field_ref="tntscpbl" level="10" />
-                <field field_ref="tnhus" level="10" />
-                <field field_ref="tnhusc" level="10" />
-                <field field_ref="tnhusscpbl" level="10" />
-                <field field_ref="evu" level="10" />
-                <field field_ref="h2o" level="10" />
-                <field field_ref="mcd" level="10" />
-                <field field_ref="dmc" level="10" />
-                <field field_ref="ref_liq" level="10" />
-                <field field_ref="ref_ice" level="10" />
-                <field field_ref="rsu4co2" level="10" />
-                <field field_ref="rlu4co2" level="10" />
-                <field field_ref="rsucs4co2" level="10" />
-                <field field_ref="rlucs4co2" level="10" />
-                <field field_ref="rsd4co2" level="10" />
-                <field field_ref="rld4co2" level="10" />
-                <field field_ref="rsdcs4co2" level="10" />
-                <field field_ref="rldcs4co2" level="10" />
-            </field_group>
-        </file>
-    </file_group>
-</file_definition>
Index: DZ5/branches/testing/DefLists/iodef_file_histins.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/iodef_file_histins.xml	(revision 2055)
+++ 	(revision )
@@ -1,510 +1,0 @@
-<file_definition>
-    <file_group id="defile">
-        <file id="histins" name="Xhistins" output_freq="6h" output_level="4" enabled=".FALSE.">
-            <!-- VARS 2D -->
-            <field_group operation="instant" freq_op="1ts">
-                <field field_ref="Ap" level="1" />
-                <field field_ref="Bp" level="1" />
-                <field field_ref="Alt" level="1" />
-                <field field_ref="phis" level="10" />
-                <field field_ref="aire" level="10" operation="once" />
-                <field field_ref="contfracATM" level="1" operation="once" />
-                <field field_ref="contfracOR" level="1" />
-                <field field_ref="aireTER" level="1" />
-                <field field_ref="flat" level="10" />
-                <field field_ref="slp" level="1" />
-                <field field_ref="tsol" level="1" />
-                <field field_ref="t2m" level="1" />
-                <field field_ref="t2m_min" level="10" operation="minimum" />
-                <field field_ref="t2m_max" level="10" operation="maximum" />
-                <field field_ref="t2m_ter" level="10" />
-                <field field_ref="t2m_lic" level="10" />
-                <field field_ref="t2m_oce" level="10" />
-                <field field_ref="t2m_sic" level="10" />
-                <field field_ref="wind10m" level="1" />
-                <field field_ref="wind10max" level="10" />
-                <field field_ref="sicf" level="10" />
-                <field field_ref="q2m" level="1" />
-                <field field_ref="ustar" level="1" />
-                <field field_ref="u10m" level="1" />
-                <field field_ref="v10m" level="1" />
-                <field field_ref="psol" level="1" />
-                <field field_ref="qsurf" level="10" />
-                <field field_ref="ustar_ter" level="10" />
-                <field field_ref="ustar_lic" level="10" />
-                <field field_ref="ustar_oce" level="10" />
-                <field field_ref="ustar_sic" level="10" />
-                <field field_ref="wstar_ter" level="10" />
-                <field field_ref="wstar_lic" level="10" />
-                <field field_ref="wstar_oce" level="10" />
-                <field field_ref="wstar_sic" level="10" />
-                <field field_ref="wstar" level="10" />
-                <field field_ref="u10m_ter" level="10" />
-                <field field_ref="u10m_lic" level="10" />
-                <field field_ref="u10m_oce" level="10" />
-                <field field_ref="u10m_sic" level="10" />
-                <field field_ref="v10m_ter" level="10" />
-                <field field_ref="v10m_lic" level="10" />
-                <field field_ref="v10m_oce" level="10" />
-                <field field_ref="v10m_sic" level="10" />
-                <field field_ref="qsol" level="10" />
-                <field field_ref="ndayrain" level="10" operation="instant"  />
-                <field field_ref="precip" level="1" />
-                <field field_ref="plul" level="1" />
-                <field field_ref="pluc" level="1" />
-                <field field_ref="snow" level="10" />
-                <field field_ref="evap" level="10" />
-                <field field_ref="evap_ter" level="10" />
-                <field field_ref="evap_lic" level="10" />
-                <field field_ref="evap_oce" level="10" />
-                <field field_ref="evap_sic" level="10" />
-                <field field_ref="msnow" level="10" />
-                <field field_ref="fsnow" level="10" />
-                <field field_ref="tops" level="10" />
-                <field field_ref="tops0" level="10" />
-                <field field_ref="topl" level="10" />
-                <field field_ref="topl0" level="10" />
-                <field field_ref="SWupTOA" level="10" />
-                <field field_ref="SWupTOAclr" level="10" />
-                <field field_ref="SWdnTOA" level="10" />
-                <field field_ref="SWdnTOAclr" level="10" />
-                <field field_ref="nettop" level="10" />
-                <field field_ref="SWup200" level="10" />
-                <field field_ref="SWup200clr" level="10" />
-                <field field_ref="SWdn200" level="10" />
-                <field field_ref="SWdn200clr" level="10" />
-                <field field_ref="LWup200" level="10" />
-                <field field_ref="LWup200clr" level="10" />
-                <field field_ref="LWdn200" level="10" />
-                <field field_ref="LWdn200clr" level="10" />
-                <field field_ref="sols" level="10" />
-                <field field_ref="sols0" level="10" />
-                <field field_ref="soll" level="10" />
-                <field field_ref="soll0" level="10" />
-                <field field_ref="radsol" level="10" />
-                <field field_ref="SWupSFC" level="10" />
-                <field field_ref="SWupSFCclr" level="10" />
-                <field field_ref="SWdnSFC" level="10" />
-                <field field_ref="SWdnSFCclr" level="10" />
-                <field field_ref="LWupSFC" level="10" />
-                <field field_ref="LWupSFCclr" level="10" />
-                <field field_ref="LWdnSFC" level="10" />
-                <field field_ref="LWdnSFCclr" level="10" />
-                <field field_ref="bils" level="10" />
-                <field field_ref="bils_tke" level="10" />
-                <field field_ref="bils_diss" level="10" />
-                <field field_ref="bils_ec" level="10" />
-                <field field_ref="bils_kinetic" level="10" />
-                <field field_ref="bils_enthalp" level="10" />
-                <field field_ref="bils_latent" level="10" />
-                <field field_ref="sens" level="10" />
-                <field field_ref="fder" level="10" />
-                <field field_ref="ffonte" level="10" />
-                <field field_ref="fqcalving" level="10" />
-                <field field_ref="fqfonte" level="10" />
-                <field field_ref="taux" level="10" />
-                <field field_ref="tauy" level="10" />
-                <field field_ref="taux_ter" level="10" />
-                <field field_ref="taux_lic" level="10" />
-                <field field_ref="taux_oce" level="10" />
-                <field field_ref="taux_sic" level="10" />
-                <field field_ref="tauy_ter" level="10" />
-                <field field_ref="tauy_lic" level="10" />
-                <field field_ref="tauy_oce" level="10" />
-                <field field_ref="tauy_sic" level="10" />
-                <field field_ref="pourc_ter" level="10" />
-                <field field_ref="pourc_lic" level="10" />
-                <field field_ref="pourc_oce" level="10" />
-                <field field_ref="pourc_sic" level="10" />
-                <field field_ref="fract_ter" level="10" />
-                <field field_ref="fract_lic" level="10" />
-                <field field_ref="fract_oce" level="10" />
-                <field field_ref="fract_sic" level="10" />
-                <field field_ref="tsol_ter" level="10" />
-                <field field_ref="tsol_lic" level="10" />
-                <field field_ref="tsol_oce" level="10" />
-                <field field_ref="tsol_sic" level="10" />
-                <field field_ref="evappot_ter" level="10" />
-                <field field_ref="evappot_lic" level="10" />
-                <field field_ref="evappot_oce" level="10" />
-                <field field_ref="evappot_sic" level="10" />
-                <field field_ref="sens_ter" level="10" />
-                <field field_ref="sens_lic" level="10" />
-                <field field_ref="sens_oce" level="10" />
-                <field field_ref="sens_sic" level="10" />
-                <field field_ref="lat_ter" level="10" />
-                <field field_ref="lat_lic" level="10" />
-                <field field_ref="lat_oce" level="10" />
-                <field field_ref="lat_sic" level="10" />
-                <field field_ref="flw_ter" level="10" />
-                <field field_ref="flw_lic" level="10" />
-                <field field_ref="flw_oce" level="10" />
-                <field field_ref="flw_sic" level="10" />
-                <field field_ref="fsw_ter" level="10" />
-                <field field_ref="fsw_lic" level="10" />
-                <field field_ref="fsw_oce" level="10" />
-                <field field_ref="fsw_sic" level="10" />
-                <field field_ref="wbils_ter" level="10" />
-                <field field_ref="wbils_lic" level="10" />
-                <field field_ref="wbils_oce" level="10" />
-                <field field_ref="wbils_sic" level="10" />
-                <field field_ref="wbilo_ter" level="10" />
-                <field field_ref="wbilo_lic" level="10" />
-                <field field_ref="wbilo_oce" level="10" />
-                <field field_ref="wbilo_sic" level="10" />
-                <field field_ref="cdrm" level="10" />
-                <field field_ref="cdrh" level="10" />
-                <field field_ref="cldl" level="10" />
-                <field field_ref="cldm" level="10" />
-                <field field_ref="cldh" level="10" />
-                <field field_ref="cldt" level="2" />
-                <field field_ref="cldq" level="10" />
-                <field field_ref="lwp" level="10" />
-                <field field_ref="iwp" level="10" />
-                <field field_ref="ue" level="10" />
-                <field field_ref="ve" level="10" />
-                <field field_ref="uq" level="10" />
-                <field field_ref="vq" level="10" />
-                <field field_ref="cape" level="10" />
-                <field field_ref="pbase" level="10" />
-                <field field_ref="ptop" level="10" />
-                <field field_ref="fbase" level="10" />
-                <field field_ref="plcl" level="10" />
-                <field field_ref="plfc" level="10" />
-                <field field_ref="wbeff" level="10" />
-                <field field_ref="prw" level="10" />
-                <field field_ref="s_pblh" level="10" />
-                <field field_ref="s_pblt" level="10" />
-                <field field_ref="s_lcl" level="10" />
-                <field field_ref="s_therm" level="10" />
-                <field field_ref="slab_bils_oce" level="10" />
-                <field field_ref="ale_bl" level="1" />
-                <field field_ref="alp_bl" level="1" />
-                <field field_ref="ale_wk" level="1" />
-                <field field_ref="alp_wk" level="1" />
-                <field field_ref="ale" level="1" />
-                <field field_ref="alp" level="1" />
-                <field field_ref="cin" level="1" />
-                <field field_ref="wape" level="1" />
-                <field field_ref="n2" level="1" />
-                <field field_ref="s2" level="1" />
-                <field field_ref="proba_notrig" level="1" />
-                <field field_ref="random_notrig" level="1" />
-                <field field_ref="ale_bl_stat" level="1" />
-                <field field_ref="ale_bl_trig" level="1" />
-                <field field_ref="alp_bl_det" level="1" />
-                <field field_ref="alp_bl_fluct_m" level="1" />
-                <field field_ref="alp_bl_fluct_tke" level="1" />
-                <field field_ref="alp_bl_conv" level="1" />
-                <field field_ref="alp_bl_stat" level="1" />
-
-                <field_group operation="instant">
-                    <field field_ref="u850" level="7" />
-                    <field field_ref="u700" level="7" />
-                    <field field_ref="u500" level="7" />
-                    <field field_ref="u200" level="7" />
-                    <field field_ref="u100" level="7" />
-                    <field field_ref="u50" level="7" />
-                    <field field_ref="u10" level="7" />
-                    <field field_ref="v850" level="7" />
-                    <field field_ref="v700" level="7" />
-                    <field field_ref="v500" level="7" />
-                    <field field_ref="v200" level="7" />
-                    <field field_ref="v100" level="7" />
-                    <field field_ref="v50" level="7" />
-                    <field field_ref="v10" level="7" />
-                    <field field_ref="w850" level="7" />
-                    <field field_ref="w700" level="7" />
-                    <field field_ref="w500" level="7" />
-                    <field field_ref="w200" level="7" />
-                    <field field_ref="w100" level="7" />
-                    <field field_ref="w50" level="7" />
-                    <field field_ref="w10" level="7" />
-                    <field field_ref="t850" level="7" />
-                    <field field_ref="t700" level="7" />
-                    <field field_ref="t500" level="7" />
-                    <field field_ref="t200" level="7" />
-                    <field field_ref="t100" level="7" />
-                    <field field_ref="t50" level="7" />
-                    <field field_ref="t10" level="7" />
-                    <field field_ref="q850" level="7" />
-                    <field field_ref="q700" level="7" />
-                    <field field_ref="q500" level="7" />
-                    <field field_ref="q200" level="7" />
-                    <field field_ref="q100" level="7" />
-                    <field field_ref="q50" level="7" />
-                    <field field_ref="q10" level="7" />
-                    <field field_ref="z850" level="7" />
-                    <field field_ref="z700" level="7" />
-                    <field field_ref="z500" level="7" />
-                    <field field_ref="z200" level="7" />
-                    <field field_ref="z100" level="7" />
-                    <field field_ref="z50" level="7" />
-                    <field field_ref="z10" level="7" />
-                </field_group>
-
-                <field field_ref="t_oce_sic" level="10" />
-                <field field_ref="weakinv" level="10" />
-                <field field_ref="dthmin" level="10" />
-                <field field_ref="u10_ter" level="10" />
-                <field field_ref="u10_lic" level="10" />
-                <field field_ref="u10_oce" level="10" />
-                <field field_ref="u10_sic" level="10" />
-                <field field_ref="v10_ter" level="10" />
-                <field field_ref="v10_lic" level="10" />
-                <field field_ref="v10_oce" level="10" />
-                <field field_ref="v10_sic" level="10" />
-                <field field_ref="rh2m" level="10" />
-                <field field_ref="rh2m_min" level="10" operation="minimum"  />
-                <field field_ref="rh2m_max" level="10" operation="maximum"  />
-                <field field_ref="qsat2m" level="10" />
-                <field field_ref="tpot" level="10" />
-                <field field_ref="tpote" level="10" />
-                <field field_ref="tke" level="10" />
-                <field field_ref="tke_ter" level="10" />
-                <field field_ref="tke_lic" level="10" />
-                <field field_ref="tke_oce" level="10" />
-                <field field_ref="tke_sic" level="10" />
-                <field field_ref="tke_max_ter" level="10" operation="maximum" />
-                <field field_ref="tke_max_lic" level="10" operation="maximum" />
-                <field field_ref="tke_max_oce" level="10" operation="maximum" />
-                <field field_ref="tke_max_sic" level="10" operation="maximum" />
-                <field field_ref="SWnetOR" level="2" />
-                <field field_ref="SWdownOR" level="2" />
-                <field field_ref="LWdownOR" level="2" />
-                <field field_ref="snowl" level="10" />
-                <field field_ref="cape_max" level="10" operation="maximum" />
-                <field field_ref="solldown" level="10" />
-                <field field_ref="dtsvdfo" level="10" />
-                <field field_ref="dtsvdft" level="10" />
-                <field field_ref="dtsvdfg" level="10" />
-                <field field_ref="dtsvdfi" level="10" />
-                <field field_ref="rugs" level="10" />
-                <field field_ref="topswad" level="10" />
-                <field field_ref="topswad0" level="10" />
-                <field field_ref="topswai" level="10" />
-                <field field_ref="solswad" level="10" />
-                <field field_ref="solswad0" level="10" />
-                <field field_ref="solswai" level="10" />
-                <field field_ref="OD550_ASBCM" level="10" />
-                <field field_ref="OD550_ASPOMM" level="10" />
-                <field field_ref="OD550_ASSO4M" level="10" />
-                <field field_ref="OD550_CSSO4M" level="10" />
-                <field field_ref="OD550_SSSSM" level="10" />
-                <field field_ref="OD550_ASSSM" level="10" />
-                <field field_ref="OD550_CSSSM" level="10" />
-                <field field_ref="OD550_CIDUSTM" level="10" />
-                <field field_ref="OD550_AIBCM" level="10" />
-                <field field_ref="OD550_AIPOMM" level="10" />
-                <field field_ref="OD550_STRAT" level="10" />
-                <field field_ref="od550aer" level="10" />
-                <field field_ref="od865aer" level="10" />
-                <field field_ref="absvisaer" level="10" />
-                <field field_ref="od550lt1aer" level="10" />
-                <field field_ref="sconcso4" level="10" />
-                <field field_ref="sconcoa" level="10" />
-                <field field_ref="sconcbc" level="10" />
-                <field field_ref="sconcss" level="10" />
-                <field field_ref="sconcdust" level="10" />
-                <field field_ref="loadso4" level="10" />
-                <field field_ref="loadoa" level="10" />
-                <field field_ref="loadbc" level="10" />
-                <field field_ref="loadss" level="10" />
-                <field field_ref="loaddust" level="10" />
-                <field field_ref="swtoaas_nat" level="10" />
-                <field field_ref="swsrfas_nat" level="10" />
-                <field field_ref="swtoacs_nat" level="10" />
-                <field field_ref="swsrfcs_nat" level="10" />
-                <field field_ref="swtoaas_ant" level="10" />
-                <field field_ref="swsrfas_ant" level="10" />
-                <field field_ref="swtoacs_ant" level="10" />
-                <field field_ref="swsrfcs_ant" level="10" />
-                <field field_ref="swtoacf_nat" level="10" />
-                <field field_ref="swsrfcf_nat" level="10" />
-                <field field_ref="swtoacf_ant" level="10" />
-                <field field_ref="swsrfcf_ant" level="10" />
-                <field field_ref="swtoacf_zero" level="10" />
-                <field field_ref="swsrfcf_zero" level="10" />
-                <field field_ref="cldncl" level="10" />
-                <field field_ref="reffclwtop" level="10" />
-                <field field_ref="cldnvi" level="10" />
-                <field field_ref="lcc" level="10" />
-                <field field_ref="wvapp" level="10" />
-                <field field_ref="albe_ter" level="10" />
-                <field field_ref="albe_lic" level="10" />
-                <field field_ref="albe_oce" level="10" />
-                <field field_ref="albe_sic" level="10" />
-                <field field_ref="ages_ter" level="10" />
-                <field field_ref="ages_lic" level="10" />
-                <field field_ref="ages_oce" level="10" />
-                <field field_ref="ages_sic" level="10" />
-                <field field_ref="rugs_ter" level="10" />
-                <field field_ref="rugs_lic" level="10" />
-                <field field_ref="rugs_oce" level="10" />
-                <field field_ref="rugs_sic" level="10" />
-                <field field_ref="alb1" level="10" />
-                <field field_ref="alb2" level="10" />
-                <field field_ref="ftime_con" level="10" operation="instant" />
-                <field field_ref="wake_h" level="10" />
-                <field field_ref="wake_s" level="10" />
-                <field field_ref="plulth" level="10" />
-                <field field_ref="plulst" level="10" />
-                <field field_ref="lmaxth" level="10" />
-                <field field_ref="ftime_th" level="10" />
-                <field field_ref="f0_th" level="10" />
-                <field field_ref="zmax_th" level="4" />
-                <field field_ref="rsut4co2" level="10" />
-                <field field_ref="rlut4co2" level="10" />
-                <field field_ref="rsutcs4co2" level="10" />
-                <field field_ref="rlutcs4co2" level="10" />
-            </field_group>
-
-            <!-- VARS 3D -->
-            <field_group operation="instant" freq_op="1ts" axis_ref="presnivs_histins">
-                <field field_ref="cldtau" level="10" />
-                <field field_ref="cldemi" level="10" />
-                <field field_ref="tke_max" level="10" operation="maximum" />
-                <field field_ref="kz" level="10" />
-                <field field_ref="kz_max" level="10" operation="maximum" />
-                <field field_ref="concso4" level="10" />
-                <field field_ref="concoa" level="10" />
-                <field field_ref="concbc" level="10" />
-                <field field_ref="concss" level="10" />
-                <field field_ref="concdust" level="10" />
-                <field field_ref="ec550aer" level="10" />
-                <field field_ref="lwcon" level="10" />
-                <field field_ref="iwcon" level="10" />
-                <field field_ref="temp" level="4" />
-                <field field_ref="theta" level="4" />
-                <field field_ref="ovap" level="4" />
-                <field field_ref="ovapinit" level="10" />
-                <field field_ref="oliq" level="4" />
-                <field field_ref="geop" level="10" />
-                <field field_ref="vitu" level="4" />
-                <field field_ref="vitv" level="4" />
-                <field field_ref="vitw" level="10" />
-                <field field_ref="pres" level="10" />
-                <field field_ref="paprs" level="10" />
-                <field field_ref="mass" level="10" />
-                <field field_ref="zfull" level="10" />
-                <field field_ref="zhalf" level="10" />
-                <field field_ref="rneb" level="10" />
-                <field field_ref="rnebcon" level="10" />
-                <field field_ref="rnebls" level="10" />
-                <field field_ref="rhum" level="10" />
-                <field field_ref="ozone" level="10" />
-                <field field_ref="ozone_daylight" level="10" />
-                <field field_ref="upwd" level="10" />
-                <field field_ref="dtphy" level="10" />
-                <field field_ref="dqphy" level="10" />
-                <field field_ref="pr_con_l" level="10" />
-                <field field_ref="pr_con_i" level="10" />
-                <field field_ref="pr_lsc_l" level="10" />
-                <field field_ref="pr_lsc_i" level="10" />
-                <field field_ref="re" level="10" />
-                <field field_ref="fl" level="10" />
-                <field field_ref="scdnc" level="10" />
-                <field field_ref="reffclws" level="10" />
-                <field field_ref="reffclwc" level="10" />
-                <field field_ref="lcc3d" level="10" />
-                <field field_ref="lcc3dcon" level="10" />
-                <field field_ref="lcc3dstra" level="10" />
-                <field field_ref="clwcon" level="10" />
-                <field field_ref="Ma" level="10" />
-                <field field_ref="dnwd" level="10" />
-                <field field_ref="dnwd0" level="10" />
-                <field field_ref="mc" level="10" />
-                <field field_ref="dtdyn" level="10" />
-                <field field_ref="dqdyn" level="10" />
-                <field field_ref="dudyn" level="10" />
-                <field field_ref="dvdyn" level="10" />
-                <field field_ref="dtcon" level="10" />
-                <field field_ref="ducon" level="10" />
-                <field field_ref="dvcon" level="10" />
-                <field field_ref="dqcon" level="10" />
-                <field field_ref="dtwak" level="10" />
-                <field field_ref="dqwak" level="10" />
-                <field field_ref="wake_deltat" level="10" />
-                <field field_ref="wake_deltaq" level="10" />
-                <field field_ref="wake_omg" level="10" />
-                <field field_ref="wdtrainA" level="10" />
-                <field field_ref="wdtrainM" level="10" />
-                <field field_ref="Vprecip" level="10" />
-                <field field_ref="ftd" level="10" />
-                <field field_ref="fqd" level="10" />
-                <field field_ref="dtlsc" level="10" />
-                <field field_ref="dtlschr" level="10" />
-                <field field_ref="dqlsc" level="10" />
-                <field field_ref="beta_prec" level="10" />
-                <field field_ref="dtvdf" level="10" />
-                <field field_ref="dtdis" level="10" />
-                <field field_ref="dqvdf" level="10" />
-                <field field_ref="dteva" level="10" />
-                <field field_ref="dqeva" level="10" />
-                <field field_ref="dqlscth" level="10" />
-                <field field_ref="dqlscst" level="10" />
-                <field field_ref="dtlscth" level="10" />
-                <field field_ref="dtlscst" level="10" />
-                <field field_ref="ptconvth" level="10" />
-                <field field_ref="ptconv" level="10" />
-                <field field_ref="ratqs" level="10" />
-                <field field_ref="dtthe" level="10" />
-                <field field_ref="f_th" level="10" />
-                <field field_ref="e_th" level="10" />
-                <field field_ref="w_th" level="10" />
-                <field field_ref="lambda_th" level="10" />
-                <field field_ref="q_th" level="10" />
-                <field field_ref="a_th" level="10" />
-                <field field_ref="d_th" level="10" />
-                <field field_ref="dqthe" level="10" />
-                <field field_ref="dtajs" level="10" />
-                <field field_ref="dqajs" level="10" />
-                <field field_ref="dtswr" level="10" />
-                <field field_ref="dtsw0" level="10" />
-                <field field_ref="dtlwr" level="10" />
-                <field field_ref="dtlw0" level="10" />
-                <field field_ref="dtec" level="10" />
-                <field field_ref="duvdf" level="10" />
-                <field field_ref="dvvdf" level="10" />
-                <field field_ref="duoro" level="10" />
-                <field field_ref="dvoro" level="10" />
-                <field field_ref="dulif" level="10" />
-                <field field_ref="dvlif" level="10" />
-                <field field_ref="duhin" level="10" />
-                <field field_ref="dvhin" level="10" />
-                <field field_ref="dtoro" level="10" />
-                <field field_ref="dtlif" level="10" />
-                <field field_ref="dthin" level="10" />
-                <field field_ref="rsu" level="10" />
-                <field field_ref="rsd" level="10" />
-                <field field_ref="rlu" level="10" />
-                <field field_ref="rld" level="10" />
-                <field field_ref="rsucs" level="10" />
-                <field field_ref="rsdcs" level="10" />
-                <field field_ref="rlucs" level="10" />
-                <field field_ref="rldcs" level="10" />
-                <field field_ref="tnt" level="10" />
-                <field field_ref="tntc" level="10" />
-                <field field_ref="tntr" level="10" />
-                <field field_ref="tntscpbl" level="10" />
-                <field field_ref="tnhus" level="10" />
-                <field field_ref="tnhusc" level="10" />
-                <field field_ref="tnhusscpbl" level="10" />
-                <field field_ref="evu" level="10" />
-                <field field_ref="h2o" level="10" />
-                <field field_ref="mcd" level="10" />
-                <field field_ref="dmc" level="10" />
-                <field field_ref="ref_liq" level="10" />
-                <field field_ref="ref_ice" level="10" />
-                <field field_ref="rsu4co2" level="10" />
-                <field field_ref="rlu4co2" level="10" />
-                <field field_ref="rsucs4co2" level="10" />
-                <field field_ref="rlucs4co2" level="10" />
-                <field field_ref="rsd4co2" level="10" />
-                <field field_ref="rld4co2" level="10" />
-                <field field_ref="rsdcs4co2" level="10" />
-                <field field_ref="rldcs4co2" level="10" />
-            </field_group>
-        </file>
-    </file_group>
-</file_definition>
Index: DZ5/branches/testing/DefLists/iodef_file_histmth.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/iodef_file_histmth.xml	(revision 2055)
+++ 	(revision )
@@ -1,514 +1,0 @@
-<file_definition>
-        <file_group id="defile">
-
-        <file id="histmth" name="Xhistmth" output_freq="1d" output_level="10"  enabled=".FALSE.">
-
-            <!-- VARS 2D -->
-            <field_group operation="average" freq_op="1ts">
-                <field field_ref="Ap"           level="1" />
-                <field field_ref="Bp"           level="1" />
-                <field field_ref="Alt"          level="1" />
-                <field field_ref="phis"         level="1" />
-                <field field_ref="aire"         level="1"   operation="once"/>
-                <field field_ref="contfracATM"  level="10"  operation="once"/>
-                <field field_ref="contfracOR"   level="10" />
-                <field field_ref="aireTER"      level="10" />
-                <field field_ref="flat"         level="5" />
-                <field field_ref="slp"          level="1" />
-                <field field_ref="tsol"         level="1" />
-                <field field_ref="t2m"          level="1" />
-                <field field_ref="t2m_min" level="1" operation="minimum" />
-                <field field_ref="t2m_max" level="1" operation="maximum" />
-                <field field_ref="t2m_ter" level="10" />
-                <field field_ref="t2m_lic" level="10" />
-                <field field_ref="t2m_oce" level="10" />
-                <field field_ref="t2m_sic" level="10" />
-                <field field_ref="wind10m" level="1" />
-                <field field_ref="wind10max" level="10" />
-                <field field_ref="sicf"      level="1" />
-                <field field_ref="q2m"       level="1" />
-                <field field_ref="ustar"     level="1" />
-                <field field_ref="u10m"      level="1" />
-                <field field_ref="v10m"      level="1" />
-                <field field_ref="psol"      level="1" />
-                <field field_ref="qsurf"     level="1" />
-                <field field_ref="ustar_ter" level="10" />
-                <field field_ref="ustar_lic" level="10" />
-                <field field_ref="ustar_oce" level="10" />
-                <field field_ref="ustar_sic" level="10" />
-                <field field_ref="wstar_ter" level="10" />
-                <field field_ref="wstar_lic" level="10" />
-                <field field_ref="wstar_oce" level="10" />
-                <field field_ref="wstar_sic" level="10" />
-                <field field_ref="wstar"    level="5" />
-                <field field_ref="u10m_ter" level="10" />
-                <field field_ref="u10m_lic" level="10" />
-                <field field_ref="u10m_oce" level="10" />
-                <field field_ref="u10m_sic" level="10" />
-                <field field_ref="v10m_ter" level="10" />
-                <field field_ref="v10m_lic" level="10" />
-                <field field_ref="v10m_oce" level="10" />
-                <field field_ref="v10m_sic" level="10" />
-                <field field_ref="qsol"     level="1" />
-                <field field_ref="ndayrain" level="1" operation="instant" />
-                <field field_ref="precip"   level="1" />
-                <field field_ref="plul"     level="1" />
-                <field field_ref="pluc"     level="1" />
-                <field field_ref="snow"     level="1" />
-                <field field_ref="evap"     level="1" />
-                <field field_ref="evap_ter" level="1" />
-                <field field_ref="evap_lic" level="1" />
-                <field field_ref="evap_oce" level="1" />
-                <field field_ref="evap_sic" level="1" />
-                <field field_ref="msnow"    level="1" />
-                <field field_ref="fsnow"    level="1" />
-                <field field_ref="tops"     level="1" />
-                <field field_ref="tops0"    level="1" />
-                <field field_ref="topl"     level="1" />
-                <field field_ref="topl0"    level="1" />
-                <field field_ref="SWupTOA"  level="1" />
-                <field field_ref="SWupTOAclr"   level="1" />
-                <field field_ref="SWdnTOA"      level="1" />
-                <field field_ref="SWdnTOAclr"   level="1" />
-                <field field_ref="nettop"       level="1" />
-                <field field_ref="SWup200"      level="1" />
-                <field field_ref="SWup200clr"   level="10" />
-                <field field_ref="SWdn200"      level="1" />
-                <field field_ref="SWdn200clr"   level="10" />
-                <field field_ref="LWup200"      level="1" />
-                <field field_ref="LWup200clr"   level="1" />
-                <field field_ref="LWdn200"      level="1" />
-                <field field_ref="LWdn200clr"   level="1" />
-                <field field_ref="sols"  level="1" />
-                <field field_ref="sols0" level="1" />
-                <field field_ref="soll" level="1" />
-                <field field_ref="soll0" level="1" />
-                <field field_ref="radsol" level="1" />
-                <field field_ref="SWupSFC" level="1" />
-                <field field_ref="SWupSFCclr" level="1" />
-                <field field_ref="SWdnSFC" level="1" />
-                <field field_ref="SWdnSFCclr" level="1" />
-                <field field_ref="LWupSFC" level="1" />
-                <field field_ref="LWupSFCclr" level="1" />
-                <field field_ref="LWdnSFC" level="1" />
-                <field field_ref="LWdnSFCclr" level="1" />
-                <field field_ref="bils" level="1" />
-                <field field_ref="bils_tke" level="1" />
-                <field field_ref="bils_diss" level="1" />
-                <field field_ref="bils_ec" level="1" />
-                <field field_ref="bils_kinetic" level="1" />
-                <field field_ref="bils_enthalp" level="1" />
-                <field field_ref="bils_latent" level="1" />
-                <field field_ref="sens" level="1" />
-                <field field_ref="fder" level="1" />
-                <field field_ref="ffonte" level="1" />
-                <field field_ref="fqcalving" level="1" />
-                <field field_ref="fqfonte" level="1" />
-                <field field_ref="taux" level="1" />
-                <field field_ref="tauy" level="1" />
-                <field field_ref="taux_ter" level="1" />
-                <field field_ref="taux_lic" level="1" />
-                <field field_ref="taux_oce" level="1" />
-                <field field_ref="taux_sic" level="1" />
-                <field field_ref="tauy_ter" level="1" />
-                <field field_ref="tauy_lic" level="1" />
-                <field field_ref="tauy_oce" level="1" />
-                <field field_ref="tauy_sic" level="1" />
-                <field field_ref="pourc_ter" level="1" />
-                <field field_ref="pourc_lic" level="1" />
-                <field field_ref="pourc_oce" level="1" />
-                <field field_ref="pourc_sic" level="1" />
-                <field field_ref="fract_ter" level="1" />
-                <field field_ref="fract_lic" level="1" />
-                <field field_ref="fract_oce" level="1" />
-                <field field_ref="fract_sic" level="1" />
-                <field field_ref="tsol_ter" level="1" />
-                <field field_ref="tsol_lic" level="1" />
-                <field field_ref="tsol_oce" level="1" />
-                <field field_ref="tsol_sic" level="1" />
-                <field field_ref="evappot_ter" level="1" />
-                <field field_ref="evappot_lic" level="4" />
-                <field field_ref="evappot_oce" level="4" />
-                <field field_ref="evappot_sic" level="4" />
-                <field field_ref="sens_ter" level="1" />
-                <field field_ref="sens_lic" level="1" />
-                <field field_ref="sens_oce" level="1" />
-                <field field_ref="sens_sic" level="1" />
-                <field field_ref="lat_ter" level="1" />
-                <field field_ref="lat_lic" level="1" />
-                <field field_ref="lat_oce" level="1" />
-                <field field_ref="lat_sic" level="1" />
-                <field field_ref="flw_ter" level="1" />
-                <field field_ref="flw_lic" level="1" />
-                <field field_ref="flw_oce" level="1" />
-                <field field_ref="flw_sic" level="1" />
-                <field field_ref="fsw_ter" level="1" />
-                <field field_ref="fsw_lic" level="1" />
-                <field field_ref="fsw_oce" level="1" />
-                <field field_ref="fsw_sic" level="1" />
-                <field field_ref="wbils_ter" level="1" />
-                <field field_ref="wbils_lic" level="1" />
-                <field field_ref="wbils_oce" level="1" />
-                <field field_ref="wbils_sic" level="1" />
-                <field field_ref="wbilo_ter" level="1" />
-                <field field_ref="wbilo_lic" level="1" />
-                <field field_ref="wbilo_oce" level="1" />
-                <field field_ref="wbilo_sic" level="1" />
-                <field field_ref="cdrm" level="1" />
-                <field field_ref="cdrh" level="1" />
-                <field field_ref="cldl" level="1" />
-                <field field_ref="cldm" level="1" />
-                <field field_ref="cldh" level="1" />
-                <field field_ref="cldt" level="1" />
-                <field field_ref="cldq" level="1" />
-                <field field_ref="lwp" level="1" />
-                <field field_ref="iwp" level="1" />
-                <field field_ref="ue" level="1" />
-                <field field_ref="ve" level="1" />
-                <field field_ref="uq" level="1" />
-                <field field_ref="vq" level="1" />
-                <field field_ref="cape" level="1" />
-                <field field_ref="pbase" level="1" />
-                <field field_ref="ptop" level="1" />
-                <field field_ref="fbase" level="1" />
-                <field field_ref="plcl" level="1" />
-                <field field_ref="plfc" level="1" />
-                <field field_ref="wbeff" level="1" />
-                <field field_ref="prw" level="1" />
-                <field field_ref="s_pblh" level="1" />
-                <field field_ref="s_pblt" level="1" />
-                <field field_ref="s_lcl" level="1" />
-                <field field_ref="s_therm" level="1" />
-                <field field_ref="slab_bils_oce" level="1" />
-                <field field_ref="ale_bl" level="1" />
-                <field field_ref="alp_bl" level="1" />
-                <field field_ref="ale_wk" level="1" />
-                <field field_ref="alp_wk" level="1" />
-                <field field_ref="ale" level="1" />
-                <field field_ref="alp" level="1" />
-                <field field_ref="cin" level="1" />
-                <field field_ref="wape" level="1" />
-                <field field_ref="n2" level="1" />
-                <field field_ref="s2" level="1" />
-                <field field_ref="proba_notrig" level="1" />
-                <field field_ref="random_notrig" level="1" />
-                <field field_ref="ale_bl_stat" level="1" />
-                <field field_ref="ale_bl_trig" level="1" />
-                <field field_ref="alp_bl_det" level="1" />
-                <field field_ref="alp_bl_fluct_m" level="1" />
-                <field field_ref="alp_bl_fluct_tke" level="1" />
-                <field field_ref="alp_bl_conv" level="1" />
-                <field field_ref="alp_bl_stat" level="1" />
-
-                <field_group operation="instant">
-                    <field field_ref="u850" level="1" />
-                    <field field_ref="u700" level="1" />
-                    <field field_ref="u500" level="1" />
-                    <field field_ref="u200" level="1" />
-                    <field field_ref="u100" level="1" />
-                    <field field_ref="u50" level="1" />
-                    <field field_ref="u10" level="1" />
-                    <field field_ref="v850" level="1" />
-                    <field field_ref="v700" level="1" />
-                    <field field_ref="v500" level="1" />
-                    <field field_ref="v200" level="1" />
-                    <field field_ref="v100" level="1" />
-                    <field field_ref="v50" level="1" />
-                    <field field_ref="v10" level="1" />
-                    <field field_ref="w850" level="1" />
-                    <field field_ref="w700" level="1" />
-                    <field field_ref="w500" level="1" />
-                    <field field_ref="w200" level="1" />
-                    <field field_ref="w100" level="1" />
-                    <field field_ref="w50" level="1" />
-                    <field field_ref="w10" level="1" />
-                    <field field_ref="t850" level="1" />
-                    <field field_ref="t700" level="1" />
-                    <field field_ref="t500" level="1" />
-                    <field field_ref="t200" level="1" />
-                    <field field_ref="t100" level="1" />
-                    <field field_ref="t50" level="1" />
-                    <field field_ref="t10" level="1" />
-                    <field field_ref="q850" level="1" />
-                    <field field_ref="q700" level="1" />
-                    <field field_ref="q500" level="1" />
-                    <field field_ref="q200" level="1" />
-                    <field field_ref="q100" level="1" />
-                    <field field_ref="q50" level="1" />
-                    <field field_ref="q10" level="1" />
-                    <field field_ref="z850" level="1" />
-                    <field field_ref="z700" level="1" />
-                    <field field_ref="z500" level="1" />
-                    <field field_ref="z200" level="1" />
-                    <field field_ref="z100" level="1" />
-                    <field field_ref="z50" level="1" />
-                    <field field_ref="z10" level="1" />
-                </field_group>
-
-                <field field_ref="t_oce_sic" level="1" />
-                <field field_ref="weakinv" level="10" />
-                <field field_ref="dthmin" level="10" />
-                <field field_ref="u10_ter" level="10" />
-                <field field_ref="u10_lic" level="10" />
-                <field field_ref="u10_oce" level="10" />
-                <field field_ref="u10_sic" level="10" />
-                <field field_ref="v10_ter" level="10" />
-                <field field_ref="v10_lic" level="10" />
-                <field field_ref="v10_oce" level="10" />
-                <field field_ref="v10_sic" level="10" />
-                <field field_ref="rh2m" level="5" />
-                <field field_ref="rh2m_min" level="10" operation="minimum" />
-                <field field_ref="rh2m_max" level="10" operation="maximum" />
-                <field field_ref="qsat2m" level="10" />
-                <field field_ref="tpot" level="10" />
-                <field field_ref="tpote" level="10" />
-                <field field_ref="tke" level="4" />
-                <field field_ref="tke_ter" level="10" />
-                <field field_ref="tke_lic" level="10" />
-                <field field_ref="tke_oce" level="10" />
-                <field field_ref="tke_sic" level="10" />
-                <field field_ref="tke_max_ter" level="10" operation="maximum" />
-                <field field_ref="tke_max_lic" level="10" operation="maximum" />
-                <field field_ref="tke_max_oce" level="10" operation="maximum" />
-                <field field_ref="tke_max_sic" level="10" operation="maximum" />
-                <field field_ref="SWnetOR" level="10" />
-                <field field_ref="SWdownOR" level="10" />
-                <field field_ref="LWdownOR" level="10" />
-                <field field_ref="snowl" level="10" />
-                <field field_ref="cape_max" level="10" operation="maximum" />
-                <field field_ref="solldown" level="10" />
-                <field field_ref="dtsvdfo" level="10" />
-                <field field_ref="dtsvdft" level="10" />
-                <field field_ref="dtsvdfg" level="10" />
-                <field field_ref="dtsvdfi" level="10" />
-                <field field_ref="rugs" level="10" />
-                <field field_ref="topswad" level="2" />
-                <field field_ref="topswad0" level="2" />
-                <field field_ref="topswai" level="2" />
-                <field field_ref="solswad" level="2" />
-                <field field_ref="solswad0" level="2" />
-                <field field_ref="solswai" level="2" />
-                <field field_ref="OD550_ASBCM" level="2" />
-                <field field_ref="OD550_ASPOMM" level="2" />
-                <field field_ref="OD550_ASSO4M" level="2" />
-                <field field_ref="OD550_CSSO4M" level="2" />
-                <field field_ref="OD550_SSSSM" level="2" />
-                <field field_ref="OD550_ASSSM" level="2" />
-                <field field_ref="OD550_CSSSM" level="2" />
-                <field field_ref="OD550_CIDUSTM" level="2" />
-                <field field_ref="OD550_AIBCM" level="2" />
-                <field field_ref="OD550_AIPOMM" level="2" />
-                <field field_ref="OD550_STRAT" level="2" />
-                <field field_ref="od550aer" level="2" />
-                <field field_ref="od865aer" level="2" />
-                <field field_ref="absvisaer" level="2" />
-                <field field_ref="od550lt1aer" level="2" />
-                <field field_ref="sconcso4" level="2" />
-                <field field_ref="sconcoa" level="2" />
-                <field field_ref="sconcbc" level="2" />
-                <field field_ref="sconcss" level="2" />
-                <field field_ref="sconcdust" level="2" />
-                <field field_ref="loadso4" level="2" />
-                <field field_ref="loadoa" level="2" />
-                <field field_ref="loadbc" level="2" />
-                <field field_ref="loadss" level="2" />
-                <field field_ref="loaddust" level="2" />
-                <field field_ref="swtoaas_nat" level="4" />
-                <field field_ref="swsrfas_nat" level="4" />
-                <field field_ref="swtoacs_nat" level="4" />
-                <field field_ref="swsrfcs_nat" level="4" />
-                <field field_ref="swtoaas_ant" level="4" />
-                <field field_ref="swsrfas_ant" level="4" />
-                <field field_ref="swtoacs_ant" level="4" />
-                <field field_ref="swsrfcs_ant" level="4" />
-                <field field_ref="swtoacf_nat" level="4" />
-                <field field_ref="swsrfcf_nat" level="4" />
-                <field field_ref="swtoacf_ant" level="4" />
-                <field field_ref="swsrfcf_ant" level="4" />
-                <field field_ref="swtoacf_zero" level="4" />
-                <field field_ref="swsrfcf_zero" level="4" />
-                <field field_ref="cldncl" level="2" />
-                <field field_ref="reffclwtop" level="2" />
-                <field field_ref="cldnvi" level="2" />
-                <field field_ref="lcc" level="2" />
-                <field field_ref="wvapp" level="2" />
-                <field field_ref="albe_ter" level="3" />
-                <field field_ref="albe_lic" level="3" />
-                <field field_ref="albe_oce" level="3" />
-                <field field_ref="albe_sic" level="3" />
-                <field field_ref="ages_ter" level="10" />
-                <field field_ref="ages_lic" level="3" />
-                <field field_ref="ages_oce" level="10" />
-                <field field_ref="ages_sic" level="3" />
-                <field field_ref="rugs_ter" level="3" />
-                <field field_ref="rugs_lic" level="3" />
-                <field field_ref="rugs_oce" level="3" />
-                <field field_ref="rugs_sic" level="3" />
-                <field field_ref="alb1" level="3" />
-                <field field_ref="alb2" level="3" />
-                <field field_ref="ftime_con" level="4" operation="instant" />
-                <field field_ref="wake_h" level="4" />
-                <field field_ref="wake_s" level="4" />
-                <field field_ref="plulth" level="10" />
-                <field field_ref="plulst" level="10" />
-                <field field_ref="lmaxth" level="10" />
-                <field field_ref="ftime_th" level="4" />
-                <field field_ref="f0_th" level="4" />
-                <field field_ref="zmax_th" level="4" />
-                <field field_ref="rsut4co2" level="5" />
-                <field field_ref="rlut4co2" level="5" />
-                <field field_ref="rsutcs4co2" level="5" />
-                <field field_ref="rlutcs4co2" level="5" />
-            </field_group>
-
-            <!-- VARS 3D -->
-            <field_group operation="average" freq_op="1ts" axis_ref="presnivs_histmth">
-                <field field_ref="cldtau" level="10" />
-                <field field_ref="cldemi" level="10" />
-                <field field_ref="tke_max" level="4" operation="maximum" />
-                <field field_ref="kz" level="4" />
-                <field field_ref="kz_max" level="4" operation="maximum" />
-                <field field_ref="concso4" level="2" />
-                <field field_ref="concoa" level="2" />
-                <field field_ref="concbc" level="2" />
-                <field field_ref="concss" level="2" />
-                <field field_ref="concdust" level="2" />
-                <field field_ref="ec550aer" level="2" />
-                <field field_ref="lwcon" level="2" />
-                <field field_ref="iwcon" level="2" />
-                <field field_ref="temp" level="2" />
-                <field field_ref="theta" level="2" />
-                <field field_ref="ovap" level="2" />
-                <field field_ref="ovapinit" level="2" />
-                <field field_ref="oliq" level="2" />
-                <field field_ref="geop" level="2" />
-                <field field_ref="vitu" level="2" />
-                <field field_ref="vitv" level="2" />
-                <field field_ref="vitw" level="2" />
-                <field field_ref="pres" level="2" />
-                <field field_ref="paprs" level="2" />
-                <field field_ref="mass" level="2" />
-                <field field_ref="zfull" level="2" />
-                <field field_ref="zhalf" level="2" />
-                <field field_ref="rneb" level="2" />
-                <field field_ref="rnebcon" level="2" />
-                <field field_ref="rnebls" level="2" />
-                <field field_ref="rhum" level="2" />
-                <field field_ref="ozone" level="2" />
-                <field field_ref="ozone_daylight" level="2" />
-                <field field_ref="upwd" level="2" />
-                <field field_ref="dtphy" level="2" />
-                <field field_ref="dqphy" level="2" />
-                <field field_ref="pr_con_l" level="2" />
-                <field field_ref="pr_con_i" level="2" />
-                <field field_ref="pr_lsc_l" level="2" />
-                <field field_ref="pr_lsc_i" level="2" />
-                <field field_ref="re" level="5" />
-                <field field_ref="fl" level="5" />
-                <field field_ref="scdnc" level="2" />
-                <field field_ref="reffclws" level="2" />
-                <field field_ref="reffclwc" level="2" />
-                <field field_ref="lcc3d" level="2" />
-                <field field_ref="lcc3dcon" level="2" />
-                <field field_ref="lcc3dstra" level="2" />
-                <field field_ref="clwcon" level="4" />
-                <field field_ref="Ma" level="4" />
-                <field field_ref="dnwd" level="4" />
-                <field field_ref="dnwd0" level="4" />
-                <field field_ref="mc" level="4" />
-                <field field_ref="dtdyn" level="4" />
-                <field field_ref="dqdyn" level="4" />
-                <field field_ref="dudyn" level="4" />
-                <field field_ref="dvdyn" level="4" />
-                <field field_ref="dtcon" level="4" />
-                <field field_ref="ducon" level="4" />
-                <field field_ref="dvcon" level="4" />
-                <field field_ref="dqcon" level="4" />
-                <field field_ref="dtwak" level="4" />
-                <field field_ref="dqwak" level="4" />
-                <field field_ref="wake_deltat" level="4" />
-                <field field_ref="wake_deltaq" level="4" />
-                <field field_ref="wake_omg" level="4" />
-                <field field_ref="wdtrainA" level="4" />
-                <field field_ref="wdtrainM" level="4" />
-                <field field_ref="Vprecip" level="10" />
-                <field field_ref="ftd" level="4" />
-                <field field_ref="fqd" level="4" />
-                <field field_ref="dtlsc" level="4" />
-                <field field_ref="dtlschr" level="4" />
-                <field field_ref="dqlsc" level="4" />
-                <field field_ref="beta_prec" level="4" />
-                <field field_ref="dtvdf" level="4" />
-                <field field_ref="dtdis" level="4" />
-                <field field_ref="dqvdf" level="4" />
-                <field field_ref="dteva" level="4" />
-                <field field_ref="dqeva" level="4" />
-                <field field_ref="dqlscth" level="10" />
-                <field field_ref="dqlscst" level="10" />
-                <field field_ref="dtlscth" level="10" />
-                <field field_ref="dtlscst" level="10" />
-                <field field_ref="ptconvth" level="10" />
-                <field field_ref="ptconv" level="4" />
-                <field field_ref="ratqs" level="4" />
-                <field field_ref="dtthe" level="4" />
-                <field field_ref="f_th" level="4" />
-                <field field_ref="e_th" level="4" />
-                <field field_ref="w_th" level="4" />
-                <field field_ref="lambda_th" level="10" />
-                <field field_ref="q_th" level="4" />
-                <field field_ref="a_th" level="4" />
-                <field field_ref="d_th" level="4" />
-                <field field_ref="dqthe" level="4" />
-                <field field_ref="dtajs" level="4" />
-                <field field_ref="dqajs" level="4" />
-                <field field_ref="dtswr" level="4" />
-                <field field_ref="dtsw0" level="4" />
-                <field field_ref="dtlwr" level="4" />
-                <field field_ref="dtlw0" level="4" />
-                <field field_ref="dtec"  level="4" />
-                <field field_ref="duvdf" level="4" />
-                <field field_ref="dvvdf" level="4" />
-                <field field_ref="duoro" level="4" />
-                <field field_ref="dvoro" level="4" />
-                <field field_ref="dulif" level="4" />
-                <field field_ref="dvlif" level="4" />
-                <field field_ref="duhin" level="4" />
-                <field field_ref="dvhin" level="4" />
-                <field field_ref="dtoro" level="4" />
-                <field field_ref="dtlif" level="4" />
-                <field field_ref="dthin" level="4" />
-                <field field_ref="rsu" level="4" />
-                <field field_ref="rsd" level="4" />
-                <field field_ref="rlu" level="4" />
-                <field field_ref="rld" level="4" />
-                <field field_ref="rsucs" level="4" />
-                <field field_ref="rsdcs" level="4" />
-                <field field_ref="rlucs" level="4" />
-                <field field_ref="rldcs" level="4" />
-                <field field_ref="tnt"  level="4" />
-                <field field_ref="tntc" level="4" />
-                <field field_ref="tntr" level="4" />
-                <field field_ref="tntscpbl" level="4" />
-                <field field_ref="tnhus"    level="4" />
-                <field field_ref="tnhusc"   level="4" />
-                <field field_ref="tnhusscpbl" level="4" />
-                <field field_ref="evu" level="4" />
-                <field field_ref="h2o" level="4" />
-                <field field_ref="mcd" level="4" />
-                <field field_ref="dmc" level="4" />
-                <field field_ref="ref_liq" level="4" />
-                <field field_ref="ref_ice" level="4" />
-                <field field_ref="rsu4co2" level="5" />
-                <field field_ref="rlu4co2" level="5" />
-                <field field_ref="rsucs4co2" level="5" />
-                <field field_ref="rlucs4co2" level="5" />
-                <field field_ref="rsd4co2" level="5" />
-                <field field_ref="rld4co2" level="5" />
-                <field field_ref="rsdcs4co2" level="5" />
-                <field field_ref="rldcs4co2" level="5" />
-            </field_group>
-        </file>
-
-        </file_group>
-    </file_definition>
-   
Index: DZ5/branches/testing/DefLists/iodef_file_histstn.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/iodef_file_histstn.xml	(revision 2055)
+++ 	(revision )
@@ -1,510 +1,0 @@
-<file_definition>
-    <file_group id="defile">
-        <file id="histstn" name="Xhiststn" output_freq="1h" output_level="5" enabled=".FALSE.">
-            <!-- VARS 2D -->
-            <field_group operation="average" freq_op="1ts">
-                <field field_ref="Ap" level="1" />
-                <field field_ref="Bp" level="1" />
-                <field field_ref="Alt" level="1" />
-                <field field_ref="phis" level="1" />
-                <field field_ref="aire" level="1" operation="once" />
-                <field field_ref="contfracATM" level="10" operation="once" />
-                <field field_ref="contfracOR" level="10" />
-                <field field_ref="aireTER" level="10" />
-                <field field_ref="flat" level="10" />
-                <field field_ref="slp" level="10" />
-                <field field_ref="tsol" level="10" />
-                <field field_ref="t2m" level="10" />
-                <field field_ref="t2m_min" level="10" operation="minimum" />
-                <field field_ref="t2m_max" level="10" operation="maximum" />
-                <field field_ref="t2m_ter" level="10" />
-                <field field_ref="t2m_lic" level="10" />
-                <field field_ref="t2m_oce" level="10" />
-                <field field_ref="t2m_sic" level="10" />
-                <field field_ref="wind10m" level="10" />
-                <field field_ref="wind10max" level="10" />
-                <field field_ref="sicf" level="10" />
-                <field field_ref="q2m" level="10" />
-                <field field_ref="ustar" level="10" />
-                <field field_ref="u10m" level="10" />
-                <field field_ref="v10m" level="10" />
-                <field field_ref="psol" level="10" />
-                <field field_ref="qsurf" level="10" />
-                <field field_ref="ustar_ter" level="10" />
-                <field field_ref="ustar_lic" level="10" />
-                <field field_ref="ustar_oce" level="10" />
-                <field field_ref="ustar_sic" level="10" />
-                <field field_ref="wstar_ter" level="10" />
-                <field field_ref="wstar_lic" level="10" />
-                <field field_ref="wstar_oce" level="10" />
-                <field field_ref="wstar_sic" level="10" />
-                <field field_ref="wstar" level="10" />
-                <field field_ref="u10m_ter" level="10" />
-                <field field_ref="u10m_lic" level="10" />
-                <field field_ref="u10m_oce" level="10" />
-                <field field_ref="u10m_sic" level="10" />
-                <field field_ref="v10m_ter" level="10" />
-                <field field_ref="v10m_lic" level="10" />
-                <field field_ref="v10m_oce" level="10" />
-                <field field_ref="v10m_sic" level="10" />
-                <field field_ref="qsol" level="10" />
-                <field field_ref="ndayrain" level="10" operation="instant" />
-                <field field_ref="precip" level="10" />
-                <field field_ref="plul" level="10" />
-                <field field_ref="pluc" level="10" />
-                <field field_ref="snow" level="10" />
-                <field field_ref="evap" level="10" />
-                <field field_ref="evap_ter" level="10" />
-                <field field_ref="evap_lic" level="10" />
-                <field field_ref="evap_oce" level="10" />
-                <field field_ref="evap_sic" level="10" />
-                <field field_ref="msnow" level="10" />
-                <field field_ref="fsnow" level="10" />
-                <field field_ref="tops" level="10" />
-                <field field_ref="tops0" level="10" />
-                <field field_ref="topl" level="10" />
-                <field field_ref="topl0" level="10" />
-                <field field_ref="SWupTOA" level="10" />
-                <field field_ref="SWupTOAclr" level="10" />
-                <field field_ref="SWdnTOA" level="10" />
-                <field field_ref="SWdnTOAclr" level="10" />
-                <field field_ref="nettop" level="10" />
-                <field field_ref="SWup200" level="10" />
-                <field field_ref="SWup200clr" level="10" />
-                <field field_ref="SWdn200" level="10" />
-                <field field_ref="SWdn200clr" level="10" />
-                <field field_ref="LWup200" level="10" />
-                <field field_ref="LWup200clr" level="10" />
-                <field field_ref="LWdn200" level="10" />
-                <field field_ref="LWdn200clr" level="10" />
-                <field field_ref="sols" level="10" />
-                <field field_ref="sols0" level="10" />
-                <field field_ref="soll" level="10" />
-                <field field_ref="soll0" level="10" />
-                <field field_ref="radsol" level="10" />
-                <field field_ref="SWupSFC" level="10" />
-                <field field_ref="SWupSFCclr" level="10" />
-                <field field_ref="SWdnSFC" level="10" />
-                <field field_ref="SWdnSFCclr" level="10" />
-                <field field_ref="LWupSFC" level="10" />
-                <field field_ref="LWupSFCclr" level="10" />
-                <field field_ref="LWdnSFC" level="10" />
-                <field field_ref="LWdnSFCclr" level="10" />
-                <field field_ref="bils" level="10" />
-                <field field_ref="bils_tke" level="10" />
-                <field field_ref="bils_diss" level="10" />
-                <field field_ref="bils_ec" level="10" />
-                <field field_ref="bils_kinetic" level="10" />
-                <field field_ref="bils_enthalp" level="10" />
-                <field field_ref="bils_latent" level="10" />
-                <field field_ref="sens" level="10" />
-                <field field_ref="fder" level="10" />
-                <field field_ref="ffonte" level="10" />
-                <field field_ref="fqcalving" level="10" />
-                <field field_ref="fqfonte" level="10" />
-                <field field_ref="taux" level="10" />
-                <field field_ref="tauy" level="10" />
-                <field field_ref="taux_ter" level="10" />
-                <field field_ref="taux_lic" level="10" />
-                <field field_ref="taux_oce" level="10" />
-                <field field_ref="taux_sic" level="10" />
-                <field field_ref="tauy_ter" level="10" />
-                <field field_ref="tauy_lic" level="10" />
-                <field field_ref="tauy_oce" level="10" />
-                <field field_ref="tauy_sic" level="10" />
-                <field field_ref="pourc_ter" level="10" />
-                <field field_ref="pourc_lic" level="10" />
-                <field field_ref="pourc_oce" level="10" />
-                <field field_ref="pourc_sic" level="10" />
-                <field field_ref="fract_ter" level="10" />
-                <field field_ref="fract_lic" level="10" />
-                <field field_ref="fract_oce" level="10" />
-                <field field_ref="fract_sic" level="10" />
-                <field field_ref="tsol_ter" level="10" />
-                <field field_ref="tsol_lic" level="10" />
-                <field field_ref="tsol_oce" level="10" />
-                <field field_ref="tsol_sic" level="10" />
-                <field field_ref="evappot_ter" level="10" />
-                <field field_ref="evappot_lic" level="10" />
-                <field field_ref="evappot_oce" level="10" />
-                <field field_ref="evappot_sic" level="10" />
-                <field field_ref="sens_ter" level="10" />
-                <field field_ref="sens_lic" level="10" />
-                <field field_ref="sens_oce" level="10" />
-                <field field_ref="sens_sic" level="10" />
-                <field field_ref="lat_ter" level="10" />
-                <field field_ref="lat_lic" level="10" />
-                <field field_ref="lat_oce" level="10" />
-                <field field_ref="lat_sic" level="10" />
-                <field field_ref="flw_ter" level="10" />
-                <field field_ref="flw_lic" level="10" />
-                <field field_ref="flw_oce" level="10" />
-                <field field_ref="flw_sic" level="10" />
-                <field field_ref="fsw_ter" level="10" />
-                <field field_ref="fsw_lic" level="10" />
-                <field field_ref="fsw_oce" level="10" />
-                <field field_ref="fsw_sic" level="10" />
-                <field field_ref="wbils_ter" level="10" />
-                <field field_ref="wbils_lic" level="10" />
-                <field field_ref="wbils_oce" level="10" />
-                <field field_ref="wbils_sic" level="10" />
-                <field field_ref="wbilo_ter" level="10" />
-                <field field_ref="wbilo_lic" level="10" />
-                <field field_ref="wbilo_oce" level="10" />
-                <field field_ref="wbilo_sic" level="10" />
-                <field field_ref="cdrm" level="10" />
-                <field field_ref="cdrh" level="10" />
-                <field field_ref="cldl" level="10" />
-                <field field_ref="cldm" level="10" />
-                <field field_ref="cldh" level="10" />
-                <field field_ref="cldt" level="10" />
-                <field field_ref="cldq" level="10" />
-                <field field_ref="lwp" level="10" />
-                <field field_ref="iwp" level="10" />
-                <field field_ref="ue" level="10" />
-                <field field_ref="ve" level="10" />
-                <field field_ref="uq" level="10" />
-                <field field_ref="vq" level="10" />
-                <field field_ref="cape" level="10" />
-                <field field_ref="pbase" level="10" />
-                <field field_ref="ptop" level="10" />
-                <field field_ref="fbase" level="10" />
-                <field field_ref="plcl" level="10" />
-                <field field_ref="plfc" level="10" />
-                <field field_ref="wbeff" level="10" />
-                <field field_ref="prw" level="10" />
-                <field field_ref="s_pblh" level="10" />
-                <field field_ref="s_pblt" level="10" />
-                <field field_ref="s_lcl" level="10" />
-                <field field_ref="s_therm" level="10" />
-                <field field_ref="slab_bils_oce" level="10" />
-                <field field_ref="ale_bl" level="10" />
-                <field field_ref="alp_bl" level="10" />
-                <field field_ref="ale_wk" level="10" />
-                <field field_ref="alp_wk" level="10" />
-                <field field_ref="ale" level="10" />
-                <field field_ref="alp" level="10" />
-                <field field_ref="cin" level="10" />
-                <field field_ref="wape" level="10" />
-                <field field_ref="n2" level="10" />
-                <field field_ref="s2" level="10" />
-                <field field_ref="proba_notrig" level="10" />
-                <field field_ref="random_notrig" level="10" />
-                <field field_ref="ale_bl_stat" level="10" />
-                <field field_ref="ale_bl_trig" level="10" />
-                <field field_ref="alp_bl_det" level="10" />
-                <field field_ref="alp_bl_fluct_m" level="10" />
-                <field field_ref="alp_bl_fluct_tke" level="10" />
-                <field field_ref="alp_bl_conv" level="10" />
-                <field field_ref="alp_bl_stat" level="10" />
-
-                <field_group operation="instant">
-                    <field field_ref="u850" level="10" />
-                    <field field_ref="u700" level="10" />
-                    <field field_ref="u500" level="10" />
-                    <field field_ref="u200" level="10" />
-                    <field field_ref="u100" level="10" />
-                    <field field_ref="u50" level="10" />
-                    <field field_ref="u10" level="10" />
-                    <field field_ref="v850" level="10" />
-                    <field field_ref="v700" level="10" />
-                    <field field_ref="v500" level="10" />
-                    <field field_ref="v200" level="10" />
-                    <field field_ref="v100" level="10" />
-                    <field field_ref="v50" level="10" />
-                    <field field_ref="v10" level="10" />
-                    <field field_ref="w850" level="10" />
-                    <field field_ref="w700" level="10" />
-                    <field field_ref="w500" level="10" />
-                    <field field_ref="w200" level="10" />
-                    <field field_ref="w100" level="10" />
-                    <field field_ref="w50" level="10" />
-                    <field field_ref="w10" level="10" />
-                    <field field_ref="t850" level="10" />
-                    <field field_ref="t700" level="10" />
-                    <field field_ref="t500" level="10" />
-                    <field field_ref="t200" level="10" />
-                    <field field_ref="t100" level="10" />
-                    <field field_ref="t50" level="10" />
-                    <field field_ref="t10" level="10" />
-                    <field field_ref="q850" level="10" />
-                    <field field_ref="q700" level="10" />
-                    <field field_ref="q500" level="10" />
-                    <field field_ref="q200" level="10" />
-                    <field field_ref="q100" level="10" />
-                    <field field_ref="q50" level="10" />
-                    <field field_ref="q10" level="10" />
-                    <field field_ref="z850" level="10" />
-                    <field field_ref="z700" level="10" />
-                    <field field_ref="z500" level="10" />
-                    <field field_ref="z200" level="10" />
-                    <field field_ref="z100" level="10" />
-                    <field field_ref="z50" level="10" />
-                    <field field_ref="z10" level="10" />
-                </field_group>
-
-                <field field_ref="t_oce_sic" level="10" />
-                <field field_ref="weakinv" level="10" />
-                <field field_ref="dthmin" level="10" />
-                <field field_ref="u10_ter" level="10" />
-                <field field_ref="u10_lic" level="10" />
-                <field field_ref="u10_oce" level="10" />
-                <field field_ref="u10_sic" level="10" />
-                <field field_ref="v10_ter" level="10" />
-                <field field_ref="v10_lic" level="10" />
-                <field field_ref="v10_oce" level="10" />
-                <field field_ref="v10_sic" level="10" />
-                <field field_ref="rh2m" level="10" />
-                <field field_ref="rh2m_min" level="10" operation="minimum" />
-                <field field_ref="rh2m_max" level="10" operation="maximum" />
-                <field field_ref="qsat2m" level="10" />
-                <field field_ref="tpot" level="10" />
-                <field field_ref="tpote" level="10" />
-                <field field_ref="tke" level="10" />
-                <field field_ref="tke_ter" level="10" />
-                <field field_ref="tke_lic" level="10" />
-                <field field_ref="tke_oce" level="10" />
-                <field field_ref="tke_sic" level="10" />
-                <field field_ref="tke_max_ter" level="10" operation="maximum" />
-                <field field_ref="tke_max_lic" level="10" operation="maximum" />
-                <field field_ref="tke_max_oce" level="10" operation="maximum" />
-                <field field_ref="tke_max_sic" level="10" operation="maximum" />
-                <field field_ref="SWnetOR" level="10" />
-                <field field_ref="SWdownOR" level="10" />
-                <field field_ref="LWdownOR" level="10" />
-                <field field_ref="snowl" level="10" />
-                <field field_ref="cape_max" level="10" operation="maximum" />
-                <field field_ref="solldown" level="10" />
-                <field field_ref="dtsvdfo" level="10" />
-                <field field_ref="dtsvdft" level="10" />
-                <field field_ref="dtsvdfg" level="10" />
-                <field field_ref="dtsvdfi" level="10" />
-                <field field_ref="rugs" level="10" />
-                <field field_ref="topswad" level="10" />
-                <field field_ref="topswad0" level="10" />
-                <field field_ref="topswai" level="10" />
-                <field field_ref="solswad" level="10" />
-                <field field_ref="solswad0" level="10" />
-                <field field_ref="solswai" level="10" />
-                <field field_ref="OD550_ASBCM" level="10" />
-                <field field_ref="OD550_ASPOMM" level="10" />
-                <field field_ref="OD550_ASSO4M" level="10" />
-                <field field_ref="OD550_CSSO4M" level="10" />
-                <field field_ref="OD550_SSSSM" level="10" />
-                <field field_ref="OD550_ASSSM" level="10" />
-                <field field_ref="OD550_CSSSM" level="10" />
-                <field field_ref="OD550_CIDUSTM" level="10" />
-                <field field_ref="OD550_AIBCM" level="10" />
-                <field field_ref="OD550_AIPOMM" level="10" />
-                <field field_ref="OD550_STRAT" level="10" />
-                <field field_ref="od550aer" level="10" />
-                <field field_ref="od865aer" level="10" />
-                <field field_ref="absvisaer" level="10" />
-                <field field_ref="od550lt1aer" level="10" />
-                <field field_ref="sconcso4" level="10" />
-                <field field_ref="sconcoa" level="10" />
-                <field field_ref="sconcbc" level="10" />
-                <field field_ref="sconcss" level="10" />
-                <field field_ref="sconcdust" level="10" />
-                <field field_ref="loadso4" level="10" />
-                <field field_ref="loadoa" level="10" />
-                <field field_ref="loadbc" level="10" />
-                <field field_ref="loadss" level="10" />
-                <field field_ref="loaddust" level="10" />
-                <field field_ref="swtoaas_nat" level="10" />
-                <field field_ref="swsrfas_nat" level="10" />
-                <field field_ref="swtoacs_nat" level="10" />
-                <field field_ref="swsrfcs_nat" level="10" />
-                <field field_ref="swtoaas_ant" level="10" />
-                <field field_ref="swsrfas_ant" level="10" />
-                <field field_ref="swtoacs_ant" level="10" />
-                <field field_ref="swsrfcs_ant" level="10" />
-                <field field_ref="swtoacf_nat" level="10" />
-                <field field_ref="swsrfcf_nat" level="10" />
-                <field field_ref="swtoacf_ant" level="10" />
-                <field field_ref="swsrfcf_ant" level="10" />
-                <field field_ref="swtoacf_zero" level="10" />
-                <field field_ref="swsrfcf_zero" level="10" />
-                <field field_ref="cldncl" level="10" />
-                <field field_ref="reffclwtop" level="10" />
-                <field field_ref="cldnvi" level="10" />
-                <field field_ref="lcc" level="10" />
-                <field field_ref="wvapp" level="10" />
-                <field field_ref="albe_ter" level="10" />
-                <field field_ref="albe_lic" level="10" />
-                <field field_ref="albe_oce" level="10" />
-                <field field_ref="albe_sic" level="10" />
-                <field field_ref="ages_ter" level="10" />
-                <field field_ref="ages_lic" level="10" />
-                <field field_ref="ages_oce" level="10" />
-                <field field_ref="ages_sic" level="10" />
-                <field field_ref="rugs_ter" level="10" />
-                <field field_ref="rugs_lic" level="10" />
-                <field field_ref="rugs_oce" level="10" />
-                <field field_ref="rugs_sic" level="10" />
-                <field field_ref="alb1" level="10" />
-                <field field_ref="alb2" level="10" />
-                <field field_ref="ftime_con" level="10" operation="instant" />
-                <field field_ref="wake_h" level="10" />
-                <field field_ref="wake_s" level="10" />
-                <field field_ref="plulth" level="10" />
-                <field field_ref="plulst" level="10" />
-                <field field_ref="lmaxth" level="10" />
-                <field field_ref="ftime_th" level="10" />
-                <field field_ref="f0_th" level="10" />
-                <field field_ref="zmax_th" level="10" />
-                <field field_ref="rsut4co2" level="10" />
-                <field field_ref="rlut4co2" level="10" />
-                <field field_ref="rsutcs4co2" level="10" />
-                <field field_ref="rlutcs4co2" level="10" />
-            </field_group>
-
-            <!-- VARS 3D -->
-            <field_group operation="average" freq_op="1ts" axis_ref="presnivs_histstn">
-                <field field_ref="cldtau" level="10" />
-                <field field_ref="cldemi" level="10" />
-                <field field_ref="tke_max" level="10" operation="maximum" />
-                <field field_ref="kz" level="10" />
-                <field field_ref="kz_max" level="10" operation="maximum" />
-                <field field_ref="concso4" level="10" />
-                <field field_ref="concoa" level="10" />
-                <field field_ref="concbc" level="10" />
-                <field field_ref="concss" level="10" />
-                <field field_ref="concdust" level="10" />
-                <field field_ref="ec550aer" level="10" />
-                <field field_ref="lwcon" level="10" />
-                <field field_ref="iwcon" level="10" />
-                <field field_ref="temp" level="10" />
-                <field field_ref="theta" level="10" />
-                <field field_ref="ovap" level="10" />
-                <field field_ref="ovapinit" level="10" />
-                <field field_ref="oliq" level="10" />
-                <field field_ref="geop" level="10" />
-                <field field_ref="vitu" level="10" />
-                <field field_ref="vitv" level="10" />
-                <field field_ref="vitw" level="10" />
-                <field field_ref="pres" level="10" />
-                <field field_ref="paprs" level="10" />
-                <field field_ref="mass" level="10" />
-                <field field_ref="zfull" level="10" />
-                <field field_ref="zhalf" level="10" />
-                <field field_ref="rneb" level="10" />
-                <field field_ref="rnebcon" level="10" />
-                <field field_ref="rnebls" level="10" />
-                <field field_ref="rhum" level="10" />
-                <field field_ref="ozone" level="10" />
-                <field field_ref="ozone_daylight" level="10" />
-                <field field_ref="upwd" level="10" />
-                <field field_ref="dtphy" level="10" />
-                <field field_ref="dqphy" level="10" />
-                <field field_ref="pr_con_l" level="10" />
-                <field field_ref="pr_con_i" level="10" />
-                <field field_ref="pr_lsc_l" level="10" />
-                <field field_ref="pr_lsc_i" level="10" />
-                <field field_ref="re" level="10" />
-                <field field_ref="fl" level="10" />
-                <field field_ref="scdnc" level="10" />
-                <field field_ref="reffclws" level="10" />
-                <field field_ref="reffclwc" level="10" />
-                <field field_ref="lcc3d" level="10" />
-                <field field_ref="lcc3dcon" level="10" />
-                <field field_ref="lcc3dstra" level="10" />
-                <field field_ref="clwcon" level="10" />
-                <field field_ref="Ma" level="10" />
-                <field field_ref="dnwd" level="10" />
-                <field field_ref="dnwd0" level="10" />
-                <field field_ref="mc" level="10" />
-                <field field_ref="dtdyn" level="10" />
-                <field field_ref="dqdyn" level="10" />
-                <field field_ref="dudyn" level="10" />
-                <field field_ref="dvdyn" level="10" />
-                <field field_ref="dtcon" level="10" />
-                <field field_ref="ducon" level="10" />
-                <field field_ref="dvcon" level="10" />
-                <field field_ref="dqcon" level="10" />
-                <field field_ref="dtwak" level="10" />
-                <field field_ref="dqwak" level="10" />
-                <field field_ref="wake_deltat" level="10" />
-                <field field_ref="wake_deltaq" level="10" />
-                <field field_ref="wake_omg" level="10" />
-                <field field_ref="wdtrainA" level="10" />
-                <field field_ref="wdtrainM" level="10" />
-                <field field_ref="Vprecip" level="10" />
-                <field field_ref="ftd" level="10" />
-                <field field_ref="fqd" level="10" />
-                <field field_ref="dtlsc" level="10" />
-                <field field_ref="dtlschr" level="10" />
-                <field field_ref="dqlsc" level="10" />
-                <field field_ref="beta_prec" level="10" />
-                <field field_ref="dtvdf" level="10" />
-                <field field_ref="dtdis" level="10" />
-                <field field_ref="dqvdf" level="10" />
-                <field field_ref="dteva" level="10" />
-                <field field_ref="dqeva" level="10" />
-                <field field_ref="dqlscth" level="10" />
-                <field field_ref="dqlscst" level="10" />
-                <field field_ref="dtlscth" level="10" />
-                <field field_ref="dtlscst" level="10" />
-                <field field_ref="ptconvth" level="10" />
-                <field field_ref="ptconv" level="10" />
-                <field field_ref="ratqs" level="10" />
-                <field field_ref="dtthe" level="10" />
-                <field field_ref="f_th" level="10" />
-                <field field_ref="e_th" level="10" />
-                <field field_ref="w_th" level="10" />
-                <field field_ref="lambda_th" level="10" />
-                <field field_ref="q_th" level="10" />
-                <field field_ref="a_th" level="10" />
-                <field field_ref="d_th" level="10" />
-                <field field_ref="dqthe" level="10" />
-                <field field_ref="dtajs" level="10" />
-                <field field_ref="dqajs" level="10" />
-                <field field_ref="dtswr" level="10" />
-                <field field_ref="dtsw0" level="10" />
-                <field field_ref="dtlwr" level="10" />
-                <field field_ref="dtlw0" level="10" />
-                <field field_ref="dtec" level="10" />
-                <field field_ref="duvdf" level="10" />
-                <field field_ref="dvvdf" level="10" />
-                <field field_ref="duoro" level="10" />
-                <field field_ref="dvoro" level="10" />
-                <field field_ref="dulif" level="10" />
-                <field field_ref="dvlif" level="10" />
-                <field field_ref="duhin" level="10" />
-                <field field_ref="dvhin" level="10" />
-                <field field_ref="dtoro" level="10" />
-                <field field_ref="dtlif" level="10" />
-                <field field_ref="dthin" level="10" />
-                <field field_ref="rsu" level="10" />
-                <field field_ref="rsd" level="10" />
-                <field field_ref="rlu" level="10" />
-                <field field_ref="rld" level="10" />
-                <field field_ref="rsucs" level="10" />
-                <field field_ref="rsdcs" level="10" />
-                <field field_ref="rlucs" level="10" />
-                <field field_ref="rldcs" level="10" />
-                <field field_ref="tnt" level="10" />
-                <field field_ref="tntc" level="10" />
-                <field field_ref="tntr" level="10" />
-                <field field_ref="tntscpbl" level="10" />
-                <field field_ref="tnhus" level="10" />
-                <field field_ref="tnhusc" level="10" />
-                <field field_ref="tnhusscpbl" level="10" />
-                <field field_ref="evu" level="10" />
-                <field field_ref="h2o" level="10" />
-                <field field_ref="mcd" level="10" />
-                <field field_ref="dmc" level="10" />
-                <field field_ref="ref_liq" level="10" />
-                <field field_ref="ref_ice" level="10" />
-                <field field_ref="rsu4co2" level="10" />
-                <field field_ref="rlu4co2" level="10" />
-                <field field_ref="rsucs4co2" level="10" />
-                <field field_ref="rlucs4co2" level="10" />
-                <field field_ref="rsd4co2" level="10" />
-                <field field_ref="rld4co2" level="10" />
-                <field field_ref="rsdcs4co2" level="10" />
-                <field field_ref="rldcs4co2" level="10" />
-            </field_group>
-        </file>
-    </file_group>
-</file_definition>
Index: /LMDZ5/branches/testing/create_make_gcm
===================================================================
--- /LMDZ5/branches/testing/create_make_gcm	(revision 2055)
+++ /LMDZ5/branches/testing/create_make_gcm	(revision 2056)
@@ -49,8 +49,6 @@
 echo "LOCAL_DIR=`echo $localdir`"
 echo 'BIBIO    = $(LIBF)/bibio'
-echo 'DYN3D_COMMON   = $(LIBF)/dyn3d_common'
 echo "FILTRE   = filtre"
 echo "PHYS  = "
-echo "DYN  = dyn "
 echo 'LIBPHY = $(LIBO)/libphy$(PHYS).a'
 echo 'DIRMAIN=dyn$(DIM)d$(FLAG_PARA)'
@@ -60,14 +58,8 @@
 echo
 echo '# Les differentes librairies pour l"edition des liens:'
-echo
-echo 'dyn3d            = $(LIBO)/libdyn3d.a $(LIBO)/lib$(FILTRE).a'
-echo 'dyn3dpar      = $(LIBO)/libdyn3dpar.a $(LIBO)/lib$(FILTRE).a'
-echo 'dyn2d            = $(LIBO)/libdyn2d.a'
-echo 'dyn1d            = $(LIBO)/libdyn1d.a'
-echo 'L_DYN      = -ldyn$(DIM)d$(FLAG_PARA)'
+echo 'L_DYN      = -ldyn$(DIM)d$(FLAG_PARA) -ldyn3d_common'
 echo 'L_FILTRE   = -l$(FILTRE)'
 echo 'L_PHY = -lphy$(PHYS) '
 echo 'L_BIBIO    = -lbibio'
-echo 'L_DYN3D_COMMON    = -ldyn3d_common'
 echo 'L_ADJNT    ='
 echo 'L_COSP     = -lcosp'
@@ -93,7 +85,8 @@
 echo
 echo "PROG = code"
+echo 'DYN  = dyn$(DIM)d'
 echo
 #echo 'main : chimie $(DYN) bibio phys $(OPTION_DEP) '
-echo 'main : $(DYN) bibio dyn3d_common phys $(OPTION_DEP) '
+echo 'main : $(DYN) bibio phys $(OPTION_DEP) '
 echo '	cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\'
 echo '	cd $(LOCAL_DIR); \'
@@ -101,13 +94,13 @@
 echo '	$(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_ADJNT) $(L_COSP) $(L_PHY) $(L_DYN) $(L_DYN3D_COMMON) $(L_BIBIO) $(L_DYN3D_COMMON) $(L_PHY) $(L_DYN) $(L_FILTRE) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o '
 echo
-echo 'dyn : $(LIBO)/libdyn$(DIM)d$(FLAG_PARA).a $(FILTRE)$(DIM)d'
-echo
 echo 'phys : $(LIBPHY)'
+echo 'dyn3d : $(LIBO)/libdyn$(DIM)d$(FLAG_PARA).a $(LIBO)/lib$(FILTRE).a $(LIBO)/libdyn3d_common.a'
+echo 'dyn2d : $(LIBO)/libdyn2d.a'
+echo 'dyn1d :'
+echo
 echo
 #echo 'chimie : $(LIBO)/libchimie.a'
 echo
 echo 'bibio : $(LIBO)/libbibio.a'
-echo
-echo 'dyn3d_common : $(LIBO)/libdyn3d_common.a'
 echo
 echo 'adjnt : $(LIBO)/libadjnt.a'
Index: /LMDZ5/branches/testing/libf/bibio/wxios.F90
===================================================================
--- /LMDZ5/branches/testing/libf/bibio/wxios.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/bibio/wxios.F90	(revision 2056)
@@ -26,17 +26,4 @@
     
     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    !   str + i   =>   str_i   !!!!!!!!!!!!!!!!!!!!
-    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    
-    SUBROUTINE concat(str, str2, str_str2)
-        CHARACTER(len=*), INTENT(IN) :: str, str2
-        CHARACTER(len=20), INTENT(OUT) :: str_str2
-        
-        
-        str_str2 = TRIM(ADJUSTL(str//"_"//TRIM(ADJUSTL(str2))))
-        !IF (prt_level >= 10) WRITE(lunout,*) "Xios. ",str,"+",str2,"=",str_str2
-    END SUBROUTINE concat
-    
-    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     !   36day => 36d etc     !!!!!!!!!!!!!!!!!!!!
     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -109,5 +96,5 @@
     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-    SUBROUTINE wxios_init(xios_ctx_name, locom, outcom)
+    SUBROUTINE wxios_init(xios_ctx_name, locom, outcom, type_ocean)
         IMPLICIT NONE
         INCLUDE 'iniprint.h'
@@ -116,4 +103,5 @@
       INTEGER, INTENT(IN), OPTIONAL :: locom
       INTEGER, INTENT(OUT), OPTIONAL :: outcom
+      CHARACTER(len=6), INTENT(IN), OPTIONAL :: type_ocean
 
     
@@ -142,6 +130,9 @@
         g_ctx_name = xios_ctx_name
         
-        CALL wxios_context_init()
-        
+        ! Si couple alors init fait dans cpl_init
+        IF (.not. PRESENT(type_ocean)) THEN
+            CALL wxios_context_init()
+        ENDIF
+
     END SUBROUTINE wxios_init
 
@@ -158,6 +149,8 @@
         g_ctx = xios_ctx
 
-        IF (prt_level >= 10) WRITE(lunout,*) "wxios_context_init: Current context is ",trim(g_ctx_name)
-
+        IF (prt_level >= 10) THEN
+          WRITE(lunout,*) "wxios_context_init: Current context is ",trim(g_ctx_name)
+          WRITE(lunout,*) "     now call xios_solve_inheritance()"
+        ENDIF
         !Une première analyse des héritages:
         CALL xios_solve_inheritance()
@@ -303,28 +296,34 @@
     ! Pour déclarer un axe vertical !!!!!!!!!!!!!!!
     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    SUBROUTINE wxios_add_vaxis(axisgroup_id, axis_file, axis_size, axis_value)
-        IMPLICIT NONE
-        INCLUDE 'iniprint.h'
-
-        CHARACTER (len=*), INTENT(IN) :: axisgroup_id, axis_file
+    SUBROUTINE wxios_add_vaxis(axis_id, axis_size, axis_value)
+        IMPLICIT NONE
+        INCLUDE 'iniprint.h'
+
+        CHARACTER (len=*), INTENT(IN) :: axis_id
         INTEGER, INTENT(IN) :: axis_size
         REAL, DIMENSION(axis_size), INTENT(IN) :: axis_value
         
-        TYPE(xios_axisgroup) :: axgroup
-        TYPE(xios_axis) :: ax
-        CHARACTER(len=20) :: axis_id
-        
-        
-        !Préparation du nom de l'axe:
-        CALL concat(axisgroup_id, axis_file, axis_id)
+!        TYPE(xios_axisgroup) :: axgroup
+!        TYPE(xios_axis) :: ax
+!        CHARACTER(len=50) :: axis_id 
+        
+!        IF (len_trim(axisgroup_id).gt.len(axis_id)) THEN
+!          WRITE(lunout,*) "wxios_add_vaxis: error, size of axis_id too small!!"
+!          WRITE(lunout,*) "     increase it to at least ",len_trim(axisgroup_id)
+!          CALL abort_gcm("wxios_add_vaxis","len(axis_id) too small",1)
+!        ENDIF
+!        axis_id=trim(axisgroup_id)
         
         !On récupère le groupe d'axes qui va bien:
-        CALL xios_get_axisgroup_handle(axisgroup_id, axgroup)
+        !CALL xios_get_axisgroup_handle(axisgroup_id, axgroup)
         
         !On ajoute l'axe correspondant à ce fichier:
-        CALL xios_add_axis(axgroup, ax, TRIM(ADJUSTL(axis_id)))
+        !CALL xios_add_axis(axgroup, ax, TRIM(ADJUSTL(axis_id)))
         
         !Et on le parametrise:
-        CALL xios_set_axis_attr_hdl(ax, size=axis_size, value=axis_value)
+        !CALL xios_set_axis_attr_hdl(ax, size=axis_size, value=axis_value)
+        
+        ! Ehouarn: New way to declare axis, without axis_group:
+        CALL xios_set_axis_attr(trim(axis_id),size=axis_size,value=axis_value)
         
         !Vérification:
@@ -332,5 +331,5 @@
             IF (prt_level >= 10) WRITE(lunout,*) "wxios_add_vaxis: Axis created: ", TRIM(ADJUSTL(axis_id))
         ELSE
-            WRITE(*,*) "wxios_add_vaxis: Invalid axis: ", TRIM(ADJUSTL(axis_id))
+            WRITE(lunout,*) "wxios_add_vaxis: Invalid axis: ", TRIM(ADJUSTL(axis_id))
         END IF
 
@@ -367,13 +366,18 @@
         
             IF (xios_is_valid_file("X"//fname)) THEN
-                IF (prt_level >= 10) WRITE(lunout,*) "wxios_add_file: New file: ", "X"//fname
-                IF (prt_level >= 10) WRITE(lunout,*) "wxios_add_file: output_freq=",TRIM(ADJUSTL(nffreq)),"; output_lvl=",flvl
+                IF (prt_level >= 10) THEN
+                  WRITE(lunout,*) "wxios_add_file: New file: ", "X"//fname
+                  WRITE(lunout,*) "wxios_add_file: output_freq=",TRIM(ADJUSTL(nffreq)),"; output_lvl=",flvl
+                ENDIF
             ELSE
-                WRITE(*,*) "wxios_add_file: Error, invalid file: ", "X"//trim(fname)
-                WRITE(*,*) "wxios_add_file: output_freq=",TRIM(ADJUSTL(nffreq)),"; output_lvl=",flvl
+                WRITE(lunout,*) "wxios_add_file: Error, invalid file: ", "X"//trim(fname)
+                WRITE(lunout,*) "wxios_add_file: output_freq=",TRIM(ADJUSTL(nffreq)),"; output_lvl=",flvl
             END IF
         ELSE
-            IF (prt_level >= 10) WRITE(lunout,*) "wxios_add_file: File ",trim(fname), " défined using XML."
-                CALL xios_set_file_attr(fname, enabled=.TRUE.)
+            IF (prt_level >= 10) THEN
+              WRITE(lunout,*) "wxios_add_file: File ",trim(fname), " défined using XML."
+            ENDIF
+            ! Ehouarn: add an enable=.true. on top of xml definitions... why???
+            CALL xios_set_file_attr(fname, enabled=.TRUE.)
         END IF
     END SUBROUTINE wxios_add_file
@@ -432,5 +436,5 @@
         CHARACTER(len=*), INTENT(IN) :: op
         
-        CHARACTER(len=20) :: axis_id
+        CHARACTER(len=20) :: axis_id ! Ehouarn: dangerous...
         CHARACTER(len=100) :: operation
         TYPE(xios_file) :: f
@@ -441,6 +445,10 @@
         
         
-        !Préparation du nom de l'axe:
-        CALL concat("presnivs", fname, axis_id)
+        ! Ajout Abd pour NMC:
+        IF (fid.LE.6) THEN
+          axis_id="presnivs"
+        ELSE
+          axis_id="plev"
+        ENDIF
         
         !on prépare le nom de l'opération:
@@ -448,8 +456,7 @@
         
         
-        
         !On selectionne le bon groupe de champs:
         IF (fdim.EQ.2) THEN
-            CALL xios_get_fieldgroup_handle("fields_2D", fieldgroup)
+          CALL xios_get_fieldgroup_handle("fields_2D", fieldgroup)
         ELSE
           CALL xios_get_fieldgroup_handle("fields_3D", fieldgroup)
@@ -515,26 +522,29 @@
             !Sinon on se contente de l'activer:
             CALL xios_set_field_attr(fieldname, enabled=.TRUE.)
+            !NB: This will override an enable=.false. set by a user in the xml file;
+            !   then the only way to not output the field is by changing its
+            !   output level
         ENDIF       
         
     END SUBROUTINE wxios_add_field_to_file
     
-    SUBROUTINE wxios_update_calendar(ito)
-        INTEGER, INTENT(IN) :: ito
-        CALL xios_update_calendar(ito)
-    END SUBROUTINE wxios_update_calendar
-    
-    SUBROUTINE wxios_write_2D(fieldname, fdata)
-        CHARACTER(len=*), INTENT(IN) :: fieldname
-        REAL, DIMENSION(:,:), INTENT(IN) :: fdata
-
-        CALL xios_send_field(fieldname, fdata)
-    END SUBROUTINE wxios_write_2D
-    
-    SUBROUTINE wxios_write_3D(fieldname, fdata)
-        CHARACTER(len=*), INTENT(IN) :: fieldname
-        REAL, DIMENSION(:,:,:), INTENT(IN) :: fdata
-        
-        CALL xios_send_field(fieldname, fdata)
-    END SUBROUTINE wxios_write_3D
+!    SUBROUTINE wxios_update_calendar(ito)
+!        INTEGER, INTENT(IN) :: ito
+!        CALL xios_update_calendar(ito)
+!    END SUBROUTINE wxios_update_calendar
+!    
+!    SUBROUTINE wxios_write_2D(fieldname, fdata)
+!        CHARACTER(len=*), INTENT(IN) :: fieldname
+!        REAL, DIMENSION(:,:), INTENT(IN) :: fdata
+!
+!        CALL xios_send_field(fieldname, fdata)
+!    END SUBROUTINE wxios_write_2D
+    
+!    SUBROUTINE wxios_write_3D(fieldname, fdata)
+!        CHARACTER(len=*), INTENT(IN) :: fieldname
+!        REAL, DIMENSION(:,:,:), INTENT(IN) :: fdata
+!        
+!        CALL xios_send_field(fieldname, fdata)
+!    END SUBROUTINE wxios_write_3D
     
     SUBROUTINE wxios_closedef()
Index: /LMDZ5/branches/testing/libf/dyn3d/calfis.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d/calfis.F	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3d/calfis.F	(revision 2056)
@@ -163,9 +163,4 @@
       REAL unskap, pksurcp
 c
-cIM diagnostique PVteta, Amip2
-      INTEGER,PARAMETER :: ntetaSTD=3
-      REAL,SAVE :: rtetaSTD(ntetaSTD)=(/350.,380.,405./) ! Earth-specific, beware !!
-      REAL PVteta(ngridmx,ntetaSTD)
-c
       REAL flxwfi(ngridmx,llm)  ! Flux de masse verticale sur la grille physiq
 c
@@ -431,14 +426,4 @@
 
       ENDDO
-c
-      if (planet_type=="earth") then
-#ifdef CPP_PHYS
-! PVtheta calls tetalevel, which is in the physics
-cIM calcul PV a teta=350, 380, 405K
-      CALL PVtheta(ngridmx,llm,pucov,pvcov,pteta,
-     $           ztfi,zplay,zplev,
-     $           ntetaSTD,rtetaSTD,PVteta)
-#endif
-      endif
 c
 c On change de grille, dynamique vers physiq, pour le flux de masse verticale
@@ -491,7 +476,5 @@
      .             zdqfi,
      .             zdpsrf,
-cIM diagnostique PVteta, Amip2          
-     .             pducov,
-     .             PVteta)
+     .             pducov)
 
       else if ( planet_type=="generic" ) then
Index: /LMDZ5/branches/testing/libf/dyn3d/conf_gcm.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d/conf_gcm.F	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3d/conf_gcm.F	(revision 2056)
@@ -2,8 +2,8 @@
 ! $Id$
 !
-c
-c
+!
+!
       SUBROUTINE conf_gcm( tapedef, etatinit, clesphy0 )
-c
+!
       USE control_mod
 #ifdef CPP_IOIPSL
@@ -17,14 +17,14 @@
 
       IMPLICIT NONE
-c-----------------------------------------------------------------------
-c     Auteurs :   L. Fairhead , P. Le Van  .
-c
-c     Arguments :
-c
-c     tapedef   :
-c     etatinit  :     = TRUE   , on ne  compare pas les valeurs des para- 
-c     -metres  du zoom  avec  celles lues sur le fichier start .
-c      clesphy0 :  sortie  .
-c
+!-----------------------------------------------------------------------
+!     Auteurs :   L. Fairhead , P. Le Van  .
+!
+!     Arguments :
+!
+!     tapedef   :
+!     etatinit  :     = TRUE   , on ne  compare pas les valeurs des para- 
+!     -metres  du zoom  avec  celles lues sur le fichier start .
+!      clesphy0 :  sortie  .
+!
        LOGICAL etatinit
        INTEGER tapedef
@@ -33,7 +33,7 @@
        PARAMETER(     longcles = 20 )
        REAL clesphy0( longcles )
-c
-c   Declarations :
-c   --------------
+!
+!   Declarations :
+!   --------------
 #include "dimensions.h"
 #include "paramet.h"
@@ -47,8 +47,8 @@
 ! #include "clesphys.h"
 #include "iniprint.h"
-c
-c
-c   local:
-c   ------
+!
+!
+!   local:
+!   ------
 
       CHARACTER ch1*72,ch2*72,ch3*72,ch4*12
@@ -58,32 +58,32 @@
       INTEGER i
       LOGICAL use_filtre_fft
-c
-c  -------------------------------------------------------------------
-c
-c       .........     Version  du 29/04/97       ..........
-c
-c   Nouveaux parametres nitergdiv,nitergrot,niterh,tetagdiv,tetagrot,
-c      tetatemp   ajoutes  pour la dissipation   .
-c
-c   Autre parametre ajoute en fin de liste de tapedef : ** fxyhypb ** 
-c
-c  Si fxyhypb = .TRUE. , choix de la fonction a derivee tangente hyperb.
-c    Sinon , choix de fxynew  , a derivee sinusoidale  ..
-c
-c   ......  etatinit = . TRUE. si defrun  est appele dans ETAT0_LMD  ou
-c         LIMIT_LMD  pour l'initialisation de start.dat (dic) et
-c                de limit.dat ( dic)                        ...........
-c           Sinon  etatinit = . FALSE .
-c
-c   Donc etatinit = .F.  si on veut comparer les valeurs de  grossismx ,
-c    grossismy,clon,clat, fxyhypb  lues sur  le fichier  start  avec
-c   celles passees  par run.def ,  au debut du gcm, apres l'appel a 
-c    lectba .  
-c   Ces parmetres definissant entre autres la grille et doivent etre
-c   pareils et coherents , sinon il y aura  divergence du gcm .
-c
-c-----------------------------------------------------------------------
-c   initialisations:
-c   ----------------
+!
+!  -------------------------------------------------------------------
+!
+!       .........     Version  du 29/04/97       ..........
+!
+!   Nouveaux parametres nitergdiv,nitergrot,niterh,tetagdiv,tetagrot,
+!      tetatemp   ajoutes  pour la dissipation   .
+!
+!   Autre parametre ajoute en fin de liste de tapedef : ** fxyhypb ** 
+!
+!  Si fxyhypb = .TRUE. , choix de la fonction a derivee tangente hyperb.
+!    Sinon , choix de fxynew  , a derivee sinusoidale  ..
+!
+!   ......  etatinit = . TRUE. si defrun  est appele dans ETAT0_LMD  ou
+!         LIMIT_LMD  pour l'initialisation de start.dat (dic) et
+!                de limit.dat ( dic)                        ...........
+!           Sinon  etatinit = . FALSE .
+!
+!   Donc etatinit = .F.  si on veut comparer les valeurs de  grossismx ,
+!    grossismy,clon,clat, fxyhypb  lues sur  le fichier  start  avec
+!   celles passees  par run.def ,  au debut du gcm, apres l'appel a 
+!    lectba .  
+!   Ces parmetres definissant entre autres la grille et doivent etre
+!   pareils et coherents , sinon il y aura  divergence du gcm .
+!
+!-----------------------------------------------------------------------
+!   initialisations:
+!   ----------------
 
 !Config  Key  = lunout
@@ -95,5 +95,5 @@
       CALL getin('lunout', lunout)
       IF (lunout /= 5 .and. lunout /= 6) THEN
-        OPEN(UNIT=lunout,FILE='lmdz.out',ACTION='write', 
+        OPEN(UNIT=lunout,FILE='lmdz.out',ACTION='write',                     &
      &          STATUS='unknown',FORM='formatted')
       ENDIF
@@ -107,7 +107,7 @@
       CALL getin('prt_level',prt_level)
 
-c-----------------------------------------------------------------------
-c  Parametres de controle du run:
-c-----------------------------------------------------------------------
+!-----------------------------------------------------------------------
+!  Parametres de controle du run:
+!-----------------------------------------------------------------------
 !Config  Key  = planet_type
 !Config  Desc = planet type ("earth", "mars", "venus", ...)
@@ -232,6 +232,6 @@
        CALL getin('dissip_period',dissip_period)
 
-ccc  ....   P. Le Van , modif le 29/04/97 .pour la dissipation  ...
-ccc
+!cc  ....   P. Le Van , modif le 29/04/97 .pour la dissipation  ...
+!cc
 
 !Config  Key  = lstardis
@@ -348,5 +348,5 @@
        CALL getin('ok_guide',ok_guide)
 
-c    ...............................................................
+!    ...............................................................
 
 !Config  Key  =  read_start
@@ -390,7 +390,7 @@
       ENDDO
 
-ccc  ....   P. Le Van , ajout  le 7/03/95 .pour le zoom ...
-c     .........   (  modif  le 17/04/96 )   .........
-c
+!cc  ....   P. Le Van , ajout  le 7/03/95 .pour le zoom ...
+!     .........   (  modif  le 17/04/96 )   .........
+!
       IF( etatinit ) GO TO 100
 
@@ -411,8 +411,8 @@
        CALL getin('clat',clatt)
 
-c
-c
+!
+!
       IF( ABS(clat - clatt).GE. 0.001 )  THEN
-        write(lunout,*)'conf_gcm: La valeur de clat passee par run.def',
+        write(lunout,*)'conf_gcm: La valeur de clat passee par run.def',     &
      &    ' est differente de celle lue sur le fichier  start '
         STOP
@@ -429,5 +429,5 @@
 
       IF( ABS(grossismx - grossismxx).GE. 0.001 )  THEN
-        write(lunout,*)'conf_gcm: La valeur de grossismx passee par ',
+        write(lunout,*)'conf_gcm: La valeur de grossismx passee par ',       &
      &  'run.def est differente de celle lue sur le fichier  start '
         STOP
@@ -443,5 +443,5 @@
 
       IF( ABS(grossismy - grossismyy).GE. 0.001 )  THEN
-        write(lunout,*)'conf_gcm: La valeur de grossismy passee par ',
+        write(lunout,*)'conf_gcm: La valeur de grossismy passee par ',        &
      & 'run.def est differente de celle lue sur le fichier  start '
         STOP
@@ -449,5 +449,5 @@
       
       IF( grossismx.LT.1. )  THEN
-        write(lunout,*)
+        write(lunout,*)                                                        &
      &       'conf_gcm: ***  ATTENTION !! grossismx < 1 .   *** '
          STOP
@@ -458,5 +458,5 @@
 
       IF( grossismy.LT.1. )  THEN
-        write(lunout,*)
+        write(lunout,*)                                                        &
      &       'conf_gcm: ***  ATTENTION !! grossismy < 1 .   *** '
          STOP
@@ -466,8 +466,8 @@
 
       write(lunout,*)'conf_gcm: alphax alphay',alphax,alphay
-c
-c    alphax et alphay sont les anciennes formulat. des grossissements
-c
-c
+!
+!    alphax et alphay sont les anciennes formulat. des grossissements
+!
+!
 
 !Config  Key  = fxyhypb
@@ -482,6 +482,6 @@
          IF( fxyhypbb )     THEN
             write(lunout,*)' ********  PBS DANS  CONF_GCM  ******** '
-            write(lunout,*)' *** fxyhypb lu sur le fichier start est ',
-     *       'F alors  qu il est  T  sur  run.def  ***'
+            write(lunout,*)' *** fxyhypb lu sur le fichier start est ',     &
+     &       'F alors  qu il est  T  sur  run.def  ***'
               STOP
          ENDIF
@@ -489,10 +489,10 @@
          IF( .NOT.fxyhypbb )   THEN
             write(lunout,*)' ********  PBS DANS  CONF_GCM  ******** '
-            write(lunout,*)' ***  fxyhypb lu sur le fichier start est ',
-     *        'T alors  qu il est  F  sur  run.def  ****  '
+            write(lunout,*)' ***  fxyhypb lu sur le fichier start est ',     &
+     &        'T alors  qu il est  F  sur  run.def  ****  '
               STOP
          ENDIF
       ENDIF
-c
+!
 !Config  Key  = dzoomx
 !Config  Desc = extension en longitude
@@ -505,6 +505,6 @@
       IF( fxyhypb )  THEN
        IF( ABS(dzoomx - dzoomxx).GE. 0.001 )  THEN
-        write(lunout,*)'conf_gcm: La valeur de dzoomx passee par ',
-     *  'run.def est differente de celle lue sur le fichier  start '
+        write(lunout,*)'conf_gcm: La valeur de dzoomx passee par ',         &
+     &  'run.def est differente de celle lue sur le fichier  start '
         STOP
        ENDIF
@@ -521,6 +521,6 @@
       IF( fxyhypb )  THEN
        IF( ABS(dzoomy - dzoomyy).GE. 0.001 )  THEN
-        write(lunout,*)'conf_gcm: La valeur de dzoomy passee par ',
-     * 'run.def est differente de celle lue sur le fichier  start '
+        write(lunout,*)'conf_gcm: La valeur de dzoomy passee par ',          &
+     & 'run.def est differente de celle lue sur le fichier  start '
         STOP
        ENDIF
@@ -536,6 +536,6 @@
       IF( fxyhypb )  THEN
        IF( ABS(taux - tauxx).GE. 0.001 )  THEN
-        write(lunout,*)'conf_gcm: La valeur de taux passee par ',
-     * 'run.def est differente de celle lue sur le fichier  start '
+        write(lunout,*)'conf_gcm: La valeur de taux passee par ',           &
+     & 'run.def est differente de celle lue sur le fichier  start '
         STOP
        ENDIF
@@ -551,11 +551,11 @@
       IF( fxyhypb )  THEN
        IF( ABS(tauy - tauyy).GE. 0.001 )  THEN
-        write(lunout,*)'conf_gcm: La valeur de tauy passee par ',
-     * 'run.def est differente de celle lue sur le fichier  start '
+        write(lunout,*)'conf_gcm: La valeur de tauy passee par ',           &
+     & 'run.def est differente de celle lue sur le fichier  start '
         STOP
        ENDIF
       ENDIF
 
-cc
+!c
       IF( .NOT.fxyhypb  )  THEN
 
@@ -572,6 +572,6 @@
           IF( ysinuss )     THEN
             write(lunout,*)' ********  PBS DANS  CONF_GCM  ******** '
-            write(lunout,*)' *** ysinus lu sur le fichier start est F',
-     *       ' alors  qu il est  T  sur  run.def  ***'
+            write(lunout,*)' *** ysinus lu sur le fichier start est F',     &
+     &       ' alors  qu il est  T  sur  run.def  ***'
             STOP
           ENDIF
@@ -579,11 +579,11 @@
           IF( .NOT.ysinuss )   THEN
             write(lunout,*)' ********  PBS DANS  CONF_GCM  ******** '
-            write(lunout,*)' *** ysinus lu sur le fichier start est T',
-     *        ' alors  qu il est  F  sur  run.def  ****  '
+            write(lunout,*)' *** ysinus lu sur le fichier start est T',     &
+     &        ' alors  qu il est  F  sur  run.def  ****  '
               STOP
           ENDIF
         ENDIF
       ENDIF ! of IF( .NOT.fxyhypb  )
-c
+!
 !Config  Key  = offline
 !Config  Desc = Nouvelle eau liquide
@@ -682,6 +682,6 @@
 
       RETURN
-c   ...............................................
-c
+!   ...............................................
+!
 100   CONTINUE
 !Config  Key  = clon
@@ -718,6 +718,5 @@
 
       IF( grossismx.LT.1. )  THEN
-        write(lunout,*)
-     &   'conf_gcm: ***  ATTENTION !! grossismx < 1 .   *** '
+        write(lunout,*)'conf_gcm: ***ATTENTION !! grossismx < 1 . *** '
          STOP
       ELSE
@@ -727,6 +726,5 @@
 
       IF( grossismy.LT.1. )  THEN
-        write(lunout,*)
-     &  'conf_gcm: ***  ATTENTION !! grossismy < 1 .   *** '
+        write(lunout,*) 'conf_gcm: ***ATTENTION !! grossismy < 1 . *** '
          STOP
       ELSE
@@ -735,8 +733,8 @@
 
       write(lunout,*)'conf_gcm: alphax alphay ',alphax,alphay
-c
-c    alphax et alphay sont les anciennes formulat. des grossissements
-c
-c
+!
+!    alphax et alphay sont les anciennes formulat. des grossissements
+!
+!
 
 !Config  Key  = fxyhypb
@@ -786,5 +784,5 @@
        ysinus = .TRUE.
        CALL getin('ysinus',ysinus)
-c
+!
 !Config  Key  = offline
 !Config  Desc = Nouvelle eau liquide
@@ -864,6 +862,6 @@
       vert_prof_dissip = merge(1, 0, ok_strato .and. llm==39)
       CALL getin('vert_prof_dissip', vert_prof_dissip)
-      call assert(vert_prof_dissip == 0 .or. vert_prof_dissip ==  1,
-     $     "bad value for vert_prof_dissip")
+      call assert(vert_prof_dissip == 0 .or. vert_prof_dissip ==  1,        &
+     &     "bad value for vert_prof_dissip")
 
 !Config  Key  = ok_gradsfile
@@ -892,5 +890,5 @@
 
       write(lunout,*)' #########################################'
-      write(lunout,*)' Configuration des parametres de cel0'
+      write(lunout,*)' Configuration des parametres de cel0'                &
      &             //'_limit: '
       write(lunout,*)' planet_type = ', planet_type
@@ -937,5 +935,5 @@
       write(lunout,*)' ok_limit = ', ok_limit
       write(lunout,*)' ok_etat0 = ', ok_etat0
-c
+!
       RETURN
       END
Index: /LMDZ5/branches/testing/libf/dyn3d/gcm.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d/gcm.F	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3d/gcm.F	(revision 2056)
@@ -105,7 +105,4 @@
       REAL ps(ip1jmp1)                       ! pression  au sol
       REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.des couches
-      REAL pks(ip1jmp1)                      ! exner au  sol
-      REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
-      REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
       REAL masse(ip1jmp1,llm)                ! masse d'air
       REAL phis(ip1jmp1)                     ! geopotentiel au sol
@@ -131,5 +128,4 @@
       data call_iniphys/.true./
 
-      REAL alpha(ip1jmp1,llm),beta(ip1jmp1,llm)
 c+jld variables test conservation energie
 c      REAL ecin(ip1jmp1,llm),ecin0(ip1jmp1,llm)
@@ -466,5 +462,9 @@
 
 
-      day_end = day_ini + nday
+      if (nday>=0) then
+         day_end = day_ini + nday
+      else
+         day_end = day_ini - nday/day_step
+      endif
       WRITE(lunout,300)day_ini,day_end
  300  FORMAT('1'/,15x,'run du jour',i7,2x,'au jour',i7//)
Index: /LMDZ5/branches/testing/libf/dyn3d/guide_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d/guide_mod.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3d/guide_mod.F90	(revision 2056)
@@ -593,4 +593,6 @@
   SUBROUTINE guide_interp(psi,teta)
   
+  use exner_hyb_m, only: exner_hyb
+  use exner_milieu_m, only: exner_milieu
   IMPLICIT NONE
 
@@ -614,6 +616,5 @@
   REAL, DIMENSION (iip1,jjm,llm)     :: pbary 
   ! Variables pour fonction Exner (P milieu couche)
-  REAL, DIMENSION (iip1,jjp1,llm)    :: pk, pkf
-  REAL, DIMENSION (iip1,jjp1,llm)    :: alpha, beta
+  REAL, DIMENSION (iip1,jjp1,llm)    :: pk
   REAL, DIMENSION (iip1,jjp1)        :: pks    
   REAL                               :: prefkap,unskap
@@ -680,7 +681,7 @@
     CALL pression( ip1jmp1, ap, bp, psi, p )
     if (pressure_exner) then
-      CALL exner_hyb(ip1jmp1,psi,p,alpha,beta,pks,pk,pkf)
+      CALL exner_hyb(ip1jmp1,psi,p,pks,pk)
     else
-      CALL exner_milieu(ip1jmp1,psi,p,beta,pks,pk,pkf)
+      CALL exner_milieu(ip1jmp1,psi,p,pks,pk)
     endif
 !    ....  Calcul de pls , pression au milieu des couches ,en Pascals
Index: /LMDZ5/branches/testing/libf/dyn3d/iniacademic.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d/iniacademic.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3d/iniacademic.F90	(revision 2056)
@@ -14,4 +14,6 @@
 #endif
   USE Write_Field
+  use exner_hyb_m, only: exner_hyb
+  use exner_milieu_m, only: exner_milieu
 
   !   Author:    Frederic Hourdin      original: 15/01/93
@@ -54,5 +56,4 @@
   REAL pks(ip1jmp1)                      ! exner au  sol
   REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
-  REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
   REAL phi(ip1jmp1,llm)                  ! geopotentiel
   REAL ddsin,zsig,tetapv,w_pv  ! variables auxiliaires
@@ -70,5 +71,5 @@
   integer idum
 
-  REAL alpha(ip1jmp1,llm),beta(ip1jmp1,llm),zdtvr
+  REAL zdtvr
   
   character(len=*),parameter :: modname="iniacademic"
@@ -223,7 +224,7 @@
         CALL pression ( ip1jmp1, ap, bp, ps, p       )
         if (pressure_exner) then
-          CALL exner_hyb( ip1jmp1, ps, p,alpha,beta, pks, pk, pkf )
-        else
-          call exner_milieu(ip1jmp1,ps,p,beta,pks,pk,pkf)
+          CALL exner_hyb( ip1jmp1, ps, p, pks, pk)
+        else
+          call exner_milieu(ip1jmp1,ps,p,pks,pk)
         endif
         CALL massdair(p,masse)
Index: /LMDZ5/branches/testing/libf/dyn3d/leapfrog.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d/leapfrog.F	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3d/leapfrog.F	(revision 2056)
@@ -19,4 +19,7 @@
      &                       iecri, ip_ebil_dyn, ok_dynzon, ok_dyn_ins,
      &                       periodav, ok_dyn_ave, output_grads_dyn
+      use exner_hyb_m, only: exner_hyb
+      use exner_milieu_m, only: exner_milieu
+
       IMPLICIT NONE
 
@@ -158,5 +161,4 @@
       character*10 string10
 
-      REAL alpha(ip1jmp1,llm),beta(ip1jmp1,llm)
       REAL :: flxw(ip1jmp1,llm)  ! flux de masse verticale
 
@@ -196,5 +198,9 @@
 
 
-      itaufin   = nday*day_step
+      if (nday>=0) then
+         itaufin   = nday*day_step
+      else
+         itaufin   = -nday
+      endif
       itaufinp1 = itaufin +1
       itau = 0
@@ -217,7 +223,7 @@
       CALL pression ( ip1jmp1, ap, bp, ps, p       )
       if (pressure_exner) then
-        CALL exner_hyb( ip1jmp1, ps, p,alpha,beta, pks, pk, pkf )
+        CALL exner_hyb( ip1jmp1, ps, p, pks, pk, pkf )
       else
-        CALL exner_milieu( ip1jmp1, ps, p, beta, pks, pk, pkf )
+        CALL exner_milieu( ip1jmp1, ps, p, pks, pk, pkf )
       endif
 
@@ -373,8 +379,12 @@
          CALL pression (  ip1jmp1, ap, bp, ps,  p      )
          if (pressure_exner) then
-           CALL exner_hyb(  ip1jmp1, ps, p,alpha,beta,pks, pk, pkf )
+           CALL exner_hyb(  ip1jmp1, ps, p,pks, pk, pkf )
          else
-           CALL exner_milieu( ip1jmp1, ps, p, beta, pks, pk, pkf )
+           CALL exner_milieu( ip1jmp1, ps, p, pks, pk, pkf )
          endif
+
+! Appel a geopot ajoute le 2014/05/08 pour garantir la convergence numerique
+! avec dyn3dmem
+         CALL geopot  ( ip1jmp1, teta  , pk , pks,  phis  , phi   )
 
 !           rdaym_ini  = itau * dtvr / daysec
@@ -448,7 +458,7 @@
           CALL massdair(p,masse)
           if (pressure_exner) then
-            CALL exner_hyb(ip1jmp1,ps,p,alpha,beta,pks,pk,pkf)
+            CALL exner_hyb(ip1jmp1,ps,p,pks,pk,pkf)
           else
-            CALL exner_milieu(ip1jmp1,ps,p,beta,pks,pk,pkf)
+            CALL exner_milieu(ip1jmp1,ps,p,pks,pk,pkf)
           endif
 
@@ -506,7 +516,7 @@
         CALL pression ( ip1jmp1, ap, bp, ps, p                  )
         if (pressure_exner) then
-          CALL exner_hyb( ip1jmp1, ps, p,alpha,beta, pks, pk, pkf )
+          CALL exner_hyb( ip1jmp1, ps, p, pks, pk, pkf )
         else
-          CALL exner_milieu( ip1jmp1, ps, p, beta, pks, pk, pkf )
+          CALL exner_milieu( ip1jmp1, ps, p, pks, pk, pkf )
         endif
         CALL massdair(p,masse)
Index: DZ5/branches/testing/libf/dyn3d_common/PVtheta.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d_common/PVtheta.F	(revision 2055)
+++ 	(revision )
@@ -1,196 +1,0 @@
-      SUBROUTINE PVtheta(ilon,ilev,pucov,pvcov,pteta,
-     $           ztfi,zplay,zplev,
-     $           nbteta,theta,PVteta)
-      IMPLICIT none
-
-c=======================================================================
-c
-c   Auteur:  I. Musat
-c   -------
-c
-c   Objet:
-c   ------
-c
-c    *******************************************************************
-c    Calcul de la vorticite potentielle PVteta sur des iso-theta selon
-c    la methodologie du NCEP/NCAR :
-c    1) on calcule la stabilite statique N**2=g/T*(dT/dz+g/cp) sur les
-c       niveaux du modele => N2
-c    2) on interpole les vents, la temperature et le N**2 sur des isentropes
-c       (en fait sur des iso-theta) lineairement en log(theta) =>
-c       ucovteta, vcovteta, N2teta
-c    3) on calcule la vorticite absolue sur des iso-theta => vorateta
-c    4) on calcule la densite rho sur des iso-theta => rhoteta 
-c
-c       rhoteta = (T/theta)**(cp/R)*p0/(R*T)
-c
-c    5) on calcule la vorticite potentielle sur des iso-theta => PVteta
-c
-c       PVteta = (vorateta * N2 * theta)/(g * rhoteta) ! en PVU
-c
-c       NB: 1PVU=10**(-6) K*m**2/(s * kg)
-c
-c       PVteta =  vorateta * N2/(g**2 * rhoteta) ! en 1/(Pa*s)
-c
-c
-c    *******************************************************************
-c
-c
-c     Variables d'entree : ilon,ilev,pucov,pvcov,pteta,ztfi,zplay,zplev,nbteta,theta
-c                       -> sur la grille dynamique
-c     Variable de sortie : PVteta
-c                       -> sur la grille physique 
-c=======================================================================
-
-#include "dimensions.h"
-#include "paramet.h"
-c
-c variables Input
-c
-      INTEGER ilon, ilev
-      REAL pvcov(iip1,jjm,ilev)
-      REAL pucov(iip1,jjp1,ilev)
-      REAL pteta(iip1,jjp1,ilev)
-      REAL ztfi(ilon,ilev)
-      REAL zplay(ilon,ilev), zplev(ilon,ilev+1)
-      INTEGER nbteta
-      REAL theta(nbteta)
-c
-c variable Output
-c
-      REAL PVteta(ilon,nbteta)
-c
-c variables locales
-c
-      INTEGER i, j, l, ig0
-      REAL SSUM
-      REAL teta(ilon, ilev)
-      REAL ptetau(ip1jmp1, ilev), ptetav(ip1jm, ilev)
-      REAL ucovteta(ip1jmp1,ilev), vcovteta(ip1jm,ilev)
-      REAL N2(ilon,ilev-1), N2teta(ilon,nbteta)
-      REAL ztfiteta(ilon,nbteta)
-      REAL rhoteta(ilon,nbteta)
-      REAL vorateta(iip1,jjm,nbteta)
-      REAL voratetafi(ilon,nbteta), vorpol(iim)
-c
-#include "comgeom2.h"
-#include "comconst.h"
-#include "comvert.h"
-c
-c projection teta sur la grille physique
-c
-      DO l=1,llm
-       teta(1,l)   =  pteta(1,1,l)
-       ig0         = 2
-       DO j = 2, jjm
-        DO i = 1, iim
-         teta(ig0,l)    = pteta(i,j,l)
-         ig0            = ig0 + 1
-        ENDDO
-       ENDDO
-       teta(ig0,l)    = pteta(1,jjp1,l)
-      ENDDO
-c
-c calcul pteta sur les grilles U et V
-c
-      DO l=1, llm
-       DO j=1, jjp1
-        DO i=1, iip1
-         ig0=i+(j-1)*iip1
-         ptetau(ig0,l)=pteta(i,j,l)
-        ENDDO !i
-       ENDDO !j
-       DO j=1, jjm
-        DO i=1, iip1
-         ig0=i+(j-1)*iip1
-         ptetav(ig0,l)=0.5*(pteta(i,j,l)+pteta(i,j+1,l))
-        ENDDO !i
-       ENDDO !j
-      ENDDO !l
-c
-c projection pucov, pvcov sur une surface de theta constante
-c
-      DO l=1, nbteta
-cIM 1rout CALL tetaleveli1j1(ip1jmp1,llm,.true.,ptetau,theta(l),
-       CALL tetalevel(ip1jmp1,llm,.true.,ptetau,theta(l),
-     .                pucov,ucovteta(:,l))
-cIM 1rout CALL tetaleveli1j(ip1jm,llm,.true.,ptetav,theta(l),
-       CALL tetalevel(ip1jm,llm,.true.,ptetav,theta(l),
-     .                pvcov,vcovteta(:,l))
-      ENDDO !l
-c
-c calcul vorticite absolue sur une iso-theta : vorateta
-c
-      CALL tourabs(nbteta,vcovteta,ucovteta,vorateta)
-c
-c projection vorateta sur la grille physique => voratetafi
-c
-      DO l=1,nbteta
-       DO j=2,jjm
-        ig0=1+(j-2)*iim
-        DO i=1,iim
-         voratetafi(ig0+i+1,l) = vorateta( i ,j-1,l) * alpha4(i+1,j) +
-     $                           vorateta(i+1,j-1,l) * alpha1(i+1,j) +
-     $                           vorateta(i  ,j  ,l) * alpha3(i+1,j) +
-     $                           vorateta(i+1,j  ,l) * alpha2(i+1,j)
-        ENDDO
-        voratetafi(ig0 +1,l) = voratetafi(ig0 +1+ iim,l)
-       ENDDO
-      ENDDO
-c
-      DO l=1,nbteta
-       DO i=1,iim
-        vorpol(i)  = vorateta(i,1,l)*aire(i,1)
-       ENDDO
-       voratetafi(1,l)= SSUM(iim,vorpol,1)/apoln
-      ENDDO
-c
-      DO l=1,nbteta
-       DO i=1,iim
-        vorpol(i)  = vorateta(i,jjm,l)* aire(i,jjm +1)
-       ENDDO
-       voratetafi(ilon,l)= SSUM(iim,vorpol,1)/apols
-      ENDDO
-c 
-c calcul N**2 sur la grille physique => N2
-c
-      DO l=1, llm-1 
-       DO i=1, ilon
-        N2(i,l) = (g**2 * zplay(i,l) * 
-     $            (ztfi(i,l+1)-ztfi(i,l)) )/
-     $            (R*ztfi(i,l)*ztfi(i,l)*
-     $            (zplev(i,l)-zplev(i,l+1)) )+
-     $            (g**2)/(ztfi(i,l)*CPP)
-       ENDDO !i
-      ENDDO !l
-c
-c calcul N2 sur une iso-theta => N2teta 
-c
-      DO l=1, nbteta
-       CALL tetalevel(ilon,llm-1,.true.,teta,theta(l),
-     $                N2,N2teta(:,l))
-       CALL tetalevel(ilon,llm,.true.,teta,theta(l),
-     $                ztfi,ztfiteta(:,l))
-      ENDDO !l=1, nbteta
-c
-c calcul rho et PV sur une iso-theta : rhoteta, PVteta
-c
-      DO l=1, nbteta
-       DO i=1, ilon
-        rhoteta(i,l)=(ztfiteta(i,l)/theta(l))**(CPP/R)*
-     $  (preff/(R*ztfiteta(i,l)))
-c
-c PVteta en PVU
-c
-        PVteta(i,l)=(theta(l)*g*voratetafi(i,l)*N2teta(i,l))/
-     $              (g**2*rhoteta(i,l))
-c
-c PVteta en 1/(Pa*s)
-c
-        PVteta(i,l)=(voratetafi(i,l)*N2teta(i,l))/
-     $              (g**2*rhoteta(i,l))
-       ENDDO !i
-      ENDDO !l
-c
-      RETURN
-      END 
Index: /LMDZ5/branches/testing/libf/dyn3d_common/disvert.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d_common/disvert.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3d_common/disvert.F90	(revision 2056)
@@ -1,10 +1,12 @@
 ! $Id$
 
-SUBROUTINE disvert(pa,preff,ap,bp,dpres,presnivs,nivsigs,nivsig,scaleheight)
-
-  ! Auteur : P. Le Van
-
+SUBROUTINE disvert()
+
+#ifdef CPP_IOIPSL
+  use ioipsl, only: getin
+#else
+  USE ioipsl_getincom, only: getin
+#endif
   use new_unit_m, only: new_unit
-  use ioipsl, only: getin
   use assert_m, only: assert
 
@@ -13,34 +15,44 @@
   include "dimensions.h"
   include "paramet.h"
+  include "comvert.h"
+  include "comconst.h"
   include "iniprint.h"
   include "logic.h"
 
-  ! s = sigma ** kappa : coordonnee verticale
-  ! dsig(l) : epaisseur de la couche l ds la coord. s
-  ! sig(l) : sigma a l'interface des couches l et l-1
-  ! ds(l) : distance entre les couches l et l-1 en coord.s
-
-  real,intent(in) :: pa, preff
-  real,intent(out) :: ap(llmp1) ! in Pa
-  real, intent(out):: bp(llmp1)
-  real,intent(out) :: dpres(llm), nivsigs(llm), nivsig(llmp1)
-  real,intent(out) :: presnivs(llm)
-  real,intent(out) :: scaleheight
-
+!-------------------------------------------------------------------------------
+! Purpose: Vertical distribution functions for LMDZ.
+!          Triggered by the levels number llm.
+!-------------------------------------------------------------------------------
+! Read    in "comvert.h":
+! pa                         !--- PURE PRESSURE COORDINATE FOR P<pa (in Pascals)
+! preff                      !--- REFERENCE PRESSURE                 (101325 Pa)
+! Written in "comvert.h":
+! ap(llm+1), bp(llm+1)       !--- Ap, Bp HYBRID COEFFICIENTS AT INTERFACES
+! aps(llm),  bps(llm)        !--- Ap, Bp HYBRID COEFFICIENTS AT MID-LAYERS
+! dpres(llm)                 !--- PRESSURE DIFFERENCE FOR EACH LAYER
+! presnivs(llm)              !--- PRESSURE AT EACH MID-LAYER
+! scaleheight                !--- VERTICAL SCALE HEIGHT            (Earth: 8kms)
+! nivsig(llm+1)              !--- SIGMA INDEX OF EACH LAYER INTERFACE
+! nivsigs(llm)               !--- SIGMA INDEX OF EACH MID-LAYER
+!-------------------------------------------------------------------------------
+! Local variables:
   REAL sig(llm+1), dsig(llm)
-  real zk, zkm1, dzk1, dzk2, k0, k1
+  REAL sig0(llm+1), zz(llm+1)
+  REAL zk, zkm1, dzk1, dzk2, z, k0, k1
 
   INTEGER l, unit
   REAL dsigmin
+  REAL vert_scale,vert_dzmin,vert_dzlow,vert_z0low,vert_dzmid,vert_z0mid,vert_h_mid,vert_dzhig,vert_z0hig,vert_h_hig
+
   REAL alpha, beta, deltaz
   REAL x
   character(len=*),parameter :: modname="disvert"
 
-  character(len=6):: vert_sampling
+  character(len=24):: vert_sampling
   ! (allowed values are "param", "tropo", "strato" and "read")
 
   !-----------------------------------------------------------------------
 
-  print *, "Call sequence information: disvert"
+  WRITE(lunout,*) TRIM(modname)//" starts"
 
   ! default scaleheight is 8km for earth
@@ -49,5 +61,5 @@
   vert_sampling = merge("strato", "tropo ", ok_strato) ! default value
   call getin('vert_sampling', vert_sampling)
-  print *, 'vert_sampling = ' // vert_sampling
+  WRITE(lunout,*) TRIM(modname)//' vert_sampling = ' // vert_sampling
   if (llm==39 .and. vert_sampling=="strato") then
      dsigmin=0.3 ! Vieille option par défaut pour CMIP5
@@ -144,4 +156,154 @@
      ap(1)=0.
      ap(2: llm + 1) = pa * (sig(2: llm + 1) - bp(2: llm + 1))
+  case("strato_correct")
+!==================================================================
+! Fredho 2014/05/18, Saint-Louis du Senegal
+! Cette version de la discretisation strato est corrige au niveau
+! du passage des sig aux ap, bp
+! la version precedente donne un coude dans l'epaisseur des couches
+! vers la tropopause
+!==================================================================
+
+
+     DO l = 1, llm
+        x = 2*asin(1.) * (l - 0.5) / (llm + 1)
+        dsig(l) =(dsigmin + 7. * SIN(x)**2) &
+             *(0.5*(1.-tanh(1.*(x-asin(1.))/asin(1.))))**2
+     ENDDO
+     dsig = dsig / sum(dsig)
+     sig0(llm+1) = 0.
+     DO l = llm, 1, -1
+        sig0(l) = sig0(l+1) + dsig(l)
+     ENDDO
+     sig=racinesig(sig0)
+
+     bp(1)=1.
+     bp(2:llm)=EXP(1.-1./sig(2: llm)**2)
+     bp(llmp1)=0.
+
+     ap(1)=0.
+     ap(2:llm)=pa*(sig(2:llm)-bp(2:llm))
+     ap(llm+1)=0.
+
+  CASE("strato_custom0") 
+!=======================================================
+! Version Transitoire
+    ! custumize strato distribution with specific alpha & beta values and function
+    ! depending on llm (experimental and temporary)!
+    SELECT CASE (llm)
+      CASE(55)
+        alpha=0.45
+        beta=4.0
+      CASE(63)
+        alpha=0.45
+        beta=5.0
+      CASE(71)
+        alpha=3.05
+        beta=65.
+      CASE(79)
+        alpha=3.20
+        ! alpha=2.05 ! FLOTT 79 (PLANTE)
+        beta=70.
+    END SELECT
+    ! Or used values provided by user in def file:
+    CALL getin("strato_alpha",alpha)
+    CALL getin("strato_beta",beta)
+    
+    ! Build geometrical distribution
+    scaleheight=7.
+    zz(1)=0.
+    IF (llm==55.OR.llm==63) THEN
+      DO l=1,llm
+        z=zz(l)/scaleheight
+        zz(l+1)=zz(l)+0.03+z*1.5*(1.-TANH(z-0.5))+alpha*(1.+TANH(z-1.5))     &
+                            +5.0*EXP((l-llm)/beta)
+      ENDDO
+    ELSEIF (llm==71) THEN !.OR.llm==79) THEN      ! FLOTT 79 (PLANTE)
+      DO l=1,llm
+        z=zz(l)
+        zz(l+1)=zz(l)+0.02+0.88*TANH(z/2.5)+alpha*(1.+TANH((z-beta)/15.))
+      ENDDO
+    ELSEIF (llm==79) THEN
+      DO l=1,llm
+        z=zz(l)
+        zz(l+1)=zz(l)+0.02+0.80*TANH(z/3.8)+alpha*(1+TANH((z-beta)/17.))     &
+                            +0.03*TANH(z/.25)
+      ENDDO
+    ENDIF ! of IF (llm==55.OR.llm==63) ...
+    
+
+    ! Build sigma distribution
+    sig0=EXP(-zz(:)/scaleheight)
+    sig0(llm+1)=0.
+!    sig=ridders(sig0)
+    sig=racinesig(sig0)
+    
+    ! Compute ap() and bp()
+    bp(1)=1.
+    bp(2:llm)=EXP(1.-1./sig(2:llm)**2)
+    bp(llm+1)=0.
+    ap=pa*(sig-bp)
+
+  CASE("strato_custom") 
+!===================================================================
+! David Cugnet, François Lott, Lionel Guez, Ehouoarn Millour, Fredho
+! 2014/05
+! custumize strato distribution
+! Al the parameter are given in km assuming a given scalehigh
+    vert_scale=7.     ! scale hight
+    vert_dzmin=0.02   ! width of first layer
+    vert_dzlow=1.     ! dz in the low atmosphere
+    vert_z0low=8.     ! height at which resolution recches dzlow
+    vert_dzmid=3.     ! dz in the mid atmsophere
+    vert_z0mid=70.    ! height at which resolution recches dzmid
+    vert_h_mid=20.    ! width of the transition
+    vert_dzhig=11.    ! dz in the high atmsophere
+    vert_z0hig=80.    ! height at which resolution recches dz
+    vert_h_hig=20.    ! width of the transition
+!===================================================================
+
+    call getin('vert_scale',vert_scale)
+    call getin('vert_dzmin',vert_dzmin)
+    call getin('vert_dzlow',vert_dzlow)
+    call getin('vert_z0low',vert_z0low)
+    CALL getin('vert_dzmid',vert_dzmid)
+    CALL getin('vert_z0mid',vert_z0mid)
+    call getin('vert_h_mid',vert_h_mid)
+    call getin('vert_dzhig',vert_dzhig)
+    call getin('vert_z0hig',vert_z0hig)
+    call getin('vert_h_hig',vert_h_hig)
+
+    scaleheight=vert_scale ! for consistency with further computations
+    ! Build geometrical distribution
+    zz(1)=0.
+    DO l=1,llm
+       z=zz(l)
+       zz(l+1)=zz(l)+vert_dzmin+vert_dzlow*TANH(z/vert_z0low)+                &
+&      (vert_dzmid-vert_dzlow)* &
+&           (TANH((z-vert_z0mid)/vert_h_mid)-TANH((-vert_z0mid)/vert_h_mid)) &
+&     +(vert_dzhig-vert_dzmid-vert_dzlow)*                                  &
+&           (TANH((z-vert_z0hig)/vert_h_hig)-TANH((-vert_z0hig)/vert_h_hig))
+    ENDDO
+
+
+!===================================================================
+! Comment added Fredho 2014/05/18, Saint-Louis, Senegal
+! From approximate z to ap, bp, so that p=ap+bp*p0 and p/p0=exp(-z/H)
+! sig0 is p/p0
+! sig is an intermediate distribution introduce to estimate bp
+! 1.   sig0=exp(-z/H)
+! 2.   inversion of sig0=(1-pa/p0)*sig+(1-pa/p0)*exp(1-1/sig**2)
+! 3.   bp=exp(1-1/sig**2)
+! 4.   ap deduced from  the combination of 2 and 3 so that sig0=ap/p0+bp
+!===================================================================
+
+    sig0=EXP(-zz(:)/vert_scale)
+    sig0(llm+1)=0.
+    sig=racinesig(sig0)
+    bp(1)=1.
+    bp(2:llm)=EXP(1.-1./sig(2:llm)**2)
+    bp(llm+1)=0.
+    ap=pa*(sig-bp)
+
   case("read")
      ! Read "ap" and "bp". First line is skipped (title line). "ap"
@@ -191,3 +353,100 @@
   write(lunout, *) presnivs
 
+CONTAINS
+
+!-------------------------------------------------------------------------------
+!
+FUNCTION ridders(sig) RESULT(sg)
+!
+!-------------------------------------------------------------------------------
+  IMPLICIT NONE
+!-------------------------------------------------------------------------------
+! Purpose: Search for s solving (Pa/Preff)*s+(1-Pa/Preff)*EXP(1-1./s**2)=sg
+! Notes:   Uses Ridders' method, quite robust. Initial bracketing: 0<=sg<=1.
+! Reference: Ridders, C. F. J. "A New Algorithm for Computing a Single Root of a
+!       Real Continuous Function" IEEE Trans. Circuits Systems 26, 979-980, 1979
+!-------------------------------------------------------------------------------
+! Arguments:
+  REAL, INTENT(IN)  :: sig(:)
+  REAL              :: sg(SIZE(sig))
+!-------------------------------------------------------------------------------
+! Local variables:
+  INTEGER :: it, ns, maxit
+  REAL :: c1, c2, x1, x2, x3, x4, f1, f2, f3, f4, s, xx, distrib
+!-------------------------------------------------------------------------------
+  ns=SIZE(sig); maxit=9999
+  c1=Pa/Preff; c2=1.-c1
+  DO l=1,ns
+    xx=HUGE(1.)
+    x1=0.0; f1=distrib(x1,c1,c2,sig(l))
+    x2=1.0; f2=distrib(x2,c1,c2,sig(l))
+    DO it=1,maxit
+      x3=0.5*(x1+x2); f3=distrib(x3,c1,c2,sig(l))
+      s=SQRT(f3**2-f1*f2);                 IF(s==0.) EXIT
+      x4=x3+(x3-x1)*(SIGN(1.,f1-f2)*f3/s); IF(ABS(10.*LOG(x4-xx))<=1E-5) EXIT
+      xx=x4; f4=distrib(x4,c1,c2,sig(l));  IF(f4==0.) EXIT
+      IF(SIGN(f3,f4)/=f3) THEN;      x1=x3; f1=f3; x2=xx; f2=f4
+      ELSE IF(SIGN(f1,f4)/=f1) THEN; x2=xx; f2=f4
+      ELSE IF(SIGN(f2,f4)/=f2) THEN; x1=xx; f1=f4
+      ELSE; CALL abort_gcm("ridders",'Algorithm failed (which is odd...')
+      END IF
+      IF(ABS(10.*LOG(ABS(x2-x1)))<=1E-5) EXIT       !--- ERROR ON SIG <= 0.01m            
+    END DO
+    IF(it==maxit+1) WRITE(lunout,'(a,i3)')'WARNING in ridder: failed to converg&
+     &e for level ',l
+    sg(l)=xx
+  END DO
+  sg(1)=1.; sg(ns)=0.
+
+END FUNCTION ridders
+
+FUNCTION racinesig(sig) RESULT(sg)
+!
+!-------------------------------------------------------------------------------
+  IMPLICIT NONE
+!-------------------------------------------------------------------------------
+! Fredho 2014/05/18
+! Purpose: Search for s solving (Pa/Preff)*sg+(1-Pa/Preff)*EXP(1-1./sg**2)=s
+! Notes:   Uses Newton Raphson search
+!-------------------------------------------------------------------------------
+! Arguments:
+  REAL, INTENT(IN)  :: sig(:)
+  REAL              :: sg(SIZE(sig))
+!-------------------------------------------------------------------------------
+! Local variables:
+  INTEGER :: it, ns, maxit
+  REAL :: c1, c2, x1, x2, x3, x4, f1, f2, f3, f4, s, xx, distrib
+!-------------------------------------------------------------------------------
+  ns=SIZE(sig); maxit=100
+  c1=Pa/Preff; c2=1.-c1
+  DO l=2,ns-1
+    sg(l)=sig(l)
+    DO it=1,maxit
+       f1=exp(1-1./sg(l)**2)*(1.-c1)
+       sg(l)=sg(l)-(c1*sg(l)+f1-sig(l))/(c1+2*f1*sg(l)**(-3))
+    ENDDO
+!   print*,'SSSSIG ',sig(l),sg(l),c1*sg(l)+exp(1-1./sg(l)**2)*(1.-c1)
+  ENDDO
+  sg(1)=1.; sg(ns)=0.
+
+END FUNCTION racinesig
+
+
+
+
 END SUBROUTINE disvert
+
+!-------------------------------------------------------------------------------
+
+FUNCTION distrib(x,c1,c2,x0) RESULT(res)
+!
+!-------------------------------------------------------------------------------
+! Arguments:
+  REAL, INTENT(IN) :: x, c1, c2, x0
+  REAL             :: res
+!-------------------------------------------------------------------------------
+  res=c1*x+c2*EXP(1-1/(x**2))-x0
+
+END FUNCTION distrib
+
+
Index: DZ5/branches/testing/libf/dyn3d_common/exner_hyb.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d_common/exner_hyb.F	(revision 2055)
+++ 	(revision )
@@ -1,152 +1,0 @@
-!
-! $Id $
-!
-      SUBROUTINE  exner_hyb ( ngrid, ps, p,alpha,beta, pks, pk, pkf )
-c
-c     Auteurs :  P.Le Van  , Fr. Hourdin  .
-c    ..........
-c
-c    ....  ngrid, ps,p             sont des argum.d'entree  au sous-prog ...
-c    .... alpha,beta, pks,pk,pkf   sont des argum.de sortie au sous-prog ...
-c
-c   ************************************************************************
-c    Calcule la fonction d'Exner pk = Cp * p ** kappa , aux milieux des 
-c    couches .   Pk(l) sera calcule aux milieux  des couches l ,entre les
-c    pressions p(l) et p(l+1) ,definis aux interfaces des llm couches .
-c   ************************************************************************
-c  .. N.B : Au sommet de l'atmosphere,  p(llm+1) = 0. , et ps et pks sont
-c    la pression et la fonction d'Exner  au  sol  .
-c
-c                                 -------- z                                   
-c    A partir des relations  ( 1 ) p*dz(pk) = kappa *pk*dz(p)      et
-c                            ( 2 ) pk(l) = alpha(l)+ beta(l)*pk(l-1)
-c    ( voir note de Fr.Hourdin )  ,
-c
-c    on determine successivement , du haut vers le bas des couches, les 
-c    coef. alpha(llm),beta(llm) .,.,alpha(l),beta(l),,,alpha(2),beta(2), 
-c    puis pk(ij,1). Ensuite ,on calcule,du bas vers le haut des couches,  
-c     pk(ij,l)  donne  par la relation (2),  pour l = 2 a l = llm .
-c
-c
-      IMPLICIT NONE
-c
-#include "dimensions.h"
-#include "paramet.h"
-#include "comconst.h"
-#include "comgeom.h"
-#include "comvert.h"
-#include "serre.h"
-
-      INTEGER  ngrid
-      REAL p(ngrid,llmp1),pk(ngrid,llm),pkf(ngrid,llm)
-      REAL ps(ngrid),pks(ngrid), alpha(ngrid,llm),beta(ngrid,llm)
-
-c    .... variables locales   ...
-
-      INTEGER l, ij
-      REAL unpl2k,dellta
-
-      REAL ppn(iim),pps(iim)
-      REAL xpn, xps
-      REAL SSUM
-c
-      logical,save :: firstcall=.true.
-      character(len=*),parameter :: modname="exner_hyb"
-      
-      ! Sanity check
-      if (firstcall) then
-        ! sanity checks for Shallow Water case (1 vertical layer)
-        if (llm.eq.1) then
-          if (kappa.ne.1) then
-            call abort_gcm(modname,
-     &      "kappa!=1 , but running in Shallow Water mode!!",42)
-          endif
-          if (cpp.ne.r) then
-            call abort_gcm(modname,
-     &      "cpp!=r , but running in Shallow Water mode!!",42)
-          endif
-        endif ! of if (llm.eq.1)
-
-        firstcall=.false.
-      endif ! of if (firstcall)
-
-      if (llm.eq.1) then
-        
-        ! Compute pks(:),pk(:),pkf(:)
-        
-        DO   ij  = 1, ngrid
-          pks(ij) = (cpp/preff) * ps(ij) 
-          pk(ij,1) = .5*pks(ij)
-        ENDDO
-        
-        CALL SCOPY   ( ngrid * llm, pk, 1, pkf, 1 )
-        CALL filtreg ( pkf, jmp1, llm, 2, 1, .TRUE., 1 ) 
-        
-        ! our work is done, exit routine
-        return
-
-      endif ! of if (llm.eq.1)
-
-!!!! General case:
-     
-      unpl2k    = 1.+ 2.* kappa
-c
-      DO   ij  = 1, ngrid
-        pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
-      ENDDO
-
-      DO  ij   = 1, iim
-        ppn(ij) = aire(   ij   ) * pks(  ij     )
-        pps(ij) = aire(ij+ip1jm) * pks(ij+ip1jm )
-      ENDDO
-      xpn      = SSUM(iim,ppn,1) /apoln
-      xps      = SSUM(iim,pps,1) /apols
-
-      DO ij   = 1, iip1
-        pks(   ij     )  =  xpn
-        pks( ij+ip1jm )  =  xps
-      ENDDO
-c
-c
-c    .... Calcul des coeff. alpha et beta  pour la couche l = llm ..
-c
-      DO     ij      = 1, ngrid
-       alpha(ij,llm) = 0.
-       beta (ij,llm) = 1./ unpl2k
-      ENDDO
-c
-c     ... Calcul des coeff. alpha et beta  pour l = llm-1  a l = 2 ...
-c
-      DO l = llm -1 , 2 , -1
-c
-        DO ij = 1, ngrid
-        dellta = p(ij,l)* unpl2k + p(ij,l+1)* ( beta(ij,l+1)-unpl2k )
-        alpha(ij,l)  = - p(ij,l+1) / dellta * alpha(ij,l+1)
-        beta (ij,l)  =   p(ij,l  ) / dellta   
-        ENDDO
-c
-      ENDDO
-c
-c  ***********************************************************************
-c     .....  Calcul de pk pour la couche 1 , pres du sol  ....
-c
-      DO   ij   = 1, ngrid
-       pk(ij,1) = ( p(ij,1)*pks(ij) - 0.5*alpha(ij,2)*p(ij,2) )  /
-     *    (  p(ij,1)* (1.+kappa) + 0.5*( beta(ij,2)-unpl2k )* p(ij,2) )
-      ENDDO
-c
-c    ..... Calcul de pk(ij,l) , pour l = 2 a l = llm  ........
-c
-      DO l = 2, llm
-        DO   ij   = 1, ngrid
-         pk(ij,l) = alpha(ij,l) + beta(ij,l) * pk(ij,l-1)
-        ENDDO
-      ENDDO
-c
-c
-      CALL SCOPY   ( ngrid * llm, pk, 1, pkf, 1 )
-      CALL filtreg ( pkf, jmp1, llm, 2, 1, .TRUE., 1 )
-      
-
-      RETURN
-      END
Index: /LMDZ5/branches/testing/libf/dyn3d_common/exner_hyb_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d_common/exner_hyb_m.F90	(revision 2056)
+++ /LMDZ5/branches/testing/libf/dyn3d_common/exner_hyb_m.F90	(revision 2056)
@@ -0,0 +1,145 @@
+module exner_hyb_m
+
+  IMPLICIT NONE
+
+contains
+
+  SUBROUTINE  exner_hyb ( ngrid, ps, p, pks, pk, pkf )
+
+    !     Auteurs :  P.Le Van  , Fr. Hourdin  .
+    !    ..........
+    !
+    !    ....  ngrid, ps,p             sont des argum.d'entree  au sous-prog ...
+    !    ....  pks,pk,pkf   sont des argum.de sortie au sous-prog ...
+    !
+    !   ************************************************************************
+    !    Calcule la fonction d'Exner pk = Cp * (p/preff) ** kappa , aux milieux des 
+    !    couches .   Pk(l) sera calcule aux milieux  des couches l ,entre les
+    !    pressions p(l) et p(l+1) ,definis aux interfaces des llm couches .
+    !   ************************************************************************
+    !  .. N.B : Au sommet de l'atmosphere,  p(llm+1) = 0. , et ps et pks sont
+    !    la pression et la fonction d'Exner  au  sol  .
+    !
+    !                                 -------- z
+    !    A partir des relations  ( 1 ) p*dz(pk) = kappa *pk*dz(p)      et
+    !                            ( 2 ) pk(l) = alpha(l)+ beta(l)*pk(l-1)
+    !    ( voir note de Fr.Hourdin )  ,
+    !
+    !    on determine successivement , du haut vers le bas des couches, les 
+    !    coef. alpha(llm),beta(llm) .,.,alpha(l),beta(l),,,alpha(2),beta(2), 
+    !    puis pk(ij,1). Ensuite ,on calcule,du bas vers le haut des couches,  
+    !     pk(ij,l)  donne  par la relation (2),  pour l = 2 a l = llm .
+    !
+    !
+    !
+    include "dimensions.h"
+    include "paramet.h"
+    include "comconst.h"
+    include "comgeom.h"
+    include "comvert.h"
+    include "serre.h"
+
+    INTEGER  ngrid
+    REAL p(ngrid,llmp1),pk(ngrid,llm)
+    real, optional:: pkf(ngrid,llm)
+    REAL ps(ngrid),pks(ngrid), alpha(ngrid,llm),beta(ngrid,llm)
+
+    !    .... variables locales   ...
+
+    INTEGER l, ij
+    REAL unpl2k,dellta
+
+    logical,save :: firstcall=.true.
+    character(len=*),parameter :: modname="exner_hyb"
+
+    ! Sanity check
+    if (firstcall) then
+       ! sanity checks for Shallow Water case (1 vertical layer)
+       if (llm.eq.1) then
+          if (kappa.ne.1) then
+             call abort_gcm(modname, &
+                  "kappa!=1 , but running in Shallow Water mode!!",42)
+          endif
+          if (cpp.ne.r) then
+             call abort_gcm(modname, &
+                  "cpp!=r , but running in Shallow Water mode!!",42)
+          endif
+       endif ! of if (llm.eq.1)
+
+       firstcall=.false.
+    endif ! of if (firstcall)
+
+    ! Specific behaviour for Shallow Water (1 vertical layer) case:
+    if (llm.eq.1) then
+
+       ! Compute pks(:),pk(:),pkf(:)
+
+       DO   ij  = 1, ngrid
+          pks(ij) = (cpp/preff) * ps(ij)
+          pk(ij,1) = .5*pks(ij)
+       ENDDO
+
+       if (present(pkf)) then
+          pkf = pk
+          CALL filtreg ( pkf, jmp1, llm, 2, 1, .TRUE., 1 ) 
+       end if
+
+       ! our work is done, exit routine
+       return
+    endif ! of if (llm.eq.1)
+
+    ! General case:
+
+    unpl2k    = 1.+ 2.* kappa
+
+    !     -------------
+    !     Calcul de pks
+    !     -------------
+
+    DO   ij  = 1, ngrid
+       pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
+    ENDDO
+
+    !    .... Calcul des coeff. alpha et beta  pour la couche l = llm ..
+    !
+    DO     ij      = 1, ngrid
+       alpha(ij,llm) = 0.
+       beta (ij,llm) = 1./ unpl2k
+    ENDDO
+    !
+    !     ... Calcul des coeff. alpha et beta  pour l = llm-1  a l = 2 ...
+    !
+    DO l = llm -1 , 2 , -1
+       !
+       DO ij = 1, ngrid
+          dellta = p(ij,l)* unpl2k + p(ij,l+1)* ( beta(ij,l+1)-unpl2k )
+          alpha(ij,l)  = - p(ij,l+1) / dellta * alpha(ij,l+1)
+          beta (ij,l)  =   p(ij,l  ) / dellta   
+       ENDDO
+    ENDDO
+
+    !  ***********************************************************************
+    !     .....  Calcul de pk pour la couche 1 , pres du sol  ....
+    !
+    DO   ij   = 1, ngrid
+       pk(ij,1) = ( p(ij,1)*pks(ij) - 0.5*alpha(ij,2)*p(ij,2) )  / &
+            (  p(ij,1)* (1.+kappa) + 0.5*( beta(ij,2)-unpl2k )* p(ij,2) )
+    ENDDO
+    !
+    !    ..... Calcul de pk(ij,l) , pour l = 2 a l = llm  ........
+    !
+    DO l = 2, llm
+       DO   ij   = 1, ngrid
+          pk(ij,l) = alpha(ij,l) + beta(ij,l) * pk(ij,l-1)
+       ENDDO
+    ENDDO
+
+    if (present(pkf)) then
+       !    calcul de pkf
+       pkf = pk
+       CALL filtreg ( pkf, jmp1, llm, 2, 1, .TRUE., 1 )
+    end if
+
+  END SUBROUTINE exner_hyb
+
+end module exner_hyb_m
Index: DZ5/branches/testing/libf/dyn3d_common/exner_milieu.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d_common/exner_milieu.F	(revision 2055)
+++ 	(revision )
@@ -1,144 +1,0 @@
-!
-! $Id $
-!
-      SUBROUTINE  exner_milieu ( ngrid, ps, p,beta, pks, pk, pkf )
-c
-c     Auteurs :  F. Forget , Y. Wanherdrick
-c P.Le Van  , Fr. Hourdin  .
-c    ..........
-c
-c    ....  ngrid, ps,p             sont des argum.d'entree  au sous-prog ...
-c    .... beta, pks,pk,pkf   sont des argum.de sortie au sous-prog ...
-c
-c   ************************************************************************
-c    Calcule la fonction d'Exner pk = Cp * (p/preff) ** kappa , aux milieux des 
-c    couches .   Pk(l) sera calcule aux milieux  des couches l ,entre les
-c    pressions p(l) et p(l+1) ,definis aux interfaces des llm couches .
-c   ************************************************************************
-c    .. N.B : Au sommet de l'atmosphere,  p(llm+1) = 0. , et ps et pks sont
-c    la pression et la fonction d'Exner  au  sol  .
-c
-c     WARNING : CECI est une version speciale de exner_hyb originale
-c               Utilise dans la version martienne pour pouvoir 
-c               tourner avec des coordonnees verticales complexe
-c              => Il ne verifie PAS la condition la proportionalite en 
-c              energie totale/ interne / potentielle (F.Forget 2001)
-c    ( voir note de Fr.Hourdin )  ,
-c
-      IMPLICIT NONE
-c
-#include "dimensions.h"
-#include "paramet.h"
-#include "comconst.h"
-#include "comgeom.h"
-#include "comvert.h"
-#include "serre.h"
-
-      INTEGER  ngrid
-      REAL p(ngrid,llmp1),pk(ngrid,llm),pkf(ngrid,llm)
-      REAL ps(ngrid),pks(ngrid), beta(ngrid,llm)
-
-c    .... variables locales   ...
-
-      INTEGER l, ij
-      REAL dum1
-
-      REAL ppn(iim),pps(iim)
-      REAL xpn, xps
-      REAL SSUM
-      EXTERNAL SSUM
-      logical,save :: firstcall=.true.
-      character(len=*),parameter :: modname="exner_milieu"
-
-      ! Sanity check
-      if (firstcall) then
-        ! sanity checks for Shallow Water case (1 vertical layer)
-        if (llm.eq.1) then
-          if (kappa.ne.1) then
-            call abort_gcm(modname,
-     &      "kappa!=1 , but running in Shallow Water mode!!",42)
-          endif
-          if (cpp.ne.r) then
-            call abort_gcm(modname,
-     &      "cpp!=r , but running in Shallow Water mode!!",42)
-          endif
-        endif ! of if (llm.eq.1)
-
-        firstcall=.false.
-      endif ! of if (firstcall)
-
-!!!! Specific behaviour for Shallow Water (1 vertical layer) case:
-      if (llm.eq.1) then
-      
-        ! Compute pks(:),pk(:),pkf(:)
-        
-        DO   ij  = 1, ngrid
-          pks(ij) = (cpp/preff) * ps(ij) 
-          pk(ij,1) = .5*pks(ij)
-        ENDDO
-        
-        CALL SCOPY   ( ngrid * llm, pk, 1, pkf, 1 )
-        CALL filtreg ( pkf, jmp1, llm, 2, 1, .TRUE., 1 ) 
-        
-        ! our work is done, exit routine
-        return
-
-      endif ! of if (llm.eq.1)
-
-!!!! General case:
-
-c     -------------
-c     Calcul de pks
-c     -------------
-   
-      DO   ij  = 1, ngrid
-        pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
-      ENDDO
-
-      DO  ij   = 1, iim
-        ppn(ij) = aire(   ij   ) * pks(  ij     )
-        pps(ij) = aire(ij+ip1jm) * pks(ij+ip1jm )
-      ENDDO
-      xpn      = SSUM(iim,ppn,1) /apoln
-      xps      = SSUM(iim,pps,1) /apols
-
-      DO ij   = 1, iip1
-        pks(   ij     )  =  xpn
-        pks( ij+ip1jm )  =  xps
-      ENDDO
-c
-c
-c    .... Calcul de pk  pour la couche l 
-c    --------------------------------------------
-c
-      dum1 = cpp * (2*preff)**(-kappa) 
-      DO l = 1, llm-1
-        DO   ij   = 1, ngrid
-         pk(ij,l) = dum1 * (p(ij,l) + p(ij,l+1))**kappa
-        ENDDO
-      ENDDO
-
-c    .... Calcul de pk  pour la couche l = llm ..
-c    (on met la meme distance (en log pression)  entre Pk(llm)
-c    et Pk(llm -1) qu'entre Pk(llm-1) et Pk(llm-2)
-
-      DO   ij   = 1, ngrid
-         pk(ij,llm) = pk(ij,llm-1)**2 / pk(ij,llm-2)
-      ENDDO
-
-
-c    calcul de pkf
-c    -------------
-      CALL SCOPY   ( ngrid * llm, pk, 1, pkf, 1 )
-      CALL filtreg ( pkf, jmp1, llm, 2, 1, .TRUE., 1 )
-      
-c    EST-CE UTILE ?? : calcul de beta
-c    --------------------------------
-      DO l = 2, llm
-        DO   ij   = 1, ngrid
-          beta(ij,l) = pk(ij,l) / pk(ij,l-1)   
-        ENDDO
-      ENDDO
-
-      RETURN
-      END
Index: /LMDZ5/branches/testing/libf/dyn3d_common/exner_milieu_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d_common/exner_milieu_m.F90	(revision 2056)
+++ /LMDZ5/branches/testing/libf/dyn3d_common/exner_milieu_m.F90	(revision 2056)
@@ -0,0 +1,124 @@
+module exner_milieu_m
+
+  IMPLICIT NONE
+
+contains
+
+  SUBROUTINE  exner_milieu ( ngrid, ps, p, pks, pk, pkf )
+    !
+    !     Auteurs :  F. Forget , Y. Wanherdrick
+    ! P.Le Van  , Fr. Hourdin  .
+    !    ..........
+    !
+    !    ....  ngrid, ps,p             sont des argum.d'entree  au sous-prog ...
+    !    ....  pks,pk,pkf   sont des argum.de sortie au sous-prog ...
+    !
+    !   ************************************************************************
+    !    Calcule la fonction d'Exner pk = Cp * (p/preff) ** kappa , aux milieux des 
+    !    couches .   Pk(l) sera calcule aux milieux  des couches l ,entre les
+    !    pressions p(l) et p(l+1) ,definis aux interfaces des llm couches .
+    !   ************************************************************************
+    !  .. N.B : Au sommet de l'atmosphere,  p(llm+1) = 0. , et ps et pks sont
+    !    la pression et la fonction d'Exner  au  sol  .
+    !
+    !     WARNING : CECI est une version speciale de exner_hyb originale
+    !               Utilise dans la version martienne pour pouvoir 
+    !               tourner avec des coordonnees verticales complexe
+    !              => Il ne verifie PAS la condition la proportionalite en 
+    !              energie totale/ interne / potentielle (F.Forget 2001)
+    !    ( voir note de Fr.Hourdin )  ,
+    !
+    !
+    include "dimensions.h"
+    include "paramet.h"
+    include "comconst.h"
+    include "comgeom.h"
+    include "comvert.h"
+    include "serre.h"
+
+    INTEGER  ngrid
+    REAL p(ngrid,llmp1),pk(ngrid,llm)
+    real, optional:: pkf(ngrid,llm)
+    REAL ps(ngrid),pks(ngrid)
+
+    !    .... variables locales   ...
+
+    INTEGER l, ij
+    REAL dum1
+
+    logical,save :: firstcall=.true.
+    character(len=*),parameter :: modname="exner_milieu"
+
+    ! Sanity check
+    if (firstcall) then
+       ! sanity checks for Shallow Water case (1 vertical layer)
+       if (llm.eq.1) then
+          if (kappa.ne.1) then
+             call abort_gcm(modname, &
+                  "kappa!=1 , but running in Shallow Water mode!!",42)
+          endif
+          if (cpp.ne.r) then
+             call abort_gcm(modname, &
+                  "cpp!=r , but running in Shallow Water mode!!",42)
+          endif
+       endif ! of if (llm.eq.1)
+
+       firstcall=.false.
+    endif ! of if (firstcall)
+
+    ! Specific behaviour for Shallow Water (1 vertical layer) case:
+    if (llm.eq.1) then
+
+       ! Compute pks(:),pk(:),pkf(:)
+
+       DO   ij  = 1, ngrid
+          pks(ij) = (cpp/preff) * ps(ij)
+          pk(ij,1) = .5*pks(ij)
+       ENDDO
+
+       if (present(pkf)) then
+          pkf = pk
+          CALL filtreg ( pkf, jmp1, llm, 2, 1, .TRUE., 1 ) 
+       end if
+
+       ! our work is done, exit routine
+       return
+    endif ! of if (llm.eq.1)
+
+    ! General case:
+
+    !     -------------
+    !     Calcul de pks
+    !     -------------
+
+    DO   ij  = 1, ngrid
+       pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
+    ENDDO
+
+    !    .... Calcul de pk  pour la couche l 
+    !    --------------------------------------------
+    !
+    dum1 = cpp * (2*preff)**(-kappa) 
+    DO l = 1, llm-1
+       DO   ij   = 1, ngrid
+          pk(ij,l) = dum1 * (p(ij,l) + p(ij,l+1))**kappa
+       ENDDO
+    ENDDO
+
+    !    .... Calcul de pk  pour la couche l = llm ..
+    !    (on met la meme distance (en log pression)  entre Pk(llm)
+    !    et Pk(llm -1) qu'entre Pk(llm-1) et Pk(llm-2)
+
+    DO   ij   = 1, ngrid
+       pk(ij,llm) = pk(ij,llm-1)**2 / pk(ij,llm-2)
+    ENDDO
+
+    if (present(pkf)) then
+       !    calcul de pkf
+       pkf = pk
+       CALL filtreg ( pkf, jmp1, llm, 2, 1, .TRUE., 1 )
+    end if
+
+  END SUBROUTINE exner_milieu
+
+end module exner_milieu_m
Index: /LMDZ5/branches/testing/libf/dyn3d_common/iniconst.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d_common/iniconst.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3d_common/iniconst.F90	(revision 2056)
@@ -73,5 +73,5 @@
   if (disvert_type==1) then
      ! standard case for Earth (automatic generation of levels)
-     call disvert(pa,preff,ap,bp,dpres,presnivs,nivsigs,nivsig, scaleheight)
+     call disvert()
   else if (disvert_type==2) then
      ! standard case for planets (levels generated using z2sig.def file)
Index: /LMDZ5/branches/testing/libf/dyn3d_common/q_sat.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d_common/q_sat.F	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3d_common/q_sat.F	(revision 2056)
@@ -2,39 +2,39 @@
 ! $Header$
 !
-c
-c
+!
+!
 
       subroutine q_sat(np,temp,pres,qsat)
-c
+!
       IMPLICIT none
-c======================================================================
-c Autheur(s): Z.X. Li (LMD/CNRS)
-c  reecriture vectorisee par F. Hourdin.
-c Objet: calculer la vapeur d'eau saturante (formule Centre Euro.)
-c======================================================================
-c Arguments:
-c kelvin---input-R: temperature en Kelvin
-c millibar--input-R: pression en mb
-c
-c q_sat----output-R: vapeur d'eau saturante en kg/kg
-c======================================================================
-c
+!======================================================================
+! Autheur(s): Z.X. Li (LMD/CNRS)
+!  reecriture vectorisee par F. Hourdin.
+! Objet: calculer la vapeur d'eau saturante (formule Centre Euro.)
+!======================================================================
+! Arguments:
+! kelvin---input-R: temperature en Kelvin
+! millibar--input-R: pression en mb
+!
+! q_sat----output-R: vapeur d'eau saturante en kg/kg
+!======================================================================
+!
       integer np
       REAL temp(np),pres(np),qsat(np)
-c
+!
       REAL r2es
       PARAMETER (r2es=611.14 *18.0153/28.9644)
-c
+!
       REAL r3les, r3ies, r3es
       PARAMETER (R3LES=17.269)
       PARAMETER (R3IES=21.875)
-c
+!
       REAL r4les, r4ies, r4es
       PARAMETER (R4LES=35.86)
       PARAMETER (R4IES=7.66)
-c
+!
       REAL rtt
       PARAMETER (rtt=273.16)
-c
+!
       REAL retv
       PARAMETER (retv=28.9644/18.0153 - 1.0)
@@ -42,14 +42,14 @@
       real zqsat
       integer ip
-c
-C     ------------------------------------------------------------------
-c
-c
+!
+!     ------------------------------------------------------------------
+!
+!
 
       do ip=1,np
 
-c      write(*,*)'kelvin,millibar=',kelvin,millibar
-c       write(*,*)'temp,pres=',temp(ip),pres(ip)
-c
+!      write(*,*)'kelvin,millibar=',kelvin,millibar
+!       write(*,*)'temp,pres=',temp(ip),pres(ip)
+!
          IF (temp(ip) .LE. rtt) THEN
             r3es = r3ies
@@ -59,14 +59,14 @@
             r4es = r4les
          ENDIF
-c
+!
          zqsat=r2es/pres(ip)*EXP(r3es*(temp(ip)-rtt)/(temp(ip)-r4es))
          zqsat=MIN(0.5,ZQSAT)
          zqsat=zqsat/(1.-retv *zqsat)
-c
+!
          qsat(ip)= zqsat
-c      write(*,*)'qsat=',qsat(ip)
+!      write(*,*)'qsat=',qsat(ip)
 
       enddo
-c
+!
       RETURN
       END
Index: DZ5/branches/testing/libf/dyn3d_common/tourabs.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d_common/tourabs.F	(revision 2055)
+++ 	(revision )
@@ -1,98 +1,0 @@
-      SUBROUTINE tourabs ( ntetaSTD,vcov, ucov, vorabs )
-      IMPLICIT NONE
-
-c=======================================================================
-c
-c   Modif:  I. Musat (28/10/04)
-c   -------
-c   adaptation du code tourpot.F pour le calcul de la vorticite absolue
-c   cf. P. Le Van
-c
-c   Objet: 
-c   ------
-c
-c    *******************************************************************
-c    .............  calcul de la vorticite absolue     .................
-c    *******************************************************************
-c
-c     ntetaSTD, vcov,ucov      sont des argum. d'entree pour le s-pg .
-c             vorabs            est  un argum.de sortie pour le s-pg .
-c
-c=======================================================================
-
-#include "dimensions.h"
-#include "paramet.h"
-#include "comgeom.h"
-#include "logic.h"
-#include "comconst.h"
-c
-      INTEGER ntetaSTD
-      REAL vcov( ip1jm,ntetaSTD ), ucov( ip1jmp1,ntetaSTD )
-      REAL vorabs( ip1jm,ntetaSTD )
-c
-c variables locales
-      INTEGER l, ij, i, j
-      REAL  rot( ip1jm,ntetaSTD )
-
-
-
-c  ... vorabs = ( Filtre( d(vcov)/dx - d(ucov)/dy ) + fext ) ..
-
-
-
-c    ........  Calcul du rotationnel du vent V  puis filtrage  ........
-
-      DO 5 l = 1,ntetaSTD
-
-      DO 2 i = 1, iip1
-      DO 2 j = 1, jjm
-c
-       ij=i+(j-1)*iip1
-       IF(ij.LE.ip1jm - 1) THEN
-c
-        IF(cv(ij).EQ.0..OR.cv(ij+1).EQ.0..OR.
-     $     cu(ij).EQ.0..OR.cu(ij+iip1).EQ.0.) THEN
-         rot( ij,l ) = 0.
-         continue
-        ELSE
-         rot( ij,l ) = (vcov(ij+1,l)/cv(ij+1)-vcov(ij,l)/cv(ij))/
-     $                 (2.*pi*RAD*cos(rlatv(j)))*REAL(iim)
-     $                +(ucov(ij+iip1,l)/cu(ij+iip1)-ucov(ij,l)/cu(ij))/
-     $                 (pi*RAD)*(REAL(jjm)-1.)
-c
-        ENDIF
-       ENDIF !(ij.LE.ip1jm - 1) THEN
-   2  CONTINUE
-
-c    ....  correction pour  rot( iip1,j,l )  .....
-c    ....     rot(iip1,j,l) = rot(1,j,l)    .....
-
-CDIR$ IVDEP
-
-      DO 3 ij = iip1, ip1jm, iip1
-      rot( ij,l ) = rot( ij -iim, l )
-   3  CONTINUE
-
-   5  CONTINUE
-
-
-      CALL  filtreg( rot, jjm, ntetaSTD, 2, 1, .FALSE., 1 )
-
-
-      DO 10 l = 1, ntetaSTD
-
-      DO 6 ij = 1, ip1jm - 1
-      vorabs( ij,l ) = ( rot(ij,l) + fext(ij)*unsairez(ij) )
-   6  CONTINUE
-
-c    ..... correction pour  vorabs( iip1,j,l)  .....
-c    ....   vorabs(iip1,j,l)= vorabs(1,j,l) ....
-CDIR$ IVDEP
-      DO 8 ij = iip1, ip1jm, iip1
-      vorabs( ij,l ) = vorabs( ij -iim,l )
-   8  CONTINUE
-
-  10  CONTINUE
-
-      RETURN
-      END
Index: /LMDZ5/branches/testing/libf/dyn3dmem/calfis_loc.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dmem/calfis_loc.F	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3dmem/calfis_loc.F	(revision 2056)
@@ -219,10 +219,4 @@
       REAL unskap, pksurcp
 c
-cIM diagnostique PVteta, Amip2
-      INTEGER,PARAMETER :: ntetaSTD=3
-      REAL,SAVE :: rtetaSTD(ntetaSTD)=(/350.,380.,405./) ! Earth-specific, beware !!
-      REAL PVteta(klon,ntetaSTD)
-      
-      
       REAL SSUM
 
@@ -252,6 +246,4 @@
       klon=klon_mpi
       
-      PVteta(:,:)=0.
-            
 c
       IF ( firstcal )  THEN
@@ -510,16 +502,4 @@
       endif
 
-
-      IF (is_sequential.and.(planet_type=="earth")) THEN
-#ifdef CPP_PHYS
-! PVtheta calls tetalevel, which is in the physics
-cIM calcul PV a teta=350, 380, 405K
-        CALL PVtheta(ngridmx,llm,pucov,pvcov,pteta,
-     $           ztfi,zplay,zplev,
-     $           ntetaSTD,rtetaSTD,PVteta)
-c
-#endif
-      ENDIF
-
 c On change de grille, dynamique vers physiq, pour le flux de masse verticale
 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
@@ -707,7 +687,5 @@
      .             zdqfi_omp,
      .             zdpsrf_omp,
-cIM diagnostique PVteta, Amip2          
-     .             pducov,
-     .             PVteta)
+     .             pducov)
 
       else if ( planet_type=="generic" ) then
Index: /LMDZ5/branches/testing/libf/dyn3dmem/call_calfis_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dmem/call_calfis_mod.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3dmem/call_calfis_mod.F90	(revision 2056)
@@ -12,6 +12,4 @@
 
     REAL,POINTER,SAVE :: p(:,:) 
-    REAL,POINTER,SAVE :: alpha(:,:) 
-    REAL,POINTER,SAVE :: beta(:,:) 
     REAL,POINTER,SAVE :: pks(:) 
     REAL,POINTER,SAVE :: pk(:,:) 
@@ -53,6 +51,4 @@
     CALL allocate_u(flxw,llm,d)
     CALL allocate_u(p,llmp1,d)
-    CALL allocate_u(alpha,llm,d)
-    CALL allocate_u(beta,llm,d)
     CALL allocate_u(pks,d)
     CALL allocate_u(pk,llm,d)
@@ -75,4 +71,6 @@
                          phis_dyn,q_dyn,flxw_dyn)
   USE dimensions_mod
+  use exner_hyb_loc_m, only: exner_hyb_loc
+  use exner_milieu_loc_m, only: exner_milieu_loc
   USE parallel_lmdz
   USE times
@@ -201,5 +199,5 @@
 
   !$OMP BARRIER
-    CALL exner_hyb_loc(  ip1jmp1, ps, p,alpha,beta, pks, pk, pkf )
+    CALL exner_hyb_loc(  ip1jmp1, ps, p, pks, pk, pkf )
   !$OMP BARRIER
     CALL geopot_loc  ( ip1jmp1, teta  , pk , pks,  phis  , phi   )
@@ -343,7 +341,7 @@
 !$OMP BARRIER
     if (pressure_exner) then
-      CALL exner_hyb_loc(ijnb_u,ps,p,alpha,beta,pks,pk,pkf)
+      CALL exner_hyb_loc(ijnb_u,ps,p,pks,pk,pkf)
     else 
-      CALL exner_milieu_loc(ijnb_u,ps,p,beta,pks,pk,pkf)
+      CALL exner_milieu_loc(ijnb_u,ps,p,pks,pk,pkf)
     endif
 !$OMP BARRIER
Index: DZ5/branches/testing/libf/dyn3dmem/exner_hyb_loc.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dmem/exner_hyb_loc.F	(revision 2055)
+++ 	(revision )
@@ -1,242 +1,0 @@
-c
-c $Id$
-c
-      SUBROUTINE  exner_hyb_loc(ngrid, ps, p,alpha,beta, pks,pk,pkf)
-c
-c     Auteurs :  P.Le Van  , Fr. Hourdin  .
-c    ..........
-c
-c    ....  ngrid, ps,p             sont des argum.d'entree  au sous-prog ...
-c    .... alpha,beta, pks,pk,pkf   sont des argum.de sortie au sous-prog ...
-c
-c   ************************************************************************
-c    Calcule la fonction d'Exner pk = Cp * p ** kappa , aux milieux des 
-c    couches .   Pk(l) sera calcule aux milieux  des couches l ,entre les
-c    pressions p(l) et p(l+1) ,definis aux interfaces des llm couches .
-c   ************************************************************************
-c  .. N.B : Au sommet de l'atmosphere,  p(llm+1) = 0. , et ps et pks sont
-c    la pression et la fonction d'Exner  au  sol  .
-c
-c                                 -------- z                                   
-c    A partir des relations  ( 1 ) p*dz(pk) = kappa *pk*dz(p)      et
-c                            ( 2 ) pk(l) = alpha(l)+ beta(l)*pk(l-1)
-c    ( voir note de Fr.Hourdin )  ,
-c
-c    on determine successivement , du haut vers le bas des couches, les 
-c    coef. alpha(llm),beta(llm) .,.,alpha(l),beta(l),,,alpha(2),beta(2), 
-c    puis pk(ij,1). Ensuite ,on calcule,du bas vers le haut des couches,  
-c     pk(ij,l)  donne  par la relation (2),  pour l = 2 a l = llm .
-c
-c
-      USE parallel_lmdz
-      USE mod_filtreg_p
-      USE write_field_loc
-      IMPLICIT NONE
-c
-#include "dimensions.h"
-#include "paramet.h"
-#include "comconst.h"
-#include "comgeom.h"
-#include "comvert.h"
-#include "serre.h"
-
-      INTEGER  ngrid
-      REAL p(ijb_u:ije_u,llmp1),pk(ijb_u:ije_u,llm)
-      REAL pkf(ijb_u:ije_u,llm)
-      REAL ps(ijb_u:ije_u),pks(ijb_u:ije_u)
-      REAL alpha(ijb_u:ije_u,llm),beta(ijb_u:ije_u,llm)
-
-c    .... variables locales   ...
-
-      INTEGER l, ij
-      REAL unpl2k,dellta
-
-      REAL ppn(iim),pps(iim)
-      REAL xpn, xps
-      REAL SSUM
-      EXTERNAL SSUM
-      INTEGER ije,ijb,jje,jjb
-      logical,save :: firstcall=.true.
-!$OMP THREADPRIVATE(firstcall) 
-      character(len=*),parameter :: modname="exner_hyb_loc"
-c
-c$OMP BARRIER           
-
-      ! Sanity check
-      if (firstcall) then
-        ! sanity checks for Shallow Water case (1 vertical layer)
-        if (llm.eq.1) then
-          if (kappa.ne.1) then
-            call abort_gcm(modname,
-     &      "kappa!=1 , but running in Shallow Water mode!!",42)
-          endif
-          if (cpp.ne.r) then
-            call abort_gcm(modname,
-     &      "cpp!=r , but running in Shallow Water mode!!",42)
-          endif
-        endif ! of if (llm.eq.1)
-
-        firstcall=.false.
-      endif ! of if (firstcall)
-
-c$OMP BARRIER
-
-! Specific behaviour for Shallow Water (1 vertical layer) case
-      if (llm.eq.1) then
-        
-        ! Compute pks(:),pk(:),pkf(:)
-        ijb=ij_begin
-        ije=ij_end
-!$OMP DO SCHEDULE(STATIC)
-        DO ij=ijb, ije
-          pks(ij)=(cpp/preff)*ps(ij)
-          pk(ij,1) = .5*pks(ij)
-          pkf(ij,1)=pk(ij,1)
-        ENDDO
-!$OMP ENDDO
-
-!$OMP MASTER
-      if (pole_nord) then
-        DO  ij   = 1, iim
-          ppn(ij) = aire(   ij   ) * pks(  ij     )
-        ENDDO
-        xpn      = SSUM(iim,ppn,1) /apoln
-  
-        DO ij   = 1, iip1
-          pks(   ij     )  =  xpn
-          pk(ij,1) = .5*pks(ij)
-          pkf(ij,1)=pk(ij,1)
-        ENDDO
-      endif
-      
-      if (pole_sud) then
-        DO  ij   = 1, iim
-          pps(ij) = aire(ij+ip1jm) * pks(ij+ip1jm )
-        ENDDO
-        xps      = SSUM(iim,pps,1) /apols 
-  
-        DO ij   = 1, iip1
-          pks( ij+ip1jm )  =  xps
-          pk(ij+ip1jm,1)=.5*pks(ij+ip1jm)
-          pkf(ij+ip1jm,1)=pk(ij+ip1jm,1)
-        ENDDO
-      endif
-!$OMP END MASTER
-!$OMP BARRIER
-        jjb=jj_begin
-        jje=jj_end
-        CALL filtreg_p ( pkf,jjb_u,jje_u,jjb,jje, jmp1, llm,
-     &                 2, 1, .TRUE., 1 )
-
-        ! our work is done, exit routine
-        return
-      endif ! of if (llm.eq.1)
-
-
-      unpl2k    = 1.+ 2.* kappa
-c
-      ijb=ij_begin
-      ije=ij_end
-
-c$OMP DO SCHEDULE(STATIC)
-      DO   ij  = ijb, ije
-        pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
-      ENDDO
-c$OMP ENDDO
-c Synchro OPENMP ici
-
-c$OMP MASTER
-      if (pole_nord) then
-        DO  ij   = 1, iim
-          ppn(ij) = aire(   ij   ) * pks(  ij     )
-        ENDDO
-        xpn      = SSUM(iim,ppn,1) /apoln
-  
-        DO ij   = 1, iip1
-          pks(   ij     )  =  xpn
-        ENDDO
-      endif
-      
-      if (pole_sud) then
-        DO  ij   = 1, iim
-          pps(ij) = aire(ij+ip1jm) * pks(ij+ip1jm )
-        ENDDO
-        xps      = SSUM(iim,pps,1) /apols 
-  
-        DO ij   = 1, iip1
-          pks( ij+ip1jm )  =  xps
-        ENDDO
-      endif
-c$OMP END MASTER
-c$OMP BARRIER
-c
-c
-c    .... Calcul des coeff. alpha et beta  pour la couche l = llm ..
-c
-c$OMP DO SCHEDULE(STATIC)
-      DO     ij      = ijb,ije
-       alpha(ij,llm) = 0.
-       beta (ij,llm) = 1./ unpl2k
-      ENDDO
-c$OMP ENDDO NOWAIT
-c
-c     ... Calcul des coeff. alpha et beta  pour l = llm-1  a l = 2 ...
-c
-      DO l = llm -1 , 2 , -1
-c
-c$OMP DO SCHEDULE(STATIC)
-        DO ij = ijb, ije
-        dellta = p(ij,l)* unpl2k + p(ij,l+1)* ( beta(ij,l+1)-unpl2k )
-        alpha(ij,l)  = - p(ij,l+1) / dellta * alpha(ij,l+1)
-        beta (ij,l)  =   p(ij,l  ) / dellta   
-        ENDDO
-c$OMP ENDDO NOWAIT
-c
-      ENDDO
-
-c
-c  ***********************************************************************
-c     .....  Calcul de pk pour la couche 1 , pres du sol  ....
-c
-c$OMP DO SCHEDULE(STATIC)
-      DO   ij   = ijb, ije
-       pk(ij,1) = ( p(ij,1)*pks(ij) - 0.5*alpha(ij,2)*p(ij,2) )  /
-     *    (  p(ij,1)* (1.+kappa) + 0.5*( beta(ij,2)-unpl2k )* p(ij,2) )
-      ENDDO
-c$OMP ENDDO NOWAIT
-c
-c    ..... Calcul de pk(ij,l) , pour l = 2 a l = llm  ........
-c
-      DO l = 2, llm
-c$OMP DO SCHEDULE(STATIC)
-        DO   ij   = ijb, ije
-         pk(ij,l) = alpha(ij,l) + beta(ij,l) * pk(ij,l-1)
-        ENDDO
-c$OMP ENDDO NOWAIT        
-      ENDDO
-c
-c
-c      CALL SCOPY   ( ngrid * llm, pk, 1, pkf, 1 )
-      DO l = 1, llm
-c$OMP DO SCHEDULE(STATIC)
-         DO   ij   = ijb, ije
-           pkf(ij,l)=pk(ij,l)
-         ENDDO
-c$OMP ENDDO NOWAIT             
-      ENDDO
-
-c$OMP BARRIER
-      
-      jjb=jj_begin
-      jje=jj_end
-#ifdef DEBUG_IO    
-      call WriteField_u('pkf',pkf)
-#endif
-      CALL filtreg_p ( pkf,jjb_u,jje_u,jjb,jje, jmp1, llm,
-     &                 2, 1, .TRUE., 1 )
-#ifdef DEBUG_IO    
-      call WriteField_u('pkf',pkf)
-#endif      
-
-      RETURN
-      END
Index: /LMDZ5/branches/testing/libf/dyn3dmem/exner_hyb_loc_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dmem/exner_hyb_loc_m.F90	(revision 2056)
+++ /LMDZ5/branches/testing/libf/dyn3dmem/exner_hyb_loc_m.F90	(revision 2056)
@@ -0,0 +1,198 @@
+module exner_hyb_loc_m
+
+  IMPLICIT NONE
+
+contains
+
+  SUBROUTINE  exner_hyb_loc(ngrid, ps, p, pks,pk,pkf)
+
+    !     Auteurs :  P.Le Van  , Fr. Hourdin  .
+    !    ..........
+    !
+    !    ....  ngrid, ps,p             sont des argum.d'entree  au sous-prog ...
+    !    ....  pks,pk,pkf   sont des argum.de sortie au sous-prog ...
+    !
+    !   ************************************************************************
+    !    Calcule la fonction d'Exner pk = Cp * (p/preff) ** kappa , aux milieux des 
+    !    couches .   Pk(l) sera calcule aux milieux  des couches l ,entre les
+    !    pressions p(l) et p(l+1) ,definis aux interfaces des llm couches .
+    !   ************************************************************************
+    !  .. N.B : Au sommet de l'atmosphere,  p(llm+1) = 0. , et ps et pks sont
+    !    la pression et la fonction d'Exner  au  sol  .
+    !
+    !                                 -------- z
+    !    A partir des relations  ( 1 ) p*dz(pk) = kappa *pk*dz(p)      et
+    !                            ( 2 ) pk(l) = alpha(l)+ beta(l)*pk(l-1)
+    !    ( voir note de Fr.Hourdin )  ,
+    !
+    !    on determine successivement , du haut vers le bas des couches, les 
+    !    coef. alpha(llm),beta(llm) .,.,alpha(l),beta(l),,,alpha(2),beta(2), 
+    !    puis pk(ij,1). Ensuite ,on calcule,du bas vers le haut des couches,  
+    !     pk(ij,l)  donne  par la relation (2),  pour l = 2 a l = llm .
+    !
+    !
+    USE parallel_lmdz
+    USE mod_filtreg_p
+    USE write_field_loc
+    !
+    include "dimensions.h"
+    include "paramet.h"
+    include "comconst.h"
+    include "comgeom.h"
+    include "comvert.h"
+    include "serre.h"
+
+    INTEGER  ngrid
+    REAL p(ijb_u:ije_u,llmp1),pk(ijb_u:ije_u,llm)
+    REAL, optional:: pkf(ijb_u:ije_u,llm)
+    REAL ps(ijb_u:ije_u),pks(ijb_u:ije_u)
+    REAL alpha(ijb_u:ije_u,llm),beta(ijb_u:ije_u,llm)
+
+    !    .... variables locales   ...
+
+    INTEGER l, ij
+    REAL unpl2k,dellta
+
+    INTEGER ije,ijb,jje,jjb
+    logical,save :: firstcall=.true.
+    !$OMP THREADPRIVATE(firstcall) 
+    character(len=*),parameter :: modname="exner_hyb_loc"
+    !
+    !$OMP BARRIER           
+
+    ! Sanity check
+    if (firstcall) then
+       ! sanity checks for Shallow Water case (1 vertical layer)
+       if (llm.eq.1) then
+          if (kappa.ne.1) then
+             call abort_gcm(modname, &
+                  "kappa!=1 , but running in Shallow Water mode!!",42)
+          endif
+          if (cpp.ne.r) then
+             call abort_gcm(modname, &
+                  "cpp!=r , but running in Shallow Water mode!!",42)
+          endif
+       endif ! of if (llm.eq.1)
+
+       firstcall=.false.
+    endif ! of if (firstcall)
+
+    !$OMP BARRIER
+
+    ! Specific behaviour for Shallow Water (1 vertical layer) case:
+    if (llm.eq.1) then
+
+       ! Compute pks(:),pk(:),pkf(:)
+       ijb=ij_begin
+       ije=ij_end
+       !$OMP DO SCHEDULE(STATIC)
+       DO ij=ijb, ije
+          pks(ij) = (cpp/preff) * ps(ij)
+          pk(ij,1) = .5*pks(ij)
+          if (present(pkf)) pkf(ij,1)=pk(ij,1)
+       ENDDO
+       !$OMP ENDDO
+
+       !$OMP BARRIER
+       if (present(pkf)) then
+          jjb=jj_begin
+          jje=jj_end
+          CALL filtreg_p ( pkf,jjb_u,jje_u,jjb,jje, jmp1, llm, &
+               2, 1, .TRUE., 1 )
+       end if
+
+       ! our work is done, exit routine
+       return
+    endif ! of if (llm.eq.1)
+
+    ! General case:
+
+    unpl2k    = 1.+ 2.* kappa
+
+    !     -------------
+    !     Calcul de pks
+    !     -------------
+
+    ijb=ij_begin
+    ije=ij_end
+
+    !$OMP DO SCHEDULE(STATIC)
+    DO   ij  = ijb, ije
+       pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
+    ENDDO
+    !$OMP ENDDO
+    ! Synchro OPENMP ici
+
+    !$OMP BARRIER
+    !
+    !
+    !    .... Calcul des coeff. alpha et beta  pour la couche l = llm ..
+    !
+    !$OMP DO SCHEDULE(STATIC)
+    DO     ij      = ijb,ije
+       alpha(ij,llm) = 0.
+       beta (ij,llm) = 1./ unpl2k
+    ENDDO
+    !$OMP ENDDO NOWAIT
+    !
+    !     ... Calcul des coeff. alpha et beta  pour l = llm-1  a l = 2 ...
+    !
+    DO l = llm -1 , 2 , -1
+       !
+       !$OMP DO SCHEDULE(STATIC)
+       DO ij = ijb, ije
+          dellta = p(ij,l)* unpl2k + p(ij,l+1)* ( beta(ij,l+1)-unpl2k )
+          alpha(ij,l)  = - p(ij,l+1) / dellta * alpha(ij,l+1)
+          beta (ij,l)  =   p(ij,l  ) / dellta   
+       ENDDO
+       !$OMP ENDDO NOWAIT
+    ENDDO
+
+    !  ***********************************************************************
+    !     .....  Calcul de pk pour la couche 1 , pres du sol  ....
+    !
+    !$OMP DO SCHEDULE(STATIC)
+    DO   ij   = ijb, ije
+       pk(ij,1) = ( p(ij,1)*pks(ij) - 0.5*alpha(ij,2)*p(ij,2) )  / &
+            (  p(ij,1)* (1.+kappa) + 0.5*( beta(ij,2)-unpl2k )* p(ij,2) )
+    ENDDO
+    !$OMP ENDDO NOWAIT
+    !
+    !    ..... Calcul de pk(ij,l) , pour l = 2 a l = llm  ........
+    !
+    DO l = 2, llm
+       !$OMP DO SCHEDULE(STATIC)
+       DO   ij   = ijb, ije
+          pk(ij,l) = alpha(ij,l) + beta(ij,l) * pk(ij,l-1)
+       ENDDO
+       !$OMP ENDDO NOWAIT        
+    ENDDO
+
+    if (present(pkf)) then
+       !    calcul de pkf
+
+       DO l = 1, llm
+          !$OMP DO SCHEDULE(STATIC)
+          DO   ij   = ijb, ije
+             pkf(ij,l)=pk(ij,l)
+          ENDDO
+          !$OMP ENDDO NOWAIT             
+       ENDDO
+
+       !$OMP BARRIER
+
+       jjb=jj_begin
+       jje=jj_end
+#ifdef DEBUG_IO    
+       call WriteField_u('pkf',pkf)
+#endif
+       CALL filtreg_p ( pkf,jjb_u,jje_u,jjb,jje, jmp1, llm, &
+            2, 1, .TRUE., 1 )
+#ifdef DEBUG_IO    
+       call WriteField_u('pkf',pkf)
+#endif     
+    end if
+
+  END SUBROUTINE exner_hyb_loc
+
+end module exner_hyb_loc_m
Index: DZ5/branches/testing/libf/dyn3dmem/exner_milieu_loc.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dmem/exner_milieu_loc.F	(revision 2055)
+++ 	(revision )
@@ -1,224 +1,0 @@
-!
-! $Id$
-!
-      SUBROUTINE  exner_milieu_loc ( ngrid, ps, p,beta, pks, pk, pkf )
-c
-c     Auteurs :  F. Forget , Y. Wanherdrick
-c P.Le Van  , Fr. Hourdin  .
-c    ..........
-c
-c    ....  ngrid, ps,p             sont des argum.d'entree  au sous-prog ...
-c    .... beta, pks,pk,pkf   sont des argum.de sortie au sous-prog ...
-c
-c   ************************************************************************
-c    Calcule la fonction d'Exner pk = Cp * (p/preff) ** kappa , aux milieux des 
-c    couches .   Pk(l) sera calcule aux milieux  des couches l ,entre les
-c    pressions p(l) et p(l+1) ,definis aux interfaces des llm couches .
-c   ************************************************************************
-c    .. N.B : Au sommet de l'atmosphere,  p(llm+1) = 0. , et ps et pks sont
-c    la pression et la fonction d'Exner  au  sol  .
-c
-c     WARNING : CECI est une version speciale de exner_hyb originale
-c               Utilise dans la version martienne pour pouvoir 
-c               tourner avec des coordonnees verticales complexe
-c              => Il ne verifie PAS la condition la proportionalite en 
-c              energie totale/ interne / potentielle (F.Forget 2001)
-c    ( voir note de Fr.Hourdin )  ,
-c
-      USE parallel_lmdz
-      USE mod_filtreg_p
-      IMPLICIT NONE
-c
-#include "dimensions.h"
-#include "paramet.h"
-#include "comconst.h"
-#include "comgeom.h"
-#include "comvert.h"
-#include "serre.h"
-
-      INTEGER  ngrid
-      REAL p(ijb_u:ije_u,llmp1),pk(ijb_u:ije_u,llm)
-      REAL pkf(ijb_u:ije_u,llm)
-      REAL ps(ijb_u:ije_u),pks(ijb_u:ije_u)
-      REAL alpha(ijb_u:ije_u,llm),beta(ijb_u:ije_u,llm)
-
-c    .... variables locales   ...
-
-      INTEGER l, ij
-      REAL dum1
-
-      REAL ppn(iim),pps(iim)
-      REAL xpn, xps
-      REAL SSUM
-      EXTERNAL SSUM
-      INTEGER ije,ijb,jje,jjb
-      logical,save :: firstcall=.true.
-!$OMP THREADPRIVATE(firstcall) 
-      character(len=*),parameter :: modname="exner_milieu_loc"
-
-      ! Sanity check
-      if (firstcall) then
-        
-        ! sanity checks for Shallow Water case (1 vertical layer)
-        if (llm.eq.1) then
-          if (kappa.ne.1) then
-            call abort_gcm(modname,
-     &      "kappa!=1 , but running in Shallow Water mode!!",42)
-          endif
-          if (cpp.ne.r) then
-            call abort_gcm(modname,
-     &      "cpp!=r , but running in Shallow Water mode!!",42)
-          endif
-        endif ! of if (llm.eq.1)
-
-        firstcall=.false.
-      endif ! of if (firstcall)
-      
-c$OMP BARRIER
-
-! Specific behaviour for Shallow Water (1 vertical layer) case
-      if (llm.eq.1) then
-              
-        ! Compute pks(:),pk(:),pkf(:)
-        ijb=ij_begin
-        ije=ij_end
-!$OMP DO SCHEDULE(STATIC)
-        DO ij=ijb, ije
-          pks(ij)=(cpp/preff)*ps(ij)
-          pk(ij,1) = .5*pks(ij)
-          pkf(ij,1)=pk(ij,1)
-        ENDDO
-!$OMP ENDDO
-
-!$OMP MASTER
-      if (pole_nord) then
-        DO  ij   = 1, iim
-          ppn(ij) = aire(   ij   ) * pks(  ij     )
-        ENDDO
-        xpn      = SSUM(iim,ppn,1) /apoln
-  
-        DO ij   = 1, iip1
-          pks(   ij     )  =  xpn
-          pk(ij,1) = .5*pks(ij)
-          pkf(ij,1)=pk(ij,1)
-        ENDDO
-      endif
-      
-      if (pole_sud) then
-        DO  ij   = 1, iim
-          pps(ij) = aire(ij+ip1jm) * pks(ij+ip1jm )
-        ENDDO
-        xps      = SSUM(iim,pps,1) /apols 
-  
-        DO ij   = 1, iip1
-          pks( ij+ip1jm )  =  xps
-          pk(ij+ip1jm,1)=.5*pks(ij+ip1jm)
-          pkf(ij+ip1jm,1)=pk(ij+ip1jm,1)
-        ENDDO
-      endif
-!$OMP END MASTER
-!$OMP BARRIER
-        jjb=jj_begin
-        jje=jj_end
-        CALL filtreg_p ( pkf,jjb_u,jje_u,jjb,jje, jmp1, llm,
-     &                 2, 1, .TRUE., 1 )
-
-        ! our work is done, exit routine
-        return
-      endif ! of if (llm.eq.1)
-
-!!!! General case:
-
-c     -------------
-c     Calcul de pks
-c     -------------
-   
-      ijb=ij_begin
-      ije=ij_end
-
-c$OMP DO SCHEDULE(STATIC)
-      DO   ij  = ijb, ije
-        pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
-      ENDDO
-c$OMP ENDDO
-c Synchro OPENMP ici
-
-c$OMP MASTER
-      if (pole_nord) then
-        DO  ij   = 1, iim
-          ppn(ij) = aire(   ij   ) * pks(  ij     )
-        ENDDO
-        xpn      = SSUM(iim,ppn,1) /apoln
-  
-        DO ij   = 1, iip1
-          pks(   ij     )  =  xpn
-        ENDDO
-      endif
-      
-      if (pole_sud) then
-        DO  ij   = 1, iim
-          pps(ij) = aire(ij+ip1jm) * pks(ij+ip1jm )
-        ENDDO
-        xps      = SSUM(iim,pps,1) /apols 
-  
-        DO ij   = 1, iip1
-          pks( ij+ip1jm )  =  xps
-        ENDDO
-      endif
-c$OMP END MASTER
-c$OMP BARRIER
-c
-c
-c    .... Calcul de pk  pour la couche l 
-c    --------------------------------------------
-c
-      dum1 = cpp * (2*preff)**(-kappa) 
-      DO l = 1, llm-1
-c$OMP DO SCHEDULE(STATIC)
-        DO   ij   = ijb, ije
-         pk(ij,l) = dum1 * (p(ij,l) + p(ij,l+1))**kappa
-        ENDDO
-c$OMP ENDDO NOWAIT        
-      ENDDO
-
-c    .... Calcul de pk  pour la couche l = llm ..
-c    (on met la meme distance (en log pression)  entre Pk(llm)
-c    et Pk(llm -1) qu'entre Pk(llm-1) et Pk(llm-2)
-
-c$OMP DO SCHEDULE(STATIC)
-      DO   ij   = ijb, ije
-         pk(ij,llm) = pk(ij,llm-1)**2 / pk(ij,llm-2)
-      ENDDO
-c$OMP ENDDO NOWAIT        
-
-
-c    calcul de pkf
-c    -------------
-c      CALL SCOPY   ( ngrid * llm, pk, 1, pkf, 1 )
-      DO l = 1, llm
-c$OMP DO SCHEDULE(STATIC)
-         DO   ij   = ijb, ije
-           pkf(ij,l)=pk(ij,l)
-         ENDDO
-c$OMP ENDDO NOWAIT             
-      ENDDO
-
-c$OMP BARRIER
-      
-      jjb=jj_begin
-      jje=jj_end
-      CALL filtreg_p ( pkf,jjb_u,jje_u,jjb,jje, jmp1, llm,
-     &                 2, 1, .TRUE., 1 )
-      
-c    EST-CE UTILE ?? : calcul de beta
-c    --------------------------------
-      DO l = 2, llm
-c$OMP DO SCHEDULE(STATIC)
-        DO   ij   = ijb, ije
-          beta(ij,l) = pk(ij,l) / pk(ij,l-1)   
-        ENDDO
-c$OMP ENDDO NOWAIT             
-      ENDDO
-
-      RETURN
-      END
Index: /LMDZ5/branches/testing/libf/dyn3dmem/exner_milieu_loc_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dmem/exner_milieu_loc_m.F90	(revision 2056)
+++ /LMDZ5/branches/testing/libf/dyn3dmem/exner_milieu_loc_m.F90	(revision 2056)
@@ -0,0 +1,163 @@
+module exner_milieu_loc_m
+
+  IMPLICIT NONE
+
+contains
+
+  SUBROUTINE  exner_milieu_loc ( ngrid, ps, p, pks, pk, pkf )
+    !
+    !     Auteurs :  F. Forget , Y. Wanherdrick
+    ! P.Le Van  , Fr. Hourdin  .
+    !    ..........
+    !
+    !    ....  ngrid, ps,p             sont des argum.d'entree  au sous-prog ...
+    !    ....  pks,pk,pkf   sont des argum.de sortie au sous-prog ...
+    !
+    !   ************************************************************************
+    !    Calcule la fonction d'Exner pk = Cp * (p/preff) ** kappa , aux milieux des 
+    !    couches .   Pk(l) sera calcule aux milieux  des couches l ,entre les
+    !    pressions p(l) et p(l+1) ,definis aux interfaces des llm couches .
+    !   ************************************************************************
+    !  .. N.B : Au sommet de l'atmosphere,  p(llm+1) = 0. , et ps et pks sont
+    !    la pression et la fonction d'Exner  au  sol  .
+    !
+    !     WARNING : CECI est une version speciale de exner_hyb originale
+    !               Utilise dans la version martienne pour pouvoir 
+    !               tourner avec des coordonnees verticales complexe
+    !              => Il ne verifie PAS la condition la proportionalite en 
+    !              energie totale/ interne / potentielle (F.Forget 2001)
+    !    ( voir note de Fr.Hourdin )  ,
+    !
+    USE parallel_lmdz
+    USE mod_filtreg_p
+    !
+    include "dimensions.h"
+    include "paramet.h"
+    include "comconst.h"
+    include "comgeom.h"
+    include "comvert.h"
+    include "serre.h"
+
+    INTEGER  ngrid
+    REAL p(ijb_u:ije_u,llmp1),pk(ijb_u:ije_u,llm)
+    REAL, optional:: pkf(ijb_u:ije_u,llm)
+    REAL ps(ijb_u:ije_u),pks(ijb_u:ije_u)
+
+    !    .... variables locales   ...
+
+    INTEGER l, ij
+    REAL dum1
+
+    INTEGER ije,ijb,jje,jjb
+    logical,save :: firstcall=.true.
+    !$OMP THREADPRIVATE(firstcall) 
+    character(len=*),parameter :: modname="exner_milieu_loc"
+
+    ! Sanity check
+    if (firstcall) then
+       ! sanity checks for Shallow Water case (1 vertical layer)
+       if (llm.eq.1) then
+          if (kappa.ne.1) then
+             call abort_gcm(modname, &
+                  "kappa!=1 , but running in Shallow Water mode!!",42)
+          endif
+          if (cpp.ne.r) then
+             call abort_gcm(modname, &
+                  "cpp!=r , but running in Shallow Water mode!!",42)
+          endif
+       endif ! of if (llm.eq.1)
+
+       firstcall=.false.
+    endif ! of if (firstcall)
+
+    !$OMP BARRIER
+
+    ! Specific behaviour for Shallow Water (1 vertical layer) case:
+    if (llm.eq.1) then
+
+       ! Compute pks(:),pk(:),pkf(:)
+       ijb=ij_begin
+       ije=ij_end
+       !$OMP DO SCHEDULE(STATIC)
+       DO ij=ijb, ije
+          pks(ij) = (cpp/preff) * ps(ij)
+          pk(ij,1) = .5*pks(ij)
+          if (present(pkf)) pkf(ij,1)=pk(ij,1)
+       ENDDO
+       !$OMP ENDDO
+
+       !$OMP BARRIER
+       if (present(pkf)) then
+          jjb=jj_begin
+          jje=jj_end
+          CALL filtreg_p ( pkf,jjb_u,jje_u,jjb,jje, jmp1, llm, &
+               2, 1, .TRUE., 1 )
+       end if
+
+       ! our work is done, exit routine
+       return
+    endif ! of if (llm.eq.1)
+
+    ! General case:
+
+    !     -------------
+    !     Calcul de pks
+    !     -------------
+
+    ijb=ij_begin
+    ije=ij_end
+
+    !$OMP DO SCHEDULE(STATIC)
+    DO   ij  = ijb, ije
+       pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
+    ENDDO
+    !$OMP ENDDO
+    ! Synchro OPENMP ici
+
+    !$OMP BARRIER
+    !
+    !
+    !    .... Calcul de pk  pour la couche l 
+    !    --------------------------------------------
+    !
+    dum1 = cpp * (2*preff)**(-kappa) 
+    DO l = 1, llm-1
+       !$OMP DO SCHEDULE(STATIC)
+       DO   ij   = ijb, ije
+          pk(ij,l) = dum1 * (p(ij,l) + p(ij,l+1))**kappa
+       ENDDO
+       !$OMP ENDDO NOWAIT
+    ENDDO
+
+    !    .... Calcul de pk  pour la couche l = llm ..
+    !    (on met la meme distance (en log pression)  entre Pk(llm)
+    !    et Pk(llm -1) qu'entre Pk(llm-1) et Pk(llm-2)
+
+    !$OMP DO SCHEDULE(STATIC)
+    DO   ij   = ijb, ije
+       pk(ij,llm) = pk(ij,llm-1)**2 / pk(ij,llm-2)
+    ENDDO
+    !$OMP ENDDO NOWAIT        
+
+    if (present(pkf)) then
+       !    calcul de pkf
+
+       DO l = 1, llm
+          !$OMP DO SCHEDULE(STATIC)
+          DO   ij   = ijb, ije
+             pkf(ij,l)=pk(ij,l)
+          ENDDO
+          !$OMP ENDDO NOWAIT
+       ENDDO
+
+       !$OMP BARRIER
+
+       jjb=jj_begin
+       jje=jj_end
+       CALL filtreg_p ( pkf,jjb_u,jje_u,jjb,jje, jmp1, llm, &
+            2, 1, .TRUE., 1 )
+    end if
+
+  END SUBROUTINE exner_milieu_loc
+
+end module exner_milieu_loc_m
Index: /LMDZ5/branches/testing/libf/dyn3dmem/gcm.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dmem/gcm.F	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3dmem/gcm.F	(revision 2056)
@@ -98,7 +98,4 @@
       REAL,ALLOCATABLE,SAVE  :: ps(:)         ! pression  au sol
 c      REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.des couches
-c      REAL pks(ip1jmp1)                      ! exner au  sol
-c      REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
-c      REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
       REAL,ALLOCATABLE,SAVE  :: masse(:,:)    ! masse d'air
       REAL,ALLOCATABLE,SAVE  :: phis(:)       ! geopotentiel au sol
@@ -124,5 +121,4 @@
       data call_iniphys/.true./
 
-c      REAL alpha(ip1jmp1,llm),beta(ip1jmp1,llm)
 c+jld variables test conservation energie
 c      REAL ecin(ip1jmp1,llm),ecin0(ip1jmp1,llm)
@@ -481,5 +477,10 @@
 
 
-      day_end = day_ini + nday
+      if (nday>=0) then
+         day_end = day_ini + nday
+      else
+         day_end = day_ini - nday/day_step
+      endif
+  
       WRITE(lunout,300)day_ini,day_end
  300  FORMAT('1'/,15x,'run du jour',i7,2x,'au jour',i7//)
Index: /LMDZ5/branches/testing/libf/dyn3dmem/guide_loc_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dmem/guide_loc_mod.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3dmem/guide_loc_mod.F90	(revision 2056)
@@ -329,4 +329,6 @@
 !=======================================================================
   SUBROUTINE guide_main(itau,ucov,vcov,teta,q,masse,ps)
+    use exner_hyb_loc_m, only: exner_hyb_loc
+    use exner_milieu_loc_m, only: exner_milieu_loc
     USE parallel_lmdz
     USE control_mod
@@ -353,6 +355,5 @@
     REAL, ALLOCATABLE, SAVE, DIMENSION (:,:) :: f_addv ! var aux: champ de guidage
     ! Variables pour fonction Exner (P milieu couche)
-    REAL, ALLOCATABLE, SAVE, DIMENSION (:,:,:)    :: pk, pkf
-    REAL, ALLOCATABLE, SAVE, DIMENSION (:,:,:)    :: alpha, beta
+    REAL, ALLOCATABLE, SAVE, DIMENSION (:,:,:)    :: pk
     REAL, ALLOCATABLE, SAVE, DIMENSION (:,:)        :: pks    
     REAL                               :: unskap
@@ -367,4 +368,5 @@
     
     INTEGER       :: i,j,l
+    INTEGER,EXTERNAL :: OMP_GET_THREAD_NUM
        
 !$OMP MASTER    
@@ -382,5 +384,5 @@
 !$OMP BARRIER
       
-     PRINT *,'---> on rentre dans guide_main'
+!    PRINT *,'---> on rentre dans guide_main'
 !    CALL AllGather_Field(ucov,ip1jmp1,llm)
 !    CALL AllGather_Field(vcov,ip1jm,llm)
@@ -399,7 +401,4 @@
         ALLOCATE(f_addv(ijb_v:ije_v,llm) ) 
         ALLOCATE(pk(iip1,jjb_u:jje_u,llm)  ) 
-        ALLOCATE(pkf(iip1,jjb_u:jje_u,llm)  ) 
-        ALLOCATE(alpha(iip1,jjb_u:jje_u,llm)  ) 
-        ALLOCATE(beta(iip1,jjb_u:jje_u,llm)  ) 
         ALLOCATE(pks(iip1,jjb_u:jje_u)  ) 
         ALLOCATE(p(ijb_u:ije_u,llmp1) ) 
@@ -431,5 +430,5 @@
         IF (ini_anal) THEN
             CALL guide_interp(ps,teta)
-!$OMP DO            
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)            
             DO l=1,llm
               IF (guide_u) ucov(ijbu:ijeu,l)=ugui2(ijbu:ijeu,l)
@@ -449,13 +448,4 @@
             ENDIF
             RETURN
-        ENDIF
-! Verification structure guidage
-        IF (guide_u) THEN
-!+tard            CALL writefield_u('unat',unat1)
-!            CALL writefield_u('ucov',ucov)
-        ENDIF
-        IF (guide_T) THEN
-!+tard            CALL writefield_p('tnat',tnat1)
-!            CALL writefield_u('teta',teta)
         ENDIF
 
@@ -536,35 +526,47 @@
     f_out=((MOD(itau,iguide_sav).EQ.0).AND.guide_sav)  
     IF (f_out) THEN
-!       Calcul niveaux pression milieu de couches 
-	CALL pression_loc( ijnb_u, ap, bp, ps, p )
-	if (pressure_exner) then
-          CALL exner_hyb_loc(ip1jmp1,ps,p,alpha,beta,pks,pk,pkf)
-	else
-          CALL exner_milieu_loc(ip1jmp1,ps,p,beta,pks,pk,pkf)
-        endif
-!$OMP BARRIER        
+
+!$OMP BARRIER
+      CALL pression_loc(ijnb_u,ap,bp,ps,p)
+
+!$OMP BARRIER
+      if (pressure_exner) then
+      CALL exner_hyb_loc( ijnb_u, ps, p, pks, pk)
+      else
+        CALL exner_milieu_loc( ijnb_u, ps, p, pks, pk )
+      endif
+
+!$OMP BARRIER
+
         unskap=1./kappa
-!$OMP DO
-	DO l = 1, llm
-	    DO j=jjbu,jjeu
-		DO i =1, iip1
-		    p(i+(j-1)*iip1,l) = preff * ( pk(i,j,l)/cpp) ** unskap
-		ENDDO
-	    ENDDO
-	ENDDO
-!$OMP MASTER
-        CALL guide_out("P",jjp1,llm,p,1.)
-!$OMP END MASTER
-!$OMP BARRIER
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+        DO l = 1, llm
+            DO j=jjbu,jjeu
+                DO i =1, iip1
+                    p(i+(j-1)*iip1,l) = preff * ( pk(i,j,l)/cpp) ** unskap
+                ENDDO
+            ENDDO
+        ENDDO
+
+!!$OMP MASTER
+!     DO l=1,llm,5
+!         print*,'avant dump2d l=',l,mpi_rank,OMP_GET_THREAD_NUM()
+!         print*,'avant dump2d l=',l,mpi_rank
+!         CALL dump2d(iip1,jjnb_u,p(:,l),'ppp   ')
+!      ENDDO
+!!$OMP END MASTER
+!!$OMP BARRIER
+
+        CALL guide_out("SP",jjp1,llm,p(ijb_u:ije_u,1:llm),1.)
     ENDIF
     
     if (guide_u) then
         if (guide_add) then
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
           DO l=1,llm
            f_addu(ijbu:ijeu,l)=(1.-tau)*ugui1(ijbu:ijeu,l)+tau*ugui2(ijbu:ijeu,l)
           ENDDO
         else
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
           DO l=1,llm
            f_addu(ijbu:ijeu,l)=(1.-tau)*ugui1(ijbu:ijeu,l)+tau*ugui2(ijbu:ijeu,l)-ucov(ijbu:ijeu,l)
@@ -576,12 +578,9 @@
         if (guide_zon) CALL guide_zonave_u(1,llm,f_addu)
         CALL guide_addfield_u(llm,f_addu,alpha_u)
-!        CALL WriteField_u('f_addu',f_addu)
-!        CALL WriteField_u('alpha_u',alpha_u)
-!$OMP MASTER
-        IF (f_out) CALL guide_out("U",jjp1,llm,f_addu(:,:),factt)
-!$OMP END MASTER
-!$OMP BARRIER
-
-!$OMP DO
+!       IF (f_out) CALL guide_out("ua",jjp1,llm,ugui1(ijb_u:ije_u,:),factt)
+        IF (f_out) CALL guide_out("ua",jjp1,llm,(1.-tau)*ugui1(ijb_u:ije_u,:)+tau*ugui2(ijb_u:ije_u,:),factt)
+        IF (f_out) CALL guide_out("u",jjp1,llm,ucov(ijb_u:ije_u,:),factt)
+        IF (f_out) CALL guide_out("ucov",jjp1,llm,f_addu(ijb_u:ije_u,:),factt)
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
         DO l=1,llm
           ucov(ijbu:ijeu,l)=ucov(ijbu:ijeu,l)+f_addu(ijbu:ijeu,l)
@@ -592,10 +591,10 @@
     if (guide_T) then
         if (guide_add) then
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
           DO l=1,llm
             f_addu(ijbu:ijeu,l)=(1.-tau)*tgui1(ijbu:ijeu,l)+tau*tgui2(ijbu:ijeu,l)
           ENDDO
         else
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
           DO l=1,llm
            f_addu(ijbu:ijeu,l)=(1.-tau)*tgui1(ijbu:ijeu,l)+tau*tgui2(ijbu:ijeu,l)-teta(ijbu:ijeu,l)
@@ -604,9 +603,6 @@
         if (guide_zon) CALL guide_zonave_u(2,llm,f_addu)
         CALL guide_addfield_u(llm,f_addu,alpha_T)
-!$OMP MASTER
-        IF (f_out) CALL guide_out("T",jjp1,llm,f_addu(:,:),factt)
-!$OMP END MASTER
-!$OMP BARRIER
-!$OMP DO
+        IF (f_out) CALL guide_out("teta",jjp1,llm,f_addu(:,:)/factt,factt)
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
         DO l=1,llm
           teta(ijbu:ijeu,l)=teta(ijbu:ijeu,l)+f_addu(ijbu:ijeu,l)
@@ -628,8 +624,5 @@
         if (guide_zon) CALL guide_zonave_u(2,1,f_addu(ijb_u:ije_u,1))
         CALL guide_addfield_u(1,f_addu(ijb_u:ije_u,1),alpha_P)
-!$OMP MASTER
-        IF (f_out) CALL guide_out("SP",jjp1,1,f_addu(1:ip1jmp1,1),factt)
-!$OMP END MASTER
-!$OMP BARRIER
+!       IF (f_out) CALL guide_out("ps",jjp1,1,f_addu(ijb_u:ije_u,1)/factt,factt)
 !$OMP MASTER
         ps(ijbu:ijeu)=ps(ijbu:ijeu)+f_addu(ijbu:ijeu,1)
@@ -643,10 +636,10 @@
     if (guide_Q) then
         if (guide_add) then
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
           DO l=1,llm
             f_addu(ijbu:ijeu,l)=(1.-tau)*qgui1(ijbu:ijeu,l)+tau*qgui2(ijbu:ijeu,l)
           ENDDO
         else
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
           DO l=1,llm
             f_addu(ijbu:ijeu,l)=(1.-tau)*qgui1(ijbu:ijeu,l)+tau*qgui2(ijbu:ijeu,l)-q(ijbu:ijeu,l)
@@ -655,10 +648,7 @@
         if (guide_zon) CALL guide_zonave_u(2,llm,f_addu)
         CALL guide_addfield_u(llm,f_addu,alpha_Q)
-!$OMP MASTER
-        IF (f_out) CALL guide_out("Q",jjp1,llm,f_addu(:,:),factt)
-!$OMP END MASTER
-!$OMP BARRIER
-
-!$OMP DO
+        IF (f_out) CALL guide_out("q",jjp1,llm,f_addu(:,:)/factt,factt)
+
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
         DO l=1,llm
           q(ijbu:ijeu,l)=q(ijbu:ijeu,l)+f_addu(ijbu:ijeu,l)
@@ -668,5 +658,5 @@
     if (guide_v) then
         if (guide_add) then
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
           DO l=1,llm
              f_addv(ijbv:ijev,l)=(1.-tau)*vgui1(ijbv:ijev,l)+tau*vgui2(ijbv:ijev,l)
@@ -674,5 +664,5 @@
 
         else
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
           DO l=1,llm
             f_addv(ijbv:ijev,l)=(1.-tau)*vgui1(ijbv:ijev,l)+tau*vgui2(ijbv:ijev,l)-vcov(ijbv:ijev,l)
@@ -680,19 +670,13 @@
 
         endif 
-!        CALL WriteField_v('f_addv',f_addv)        
     
         if (guide_zon) CALL guide_zonave_v(2,jjm,llm,f_addv(ijb_v:ije_v,:))
-!        CALL WriteField_v('f_addv',f_addv)        
         
         CALL guide_addfield_v(llm,f_addv(ijb_v:ije_v,:),alpha_v)
-!        CALL WriteField_v('f_addv',f_addv)        
-!        CALL WriteField_v('alpha_v',alpha_v)        
-!$OMP MASTER
-        IF (f_out) CALL guide_out("V",jjm,llm,f_addv(1:ip1jm,:),factt)
-!$OMP END MASTER
-!$OMP BARRIER
-!        CALL WriteField_v('f_addv',f_addv)        
-
-!$OMP DO
+        IF (f_out) CALL guide_out("v",jjm,llm,vcov(ijb_v:ije_v,:),factt)
+        IF (f_out) CALL guide_out("va",jjm,llm,(1.-tau)*vgui1(ijb_v:ije_v,:)+tau*vgui2(ijb_v:ije_v,:),factt)
+        IF (f_out) CALL guide_out("vcov",jjm,llm,f_addv(:,:)/factt,factt)
+
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
         DO l=1,llm
           vcov(ijbv:ijev,l)=vcov(ijbv:ijev,l)+f_addv(ijbv:ijev,l)
@@ -700,9 +684,4 @@
     endif
 
-!    CALL WriteField_u('ucov_guide',ucov)
-!    CALL WriteField_v('vcov_guide',vcov)
-!    CALL WriteField_u('teta_guide',teta)
-!    CALL WriteField_u('masse_guide',masse)
-
   END SUBROUTINE guide_main
 
@@ -723,5 +702,5 @@
     INTEGER :: l
 
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     DO l=1,vsize
       field(ijbu:ijeu,l)=alpha(ijbu:ijeu)*field(ijbu:ijeu,l)*alpha_pcor(l)
@@ -746,5 +725,5 @@
     INTEGER :: l
 
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     DO l=1,vsize
       field(ijbv:ijev,l)=alpha(ijbv:ijev)*field(ijbv:ijev,l)*alpha_pcor(l)
@@ -799,5 +778,5 @@
 
     
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
       DO l=1,vsize
         fieldm(:,l)=0.
@@ -869,5 +848,5 @@
     ENDIF
 
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
       DO l=1,vsize
       ! Compute zonal average
@@ -894,4 +873,6 @@
 !=======================================================================
   SUBROUTINE guide_interp(psi,teta)
+    use exner_hyb_loc_m, only: exner_hyb_loc
+    use exner_milieu_loc_m, only: exner_milieu_loc
   USE parallel_lmdz
   USE mod_hallo
@@ -919,6 +900,5 @@
   REAL, ALLOCATABLE, SAVE,DIMENSION (:,:,:)     :: pbary 
   ! Variables pour fonction Exner (P milieu couche)
-  REAL, ALLOCATABLE, SAVE,DIMENSION (:,:,:)    :: pk, pkf
-  REAL, ALLOCATABLE, SAVE, DIMENSION (:,:,:)    :: alpha, beta
+  REAL, ALLOCATABLE, SAVE,DIMENSION (:,:,:)    :: pk
   REAL ,ALLOCATABLE, SAVE, DIMENSION (:,:)        :: pks    
   REAL                               :: unskap
@@ -949,7 +929,4 @@
       ALLOCATE(pbary(iip1,jjb_v:jje_v,llm) )    
       ALLOCATE(pk(iip1,jjb_u:jje_u,llm) )    
-      ALLOCATE(pkf(iip1,jjb_u:jje_u,llm)  )    
-      ALLOCATE(alpha(iip1,jjb_u:jje_u,llm) )    
-      ALLOCATE(beta(iip1,jjb_u:jje_u,llm) )    
       ALLOCATE(pks (iip1,jjb_u:jje_u) )    
       ALLOCATE(qsat(ijb_u:ije_u,llm) )    
@@ -1021,33 +998,33 @@
 !    ....  Calcul de pls , pression au milieu des couches ,en Pascals
     IF (guide_plevs.EQ.1) THEN
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
         DO l=1,llm
 	    DO j=jjbu,jjeu
 		DO i =1, iip1
                     pls(i,j,l)=(ap(l)+ap(l+1))/2.+psi(i,j)*(bp(l)+bp(l+1))/2.
-		ENDDO
-	    ENDDO
+                ENDDO
+            ENDDO
         ENDDO
     ELSE
-	CALL pression_loc( ijnb_u, ap, bp, psi, p )
-	if (disvert_type==1) then
-          CALL exner_hyb_loc(ijnb_u,psi,p,alpha,beta,pks,pk,pkf)
+        CALL pression_loc( ijnb_u, ap, bp, psi, p )
+        if (disvert_type==1) then
+          CALL exner_hyb_loc(ijnb_u,psi,p,pks,pk)
         else ! we assume that we are in the disvert_type==2 case
-          CALL exner_milieu_loc(ijnb_u,psi,p,beta,pks,pk,pkf)
+          CALL exner_milieu_loc(ijnb_u,psi,p,pks,pk)
         endif
-	unskap=1./kappa
-!$OMP BARRIER
-!$OMP DO
-	DO l = 1, llm
-	    DO j=jjbu,jjeu
-		DO i =1, iip1
-		    pls(i,j,l) = preff * ( pk(i,j,l)/cpp) ** unskap
-		ENDDO
-	    ENDDO
-	ENDDO
+        unskap=1./kappa
+!$OMP BARRIER
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+   DO l = 1, llm
+       DO j=jjbu,jjeu
+   	DO i =1, iip1
+   	    pls(i,j,l) = preff * ( pk(i,j,l)/cpp) ** unskap
+   	ENDDO
+       ENDDO
+   ENDDO
     ENDIF
 
 !   calcul des pressions pour les grilles u et v
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     do l=1,llm
         do j=jjbu,jjeu
@@ -1066,5 +1043,5 @@
     call massbar_loc(pext, pbarx, pbary )
 !$OMP BARRIER
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     do l=1,llm
         do j=jjbu,jjeu
@@ -1075,5 +1052,5 @@
         enddo
     enddo
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     do l=1,llm
         do j=jjbv,jjev
@@ -1136,5 +1113,5 @@
 !$OMP BARRIER
         ! Conversion en variables GCM
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
         do l=1,llm
             do j=jjbu,jjeu
@@ -1206,5 +1183,5 @@
         ! On suppose qu'on a la bonne variable dans le fichier de guidage:
         ! Hum.Rel si guide_hr, Hum.Spec. sinon.
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
         do l=1,llm
             do j=jjbu,jjeu
@@ -1231,5 +1208,5 @@
         enddo
         IF (guide_hr) THEN
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
           do l=1,llm
             CALL q_sat(iip1*jjnu,teta(:,jjbu:jjeu,l)*pk(:,jjbu:jjeu,l)/cpp,       &
@@ -1284,5 +1261,5 @@
 
         ! Conversion en variables GCM
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
         do l=1,llm
             do j=jjbu,jjeu
@@ -1359,5 +1336,5 @@
 !$OMP BARRIER
         ! Conversion en variables GCM
-!$OMP DO
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
         do l=1,llm
             do j=jjbv,jjev
@@ -1755,4 +1732,5 @@
      endif
 
+
 !  Temperature
      if (guide_T) then
@@ -1908,4 +1886,5 @@
              if (ncidpl.eq.-99) ncidpl=ncidu
          endif
+
 ! Vent meridien
          if (guide_v) then
@@ -2045,4 +2024,5 @@
      endif
 
+
 !  Temperature
      if (guide_T) then
@@ -2096,4 +2076,5 @@
 
          IF (invert_y) THEN
+ 
 !           PRINT*,"Invertion impossible actuellement"
 !           CALL abort_gcm(modname,abort_message,1)
@@ -2130,6 +2111,7 @@
   
 !=======================================================================
-  SUBROUTINE guide_out(varname,hsize,vsize,field,factt)
+  SUBROUTINE guide_out(varname,hsize,vsize,field_loc,factt)
     USE parallel_lmdz
+    USE mod_hallo, ONLY : gather_field_u, gather_field_v
     IMPLICIT NONE
 
@@ -2142,8 +2124,9 @@
     
     ! Variables entree
-    CHARACTER, INTENT(IN)                          :: varname
+    CHARACTER*(*), INTENT(IN)                      :: varname
     INTEGER,   INTENT (IN)                         :: hsize,vsize
-    REAL, DIMENSION (iip1,hsize,vsize), INTENT(IN) :: field
-    REAL, INTENT (IN)                              :: factt
+!   REAL, DIMENSION (iip1,hsize,vsize), INTENT(IN) :: field_loc
+    REAL, DIMENSION (:,:), INTENT(IN) :: field_loc
+    REAL factt
 
     ! Variables locales
@@ -2152,13 +2135,38 @@
     INTEGER       :: nid, id_lonu, id_lonv, id_latu, id_latv, id_tim, id_lev
     INTEGER       :: vid_lonu,vid_lonv,vid_latu,vid_latv,vid_cu,vid_cv,vid_lev
+    INTEGER       :: vid_au,vid_av
     INTEGER, DIMENSION (3) :: dim3
     INTEGER, DIMENSION (4) :: dim4,count,start
-    INTEGER                :: ierr, varid
-    
-    CALL gather_field(field,iip1*hsize,vsize,0)
-    
-    IF (mpi_rank /= 0) RETURN
-    
-    print *,'Guide: output timestep',timestep,'var ',varname
+    INTEGER                :: ierr, varid,l
+    REAL zu(ip1jmp1),zv(ip1jm)
+    REAL, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: field_glo
+    
+!$OMP MASTER
+    ALLOCATE(field_glo(iip1,hsize,vsize))
+!$OMP END MASTER
+!$OMP BARRIER
+
+    print*,'gvide_out apres allocation ',hsize,vsize
+
+    IF (hsize==jjp1) THEN
+        CALL gather_field_u(field_loc,field_glo,vsize)
+    ELSE IF (hsize==jjm) THEN
+       CALL gather_field_v(field_loc,field_glo, vsize)
+    ENDIF
+
+    print*,'guide_out apres gather '
+    CALL Gather_field_u(alpha_u,zu,1)
+    CALL Gather_field_v(alpha_v,zv,1)
+
+    IF (mpi_rank >  0) THEN
+!$OMP MASTER
+       DEALLOCATE(field_glo)
+!$OMP END MASTER
+!$OMP BARRIER
+
+       RETURN
+    ENDIF
+    
+!$OMP MASTER
     IF (timestep.EQ.0) THEN 
 ! ----------------------------------------------
@@ -2183,5 +2191,7 @@
         ierr=NF_DEF_VAR(nid,"cu",NF_FLOAT,2,(/id_lonu,id_latu/),vid_cu)
         ierr=NF_DEF_VAR(nid,"cv",NF_FLOAT,2,(/id_lonv,id_latv/),vid_cv)
-        
+        ierr=NF_DEF_VAR(nid,"au",NF_FLOAT,2,(/id_lonu,id_latu/),vid_au)
+        ierr=NF_DEF_VAR(nid,"av",NF_FLOAT,2,(/id_lonv,id_latv/),vid_av)
+
         ierr=NF_ENDDEF(nid)
 
@@ -2195,4 +2205,6 @@
         ierr = NF_PUT_VAR_DOUBLE(nid,vid_cu,cu)
         ierr = NF_PUT_VAR_DOUBLE(nid,vid_cv,cv)
+        ierr = NF_PUT_VAR_DOUBLE(nid,vid_au,zu)
+        ierr = NF_PUT_VAR_DOUBLE(nid,vid_av,zv)
 #else
         ierr = NF_PUT_VAR_REAL(nid,vid_lonu,rlonu*180./pi)
@@ -2203,4 +2215,6 @@
         ierr = NF_PUT_VAR_REAL(nid,vid_cu,cu)
         ierr = NF_PUT_VAR_REAL(nid,vid_cv,cv)
+        ierr = NF_PUT_VAR_REAL(nid,vid_au,alpha_u)
+        ierr = NF_PUT_VAR_REAL(nid,vid_av,alpha_v)
 #endif
 ! --------------------------------------------------------------------
@@ -2210,5 +2224,5 @@
 ! Pressure (GCM)
         dim4=(/id_lonv,id_latu,id_lev,id_tim/)
-        ierr = NF_DEF_VAR(nid,"P",NF_FLOAT,4,dim4,varid)
+        ierr = NF_DEF_VAR(nid,"SP",NF_FLOAT,4,dim4,varid)
 ! Surface pressure (guidage)
         IF (guide_P) THEN
@@ -2219,4 +2233,6 @@
         IF (guide_u) THEN
             dim4=(/id_lonu,id_latu,id_lev,id_tim/)
+            ierr = NF_DEF_VAR(nid,"u",NF_FLOAT,4,dim4,varid)
+            ierr = NF_DEF_VAR(nid,"ua",NF_FLOAT,4,dim4,varid)
             ierr = NF_DEF_VAR(nid,"ucov",NF_FLOAT,4,dim4,varid)
         ENDIF
@@ -2224,4 +2240,6 @@
         IF (guide_v) THEN
             dim4=(/id_lonv,id_latv,id_lev,id_tim/)
+            ierr = NF_DEF_VAR(nid,"v",NF_FLOAT,4,dim4,varid)
+            ierr = NF_DEF_VAR(nid,"va",NF_FLOAT,4,dim4,varid)
             ierr = NF_DEF_VAR(nid,"vcov",NF_FLOAT,4,dim4,varid)
         ENDIF
@@ -2247,63 +2265,57 @@
     ierr=NF_OPEN("guide_ins.nc",NF_WRITE,nid)
 
+    IF (varname=="SP") timestep=timestep+1
+
+    ierr = NF_INQ_VARID(nid,varname,varid)
     SELECT CASE (varname)
-    CASE ("P")
-        timestep=timestep+1
-        ierr = NF_INQ_VARID(nid,"P",varid)
+    CASE ("SP","ps")
         start=(/1,1,1,timestep/)
         count=(/iip1,jjp1,llm,1/)
-#ifdef NC_DOUBLE
-        ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,count,field)
-#else
-        ierr = NF_PUT_VARA_REAL(nid,varid,start,count,field)
-#endif
-    CASE ("SP")
-        ierr = NF_INQ_VARID(nid,"ps",varid)
-        start=(/1,1,timestep,0/)
-        count=(/iip1,jjp1,1,0/)
-#ifdef NC_DOUBLE
-        ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,count,field/factt)
-#else
-        ierr = NF_PUT_VARA_REAL(nid,varid,start,count,field/factt)
-#endif
-    CASE ("U")
-        ierr = NF_INQ_VARID(nid,"ucov",varid)
+    CASE ("v","va","vcov")
+        start=(/1,1,1,timestep/)
+        count=(/iip1,jjm,llm,1/)
+    CASE DEFAULT
         start=(/1,1,1,timestep/)
         count=(/iip1,jjp1,llm,1/)
+    END SELECT
+
+!$OMP END MASTER
+!$OMP BARRIER
+
+    SELECT CASE (varname)
+
+    CASE("u","ua")
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+        DO l=1,llm 
+            field_glo(:,2:jjm,l)=field_glo(:,2:jjm,l)/cu(:,2:jjm)
+            field_glo(:,1,l)=0. ; field_glo(:,jjp1,l)=0.
+        ENDDO
+    CASE("v","va")
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+        DO l=1,llm
+           field_glo(:,:,l)=field_glo(:,:,l)/cv(:,:)
+        ENDDO
+    END SELECT
+
+!    if (varname=="ua") then
+!    call dump2d(iip1,jjp1,field_glo,'ua gui1 1ere couche ')
+!    call dump2d(iip1,jjp1,field_glo(:,:,llm),'ua gui1 llm ')
+!    endif
+
+!$OMP MASTER
+
 #ifdef NC_DOUBLE
-        ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,count,field/factt)
+    ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,count,field_glo)
 #else
-        ierr = NF_PUT_VARA_REAL(nid,varid,start,count,field/factt)
+    ierr = NF_PUT_VARA_REAL(nid,varid,start,count,field_glo)
 #endif
-    CASE ("V")
-        ierr = NF_INQ_VARID(nid,"vcov",varid)
-        start=(/1,1,1,timestep/)
-        count=(/iip1,jjm,llm,1/)
-#ifdef NC_DOUBLE
-        ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,count,field/factt)
-#else
-        ierr = NF_PUT_VARA_REAL(nid,varid,start,count,field/factt)
-#endif
-    CASE ("T")
-        ierr = NF_INQ_VARID(nid,"teta",varid)
-        start=(/1,1,1,timestep/)
-        count=(/iip1,jjp1,llm,1/)
-#ifdef NC_DOUBLE
-        ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,count,field/factt)
-#else
-        ierr = NF_PUT_VARA_REAL(nid,varid,start,count,field/factt)
-#endif
-    CASE ("Q")
-        ierr = NF_INQ_VARID(nid,"q",varid)
-        start=(/1,1,1,timestep/)
-        count=(/iip1,jjp1,llm,1/)
-#ifdef NC_DOUBLE
-        ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,count,field/factt)
-#else
-        ierr = NF_PUT_VARA_REAL(nid,varid,start,count,field/factt)
-#endif
-    END SELECT
- 
+
     ierr = NF_CLOSE(nid)
+
+       DEALLOCATE(field_glo)
+!$OMP END MASTER
+!$OMP BARRIER
+
+    RETURN
 
   END SUBROUTINE guide_out
@@ -2329,4 +2341,53 @@
   end subroutine correctbid
 
+
+!====================================================================
+! Ascii debug output. Could be reactivated
+!====================================================================
+
+subroutine dump2du(var,varname)
+use parallel_lmdz
+use mod_hallo
+implicit none
+include 'dimensions.h'
+include 'paramet.h'
+
+      CHARACTER (len=*) :: varname
+
+
+real, dimension(ijb_u:ije_u) :: var
+
+real, dimension(ip1jmp1) :: var_glob
+
+    RETURN
+
+    call barrier
+    CALL Gather_field_u(var,var_glob,1)
+    call barrier
+
+    if (mpi_rank==0) then
+       call dump2d(iip1,jjp1,var_glob,varname)
+    endif
+
+    call barrier
+
+    return
+    end subroutine dump2du
+
+!====================================================================
+! Ascii debug output. Could be reactivated
+!====================================================================
+subroutine dumpall
+     implicit none
+     include "dimensions.h"
+     include "paramet.h"
+     include "comgeom.h"
+     call barrier
+     call dump2du(alpha_u(ijb_u:ije_u),'  alpha_u couche 1')
+     call dump2du(unat2(:,jjbu:jjeu,nlevnc),'  unat2 couche nlevnc')
+     call dump2du(ugui1(ijb_u:ije_u,1)*sqrt(unscu2(ijb_u:ije_u)),'  ugui1 couche 1')
+     return
+end subroutine dumpall
+
 !===========================================================================
 END MODULE guide_loc_mod
Index: /LMDZ5/branches/testing/libf/dyn3dmem/iniacademic_loc.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dmem/iniacademic_loc.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3dmem/iniacademic_loc.F90	(revision 2056)
@@ -4,4 +4,6 @@
 SUBROUTINE iniacademic_loc(vcov,ucov,teta,q,masse,ps,phis,time_0)
 
+  use exner_hyb_m, only: exner_hyb
+  use exner_milieu_m, only: exner_milieu
   USE filtreg_mod
   USE infotrac, ONLY : nqtot
@@ -58,5 +60,4 @@
   REAL pks(ip1jmp1)                      ! exner au  sol
   REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
-  REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
   REAL phi(ip1jmp1,llm)                  ! geopotentiel
   REAL ddsin,zsig,tetapv,w_pv  ! variables auxiliaires
@@ -75,5 +76,4 @@
 
   REAL zdtvr
-  real,allocatable :: alpha(:,:),beta(:,:)
   
   character(len=*),parameter :: modname="iniacademic"
@@ -219,6 +219,4 @@
        allocate(masse_glo(ip1jmp1,llm))
        allocate(phis_glo(ip1jmp1))
-       allocate(alpha(ip1jmp1,llm))
-       allocate(beta(ip1jmp1,llm))
 
         ! surface pressure
@@ -238,7 +236,7 @@
         CALL pression ( ip1jmp1, ap, bp, ps_glo, p       )
         if (pressure_exner) then
-          CALL exner_hyb( ip1jmp1, ps_glo, p,alpha,beta, pks, pk, pkf )
+          CALL exner_hyb( ip1jmp1, ps_glo, p, pks, pk )
         else
-          call exner_milieu(ip1jmp1,ps_glo,p,beta,pks,pk,pkf)
+          call exner_milieu(ip1jmp1,ps_glo,p,pks,pk)
         endif
         CALL massdair(p,masse_glo)
@@ -301,6 +299,4 @@
         deallocate(ps_glo)
         deallocate(phis_glo)
-        deallocate(alpha)
-        deallocate(beta)
      ENDIF ! of IF (.NOT. read_start)
   endif academic_case
Index: /LMDZ5/branches/testing/libf/dyn3dmem/leapfrog_loc.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dmem/leapfrog_loc.F	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3dmem/leapfrog_loc.F	(revision 2056)
@@ -31,4 +31,6 @@
        USE call_calfis_mod, ONLY : call_calfis
        USE leapfrog_mod
+       use exner_hyb_loc_m, only: exner_hyb_loc
+       use exner_milieu_loc_m, only: exner_milieu_loc
       IMPLICIT NONE
 
@@ -156,5 +158,4 @@
       character*10 string10
 
-!      REAL,SAVE,ALLOCATABLE :: alpha(:,:),beta(:,:)
 !      REAL,SAVE,ALLOCATABLE :: flxw(:,:) ! flux de masse verticale
 
@@ -213,5 +214,10 @@
       lafin=.false.
       
-      itaufin   = nday*day_step
+      if (nday>=0) then
+         itaufin   = nday*day_step
+      else
+         itaufin   = -nday
+      endif
+
       itaufinp1 = itaufin +1
 
@@ -261,5 +267,4 @@
 !      ALLOCATE(dqfi_tmp(iip1,llm,nqtot))
 !      ALLOCATE(finvmaold(ijb_u:ije_u,llm))
-!      ALLOCATE(alpha(ijb_u:ije_u,llm),beta(ijb_u:ije_u,llm))
 !      ALLOCATE(flxw(ijb_u:ije_u,llm))
 !      ALLOCATE(ecin(ijb_u:ije_u,llm),ecin0(ijb_u:ije_u,llm))
@@ -284,7 +289,7 @@
 c$OMP END MASTER
       if (pressure_exner) then
-      CALL exner_hyb_loc( ijnb_u, ps, p,alpha,beta, pks, pk, pkf)
+      CALL exner_hyb_loc( ijnb_u, ps, p, pks, pk, pkf)
       else 
-        CALL exner_milieu_loc( ijnb_u, ps, p, beta, pks, pk, pkf )
+        CALL exner_milieu_loc( ijnb_u, ps, p, pks, pk, pkf )
       endif
 c-----------------------------------------------------------------------
@@ -780,5 +785,5 @@
 
 ! c$OMP BARRIER
-!          CALL exner_hyb_loc(  ip1jmp1, ps, p,alpha,beta,pks, pk, pkf )
+!          CALL exner_hyb_loc(  ip1jmp1, ps, p,pks, pk, pkf )
 ! c$OMP BARRIER
 !            jD_cur = jD_ref + day_ini - day_ref
@@ -1135,7 +1140,7 @@
 c$OMP BARRIER
         if (pressure_exner) then
-        CALL exner_hyb_loc( ijnb_u, ps, p,alpha,beta, pks, pk, pkf )
+        CALL exner_hyb_loc( ijnb_u, ps, p, pks, pk, pkf )
         else 
-          CALL exner_milieu_loc( ijnb_u, ps, p, beta, pks, pk, pkf )
+          CALL exner_milieu_loc( ijnb_u, ps, p, pks, pk, pkf )
         endif
 c$OMP BARRIER
Index: /LMDZ5/branches/testing/libf/dyn3dmem/leapfrog_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dmem/leapfrog_mod.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3dmem/leapfrog_mod.F90	(revision 2056)
@@ -27,6 +27,4 @@
   REAL,POINTER,SAVE :: dq(:,:,:)
   REAL,POINTER,SAVE :: finvmaold(:,:)
-  REAL,POINTER,SAVE :: alpha(:,:)
-  REAL,POINTER,SAVE :: beta(:,:)
   REAL,POINTER,SAVE :: flxw(:,:)
   REAL,POINTER,SAVE :: unat(:,:)
@@ -79,6 +77,4 @@
     CALL allocate_u(dq,llm,nqtot,d)
     CALL allocate_u(finvmaold,llm,d)
-    CALL allocate_u(alpha,llm,d)
-    CALL allocate_u(beta,llm,d)
     CALL allocate_u(flxw,llm,d)
     CALL allocate_u(unat,llm,d)
@@ -129,6 +125,4 @@
     CALL switch_u(dq,distrib_caldyn,dist)
     CALL switch_u(finvmaold,distrib_caldyn,dist)
-    CALL switch_u(alpha,distrib_caldyn,dist)
-    CALL switch_u(beta,distrib_caldyn,dist)
     CALL switch_u(flxw,distrib_caldyn,dist)
     CALL switch_u(unat,distrib_caldyn,dist)
Index: /LMDZ5/branches/testing/libf/dyn3dmem/mod_const_mpi.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dmem/mod_const_mpi.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3dmem/mod_const_mpi.F90	(revision 2056)
@@ -21,4 +21,7 @@
     USE mod_prism
 #endif
+#ifdef CPP_XIOS
+    USE wxios, only: wxios_init
+#endif
     IMPLICIT NONE
 #ifdef CPP_MPI
@@ -41,6 +44,10 @@
 #ifdef CPP_COUPLE
 !$OMP MASTER
-       CALL prism_init_comp_proto (comp_id, 'lmdz.x', ierr)
+#ifdef CPP_XIOS
+      CALL wxios_init("LMDZ", outcom=COMM_LMDZ, type_ocean=type_ocean)
+#else
+       CALL prism_init_comp_proto (comp_id, 'LMDZ', ierr)
        CALL prism_get_localcomm_proto(COMM_LMDZ,ierr)
+#endif
 !$OMP END MASTER
 #endif
Index: /LMDZ5/branches/testing/libf/dyn3dmem/parallel_lmdz.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dmem/parallel_lmdz.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3dmem/parallel_lmdz.F90	(revision 2056)
@@ -422,4 +422,8 @@
 
       if (type_ocean == 'couple') then
+#ifdef CPP_XIOS
+    !Fermeture propre de XIOS
+      CALL wxios_close()
+#else
 #ifdef CPP_COUPLE
          call prism_terminate_proto(ierr)
@@ -428,4 +432,5 @@
          endif
 #endif 
+#endif
       else
 #ifdef CPP_XIOS
Index: /LMDZ5/branches/testing/libf/dyn3dpar/calfis_p.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dpar/calfis_p.F	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3dpar/calfis_p.F	(revision 2056)
@@ -217,9 +217,4 @@
       REAL unskap, pksurcp
 c
-cIM diagnostique PVteta, Amip2
-      INTEGER,PARAMETER :: ntetaSTD=3
-      REAL,SAVE :: rtetaSTD(ntetaSTD)=(/350.,380.,405./) ! Earth-specific, beware !!
-      REAL PVteta(klon,ntetaSTD)
-      
       REAL SSUM
 
@@ -249,6 +244,4 @@
       klon=klon_mpi
       
-      PVteta(:,:)=0.
-            
 c
       IF ( firstcal )  THEN
@@ -484,16 +477,4 @@
       endif
 
-
-      IF (is_sequential.and.(planet_type=="earth")) THEN
-#ifdef CPP_PHYS
-! PVtheta calls tetalevel, which is in the physics
-cIM calcul PV a teta=350, 380, 405K
-        CALL PVtheta(ngridmx,llm,pucov,pvcov,pteta,
-     $           ztfi,zplay,zplev,
-     $           ntetaSTD,rtetaSTD,PVteta)
-c
-#endif
-      ENDIF
-
 c On change de grille, dynamique vers physiq, pour le flux de masse verticale
       CALL gr_dyn_fi_p(llm,iip1,jjp1,klon,flxw,flxwfi)
@@ -668,7 +649,5 @@
      .             zdqfi_omp,
      .             zdpsrf_omp,
-cIM diagnostique PVteta, Amip2          
-     .             pducov,
-     .             PVteta)
+     .             pducov)
 
       else if ( planet_type=="generic" ) then
Index: DZ5/branches/testing/libf/dyn3dpar/exner_hyb_p.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dpar/exner_hyb_p.F	(revision 2055)
+++ 	(revision )
@@ -1,231 +1,0 @@
-!
-! $Id $
-!
-      SUBROUTINE  exner_hyb_p ( ngrid, ps, p,alpha,beta, pks, pk, pkf )
-c
-c     Auteurs :  P.Le Van  , Fr. Hourdin  .
-c    ..........
-c
-c    ....  ngrid, ps,p             sont des argum.d'entree  au sous-prog ...
-c    .... alpha,beta, pks,pk,pkf   sont des argum.de sortie au sous-prog ...
-c
-c   ************************************************************************
-c    Calcule la fonction d'Exner pk = Cp * p ** kappa , aux milieux des 
-c    couches .   Pk(l) sera calcule aux milieux  des couches l ,entre les
-c    pressions p(l) et p(l+1) ,definis aux interfaces des llm couches .
-c   ************************************************************************
-c  .. N.B : Au sommet de l'atmosphere,  p(llm+1) = 0. , et ps et pks sont
-c    la pression et la fonction d'Exner  au  sol  .
-c
-c                                 -------- z                                   
-c    A partir des relations  ( 1 ) p*dz(pk) = kappa *pk*dz(p)      et
-c                            ( 2 ) pk(l) = alpha(l)+ beta(l)*pk(l-1)
-c    ( voir note de Fr.Hourdin )  ,
-c
-c    on determine successivement , du haut vers le bas des couches, les 
-c    coef. alpha(llm),beta(llm) .,.,alpha(l),beta(l),,,alpha(2),beta(2), 
-c    puis pk(ij,1). Ensuite ,on calcule,du bas vers le haut des couches,  
-c     pk(ij,l)  donne  par la relation (2),  pour l = 2 a l = llm .
-c
-c
-      USE parallel_lmdz
-      IMPLICIT NONE
-c
-#include "dimensions.h"
-#include "paramet.h"
-#include "comconst.h"
-#include "comgeom.h"
-#include "comvert.h"
-#include "serre.h"
-
-      INTEGER  ngrid
-      REAL p(ngrid,llmp1),pk(ngrid,llm),pkf(ngrid,llm)
-      REAL ps(ngrid),pks(ngrid), alpha(ngrid,llm),beta(ngrid,llm)
-
-c    .... variables locales   ...
-
-      INTEGER l, ij
-      REAL unpl2k,dellta
-
-      REAL ppn(iim),pps(iim)
-      REAL xpn, xps
-      REAL SSUM
-      EXTERNAL SSUM
-      INTEGER ije,ijb,jje,jjb
-      logical,save :: firstcall=.true.
-!$OMP THREADPRIVATE(firstcall) 
-      character(len=*),parameter :: modname="exner_hyb_p"
-c
-
-      ! Sanity check
-      if (firstcall) then
-        ! sanity checks for Shallow Water case (1 vertical layer)
-        if (llm.eq.1) then
-          if (kappa.ne.1) then
-            call abort_gcm(modname,
-     &      "kappa!=1 , but running in Shallow Water mode!!",42)
-          endif
-          if (cpp.ne.r) then
-            call abort_gcm(modname,
-     &      "cpp!=r , but running in Shallow Water mode!!",42)
-          endif
-        endif ! of if (llm.eq.1)
-
-        firstcall=.false.
-      endif ! of if (firstcall)
-
-c$OMP BARRIER
-
-! Specific behaviour for Shallow Water (1 vertical layer) case
-      if (llm.eq.1) then
-      
-        ! Compute pks(:),pk(:),pkf(:)
-        ijb=ij_begin
-        ije=ij_end
-!$OMP DO SCHEDULE(STATIC)
-        DO ij=ijb, ije
-          pks(ij)=(cpp/preff)*ps(ij)
-          pk(ij,1) = .5*pks(ij)
-          pkf(ij,1)=pk(ij,1)
-        ENDDO
-!$OMP ENDDO
-
-!$OMP MASTER
-      if (pole_nord) then
-        DO  ij   = 1, iim
-          ppn(ij) = aire(   ij   ) * pks(  ij     )
-        ENDDO
-        xpn      = SSUM(iim,ppn,1) /apoln
-  
-        DO ij   = 1, iip1
-          pks(   ij     )  =  xpn
-          pk(ij,1) = .5*pks(ij)
-          pkf(ij,1)=pk(ij,1)
-        ENDDO
-      endif
-      
-      if (pole_sud) then
-        DO  ij   = 1, iim
-          pps(ij) = aire(ij+ip1jm) * pks(ij+ip1jm )
-        ENDDO
-        xps      = SSUM(iim,pps,1) /apols 
-  
-        DO ij   = 1, iip1
-          pks( ij+ip1jm )  =  xps
-          pk(ij+ip1jm,1)=.5*pks(ij+ip1jm)
-          pkf(ij+ip1jm,1)=pk(ij+ip1jm,1)
-        ENDDO
-      endif
-!$OMP END MASTER
-!$OMP BARRIER
-        jjb=jj_begin
-        jje=jj_end
-        CALL filtreg_p ( pkf,jjb,jje, jmp1, llm, 2, 1, .TRUE., 1 )
-
-        ! our work is done, exit routine
-        return
-      endif ! of if (llm.eq.1)
-
-!!!! General case:
-
-      unpl2k    = 1.+ 2.* kappa
-c
-      ijb=ij_begin
-      ije=ij_end
-
-c$OMP DO SCHEDULE(STATIC)
-      DO   ij  = ijb, ije
-        pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
-      ENDDO
-c$OMP ENDDO
-c Synchro OPENMP ici
-
-c$OMP MASTER
-      if (pole_nord) then
-        DO  ij   = 1, iim
-          ppn(ij) = aire(   ij   ) * pks(  ij     )
-        ENDDO
-        xpn      = SSUM(iim,ppn,1) /apoln
-  
-        DO ij   = 1, iip1
-          pks(   ij     )  =  xpn
-        ENDDO
-      endif
-      
-      if (pole_sud) then
-        DO  ij   = 1, iim
-          pps(ij) = aire(ij+ip1jm) * pks(ij+ip1jm )
-        ENDDO
-        xps      = SSUM(iim,pps,1) /apols 
-  
-        DO ij   = 1, iip1
-          pks( ij+ip1jm )  =  xps
-        ENDDO
-      endif
-c$OMP END MASTER
-c$OMP BARRIER
-c
-c
-c    .... Calcul des coeff. alpha et beta  pour la couche l = llm ..
-c
-c$OMP DO SCHEDULE(STATIC)
-      DO     ij      = ijb,ije
-       alpha(ij,llm) = 0.
-       beta (ij,llm) = 1./ unpl2k
-      ENDDO
-c$OMP ENDDO NOWAIT
-c
-c     ... Calcul des coeff. alpha et beta  pour l = llm-1  a l = 2 ...
-c
-      DO l = llm -1 , 2 , -1
-c
-c$OMP DO SCHEDULE(STATIC)
-        DO ij = ijb, ije
-        dellta = p(ij,l)* unpl2k + p(ij,l+1)* ( beta(ij,l+1)-unpl2k )
-        alpha(ij,l)  = - p(ij,l+1) / dellta * alpha(ij,l+1)
-        beta (ij,l)  =   p(ij,l  ) / dellta   
-        ENDDO
-c$OMP ENDDO NOWAIT
-c
-      ENDDO
-
-c
-c  ***********************************************************************
-c     .....  Calcul de pk pour la couche 1 , pres du sol  ....
-c
-c$OMP DO SCHEDULE(STATIC)
-      DO   ij   = ijb, ije
-       pk(ij,1) = ( p(ij,1)*pks(ij) - 0.5*alpha(ij,2)*p(ij,2) )  /
-     *    (  p(ij,1)* (1.+kappa) + 0.5*( beta(ij,2)-unpl2k )* p(ij,2) )
-      ENDDO
-c$OMP ENDDO NOWAIT
-c
-c    ..... Calcul de pk(ij,l) , pour l = 2 a l = llm  ........
-c
-      DO l = 2, llm
-c$OMP DO SCHEDULE(STATIC)
-        DO   ij   = ijb, ije
-         pk(ij,l) = alpha(ij,l) + beta(ij,l) * pk(ij,l-1)
-        ENDDO
-c$OMP ENDDO NOWAIT        
-      ENDDO
-c
-c
-c      CALL SCOPY   ( ngrid * llm, pk, 1, pkf, 1 )
-      DO l = 1, llm
-c$OMP DO SCHEDULE(STATIC)
-         DO   ij   = ijb, ije
-           pkf(ij,l)=pk(ij,l)
-         ENDDO
-c$OMP ENDDO NOWAIT             
-      ENDDO
-
-c$OMP BARRIER
-      
-      jjb=jj_begin
-      jje=jj_end
-      CALL filtreg_p ( pkf,jjb,jje, jmp1, llm, 2, 1, .TRUE., 1 )
-      
-
-      RETURN
-      END
Index: /LMDZ5/branches/testing/libf/dyn3dpar/exner_hyb_p_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dpar/exner_hyb_p_m.F90	(revision 2056)
+++ /LMDZ5/branches/testing/libf/dyn3dpar/exner_hyb_p_m.F90	(revision 2056)
@@ -0,0 +1,186 @@
+module exner_hyb_p_m
+
+  IMPLICIT NONE
+
+contains
+
+  SUBROUTINE  exner_hyb_p ( ngrid, ps, p, pks, pk, pkf )
+
+    !     Auteurs :  P.Le Van  , Fr. Hourdin  .
+    !    ..........
+    !
+    !    ....  ngrid, ps,p             sont des argum.d'entree  au sous-prog ...
+    !    ....  pks,pk,pkf   sont des argum.de sortie au sous-prog ...
+    !
+    !   ************************************************************************
+    !    Calcule la fonction d'Exner pk = Cp * (p/preff) ** kappa , aux milieux des 
+    !    couches .   Pk(l) sera calcule aux milieux  des couches l ,entre les
+    !    pressions p(l) et p(l+1) ,definis aux interfaces des llm couches .
+    !   ************************************************************************
+    !  .. N.B : Au sommet de l'atmosphere,  p(llm+1) = 0. , et ps et pks sont
+    !    la pression et la fonction d'Exner  au  sol  .
+    !
+    !                                 -------- z
+    !    A partir des relations  ( 1 ) p*dz(pk) = kappa *pk*dz(p)      et
+    !                            ( 2 ) pk(l) = alpha(l)+ beta(l)*pk(l-1)
+    !    ( voir note de Fr.Hourdin )  ,
+    !
+    !    on determine successivement , du haut vers le bas des couches, les 
+    !    coef. alpha(llm),beta(llm) .,.,alpha(l),beta(l),,,alpha(2),beta(2), 
+    !    puis pk(ij,1). Ensuite ,on calcule,du bas vers le haut des couches,  
+    !     pk(ij,l)  donne  par la relation (2),  pour l = 2 a l = llm .
+    !
+    !
+    USE parallel_lmdz
+    !
+    include "dimensions.h"
+    include "paramet.h"
+    include "comconst.h"
+    include "comgeom.h"
+    include "comvert.h"
+    include "serre.h"
+
+    INTEGER  ngrid
+    REAL p(ngrid,llmp1),pk(ngrid,llm)
+    REAL, optional:: pkf(ngrid,llm)
+    REAL ps(ngrid),pks(ngrid)
+    REAL alpha(ngrid,llm),beta(ngrid,llm)
+
+    !    .... variables locales   ...
+
+    INTEGER l, ij
+    REAL unpl2k,dellta
+
+    INTEGER ije,ijb,jje,jjb
+    logical,save :: firstcall=.true.
+    !$OMP THREADPRIVATE(firstcall) 
+    character(len=*),parameter :: modname="exner_hyb_p"
+
+    ! Sanity check
+    if (firstcall) then
+       ! sanity checks for Shallow Water case (1 vertical layer)
+       if (llm.eq.1) then
+          if (kappa.ne.1) then
+             call abort_gcm(modname, &
+                  "kappa!=1 , but running in Shallow Water mode!!",42)
+          endif
+          if (cpp.ne.r) then
+             call abort_gcm(modname, &
+                  "cpp!=r , but running in Shallow Water mode!!",42)
+          endif
+       endif ! of if (llm.eq.1)
+
+       firstcall=.false.
+    endif ! of if (firstcall)
+
+    !$OMP BARRIER
+
+    ! Specific behaviour for Shallow Water (1 vertical layer) case:
+    if (llm.eq.1) then
+
+       ! Compute pks(:),pk(:),pkf(:)
+       ijb=ij_begin
+       ije=ij_end
+       !$OMP DO SCHEDULE(STATIC)
+       DO ij=ijb, ije
+          pks(ij) = (cpp/preff) * ps(ij)
+          pk(ij,1) = .5*pks(ij)
+          if (present(pkf)) pkf(ij,1)=pk(ij,1)
+       ENDDO
+       !$OMP ENDDO
+
+       !$OMP BARRIER
+       if (present(pkf)) then
+          jjb=jj_begin
+          jje=jj_end
+          CALL filtreg_p ( pkf,jjb,jje, jmp1, llm, 2, 1, .TRUE., 1 )
+       end if
+
+       ! our work is done, exit routine
+       return
+    endif ! of if (llm.eq.1)
+
+    ! General case:
+
+    unpl2k    = 1.+ 2.* kappa
+
+    !     -------------
+    !     Calcul de pks
+    !     -------------
+
+    ijb=ij_begin
+    ije=ij_end
+
+    !$OMP DO SCHEDULE(STATIC)
+    DO   ij  = ijb, ije
+       pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
+    ENDDO
+    !$OMP ENDDO
+    ! Synchro OPENMP ici
+
+    !$OMP BARRIER
+    !
+    !
+    !    .... Calcul des coeff. alpha et beta  pour la couche l = llm ..
+    !
+    !$OMP DO SCHEDULE(STATIC)
+    DO     ij      = ijb,ije
+       alpha(ij,llm) = 0.
+       beta (ij,llm) = 1./ unpl2k
+    ENDDO
+    !$OMP ENDDO NOWAIT
+    !
+    !     ... Calcul des coeff. alpha et beta  pour l = llm-1  a l = 2 ...
+    !
+    DO l = llm -1 , 2 , -1
+       !
+       !$OMP DO SCHEDULE(STATIC)
+       DO ij = ijb, ije
+          dellta = p(ij,l)* unpl2k + p(ij,l+1)* ( beta(ij,l+1)-unpl2k )
+          alpha(ij,l)  = - p(ij,l+1) / dellta * alpha(ij,l+1)
+          beta (ij,l)  =   p(ij,l  ) / dellta   
+       ENDDO
+       !$OMP ENDDO NOWAIT
+    ENDDO
+
+    !  ***********************************************************************
+    !     .....  Calcul de pk pour la couche 1 , pres du sol  ....
+    !
+    !$OMP DO SCHEDULE(STATIC)
+    DO   ij   = ijb, ije
+       pk(ij,1) = ( p(ij,1)*pks(ij) - 0.5*alpha(ij,2)*p(ij,2) )  / &
+            (  p(ij,1)* (1.+kappa) + 0.5*( beta(ij,2)-unpl2k )* p(ij,2) )
+    ENDDO
+    !$OMP ENDDO NOWAIT
+    !
+    !    ..... Calcul de pk(ij,l) , pour l = 2 a l = llm  ........
+    !
+    DO l = 2, llm
+       !$OMP DO SCHEDULE(STATIC)
+       DO   ij   = ijb, ije
+          pk(ij,l) = alpha(ij,l) + beta(ij,l) * pk(ij,l-1)
+       ENDDO
+       !$OMP ENDDO NOWAIT        
+    ENDDO
+
+    if (present(pkf)) then
+       !    calcul de pkf
+
+       DO l = 1, llm
+          !$OMP DO SCHEDULE(STATIC)
+          DO   ij   = ijb, ije
+             pkf(ij,l)=pk(ij,l)
+          ENDDO
+          !$OMP ENDDO NOWAIT             
+       ENDDO
+
+       !$OMP BARRIER
+
+       jjb=jj_begin
+       jje=jj_end
+       CALL filtreg_p ( pkf,jjb,jje, jmp1, llm, 2, 1, .TRUE., 1 )
+    end if
+
+  END SUBROUTINE exner_hyb_p
+
+end module exner_hyb_p_m
Index: DZ5/branches/testing/libf/dyn3dpar/exner_milieu_p.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dpar/exner_milieu_p.F	(revision 2055)
+++ 	(revision )
@@ -1,218 +1,0 @@
-!
-! $Id $
-!
-      SUBROUTINE  exner_milieu_p ( ngrid, ps, p,beta, pks, pk, pkf )
-c
-c     Auteurs :  F. Forget , Y. Wanherdrick
-c P.Le Van  , Fr. Hourdin  .
-c    ..........
-c
-c    ....  ngrid, ps,p             sont des argum.d'entree  au sous-prog ...
-c    .... beta, pks,pk,pkf   sont des argum.de sortie au sous-prog ...
-c
-c   ************************************************************************
-c    Calcule la fonction d'Exner pk = Cp * (p/preff) ** kappa , aux milieux des 
-c    couches .   Pk(l) sera calcule aux milieux  des couches l ,entre les
-c    pressions p(l) et p(l+1) ,definis aux interfaces des llm couches .
-c   ************************************************************************
-c    .. N.B : Au sommet de l'atmosphere,  p(llm+1) = 0. , et ps et pks sont
-c    la pression et la fonction d'Exner  au  sol  .
-c
-c     WARNING : CECI est une version speciale de exner_hyb originale
-c               Utilise dans la version martienne pour pouvoir 
-c               tourner avec des coordonnees verticales complexe
-c              => Il ne verifie PAS la condition la proportionalite en 
-c              energie totale/ interne / potentielle (F.Forget 2001)
-c    ( voir note de Fr.Hourdin )  ,
-c
-      USE parallel_lmdz
-      IMPLICIT NONE
-c
-#include "dimensions.h"
-#include "paramet.h"
-#include "comconst.h"
-#include "comgeom.h"
-#include "comvert.h"
-#include "serre.h"
-
-      INTEGER  ngrid
-      REAL p(ngrid,llmp1),pk(ngrid,llm),pkf(ngrid,llm)
-      REAL ps(ngrid),pks(ngrid), beta(ngrid,llm)
-
-c    .... variables locales   ...
-
-      INTEGER l, ij
-      REAL dum1
-
-      REAL ppn(iim),pps(iim)
-      REAL xpn, xps
-      REAL SSUM
-      EXTERNAL SSUM
-      INTEGER ije,ijb,jje,jjb
-      logical,save :: firstcall=.true.
-!$OMP THREADPRIVATE(firstcall) 
-      character(len=*),parameter :: modname="exner_milieu_p"
-
-      ! Sanity check
-      if (firstcall) then
-        ! sanity checks for Shallow Water case (1 vertical layer)
-        if (llm.eq.1) then
-          if (kappa.ne.1) then
-            call abort_gcm(modname,
-     &      "kappa!=1 , but running in Shallow Water mode!!",42)
-          endif
-          if (cpp.ne.r) then
-            call abort_gcm(modname,
-     &      "cpp!=r , but running in Shallow Water mode!!",42)
-          endif
-        endif ! of if (llm.eq.1)
-
-        firstcall=.false.
-      endif ! of if (firstcall)
-      
-c$OMP BARRIER
-
-! Specific behaviour for Shallow Water (1 vertical layer) case
-      if (llm.eq.1) then
-              
-        ! Compute pks(:),pk(:),pkf(:)
-        ijb=ij_begin
-        ije=ij_end
-!$OMP DO SCHEDULE(STATIC)
-        DO ij=ijb, ije
-          pks(ij)=(cpp/preff)*ps(ij)
-          pk(ij,1) = .5*pks(ij)
-          pkf(ij,1)=pk(ij,1)
-        ENDDO
-!$OMP ENDDO
-
-!$OMP MASTER
-      if (pole_nord) then
-        DO  ij   = 1, iim
-          ppn(ij) = aire(   ij   ) * pks(  ij     )
-        ENDDO
-        xpn      = SSUM(iim,ppn,1) /apoln
-  
-        DO ij   = 1, iip1
-          pks(   ij     )  =  xpn
-          pk(ij,1) = .5*pks(ij)
-          pkf(ij,1)=pk(ij,1)
-        ENDDO
-      endif
-      
-      if (pole_sud) then
-        DO  ij   = 1, iim
-          pps(ij) = aire(ij+ip1jm) * pks(ij+ip1jm )
-        ENDDO
-        xps      = SSUM(iim,pps,1) /apols 
-  
-        DO ij   = 1, iip1
-          pks( ij+ip1jm )  =  xps
-          pk(ij+ip1jm,1)=.5*pks(ij+ip1jm)
-          pkf(ij+ip1jm,1)=pk(ij+ip1jm,1)
-        ENDDO
-      endif
-!$OMP END MASTER
-!$OMP BARRIER
-        jjb=jj_begin
-        jje=jj_end
-        CALL filtreg_p ( pkf,jjb,jje, jmp1, llm, 2, 1, .TRUE., 1 )
-
-        ! our work is done, exit routine
-        return
-      endif ! of if (llm.eq.1)
-
-!!!! General case:
-
-c     -------------
-c     Calcul de pks
-c     -------------
-   
-      ijb=ij_begin
-      ije=ij_end
-
-c$OMP DO SCHEDULE(STATIC)
-      DO   ij  = ijb, ije
-        pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
-      ENDDO
-c$OMP ENDDO
-c Synchro OPENMP ici
-
-c$OMP MASTER
-      if (pole_nord) then
-        DO  ij   = 1, iim
-          ppn(ij) = aire(   ij   ) * pks(  ij     )
-        ENDDO
-        xpn      = SSUM(iim,ppn,1) /apoln
-  
-        DO ij   = 1, iip1
-          pks(   ij     )  =  xpn
-        ENDDO
-      endif
-      
-      if (pole_sud) then
-        DO  ij   = 1, iim
-          pps(ij) = aire(ij+ip1jm) * pks(ij+ip1jm )
-        ENDDO
-        xps      = SSUM(iim,pps,1) /apols 
-  
-        DO ij   = 1, iip1
-          pks( ij+ip1jm )  =  xps
-        ENDDO
-      endif
-c$OMP END MASTER
-c$OMP BARRIER
-c
-c
-c    .... Calcul de pk  pour la couche l 
-c    --------------------------------------------
-c
-      dum1 = cpp * (2*preff)**(-kappa) 
-      DO l = 1, llm-1
-c$OMP DO SCHEDULE(STATIC)
-        DO   ij   = ijb, ije
-         pk(ij,l) = dum1 * (p(ij,l) + p(ij,l+1))**kappa
-        ENDDO
-c$OMP ENDDO NOWAIT        
-      ENDDO
-
-c    .... Calcul de pk  pour la couche l = llm ..
-c    (on met la meme distance (en log pression)  entre Pk(llm)
-c    et Pk(llm -1) qu'entre Pk(llm-1) et Pk(llm-2)
-
-c$OMP DO SCHEDULE(STATIC)
-      DO   ij   = ijb, ije
-         pk(ij,llm) = pk(ij,llm-1)**2 / pk(ij,llm-2)
-      ENDDO
-c$OMP ENDDO NOWAIT        
-
-
-c    calcul de pkf
-c    -------------
-c      CALL SCOPY   ( ngrid * llm, pk, 1, pkf, 1 )
-      DO l = 1, llm
-c$OMP DO SCHEDULE(STATIC)
-         DO   ij   = ijb, ije
-           pkf(ij,l)=pk(ij,l)
-         ENDDO
-c$OMP ENDDO NOWAIT             
-      ENDDO
-
-c$OMP BARRIER
-      
-      jjb=jj_begin
-      jje=jj_end
-      CALL filtreg_p ( pkf,jjb,jje, jmp1, llm, 2, 1, .TRUE., 1 )
-      
-c    EST-CE UTILE ?? : calcul de beta
-c    --------------------------------
-      DO l = 2, llm
-c$OMP DO SCHEDULE(STATIC)
-        DO   ij   = ijb, ije
-          beta(ij,l) = pk(ij,l) / pk(ij,l-1)   
-        ENDDO
-c$OMP ENDDO NOWAIT             
-      ENDDO
-
-      RETURN
-      END
Index: /LMDZ5/branches/testing/libf/dyn3dpar/exner_milieu_p_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dpar/exner_milieu_p_m.F90	(revision 2056)
+++ /LMDZ5/branches/testing/libf/dyn3dpar/exner_milieu_p_m.F90	(revision 2056)
@@ -0,0 +1,159 @@
+module exner_milieu_p_m
+
+  IMPLICIT NONE
+
+contains
+
+  SUBROUTINE  exner_milieu_p ( ngrid, ps, p, pks, pk, pkf )
+    !
+    !     Auteurs :  F. Forget , Y. Wanherdrick
+    ! P.Le Van  , Fr. Hourdin  .
+    !    ..........
+    !
+    !    ....  ngrid, ps,p             sont des argum.d'entree  au sous-prog ...
+    !    ....  pks,pk,pkf   sont des argum.de sortie au sous-prog ...
+    !
+    !   ************************************************************************
+    !    Calcule la fonction d'Exner pk = Cp * (p/preff) ** kappa , aux milieux des 
+    !    couches .   Pk(l) sera calcule aux milieux  des couches l ,entre les
+    !    pressions p(l) et p(l+1) ,definis aux interfaces des llm couches .
+    !   ************************************************************************
+    !  .. N.B : Au sommet de l'atmosphere,  p(llm+1) = 0. , et ps et pks sont
+    !    la pression et la fonction d'Exner  au  sol  .
+    !
+    !     WARNING : CECI est une version speciale de exner_hyb originale
+    !               Utilise dans la version martienne pour pouvoir 
+    !               tourner avec des coordonnees verticales complexe
+    !              => Il ne verifie PAS la condition la proportionalite en 
+    !              energie totale/ interne / potentielle (F.Forget 2001)
+    !    ( voir note de Fr.Hourdin )  ,
+    !
+    USE parallel_lmdz
+    !
+    include "dimensions.h"
+    include "paramet.h"
+    include "comconst.h"
+    include "comgeom.h"
+    include "comvert.h"
+    include "serre.h"
+
+    INTEGER  ngrid
+    REAL p(ngrid,llmp1),pk(ngrid,llm)
+    REAL, optional:: pkf(ngrid,llm)
+    REAL ps(ngrid),pks(ngrid)
+
+    !    .... variables locales   ...
+
+    INTEGER l, ij,ijb,ije,jjb,jje
+    REAL dum1
+
+    logical,save :: firstcall=.true.
+    !$OMP THREADPRIVATE(firstcall) 
+    character(len=*),parameter :: modname="exner_milieu_p"
+
+    ! Sanity check
+    if (firstcall) then
+       ! sanity checks for Shallow Water case (1 vertical layer)
+       if (llm.eq.1) then
+          if (kappa.ne.1) then
+             call abort_gcm(modname, &
+                  "kappa!=1 , but running in Shallow Water mode!!",42)
+          endif
+          if (cpp.ne.r) then
+             call abort_gcm(modname, &
+                  "cpp!=r , but running in Shallow Water mode!!",42)
+          endif
+       endif ! of if (llm.eq.1)
+
+       firstcall=.false.
+    endif ! of if (firstcall)
+
+    !$OMP BARRIER
+
+    ! Specific behaviour for Shallow Water (1 vertical layer) case:
+    if (llm.eq.1) then
+
+       ! Compute pks(:),pk(:),pkf(:)
+       ijb=ij_begin
+       ije=ij_end
+       !$OMP DO SCHEDULE(STATIC)
+       DO ij=ijb, ije
+          pks(ij) = (cpp/preff) * ps(ij)
+          pk(ij,1) = .5*pks(ij)
+          if (present(pkf)) pkf(ij,1)=pk(ij,1)
+       ENDDO
+       !$OMP ENDDO
+
+       !$OMP BARRIER
+       if (present(pkf)) then
+          jjb=jj_begin
+          jje=jj_end
+          CALL filtreg_p ( pkf,jjb,jje, jmp1, llm, 2, 1, .TRUE., 1 )
+       end if
+
+       ! our work is done, exit routine
+       return
+    endif ! of if (llm.eq.1)
+
+    ! General case:
+
+    !     -------------
+    !     Calcul de pks
+    !     -------------
+
+    ijb=ij_begin
+    ije=ij_end
+
+    !$OMP DO SCHEDULE(STATIC)
+    DO   ij  = ijb, ije
+       pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
+    ENDDO
+    !$OMP ENDDO
+    ! Synchro OPENMP ici
+
+    !$OMP BARRIER
+    !
+    !
+    !    .... Calcul de pk  pour la couche l 
+    !    --------------------------------------------
+    !
+    dum1 = cpp * (2*preff)**(-kappa) 
+    DO l = 1, llm-1
+       !$OMP DO SCHEDULE(STATIC)
+       DO   ij   = ijb, ije
+          pk(ij,l) = dum1 * (p(ij,l) + p(ij,l+1))**kappa
+       ENDDO
+       !$OMP ENDDO NOWAIT
+    ENDDO
+
+    !    .... Calcul de pk  pour la couche l = llm ..
+    !    (on met la meme distance (en log pression)  entre Pk(llm)
+    !    et Pk(llm -1) qu'entre Pk(llm-1) et Pk(llm-2)
+
+    !$OMP DO SCHEDULE(STATIC)
+    DO   ij   = ijb, ije
+       pk(ij,llm) = pk(ij,llm-1)**2 / pk(ij,llm-2)
+    ENDDO
+    !$OMP ENDDO NOWAIT        
+
+    if (present(pkf)) then
+       !    calcul de pkf
+
+       DO l = 1, llm
+          !$OMP DO SCHEDULE(STATIC)
+          DO   ij   = ijb, ije
+             pkf(ij,l)=pk(ij,l)
+          ENDDO
+          !$OMP ENDDO NOWAIT
+       ENDDO
+
+       !$OMP BARRIER
+
+       jjb=jj_begin
+       jje=jj_end
+       CALL filtreg_p ( pkf,jjb,jje, jmp1, llm, 2, 1, .TRUE., 1 )
+    end if
+
+  END SUBROUTINE exner_milieu_p
+
+end module exner_milieu_p_m
Index: /LMDZ5/branches/testing/libf/dyn3dpar/gcm.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dpar/gcm.F	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3dpar/gcm.F	(revision 2056)
@@ -99,7 +99,4 @@
       REAL ps(ip1jmp1)                       ! pression  au sol
 c      REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.des couches
-c      REAL pks(ip1jmp1)                      ! exner au  sol
-c      REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
-c      REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
       REAL masse(ip1jmp1,llm)                ! masse d'air
       REAL phis(ip1jmp1)                     ! geopotentiel au sol
@@ -125,5 +122,4 @@
       data call_iniphys/.true./
 
-c      REAL alpha(ip1jmp1,llm),beta(ip1jmp1,llm)
 c+jld variables test conservation energie
 c      REAL ecin(ip1jmp1,llm),ecin0(ip1jmp1,llm)
@@ -481,5 +477,10 @@
 
 
-      day_end = day_ini + nday
+      if (nday>=0) then
+         day_end = day_ini + nday
+      else
+         day_end = day_ini - nday/day_step
+      endif
+
       WRITE(lunout,300)day_ini,day_end
  300  FORMAT('1'/,15x,'run du jour',i7,2x,'au jour',i7//)
Index: /LMDZ5/branches/testing/libf/dyn3dpar/guide_p_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dpar/guide_p_mod.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3dpar/guide_p_mod.F90	(revision 2056)
@@ -328,4 +328,6 @@
 !=======================================================================
   SUBROUTINE guide_main(itau,ucov,vcov,teta,q,masse,ps)
+    use exner_hyb_p_m, only: exner_hyb_p
+    use exner_milieu_p_m, only: exner_milieu_p
     USE parallel_lmdz
     USE control_mod
@@ -349,6 +351,5 @@
     REAL, DIMENSION (ip1jmp1,llm) :: f_add ! var aux: champ de guidage
     ! Variables pour fonction Exner (P milieu couche)
-    REAL, DIMENSION (iip1,jjp1,llm)    :: pk, pkf
-    REAL, DIMENSION (iip1,jjp1,llm)    :: alpha, beta
+    REAL, DIMENSION (iip1,jjp1,llm)    :: pk
     REAL, DIMENSION (iip1,jjp1)        :: pks    
     REAL                               :: unskap
@@ -493,7 +494,7 @@
         CALL pression_p( ip1jmp1, ap, bp, ps, p )
         if (pressure_exner) then
-          CALL exner_hyb_p(ip1jmp1,ps,p,alpha,beta,pks,pk,pkf)
+          CALL exner_hyb_p(ip1jmp1,ps,p,pks,pk)
         else
-          CALL exner_milieu_p(ip1jmp1,ps,p,beta,pks,pk,pkf)
+          CALL exner_milieu_p(ip1jmp1,ps,p,pks,pk)
         endif
         unskap=1./kappa
@@ -693,4 +694,6 @@
 !=======================================================================
   SUBROUTINE guide_interp(psi,teta)
+    use exner_hyb_p_m, only: exner_hyb_p
+    use exner_milieu_p_m, only: exner_milieu_p
   USE parallel_lmdz
   USE mod_hallo
@@ -717,6 +720,5 @@
   REAL, DIMENSION (iip1,jjm,llm)     :: pbary 
   ! Variables pour fonction Exner (P milieu couche)
-  REAL, DIMENSION (iip1,jjp1,llm)    :: pk, pkf
-  REAL, DIMENSION (iip1,jjp1,llm)    :: alpha, beta
+  REAL, DIMENSION (iip1,jjp1,llm)    :: pk
   REAL, DIMENSION (iip1,jjp1)        :: pks    
   REAL                               :: unskap
@@ -797,7 +799,7 @@
         CALL pression_p( ip1jmp1, ap, bp, psi, p )
         if (pressure_exner) then
-          CALL exner_hyb_p(ip1jmp1,psi,p,alpha,beta,pks,pk,pkf)
+          CALL exner_hyb_p(ip1jmp1,psi,p,pks,pk)
         else
-          CALL exner_milieu_p(ip1jmp1,psi,p,beta,pks,pk,pkf)
+          CALL exner_milieu_p(ip1jmp1,psi,p,pks,pk)
         endif
         unskap=1./kappa
Index: /LMDZ5/branches/testing/libf/dyn3dpar/iniacademic.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dpar/iniacademic.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3dpar/iniacademic.F90	(revision 2056)
@@ -4,4 +4,6 @@
 SUBROUTINE iniacademic(vcov,ucov,teta,q,masse,ps,phis,time_0)
 
+  use exner_hyb_m, only: exner_hyb
+  use exner_milieu_m, only: exner_milieu
   USE filtreg_mod
   USE infotrac, ONLY : nqtot
@@ -54,5 +56,4 @@
   REAL pks(ip1jmp1)                      ! exner au  sol
   REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
-  REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
   REAL phi(ip1jmp1,llm)                  ! geopotentiel
   REAL ddsin,zsig,tetapv,w_pv  ! variables auxiliaires
@@ -70,5 +71,5 @@
   integer idum
 
-  REAL alpha(ip1jmp1,llm),beta(ip1jmp1,llm),zdtvr
+  REAL zdtvr
   
   character(len=*),parameter :: modname="iniacademic"
@@ -223,7 +224,7 @@
         CALL pression ( ip1jmp1, ap, bp, ps, p       )
         if (pressure_exner) then
-          CALL exner_hyb( ip1jmp1, ps, p,alpha,beta, pks, pk, pkf )
-        else
-          call exner_milieu(ip1jmp1,ps,p,beta,pks,pk,pkf)
+          CALL exner_hyb( ip1jmp1, ps, p, pks, pk )
+        else
+          call exner_milieu(ip1jmp1,ps,p,pks,pk)
         endif
         CALL massdair(p,masse)
Index: /LMDZ5/branches/testing/libf/dyn3dpar/leapfrog_p.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dpar/leapfrog_p.F	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3dpar/leapfrog_p.F	(revision 2056)
@@ -8,4 +8,8 @@
      &                    time_0)
 
+      use exner_hyb_m, only: exner_hyb
+      use exner_milieu_m, only: exner_milieu
+      use exner_hyb_p_m, only: exner_hyb_p
+      use exner_milieu_p_m, only: exner_milieu_p
        USE misc_mod
        USE parallel_lmdz
@@ -149,5 +153,4 @@
       character*10 string10
 
-      REAL,SAVE :: alpha(ip1jmp1,llm),beta(ip1jmp1,llm)
       REAL,SAVE :: flxw(ip1jmp1,llm) ! flux de masse verticale
 
@@ -209,5 +212,10 @@
       lafin=.false.
       
-      itaufin   = nday*day_step
+      if (nday>=0) then
+         itaufin   = nday*day_step
+      else
+         itaufin   = -nday
+      endif
+
       itaufinp1 = itaufin +1
 
@@ -241,7 +249,7 @@
       CALL pression ( ip1jmp1, ap, bp, ps, p       )
       if (pressure_exner) then
-        CALL exner_hyb( ip1jmp1, ps, p,alpha,beta, pks, pk, pkf )
+        CALL exner_hyb( ip1jmp1, ps, p, pks, pk, pkf )
       else
-        CALL exner_milieu( ip1jmp1, ps, p, beta, pks, pk, pkf )
+        CALL exner_milieu( ip1jmp1, ps, p, pks, pk, pkf )
       endif
 c$OMP END MASTER
@@ -705,8 +713,11 @@
 c$OMP BARRIER
          if (pressure_exner) then
-           CALL exner_hyb_p(  ip1jmp1, ps, p,alpha,beta,pks, pk, pkf )
+           CALL exner_hyb_p(  ip1jmp1, ps, p,pks, pk, pkf )
          else
-           CALL exner_milieu_p( ip1jmp1, ps, p, beta, pks, pk, pkf )
+           CALL exner_milieu_p( ip1jmp1, ps, p, pks, pk, pkf )
          endif
+! Appel a geopot ajoute le 2014/05/08 pour garantir la convergence numerique
+! avec dyn3dmem
+      CALL geopot  ( ip1jmp1, teta  , pk , pks,  phis  , phi   )
 c$OMP BARRIER
            jD_cur = jD_ref + day_ini - day_ref
@@ -918,7 +929,7 @@
 c$OMP BARRIER
           if (pressure_exner) then
-            CALL exner_hyb_p(ip1jmp1,ps,p,alpha,beta,pks,pk,pkf)
+            CALL exner_hyb_p(ip1jmp1,ps,p,pks,pk,pkf)
           else
-            CALL exner_milieu_p(ip1jmp1,ps,p,beta,pks,pk,pkf)
+            CALL exner_milieu_p(ip1jmp1,ps,p,pks,pk,pkf)
           endif
 c$OMP BARRIER
@@ -1059,7 +1070,7 @@
 c$OMP BARRIER
         if (pressure_exner) then
-          CALL exner_hyb_p( ip1jmp1, ps, p,alpha,beta, pks, pk, pkf )
+          CALL exner_hyb_p( ip1jmp1, ps, p, pks, pk, pkf )
         else
-          CALL exner_milieu_p( ip1jmp1, ps, p, beta, pks, pk, pkf )
+          CALL exner_milieu_p( ip1jmp1, ps, p, pks, pk, pkf )
         endif
 c$OMP BARRIER
Index: /LMDZ5/branches/testing/libf/dyn3dpar/mod_const_mpi.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dpar/mod_const_mpi.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3dpar/mod_const_mpi.F90	(revision 2056)
@@ -21,4 +21,7 @@
     USE mod_prism
 #endif
+#ifdef CPP_XIOS
+    USE wxios, only: wxios_init
+#endif
     IMPLICIT NONE
 #ifdef CPP_MPI
@@ -41,6 +44,10 @@
 #ifdef CPP_COUPLE
 !$OMP MASTER
-       CALL prism_init_comp_proto (comp_id, 'lmdz.x', ierr)
+#ifdef CPP_XIOS
+      CALL wxios_init("LMDZ", outcom=COMM_LMDZ, type_ocean=type_ocean)
+#else
+       CALL prism_init_comp_proto (comp_id, 'LMDZ', ierr)
        CALL prism_get_localcomm_proto(COMM_LMDZ,ierr)
+#endif
 !$OMP END MASTER
 #endif
Index: /LMDZ5/branches/testing/libf/dyn3dpar/parallel_lmdz.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dpar/parallel_lmdz.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/dyn3dpar/parallel_lmdz.F90	(revision 2056)
@@ -255,4 +255,8 @@
 
       if (type_ocean == 'couple') then
+#ifdef CPP_XIOS
+    !Fermeture propre de XIOS
+      CALL wxios_close()
+#else
 #ifdef CPP_COUPLE
          call prism_terminate_proto(ierr)
@@ -261,4 +265,5 @@
          endif
 #endif 
+#endif
       else
 #ifdef CPP_XIOS
Index: /LMDZ5/branches/testing/libf/phydev/iophy.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phydev/iophy.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phydev/iophy.F90	(revision 2056)
@@ -340,5 +340,5 @@
   USE mod_phys_lmdz_para, only: gather_omp, grid1Dto2D_mpi, &
                                 jj_nb, klon_mpi
-  USE wxios, only: wxios_write_2D
+  USE xios, only: xios_send_field
 
 
@@ -361,5 +361,5 @@
     CALL grid1Dto2D_mpi(buffer_omp,Field2d)
     
-    CALL wxios_write_2D(field_name, Field2d)
+    CALL xios_send_field(field_name, Field2d)
 !$OMP END MASTER   
 
@@ -376,5 +376,5 @@
   USE mod_phys_lmdz_para, only: gather_omp, grid1Dto2D_mpi, &
                                 jj_nb, klon_mpi
-  USE wxios, only: wxios_write_3D
+  USE xios, only: xios_send_field
 
 
@@ -401,5 +401,5 @@
     CALL grid1Dto2D_mpi(buffer_omp,field3d)
 
-    CALL wxios_write_3D(field_name, Field3d(:,:,1:klev))
+    CALL xios_send_field(field_name, Field3d(:,:,1:nlev))
 !$OMP END MASTER   
 
Index: /LMDZ5/branches/testing/libf/phydev/physiq.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phydev/physiq.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phydev/physiq.F90	(revision 2056)
@@ -8,6 +8,5 @@
      &            flxmass_w, &
      &            d_u, d_v, d_t, d_qx, d_ps &
-     &            , dudyn &
-     &            , PVteta)
+     &            , dudyn)
 
       USE dimphy, only : klon,klev
@@ -21,6 +20,7 @@
 
 #ifdef CPP_XIOS
+      USE xios, ONLY: xios_update_calendar
       USE wxios, only: wxios_add_vaxis, wxios_set_timestep, wxios_closedef, &
-                       wxios_update_calendar, histwrite_phy
+                       histwrite_phy
 #endif
 
@@ -58,8 +58,4 @@
       real,intent(out) :: d_ps(klon) ! physics tendency on surface pressure
       real,intent(in) :: dudyn(iim+1,jjmp1,klev) ! Not used
-!FH! REAL PVteta(klon,nbteta)
-!      REAL PVteta(klon,1)
-      real,intent(in) :: PVteta(klon,3) ! Not used ; should match definition
-                                        ! in calfis.F
 
 integer,save :: itau=0 ! counter to count number of calls to physics
@@ -137,11 +133,12 @@
 #ifdef CPP_XIOS
 !XIOS
-    ! Déclaration de l'axe vertical du fichier:    
-    CALL wxios_add_vaxis("presnivs", "histins", klev, presnivs)
-
-    !Déclaration du pas de temps:
+    ! Declare available vertical axes to be used in output files:    
+    !CALL wxios_add_vaxis("presnivs", "dummy-not-used", klev, presnivs)
+    CALL wxios_add_vaxis("presnivs", klev, presnivs)
+
+    ! Declare time step length (in s):
     CALL wxios_set_timestep(dtime)
 
-    !Finalisation du contexte:
+    !Finalize the context:
     CALL wxios_closedef()
 #endif
@@ -187,10 +184,12 @@
 !$OMP MASTER
     !Increment XIOS time
-    CALL wxios_update_calendar(itau)
+    CALL xios_update_calendar(itau)
 !$OMP END MASTER
 !$OMP BARRIER
 
-    !Send fields to XIOS:
+    !Send fields to XIOS: (NB these fields must also be defined as
+    ! <field id="..." /> in iodef.xml to be correctly used
     CALL histwrite_phy("temperature",t)
+    CALL histwrite_phy("temp_newton",temp_newton)
     CALL histwrite_phy("u",u)
     CALL histwrite_phy("v",v)
Index: DZ5/branches/testing/libf/phydev/tetalevel.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phydev/tetalevel.F90	(revision 2055)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../phylmd/tetalevel.F90
Index: /LMDZ5/branches/testing/libf/phylmd/1DUTILS.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/1DUTILS.h	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/1DUTILS.h	(revision 2056)
@@ -0,0 +1,3517 @@
+#include "../dyn3d/conf_gcm.F"
+#include "../dyn3d_common/q_sat.F"
+
+!
+! $Id: conf_unicol.F 1279 2010-08-04 17:20:56Z lahellec $
+!
+!
+!
+      SUBROUTINE conf_unicol
+!
+#ifdef CPP_IOIPSL
+      use IOIPSL
+#else
+! if not using IOIPSL, we still need to use (a local version of) getin
+      use ioipsl_getincom
+#endif
+      IMPLICIT NONE
+!-----------------------------------------------------------------------
+!     Auteurs :   A. Lahellec  .
+!
+!   Declarations :
+!   --------------
+
+#include "compar1d.h"
+#include "flux_arp.h"
+#include "tsoilnudge.h"
+#include "fcg_gcssold.h"
+#include "fcg_racmo.h"
+#include "iniprint.h"
+!
+!
+!   local:
+!   ------
+
+!      CHARACTER ch1*72,ch2*72,ch3*72,ch4*12
+      
+!
+!  -------------------------------------------------------------------
+!
+!      .........    Initilisation parametres du lmdz1D      ..........
+!
+!---------------------------------------------------------------------
+!   initialisations:
+!   ----------------
+
+!Config  Key  = lunout
+!Config  Desc = unite de fichier pour les impressions
+!Config  Def  = 6
+!Config  Help = unite de fichier pour les impressions 
+!Config         (defaut sortie standard = 6)
+      lunout=6
+!      CALL getin('lunout', lunout)
+      IF (lunout /= 5 .and. lunout /= 6) THEN
+        OPEN(lunout,FILE='lmdz.out')
+      ENDIF
+
+!Config  Key  = prt_level
+!Config  Desc = niveau d'impressions de débogage
+!Config  Def  = 0
+!Config  Help = Niveau d'impression pour le débogage
+!Config         (0 = minimum d'impression)
+!      prt_level = 0
+!      CALL getin('prt_level',prt_level)
+
+!-----------------------------------------------------------------------
+!  Parametres de controle du run:
+!-----------------------------------------------------------------------
+
+!Config  Key  = restart
+!Config  Desc = on repart des startphy et start1dyn
+!Config  Def  = false
+!Config  Help = les fichiers restart doivent etre renomme en start
+       restart =.false.
+       CALL getin('restart',restart)
+
+!Config  Key  = forcing_type
+!Config  Desc = defines the way the SCM is forced:
+!Config  Def  = 0
+!!Config  Help = 0 ==> forcing_les = .true.
+!             initial profiles from file prof.inp.001
+!             no forcing by LS convergence ; 
+!             surface temperature imposed ;
+!             radiative cooling may be imposed (iflag_radia=0 in physiq.def)
+!         = 1 ==> forcing_radconv = .true.
+!             idem forcing_type = 0, but the imposed radiative cooling 
+!             is set to 0 (hence, if iflag_radia=0 in physiq.def, 
+!             then there is no radiative cooling at all)
+!         = 2 ==> forcing_toga = .true.
+!             initial profiles from TOGA-COARE IFA files 
+!             LS convergence and SST imposed from TOGA-COARE IFA files 
+!         = 3 ==> forcing_GCM2SCM = .true.
+!             initial profiles from the GCM output
+!             LS convergence imposed from the GCM output
+!         = 4 ==> forcing_twpi = .true.
+!             initial profiles from TWPICE nc files 
+!             LS convergence and SST imposed from TWPICE nc files 
+!         = 5 ==> forcing_rico = .true.
+!             initial profiles from RICO idealized
+!             LS convergence imposed from  RICO (cst) 
+!         = 6 ==> forcing_amma = .true.
+!         = 40 ==> forcing_GCSSold = .true.
+!             initial profile from GCSS file
+!             LS convergence imposed from GCSS file
+!         = 50 ==> forcing_fire = .true.
+!         = 59 ==> forcing_sandu = .true.
+!             initial profiles from sanduref file: see prof.inp.001
+!             SST varying with time and divergence constante: see ifa_sanduref.txt file
+!             Radiation has to be computed interactively
+!         = 60 ==> forcing_astex = .true.
+!             initial profiles from file: see prof.inp.001 
+!             SST,divergence,ug,vg,ufa,vfa varying with time : see ifa_astex.txt file
+!             Radiation has to be computed interactively
+!         = 61 ==> forcing_armcu = .true.
+!             initial profiles from file: see prof.inp.001 
+!             sensible and latent heat flux imposed: see ifa_arm_cu_1.txt
+!             large scale advective forcing & radiative tendencies applied below 1000m: see ifa_arm_cu_2.txt
+!             use geostrophic wind ug=10m/s vg=0m/s. Duration of the case 53100s 
+!             Radiation to be switched off
+!
+       forcing_type = 0
+       CALL getin('forcing_type',forcing_type)
+         imp_fcg_gcssold   = .false.
+         ts_fcg_gcssold    = .false.  
+         Tp_fcg_gcssold    = .false.  
+         Tp_ini_gcssold    = .false.  
+         xTurb_fcg_gcssold = .false. 
+        IF (forcing_type .eq.40) THEN
+          CALL getin('imp_fcg',imp_fcg_gcssold)
+          CALL getin('ts_fcg',ts_fcg_gcssold)
+          CALL getin('tp_fcg',Tp_fcg_gcssold)
+          CALL getin('tp_ini',Tp_ini_gcssold)
+          CALL getin('turb_fcg',xTurb_fcg_gcssold)
+        ENDIF
+
+!Config  Key  = ok_flux_surf
+!Config  Desc = forcage ou non par les flux de surface
+!Config  Def  = false
+!Config  Help = forcage ou non par les flux de surface
+       ok_flux_surf =.false.
+       CALL getin('ok_flux_surf',ok_flux_surf)
+
+!Config  Key  = ok_old_disvert
+!Config  Desc = utilisation de l ancien programme disvert0 (dans 1DUTILS.h)
+!Config  Def  = false
+!Config  Help = utilisation de l ancien programme disvert0 (dans 1DUTILS.h)
+       ok_old_disvert = .FALSE.
+       CALL getin('ok_old_disvert',ok_old_disvert)
+
+!Config  Key  = time_ini
+!Config  Desc = meaningless in this  case
+!Config  Def  = 0.
+!Config  Help = 
+       tsurf = 0.
+       CALL getin('time_ini',time_ini)
+
+!Config  Key  = rlat et rlon
+!Config  Desc = latitude et longitude
+!Config  Def  = 0.0  0.0
+!Config  Help = fixe la position de la colonne
+       xlat = 0.
+       xlon = 0.
+       CALL getin('rlat',xlat)
+       CALL getin('rlon',xlon)
+
+!Config  Key  = airephy
+!Config  Desc = Grid cell area
+!Config  Def  = 1.e11
+!Config  Help = 
+       airefi = 1.e11
+       CALL getin('airephy',airefi)
+
+!Config  Key  = nat_surf
+!Config  Desc = surface type
+!Config  Def  = 0 (ocean)
+!Config  Help = 0=ocean,1=land,2=glacier,3=banquise
+       nat_surf = 0.
+       CALL getin('nat_surf',nat_surf)
+
+!Config  Key  = tsurf
+!Config  Desc = surface temperature
+!Config  Def  = 290.
+!Config  Help = not used if type_ts_forcing=1 in lmdz1d.F
+       tsurf = 290.
+       CALL getin('tsurf',tsurf)
+
+!Config  Key  = psurf
+!Config  Desc = surface pressure
+!Config  Def  = 102400.
+!Config  Help = 
+       psurf = 102400.
+       CALL getin('psurf',psurf)
+
+!Config  Key  = zsurf
+!Config  Desc = surface altitude
+!Config  Def  = 0.
+!Config  Help = 
+       zsurf = 0.
+       CALL getin('zsurf',zsurf)
+
+!Config  Key  = rugos
+!Config  Desc = coefficient de frottement
+!Config  Def  = 0.0001
+!Config  Help = calcul du Cdrag
+       rugos = 0.0001
+       CALL getin('rugos',rugos)
+
+!Config  Key  = wtsurf et wqsurf
+!Config  Desc = ???
+!Config  Def  = 0.0 0.0
+!Config  Help = 
+       wtsurf = 0.0
+       wqsurf = 0.0
+       CALL getin('wtsurf',wtsurf)
+       CALL getin('wqsurf',wqsurf)
+
+!Config  Key  = albedo
+!Config  Desc = albedo
+!Config  Def  = 0.09
+!Config  Help = 
+       albedo = 0.09
+       CALL getin('albedo',albedo)
+
+!Config  Key  = agesno
+!Config  Desc = age de la neige
+!Config  Def  = 30.0
+!Config  Help = 
+       xagesno = 30.0
+       CALL getin('agesno',xagesno)
+
+!Config  Key  = restart_runoff
+!Config  Desc = age de la neige
+!Config  Def  = 30.0
+!Config  Help = 
+       restart_runoff = 0.0
+       CALL getin('restart_runoff',restart_runoff)
+
+!Config  Key  = qsolinp
+!Config  Desc = initial bucket water content (kg/m2) when land (5std)
+!Config  Def  = 30.0
+!Config  Help = 
+       qsolinp = 1.
+       CALL getin('qsolinp',qsolinp)
+
+!Config  Key  = zpicinp
+!Config  Desc = denivellation orographie
+!Config  Def  = 300.
+!Config  Help =  input brise
+       zpicinp = 300.
+       CALL getin('zpicinp',zpicinp)
+!Config key = nudge_tsoil
+!Config  Desc = activation of soil temperature nudging
+!Config  Def  = .FALSE.
+!Config  Help = ...
+
+       nudge_tsoil=.FALSE.
+       CALL getin('nudge_tsoil',nudge_tsoil)
+
+!Config key = isoil_nudge
+!Config  Desc = level number where soil temperature is nudged
+!Config  Def  = 3
+!Config  Help = ...
+
+       isoil_nudge=3
+       CALL getin('isoil_nudge',isoil_nudge)
+
+!Config key = Tsoil_nudge
+!Config  Desc = target temperature for tsoil(isoil_nudge)
+!Config  Def  = 300.
+!Config  Help = ...
+
+       Tsoil_nudge=300.
+       CALL getin('Tsoil_nudge',Tsoil_nudge)
+
+!Config key = tau_soil_nudge
+!Config  Desc = nudging relaxation time for tsoil
+!Config  Def  = 3600.
+!Config  Help = ...
+
+       tau_soil_nudge=3600.
+       CALL getin('tau_soil_nudge',tau_soil_nudge)
+
+
+
+
+      write(lunout,*)' +++++++++++++++++++++++++++++++++++++++'
+      write(lunout,*)' Configuration des parametres du gcm1D: '
+      write(lunout,*)' +++++++++++++++++++++++++++++++++++++++'
+      write(lunout,*)' restart = ', restart
+      write(lunout,*)' forcing_type = ', forcing_type
+      write(lunout,*)' time_ini = ', time_ini
+      write(lunout,*)' rlat = ', xlat
+      write(lunout,*)' rlon = ', xlon
+      write(lunout,*)' airephy = ', airefi
+      write(lunout,*)' nat_surf = ', nat_surf
+      write(lunout,*)' tsurf = ', tsurf
+      write(lunout,*)' psurf = ', psurf
+      write(lunout,*)' zsurf = ', zsurf
+      write(lunout,*)' rugos = ', rugos
+      write(lunout,*)' wtsurf = ', wtsurf
+      write(lunout,*)' wqsurf = ', wqsurf
+      write(lunout,*)' albedo = ', albedo
+      write(lunout,*)' xagesno = ', xagesno
+      write(lunout,*)' restart_runoff = ', restart_runoff
+      write(lunout,*)' qsolinp = ', qsolinp
+      write(lunout,*)' zpicinp = ', zpicinp
+      write(lunout,*)' nudge_tsoil = ', nudge_tsoil
+      write(lunout,*)' isoil_nudge = ', isoil_nudge
+      write(lunout,*)' Tsoil_nudge = ', Tsoil_nudge
+      write(lunout,*)' tau_soil_nudge = ', tau_soil_nudge
+      IF (forcing_type .eq.40) THEN
+        write(lunout,*) '--- Forcing type GCSS Old --- with:'
+        write(lunout,*)'imp_fcg',imp_fcg_gcssold
+        write(lunout,*)'ts_fcg',ts_fcg_gcssold
+        write(lunout,*)'tp_fcg',Tp_fcg_gcssold
+        write(lunout,*)'tp_ini',Tp_ini_gcssold
+        write(lunout,*)'xturb_fcg',xTurb_fcg_gcssold
+      ENDIF
+
+      write(lunout,*)' +++++++++++++++++++++++++++++++++++++++'
+      write(lunout,*)
+!
+      RETURN
+      END
+!
+! $Id: dyn1deta0.F 1279 2010/07/30 A Lahellec$
+!
+!
+      SUBROUTINE dyn1deta0(fichnom,plev,play,phi,phis,presnivs,                 &
+     &                          ucov,vcov,temp,q,omega2)
+      USE dimphy
+      USE mod_grid_phy_lmdz
+      USE mod_phys_lmdz_para
+      USE iophy
+      USE phys_state_var_mod
+      USE iostart
+      USE write_field_phy
+      USE infotrac
+      use control_mod
+
+      IMPLICIT NONE
+!=======================================================
+! Ecriture du fichier de redemarrage sous format NetCDF
+!=======================================================
+!   Declarations:
+!   -------------
+#include "dimensions.h"
+#include "comconst.h"
+#include "temps.h"
+!!#include "control.h"
+#include "logic.h"
+#include "netcdf.inc"
+
+!   Arguments:
+!   ----------
+      CHARACTER*(*) fichnom
+!Al1 plev tronque pour .nc mais plev(klev+1):=0
+      real :: plev(klon,klev),play (klon,klev),phi(klon,klev)
+      real :: presnivs(klon,klev)
+      real :: ucov(klon,klev),vcov(klon,klev),temp(klon,klev)
+      real :: q(klon,klev,nqtot),omega2(klon,klev)
+!      real :: ug(klev),vg(klev),fcoriolis
+      real :: phis(klon) 
+
+!   Variables locales pour NetCDF:
+!   ------------------------------
+      INTEGER iq
+      INTEGER length
+      PARAMETER (length = 100)
+      REAL tab_cntrl(length) ! tableau des parametres du run
+      character*4 nmq(nqtot)
+      character*12 modname
+      character*80 abort_message
+      LOGICAL found
+
+      modname = 'dyn1deta0 : '
+      nmq(1)="vap"
+      nmq(2)="cond"
+      do iq=3,nqtot
+        write(nmq(iq),'("tra",i1)') iq-2
+      enddo
+      print*,'in dyn1deta0 ',fichnom,klon,klev,nqtot
+      CALL open_startphy(fichnom)
+      print*,'after open startphy ',fichnom,nmq
+
+!
+! Lecture des parametres de controle:
+!
+      CALL get_var("controle",tab_cntrl)
+       
+
+      im         = tab_cntrl(1)
+      jm         = tab_cntrl(2)
+      lllm       = tab_cntrl(3)
+      day_ref    = tab_cntrl(4)
+      annee_ref  = tab_cntrl(5)
+!      rad        = tab_cntrl(6)
+!      omeg       = tab_cntrl(7)
+!      g          = tab_cntrl(8)
+!      cpp        = tab_cntrl(9)
+!      kappa      = tab_cntrl(10)
+!      daysec     = tab_cntrl(11)
+!      dtvr       = tab_cntrl(12)
+!      etot0      = tab_cntrl(13)
+!      ptot0      = tab_cntrl(14)
+!      ztot0      = tab_cntrl(15)
+!      stot0      = tab_cntrl(16)
+!      ang0       = tab_cntrl(17)
+!      pa         = tab_cntrl(18)
+!      preff      = tab_cntrl(19)
+!
+!      clon       = tab_cntrl(20)
+!      clat       = tab_cntrl(21)
+!      grossismx  = tab_cntrl(22)
+!      grossismy  = tab_cntrl(23)
+!
+      IF ( tab_cntrl(24).EQ.1. )  THEN
+        fxyhypb  =.true.
+!        dzoomx   = tab_cntrl(25)
+!        dzoomy   = tab_cntrl(26)
+!        taux     = tab_cntrl(28)
+!        tauy     = tab_cntrl(29)
+      ELSE
+        fxyhypb = .false.
+        ysinus  = .false.
+        IF( tab_cntrl(27).EQ.1. ) ysinus =.true. 
+      ENDIF
+
+      day_ini = tab_cntrl(30)
+      itau_dyn = tab_cntrl(31)
+!   .................................................................
+!
+!
+!      PRINT*,'rad,omeg,g,cpp,kappa',rad,omeg,g,cpp,kappa
+!Al1
+       Print*,'day_ref,annee_ref,day_ini,itau_dyn',                         &
+     &              day_ref,annee_ref,day_ini,itau_dyn
+
+!  Lecture des champs
+!
+      plev(1,klev+1)=0.
+      CALL get_field("plev",plev,found)
+      IF (.NOT. found) PRINT*, modname//'Le champ <Plev> est absent'
+      CALL get_field("play",play,found)
+      IF (.NOT. found) PRINT*, modname//'Le champ <Play> est absent'
+      CALL get_field("phi",phi,found)
+      IF (.NOT. found) PRINT*, modname//'Le champ <Phi> est absent'
+      CALL get_field("phis",phis,found)
+      IF (.NOT. found) PRINT*, modname//'Le champ <Phis> est absent'
+      CALL get_field("presnivs",presnivs,found)
+      IF (.NOT. found) PRINT*, modname//'Le champ <Presnivs> est absent'
+      CALL get_field("ucov",ucov,found)
+      IF (.NOT. found) PRINT*, modname//'Le champ <ucov> est absent'
+      CALL get_field("vcov",vcov,found)
+      IF (.NOT. found) PRINT*, modname//'Le champ <vcov> est absent'
+      CALL get_field("temp",temp,found)
+      IF (.NOT. found) PRINT*, modname//'Le champ <temp> est absent'
+      CALL get_field("omega2",omega2,found)
+      IF (.NOT. found) PRINT*, modname//'Le champ <omega2> est absent'
+
+      Do iq=1,nqtot
+        CALL get_field("q"//nmq(iq),q(:,:,iq),found)
+        IF (.NOT.found)PRINT*, modname//'Le champ <q'//nmq//'> est absent'
+      EndDo
+
+      CALL close_startphy
+      print*,' close startphy',fichnom,play(1,1),play(1,klev),temp(1,klev)
+!
+      RETURN
+      END
+!
+! $Id: dyn1dredem.F 1279 2010/07/29 A Lahellec$
+!
+!
+      SUBROUTINE dyn1dredem(fichnom,plev,play,phi,phis,presnivs,           &
+     &                          ucov,vcov,temp,q,omega2)
+      USE dimphy
+      USE mod_grid_phy_lmdz
+      USE mod_phys_lmdz_para
+      USE phys_state_var_mod
+      USE iostart
+      USE infotrac
+      use control_mod
+
+      IMPLICIT NONE
+!=======================================================
+! Ecriture du fichier de redemarrage sous format NetCDF
+!=======================================================
+!   Declarations:
+!   -------------
+#include "dimensions.h"
+#include "comconst.h"
+#include "temps.h"
+!!#include "control.h"
+#include "logic.h"
+#include "netcdf.inc"
+
+!   Arguments:
+!   ----------
+      CHARACTER*(*) fichnom
+!Al1 plev tronque pour .nc mais plev(klev+1):=0
+      real :: plev(klon,klev),play (klon,klev),phi(klon,klev)
+      real :: presnivs(klon,klev)
+      real :: ucov(klon,klev),vcov(klon,klev),temp(klon,klev)
+      real :: q(klon,klev,nqtot)
+      real :: omega2(klon,klev),rho(klon,klev+1)
+!      real :: ug(klev),vg(klev),fcoriolis
+      real :: phis(klon) 
+
+!   Variables locales pour NetCDF:
+!   ------------------------------
+      INTEGER nid
+      INTEGER ierr
+      INTEGER iq,l
+      INTEGER length
+      PARAMETER (length = 100)
+      REAL tab_cntrl(length) ! tableau des parametres du run
+      character*4 nmq(nqtot)
+      character*20 modname
+      character*80 abort_message
+!
+      INTEGER nb
+      SAVE nb
+      DATA nb / 0 /
+
+      CALL open_restartphy(fichnom)
+      print*,'redm1 ',fichnom,klon,klev,nqtot
+      nmq(1)="vap"
+      nmq(2)="cond"
+      nmq(3)="tra1"
+      nmq(4)="tra2"
+
+      modname = 'dyn1dredem'
+      ierr = NF_OPEN(fichnom, NF_WRITE, nid)
+      IF (ierr .NE. NF_NOERR) THEN
+         abort_message="Pb. d ouverture "//fichnom
+         CALL abort_gcm('Modele 1D',abort_message,1)
+      ENDIF
+
+      DO l=1,length
+       tab_cntrl(l) = 0.
+      ENDDO
+       tab_cntrl(1)  = FLOAT(iim)
+       tab_cntrl(2)  = FLOAT(jjm)
+       tab_cntrl(3)  = FLOAT(llm)
+       tab_cntrl(4)  = FLOAT(day_ref)
+       tab_cntrl(5)  = FLOAT(annee_ref)
+       tab_cntrl(6)  = rad
+       tab_cntrl(7)  = omeg
+       tab_cntrl(8)  = g
+       tab_cntrl(9)  = cpp
+       tab_cntrl(10) = kappa
+       tab_cntrl(11) = daysec
+       tab_cntrl(12) = dtvr
+!       tab_cntrl(13) = etot0
+!       tab_cntrl(14) = ptot0
+!       tab_cntrl(15) = ztot0
+!       tab_cntrl(16) = stot0
+!       tab_cntrl(17) = ang0
+!       tab_cntrl(18) = pa
+!       tab_cntrl(19) = preff
+!
+!    .....    parametres  pour le zoom      ......   
+
+!       tab_cntrl(20)  = clon
+!       tab_cntrl(21)  = clat
+!       tab_cntrl(22)  = grossismx
+!       tab_cntrl(23)  = grossismy
+!
+      IF ( fxyhypb )   THEN
+       tab_cntrl(24) = 1.
+!       tab_cntrl(25) = dzoomx
+!       tab_cntrl(26) = dzoomy
+       tab_cntrl(27) = 0.
+!       tab_cntrl(28) = taux
+!       tab_cntrl(29) = tauy
+      ELSE
+       tab_cntrl(24) = 0.
+!       tab_cntrl(25) = dzoomx
+!       tab_cntrl(26) = dzoomy
+       tab_cntrl(27) = 0.
+       tab_cntrl(28) = 0.
+       tab_cntrl(29) = 0.
+       IF( ysinus )  tab_cntrl(27) = 1.
+      ENDIF
+!Al1 iday_end -> day_end
+       tab_cntrl(30) = FLOAT(day_end)
+       tab_cntrl(31) = FLOAT(itau_dyn + itaufin)
+!
+      CALL put_var("controle","Param. de controle Dyn1D",tab_cntrl)
+!
+
+!  Ecriture/extension de la coordonnee temps
+
+      nb = nb + 1
+
+!  Ecriture des champs
+!
+      CALL put_field("plev","p interfaces sauf la nulle",plev)
+      CALL put_field("play","",play)
+      CALL put_field("phi","geopotentielle",phi)
+      CALL put_field("phis","geopotentiell de surface",phis)
+      CALL put_field("presnivs","",presnivs)
+      CALL put_field("ucov","",ucov)
+      CALL put_field("vcov","",vcov)
+      CALL put_field("temp","",temp)
+      CALL put_field("omega2","",omega2)
+
+      Do iq=1,nqtot
+        CALL put_field("q"//nmq(iq),"eau vap ou condens et traceurs",           &
+     &                                                      q(:,:,iq))
+      EndDo
+      CALL close_restartphy
+
+!
+      RETURN
+      END
+      SUBROUTINE gr_fi_dyn(nfield,ngrid,im,jm,pfi,pdyn)
+      IMPLICIT NONE
+!=======================================================================
+!   passage d'un champ de la grille scalaire a la grille physique
+!=======================================================================
+ 
+!-----------------------------------------------------------------------
+!   declarations:
+!   -------------
+ 
+      INTEGER im,jm,ngrid,nfield
+      REAL pdyn(im,jm,nfield)
+      REAL pfi(ngrid,nfield)
+ 
+      INTEGER i,j,ifield,ig
+ 
+!-----------------------------------------------------------------------
+!   calcul:
+!   -------
+ 
+      DO ifield=1,nfield
+!   traitement des poles
+         DO i=1,im
+            pdyn(i,1,ifield)=pfi(1,ifield)
+            pdyn(i,jm,ifield)=pfi(ngrid,ifield)
+         ENDDO
+ 
+!   traitement des point normaux
+         DO j=2,jm-1
+            ig=2+(j-2)*(im-1)
+            CALL SCOPY(im-1,pfi(ig,ifield),1,pdyn(1,j,ifield),1)
+            pdyn(im,j,ifield)=pdyn(1,j,ifield)
+         ENDDO
+      ENDDO
+ 
+      RETURN
+      END
+ 
+ 
+
+      SUBROUTINE abort_gcm(modname, message, ierr)
+ 
+      USE IOIPSL
+!
+! Stops the simulation cleanly, closing files and printing various
+! comments
+!
+!  Input: modname = name of calling program
+!         message = stuff to print
+!         ierr    = severity of situation ( = 0 normal )
+ 
+      character(len=*) modname
+      integer ierr
+      character(len=*) message
+ 
+      write(*,*) 'in abort_gcm'
+      call histclo
+!     call histclo(2)
+!     call histclo(3)
+!     call histclo(4)
+!     call histclo(5)
+      write(*,*) 'out of histclo'
+      write(*,*) 'Stopping in ', modname
+      write(*,*) 'Reason = ',message
+      call getin_dump
+!
+      if (ierr .eq. 0) then
+        write(*,*) 'Everything is cool'
+      else
+        write(*,*) 'Houston, we have a problem ', ierr
+      endif
+      STOP
+      END
+      REAL FUNCTION fq_sat(kelvin, millibar)
+!
+      IMPLICIT none
+!======================================================================
+! Autheur(s): Z.X. Li (LMD/CNRS)
+! Objet: calculer la vapeur d'eau saturante (formule Centre Euro.)
+!======================================================================
+! Arguments:
+! kelvin---input-R: temperature en Kelvin
+! millibar--input-R: pression en mb
+!
+! fq_sat----output-R: vapeur d'eau saturante en kg/kg
+!======================================================================
+!
+      REAL kelvin, millibar
+!
+      REAL r2es
+      PARAMETER (r2es=611.14 *18.0153/28.9644)
+!
+      REAL r3les, r3ies, r3es
+      PARAMETER (R3LES=17.269)
+      PARAMETER (R3IES=21.875)
+!
+      REAL r4les, r4ies, r4es
+      PARAMETER (R4LES=35.86)
+      PARAMETER (R4IES=7.66)
+!
+      REAL rtt
+      PARAMETER (rtt=273.16)
+!
+      REAL retv
+      PARAMETER (retv=28.9644/18.0153 - 1.0)
+!
+      REAL zqsat
+      REAL temp, pres
+!     ------------------------------------------------------------------
+!
+!
+      temp = kelvin
+      pres = millibar * 100.0
+!      write(*,*)'kelvin,millibar=',kelvin,millibar
+!      write(*,*)'temp,pres=',temp,pres
+!
+      IF (temp .LE. rtt) THEN
+         r3es = r3ies
+         r4es = r4ies
+      ELSE
+         r3es = r3les
+         r4es = r4les
+      ENDIF
+!
+      zqsat=r2es/pres * EXP ( r3es*(temp-rtt) / (temp-r4es) )
+      zqsat=MIN(0.5,ZQSAT)
+      zqsat=zqsat/(1.-retv  *zqsat)
+!
+      fq_sat = zqsat
+!
+      RETURN
+      END
+ 
+      SUBROUTINE gr_dyn_fi(nfield,im,jm,ngrid,pdyn,pfi)
+      IMPLICIT NONE
+!=======================================================================
+!   passage d'un champ de la grille scalaire a la grille physique
+!=======================================================================
+ 
+!-----------------------------------------------------------------------
+!   declarations:
+!   -------------
+ 
+      INTEGER im,jm,ngrid,nfield
+      REAL pdyn(im,jm,nfield)
+      REAL pfi(ngrid,nfield)
+ 
+      INTEGER j,ifield,ig
+ 
+!-----------------------------------------------------------------------
+!   calcul:
+!   -------
+ 
+      IF(ngrid.NE.2+(jm-2)*(im-1).AND.ngrid.NE.1)                          &
+     &    STOP 'probleme de dim'
+!   traitement des poles
+      CALL SCOPY(nfield,pdyn,im*jm,pfi,ngrid)
+      CALL SCOPY(nfield,pdyn(1,jm,1),im*jm,pfi(ngrid,1),ngrid)
+ 
+!   traitement des point normaux
+      DO ifield=1,nfield
+         DO j=2,jm-1
+            ig=2+(j-2)*(im-1)
+            CALL SCOPY(im-1,pdyn(1,j,ifield),1,pfi(ig,ifield),1)
+         ENDDO
+      ENDDO
+ 
+      RETURN
+      END
+ 
+      SUBROUTINE disvert0(pa,preff,ap,bp,dpres,presnivs,nivsigs,nivsig)
+ 
+!    Ancienne version disvert dont on a modifie nom pour utiliser
+!    le disvert de dyn3d (qui permet d'utiliser grille avec ab,bp imposes)
+!    (MPL 18092012)
+!
+!    Auteur :  P. Le Van .
+!
+      IMPLICIT NONE
+ 
+#include "dimensions.h"
+#include "paramet.h"
+!
+!=======================================================================
+!
+!
+!    s = sigma ** kappa   :  coordonnee  verticale
+!    dsig(l)            : epaisseur de la couche l ds la coord.  s
+!    sig(l)             : sigma a l'interface des couches l et l-1
+!    ds(l)              : distance entre les couches l et l-1 en coord.s
+!
+!=======================================================================
+!
+      REAL pa,preff
+      REAL ap(llmp1),bp(llmp1),dpres(llm),nivsigs(llm),nivsig(llmp1)
+      REAL presnivs(llm)
+!
+!   declarations:
+!   -------------
+!
+      REAL sig(llm+1),dsig(llm)
+!
+      INTEGER l
+      REAL snorm
+      REAL alpha,beta,gama,delta,deltaz,h
+      INTEGER np,ierr
+      REAL pi,x
+      REAL :: scaleheight=8.
+ 
+!-----------------------------------------------------------------------
+!
+      pi=2.*ASIN(1.)
+ 
+      OPEN(99,file='sigma.def',status='old',form='formatted',                   &
+     &   iostat=ierr)
+ 
+!-----------------------------------------------------------------------
+!   cas 1 on lit les options dans sigma.def:
+!   ----------------------------------------
+ 
+      IF (ierr.eq.0) THEN
+ 
+      print*,'WARNING!!! on lit les options dans sigma.def'
+      READ(99,*) deltaz
+      READ(99,*) h
+      READ(99,*) beta
+      READ(99,*) gama
+      READ(99,*) delta
+      READ(99,*) np
+      CLOSE(99)
+      alpha=deltaz/(llm*h)
+!
+ 
+       DO 1  l = 1, llm
+       dsig(l) = (alpha+(1.-alpha)*exp(-beta*(llm-l)))*                    &
+     &          ( (tanh(gama*l)/tanh(gama*llm))**np +                      &
+     &            (1.-l/FLOAT(llm))*delta )
+   1   CONTINUE
+ 
+       sig(1)=1.
+       DO 101 l=1,llm-1
+          sig(l+1)=sig(l)*(1.-dsig(l))/(1.+dsig(l))
+101    CONTINUE
+       sig(llm+1)=0.
+ 
+       DO 2  l = 1, llm
+       dsig(l) = sig(l)-sig(l+1)
+   2   CONTINUE
+!
+ 
+      ELSE
+!-----------------------------------------------------------------------
+!   cas 2 ancienne discretisation (LMD5...):
+!   ----------------------------------------
+ 
+      PRINT*,'WARNING!!! Ancienne discretisation verticale'
+ 
+      h=7.
+      snorm  = 0.
+      DO l = 1, llm
+         x = 2.*asin(1.) * (FLOAT(l)-0.5) / float(llm+1)
+         dsig(l) = 1.0 + 7.0 * SIN(x)**2
+         snorm = snorm + dsig(l)
+      ENDDO
+      snorm = 1./snorm
+      DO l = 1, llm
+         dsig(l) = dsig(l)*snorm
+      ENDDO
+      sig(llm+1) = 0.
+      DO l = llm, 1, -1
+         sig(l) = sig(l+1) + dsig(l)
+      ENDDO
+ 
+      ENDIF
+ 
+ 
+      DO l=1,llm
+        nivsigs(l) = FLOAT(l)
+      ENDDO
+ 
+      DO l=1,llmp1
+        nivsig(l)= FLOAT(l)
+      ENDDO
+ 
+!
+!    ....  Calculs  de ap(l) et de bp(l)  ....
+!    .........................................
+!
+!
+!   .....  pa et preff sont lus  sur les fichiers start par lectba  .....
+!
+ 
+      bp(llmp1) =   0.
+ 
+      DO l = 1, llm
+!c
+!cc    ap(l) = 0.
+!cc    bp(l) = sig(l)
+ 
+      bp(l) = EXP( 1. -1./( sig(l)*sig(l)) )
+      ap(l) = pa * ( sig(l) - bp(l) )
+!
+      ENDDO
+      ap(llmp1) = pa * ( sig(llmp1) - bp(llmp1) )
+ 
+      PRINT *,' BP '
+      PRINT *,  bp
+      PRINT *,' AP '
+      PRINT *,  ap
+ 
+   print*,'scaleheight=',scaleheight
+  DO l = 1, llm
+     dpres(l) = bp(l) - bp(l+1)
+     presnivs(l) = 0.5 *( ap(l)+bp(l)*preff + ap(l+1)+bp(l+1)*preff )
+     write(*, *)'PRESNIVS(', l, ')=', presnivs(l), ' Z ~ ', &
+          log(preff/presnivs(l))*scaleheight &
+          , ' DZ ~ ', scaleheight*log((ap(l)+bp(l)*preff)/ &
+          max(ap(l+1)+bp(l+1)*preff, 1.e-10))
+  ENDDO
+
+ 
+      PRINT *,' PRESNIVS '
+      PRINT *,presnivs
+ 
+      RETURN
+      END
+
+!======================================================================
+       SUBROUTINE read_tsurf1d(knon,sst_out)
+
+! This subroutine specifies the surface temperature to be used in 1D simulations
+
+      USE dimphy, ONLY : klon
+
+      INTEGER, INTENT(IN)                  :: knon     ! nomber of points on compressed grid
+      REAL, DIMENSION(klon), INTENT(OUT)   :: sst_out  ! tsurf used to force the single-column model
+
+       INTEGER :: i
+! COMMON defined in lmdz1d.F:
+       real ts_cur
+       common /sst_forcing/ts_cur
+
+       DO i = 1, knon
+        sst_out(i) = ts_cur
+       ENDDO
+
+      END SUBROUTINE read_tsurf1d
+
+!===============================================================
+      subroutine advect_vert(llm,w,dt,q,plev)
+!===============================================================
+!   Schema amont pour l'advection verticale en 1D
+!   w est la vitesse verticale dp/dt en Pa/s
+!   Traitement en volumes finis 
+!   d / dt ( zm q ) = delta_z ( omega q )
+!   d / dt ( zm ) = delta_z ( omega )
+!   avec zm = delta_z ( p )
+!   si * designe la valeur au pas de temps t+dt
+!   zm*(l) q*(l) - zm(l) q(l) = w(l+1) q(l+1) - w(l) q(l)
+!   zm*(l) -zm(l) = w(l+1) - w(l)
+!   avec w=omega * dt
+!---------------------------------------------------------------
+      implicit none
+! arguments
+      integer llm
+      real w(llm+1),q(llm),plev(llm+1),dt
+
+! local
+      integer l
+      real zwq(llm+1),zm(llm+1),zw(llm+1)
+      real qold
+
+!---------------------------------------------------------------
+
+      do l=1,llm
+         zw(l)=dt*w(l)
+         zm(l)=plev(l)-plev(l+1)
+         zwq(l)=q(l)*zw(l)
+      enddo
+      zwq(llm+1)=0.
+      zw(llm+1)=0.
+ 
+      do l=1,llm
+         qold=q(l)
+         q(l)=(q(l)*zm(l)+zwq(l+1)-zwq(l))/(zm(l)+zw(l+1)-zw(l))
+         print*,'ADV Q ',zm(l),zw(l),zwq(l),qold,q(l)
+      enddo
+
+ 
+      return
+      end
+
+!===============================================================
+
+
+       SUBROUTINE advect_va(llm,omega,d_t_va,d_q_va,d_u_va,d_v_va,              &
+     &                q,temp,u,v,play)
+!itlmd 
+!----------------------------------------------------------------------
+!   Calcul de l'advection verticale (ascendance et subsidence) de 
+!   température et d'humidité. Hypothèse : ce qui rentre de l'extérieur
+!   a les mêmes caractéristiques que l'air de la colonne 1D (WTG) ou 
+!   sans WTG rajouter une advection horizontale 
+!----------------------------------------------------------------------  
+        implicit none
+#include "YOMCST.h"
+!        argument
+        integer llm
+        real  omega(llm+1),d_t_va(llm), d_q_va(llm,3)
+        real  d_u_va(llm), d_v_va(llm)
+        real  q(llm,3),temp(llm)
+        real  u(llm),v(llm)
+        real  play(llm)
+! interne
+        integer l
+        real alpha,omgdown,omgup
+
+      do l= 1,llm
+       if(l.eq.1) then
+!si omgup pour la couche 1, alors tendance nulle
+        omgdown=max(omega(2),0.0)
+        alpha = rkappa*temp(l)*(1.+q(l,1)*rv/rd)/(play(l)*(1.+q(l,1)))
+        d_t_va(l)= alpha*(omgdown)-omgdown*(temp(l)-temp(l+1))             &
+     &       /(play(l)-play(l+1))
+
+        d_q_va(l,:)= -omgdown*(q(l,:)-q(l+1,:))/(play(l)-play(l+1))              
+
+        d_u_va(l)= -omgdown*(u(l)-u(l+1))/(play(l)-play(l+1))              
+        d_v_va(l)= -omgdown*(v(l)-v(l+1))/(play(l)-play(l+1))              
+
+        
+       elseif(l.eq.llm) then
+        omgup=min(omega(l),0.0)
+        alpha = rkappa*temp(l)*(1.+q(l,1)*rv/rd)/(play(l)*(1.+q(l,1)))
+        d_t_va(l)= alpha*(omgup)-                                          &
+
+!bug?     &              omgup*(temp(l-1)-temp(l))/(play(l-1)-plev(l))
+     &              omgup*(temp(l-1)-temp(l))/(play(l-1)-play(l))
+        d_q_va(l,:)= -omgup*(q(l-1,:)-q(l,:))/(play(l-1)-play(l))
+        d_u_va(l)= -omgup*(u(l-1)-u(l))/(play(l-1)-play(l))
+        d_v_va(l)= -omgup*(v(l-1)-v(l))/(play(l-1)-play(l))
+       
+       else
+        omgup=min(omega(l),0.0)
+        omgdown=max(omega(l+1),0.0)
+        alpha = rkappa*temp(l)*(1.+q(l,1)*rv/rd)/(play(l)*(1.+q(l,1)))
+        d_t_va(l)= alpha*(omgup+omgdown)-omgdown*(temp(l)-temp(l+1))       &
+     &              /(play(l)-play(l+1))-                                  &
+!bug?     &              omgup*(temp(l-1)-temp(l))/(play(l-1)-plev(l))
+     &              omgup*(temp(l-1)-temp(l))/(play(l-1)-play(l))
+!      print*, '  ??? '
+
+        d_q_va(l,:)= -omgdown*(q(l,:)-q(l+1,:))                            &
+     &              /(play(l)-play(l+1))-                                  &
+     &              omgup*(q(l-1,:)-q(l,:))/(play(l-1)-play(l)) 
+        d_u_va(l)= -omgdown*(u(l)-u(l+1))                                  &
+     &              /(play(l)-play(l+1))-                                  &
+     &              omgup*(u(l-1)-u(l))/(play(l-1)-play(l)) 
+        d_v_va(l)= -omgdown*(v(l)-v(l+1))                                  &
+     &              /(play(l)-play(l+1))-                                  &
+     &              omgup*(v(l-1)-v(l))/(play(l-1)-play(l))
+       
+      endif
+         
+      enddo
+!fin itlmd
+        return
+        end
+!       SUBROUTINE lstendH(llm,omega,d_t_va,d_q_va,d_u_va,d_v_va,
+       SUBROUTINE lstendH(llm,nqtot,omega,d_t_va,d_q_va,                        &
+     &                q,temp,u,v,play)
+!itlmd 
+!----------------------------------------------------------------------
+!   Calcul de l'advection verticale (ascendance et subsidence) de 
+!   température et d'humidité. Hypothèse : ce qui rentre de l'extérieur
+!   a les mêmes caractéristiques que l'air de la colonne 1D (WTG) ou 
+!   sans WTG rajouter une advection horizontale 
+!----------------------------------------------------------------------  
+        implicit none
+#include "YOMCST.h"
+!        argument
+        integer llm,nqtot
+        real  omega(llm+1),d_t_va(llm), d_q_va(llm,nqtot)
+!        real  d_u_va(llm), d_v_va(llm)
+        real  q(llm,nqtot),temp(llm)
+        real  u(llm),v(llm)
+        real  play(llm)
+        real cor(llm)
+!        real dph(llm),dudp(llm),dvdp(llm),dqdp(llm),dtdp(llm)
+        real dph(llm),dqdp(llm),dtdp(llm)
+! interne
+        integer k
+        real omdn,omup
+
+!        dudp=0.
+!        dvdp=0.
+        dqdp=0.
+        dtdp=0.
+!        d_u_va=0.
+!        d_v_va=0.
+
+      cor(:) = rkappa*temp*(1.+q(:,1)*rv/rd)/(play*(1.+q(:,1)))
+
+
+      do k=2,llm-1
+
+       dph  (k-1) = (play(k  )- play(k-1  ))
+!       dudp (k-1) = (u   (k  )- u   (k-1  ))/dph(k-1)
+!       dvdp (k-1) = (v   (k  )- v   (k-1  ))/dph(k-1)
+       dqdp (k-1) = (q   (k,1)- q   (k-1,1))/dph(k-1)
+       dtdp (k-1) = (temp(k  )- temp(k-1  ))/dph(k-1)
+
+      enddo
+
+!      dudp (  llm  ) = dudp ( llm-1 )
+!      dvdp (  llm  ) = dvdp ( llm-1 )
+      dqdp (  llm  ) = dqdp ( llm-1 )
+      dtdp (  llm  ) = dtdp ( llm-1 )
+
+      do k=2,llm-1
+      omdn=max(0.0,omega(k+1))
+      omup=min(0.0,omega( k ))
+
+!      d_u_va(k)  = -omdn*dudp(k)-omup*dudp(k-1)
+!      d_v_va(k)  = -omdn*dvdp(k)-omup*dvdp(k-1)
+      d_q_va(k,1)= -omdn*dqdp(k)-omup*dqdp(k-1)
+      d_t_va(k)  = -omdn*dtdp(k)-omup*dtdp(k-1)+(omup+omdn)*cor(k)
+      enddo
+
+      omdn=max(0.0,omega( 2 ))
+      omup=min(0.0,omega(llm))
+!      d_u_va( 1 )   = -omdn*dudp( 1 )
+!      d_u_va(llm)   = -omup*dudp(llm)
+!      d_v_va( 1 )   = -omdn*dvdp( 1 )
+!      d_v_va(llm)   = -omup*dvdp(llm)
+      d_q_va( 1 ,1) = -omdn*dqdp( 1 )
+      d_q_va(llm,1) = -omup*dqdp(llm)
+      d_t_va( 1 )   = -omdn*dtdp( 1 )+omdn*cor( 1 )
+      d_t_va(llm)   = -omup*dtdp(llm)!+omup*cor(llm)
+
+!      if(abs(rlat(1))>10.) then
+!     Calculate the tendency due agestrophic motions
+!      du_age = fcoriolis*(v-vg)
+!      dv_age = fcoriolis*(ug-u)
+!      endif
+
+!       call writefield_phy('d_t_va',d_t_va,llm)
+
+          return
+         end
+
+!======================================================================
+      SUBROUTINE read_togacoare(fich_toga,nlev_toga,nt_toga                     &
+     &             ,ts_toga,plev_toga,t_toga,q_toga,u_toga,v_toga,w_toga        &
+     &             ,ht_toga,vt_toga,hq_toga,vq_toga)
+      implicit none
+
+!-------------------------------------------------------------------------
+! Read TOGA-COARE forcing data 
+!-------------------------------------------------------------------------
+
+      integer nlev_toga,nt_toga
+      real ts_toga(nt_toga),plev_toga(nlev_toga,nt_toga)
+      real t_toga(nlev_toga,nt_toga),q_toga(nlev_toga,nt_toga)
+      real u_toga(nlev_toga,nt_toga),v_toga(nlev_toga,nt_toga)
+      real w_toga(nlev_toga,nt_toga)
+      real ht_toga(nlev_toga,nt_toga),vt_toga(nlev_toga,nt_toga)
+      real hq_toga(nlev_toga,nt_toga),vq_toga(nlev_toga,nt_toga)
+      character*80 fich_toga
+
+      integer k,ip
+      real bid
+
+      integer iy,im,id,ih
+      
+       real plev_min
+
+       plev_min = 55.  ! pas de tendance de vap. d eau au-dessus de 55 hPa
+
+      open(21,file=trim(fich_toga),form='formatted')
+      read(21,'(a)') 
+      do ip = 1, nt_toga
+      read(21,'(a)') 
+      read(21,'(a)') 
+      read(21,223) iy, im, id, ih, bid, ts_toga(ip), bid,bid,bid,bid
+      read(21,'(a)') 
+      read(21,'(a)') 
+
+       do k = 1, nlev_toga
+         read(21,230) plev_toga(k,ip), t_toga(k,ip), q_toga(k,ip)          &
+     &       ,u_toga(k,ip), v_toga(k,ip), w_toga(k,ip)                     &
+     &       ,ht_toga(k,ip), vt_toga(k,ip), hq_toga(k,ip), vq_toga(k,ip)
+
+! conversion in SI units:
+         t_toga(k,ip)=t_toga(k,ip)+273.15     ! K
+         q_toga(k,ip)=q_toga(k,ip)*0.001      ! kg/kg
+         w_toga(k,ip)=w_toga(k,ip)*100./3600. ! Pa/s
+! no water vapour tendency above 55 hPa
+         if (plev_toga(k,ip) .lt. plev_min) then
+          q_toga(k,ip) = 0.
+          hq_toga(k,ip) = 0.
+          vq_toga(k,ip) =0.
+         endif
+       enddo
+
+         ts_toga(ip)=ts_toga(ip)+273.15       ! K
+       enddo
+       close(21)
+
+  223 format(4i3,6f8.2)
+  230 format(6f9.3,4e11.3)
+
+          return
+          end
+
+!-------------------------------------------------------------------------
+      SUBROUTINE read_sandu(fich_sandu,nlev_sandu,nt_sandu,ts_sandu)
+      implicit none
+
+!-------------------------------------------------------------------------
+! Read I.SANDU case forcing data
+!-------------------------------------------------------------------------
+
+      integer nlev_sandu,nt_sandu
+      real ts_sandu(nt_sandu)
+      character*80 fich_sandu
+
+      integer ip
+      integer iy,im,id,ih
+
+      real plev_min
+
+      print*,'nlev_sandu',nlev_sandu
+      plev_min = 55000.  ! pas de tendance de vap. d eau au-dessus de 55 hPa
+
+      open(21,file=trim(fich_sandu),form='formatted')
+      read(21,'(a)')
+      do ip = 1, nt_sandu
+      read(21,'(a)')
+      read(21,'(a)')
+      read(21,223) iy, im, id, ih, ts_sandu(ip)
+      print *,'ts=',iy,im,id,ih,ip,ts_sandu(ip)
+      enddo
+      close(21)
+
+  223 format(4i3,f8.2)
+
+          return
+          end
+
+!=====================================================================
+!-------------------------------------------------------------------------
+      SUBROUTINE read_astex(fich_astex,nlev_astex,nt_astex,div_astex,      &
+     & ts_astex,ug_astex,vg_astex,ufa_astex,vfa_astex)
+      implicit none
+
+!-------------------------------------------------------------------------
+! Read Astex case forcing data
+!-------------------------------------------------------------------------
+
+      integer nlev_astex,nt_astex
+      real div_astex(nt_astex),ts_astex(nt_astex),ug_astex(nt_astex)
+      real vg_astex(nt_astex),ufa_astex(nt_astex),vfa_astex(nt_astex)
+      character*80 fich_astex
+
+      integer ip
+      integer iy,im,id,ih
+
+       real plev_min
+
+      print*,'nlev_astex',nlev_astex
+       plev_min = 55000.  ! pas de tendance de vap. d eau au-dessus de 55 hPa
+
+      open(21,file=trim(fich_astex),form='formatted')
+      read(21,'(a)')
+      read(21,'(a)')
+      do ip = 1, nt_astex
+      read(21,'(a)')
+      read(21,'(a)')
+      read(21,223) iy, im, id, ih, div_astex(ip),ts_astex(ip),             &
+     &ug_astex(ip),vg_astex(ip),ufa_astex(ip),vfa_astex(ip)
+      ts_astex(ip)=ts_astex(ip)+273.15
+      print *,'ts=',iy,im,id,ih,ip,div_astex(ip),ts_astex(ip),             &
+     &ug_astex(ip),vg_astex(ip),ufa_astex(ip),vg_astex(ip)
+      enddo
+      close(21)
+
+  223 format(4i3,e13.2,f7.2,f7.3,f7.2,f7.3,f7.2)
+
+          return
+          end
+!=====================================================================
+      subroutine read_twpice(fich_twpice,nlevel,ntime                       &
+     &     ,T_srf,plev,T,q,u,v,omega                                       &
+     &     ,T_adv_h,T_adv_v,q_adv_h,q_adv_v)
+
+!program reading forcings of the TWP-ICE experiment
+
+!      use netcdf
+
+      implicit none
+
+#include "netcdf.inc"
+
+      integer ntime,nlevel
+      integer l,k
+      character*80 :: fich_twpice
+      real*8 time(ntime)
+      real*8 lat, lon, alt, phis
+      real*8 lev(nlevel)
+      real*8 plev(nlevel,ntime)
+
+      real*8 T(nlevel,ntime)
+      real*8 q(nlevel,ntime),u(nlevel,ntime)
+      real*8 v(nlevel,ntime)
+      real*8 omega(nlevel,ntime), div(nlevel,ntime)
+      real*8 T_adv_h(nlevel,ntime)
+      real*8 T_adv_v(nlevel,ntime), q_adv_h(nlevel,ntime)
+      real*8 q_adv_v(nlevel,ntime)
+      real*8 s(nlevel,ntime), s_adv_h(nlevel,ntime)
+      real*8 s_adv_v(nlevel,ntime)
+      real*8 p_srf_aver(ntime), p_srf_center(ntime)
+      real*8 T_srf(ntime)
+
+      integer nid, ierr
+      integer nbvar3d
+      parameter(nbvar3d=20)
+      integer var3didin(nbvar3d)
+
+      ierr = NF_OPEN(fich_twpice,NF_NOWRITE,nid)
+      if (ierr.NE.NF_NOERR) then
+         write(*,*) 'ERROR: Pb opening forcings cdf file '
+         write(*,*) NF_STRERROR(ierr)
+         stop ""
+      endif
+
+      ierr=NF_INQ_VARID(nid,"lat",var3didin(1))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'lat'
+         endif
+      
+       ierr=NF_INQ_VARID(nid,"lon",var3didin(2))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'lon'
+         endif
+
+       ierr=NF_INQ_VARID(nid,"alt",var3didin(3))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'alt'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"phis",var3didin(4))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'phis'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"T",var3didin(5))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'T'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"q",var3didin(6))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'q'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"u",var3didin(7))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'u'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"v",var3didin(8))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'v'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"omega",var3didin(9))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'omega'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"div",var3didin(10))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'div'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"T_adv_h",var3didin(11))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'T_adv_h'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"T_adv_v",var3didin(12))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'T_adv_v'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"q_adv_h",var3didin(13))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'q_adv_h'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"q_adv_v",var3didin(14))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'q_adv_v'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"s",var3didin(15))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 's'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"s_adv_h",var3didin(16))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 's_adv_h'
+         endif
+    
+      ierr=NF_INQ_VARID(nid,"s_adv_v",var3didin(17))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 's_adv_v'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"p_srf_aver",var3didin(18))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'p_srf_aver'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"p_srf_center",var3didin(19))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'p_srf_center'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"T_srf",var3didin(20))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'T_srf'
+         endif
+
+!dimensions lecture
+      call catchaxis(nid,ntime,nlevel,time,lev,ierr)
+
+!pressure 
+       do l=1,ntime
+       do k=1,nlevel
+          plev(k,l)=lev(k)
+       enddo
+       enddo
+          
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(1),lat)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(1),lat)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!         write(*,*)'lecture lat ok',lat
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(2),lon)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(2),lon)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!         write(*,*)'lecture lon ok',lon
+ 
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(3),alt)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(3),alt)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture alt ok',alt
+ 
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(4),phis)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(4),phis)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture phis ok',phis
+          
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(5),T)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(5),T)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!         write(*,*)'lecture T ok'
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(6),q)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(6),q)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!         write(*,*)'lecture q ok'
+!q in kg/kg
+       do l=1,ntime
+       do k=1,nlevel
+          q(k,l)=q(k,l)/1000.
+       enddo
+       enddo
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(7),u)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(7),u)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!         write(*,*)'lecture u ok'
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(8),v)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(8),v)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!         write(*,*)'lecture v ok'
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(9),omega)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(9),omega)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!         write(*,*)'lecture omega ok'
+!omega in mb/hour
+       do l=1,ntime
+       do k=1,nlevel
+          omega(k,l)=omega(k,l)*100./3600.
+       enddo
+       enddo
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(10),div)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(10),div)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!         write(*,*)'lecture div ok'
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(11),T_adv_h)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(11),T_adv_h)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!         write(*,*)'lecture T_adv_h ok'
+!T adv in K/s
+       do l=1,ntime
+       do k=1,nlevel
+          T_adv_h(k,l)=T_adv_h(k,l)/3600.
+       enddo
+       enddo
+
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(12),T_adv_v)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(12),T_adv_v)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!         write(*,*)'lecture T_adv_v ok'
+!T adv in K/s
+       do l=1,ntime
+       do k=1,nlevel
+          T_adv_v(k,l)=T_adv_v(k,l)/3600.
+       enddo
+       enddo
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(13),q_adv_h)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(13),q_adv_h)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!         write(*,*)'lecture q_adv_h ok'
+!q adv in kg/kg/s
+       do l=1,ntime
+       do k=1,nlevel
+          q_adv_h(k,l)=q_adv_h(k,l)/1000./3600.
+       enddo
+       enddo
+
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(14),q_adv_v)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(14),q_adv_v)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!         write(*,*)'lecture q_adv_v ok'
+!q adv in kg/kg/s
+       do l=1,ntime
+       do k=1,nlevel
+          q_adv_v(k,l)=q_adv_v(k,l)/1000./3600.
+       enddo
+       enddo
+
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(15),s)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(15),s)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(16),s_adv_h)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(16),s_adv_h)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(17),s_adv_v)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(17),s_adv_v)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(18),p_srf_aver)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(18),p_srf_aver)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(19),p_srf_center)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(19),p_srf_center)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(20),T_srf)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(20),T_srf)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!         write(*,*)'lecture T_srf ok', T_srf
+
+         return 
+         end subroutine read_twpice
+!=====================================================================
+         subroutine catchaxis(nid,ttm,llm,time,lev,ierr)
+
+!         use netcdf
+
+         implicit none
+#include "netcdf.inc"
+         integer nid,ttm,llm
+         real*8 time(ttm)
+         real*8 lev(llm)
+         integer ierr
+
+         integer timevar,levvar
+         integer timelen,levlen
+         integer timedimin,levdimin
+
+! Control & lecture on dimensions
+! ===============================
+         ierr=NF_INQ_DIMID(nid,"time",timedimin)
+         ierr=NF_INQ_VARID(nid,"time",timevar)
+         if (ierr.NE.NF_NOERR) then
+            write(*,*) 'ERROR: Field <time> is missing'
+            stop ""  
+         endif
+         ierr=NF_INQ_DIMLEN(nid,timedimin,timelen)
+
+         ierr=NF_INQ_DIMID(nid,"lev",levdimin)
+         ierr=NF_INQ_VARID(nid,"lev",levvar)
+         if (ierr.NE.NF_NOERR) then
+             write(*,*) 'ERROR: Field <lev> is lacking'
+             stop "" 
+         endif
+         ierr=NF_INQ_DIMLEN(nid,levdimin,levlen)
+
+         if((timelen/=ttm).or.(levlen/=llm)) then
+            write(*,*) 'ERROR: Not the good lenght for axis'
+            write(*,*) 'longitude: ',timelen,ttm+1
+            write(*,*) 'latitude: ',levlen,llm
+            stop ""  
+         endif
+
+!#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,timevar,time)
+         ierr = NF_GET_VAR_DOUBLE(nid,levvar,lev)
+!#else
+!        ierr = NF_GET_VAR_REAL(nid,timevar,time)
+!        ierr = NF_GET_VAR_REAL(nid,levvar,lev)
+!#endif
+
+       return
+       end
+!=====================================================================
+
+       SUBROUTINE interp_sandu_vertical(play,nlev_sandu,plev_prof          &
+     &         ,t_prof,thl_prof,q_prof,u_prof,v_prof,w_prof                &
+     &         ,omega_prof,o3mmr_prof                                      &
+     &         ,t_mod,thl_mod,q_mod,u_mod,v_mod,w_mod                      &
+     &         ,omega_mod,o3mmr_mod,mxcalc)
+
+       implicit none
+
+#include "dimensions.h"
+
+!-------------------------------------------------------------------------
+! Vertical interpolation of SANDUREF forcing data onto model levels
+!-------------------------------------------------------------------------
+
+       integer nlevmax
+       parameter (nlevmax=41)
+       integer nlev_sandu,mxcalc
+!       real play(llm), plev_prof(nlevmax)
+!       real t_prof(nlevmax),q_prof(nlevmax)
+!       real u_prof(nlevmax),v_prof(nlevmax), w_prof(nlevmax)
+!       real ht_prof(nlevmax),vt_prof(nlevmax)
+!       real hq_prof(nlevmax),vq_prof(nlevmax)
+
+       real play(llm), plev_prof(nlev_sandu)
+       real t_prof(nlev_sandu),thl_prof(nlev_sandu),q_prof(nlev_sandu)
+       real u_prof(nlev_sandu),v_prof(nlev_sandu), w_prof(nlev_sandu)
+       real omega_prof(nlev_sandu),o3mmr_prof(nlev_sandu)
+
+       real t_mod(llm),thl_mod(llm),q_mod(llm)
+       real u_mod(llm),v_mod(llm), w_mod(llm)
+       real omega_mod(llm),o3mmr_mod(llm)
+
+       integer l,k,k1,k2
+       real frac,frac1,frac2,fact
+
+       do l = 1, llm
+
+        if (play(l).ge.plev_prof(nlev_sandu)) then
+
+        mxcalc=l
+         k1=0
+         k2=0
+
+         if (play(l).le.plev_prof(1)) then
+
+         do k = 1, nlev_sandu-1
+          if (play(l).le.plev_prof(k).and. play(l).gt.plev_prof(k+1)) then
+            k1=k
+            k2=k+1
+          endif
+         enddo
+
+         if (k1.eq.0 .or. k2.eq.0) then
+          write(*,*) 'PB! k1, k2 = ',k1,k2
+          write(*,*) 'l,play(l) = ',l,play(l)/100
+         do k = 1, nlev_sandu-1
+          write(*,*) 'k,plev_prof(k) = ',k,plev_prof(k)/100
+         enddo
+         endif
+
+         frac = (plev_prof(k2)-play(l))/(plev_prof(k2)-plev_prof(k1))
+         t_mod(l)= t_prof(k2) - frac*(t_prof(k2)-t_prof(k1))
+         thl_mod(l)= thl_prof(k2) - frac*(thl_prof(k2)-thl_prof(k1))
+         q_mod(l)= q_prof(k2) - frac*(q_prof(k2)-q_prof(k1))
+         u_mod(l)= u_prof(k2) - frac*(u_prof(k2)-u_prof(k1))
+         v_mod(l)= v_prof(k2) - frac*(v_prof(k2)-v_prof(k1))
+         w_mod(l)= w_prof(k2) - frac*(w_prof(k2)-w_prof(k1))
+         omega_mod(l)=omega_prof(k2)-frac*(omega_prof(k2)-omega_prof(k1))
+         o3mmr_mod(l)=o3mmr_prof(k2)-frac*(o3mmr_prof(k2)-o3mmr_prof(k1))
+
+         else !play>plev_prof(1)
+
+         k1=1
+         k2=2
+         frac1 = (play(l)-plev_prof(k2))/(plev_prof(k1)-plev_prof(k2))
+         frac2 = (play(l)-plev_prof(k1))/(plev_prof(k1)-plev_prof(k2))
+         t_mod(l)= frac1*t_prof(k1) - frac2*t_prof(k2)
+         thl_mod(l)= frac1*thl_prof(k1) - frac2*thl_prof(k2)
+         q_mod(l)= frac1*q_prof(k1) - frac2*q_prof(k2)
+         u_mod(l)= frac1*u_prof(k1) - frac2*u_prof(k2)
+         v_mod(l)= frac1*v_prof(k1) - frac2*v_prof(k2)
+         w_mod(l)= frac1*w_prof(k1) - frac2*w_prof(k2)
+         omega_mod(l)= frac1*omega_prof(k1) - frac2*omega_prof(k2)
+         o3mmr_mod(l)= frac1*o3mmr_prof(k1) - frac2*o3mmr_prof(k2)
+
+         endif ! play.le.plev_prof(1)
+
+        else ! above max altitude of forcing file
+
+!jyg
+         fact=20.*(plev_prof(nlev_sandu)-play(l))/plev_prof(nlev_sandu) !jyg
+         fact = max(fact,0.)                                           !jyg
+         fact = exp(-fact)                                             !jyg
+         t_mod(l)= t_prof(nlev_sandu)                                   !jyg
+         thl_mod(l)= thl_prof(nlev_sandu)                                   !jyg
+         q_mod(l)= q_prof(nlev_sandu)*fact                              !jyg
+         u_mod(l)= u_prof(nlev_sandu)*fact                              !jyg
+         v_mod(l)= v_prof(nlev_sandu)*fact                              !jyg
+         w_mod(l)= w_prof(nlev_sandu)*fact                              !jyg
+         omega_mod(l)= omega_prof(nlev_sandu)*fact                      !jyg
+         o3mmr_mod(l)= o3mmr_prof(nlev_sandu)*fact                      !jyg
+
+        endif ! play
+
+       enddo ! l
+
+       do l = 1,llm
+!      print *,'t_mod(l),thl_mod(l),q_mod(l),u_mod(l),v_mod(l) ',
+!    $        l,t_mod(l),thl_mod(l),q_mod(l),u_mod(l),v_mod(l)
+       enddo
+
+          return
+          end
+!=====================================================================
+       SUBROUTINE interp_astex_vertical(play,nlev_astex,plev_prof          &
+     &         ,t_prof,thl_prof,qv_prof,ql_prof,qt_prof,u_prof,v_prof      &
+     &         ,w_prof,tke_prof,o3mmr_prof                                 &
+     &         ,t_mod,thl_mod,qv_mod,ql_mod,qt_mod,u_mod,v_mod,w_mod       &
+     &         ,tke_mod,o3mmr_mod,mxcalc)
+
+       implicit none
+
+#include "dimensions.h"
+
+!-------------------------------------------------------------------------
+! Vertical interpolation of Astex forcing data onto model levels
+!-------------------------------------------------------------------------
+
+       integer nlevmax
+       parameter (nlevmax=41)
+       integer nlev_astex,mxcalc
+!       real play(llm), plev_prof(nlevmax)
+!       real t_prof(nlevmax),qv_prof(nlevmax)
+!       real u_prof(nlevmax),v_prof(nlevmax), w_prof(nlevmax)
+!       real ht_prof(nlevmax),vt_prof(nlevmax)
+!       real hq_prof(nlevmax),vq_prof(nlevmax)
+
+       real play(llm), plev_prof(nlev_astex)
+       real t_prof(nlev_astex),thl_prof(nlev_astex),qv_prof(nlev_astex)
+       real u_prof(nlev_astex),v_prof(nlev_astex), w_prof(nlev_astex)
+       real o3mmr_prof(nlev_astex),ql_prof(nlev_astex)
+       real qt_prof(nlev_astex),tke_prof(nlev_astex)
+
+       real t_mod(llm),thl_mod(llm),qv_mod(llm)
+       real u_mod(llm),v_mod(llm), w_mod(llm),tke_mod(llm)
+       real o3mmr_mod(llm),ql_mod(llm),qt_mod(llm)
+
+       integer l,k,k1,k2
+       real frac,frac1,frac2,fact
+
+       do l = 1, llm
+
+        if (play(l).ge.plev_prof(nlev_astex)) then
+
+        mxcalc=l
+         k1=0
+         k2=0
+
+         if (play(l).le.plev_prof(1)) then
+
+         do k = 1, nlev_astex-1
+          if (play(l).le.plev_prof(k).and. play(l).gt.plev_prof(k+1)) then
+            k1=k
+            k2=k+1
+          endif
+         enddo
+
+         if (k1.eq.0 .or. k2.eq.0) then
+          write(*,*) 'PB! k1, k2 = ',k1,k2
+          write(*,*) 'l,play(l) = ',l,play(l)/100
+         do k = 1, nlev_astex-1
+          write(*,*) 'k,plev_prof(k) = ',k,plev_prof(k)/100
+         enddo
+         endif
+
+         frac = (plev_prof(k2)-play(l))/(plev_prof(k2)-plev_prof(k1))
+         t_mod(l)= t_prof(k2) - frac*(t_prof(k2)-t_prof(k1))
+         thl_mod(l)= thl_prof(k2) - frac*(thl_prof(k2)-thl_prof(k1))
+         qv_mod(l)= qv_prof(k2) - frac*(qv_prof(k2)-qv_prof(k1))
+         ql_mod(l)= ql_prof(k2) - frac*(ql_prof(k2)-ql_prof(k1))
+         qt_mod(l)= qt_prof(k2) - frac*(qt_prof(k2)-qt_prof(k1))
+         u_mod(l)= u_prof(k2) - frac*(u_prof(k2)-u_prof(k1))
+         v_mod(l)= v_prof(k2) - frac*(v_prof(k2)-v_prof(k1))
+         w_mod(l)= w_prof(k2) - frac*(w_prof(k2)-w_prof(k1))
+         tke_mod(l)= tke_prof(k2) - frac*(tke_prof(k2)-tke_prof(k1))
+         o3mmr_mod(l)=o3mmr_prof(k2)-frac*(o3mmr_prof(k2)-o3mmr_prof(k1))
+
+         else !play>plev_prof(1)
+
+         k1=1
+         k2=2
+         frac1 = (play(l)-plev_prof(k2))/(plev_prof(k1)-plev_prof(k2))
+         frac2 = (play(l)-plev_prof(k1))/(plev_prof(k1)-plev_prof(k2))
+         t_mod(l)= frac1*t_prof(k1) - frac2*t_prof(k2)
+         thl_mod(l)= frac1*thl_prof(k1) - frac2*thl_prof(k2)
+         qv_mod(l)= frac1*qv_prof(k1) - frac2*qv_prof(k2)
+         ql_mod(l)= frac1*ql_prof(k1) - frac2*ql_prof(k2)
+         qt_mod(l)= frac1*qt_prof(k1) - frac2*qt_prof(k2)
+         u_mod(l)= frac1*u_prof(k1) - frac2*u_prof(k2)
+         v_mod(l)= frac1*v_prof(k1) - frac2*v_prof(k2)
+         w_mod(l)= frac1*w_prof(k1) - frac2*w_prof(k2)
+         tke_mod(l)= frac1*tke_prof(k1) - frac2*tke_prof(k2)
+         o3mmr_mod(l)= frac1*o3mmr_prof(k1) - frac2*o3mmr_prof(k2)
+
+         endif ! play.le.plev_prof(1)
+
+        else ! above max altitude of forcing file
+
+!jyg
+         fact=20.*(plev_prof(nlev_astex)-play(l))/plev_prof(nlev_astex) !jyg
+         fact = max(fact,0.)                                           !jyg
+         fact = exp(-fact)                                             !jyg
+         t_mod(l)= t_prof(nlev_astex)                                   !jyg
+         thl_mod(l)= thl_prof(nlev_astex)                                   !jyg
+         qv_mod(l)= qv_prof(nlev_astex)*fact                              !jyg
+         ql_mod(l)= ql_prof(nlev_astex)*fact                              !jyg
+         qt_mod(l)= qt_prof(nlev_astex)*fact                              !jyg
+         u_mod(l)= u_prof(nlev_astex)*fact                              !jyg
+         v_mod(l)= v_prof(nlev_astex)*fact                              !jyg
+         w_mod(l)= w_prof(nlev_astex)*fact                              !jyg
+         tke_mod(l)= tke_prof(nlev_astex)*fact                              !jyg
+         o3mmr_mod(l)= o3mmr_prof(nlev_astex)*fact                      !jyg
+
+        endif ! play
+
+       enddo ! l
+
+       do l = 1,llm
+!      print *,'t_mod(l),thl_mod(l),qv_mod(l),u_mod(l),v_mod(l) ',
+!    $        l,t_mod(l),thl_mod(l),qv_mod(l),u_mod(l),v_mod(l)
+       enddo
+
+          return
+          end
+
+!======================================================================
+      SUBROUTINE read_rico(fich_rico,nlev_rico,ps_rico,play                &
+     &             ,ts_rico,t_rico,q_rico,u_rico,v_rico,w_rico             &
+     &             ,dth_dyn,dqh_dyn)
+      implicit none
+
+!-------------------------------------------------------------------------
+! Read RICO forcing data 
+!-------------------------------------------------------------------------
+#include "dimensions.h"
+
+
+      integer nlev_rico
+      real ts_rico,ps_rico
+      real t_rico(llm),q_rico(llm)
+      real u_rico(llm),v_rico(llm)
+      real w_rico(llm)
+      real dth_dyn(llm)
+      real dqh_dyn(llm)
+      
+
+      real play(llm),zlay(llm)
+     
+
+      real prico(nlev_rico),zrico(nlev_rico)
+
+      character*80 fich_rico
+
+      integer k,l
+
+      
+      print*,fich_rico
+      open(21,file=trim(fich_rico),form='formatted')
+        do k=1,llm
+      zlay(k)=0.
+         enddo
+      
+        read(21,*) ps_rico,ts_rico
+        prico(1)=ps_rico
+        zrico(1)=0.0
+      do l=2,nlev_rico
+        read(21,*) k,prico(l),zrico(l)
+      enddo
+       close(21)
+
+      do k=1,llm
+        do l=1,80
+          if(prico(l)>play(k)) then
+              if(play(k)>prico(l+1)) then
+                zlay(k)=zrico(l)+(play(k)-prico(l)) *                      &
+     &              (zrico(l+1)-zrico(l))/(prico(l+1)-prico(l))
+              else 
+                zlay(k)=zrico(l)+(play(k)-prico(80))*                      &
+     &              (zrico(81)-zrico(80))/(prico(81)-prico(80))
+              endif
+          endif
+        enddo
+        print*,k,zlay(k)
+        ! U
+        if(0 < zlay(k) .and. zlay(k) < 4000) then
+          u_rico(k)=-9.9 + (-1.9 + 9.9)*zlay(k)/4000
+        elseif(4000 < zlay(k) .and. zlay(k) < 12000) then
+       u_rico(k)=  -1.9 + (30.0 + 1.9) /                                   &
+     &          (12000 - 4000) * (zlay(k) - 4000)
+        elseif(12000 < zlay(k) .and. zlay(k) < 13000) then
+          u_rico(k)=30.0
+        elseif(13000 < zlay(k) .and. zlay(k) < 20000) then
+          u_rico(k)=30.0 - (30.0) /                                        &
+     & (20000 - 13000) * (zlay(k) - 13000)
+        else
+          u_rico(k)=0.0
+        endif
+
+!Q_v
+        if(0 < zlay(k) .and. zlay(k) < 740) then
+          q_rico(k)=16.0 + (13.8 - 16.0) / (740) * zlay(k)
+        elseif(740 < zlay(k) .and. zlay(k) < 3260) then
+          q_rico(k)=13.8 + (2.4 - 13.8) /                                   &
+     &          (3260 - 740) * (zlay(k) - 740)
+        elseif(3260 < zlay(k) .and. zlay(k) < 4000) then
+          q_rico(k)=2.4 + (1.8 - 2.4) /                                    &
+     &               (4000 - 3260) * (zlay(k) - 3260)
+        elseif(4000 < zlay(k) .and. zlay(k) < 9000) then
+          q_rico(k)=1.8 + (0 - 1.8) /                                      &
+     &             (10000 - 4000) * (zlay(k) - 4000)
+        else
+          q_rico(k)=0.0
+        endif
+
+!T
+        if(0 < zlay(k) .and. zlay(k) < 740) then
+          t_rico(k)=299.2 + (292.0 - 299.2) / (740) * zlay(k)
+        elseif(740 < zlay(k) .and. zlay(k) < 4000) then
+          t_rico(k)=292.0 + (278.0 - 292.0) /                              &                       
+     &       (4000 - 740) * (zlay(k) - 740)
+        elseif(4000 < zlay(k) .and. zlay(k) < 15000) then
+          t_rico(k)=278.0 + (203.0 - 278.0) /                              &
+     &       (15000 - 4000) * (zlay(k) - 4000)
+        elseif(15000 < zlay(k) .and. zlay(k) < 17500) then
+          t_rico(k)=203.0 + (194.0 - 203.0) /                              & 
+     &       (17500 - 15000)* (zlay(k) - 15000)
+        elseif(17500 < zlay(k) .and. zlay(k) < 20000) then
+          t_rico(k)=194.0 + (206.0 - 194.0) /                              &
+     &       (20000 - 17500)* (zlay(k) - 17500)
+        elseif(20000 < zlay(k) .and. zlay(k) < 60000) then
+          t_rico(k)=206.0 + (270.0 - 206.0) /                              & 
+     &        (60000 - 20000)* (zlay(k) - 20000)
+        endif
+
+! W
+        if(0 < zlay(k) .and. zlay(k) < 2260 ) then
+          w_rico(k)=- (0.005/2260) * zlay(k)
+        elseif(2260 < zlay(k) .and. zlay(k) < 4000 ) then
+          w_rico(k)=- 0.005
+        elseif(4000 < zlay(k) .and. zlay(k) < 5000 ) then
+       w_rico(k)=- 0.005 + (0.005/ (5000 - 4000)) * (zlay(k) - 4000)
+        else
+          w_rico(k)=0.0
+        endif
+
+! dThrz+dTsw0+dTlw0
+        if(0 < zlay(k) .and. zlay(k) < 4000) then
+          dth_dyn(k)=- 2.51 / 86400 + (-2.18 + 2.51 )/                     &
+     &               (86400*4000) * zlay(k)
+        elseif(4000 < zlay(k) .and. zlay(k) < 5000) then
+          dth_dyn(k)=- 2.18 / 86400 + ( 2.18 ) /                           &
+     &           (86400*(5000 - 4000)) * (zlay(k) - 4000)
+        else
+          dth_dyn(k)=0.0
+        endif
+! dQhrz
+        if(0 < zlay(k) .and. zlay(k) < 3000) then
+          dqh_dyn(k)=-1.0 / 86400 + (0.345 + 1.0)/                         &
+     &                    (86400*3000) * (zlay(k))
+        elseif(3000 < zlay(k) .and. zlay(k) < 4000) then
+          dqh_dyn(k)=0.345 / 86400
+        elseif(4000 < zlay(k) .and. zlay(k) < 5000) then
+          dqh_dyn(k)=0.345 / 86400 +                                       &
+     &   (-0.345)/(86400 * (5000 - 4000)) * (zlay(k)-4000)
+        else
+          dqh_dyn(k)=0.0
+        endif
+
+!?        if(play(k)>6e4) then
+!?          ratqs0(1,k)=ratqsbas*(plev(1)-play(k))/(plev(1)-6e4)
+!?        elseif((play(k)>3e4).and.(play(k)<6e4)) then
+!?          ratqs0(1,k)=ratqsbas+(ratqshaut-ratqsbas)&
+!?                          *(6e4-play(k))/(6e4-3e4)
+!?        else
+!?          ratqs0(1,k)=ratqshaut
+!?        endif
+
+      enddo
+
+      do k=1,llm
+      q_rico(k)=q_rico(k)/1e3 
+      dqh_dyn(k)=dqh_dyn(k)/1e3
+      v_rico(k)=-3.8
+      enddo
+
+          return
+          end
+
+!======================================================================
+        SUBROUTINE interp_sandu_time(day,day1,annee_ref                    &
+     &             ,year_ini_sandu,day_ini_sandu,nt_sandu,dt_sandu         &
+     &             ,nlev_sandu,ts_sandu,ts_prof)
+        implicit none
+
+!---------------------------------------------------------------------------------------
+! Time interpolation of a 2D field to the timestep corresponding to day
+!
+! day: current julian day (e.g. 717538.2)
+! day1: first day of the simulation
+! nt_sandu: total nb of data in the forcing (e.g. 13 for Sanduref)
+! dt_sandu: total time interval (in sec) between 2 forcing data (e.g. 6h for Sanduref)
+!---------------------------------------------------------------------------------------
+! inputs:
+        integer annee_ref
+        integer nt_sandu,nlev_sandu
+        integer year_ini_sandu
+        real day, day1,day_ini_sandu,dt_sandu
+        real ts_sandu(nt_sandu)
+! outputs:
+        real ts_prof
+! local:
+        integer it_sandu1, it_sandu2
+        real timeit,time_sandu1,time_sandu2,frac
+! Check that initial day of the simulation consistent with SANDU period:
+       if (annee_ref.ne.2006 ) then
+        print*,'Pour SANDUREF, annee_ref doit etre 2006 '
+        print*,'Changer annee_ref dans run.def'
+        stop
+       endif
+!      if (annee_ref.eq.2006 .and. day1.lt.day_ini_sandu) then
+!       print*,'SANDUREF debute le 15 Juillet 2006 (jour julien=196)'
+!       print*,'Changer dayref dans run.def'
+!       stop
+!      endif
+
+! Determine timestep relative to the 1st day of TOGA-COARE:
+!       timeit=(day-day1)*86400.
+!       if (annee_ref.eq.1992) then
+!        timeit=(day-day_ini_sandu)*86400.
+!       else
+!        timeit=(day+61.-1.)*86400. ! 61 days between Nov01 and Dec31 1992
+!       endif
+      timeit=(day-day_ini_sandu)*86400
+
+! Determine the closest observation times:
+       it_sandu1=INT(timeit/dt_sandu)+1
+       it_sandu2=it_sandu1 + 1
+       time_sandu1=(it_sandu1-1)*dt_sandu
+       time_sandu2=(it_sandu2-1)*dt_sandu
+       print *,'timeit day day_ini_sandu',timeit,day,day_ini_sandu
+       print *,'it_sandu1,it_sandu2,time_sandu1,time_sandu2',              &
+     &          it_sandu1,it_sandu2,time_sandu1,time_sandu2
+
+       if (it_sandu1 .ge. nt_sandu) then
+        write(*,*) 'PB-stop: day, it_sandu1, it_sandu2, timeit: '          &
+     &        ,day,it_sandu1,it_sandu2,timeit/86400.
+        stop
+       endif
+
+! time interpolation:
+       frac=(time_sandu2-timeit)/(time_sandu2-time_sandu1)
+       frac=max(frac,0.0)
+
+       ts_prof = ts_sandu(it_sandu2)                                       &
+     &          -frac*(ts_sandu(it_sandu2)-ts_sandu(it_sandu1))
+
+         print*,                                                           &
+     &'day,annee_ref,day_ini_sandu,timeit,it_sandu1,it_sandu2,SST:',       &
+     &day,annee_ref,day_ini_sandu,timeit/86400.,it_sandu1,                  &
+     &it_sandu2,ts_prof
+
+        return
+        END
+!=====================================================================
+!-------------------------------------------------------------------------
+      SUBROUTINE read_armcu(fich_armcu,nlev_armcu,nt_armcu,                &
+     & sens,flat,adv_theta,rad_theta,adv_qt)
+      implicit none
+
+!-------------------------------------------------------------------------
+! Read ARM_CU case forcing data
+!-------------------------------------------------------------------------
+
+      integer nlev_armcu,nt_armcu
+      real sens(nt_armcu),flat(nt_armcu)
+      real adv_theta(nt_armcu),rad_theta(nt_armcu),adv_qt(nt_armcu)
+      character*80 fich_armcu
+
+      integer ip
+
+      integer iy,im,id,ih,in
+
+      print*,'nlev_armcu',nlev_armcu
+
+      open(21,file=trim(fich_armcu),form='formatted')
+      read(21,'(a)')
+      do ip = 1, nt_armcu
+      read(21,'(a)')
+      read(21,'(a)')
+      read(21,223) iy, im, id, ih, in, sens(ip),flat(ip),                  &
+     &             adv_theta(ip),rad_theta(ip),adv_qt(ip)
+      print *,'forcages=',iy,im,id,ih,in, sens(ip),flat(ip),               &
+     &             adv_theta(ip),rad_theta(ip),adv_qt(ip)
+      enddo
+      close(21)
+
+  223 format(5i3,5f8.3)
+
+          return
+          end
+
+!=====================================================================
+       SUBROUTINE interp_toga_vertical(play,nlev_toga,plev_prof            &
+     &         ,t_prof,q_prof,u_prof,v_prof,w_prof                         &
+     &         ,ht_prof,vt_prof,hq_prof,vq_prof                            &
+     &         ,t_mod,q_mod,u_mod,v_mod,w_mod                              &
+     &         ,ht_mod,vt_mod,hq_mod,vq_mod,mxcalc)
+ 
+       implicit none
+ 
+#include "dimensions.h"
+
+!-------------------------------------------------------------------------
+! Vertical interpolation of TOGA-COARE forcing data onto model levels
+!-------------------------------------------------------------------------
+ 
+       integer nlevmax
+       parameter (nlevmax=41)
+       integer nlev_toga,mxcalc
+!       real play(llm), plev_prof(nlevmax) 
+!       real t_prof(nlevmax),q_prof(nlevmax)
+!       real u_prof(nlevmax),v_prof(nlevmax), w_prof(nlevmax)
+!       real ht_prof(nlevmax),vt_prof(nlevmax)
+!       real hq_prof(nlevmax),vq_prof(nlevmax)
+ 
+       real play(llm), plev_prof(nlev_toga) 
+       real t_prof(nlev_toga),q_prof(nlev_toga)
+       real u_prof(nlev_toga),v_prof(nlev_toga), w_prof(nlev_toga)
+       real ht_prof(nlev_toga),vt_prof(nlev_toga)
+       real hq_prof(nlev_toga),vq_prof(nlev_toga)
+ 
+       real t_mod(llm),q_mod(llm)
+       real u_mod(llm),v_mod(llm), w_mod(llm)
+       real ht_mod(llm),vt_mod(llm)
+       real hq_mod(llm),vq_mod(llm)
+ 
+       integer l,k,k1,k2
+       real frac,frac1,frac2,fact
+ 
+       do l = 1, llm
+
+        if (play(l).ge.plev_prof(nlev_toga)) then
+ 
+        mxcalc=l
+         k1=0
+         k2=0
+
+         if (play(l).le.plev_prof(1)) then
+
+         do k = 1, nlev_toga-1
+          if (play(l).le.plev_prof(k).and. play(l).gt.plev_prof(k+1)) then
+            k1=k
+            k2=k+1
+          endif
+         enddo
+
+         if (k1.eq.0 .or. k2.eq.0) then
+          write(*,*) 'PB! k1, k2 = ',k1,k2
+          write(*,*) 'l,play(l) = ',l,play(l)/100
+         do k = 1, nlev_toga-1
+          write(*,*) 'k,plev_prof(k) = ',k,plev_prof(k)/100
+         enddo
+         endif
+
+         frac = (plev_prof(k2)-play(l))/(plev_prof(k2)-plev_prof(k1))
+         t_mod(l)= t_prof(k2) - frac*(t_prof(k2)-t_prof(k1))
+         q_mod(l)= q_prof(k2) - frac*(q_prof(k2)-q_prof(k1))
+         u_mod(l)= u_prof(k2) - frac*(u_prof(k2)-u_prof(k1))
+         v_mod(l)= v_prof(k2) - frac*(v_prof(k2)-v_prof(k1))
+         w_mod(l)= w_prof(k2) - frac*(w_prof(k2)-w_prof(k1))
+         ht_mod(l)= ht_prof(k2) - frac*(ht_prof(k2)-ht_prof(k1))
+         vt_mod(l)= vt_prof(k2) - frac*(vt_prof(k2)-vt_prof(k1))
+         hq_mod(l)= hq_prof(k2) - frac*(hq_prof(k2)-hq_prof(k1))
+         vq_mod(l)= vq_prof(k2) - frac*(vq_prof(k2)-vq_prof(k1))
+     
+         else !play>plev_prof(1)
+
+         k1=1
+         k2=2
+         frac1 = (play(l)-plev_prof(k2))/(plev_prof(k1)-plev_prof(k2))
+         frac2 = (play(l)-plev_prof(k1))/(plev_prof(k1)-plev_prof(k2))
+         t_mod(l)= frac1*t_prof(k1) - frac2*t_prof(k2)
+         q_mod(l)= frac1*q_prof(k1) - frac2*q_prof(k2)
+         u_mod(l)= frac1*u_prof(k1) - frac2*u_prof(k2)
+         v_mod(l)= frac1*v_prof(k1) - frac2*v_prof(k2)
+         w_mod(l)= frac1*w_prof(k1) - frac2*w_prof(k2)
+         ht_mod(l)= frac1*ht_prof(k1) - frac2*ht_prof(k2)
+         vt_mod(l)= frac1*vt_prof(k1) - frac2*vt_prof(k2)
+         hq_mod(l)= frac1*hq_prof(k1) - frac2*hq_prof(k2)
+         vq_mod(l)= frac1*vq_prof(k1) - frac2*vq_prof(k2)
+
+         endif ! play.le.plev_prof(1)
+
+        else ! above max altitude of forcing file
+ 
+!jyg
+         fact=20.*(plev_prof(nlev_toga)-play(l))/plev_prof(nlev_toga) !jyg
+         fact = max(fact,0.)                                           !jyg
+         fact = exp(-fact)                                             !jyg
+         t_mod(l)= t_prof(nlev_toga)                                   !jyg
+         q_mod(l)= q_prof(nlev_toga)*fact                              !jyg
+         u_mod(l)= u_prof(nlev_toga)*fact                              !jyg
+         v_mod(l)= v_prof(nlev_toga)*fact                              !jyg
+         w_mod(l)= 0.0                                                 !jyg
+         ht_mod(l)= ht_prof(nlev_toga)                                 !jyg
+         vt_mod(l)= vt_prof(nlev_toga)                                 !jyg
+         hq_mod(l)= hq_prof(nlev_toga)*fact                            !jyg
+         vq_mod(l)= vq_prof(nlev_toga)*fact                            !jyg
+ 
+        endif ! play
+ 
+       enddo ! l
+
+!       do l = 1,llm
+!       print *,'t_mod(l),q_mod(l),ht_mod(l),hq_mod(l) ',
+!     $        l,t_mod(l),q_mod(l),ht_mod(l),hq_mod(l)
+!       enddo
+ 
+          return
+          end
+ 
+!======================================================================
+        SUBROUTINE interp_astex_time(day,day1,annee_ref                    &
+     &             ,year_ini_astex,day_ini_astex,nt_astex,dt_astex         &
+     &             ,nlev_astex,div_astex,ts_astex,ug_astex,vg_astex        &
+     &             ,ufa_astex,vfa_astex,div_prof,ts_prof,ug_prof,vg_prof   &
+     &             ,ufa_prof,vfa_prof)
+        implicit none
+
+!---------------------------------------------------------------------------------------
+! Time interpolation of a 2D field to the timestep corresponding to day
+!
+! day: current julian day (e.g. 717538.2)
+! day1: first day of the simulation
+! nt_astex: total nb of data in the forcing (e.g. 41 for Astex)
+! dt_astex: total time interval (in sec) between 2 forcing data (e.g. 1h for Astex)
+!---------------------------------------------------------------------------------------
+
+! inputs:
+        integer annee_ref
+        integer nt_astex,nlev_astex
+        integer year_ini_astex
+        real day, day1,day_ini_astex,dt_astex
+        real div_astex(nt_astex),ts_astex(nt_astex),ug_astex(nt_astex)
+        real vg_astex(nt_astex),ufa_astex(nt_astex),vfa_astex(nt_astex)
+! outputs:
+        real div_prof,ts_prof,ug_prof,vg_prof,ufa_prof,vfa_prof
+! local:
+        integer it_astex1, it_astex2
+        real timeit,time_astex1,time_astex2,frac
+
+! Check that initial day of the simulation consistent with ASTEX period:
+       if (annee_ref.ne.1992 ) then
+        print*,'Pour Astex, annee_ref doit etre 1992 '
+        print*,'Changer annee_ref dans run.def'
+        stop
+       endif
+       if (annee_ref.eq.1992 .and. day1.lt.day_ini_astex) then
+        print*,'Astex debute le 13 Juin 1992 (jour julien=165)'
+        print*,'Changer dayref dans run.def'
+        stop
+       endif
+
+! Determine timestep relative to the 1st day of TOGA-COARE:
+!       timeit=(day-day1)*86400.
+!       if (annee_ref.eq.1992) then
+!        timeit=(day-day_ini_astex)*86400.
+!       else
+!        timeit=(day+2.-1.)*86400. ! 2 days between Jun13 and Jun15 1992
+!       endif
+      timeit=(day-day_ini_astex)*86400
+
+! Determine the closest observation times:
+       it_astex1=INT(timeit/dt_astex)+1
+       it_astex2=it_astex1 + 1
+       time_astex1=(it_astex1-1)*dt_astex
+       time_astex2=(it_astex2-1)*dt_astex
+       print *,'timeit day day_ini_astex',timeit,day,day_ini_astex
+       print *,'it_astex1,it_astex2,time_astex1,time_astex2',              &
+     &          it_astex1,it_astex2,time_astex1,time_astex2
+
+       if (it_astex1 .ge. nt_astex) then
+        write(*,*) 'PB-stop: day, it_astex1, it_astex2, timeit: '          &
+     &        ,day,it_astex1,it_astex2,timeit/86400.
+        stop
+       endif
+
+! time interpolation:
+       frac=(time_astex2-timeit)/(time_astex2-time_astex1)
+       frac=max(frac,0.0)
+
+       div_prof = div_astex(it_astex2)                                     &
+     &          -frac*(div_astex(it_astex2)-div_astex(it_astex1))
+       ts_prof = ts_astex(it_astex2)                                        &
+     &          -frac*(ts_astex(it_astex2)-ts_astex(it_astex1))
+       ug_prof = ug_astex(it_astex2)                                       &
+     &          -frac*(ug_astex(it_astex2)-ug_astex(it_astex1))
+       vg_prof = vg_astex(it_astex2)                                       &
+     &          -frac*(vg_astex(it_astex2)-vg_astex(it_astex1))
+       ufa_prof = ufa_astex(it_astex2)                                     &
+     &          -frac*(ufa_astex(it_astex2)-ufa_astex(it_astex1))
+       vfa_prof = vfa_astex(it_astex2)                                     &
+     &          -frac*(vfa_astex(it_astex2)-vfa_astex(it_astex1))
+
+         print*,                                                           &
+     &'day,annee_ref,day_ini_astex,timeit,it_astex1,it_astex2,SST:',       &
+     &day,annee_ref,day_ini_astex,timeit/86400.,it_astex1,                 &
+     &it_astex2,div_prof,ts_prof,ug_prof,vg_prof,ufa_prof,vfa_prof 
+
+        return
+        END
+
+!======================================================================
+        SUBROUTINE interp_toga_time(day,day1,annee_ref                     &
+     &             ,year_ini_toga,day_ini_toga,nt_toga,dt_toga,nlev_toga   &
+     &             ,ts_toga,plev_toga,t_toga,q_toga,u_toga,v_toga,w_toga   &
+     &             ,ht_toga,vt_toga,hq_toga,vq_toga                        &
+     &             ,ts_prof,plev_prof,t_prof,q_prof,u_prof,v_prof,w_prof   &
+     &             ,ht_prof,vt_prof,hq_prof,vq_prof)
+        implicit none
+
+!---------------------------------------------------------------------------------------
+! Time interpolation of a 2D field to the timestep corresponding to day
+!
+! day: current julian day (e.g. 717538.2)
+! day1: first day of the simulation
+! nt_toga: total nb of data in the forcing (e.g. 480 for TOGA-COARE)
+! dt_toga: total time interval (in sec) between 2 forcing data (e.g. 6h for TOGA-COARE)
+!---------------------------------------------------------------------------------------
+
+#include "compar1d.h"
+
+! inputs:
+        integer annee_ref
+        integer nt_toga,nlev_toga
+        integer year_ini_toga
+        real day, day1,day_ini_toga,dt_toga
+        real ts_toga(nt_toga)
+        real plev_toga(nlev_toga,nt_toga),t_toga(nlev_toga,nt_toga)
+        real q_toga(nlev_toga,nt_toga),u_toga(nlev_toga,nt_toga)
+        real v_toga(nlev_toga,nt_toga),w_toga(nlev_toga,nt_toga)
+        real ht_toga(nlev_toga,nt_toga),vt_toga(nlev_toga,nt_toga)
+        real hq_toga(nlev_toga,nt_toga),vq_toga(nlev_toga,nt_toga)
+! outputs:
+        real ts_prof
+        real plev_prof(nlev_toga),t_prof(nlev_toga)
+        real q_prof(nlev_toga),u_prof(nlev_toga)
+        real v_prof(nlev_toga),w_prof(nlev_toga)
+        real ht_prof(nlev_toga),vt_prof(nlev_toga)
+        real hq_prof(nlev_toga),vq_prof(nlev_toga)
+! local:
+        integer it_toga1, it_toga2,k
+        real timeit,time_toga1,time_toga2,frac
+
+
+        if (forcing_type.eq.2) then
+! Check that initial day of the simulation consistent with TOGA-COARE period:
+       if (annee_ref.ne.1992 .and. annee_ref.ne.1993) then
+        print*,'Pour TOGA-COARE, annee_ref doit etre 1992 ou 1993'
+        print*,'Changer annee_ref dans run.def'
+        stop
+       endif
+       if (annee_ref.eq.1992 .and. day1.lt.day_ini_toga) then
+        print*,'TOGA-COARE a débuté le 1er Nov 1992 (jour julien=306)'
+        print*,'Changer dayref dans run.def'
+        stop
+       endif
+       if (annee_ref.eq.1993 .and. day1.gt.day_ini_toga+119) then
+        print*,'TOGA-COARE a fini le 28 Feb 1993 (jour julien=59)'
+        print*,'Changer dayref ou nday dans run.def'
+        stop
+       endif
+
+       else if (forcing_type.eq.4) then
+
+! Check that initial day of the simulation consistent with TWP-ICE period:
+       if (annee_ref.ne.2006) then
+        print*,'Pour TWP-ICE, annee_ref doit etre 2006'
+        print*,'Changer annee_ref dans run.def'
+        stop
+       endif
+       if (annee_ref.eq.2006 .and. day1.lt.day_ini_toga) then
+        print*,'TWP-ICE a debute le 17 Jan 2006 (jour julien=17)'
+        print*,'Changer dayref dans run.def'
+        stop
+       endif
+       if (annee_ref.eq.2006 .and. day1.gt.day_ini_toga+26) then
+        print*,'TWP-ICE a fini le 12 Feb 2006 (jour julien=43)'
+        print*,'Changer dayref ou nday dans run.def'
+        stop
+       endif
+
+       endif
+
+! Determine timestep relative to the 1st day of TOGA-COARE:
+!       timeit=(day-day1)*86400.
+!       if (annee_ref.eq.1992) then
+!        timeit=(day-day_ini_toga)*86400.
+!       else
+!        timeit=(day+61.-1.)*86400. ! 61 days between Nov01 and Dec31 1992
+!       endif
+      timeit=(day-day_ini_toga)*86400
+
+! Determine the closest observation times:
+       it_toga1=INT(timeit/dt_toga)+1
+       it_toga2=it_toga1 + 1
+       time_toga1=(it_toga1-1)*dt_toga
+       time_toga2=(it_toga2-1)*dt_toga
+
+       if (it_toga1 .ge. nt_toga) then
+        write(*,*) 'PB-stop: day, it_toga1, it_toga2, timeit: '            &
+     &        ,day,it_toga1,it_toga2,timeit/86400.
+        stop
+       endif
+
+! time interpolation:
+       frac=(time_toga2-timeit)/(time_toga2-time_toga1)
+       frac=max(frac,0.0)
+
+       ts_prof = ts_toga(it_toga2)                                         &
+     &          -frac*(ts_toga(it_toga2)-ts_toga(it_toga1))
+
+!        print*,
+!     :'day,annee_ref,day_ini_toga,timeit,it_toga1,it_toga2,SST:',
+!     :day,annee_ref,day_ini_toga,timeit/86400.,it_toga1,it_toga2,ts_prof
+
+       do k=1,nlev_toga
+        plev_prof(k) = 100.*(plev_toga(k,it_toga2)                         &
+     &          -frac*(plev_toga(k,it_toga2)-plev_toga(k,it_toga1)))
+        t_prof(k) = t_toga(k,it_toga2)                                     &
+     &          -frac*(t_toga(k,it_toga2)-t_toga(k,it_toga1))
+        q_prof(k) = q_toga(k,it_toga2)                                     &
+     &          -frac*(q_toga(k,it_toga2)-q_toga(k,it_toga1))
+        u_prof(k) = u_toga(k,it_toga2)                                     &
+     &          -frac*(u_toga(k,it_toga2)-u_toga(k,it_toga1))
+        v_prof(k) = v_toga(k,it_toga2)                                     &
+     &          -frac*(v_toga(k,it_toga2)-v_toga(k,it_toga1))
+        w_prof(k) = w_toga(k,it_toga2)                                     &
+     &          -frac*(w_toga(k,it_toga2)-w_toga(k,it_toga1))
+        ht_prof(k) = ht_toga(k,it_toga2)                                   &
+     &          -frac*(ht_toga(k,it_toga2)-ht_toga(k,it_toga1))
+        vt_prof(k) = vt_toga(k,it_toga2)                                   &
+     &          -frac*(vt_toga(k,it_toga2)-vt_toga(k,it_toga1))
+        hq_prof(k) = hq_toga(k,it_toga2)                                   &
+     &          -frac*(hq_toga(k,it_toga2)-hq_toga(k,it_toga1))
+        vq_prof(k) = vq_toga(k,it_toga2)                                   &
+     &          -frac*(vq_toga(k,it_toga2)-vq_toga(k,it_toga1))
+        enddo
+
+        return
+        END
+
+!======================================================================
+        SUBROUTINE interp_armcu_time(day,day1,annee_ref                    &
+     &             ,year_ini_armcu,day_ini_armcu,nt_armcu,dt_armcu         &
+     &             ,nlev_armcu,fs_armcu,fl_armcu,at_armcu,rt_armcu         &
+     &             ,aqt_armcu,fs_prof,fl_prof,at_prof,rt_prof,aqt_prof)
+        implicit none
+
+!---------------------------------------------------------------------------------------
+! Time interpolation of a 2D field to the timestep corresponding to day
+!
+! day: current julian day (e.g. 717538.2)
+! day1: first day of the simulation
+! nt_armcu: total nb of data in the forcing (e.g. 31 for armcu)
+! dt_armcu: total time interval (in sec) between 2 forcing data (e.g. 1/2h for armcu)
+! fs= sensible flux
+! fl= latent flux
+! at,rt,aqt= advective and radiative tendencies
+!---------------------------------------------------------------------------------------
+
+! inputs:
+        integer annee_ref
+        integer nt_armcu,nlev_armcu
+        integer year_ini_armcu
+        real day, day1,day_ini_armcu,dt_armcu
+        real fs_armcu(nt_armcu),fl_armcu(nt_armcu),at_armcu(nt_armcu)
+        real rt_armcu(nt_armcu),aqt_armcu(nt_armcu)
+! outputs:
+        real fs_prof,fl_prof,at_prof,rt_prof,aqt_prof
+! local:
+        integer it_armcu1, it_armcu2,k
+        real timeit,time_armcu1,time_armcu2,frac
+
+! Check that initial day of the simulation consistent with ARMCU period:
+       if (annee_ref.ne.1997 ) then
+        print*,'Pour ARMCU, annee_ref doit etre 1997 '
+        print*,'Changer annee_ref dans run.def'
+        stop
+       endif
+
+      timeit=(day-day_ini_armcu)*86400
+
+! Determine the closest observation times:
+       it_armcu1=INT(timeit/dt_armcu)+1
+       it_armcu2=it_armcu1 + 1
+       time_armcu1=(it_armcu1-1)*dt_armcu
+       time_armcu2=(it_armcu2-1)*dt_armcu
+       print *,'timeit day day_ini_armcu',timeit,day,day_ini_armcu
+       print *,'it_armcu1,it_armcu2,time_armcu1,time_armcu2',              &
+     &          it_armcu1,it_armcu2,time_armcu1,time_armcu2
+
+       if (it_armcu1 .ge. nt_armcu) then
+        write(*,*) 'PB-stop: day, it_armcu1, it_armcu2, timeit: '          &
+     &        ,day,it_armcu1,it_armcu2,timeit/86400.
+        stop
+       endif
+
+! time interpolation:
+       frac=(time_armcu2-timeit)/(time_armcu2-time_armcu1)
+       frac=max(frac,0.0)
+
+       fs_prof = fs_armcu(it_armcu2)                                       &
+     &          -frac*(fs_armcu(it_armcu2)-fs_armcu(it_armcu1))
+       fl_prof = fl_armcu(it_armcu2)                                       &
+     &          -frac*(fl_armcu(it_armcu2)-fl_armcu(it_armcu1))
+       at_prof = at_armcu(it_armcu2)                                       &
+     &          -frac*(at_armcu(it_armcu2)-at_armcu(it_armcu1))
+       rt_prof = rt_armcu(it_armcu2)                                       &
+     &          -frac*(rt_armcu(it_armcu2)-rt_armcu(it_armcu1))
+       aqt_prof = aqt_armcu(it_armcu2)                                       &
+     &          -frac*(aqt_armcu(it_armcu2)-aqt_armcu(it_armcu1))
+
+         print*,                                                           &
+     &'day,annee_ref,day_ini_armcu,timeit,it_armcu1,it_armcu2,SST:',       &
+     &day,annee_ref,day_ini_armcu,timeit/86400.,it_armcu1,                 &
+     &it_armcu2,fs_prof,fl_prof,at_prof,rt_prof,aqt_prof
+
+        return
+        END
+
+!=====================================================================
+      subroutine readprofiles(nlev_max,kmax,ntrac,height,                  &
+     &           thlprof,qtprof,uprof,                                     &
+     &           vprof,e12prof,ugprof,vgprof,                              &
+     &           wfls,dqtdxls,dqtdyls,dqtdtls,                             &
+     &           thlpcar,tracer,nt1,nt2)
+      implicit none
+
+        integer nlev_max,kmax,kmax2,ntrac
+        logical :: llesread = .true.
+
+        real height(nlev_max),thlprof(nlev_max),qtprof(nlev_max),          &
+     &       uprof(nlev_max),vprof(nlev_max),e12prof(nlev_max),            &
+     &       ugprof(nlev_max),vgprof(nlev_max),wfls(nlev_max),             &
+     &       dqtdxls(nlev_max),dqtdyls(nlev_max),dqtdtls(nlev_max),        &
+     &           thlpcar(nlev_max),tracer(nlev_max,ntrac)
+
+        integer, parameter :: ilesfile=1
+        integer :: ierr,k,itrac,nt1,nt2
+
+        if(.not.(llesread)) return
+
+       open (ilesfile,file='prof.inp.001',status='old',iostat=ierr)
+        if (ierr /= 0) stop 'ERROR:Prof.inp does not exist'
+        read (ilesfile,*) kmax
+        do k=1,kmax
+          read (ilesfile,*) height(k),thlprof(k),qtprof (k),               &
+     &                      uprof (k),vprof  (k),e12prof(k)
+        enddo
+        close(ilesfile)
+
+       open(ilesfile,file='lscale.inp.001',status='old',iostat=ierr)
+        if (ierr /= 0) stop 'ERROR:Lscale.inp does not exist'
+        read (ilesfile,*) kmax2
+        if (kmax .ne. kmax2) then
+          print *, 'fichiers prof.inp et lscale.inp incompatibles :'
+          print *, 'nbre de niveaux : ',kmax,' et ',kmax2
+          stop 'lecture profiles'
+        endif
+        do k=1,kmax
+          read (ilesfile,*) height(k),ugprof(k),vgprof(k),wfls(k),         &
+     &                      dqtdxls(k),dqtdyls(k),dqtdtls(k),thlpcar(k)
+        end do
+        close(ilesfile)
+
+       open(ilesfile,file='trac.inp.001',status='old',iostat=ierr)
+        if (ierr /= 0) then
+            print*,'WARNING : trac.inp does not exist'
+        else
+        read (ilesfile,*) kmax2,nt1,nt2
+        if (nt2>ntrac) then
+          stop'Augmenter le nombre de traceurs dans traceur.def'
+        endif
+        if (kmax .ne. kmax2) then
+          print *, 'fichiers prof.inp et lscale.inp incompatibles :'
+          print *, 'nbre de niveaux : ',kmax,' et ',kmax2
+          stop 'lecture profiles'
+        endif
+        do k=1,kmax
+          read (ilesfile,*) height(k),(tracer(k,itrac),itrac=nt1,nt2)
+        end do
+        close(ilesfile)
+        endif
+
+        return
+        end
+!======================================================================
+      subroutine readprofile_sandu(nlev_max,kmax,height,pprof,tprof,       &
+     &       thlprof,qprof,uprof,vprof,wprof,omega,o3mmr)
+!======================================================================
+      implicit none
+
+        integer nlev_max,kmax
+        logical :: llesread = .true.
+
+        real height(nlev_max),pprof(nlev_max),tprof(nlev_max)
+        real thlprof(nlev_max)
+        real qprof(nlev_max),uprof(nlev_max),vprof(nlev_max)
+        real wprof(nlev_max),omega(nlev_max),o3mmr(nlev_max)
+
+        integer, parameter :: ilesfile=1
+        integer :: k,ierr
+
+        if(.not.(llesread)) return
+
+       open (ilesfile,file='prof.inp.001',status='old',iostat=ierr)
+        if (ierr /= 0) stop 'ERROR:Prof.inp does not exist'
+        read (ilesfile,*) kmax
+        do k=1,kmax
+          read (ilesfile,*) height(k),pprof(k),  tprof(k),thlprof(k),      &
+     &                      qprof (k),uprof(k),  vprof(k),  wprof(k),      &
+     &                      omega (k),o3mmr(k)
+        enddo
+        close(ilesfile)
+
+        return
+        end
+
+!======================================================================
+      subroutine readprofile_astex(nlev_max,kmax,height,pprof,tprof,       &
+     &    thlprof,qvprof,qlprof,qtprof,uprof,vprof,wprof,tkeprof,o3mmr)
+!======================================================================
+      implicit none
+
+        integer nlev_max,kmax
+        logical :: llesread = .true.
+
+        real height(nlev_max),pprof(nlev_max),tprof(nlev_max),             &
+     &  thlprof(nlev_max),qlprof(nlev_max),qtprof(nlev_max),               &
+     &  qvprof(nlev_max),uprof(nlev_max),vprof(nlev_max),                  &
+     &  wprof(nlev_max),tkeprof(nlev_max),o3mmr(nlev_max)
+
+        integer, parameter :: ilesfile=1
+        integer :: ierr,k
+
+        if(.not.(llesread)) return
+
+       open (ilesfile,file='prof.inp.001',status='old',iostat=ierr)
+        if (ierr /= 0) stop 'ERROR:Prof.inp does not exist'
+        read (ilesfile,*) kmax
+        do k=1,kmax
+          read (ilesfile,*) height(k),pprof(k),  tprof(k),thlprof(k),      &
+     &                qvprof (k),qlprof (k),qtprof (k),                    &
+     &                uprof(k),  vprof(k),  wprof(k),tkeprof(k),o3mmr(k)
+        enddo
+        close(ilesfile)
+
+        return
+        end
+
+
+
+!======================================================================
+      subroutine readprofile_armcu(nlev_max,kmax,height,pprof,uprof,       &
+     &       vprof,thetaprof,tprof,qvprof,rvprof,aprof,bprof)
+!======================================================================
+      implicit none
+
+        integer nlev_max,kmax
+        logical :: llesread = .true.
+
+        real height(nlev_max),pprof(nlev_max),tprof(nlev_max)
+        real thetaprof(nlev_max),rvprof(nlev_max)
+        real qvprof(nlev_max),uprof(nlev_max),vprof(nlev_max)
+        real aprof(nlev_max+1),bprof(nlev_max+1)
+
+        integer, parameter :: ilesfile=1
+        integer, parameter :: ifile=2
+        integer :: ierr,jtot,k
+
+        if(.not.(llesread)) return
+
+! Read profiles at full levels
+       IF(nlev_max.EQ.19) THEN
+       open (ilesfile,file='prof.inp.19',status='old',iostat=ierr)
+       print *,'On ouvre prof.inp.19'
+       ELSE
+       open (ilesfile,file='prof.inp.40',status='old',iostat=ierr)
+       print *,'On ouvre prof.inp.40'
+       ENDIF
+        if (ierr /= 0) stop 'ERROR:Prof.inp does not exist'
+        read (ilesfile,*) kmax
+        do k=1,kmax
+          read (ilesfile,*) height(k)    ,pprof(k),  uprof(k), vprof(k),   &
+     &                      thetaprof(k) ,tprof(k), qvprof(k),rvprof(k)
+        enddo
+        close(ilesfile)
+
+! Vertical coordinates half levels for eta-coordinates (plev = alpha + beta * psurf) 
+       IF(nlev_max.EQ.19) THEN
+       open (ifile,file='proh.inp.19',status='old',iostat=ierr)
+       print *,'On ouvre proh.inp.19'
+       if (ierr /= 0) stop 'ERROR:Proh.inp.19 does not exist'
+       ELSE
+       open (ifile,file='proh.inp.40',status='old',iostat=ierr)
+       print *,'On ouvre proh.inp.40'
+       if (ierr /= 0) stop 'ERROR:Proh.inp.40 does not exist'
+       ENDIF
+        read (ifile,*) kmax
+        do k=1,kmax
+          read (ifile,*) jtot,aprof(k),bprof(k)
+        enddo
+        close(ifile)
+
+        return
+        end
+!=====================================================================
+      subroutine read_amma(fich_amma,nlevel,ntime                          &
+     &     ,zz,pp,temp,qv,u,v,dw                                           &
+     &     ,dt,dq,sens,flat)
+
+!program reading forcings of the AMMA case study
+
+
+      implicit none
+
+#include "netcdf.inc"
+
+      integer ntime,nlevel
+      character*80 :: fich_amma
+      real*8 zz(nlevel)
+
+      real*8 temp(nlevel),pp(nlevel)
+      real*8 qv(nlevel),u(nlevel)
+      real*8 v(nlevel)
+      real*8 dw(nlevel,ntime)
+      real*8 dt(nlevel,ntime)
+      real*8 dq(nlevel,ntime)
+      real*8 flat(ntime),sens(ntime)
+
+      integer nid, ierr
+      integer nbvar3d
+      parameter(nbvar3d=30)
+      integer var3didin(nbvar3d)
+
+      ierr = NF_OPEN(fich_amma,NF_NOWRITE,nid)
+      if (ierr.NE.NF_NOERR) then
+         write(*,*) 'ERROR: Pb opening forcings nc file '
+         write(*,*) NF_STRERROR(ierr)
+         stop ""
+      endif
+
+
+       ierr=NF_INQ_VARID(nid,"zz",var3didin(1)) 
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'lev'
+         endif
+
+
+      ierr=NF_INQ_VARID(nid,"temp",var3didin(2))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'temp'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"qv",var3didin(3))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'qv'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"u",var3didin(4))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'u'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"v",var3didin(5))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'v'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"dw",var3didin(6))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'dw'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"dt",var3didin(7))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'dt'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"dq",var3didin(8))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'dq'
+         endif
+      
+      ierr=NF_INQ_VARID(nid,"sens",var3didin(9))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'sens'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"flat",var3didin(10))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'flat'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"pp",var3didin(11))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'pp'
+      endif
+
+!dimensions lecture
+!      call catchaxis(nid,ntime,nlevel,time,z,ierr)
+ 
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(1),zz)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(1),zz)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture z ok',zz
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(2),temp)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(2),temp)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture th ok',temp
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(3),qv)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(3),qv)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture qv ok',qv
+ 
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(4),u)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(4),u)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture u ok',u
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(5),v)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(5),v)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture v ok',v
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(6),dw)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(6),dw)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture w ok',dw
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(7),dt)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(7),dt)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture dt ok',dt
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(8),dq)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(8),dq)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture dq ok',dq
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(9),sens)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(9),sens)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture sens ok',sens
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(10),flat)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(10),flat)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture flat ok',flat
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(11),pp)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(11),pp)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture pp ok',pp
+
+         return 
+         end subroutine read_amma
+!======================================================================
+        SUBROUTINE interp_amma_time(day,day1,annee_ref                     &
+     &         ,year_ini_amma,day_ini_amma,nt_amma,dt_amma,nlev_amma       &
+     &         ,vitw_amma,ht_amma,hq_amma,lat_amma,sens_amma               &
+     &         ,vitw_prof,ht_prof,hq_prof,lat_prof,sens_prof)
+        implicit none
+
+!---------------------------------------------------------------------------------------
+! Time interpolation of a 2D field to the timestep corresponding to day
+!
+! day: current julian day (e.g. 717538.2)
+! day1: first day of the simulation
+! nt_amma: total nb of data in the forcing (e.g. 48 for AMMA)
+! dt_amma: total time interval (in sec) between 2 forcing data (e.g. 30min for AMMA)
+!---------------------------------------------------------------------------------------
+
+#include "compar1d.h"
+
+! inputs:
+        integer annee_ref
+        integer nt_amma,nlev_amma
+        integer year_ini_amma
+        real day, day1,day_ini_amma,dt_amma
+        real vitw_amma(nlev_amma,nt_amma)
+        real ht_amma(nlev_amma,nt_amma)
+        real hq_amma(nlev_amma,nt_amma)
+        real lat_amma(nt_amma)
+        real sens_amma(nt_amma)
+! outputs:
+        real vitw_prof(nlev_amma)
+        real ht_prof(nlev_amma)
+        real hq_prof(nlev_amma)
+        real lat_prof,sens_prof
+! local:
+        integer it_amma1, it_amma2,k
+        real timeit,time_amma1,time_amma2,frac
+
+
+        if (forcing_type.eq.6) then
+! Check that initial day of the simulation consistent with AMMA case:
+       if (annee_ref.ne.2006) then
+        print*,'Pour AMMA, annee_ref doit etre 2006'
+        print*,'Changer annee_ref dans run.def'
+        stop
+       endif
+       if (annee_ref.eq.2006 .and. day1.lt.day_ini_amma) then
+        print*,'AMMA a débuté le 10 juillet 2006',day1,day_ini_amma
+        print*,'Changer dayref dans run.def'
+        stop
+       endif
+       if (annee_ref.eq.2006 .and. day1.gt.day_ini_amma+1) then
+        print*,'AMMA a fini le 11 juillet'
+        print*,'Changer dayref ou nday dans run.def'
+        stop
+       endif
+       endif
+
+! Determine timestep relative to the 1st day of AMMA:
+!       timeit=(day-day1)*86400.
+!       if (annee_ref.eq.1992) then
+!        timeit=(day-day_ini_toga)*86400.
+!       else
+!        timeit=(day+61.-1.)*86400. ! 61 days between Nov01 and Dec31 1992
+!       endif
+      timeit=(day-day_ini_amma)*86400
+
+! Determine the closest observation times:
+!       it_amma1=INT(timeit/dt_amma)+1
+!       it_amma2=it_amma1 + 1
+!       time_amma1=(it_amma1-1)*dt_amma
+!       time_amma2=(it_amma2-1)*dt_amma
+
+       it_amma1=INT(timeit/dt_amma)+1
+       IF (it_amma1 .EQ. nt_amma) THEN
+       it_amma2=it_amma1 
+       ELSE
+       it_amma2=it_amma1 + 1
+       ENDIF
+       time_amma1=(it_amma1-1)*dt_amma
+       time_amma2=(it_amma2-1)*dt_amma
+
+       if (it_amma1 .gt. nt_amma) then
+        write(*,*) 'PB-stop: day, it_amma1, it_amma2, timeit: '            &
+     &        ,day,day_ini_amma,it_amma1,it_amma2,timeit/86400.
+        stop
+       endif
+
+! time interpolation:
+       frac=(time_amma2-timeit)/(time_amma2-time_amma1)
+       frac=max(frac,0.0)
+
+       lat_prof = lat_amma(it_amma2)                                       &
+     &          -frac*(lat_amma(it_amma2)-lat_amma(it_amma1)) 
+       sens_prof = sens_amma(it_amma2)                                     &
+     &          -frac*(sens_amma(it_amma2)-sens_amma(it_amma1))
+
+       do k=1,nlev_amma
+        vitw_prof(k) = vitw_amma(k,it_amma2)                               &
+     &          -frac*(vitw_amma(k,it_amma2)-vitw_amma(k,it_amma1))
+        ht_prof(k) = ht_amma(k,it_amma2)                                   &
+     &          -frac*(ht_amma(k,it_amma2)-ht_amma(k,it_amma1))
+        hq_prof(k) = hq_amma(k,it_amma2)                                   &
+     &          -frac*(hq_amma(k,it_amma2)-hq_amma(k,it_amma1))
+        enddo
+
+        return
+        END
+
+!=====================================================================
+      subroutine read_fire(fich_fire,nlevel,ntime                          &
+     &     ,zz,thl,qt,u,v,tke                                              &
+     &     ,ug,vg,wls,dqtdx,dqtdy,dqtdt,thl_rad)
+
+!program reading forcings of the FIRE case study
+
+
+      implicit none
+
+#include "netcdf.inc"
+
+      integer ntime,nlevel
+      character*80 :: fich_fire
+      real*8 zz(nlevel)
+
+      real*8 thl(nlevel)
+      real*8 qt(nlevel),u(nlevel)
+      real*8 v(nlevel),tke(nlevel)
+      real*8 ug(nlevel,ntime),vg(nlevel,ntime),wls(nlevel,ntime)
+      real*8 dqtdx(nlevel,ntime),dqtdy(nlevel,ntime)
+      real*8 dqtdt(nlevel,ntime),thl_rad(nlevel,ntime)
+
+      integer nid, ierr
+      integer nbvar3d
+      parameter(nbvar3d=30)
+      integer var3didin(nbvar3d)
+
+      ierr = NF_OPEN(fich_fire,NF_NOWRITE,nid)
+      if (ierr.NE.NF_NOERR) then
+         write(*,*) 'ERROR: Pb opening forcings nc file '
+         write(*,*) NF_STRERROR(ierr)
+         stop ""
+      endif
+
+
+       ierr=NF_INQ_VARID(nid,"zz",var3didin(1)) 
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'lev'
+         endif
+
+
+      ierr=NF_INQ_VARID(nid,"thetal",var3didin(2))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'temp'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"qt",var3didin(3))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'qv'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"u",var3didin(4))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'u'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"v",var3didin(5))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'v'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"tke",var3didin(6))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'tke'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"ugeo",var3didin(7))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'ug'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"vgeo",var3didin(8))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'vg'
+         endif
+      
+      ierr=NF_INQ_VARID(nid,"wls",var3didin(9))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'wls'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"dqtdx",var3didin(10))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'dqtdx'
+         endif
+
+      ierr=NF_INQ_VARID(nid,"dqtdy",var3didin(11))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'dqtdy'
+      endif
+
+      ierr=NF_INQ_VARID(nid,"dqtdt",var3didin(12))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'dqtdt'
+      endif
+
+      ierr=NF_INQ_VARID(nid,"thl_rad",var3didin(13))
+         if(ierr/=NF_NOERR) then
+           write(*,*) NF_STRERROR(ierr)
+           stop 'thl_rad'
+      endif
+!dimensions lecture
+!      call catchaxis(nid,ntime,nlevel,time,z,ierr)
+ 
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(1),zz)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(1),zz)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture z ok',zz
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(2),thl)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(2),thl)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture thl ok',thl
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(3),qt)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(3),qt)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture qt ok',qt
+ 
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(4),u)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(4),u)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture u ok',u
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(5),v)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(5),v)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture v ok',v
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(6),tke)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(6),tke)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture tke ok',tke
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(7),ug)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(7),ug)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture ug ok',ug
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(8),vg)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(8),vg)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture vg ok',vg
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(9),wls)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(9),wls)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture wls ok',wls
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(10),dqtdx)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(10),dqtdx)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture dqtdx ok',dqtdx
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(11),dqtdy)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(11),dqtdy)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture dqtdy ok',dqtdy
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(12),dqtdt)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(12),dqtdt)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture dqtdt ok',dqtdt
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(13),thl_rad)
+#else
+         ierr = NF_GET_VAR_REAL(nid,var3didin(13),thl_rad)
+#endif
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+!          write(*,*)'lecture thl_rad ok',thl_rad
+
+         return 
+         end subroutine read_fire
Index: /LMDZ5/branches/testing/libf/phylmd/1D_decl_cases.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/1D_decl_cases.h	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/1D_decl_cases.h	(revision 2056)
@@ -0,0 +1,243 @@
+! Declarations specifiques au cas Toga
+        character*80 :: fich_toga
+!        integer nlev_prof
+!        parameter (nlev_prof = 41)
+        integer nlev_toga, nt_toga
+        parameter (nlev_toga=41, nt_toga=480)
+        integer year_ini_toga, day_ini_toga, mth_ini_toga
+        real day_ju_ini_toga   ! Julian day of toga coare first day
+        parameter (year_ini_toga=1992) 
+        parameter (mth_ini_toga=11)
+        parameter (day_ini_toga=1)  !  1erNov1992
+        real dt_toga
+        parameter (dt_toga=6.*3600.)
+!!
+        integer year_print, month_print, day_print
+        real    sec_print
+!!
+        real ts_toga(nt_toga)
+        real plev_toga(nlev_toga,nt_toga),w_toga(nlev_toga,nt_toga)
+        real t_toga(nlev_toga,nt_toga),q_toga(nlev_toga,nt_toga)
+        real u_toga(nlev_toga,nt_toga),v_toga(nlev_toga,nt_toga)
+        real ht_toga(nlev_toga,nt_toga),vt_toga(nlev_toga,nt_toga)
+        real hq_toga(nlev_toga,nt_toga),vq_toga(nlev_toga,nt_toga)
+
+        real ts_prof
+        real plev_prof(nlev_toga),w_prof(nlev_toga)
+        real t_prof(nlev_toga),q_prof(nlev_toga)
+        real u_prof(nlev_toga),v_prof(nlev_toga)
+        real ht_prof(nlev_toga),vt_prof(nlev_toga)
+        real hq_prof(nlev_toga),vq_prof(nlev_toga)
+
+        real w_mod(llm), t_mod(llm),q_mod(llm)
+        real u_mod(llm),v_mod(llm), ht_mod(llm),vt_mod(llm)
+        real hq_mod(llm),vq_mod(llm),qv_mod(llm),ql_mod(llm),qt_mod(llm)
+
+        real ts_cur
+        common /sst_forcing/ts_cur ! also in read_tsurf1d.F
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! Declarations specifiques au cas RICO
+        character*80 :: fich_rico
+        integer nlev_rico
+
+        parameter (nlev_rico=81)
+        real ts_rico,ps_rico
+        real w_rico(llm)
+        real t_rico(llm),q_rico(llm)
+        real u_rico(llm),v_rico(llm)
+        real dth_rico(llm)
+        real dqh_rico(llm)
+        real du_age(llm),dv_age(llm)
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! Declarations specifiques au cas TWPice
+        character*80 :: fich_twpice
+        integer nlev_twpi, nt_twpi
+        parameter (nlev_twpi=40, nt_twpi=215)
+        integer year_ini_twpi, day_ini_twpi, mth_ini_twpi
+        real heure_ini_twpi
+        real day_ju_ini_twpi   ! Julian day of twpice first day
+        parameter (year_ini_twpi=2006) 
+        parameter (mth_ini_twpi=1)
+        parameter (day_ini_twpi=17)  ! 17 = 17Jan2006
+        parameter (heure_ini_twpi=10800.) !3h en secondes
+        real dt_twpi
+        parameter (dt_twpi=3.*3600.)
+
+        real ts_twpi(nt_twpi)
+        real plev_twpi(nlev_twpi,nt_twpi),w_twpi(nlev_twpi,nt_twpi)
+        real t_twpi(nlev_twpi,nt_twpi),q_twpi(nlev_twpi,nt_twpi)
+        real u_twpi(nlev_twpi,nt_twpi),v_twpi(nlev_twpi,nt_twpi)
+        real ht_twpi(nlev_twpi,nt_twpi),vt_twpi(nlev_twpi,nt_twpi)
+        real hq_twpi(nlev_twpi,nt_twpi),vq_twpi(nlev_twpi,nt_twpi)
+
+        real ts_proftwp
+        real plev_proftwp(nlev_twpi),w_proftwp(nlev_twpi)
+        real t_proftwp(nlev_twpi),q_proftwp(nlev_twpi)
+        real u_proftwp(nlev_twpi),v_proftwp(nlev_twpi)
+        real ht_proftwp(nlev_twpi),vt_proftwp(nlev_twpi)
+        real hq_proftwp(nlev_twpi),vq_proftwp(nlev_twpi)
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!Declarations specifiques au cas AMMA
+        character*80 :: fich_amma
+! Option du cas AMMA ou on impose la discretisation verticale (Ap,Bp)
+        integer nlev_amma, nt_amma
+!       parameter (nlev_amma=29, nt_amma=48)  ! Fleur, juillet 2012
+        parameter (nlev_amma=36, nt_amma=48)  ! Romain, octobre 2012
+!       parameter (nlev_amma=26, nt_amma=48)  ! Test MPL feverier 2013
+        integer year_ini_amma, day_ini_amma, mth_ini_amma
+        real heure_ini_amma
+        real day_ju_ini_amma   ! Julian day of amma first day
+        parameter (year_ini_amma=2006) 
+        parameter (mth_ini_amma=7)
+        parameter (day_ini_amma=10)  ! 10 = 10Juil2006
+        parameter (heure_ini_amma=0.) !0h en secondes
+        real dt_amma
+        parameter (dt_amma=1800.)
+
+!profils initiaux:
+        real plev_amma(nlev_amma)
+        
+        real z_amma(nlev_amma)
+        real th_amma(nlev_amma),q_amma(nlev_amma)
+        real u_amma(nlev_amma)
+        real v_amma(nlev_amma)
+
+        real th_ammai(nlev_amma),q_ammai(nlev_amma)
+        real u_ammai(nlev_amma)
+        real v_ammai(nlev_amma)
+        real vitw_ammai(nlev_amma) 
+        real ht_ammai(nlev_amma)
+        real hq_ammai(nlev_amma)
+        real vt_ammai(nlev_amma)
+        real vq_ammai(nlev_amma)
+        
+!forcings
+        real ht_amma(nlev_amma,nt_amma)
+        real hq_amma(nlev_amma,nt_amma)
+        real vitw_amma(nlev_amma,nt_amma)
+        real lat_amma(nt_amma),sens_amma(nt_amma)
+
+!champs interpoles
+        real vitw_profamma(nlev_amma)
+        real ht_profamma(nlev_amma)
+        real hq_profamma(nlev_amma)
+        real lat_profamma,sens_profamma
+        real vt_profamma(nlev_amma)
+        real vq_profamma(nlev_amma)
+        real th_profamma(nlev_amma)
+        real q_profamma(nlev_amma)
+        real u_profamma(nlev_amma)
+        real v_profamma(nlev_amma)
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!Declarations specifiques au cas FIRE
+        character*80 :: fich_fire
+        integer nlev_fire, nt_fire
+        parameter (nlev_fire=120, nt_fire=1)  
+        integer year_ini_fire, day_ini_fire, mth_ini_fire
+        real heure_ini_fire
+        parameter (year_ini_fire=1987) 
+        parameter (mth_ini_fire=7)
+        parameter (day_ini_fire=14)  ! 14 = 14Juil1987
+        parameter (heure_ini_fire=0.) !0h en secondes
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! Declarations specifiques au cas GCSSold
+        character*80 :: fich_gcssold_ctl
+        character*80 :: fich_gcssold_dat
+        real  ht_gcssold(llm),hq_gcssold(llm),hw_gcssold(llm)
+        real  hu_gcssold(llm)
+        real  hv_gcssold(llm)
+        real  hthturb_gcssold(llm)
+        real  hqturb_gcssold(llm)
+        real  Ts_gcssold
+        real  dtime_frcg
+        logical :: Turb_fcg_gcssold
+
+        common /turb_forcing/                                                   &
+     &  dtime_frcg,hthturb_gcssold, hqturb_gcssold,Turb_fcg_gcssold
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! Declarations specifiques au cas Arm_cu
+        character*80 :: fich_armcu
+
+
+        integer nlev_armcu, nt_armcu
+        parameter (nlev_armcu=40, nt_armcu=31)
+        integer year_ini_armcu, day_ini_armcu, mth_ini_armcu
+        real  heure_ini_armcu
+        real day_ju_ini_armcu                                ! Julian day of armcu case first day
+        parameter (year_ini_armcu=1997) 
+        parameter (mth_ini_armcu=6)
+        parameter (day_ini_armcu=21)  ! 172 = 21 juin 1997
+        parameter (heure_ini_armcu=41400)   ! 11:30 en secondes
+        real dt_armcu
+        parameter (dt_armcu=1.*1800.)   ! forcages donnes ttes les demi-heures par ifa_armcu.txt
+        real sens_armcu(nt_armcu),flat_armcu(nt_armcu)
+        real adv_theta_armcu(nt_armcu),rad_theta_armcu(nt_armcu)
+        real adv_qt_armcu(nt_armcu)
+        real theta_mod(llm),rv_mod(llm),play_mod(llm)
+! profc comme "profil armcu"
+        
+! forcages interpoles dans le temps
+        real adv_theta_prof,rad_theta_prof,adv_qt_prof
+        real sens_prof,flat_prof,fact
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! declarations specifiques au cas Sandu
+        character*80 :: fich_sandu
+!        integer nlev_prof
+!        parameter (nlev_prof = 41)
+        integer nlev_sandu, nt_sandu
+        parameter (nlev_sandu=87, nt_sandu=13)
+        integer year_ini_sandu, day_ini_sandu, mth_ini_sandu
+        real day_ju_ini_sandu                                ! Julian day of sandu case first day
+        parameter (year_ini_sandu=2006)
+        parameter (mth_ini_sandu=7)
+        parameter (day_ini_sandu=15)  ! 196 = 15 juillet 2006
+        real dt_sandu, tau_sandu
+        logical  :: trouve_700=.true.
+        parameter (dt_sandu=6.*3600.)   ! forcages donnes ttes les 6 heures par ifa_sandu.txt
+        parameter (tau_sandu=3600.)  ! temps de relaxation u,v,thetal,qt vers profil init et au dessus 700hPa
+!!
+        real ts_sandu(nt_sandu)
+! profs comme "profil sandu"
+        real plev_profs(nlev_sandu)
+        real t_profs(nlev_sandu),thl_profs(nlev_sandu)
+        real q_profs(nlev_sandu)
+        real u_profs(nlev_sandu),v_profs(nlev_sandu),w_profs(nlev_sandu)
+        real omega_profs(nlev_sandu),o3mmr_profs(nlev_sandu)
+
+        real, dimension(llm) :: relax_u,relax_v,relax_thl
+        real, dimension(llm,2) :: relax_q
+
+        real thl_mod(llm),omega_mod(llm),o3mmr_mod(llm),tke_mod(llm)
+!vertical advection computation
+        real d_t_z(llm), d_q_z(llm)
+        real d_t_dyn_z(llm), d_q_dyn_z(llm)
+        real zz(llm)
+        real zfact
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! Declarations specifiques au cas Astex
+        character*80 :: fich_astex
+        integer nlev_astex, nt_astex
+        parameter (nlev_astex=34, nt_astex=49)
+        integer year_ini_astex, day_ini_astex, mth_ini_astex
+        real day_ju_ini_astex                                ! Julian day of astex case first day
+        parameter (year_ini_astex=1992)
+        parameter (mth_ini_astex=6)
+        parameter (day_ini_astex=13)  ! 165 = 13 juin 1992
+        real dt_astex
+        parameter (dt_astex=3600.)    ! forcages donnes ttes les heures par ifa_astex.txt
+        real ts_astex(nt_astex),div_astex(nt_astex),ug_astex(nt_astex)
+        real vg_astex(nt_astex),ufa_astex(nt_astex),vfa_astex(nt_astex)
+        real div_prof,ug_prof,vg_prof,ufa_prof,vfa_prof
+! profa comme "profil astex"
+        real plev_profa(nlev_astex)
+        real t_profa(nlev_astex),thl_profa(nlev_astex)
+        real qv_profa(nlev_astex),ql_profa(nlev_astex)
+        real qt_profa(nlev_astex),o3mmr_profa(nlev_astex)
+        real u_profa(nlev_astex),v_profa(nlev_astex),w_profa(nlev_astex)
+        real tke_profa(nlev_astex)
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
Index: /LMDZ5/branches/testing/libf/phylmd/1D_interp_cases.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/1D_interp_cases.h	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/1D_interp_cases.h	(revision 2056)
@@ -0,0 +1,497 @@
+!---------------------------------------------------------------------
+! Interpolation forcing in time and onto model levels
+!---------------------------------------------------------------------
+      if (forcing_GCSSold) then
+
+       call get_uvd(it,timestep,fich_gcssold_ctl,fich_gcssold_dat,              &
+     &               ht_gcssold,hq_gcssold,hw_gcssold,                          &
+     &               hu_gcssold,hv_gcssold,                                     &
+     &               hthturb_gcssold,hqturb_gcssold,Ts_gcssold,                 &
+     &               imp_fcg_gcssold,ts_fcg_gcssold,                            &
+     &               Tp_fcg_gcssold,Turb_fcg_gcssold)
+       if (prt_level.ge.1) then
+         print *,' get_uvd -> hqturb_gcssold ',it,hqturb_gcssold
+       endif
+! large-scale forcing :
+!!!      tsurf = ts_gcssold
+      do l = 1, llm
+!       u(l) = hu_gcssold(l) !  on prescrit le vent
+!       v(l) = hv_gcssold(l)    !  on prescrit le vent
+!       omega(l) = hw_gcssold(l)
+!       rho(l)  = play(l)/(rd*temp(l)*(1.+(rv/rd-1.)*q(l,1)))
+!       omega2(l)=-rho(l)*omega(l)
+       omega(l) = hw_gcssold(l)
+       omega2(l)= omega(l)/rg*airefi ! flxmass_w calcule comme ds physiq
+
+       alpha = rd*temp(l)*(1.+(rv/rd-1.)*q(l,1))/play(l)
+       d_th_adv(l) = ht_gcssold(l)
+       d_q_adv(l,1) = hq_gcssold(l)
+       dt_cooling(l) = 0.0
+      enddo
+
+      endif ! forcing_GCSSold
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!---------------------------------------------------------------------
+! Interpolation Toga forcing 
+!---------------------------------------------------------------------
+      if (forcing_toga) then
+
+       if (prt_level.ge.1) then
+        print*,                                                             &
+     & '#### ITAP,day,day1,(day-day1)*86400,(day-day1)*86400/dt_toga=',     &
+     &    day,day1,(day-day1)*86400.,(day-day1)*86400/dt_toga
+       endif
+
+! time interpolation:
+        CALL interp_toga_time(daytime,day1,annee_ref                        &
+     &             ,year_ini_toga,day_ju_ini_toga,nt_toga,dt_toga           &
+     &             ,nlev_toga,ts_toga,plev_toga,t_toga,q_toga,u_toga        &
+     &             ,v_toga,w_toga,ht_toga,vt_toga,hq_toga,vq_toga           &
+     &             ,ts_prof,plev_prof,t_prof,q_prof,u_prof,v_prof,w_prof    &
+     &             ,ht_prof,vt_prof,hq_prof,vq_prof)
+
+        if (type_ts_forcing.eq.1) ts_cur = ts_prof ! SST used in read_tsurf1d
+
+! vertical interpolation:
+      CALL interp_toga_vertical(play,nlev_toga,plev_prof                    &
+     &         ,t_prof,q_prof,u_prof,v_prof,w_prof                          &
+     &         ,ht_prof,vt_prof,hq_prof,vq_prof                             &
+     &         ,t_mod,q_mod,u_mod,v_mod,w_mod                               &
+     &         ,ht_mod,vt_mod,hq_mod,vq_mod,mxcalc)
+
+! large-scale forcing :
+      tsurf = ts_prof
+      do l = 1, llm
+       u(l) = u_mod(l) ! sb: on prescrit le vent
+       v(l) = v_mod(l) ! sb: on prescrit le vent
+!       omega(l) = w_prof(l)
+!       rho(l)  = play(l)/(rd*temp(l)*(1.+(rv/rd-1.)*q(l,1)))
+!       omega2(l)=-rho(l)*omega(l)
+       omega(l) = w_mod(l)
+       omega2(l)= omega(l)/rg*airefi ! flxmass_w calcule comme ds physiq
+
+       alpha = rd*temp(l)*(1.+(rv/rd-1.)*q(l,1))/play(l)
+       d_th_adv(l) = alpha*omega(l)/rcpd-(ht_mod(l)+vt_mod(l))
+       d_q_adv(l,1) = -(hq_mod(l)+vq_mod(l))
+       dt_cooling(l) = 0.0
+      enddo
+
+      endif ! forcing_toga
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!---------------------------------------------------------------------
+! Interpolation forcing TWPice
+!---------------------------------------------------------------------
+      if (forcing_twpice) then
+
+        print*,                                                             &
+     & '#### ITAP,day,day1,(day-day1)*86400,(day-day1)*86400/dt_twpi=',     &
+     &    daytime,day1,(daytime-day1)*86400.,                               &
+     &    (daytime-day1)*86400/dt_twpi
+
+! time interpolation:
+        CALL interp_toga_time(daytime,day1,annee_ref                        &
+     &       ,year_ini_twpi,day_ju_ini_twpi,nt_twpi,dt_twpi,nlev_twpi       &
+     &       ,ts_twpi,plev_twpi,t_twpi,q_twpi,u_twpi,v_twpi,w_twpi          &
+     &       ,ht_twpi,vt_twpi,hq_twpi,vq_twpi                               &
+     &       ,ts_proftwp,plev_proftwp,t_proftwp,q_proftwp,u_proftwp         &
+     &       ,v_proftwp,w_proftwp                                           &
+     &       ,ht_proftwp,vt_proftwp,hq_proftwp,vq_proftwp)
+
+! vertical interpolation:
+      CALL interp_toga_vertical(play,nlev_twpi,plev_proftwp                 &
+     &         ,t_proftwp,q_proftwp,u_proftwp,v_proftwp,w_proftwp           &
+     &         ,ht_proftwp,vt_proftwp,hq_proftwp,vq_proftwp                 &
+     &         ,t_mod,q_mod,u_mod,v_mod,w_mod                               &
+     &         ,ht_mod,vt_mod,hq_mod,vq_mod,mxcalc)
+
+
+!calcul de l'advection verticale a partir du omega
+!Calcul des gradients verticaux
+!initialisation
+      d_t_z(:)=0.
+      d_q_z(:)=0.
+      d_t_dyn_z(:)=0.
+      d_q_dyn_z(:)=0.
+      DO l=2,llm-1
+       d_t_z(l)=(temp(l+1)-temp(l-1))/(play(l+1)-play(l-1))
+       d_q_z(l)=(q(l+1,1)-q(l-1,1))/(play(l+1)-play(l-1))
+      ENDDO
+      d_t_z(1)=d_t_z(2)
+      d_q_z(1)=d_q_z(2)
+      d_t_z(llm)=d_t_z(llm-1)
+      d_q_z(llm)=d_q_z(llm-1)
+
+!Calcul de l advection verticale
+      d_t_dyn_z(:)=w_mod(:)*d_t_z(:)
+      d_q_dyn_z(:)=w_mod(:)*d_q_z(:)
+
+!wind nudging above 500m with a 2h time scale
+        do l=1,llm
+        if (nudge_wind) then
+!           if (phi(l).gt.5000.) then
+        if (phi(l).gt.0.) then
+        u(l)=u(l)+timestep*(u_mod(l)-u(l))/(2.*3600.)
+        v(l)=v(l)+timestep*(v_mod(l)-v(l))/(2.*3600.)
+           endif    
+        else
+        u(l) = u_mod(l) 
+        v(l) = v_mod(l)
+        endif
+        enddo
+
+!CR:nudging of q and theta with a 6h time scale above 15km
+        if (nudge_thermo) then
+        do l=1,llm
+           zz(l)=phi(l)/9.8
+           if ((zz(l).le.16000.).and.(zz(l).gt.15000.)) then
+             zfact=(zz(l)-15000.)/1000.
+        q(l,1)=q(l,1)+timestep*(q_mod(l)-q(l,1))/(6.*3600.)*zfact
+        temp(l)=temp(l)+timestep*(t_mod(l)-temp(l))/(6.*3600.)*zfact
+           else if (zz(l).gt.16000.) then 
+        q(l,1)=q(l,1)+timestep*(q_mod(l)-q(l,1))/(6.*3600.)
+        temp(l)=temp(l)+timestep*(t_mod(l)-temp(l))/(6.*3600.)
+           endif
+        enddo    
+        endif
+
+      do l = 1, llm
+       omega(l) = w_mod(l)
+       omega2(l)= omega(l)/rg*airefi ! flxmass_w calcule comme ds physiq
+       alpha = rd*temp(l)*(1.+(rv/rd-1.)*q(l,1))/play(l)
+!calcul de l'advection totale
+        if (cptadvw) then
+        d_th_adv(l) = alpha*omega(l)/rcpd+ht_mod(l)-d_t_dyn_z(l)
+!        print*,'temp vert adv',l,ht_mod(l),vt_mod(l),-d_t_dyn_z(l)
+        d_q_adv(l,1) = hq_mod(l)-d_q_dyn_z(l)
+!        print*,'q vert adv',l,hq_mod(l),vq_mod(l),-d_q_dyn_z(l)
+        else
+        d_th_adv(l) = alpha*omega(l)/rcpd+(ht_mod(l)+vt_mod(l))
+        d_q_adv(l,1) = (hq_mod(l)+vq_mod(l))
+        endif
+       dt_cooling(l) = 0.0
+      enddo
+
+      endif ! forcing_twpice
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!---------------------------------------------------------------------
+! Interpolation forcing AMMA
+!---------------------------------------------------------------------
+
+       if (forcing_amma) then
+
+        print*,                                                             &
+     & '#### ITAP,day,day1,(day-day1)*86400,(day-day1)*86400/dt_amma=',     &
+     &    daytime,day1,(daytime-day1)*86400.,                               &
+     &    (daytime-day1)*86400/dt_amma
+
+! time interpolation using TOGA interpolation routine
+        CALL interp_amma_time(daytime,day1,annee_ref                        &
+     &       ,year_ini_amma,day_ju_ini_amma,nt_amma,dt_amma,nlev_amma       &
+     &       ,vitw_amma,ht_amma,hq_amma,lat_amma,sens_amma                  &
+     &       ,vitw_profamma,ht_profamma,hq_profamma,lat_profamma            &
+     &       ,sens_profamma)
+
+      print*,'apres interpolation temporelle AMMA'
+
+      do k=1,nlev_amma
+         th_profamma(k)=0.
+         q_profamma(k)=0.
+         u_profamma(k)=0.
+         v_profamma(k)=0.
+         vt_profamma(k)=0.
+         vq_profamma(k)=0.
+       enddo
+! vertical interpolation using TOGA interpolation routine:
+!      write(*,*)'avant interp vert', t_proftwp
+      CALL interp_toga_vertical(play,nlev_amma,plev_amma                      &
+     &         ,th_profamma,q_profamma,u_profamma,v_profamma                 &
+     &         ,vitw_profamma                                               &
+     &         ,ht_profamma,vt_profamma,hq_profamma,vq_profamma             &
+     &         ,t_mod,q_mod,u_mod,v_mod,w_mod                               &
+     &         ,ht_mod,vt_mod,hq_mod,vq_mod,mxcalc)
+       write(*,*) 'Profil initial forcing AMMA interpole'
+
+
+!calcul de l'advection verticale a partir du omega
+!Calcul des gradients verticaux
+!initialisation
+      do l=1,llm
+      d_t_z(l)=0.
+      d_q_z(l)=0.
+      enddo
+
+      DO l=2,llm-1
+       d_t_z(l)=(temp(l+1)-temp(l-1))/(play(l+1)-play(l-1))
+       d_q_z(l)=(q(l+1,1)-q(l-1,1))/(play(l+1)-play(l-1))
+      ENDDO
+      d_t_z(1)=d_t_z(2)
+      d_q_z(1)=d_q_z(2)
+      d_t_z(llm)=d_t_z(llm-1)
+      d_q_z(llm)=d_q_z(llm-1)
+
+
+      do l = 1, llm
+       rho(l)  = play(l)/(rd*temp(l)*(1.+(rv/rd-1.)*q(l,1)))
+       omega(l) = w_mod(l)*(-rg*rho(l))
+       omega2(l)= omega(l)/rg*airefi ! flxmass_w calcule comme ds physiq
+       alpha = rd*temp(l)*(1.+(rv/rd-1.)*q(l,1))/play(l)
+!calcul de l'advection totale
+!        d_th_adv(l) = alpha*omega(l)/rcpd+ht_mod(l)-omega(l)*d_t_z(l)
+!attention: on impose dth
+        d_th_adv(l) = alpha*omega(l)/rcpd+                                  &
+     &         ht_mod(l)*(play(l)/pzero)**rkappa-omega(l)*d_t_z(l)
+!        d_th_adv(l) = 0.
+!        print*,'temp vert adv',l,ht_mod(l),vt_mod(l),-d_t_dyn_z(l)
+        d_q_adv(l,1) = hq_mod(l)-omega(l)*d_q_z(l)
+!        d_q_adv(l,1) = 0.
+!        print*,'q vert adv',l,hq_mod(l),vq_mod(l),-d_q_dyn_z(l)
+   
+       dt_cooling(l) = 0.0
+      enddo
+
+
+!     ok_flux_surf=.false.
+      fsens=-1.*sens_profamma
+      flat=-1.*lat_profamma
+
+      endif ! forcing_amma
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!---------------------------------------------------------------------
+! Interpolation forcing Rico
+!---------------------------------------------------------------------
+      if (forcing_rico) then
+!       call lstendH(llm,omega,dt_dyn,dq_dyn,du_dyn, dv_dyn,
+!     :  q,temp,u,v,play)
+       call lstendH(llm,nqtot,omega,dt_dyn,dq_dyn,q,temp,u,v,play)
+
+        do l=1,llm
+       d_th_adv(l) =  (dth_rico(l) +  dt_dyn(l))
+       d_q_adv(l,1) = (dqh_rico(l) +  dq_dyn(l,1))
+       d_q_adv(l,2) = 0.
+        enddo
+      endif  ! forcing_rico
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!---------------------------------------------------------------------
+! Interpolation forcing Arm_cu
+!---------------------------------------------------------------------
+      if (forcing_armcu) then
+
+        print*,                                                             &
+     & '#### ITAP,day,day1,(day-day1)*86400,(day-day1)*86400/dt_armcu=',    &
+     &    day,day1,(day-day1)*86400.,(day-day1)*86400/dt_armcu
+
+! time interpolation:
+! ATTENTION, cet appel ne convient pas pour TOGA !!
+! revoir 1DUTILS.h et les arguments
+      CALL interp_armcu_time(daytime,day1,annee_ref                         &
+     &            ,year_ini_armcu,day_ju_ini_armcu,nt_armcu,dt_armcu        &
+     &            ,nlev_armcu,sens_armcu,flat_armcu,adv_theta_armcu          &
+     &            ,rad_theta_armcu,adv_qt_armcu,sens_prof,flat_prof         &
+     &            ,adv_theta_prof,rad_theta_prof,adv_qt_prof)
+
+! vertical interpolation:
+! No vertical interpolation if nlev imposed to 19 or 40
+
+! For this case, fluxes are imposed
+       fsens=-1*sens_prof
+       flat=-1*flat_prof
+
+! Advective forcings are given in K or g/kg ... BY HOUR
+      do l = 1, llm
+       ug(l)= u_mod(l)
+       vg(l)= v_mod(l)
+       IF((phi(l)/RG).LT.1000) THEN
+         d_th_adv(l) = (adv_theta_prof + rad_theta_prof)/3600.
+         d_q_adv(l,1) = adv_qt_prof/1000./3600.
+         d_q_adv(l,2) = 0.0
+!        print *,'INF1000: phi dth dq1 dq2',
+!    :  phi(l)/RG,d_th_adv(l),d_q_adv(l,1),d_q_adv(l,2)
+       ELSEIF ((phi(l)/RG).GE.1000.AND.(phi(l)/RG).lt.3000) THEN
+         fact=((phi(l)/RG)-1000.)/2000.
+         fact=1-fact
+         d_th_adv(l) = (adv_theta_prof + rad_theta_prof)*fact/3600.
+         d_q_adv(l,1) = adv_qt_prof*fact/1000./3600.
+         d_q_adv(l,2) = 0.0
+!        print *,'SUP1000: phi fact dth dq1 dq2',
+!    :  phi(l)/RG,fact,d_th_adv(l),d_q_adv(l,1),d_q_adv(l,2)
+       ELSE
+         d_th_adv(l) = 0.0
+         d_q_adv(l,1) = 0.0
+         d_q_adv(l,2) = 0.0
+!        print *,'SUP3000: phi dth dq1 dq2',
+!    :  phi(l)/RG,d_th_adv(l),d_q_adv(l,1),d_q_adv(l,2)
+       ENDIF
+      dt_cooling(l) = 0.0  
+!     print *,'Interp armcu: phi dth dq1 dq2',
+!    :  l,phi(l),d_th_adv(l),d_q_adv(l,1),d_q_adv(l,2)
+      enddo
+      endif ! forcing_armcu
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!---------------------------------------------------------------------
+! Interpolation forcing in time and onto model levels
+!---------------------------------------------------------------------
+      if (forcing_sandu) then
+
+        print*,                                                             &
+     & '#### ITAP,day,day1,(day-day1)*86400,(day-day1)*86400/dt_sandu=',    &
+     &    day,day1,(day-day1)*86400.,(day-day1)*86400/dt_sandu 
+
+! time interpolation:
+! ATTENTION, cet appel ne convient pas pour TOGA !!
+! revoir 1DUTILS.h et les arguments
+      CALL interp_sandu_time(daytime,day1,annee_ref                         &
+     &             ,year_ini_sandu,day_ju_ini_sandu,nt_sandu,dt_sandu       &
+     &             ,nlev_sandu                                              &
+     &             ,ts_sandu,ts_prof)
+
+        if (type_ts_forcing.eq.1) ts_cur = ts_prof ! SST used in read_tsurf1d
+
+! vertical interpolation:
+      CALL interp_sandu_vertical(play,nlev_sandu,plev_profs                 &
+     &         ,t_profs,thl_profs,q_profs,u_profs,v_profs,w_profs           &
+     &         ,omega_profs,o3mmr_profs                                     &
+     &         ,t_mod,thl_mod,q_mod,u_mod,v_mod,w_mod                       &
+     &         ,omega_mod,o3mmr_mod,mxcalc)
+!calcul de l'advection verticale
+!Calcul des gradients verticaux
+!initialisation
+      d_t_z(:)=0.
+      d_q_z(:)=0.
+      d_t_dyn_z(:)=0.
+      d_q_dyn_z(:)=0.
+! schema centre
+!     DO l=2,llm-1
+!      d_t_z(l)=(temp(l+1)-temp(l-1))
+!    &          /(play(l+1)-play(l-1))
+!      d_q_z(l)=(q(l+1,1)-q(l-1,1))
+!    &          /(play(l+1)-play(l-1))
+! schema amont
+      DO l=2,llm-1
+       d_t_z(l)=(temp(l+1)-temp(l))/(play(l+1)-play(l))
+       d_q_z(l)=(q(l+1,1)-q(l,1))/(play(l+1)-play(l))
+!     print *,'l temp2 temp0 play2 play0 omega_mod',
+!    & temp(l+1),temp(l-1),play(l+1),play(l-1),omega_mod(l)
+      ENDDO
+      d_t_z(1)=d_t_z(2)
+      d_q_z(1)=d_q_z(2)
+      d_t_z(llm)=d_t_z(llm-1)
+      d_q_z(llm)=d_q_z(llm-1)
+
+!  calcul de l advection verticale
+! Confusion w (m/s) et omega (Pa/s) !!
+      d_t_dyn_z(:)=omega_mod(:)*d_t_z(:)
+      d_q_dyn_z(:)=omega_mod(:)*d_q_z(:)
+!     do l=1,llm
+!      print *,'d_t_dyn omega_mod d_t_z d_q_dyn d_q_z',
+!    :l,d_t_dyn_z(l),omega_mod(l),d_t_z(l),d_q_dyn_z(l),d_q_z(l)
+!     enddo
+
+
+! large-scale forcing : pour le cas Sandu ces forcages sont la SST
+! et une divergence constante -> profil de omega
+      tsurf = ts_prof
+      write(*,*) 'SST suivante: ',tsurf
+      do l = 1, llm
+       omega(l) = omega_mod(l)
+       omega2(l)= omega(l)/rg*airefi ! flxmass_w calcule comme ds physiq
+
+       alpha = rd*temp(l)*(1.+(rv/rd-1.)*q(l,1))/play(l)
+!
+!      d_th_adv(l) = 0.0
+!      d_q_adv(l,1) = 0.0
+!CR:test advection=0
+!calcul de l'advection verticale
+        d_th_adv(l) = alpha*omega(l)/rcpd-d_t_dyn_z(l)
+!        print*,'temp adv',l,-d_t_dyn_z(l)
+        d_q_adv(l,1) = -d_q_dyn_z(l)
+!        print*,'q adv',l,-d_q_dyn_z(l)
+       dt_cooling(l) = 0.0
+      enddo
+      endif ! forcing_sandu
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!---------------------------------------------------------------------
+! Interpolation forcing in time and onto model levels
+!---------------------------------------------------------------------
+      if (forcing_astex) then
+
+        print*,                                                             &
+     & '#### ITAP,day,day1,(day-day1)*86400,(day-day1)*86400/dt_astex=',    &
+     &    day,day1,(day-day1)*86400.,(day-day1)*86400/dt_astex
+
+! time interpolation:
+! ATTENTION, cet appel ne convient pas pour TOGA !!
+! revoir 1DUTILS.h et les arguments
+      CALL interp_astex_time(daytime,day1,annee_ref                         &
+     &             ,year_ini_astex,day_ju_ini_astex,nt_astex,dt_astex       &
+     &             ,nlev_astex,div_astex,ts_astex,ug_astex,vg_astex         &
+     &             ,ufa_astex,vfa_astex,div_prof,ts_prof,ug_prof,vg_prof    &
+     &             ,ufa_prof,vfa_prof)
+
+        if (type_ts_forcing.eq.1) ts_cur = ts_prof ! SST used in read_tsurf1d
+
+! vertical interpolation:
+      CALL interp_astex_vertical(play,nlev_astex,plev_profa                 &
+     &         ,t_profa,thl_profa,qv_profa,ql_profa,qt_profa                &
+     &         ,u_profa,v_profa,w_profa,tke_profa,o3mmr_profa               &
+     &         ,t_mod,thl_mod,qv_mod,ql_mod,qt_mod,u_mod,v_mod,w_mod        &
+     &         ,tke_mod,o3mmr_mod,mxcalc)
+!calcul de l'advection verticale
+!Calcul des gradients verticaux
+!initialisation
+      d_t_z(:)=0.
+      d_q_z(:)=0.
+      d_t_dyn_z(:)=0.
+      d_q_dyn_z(:)=0.
+! schema centre
+!     DO l=2,llm-1
+!      d_t_z(l)=(temp(l+1)-temp(l-1))
+!    &          /(play(l+1)-play(l-1))
+!      d_q_z(l)=(q(l+1,1)-q(l-1,1))
+!    &          /(play(l+1)-play(l-1))
+! schema amont
+      DO l=2,llm-1
+       d_t_z(l)=(temp(l+1)-temp(l))/(play(l+1)-play(l))
+       d_q_z(l)=(q(l+1,1)-q(l,1))/(play(l+1)-play(l))
+!     print *,'l temp2 temp0 play2 play0 omega_mod',
+!    & temp(l+1),temp(l-1),play(l+1),play(l-1),omega_mod(l)
+      ENDDO
+      d_t_z(1)=d_t_z(2)
+      d_q_z(1)=d_q_z(2)
+      d_t_z(llm)=d_t_z(llm-1)
+      d_q_z(llm)=d_q_z(llm-1)
+
+!  calcul de l advection verticale
+! Confusion w (m/s) et omega (Pa/s) !!
+      d_t_dyn_z(:)=w_mod(:)*d_t_z(:)
+      d_q_dyn_z(:)=w_mod(:)*d_q_z(:)
+!     do l=1,llm
+!      print *,'d_t_dyn omega_mod d_t_z d_q_dyn d_q_z',
+!    :l,d_t_dyn_z(l),omega_mod(l),d_t_z(l),d_q_dyn_z(l),d_q_z(l)
+!     enddo
+
+
+! large-scale forcing : pour le cas Astex ces forcages sont la SST
+! la divergence,ug,vg,ufa,vfa
+      tsurf = ts_prof
+      write(*,*) 'SST suivante: ',tsurf
+      do l = 1, llm
+       omega(l) = w_mod(l)
+       omega2(l)= omega(l)/rg*airefi ! flxmass_w calcule comme ds physiq
+
+       alpha = rd*temp(l)*(1.+(rv/rd-1.)*q(l,1))/play(l)
+!
+!      d_th_adv(l) = 0.0
+!      d_q_adv(l,1) = 0.0
+!CR:test advection=0
+!calcul de l'advection verticale
+        d_th_adv(l) = alpha*omega(l)/rcpd-d_t_dyn_z(l)
+!        print*,'temp adv',l,-d_t_dyn_z(l)
+        d_q_adv(l,1) = -d_q_dyn_z(l)
+!        print*,'q adv',l,-d_q_dyn_z(l)
+       dt_cooling(l) = 0.0
+      enddo
+      endif ! forcing_astex
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
Index: /LMDZ5/branches/testing/libf/phylmd/1D_nudge_sandu_astex.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/1D_nudge_sandu_astex.h	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/1D_nudge_sandu_astex.h	(revision 2056)
@@ -0,0 +1,34 @@
+      do l = 1, llm
+!
+! au dessus de 700hPa, on relaxe vers profil init
+!      on fait l'hypothese que dans ce cas, il n'y a plus d'eau liq. au dessus 700hpa
+!      donc la relaxation en thetal et qt devient relaxation en tempe et qv
+       relax_u(l)=(u(l)-u_mod(l))/tau_sandu  ! pour u et v on relaxe sur tte la colonne
+       relax_v(l)=(v(l)-v_mod(l))/tau_sandu
+       relax_q(l,1)=0.
+       relax_q(l,2)=0.
+       relax_thl(l)=0.
+!      print *,'nudge: l tau_sandu u u_mod',l,tau_sandu,u(l),u_mod(l)
+!
+       if (l.ge.llm700) then 
+         relax_q(l,1)=(q(l,1)-q_mod(l))/tau_sandu
+         relax_q(l,2)=0.
+         relax_thl(l)=(temp(l)-t_mod(l))/tau_sandu
+       endif
+!     print *,'l dq1 relax dqadv',l,dq(l,1),relax_q(l,1),d_q_adv(l,1)
+!     print *,'l dq2 relax dqadv',l,dq(l,2),relax_q(l,2),d_q_adv(l,2)
+!     print *,'l dt  relax dtadv',l,dt_phys(l),relax_thl(l),d_th_adv(l)
+      enddo
+        u(1:mxcalc)=u(1:mxcalc) + timestep*(                                &          
+     &              du_phys(1:mxcalc) - relax_u(1:mxcalc))
+        v(1:mxcalc)=v(1:mxcalc) + timestep*(                                &
+     &               dv_phys(1:mxcalc) - relax_v(1:mxcalc))
+!       q(1:mxcalc,:)=q(1:mxcalc,:)+timestep*(
+!    .              dq(1:mxcalc,:) - relax_q(1:mxcalc,:)+
+!    .              d_q_adv(1:mxcalc,:))
+        q(1:mxcalc,1)=q(1:mxcalc,1)+timestep*(                              &
+     &      dq(1:mxcalc,1) - relax_q(1:mxcalc,1)+d_q_adv(1:mxcalc,1))
+        q(1:mxcalc,2)=q(1:mxcalc,2)+timestep*(                              &
+     &      dq(1:mxcalc,2) - relax_q(1:mxcalc,2)+d_q_adv(1:mxcalc,2))
+        temp(1:mxcalc)=temp(1:mxcalc)+timestep*(                            &
+     &      dt_phys(1:mxcalc)-relax_thl(1:mxcalc)+d_th_adv(1:mxcalc))
Index: /LMDZ5/branches/testing/libf/phylmd/1D_read_forc_cases.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/1D_read_forc_cases.h	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/1D_read_forc_cases.h	(revision 2056)
@@ -0,0 +1,612 @@
+!----------------------------------------------------------------------
+! forcing_les = .T. : Impose a constant cooling 
+! forcing_radconv = .T. : Pure radiative-convective equilibrium:
+!----------------------------------------------------------------------
+
+
+      nq1=0
+      nq2=0
+
+      if (forcing_les .or. forcing_radconv                                      &
+     &    .or. forcing_GCSSold .or. forcing_fire) then
+
+      if (forcing_fire) then
+!----------------------------------------------------------------------
+!read fire forcings from fire.nc
+!----------------------------------------------------------------------
+      fich_fire='fire.nc'
+      call read_fire(fich_fire,nlev_fire,nt_fire                                &
+     &     ,height,tttprof,qtprof,uprof,vprof,e12prof                           &
+     &     ,ugprof,vgprof,wfls,dqtdxls                                          &
+     &     ,dqtdyls,dqtdtls,thlpcar)
+      write(*,*) 'Forcing FIRE lu'
+      kmax=120            ! nombre de niveaux dans les profils et forcages
+      else 
+!----------------------------------------------------------------------
+! Read profiles from files: prof.inp.001 and lscale.inp.001
+! (repris de readlesfiles)
+!----------------------------------------------------------------------
+
+      call readprofiles(nlev_max,kmax,nqtot,height,                             &
+     &           tttprof,qtprof,uprof,vprof,                                    &
+     &           e12prof,ugprof,vgprof,                                         &
+     &           wfls,dqtdxls,dqtdyls,dqtdtls,                                  &
+     &           thlpcar,qprof,nq1,nq2)
+      endif
+
+! compute altitudes of play levels.
+      zlay(1) =zsurf +  rd*tsurf*(psurf-play(1))/(rg*psurf)
+      do l = 2,llm
+        zlay(l) = zlay(l-1)+rd*tsurf*(psurf-play(1))/(rg*psurf)
+      enddo
+
+!----------------------------------------------------------------------
+! Interpolation of the profiles given on the input file to
+! model levels
+!----------------------------------------------------------------------
+      zlay(1) = zsurf +  rd*tsurf*(psurf-play(1))/(rg*psurf)
+      do l=1,llm
+        ! Above the max altutide of the input file
+
+        if (zlay(l)<height(kmax)) mxcalc=l
+
+        frac = (height(kmax)-zlay(l))/(height (kmax)-height(kmax-1))
+        ttt =tttprof(kmax)-frac*(tttprof(kmax)-tttprof(kmax-1))
+       if ((forcing_GCSSold .AND. tp_ini_GCSSold) .OR. forcing_fire)then ! pot. temp. in initial profile
+          temp(l) = ttt*(play(l)/pzero)**rkappa
+          teta(l) = ttt
+       else
+          temp(l) = ttt
+          teta(l) = ttt*(pzero/play(l))**rkappa
+       endif
+          print *,' temp,teta ',l,temp(l),teta(l)
+        q(l,1)  = qtprof(kmax)-frac*( qtprof(kmax)- qtprof(kmax-1))
+        u(l)    =  uprof(kmax)-frac*(  uprof(kmax)-  uprof(kmax-1))
+        v(l)    =  vprof(kmax)-frac*(  vprof(kmax)-  vprof(kmax-1))
+        ug(l)   = ugprof(kmax)-frac*( ugprof(kmax)- ugprof(kmax-1))
+        vg(l)   = vgprof(kmax)-frac*( vgprof(kmax)- vgprof(kmax-1))
+        IF (nq2>0) q(l,nq1:nq2)=qprof(kmax,nq1:nq2)                         &
+     &               -frac*(qprof(kmax,nq1:nq2)-qprof(kmax-1,nq1:nq2))
+        omega(l)=   wfls(kmax)-frac*(   wfls(kmax)-   wfls(kmax-1))
+
+        dq_dyn(l,1) = dqtdtls(kmax)-frac*(dqtdtls(kmax)-dqtdtls(kmax-1))
+        dt_cooling(l)=thlpcar(kmax)-frac*(thlpcar(kmax)-thlpcar(kmax-1))
+        do k=2,kmax
+          frac = (height(k)-zlay(l))/(height(k)-height(k-1))
+          if(l==1) print*,'k, height, tttprof',k,height(k),tttprof(k)
+          if(zlay(l)>height(k-1).and.zlay(l)<height(k)) then
+            ttt =tttprof(k)-frac*(tttprof(k)-tttprof(k-1))
+       if ((forcing_GCSSold .AND. tp_ini_GCSSold) .OR. forcing_fire)then ! pot. temp. in initial profile
+          temp(l) = ttt*(play(l)/pzero)**rkappa
+          teta(l) = ttt
+       else
+          temp(l) = ttt
+          teta(l) = ttt*(pzero/play(l))**rkappa
+       endif
+          print *,' temp,teta ',l,temp(l),teta(l)
+            q(l,1)  = qtprof(k)-frac*( qtprof(k)- qtprof(k-1))
+            u(l)    =  uprof(k)-frac*(  uprof(k)-  uprof(k-1))
+            v(l)    =  vprof(k)-frac*(  vprof(k)-  vprof(k-1))
+            ug(l)   = ugprof(k)-frac*( ugprof(k)- ugprof(k-1))
+            vg(l)   = vgprof(k)-frac*( vgprof(k)- vgprof(k-1))
+            IF (nq2>0) q(l,nq1:nq2)=qprof(k,nq1:nq2)                        &
+     &                   -frac*(qprof(k,nq1:nq2)-qprof(k-1,nq1:nq2))
+            omega(l)=   wfls(k)-frac*(   wfls(k)-   wfls(k-1))
+            dq_dyn(l,1)=dqtdtls(k)-frac*(dqtdtls(k)-dqtdtls(k-1))
+            dt_cooling(l)=thlpcar(k)-frac*(thlpcar(k)-thlpcar(k-1))
+          elseif(zlay(l)<height(1)) then ! profils uniformes pour z<height(1)
+            ttt =tttprof(1)
+       if ((forcing_GCSSold .AND. tp_ini_GCSSold) .OR. forcing_fire)then ! pot. temp. in initial profile
+          temp(l) = ttt*(play(l)/pzero)**rkappa
+          teta(l) = ttt
+       else
+          temp(l) = ttt
+          teta(l) = ttt*(pzero/play(l))**rkappa
+       endif
+            q(l,1)  = qtprof(1)
+            u(l)    =  uprof(1)
+            v(l)    =  vprof(1)
+            ug(l)   = ugprof(1)
+            vg(l)   = vgprof(1)
+            omega(l)=   wfls(1)
+            IF (nq2>0) q(l,nq1:nq2)=qprof(1,nq1:nq2)
+            dq_dyn(l,1)  =dqtdtls(1)
+            dt_cooling(l)=thlpcar(1)
+          endif
+        enddo 
+
+        temp(l)=max(min(temp(l),350.),150.)
+        rho(l)  = play(l)/(rd*temp(l)*(1.+(rv/rd-1.)*q(l,1)))
+        if (l .lt. llm) then
+          zlay(l+1) = zlay(l) + (play(l)-play(l+1))/(rg*rho(l))
+        endif
+        omega2(l)=-rho(l)*omega(l)
+        omega(l)= omega(l)*(-rg*rho(l)) !en Pa/s
+        if (l>1) then
+        if(zlay(l-1)>height(kmax)) then
+           omega(l)=0.0
+           omega2(l)=0.0
+        endif   
+        endif
+        if(q(l,1)<0.) q(l,1)=0.0
+        q(l,2)  = 0.0
+      enddo
+
+      endif ! forcing_les .or. forcing_GCSSold .or. forcing_fire
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!---------------------------------------------------------------------
+! Forcing for GCSSold:
+!---------------------------------------------------------------------
+      if (forcing_GCSSold) then
+       fich_gcssold_ctl = './forcing.ctl'
+       fich_gcssold_dat = './forcing8.dat'
+       call copie(llm,play,psurf,fich_gcssold_ctl)
+       call get_uvd2(it,timestep,fich_gcssold_ctl,fich_gcssold_dat,         &
+     &               ht_gcssold,hq_gcssold,hw_gcssold,                      &
+     &               hu_gcssold,hv_gcssold,                                 &
+     &               hthturb_gcssold,hqturb_gcssold,Ts_gcssold,             &
+     &               imp_fcg_gcssold,ts_fcg_gcssold,                        &
+     &               Tp_fcg_gcssold,Turb_fcg_gcssold)
+       print *,' get_uvd2 -> hqturb_gcssold ',hqturb_gcssold
+      endif ! forcing_GCSSold
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!---------------------------------------------------------------------
+! Forcing for RICO:
+!---------------------------------------------------------------------
+      if (forcing_rico) then
+
+!       call writefield_phy('omega', omega,llm+1)
+      fich_rico = 'rico.txt'
+       call read_rico(fich_rico,nlev_rico,ps_rico,play                      &
+     &             ,ts_rico,t_rico,q_rico,u_rico,v_rico,w_rico              &
+     &             ,dth_rico,dqh_rico)
+        print*, ' on a lu et prepare RICO'
+
+       mxcalc=llm
+       print *, airefi, ' airefi '
+       do l = 1, llm
+       rho(l)  = play(l)/(rd*t_rico(l)*(1.+(rv/rd-1.)*q_rico(l)))
+       temp(l) = t_rico(l)
+       q(l,1) = q_rico(l)
+       q(l,2) = 0.0
+       u(l) = u_rico(l)
+       v(l) = v_rico(l)
+       ug(l)=u_rico(l)
+       vg(l)=v_rico(l)
+       omega(l) = -w_rico(l)*rg
+       omega2(l) = omega(l)/rg*airefi
+       enddo
+      endif
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!---------------------------------------------------------------------
+! Forcing from TOGA-COARE experiment (Ciesielski et al. 2002) :
+!---------------------------------------------------------------------
+
+      if (forcing_toga) then
+
+! read TOGA-COARE forcing (native vertical grid, nt_toga timesteps):
+      fich_toga = './d_toga/ifa_toga_coare_v21_dime.txt'
+      CALL read_togacoare(fich_toga,nlev_toga,nt_toga                       &
+     &         ,ts_toga,plev_toga,t_toga,q_toga,u_toga,v_toga,w_toga        &
+     &         ,ht_toga,vt_toga,hq_toga,vq_toga)
+
+       write(*,*) 'Forcing TOGA lu'
+
+! time interpolation for initial conditions:
+      write(*,*) 'AVT 1ere INTERPOLATION: day,day1 = ',day,day1
+      CALL interp_toga_time(daytime,day1,annee_ref                          &
+     &             ,year_ini_toga,day_ju_ini_toga,nt_toga,dt_toga           &
+     &             ,nlev_toga,ts_toga,plev_toga,t_toga,q_toga,u_toga        &
+     &             ,v_toga,w_toga,ht_toga,vt_toga,hq_toga,vq_toga           &
+     &             ,ts_prof,plev_prof,t_prof,q_prof,u_prof,v_prof,w_prof    &
+     &             ,ht_prof,vt_prof,hq_prof,vq_prof)
+
+! vertical interpolation:
+      CALL interp_toga_vertical(play,nlev_toga,plev_prof                    &
+     &         ,t_prof,q_prof,u_prof,v_prof,w_prof                          &
+     &         ,ht_prof,vt_prof,hq_prof,vq_prof                             &
+     &         ,t_mod,q_mod,u_mod,v_mod,w_mod                               &
+     &         ,ht_mod,vt_mod,hq_mod,vq_mod,mxcalc)
+       write(*,*) 'Profil initial forcing TOGA interpole'
+
+! initial and boundary conditions :
+      tsurf = ts_prof
+      write(*,*) 'SST initiale: ',tsurf
+      do l = 1, llm
+       temp(l) = t_mod(l)
+       q(l,1) = q_mod(l)
+       q(l,2) = 0.0
+       u(l) = u_mod(l)
+       v(l) = v_mod(l)
+       omega(l) = w_mod(l)
+       omega2(l)=omega(l)/rg*airefi ! flxmass_w calcule comme ds physiq
+!?       rho(l)  = play(l)/(rd*temp(l)*(1.+(rv/rd-1.)*q(l,1)))
+!?       omega2(l)=-rho(l)*omega(l)
+       alpha = rd*temp(l)*(1.+(rv/rd-1.)*q(l,1))/play(l)
+       d_th_adv(l) = alpha*omega(l)/rcpd-(ht_mod(l)+vt_mod(l))
+       d_q_adv(l,1) = -(hq_mod(l)+vq_mod(l))
+       d_q_adv(l,2) = 0.0
+      enddo
+
+      endif ! forcing_toga
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!---------------------------------------------------------------------
+! Forcing from TWPICE experiment (Shaocheng et al. 2010) :
+!---------------------------------------------------------------------
+
+      if (forcing_twpice) then
+!read TWP-ICE forcings
+     fich_twpice='d_twpi/twp180iopsndgvarana_v2.1_C3.c1.20060117.000000.cdf'
+      call read_twpice(fich_twpice,nlev_twpi,nt_twpi                        &
+     &     ,ts_twpi,plev_twpi,t_twpi,q_twpi,u_twpi,v_twpi,w_twpi            &
+     &     ,ht_twpi,vt_twpi,hq_twpi,vq_twpi)
+
+      write(*,*) 'Forcing TWP-ICE lu'
+!Time interpolation for initial conditions using TOGA interpolation routine
+         write(*,*) 'AVT 1ere INTERPOLATION: day,day1 = ',daytime,day1   
+      CALL interp_toga_time(daytime,day1,annee_ref                          &
+     &          ,year_ini_twpi,day_ju_ini_twpi,nt_twpi,dt_twpi,nlev_twpi    &
+     &             ,ts_twpi,plev_twpi,t_twpi,q_twpi,u_twpi,v_twpi,w_twpi    &
+     &             ,ht_twpi,vt_twpi,hq_twpi,vq_twpi                         &
+     &             ,ts_proftwp,plev_proftwp,t_proftwp,q_proftwp             &
+     &             ,u_proftwp,v_proftwp,w_proftwp                           &
+     &             ,ht_proftwp,vt_proftwp,hq_proftwp,vq_proftwp)
+
+! vertical interpolation using TOGA interpolation routine:
+!      write(*,*)'avant interp vert', t_proftwp
+      CALL interp_toga_vertical(play,nlev_twpi,plev_proftwp                 &
+     &         ,t_proftwp,q_proftwp,u_proftwp,v_proftwp,w_proftwp           &
+     &         ,ht_proftwp,vt_proftwp,hq_proftwp,vq_proftwp                 &
+     &         ,t_mod,q_mod,u_mod,v_mod,w_mod                               &
+     &         ,ht_mod,vt_mod,hq_mod,vq_mod,mxcalc)
+!       write(*,*) 'Profil initial forcing TWP-ICE interpole',t_mod
+
+! initial and boundary conditions :
+!      tsurf = ts_proftwp
+      write(*,*) 'SST initiale: ',tsurf
+      do l = 1, llm
+       temp(l) = t_mod(l)
+       q(l,1) = q_mod(l)
+       q(l,2) = 0.0
+       u(l) = u_mod(l)
+       v(l) = v_mod(l)
+       omega(l) = w_mod(l)
+       omega2(l)=omega(l)/rg*airefi ! flxmass_w calcule comme ds physiq
+
+       alpha = rd*temp(l)*(1.+(rv/rd-1.)*q(l,1))/play(l)
+!on applique le forcage total au premier pas de temps
+!attention: signe different de toga
+       d_th_adv(l) = alpha*omega(l)/rcpd+(ht_mod(l)+vt_mod(l))
+       d_q_adv(l,1) = (hq_mod(l)+vq_mod(l))
+       d_q_adv(l,2) = 0.0
+      enddo     
+       
+      endif !forcing_twpice
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!---------------------------------------------------------------------
+! Forcing from AMMA experiment (Couvreux et al. 2010) :
+!---------------------------------------------------------------------
+
+      if (forcing_amma) then
+!read AMMA forcings
+      fich_amma='amma.nc'
+      call read_amma(fich_amma,nlev_amma,nt_amma                            &
+     &     ,z_amma,plev_amma,th_amma,q_amma,u_amma,v_amma,vitw_amma         &
+     &     ,ht_amma,hq_amma,sens_amma,lat_amma)
+
+      write(*,*) 'Forcing AMMA lu'
+
+!champs initiaux:
+      do k=1,nlev_amma
+         th_ammai(k)=th_amma(k)
+         q_ammai(k)=q_amma(k)
+         u_ammai(k)=u_amma(k)
+         v_ammai(k)=v_amma(k)
+         vitw_ammai(k)=vitw_amma(k,12)
+         ht_ammai(k)=ht_amma(k,12)
+         hq_ammai(k)=hq_amma(k,12)
+         vt_ammai(k)=0.
+         vq_ammai(k)=0.
+      enddo   
+      omega(:)=0.      
+      omega2(:)=0.
+      rho(:)=0.
+! vertical interpolation using TOGA interpolation routine:
+!      write(*,*)'avant interp vert', t_proftwp
+      CALL interp_toga_vertical(play,nlev_amma,plev_amma                    &
+     &         ,th_ammai,q_ammai,u_ammai,v_ammai,vitw_ammai                 &
+     &         ,ht_ammai,vt_ammai,hq_ammai,vq_ammai                         &
+     &         ,t_mod,q_mod,u_mod,v_mod,w_mod                               &
+     &         ,ht_mod,vt_mod,hq_mod,vq_mod,mxcalc)
+!       write(*,*) 'Profil initial forcing TWP-ICE interpole',t_mod
+
+! initial and boundary conditions :
+!      tsurf = ts_proftwp
+      write(*,*) 'SST initiale mxcalc: ',tsurf,mxcalc
+      do l = 1, llm
+! Ligne du dessous à decommenter si on lit theta au lieu de temp
+!      temp(l) = t_mod(l)*(play(l)/pzero)**rkappa 
+       temp(l) = t_mod(l) 
+       q(l,1) = q_mod(l)
+       q(l,2) = 0.0
+!      print *,'read_forc: l,temp,q=',l,temp(l),q(l,1)
+       u(l) = u_mod(l)
+       v(l) = v_mod(l)
+       rho(l)  = play(l)/(rd*temp(l)*(1.+(rv/rd-1.)*q(l,1)))
+       omega(l) = w_mod(l)*(-rg*rho(l))
+       omega2(l)=omega(l)/rg*airefi ! flxmass_w calcule comme ds physiq
+
+       alpha = rd*temp(l)*(1.+(rv/rd-1.)*q(l,1))/play(l)
+!on applique le forcage total au premier pas de temps
+!attention: signe different de toga
+       d_th_adv(l) = alpha*omega(l)/rcpd+ht_mod(l)
+!forcage en th
+!       d_th_adv(l) = ht_mod(l)
+       d_q_adv(l,1) = hq_mod(l)
+       d_q_adv(l,2) = 0.0
+       dt_cooling(l)=0.
+      enddo     
+       write(*,*) 'Prof initeforcing AMMA interpole temp39',temp(39)
+      
+
+!     ok_flux_surf=.false.
+      fsens=-1.*sens_amma(12)
+      flat=-1.*lat_amma(12)
+       
+      endif !forcing_amma
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!---------------------------------------------------------------------
+! Forcing from Arm_Cu case                   
+! For this case, ifa_armcu.txt contains sensible, latent heat fluxes
+! large scale advective forcing,radiative forcing 
+! and advective tendency of theta and qt to be applied 
+!---------------------------------------------------------------------
+
+      if (forcing_armcu) then
+! read armcu forcing :
+       write(*,*) 'Avant lecture Forcing Arm_Cu'
+      fich_armcu = './ifa_armcu.txt'
+      CALL read_armcu(fich_armcu,nlev_armcu,nt_armcu,                       &
+     & sens_armcu,flat_armcu,adv_theta_armcu,                               &
+     & rad_theta_armcu,adv_qt_armcu)
+       write(*,*) 'Forcing Arm_Cu lu'
+
+!----------------------------------------------------------------------
+! Read profiles from file: prof.inp.19 or prof.inp.40 
+! For this case, profiles are given for two vertical resolution
+! 19 or 40 levels
+!
+! Comment from: http://www.knmi.nl/samenw/eurocs/ARM/profiles.html
+! Note that the initial profiles contain no liquid water! 
+! (so potential temperature can be interpreted as liquid water 
+! potential temperature and water vapor as total water)
+! profiles are given at full levels
+!----------------------------------------------------------------------
+
+      call readprofile_armcu(nlev_max,kmax,height,play_mod,u_mod,           &
+     &           v_mod,theta_mod,t_mod,qv_mod,rv_mod,ap,bp)
+
+! time interpolation for initial conditions:
+      write(*,*) 'AVT 1ere INTERPOLATION: day,day1 = ',day,day1
+
+      print *,'Avant interp_armcu_time'
+      print *,'daytime=',daytime
+      print *,'day1=',day1
+      print *,'annee_ref=',annee_ref
+      print *,'year_ini_armcu=',year_ini_armcu
+      print *,'day_ju_ini_armcu=',day_ju_ini_armcu
+      print *,'nt_armcu=',nt_armcu
+      print *,'dt_armcu=',dt_armcu
+      print *,'nlev_armcu=',nlev_armcu
+      CALL interp_armcu_time(daytime,day1,annee_ref                         &
+     &            ,year_ini_armcu,day_ju_ini_armcu,nt_armcu,dt_armcu        &
+     &            ,nlev_armcu,sens_armcu,flat_armcu,adv_theta_armcu         &
+     &            ,rad_theta_armcu,adv_qt_armcu,sens_prof,flat_prof         &
+     &            ,adv_theta_prof,rad_theta_prof,adv_qt_prof)
+       write(*,*) 'Forcages interpoles dans temps'
+
+! No vertical interpolation if nlev imposed to 19 or 40
+! The vertical grid stops at 4000m # 600hPa
+      mxcalc=llm
+
+! initial and boundary conditions :
+!     tsurf = ts_prof
+! tsurf read in lmdz1d.def
+      write(*,*) 'Tsurf initiale: ',tsurf
+      do l = 1, llm
+       play(l)=play_mod(l)*100.
+       presnivs(l)=play(l)
+       zlay(l)=height(l)
+       temp(l) = t_mod(l)
+       teta(l)=theta_mod(l)
+       q(l,1) = qv_mod(l)/1000.
+! No liquid water in the initial profil
+       q(l,2) = 0.
+       u(l) = u_mod(l)
+       ug(l)= u_mod(l)
+       v(l) = v_mod(l)
+       vg(l)= v_mod(l)
+! Advective forcings are given in K or g/kg ... per HOUR
+!      IF(height(l).LT.1000) THEN
+!        d_th_adv(l) = (adv_theta_prof + rad_theta_prof)/3600.
+!        d_q_adv(l,1) = adv_qt_prof/1000./3600.
+!        d_q_adv(l,2) = 0.0
+!      ELSEIF (height(l).GE.1000.AND.height(l).LT.3000) THEN
+!        d_th_adv(l) = (adv_theta_prof + rad_theta_prof)*
+!    :               (1-(height(l)-1000.)/2000.)
+!        d_th_adv(l) = d_th_adv(l)/3600.
+!        d_q_adv(l,1) = adv_qt_prof*(1-(height(l)-1000.)/2000.)
+!        d_q_adv(l,1) = d_q_adv(l,1)/1000./3600.
+!        d_q_adv(l,2) = 0.0
+!      ELSE
+!        d_th_adv(l) = 0.0
+!        d_q_adv(l,1) = 0.0
+!        d_q_adv(l,2) = 0.0
+!      ENDIF
+      enddo
+! plev at half levels is given in proh.inp.19 or proh.inp.40 files
+      plev(1)= ap(llm+1)+bp(llm+1)*psurf
+      do l = 1, llm
+      plev(l+1) = ap(llm-l+1)+bp(llm-l+1)*psurf
+      print *,'Read_forc: l height play plev zlay temp',                    &
+     &   l,height(l),play(l),plev(l),zlay(l),temp(l)
+      enddo
+! For this case, fluxes are imposed
+       fsens=-1*sens_prof
+       flat=-1*flat_prof
+
+      endif ! forcing_armcu
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!---------------------------------------------------------------------
+! Forcing from transition case of Irina Sandu                  
+!---------------------------------------------------------------------
+
+      if (forcing_sandu) then
+       write(*,*) 'Avant lecture Forcing SANDU'
+
+! read sanduref forcing :
+      fich_sandu = './ifa_sanduref.txt'
+      CALL read_sandu(fich_sandu,nlev_sandu,nt_sandu,ts_sandu)
+
+       write(*,*) 'Forcing SANDU lu'
+
+!----------------------------------------------------------------------
+! Read profiles from file: prof.inp.001 
+!----------------------------------------------------------------------
+
+      call readprofile_sandu(nlev_max,kmax,height,plev_profs,t_profs,       &
+     &           thl_profs,q_profs,u_profs,v_profs,                         &
+     &           w_profs,omega_profs,o3mmr_profs)
+
+! time interpolation for initial conditions:
+      write(*,*) 'AVT 1ere INTERPOLATION: day,day1 = ',day,day1
+! ATTENTION, cet appel ne convient pas pour le cas SANDU !!
+! revoir 1DUTILS.h et les arguments
+
+      print *,'Avant interp_sandu_time'
+      print *,'daytime=',daytime
+      print *,'day1=',day1
+      print *,'annee_ref=',annee_ref
+      print *,'year_ini_sandu=',year_ini_sandu
+      print *,'day_ju_ini_sandu=',day_ju_ini_sandu
+      print *,'nt_sandu=',nt_sandu
+      print *,'dt_sandu=',dt_sandu
+      print *,'nlev_sandu=',nlev_sandu
+      CALL interp_sandu_time(daytime,day1,annee_ref                         &
+     &             ,year_ini_sandu,day_ju_ini_sandu,nt_sandu,dt_sandu       &
+     &             ,nlev_sandu                                              &
+     &             ,ts_sandu,ts_prof)
+
+! vertical interpolation:
+      print *,'Avant interp_vertical: nlev_sandu=',nlev_sandu
+      CALL interp_sandu_vertical(play,nlev_sandu,plev_profs                 &
+     &         ,t_profs,thl_profs,q_profs,u_profs,v_profs,w_profs           &
+     &         ,omega_profs,o3mmr_profs                                     &
+     &         ,t_mod,thl_mod,q_mod,u_mod,v_mod,w_mod                       &
+     &         ,omega_mod,o3mmr_mod,mxcalc)
+       write(*,*) 'Profil initial forcing SANDU interpole'
+
+! initial and boundary conditions :
+      tsurf = ts_prof
+      write(*,*) 'SST initiale: ',tsurf
+      do l = 1, llm
+       temp(l) = t_mod(l)
+       tetal(l)=thl_mod(l)
+       q(l,1) = q_mod(l)
+       q(l,2) = 0.0
+       u(l) = u_mod(l)
+       v(l) = v_mod(l)
+       w(l) = w_mod(l)
+       omega(l) = omega_mod(l)
+       omega2(l)=omega(l)/rg*airefi ! flxmass_w calcule comme ds physiq
+!?       rho(l)  = play(l)/(rd*temp(l)*(1.+(rv/rd-1.)*q(l,1)))
+!?       omega2(l)=-rho(l)*omega(l)
+       alpha = rd*temp(l)*(1.+(rv/rd-1.)*q(l,1))/play(l)
+!      d_th_adv(l) = alpha*omega(l)/rcpd+vt_mod(l)
+!      d_q_adv(l,1) = vq_mod(l)
+       d_th_adv(l) = alpha*omega(l)/rcpd
+       d_q_adv(l,1) = 0.0
+       d_q_adv(l,2) = 0.0
+      enddo
+
+      endif ! forcing_sandu
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!---------------------------------------------------------------------
+! Forcing from Astex case
+!---------------------------------------------------------------------
+
+      if (forcing_astex) then
+       write(*,*) 'Avant lecture Forcing Astex'
+
+! read astex forcing :
+      fich_astex = './ifa_astex.txt'
+      CALL read_astex(fich_astex,nlev_astex,nt_astex,div_astex,ts_astex,    &
+     &  ug_astex,vg_astex,ufa_astex,vfa_astex)
+
+       write(*,*) 'Forcing Astex lu'
+
+!----------------------------------------------------------------------
+! Read profiles from file: prof.inp.001
+!----------------------------------------------------------------------
+
+      call readprofile_astex(nlev_max,kmax,height,plev_profa,t_profa,       &
+     &           thl_profa,qv_profa,ql_profa,qt_profa,u_profa,v_profa,      &
+     &           w_profa,tke_profa,o3mmr_profa)
+
+! time interpolation for initial conditions:
+      write(*,*) 'AVT 1ere INTERPOLATION: day,day1 = ',day,day1
+! ATTENTION, cet appel ne convient pas pour le cas SANDU !!
+! revoir 1DUTILS.h et les arguments
+
+      print *,'Avant interp_astex_time'
+      print *,'daytime=',daytime
+      print *,'day1=',day1
+      print *,'annee_ref=',annee_ref
+      print *,'year_ini_astex=',year_ini_astex
+      print *,'day_ju_ini_astex=',day_ju_ini_astex
+      print *,'nt_astex=',nt_astex
+      print *,'dt_astex=',dt_astex
+      print *,'nlev_astex=',nlev_astex
+      CALL interp_astex_time(daytime,day1,annee_ref                         &
+     &             ,year_ini_astex,day_ju_ini_astex,nt_astex,dt_astex       &
+     &             ,nlev_astex,div_astex,ts_astex,ug_astex,vg_astex         &
+     &             ,ufa_astex,vfa_astex,div_prof,ts_prof,ug_prof,vg_prof    &
+     &             ,ufa_prof,vfa_prof)
+
+! vertical interpolation:
+      print *,'Avant interp_vertical: nlev_astex=',nlev_astex
+      CALL interp_astex_vertical(play,nlev_astex,plev_profa                 &
+     &         ,t_profa,thl_profa,qv_profa,ql_profa,qt_profa                &
+     &         ,u_profa,v_profa,w_profa,tke_profa,o3mmr_profa               &
+     &         ,t_mod,thl_mod,qv_mod,ql_mod,qt_mod,u_mod,v_mod,w_mod        &
+     &         ,tke_mod,o3mmr_mod,mxcalc)
+       write(*,*) 'Profil initial forcing Astex interpole'
+
+! initial and boundary conditions :
+      tsurf = ts_prof
+      write(*,*) 'SST initiale: ',tsurf
+      do l = 1, llm
+       temp(l) = t_mod(l)
+       tetal(l)=thl_mod(l)
+       q(l,1) = qv_mod(l)
+       q(l,2) = ql_mod(l)
+       u(l) = u_mod(l)
+       v(l) = v_mod(l)
+       w(l) = w_mod(l)
+       omega(l) = w_mod(l)
+!      omega2(l)=omega(l)/rg*airefi ! flxmass_w calcule comme ds physiq
+!      rho(l)  = play(l)/(rd*temp(l)*(1.+(rv/rd-1.)*q(l,1)))
+!      omega2(l)=-rho(l)*omega(l)
+       alpha = rd*temp(l)*(1.+(rv/rd-1.)*q(l,1))/play(l)
+!      d_th_adv(l) = alpha*omega(l)/rcpd+vt_mod(l)
+!      d_q_adv(l,1) = vq_mod(l)
+       d_th_adv(l) = alpha*omega(l)/rcpd
+       d_q_adv(l,1) = 0.0
+       d_q_adv(l,2) = 0.0
+      enddo
+
+      endif ! forcing_astex
+
Index: /LMDZ5/branches/testing/libf/phylmd/1Dconv.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/1Dconv.h	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/1Dconv.h	(revision 2056)
@@ -0,0 +1,872 @@
+        subroutine get_uvd(itap,dtime,file_forctl,file_fordat,                  &
+     &       ht,hq,hw,hu,hv,hthturb,hqturb,                                     &
+     &       Ts,imp_fcg,ts_fcg,Tp_fcg,Turb_fcg)                                 
+!
+        implicit none
+ 
+!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+! cette routine permet d obtenir u_convg,v_convg,ht,hq et ainsi de
+! pouvoir calculer la convergence et le cisaillement dans la physiq
+!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+
+#include "YOMCST.h"
+
+      INTEGER klev
+      REAL play(100)  !pression en Pa au milieu de chaque couche GCM
+      INTEGER JM(100) !pression en Pa au milieu de chaque couche GCM
+      REAL coef1(100) !coefficient d interpolation
+      REAL coef2(100) !coefficient d interpolation
+
+      INTEGER nblvlm !nombre de niveau de pression du mesoNH
+      REAL playm(100)  !pression en Pa au milieu de chaque couche Meso-NH
+      REAL hplaym(100) !pression en hPa milieux des couches Meso-NH
+
+      integer i,j,k,ll,in
+
+      CHARACTER*80 file_forctl,file_fordat
+
+      COMMON/com1_phys_gcss/play,coef1,coef2,JM,klev
+      COMMON/com2_phys_gcss/playm,hplaym,nblvlm
+
+!======================================================================
+! methode: on va chercher les donnees du mesoNH de meteo france, on y
+!          a acces a tout pas detemps grace a la routine rdgrads qui
+!          est une boucle lisant dans ces fichiers.
+!          Puis on interpole ces donnes sur les 11 niveaux du gcm et
+!          et sur les pas de temps de ce meme gcm
+!----------------------------------------------------------------------
+! input:
+!       pasmax     :nombre de pas de temps maximum du mesoNH
+!       dt         :pas de temps du meso_NH (en secondes)
+!----------------------------------------------------------------------
+      integer pasmax,dt
+      save pasmax,dt
+!----------------------------------------------------------------------
+! arguments:
+!           itap   :compteur de la physique(le nombre de ces pas est
+!                   fixe dans la subroutine calcul_ini_gcm de interpo
+!                   -lation
+!           dtime  :pas detemps du gcm (en secondes)
+!           ht     :convergence horizontale de temperature(K/s)
+!           hq     :    "         "       d humidite (kg/kg/s)
+!           hw     :vitesse verticale moyenne (m/s**2)
+!           hu     :convergence horizontale d impulsion le long de x
+!                  (kg/(m^2 s^2)
+!           hv     : idem le long de y.
+!           Ts     : Temperature de surface (K)
+!           imp_fcg: var. logical .eq. T si forcage en impulsion
+!           ts_fcg: var. logical .eq. T si forcage en Ts present dans fichier
+!           Tp_fcg: var. logical .eq. T si forcage donne en Temp potentielle
+!           Turb_fcg: var. logical .eq. T si forcage turbulent present dans fichier
+!----------------------------------------------------------------------
+        integer itap
+        real dtime
+        real ht(100)
+        real hq(100)
+        real hu(100)
+        real hv(100)
+        real hw(100)
+        real hthturb(100)
+        real hqturb(100)
+        real Ts, Ts_subr
+        logical imp_fcg
+        logical ts_fcg
+        logical Tp_fcg
+        logical Turb_fcg
+!----------------------------------------------------------------------
+! Variables internes de get_uvd (note : l interpolation temporelle
+! est faite entre les pas de temps before et after, sur les variables
+! definies sur la grille du SCM; on atteint exactement les valeurs Meso
+! aux milieux des pas de temps Meso)
+!     time0     :date initiale en secondes
+!     time      :temps associe a chaque pas du SCM
+!     pas       :numero du pas du meso_NH (on lit en pas : le premier pas
+!                 des donnees est duplique)
+!     pasprev   :numero du pas de lecture precedent
+!     htaft     :advection horizontale de temp. au pas de temps after
+!     hqaft     :    "         "      d humidite        "
+!     hwaft     :vitesse verticalle moyenne  au pas de temps after
+!     huaft,hvaft :advection horizontale d impulsion au pas de temps after
+!     tsaft     : surface temperature 'after time step'
+!     htbef     :idem htaft, mais pour le pas de temps before
+!     hqbef     :voir hqaft
+!     hwbef     :voir hwaft
+!     hubef,hvbef : idem huaft,hvaft, mais pour before
+!     tsbef     : surface temperature 'before time step'
+!----------------------------------------------------------------------
+        integer time0,pas,pasprev
+        save time0,pas,pasprev
+        real time
+        real htaft(100),hqaft(100),hwaft(100),huaft(100),hvaft(100)
+        real hthturbaft(100),hqturbaft(100)
+        real Tsaft
+        save htaft,hqaft,hwaft,huaft,hvaft,hthturbaft,hqturbaft
+        real htbef(100),hqbef(100),hwbef(100),hubef(100),hvbef(100)
+        real hthturbbef(100),hqturbbef(100)
+        real Tsbef
+        save htbef,hqbef,hwbef,hubef,hvbef,hthturbbef,hqturbbef
+!
+        real timeaft,timebef
+        save timeaft,timebef
+        integer temps
+        character*4 string
+!----------------------------------------------------------------------
+! variables arguments de la subroutine rdgrads
+!---------------------------------------------------------------------
+        integer icompt,icomp1 !compteurs de rdgrads
+        real z(100)         ! altitude (grille Meso)
+        real ht_mes(100)    !convergence horizontale de temperature
+                            !-(grille Meso)
+        real hq_mes(100)    !convergence horizontale d humidite
+                            !(grille Meso)
+        real hw_mes(100)    !vitesse verticale moyenne
+                            !(grille Meso)
+        real hu_mes(100),hv_mes(100)    !convergence horizontale d impulsion
+                                        !(grille Meso)
+        real hthturb_mes(100) !tendance horizontale de T_pot, due aux
+                              !flux turbulents
+        real hqturb_mes(100) !tendance horizontale d humidite, due aux
+                              !flux turbulents
+!
+!---------------------------------------------------------------------
+! variable argument de la subroutine copie
+!---------------------------------------------------------------------
+! SB        real pplay(100)    !pression en milieu de couche du gcm
+! SB                            !argument de la physique
+!---------------------------------------------------------------------
+! variables destinees a la lecture du pas de temps du fichier de donnees
+!---------------------------------------------------------------------
+       character*80 aaa,atemps,spaces,apasmax
+       integer nch,imn,ipa
+!---------------------------------------------------------------------
+!  procedures appelees
+        external rdgrads    !lire en iterant dans forcing.dat
+!---------------------------------------------------------------------
+               print*,'le pas itap est:',itap
+!*** on determine le pas du meso_NH correspondant au nouvel itap ***
+!*** pour aller chercher les champs dans rdgrads                 ***
+!
+        time=time0+itap*dtime
+!c        temps=int(time/dt+1)
+!c        pas=min(temps,pasmax)
+        temps = 1 + int((dt + 2*time)/(2*dt))
+        pas=min(temps,pasmax-1)
+             print*,'le pas Meso est:',pas
+!
+!
+!===================================================================
+!
+!*** on remplit les champs before avec les champs after du pas   ***
+!*** precedent en format gcm                                     ***
+        if(pas.gt.pasprev)then
+          do i=1,klev
+             htbef(i)=htaft(i)
+             hqbef(i)=hqaft(i)
+             hwbef(i)=hwaft(i)
+             hubef(i)=huaft(i)
+             hvbef(i)=hvaft(i)
+             hThTurbbef(i)=hThTurbaft(i)
+             hqTurbbef(i)=hqTurbaft(i)
+          enddo
+          tsbef = tsaft
+          timebef=pasprev*dt
+          timeaft=timebef+dt
+          icomp1 = nblvlm*4
+          IF (ts_fcg) icomp1 = icomp1 + 1
+          IF (imp_fcg) icomp1 = icomp1 + nblvlm*2
+          IF (Turb_fcg) icomp1 = icomp1 + nblvlm*2
+          icompt = icomp1*pas
+         print *, 'imp_fcg,ts_fcg,Turb_fcg,pas,nblvlm,icompt'
+         print *, imp_fcg,ts_fcg,Turb_fcg,pas,nblvlm,icompt
+                       print*,'le pas pas est:',pas
+!*** on va chercher les nouveaux champs after dans toga.dat     ***
+!*** champs en format meso_NH                                   ***
+          open(99,FILE=file_fordat,FORM='UNFORMATTED',                        &
+     &             ACCESS='DIRECT',RECL=8)
+          call rdgrads(99,icompt,nblvlm,z,ht_mes,hq_mes,hw_mes                &
+     &                  ,hu_mes,hv_mes,hthturb_mes,hqturb_mes                 &
+     &                  ,ts_fcg,ts_subr,imp_fcg,Turb_fcg)
+!
+
+               if(Tp_fcg) then
+!     (le forcage est donne en temperature potentielle)
+         do i = 1,nblvlm
+           ht_mes(i) = ht_mes(i)*(hplaym(i)/1000.)**rkappa
+         enddo
+               endif ! Tp_fcg
+        if(Turb_fcg) then
+         do i = 1,nblvlm
+           hThTurb_mes(i) = hThTurb_mes(i)*(hplaym(i)/1000.)**rkappa
+         enddo
+        endif  ! Turb_fcg
+!
+               print*,'ht_mes ',(ht_mes(i),i=1,nblvlm)
+               print*,'hq_mes ',(hq_mes(i),i=1,nblvlm)
+               print*,'hw_mes ',(hw_mes(i),i=1,nblvlm)
+                  if(imp_fcg) then
+               print*,'hu_mes ',(hu_mes(i),i=1,nblvlm)
+               print*,'hv_mes ',(hv_mes(i),i=1,nblvlm)
+                  endif
+                  if(Turb_fcg) then
+               print*,'hThTurb_mes ',(hThTurb_mes(i),i=1,nblvlm)
+               print*,'hqTurb_mes ',(hqTurb_mes(i),i=1,nblvlm)
+                  endif
+          IF (ts_fcg) print*,'ts_subr', ts_subr
+!*** on interpole les champs meso_NH sur les niveaux de pression***
+!*** gcm . on obtient le nouveau champ after                    ***
+            do k=1,klev
+             if (JM(k) .eq. 0) then
+         htaft(k)=              ht_mes(jm(k)+1)
+         hqaft(k)=              hq_mes(jm(k)+1)
+         hwaft(k)=              hw_mes(jm(k)+1)
+               if(imp_fcg) then
+           huaft(k)=              hu_mes(jm(k)+1)
+           hvaft(k)=              hv_mes(jm(k)+1)
+               endif ! imp_fcg
+               if(Turb_fcg) then
+           hThTurbaft(k)=         hThTurb_mes(jm(k)+1)
+           hqTurbaft(k)=          hqTurb_mes(jm(k)+1)
+               endif ! Turb_fcg
+             else ! JM(k) .eq. 0
+           htaft(k)=coef1(k)*ht_mes(jm(k))+coef2(k)*ht_mes(jm(k)+1)
+           hqaft(k)=coef1(k)*hq_mes(jm(k))+coef2(k)*hq_mes(jm(k)+1)
+           hwaft(k)=coef1(k)*hw_mes(jm(k))+coef2(k)*hw_mes(jm(k)+1)
+               if(imp_fcg) then
+           huaft(k)=coef1(k)*hu_mes(jm(k))+coef2(k)*hu_mes(jm(k)+1)
+           hvaft(k)=coef1(k)*hv_mes(jm(k))+coef2(k)*hv_mes(jm(k)+1)
+               endif ! imp_fcg
+               if(Turb_fcg) then
+           hThTurbaft(k)=coef1(k)*hThTurb_mes(jm(k))                            &
+     &               +coef2(k)*hThTurb_mes(jm(k)+1)
+           hqTurbaft(k) =coef1(k)*hqTurb_mes(jm(k))                             &
+     &               +coef2(k)*hqTurb_mes(jm(k)+1)
+               endif ! Turb_fcg
+             endif ! JM(k) .eq. 0
+            enddo
+            tsaft = ts_subr
+            pasprev=pas
+         else ! pas.gt.pasprev
+            print*,'timebef est:',timebef
+         endif ! pas.gt.pasprev    fin du bloc relatif au passage au pas
+                                  !de temps (meso) suivant
+!*** si on atteint le pas max des donnees experimentales ,on     ***
+!*** on conserve les derniers champs calcules                    ***
+      if(temps.ge.pasmax)then
+          do ll=1,klev
+               ht(ll)=htaft(ll)
+               hq(ll)=hqaft(ll)
+               hw(ll)=hwaft(ll)
+               hu(ll)=huaft(ll)
+               hv(ll)=hvaft(ll)
+               hThTurb(ll)=hThTurbaft(ll)
+               hqTurb(ll)=hqTurbaft(ll)
+          enddo
+          ts_subr = tsaft
+      else ! temps.ge.pasmax
+!*** on interpole sur les pas de temps de 10mn du gcm a partir   ***
+!** des pas de temps de 1h du meso_NH                            ***
+         do j=1,klev
+         ht(j)=((timeaft-time)*htbef(j)+(time-timebef)*htaft(j))/dt
+         hq(j)=((timeaft-time)*hqbef(j)+(time-timebef)*hqaft(j))/dt
+         hw(j)=((timeaft-time)*hwbef(j)+(time-timebef)*hwaft(j))/dt
+             if(imp_fcg) then
+         hu(j)=((timeaft-time)*hubef(j)+(time-timebef)*huaft(j))/dt
+         hv(j)=((timeaft-time)*hvbef(j)+(time-timebef)*hvaft(j))/dt
+             endif ! imp_fcg
+             if(Turb_fcg) then
+         hThTurb(j)=((timeaft-time)*hThTurbbef(j)                           &
+     &           +(time-timebef)*hThTurbaft(j))/dt
+         hqTurb(j)= ((timeaft-time)*hqTurbbef(j)                            &
+     &           +(time-timebef)*hqTurbaft(j))/dt
+             endif ! Turb_fcg
+         enddo
+         ts_subr = ((timeaft-time)*tsbef + (time-timebef)*tsaft)/dt
+       endif ! temps.ge.pasmax
+!
+        print *,' time,timebef,timeaft',time,timebef,timeaft
+        print *,' ht,htbef,htaft,hthturb,hthturbbef,hthturbaft'
+        do j= 1,klev
+           print *, j,ht(j),htbef(j),htaft(j),                              &
+     &             hthturb(j),hthturbbef(j),hthturbaft(j)
+        enddo
+        print *,' hq,hqbef,hqaft,hqturb,hqturbbef,hqturbaft'
+        do j= 1,klev
+           print *, j,hq(j),hqbef(j),hqaft(j),                              &
+     &             hqturb(j),hqturbbef(j),hqturbaft(j)
+        enddo
+!
+!-------------------------------------------------------------------
+!
+         IF (Ts_fcg) Ts = Ts_subr
+         return
+!
+!-----------------------------------------------------------------------
+! on sort les champs de "convergence" pour l instant initial 'in'
+! ceci se passe au pas temps itap=0 de la physique
+!-----------------------------------------------------------------------
+        entry get_uvd2(itap,dtime,file_forctl,file_fordat,                  &
+     &           ht,hq,hw,hu,hv,hThTurb,hqTurb,ts,                          &
+     &           imp_fcg,ts_fcg,Tp_fcg,Turb_fcg)
+             print*,'le pas itap est:',itap
+!
+!===================================================================
+!
+       write(*,'(a)') 'OPEN '//file_forctl
+       open(97,FILE=file_forctl,FORM='FORMATTED')
+!
+!------------------
+      do i=1,1000
+      read(97,1000,end=999) string
+ 1000 format (a4)
+      if (string .eq. 'TDEF') go to 50
+      enddo
+ 50   backspace(97)
+!-------------------------------------------------------------------
+!   *** on lit le pas de temps dans le fichier de donnees ***
+!   *** "forcing.ctl" et pasmax                           ***
+!-------------------------------------------------------------------
+      read(97,2000) aaa
+ 2000  format (a80)
+         print*,'aaa est',aaa
+      aaa=spaces(aaa,1)
+         print*,'aaa',aaa
+      call getsch(aaa,' ',' ',5,atemps,nch)
+         print*,'atemps est',atemps
+        atemps=atemps(1:nch-2)
+         print*,'atemps',atemps
+        read(atemps,*) imn
+        dt=imn*60
+         print*,'le pas de temps dt',dt
+      call getsch(aaa,' ',' ',2,apasmax,nch)
+        apasmax=apasmax(1:nch)
+        read(apasmax,*) ipa
+        pasmax=ipa
+         print*,'pasmax est',pasmax
+      CLOSE(97)
+!------------------------------------------------------------------
+! *** on lit le pas de temps initial de la simulation ***
+!------------------------------------------------------------------
+                  in=itap
+!c                  pasprev=in
+!c                  time0=dt*(pasprev-1)
+                  pasprev=in-1
+                  time0=dt*pasprev
+!
+          close(98)
+!
+      write(*,'(a)') 'OPEN '//file_fordat
+      open(99,FILE=file_fordat,FORM='UNFORMATTED',                          &
+     &          ACCESS='DIRECT',RECL=8)
+          icomp1 = nblvlm*4
+          IF (ts_fcg) icomp1 = icomp1 + 1
+          IF (imp_fcg) icomp1 = icomp1 + nblvlm*2
+          IF (Turb_fcg) icomp1 = icomp1 + nblvlm*2
+          icompt = icomp1*(in-1)
+          call rdgrads(99,icompt,nblvlm,z,ht_mes,hq_mes,hw_mes              &
+     &                   ,hu_mes,hv_mes,hthturb_mes,hqturb_mes              &
+     &                   ,ts_fcg,ts_subr,imp_fcg,Turb_fcg)
+          print *, 'get_uvd : rdgrads ->'
+          print *, tp_fcg
+!
+! following commented out because we have temperature already in ARM case
+!   (otherwise this is the potential temperature )
+!------------------------------------------------------------------------
+               if(Tp_fcg) then
+          do i = 1,nblvlm
+            ht_mes(i) = ht_mes(i)*(hplaym(i)/1000.)**rkappa
+          enddo
+               endif ! Tp_fcg
+           print*,'ht_mes ',(ht_mes(i),i=1,nblvlm)
+           print*,'hq_mes ',(hq_mes(i),i=1,nblvlm)
+           print*,'hw_mes ',(hw_mes(i),i=1,nblvlm)
+              if(imp_fcg) then
+           print*,'hu_mes ',(hu_mes(i),i=1,nblvlm)
+           print*,'hv_mes ',(hv_mes(i),i=1,nblvlm)
+           print*,'t',ts_subr
+              endif ! imp_fcg
+              if(Turb_fcg) then
+                 print*,'hThTurb_mes ',(hThTurb_mes(i),i=1,nblvlm)
+                 print*,'hqTurb ',     (hqTurb_mes(i),i=1,nblvlm)
+              endif ! Turb_fcg
+!----------------------------------------------------------------------
+! on a obtenu des champs initiaux sur les niveaux du meso_NH
+! on interpole sur les niveaux du gcm(niveau pression bien sur!)
+!-----------------------------------------------------------------------
+            do k=1,klev
+             if (JM(k) .eq. 0) then
+!FKC bug? ne faut il pas convertir tsol en tendance ????
+!RT bug taken care of by removing the stuff
+           htaft(k)=              ht_mes(jm(k)+1)
+           hqaft(k)=              hq_mes(jm(k)+1)
+           hwaft(k)=              hw_mes(jm(k)+1)
+               if(imp_fcg) then
+           huaft(k)=              hu_mes(jm(k)+1)
+           hvaft(k)=              hv_mes(jm(k)+1)
+               endif ! imp_fcg
+               if(Turb_fcg) then
+           hThTurbaft(k)=         hThTurb_mes(jm(k)+1)
+           hqTurbaft(k)=          hqTurb_mes(jm(k)+1)
+               endif ! Turb_fcg
+             else ! JM(k) .eq. 0
+           htaft(k)=coef1(k)*ht_mes(jm(k))+coef2(k)*ht_mes(jm(k)+1)
+           hqaft(k)=coef1(k)*hq_mes(jm(k))+coef2(k)*hq_mes(jm(k)+1)
+           hwaft(k)=coef1(k)*hw_mes(jm(k))+coef2(k)*hw_mes(jm(k)+1)
+               if(imp_fcg) then
+           huaft(k)=coef1(k)*hu_mes(jm(k))+coef2(k)*hu_mes(jm(k)+1)
+           hvaft(k)=coef1(k)*hv_mes(jm(k))+coef2(k)*hv_mes(jm(k)+1)
+               endif ! imp_fcg
+               if(Turb_fcg) then
+           hThTurbaft(k)=coef1(k)*hThTurb_mes(jm(k))                        &
+     &                  +coef2(k)*hThTurb_mes(jm(k)+1)
+           hqTurbaft(k) =coef1(k)*hqTurb_mes(jm(k))                         &
+     &                  +coef2(k)*hqTurb_mes(jm(k)+1)
+               endif ! Turb_fcg
+             endif ! JM(k) .eq. 0
+            enddo
+            tsaft = ts_subr
+! valeurs initiales des champs de convergence
+          do k=1,klev
+             ht(k)=htaft(k)
+             hq(k)=hqaft(k)
+             hw(k)=hwaft(k)
+                if(imp_fcg) then
+             hu(k)=huaft(k)
+             hv(k)=hvaft(k)
+                endif ! imp_fcg
+                if(Turb_fcg) then
+             hThTurb(k)=hThTurbaft(k)
+             hqTurb(k) =hqTurbaft(k)
+                endif ! Turb_fcg
+          enddo
+          ts_subr = tsaft
+          close(99)
+          close(98)
+!
+!-------------------------------------------------------------------
+!
+!
+ 100      IF (Ts_fcg) Ts = Ts_subr
+        return
+!
+999     continue
+        stop 'erreur lecture, file forcing.ctl'
+        end
+
+      SUBROUTINE advect_tvl(dtime,zt,zq,vu_f,vv_f,t_f,q_f                   &
+     &                     ,d_t_adv,d_q_adv)
+      use dimphy
+      implicit none
+
+#include "dimensions.h"
+!cccc#include "dimphy.h"
+
+      integer k
+      real dtime, fact, du, dv, cx, cy, alx, aly
+      real zt(klev), zq(klev,3)
+      real vu_f(klev), vv_f(klev), t_f(klev), q_f(klev,3)
+
+      real d_t_adv(klev), d_q_adv(klev,3)
+
+! Velocity of moving cell
+      data cx,cy /12., -2./
+
+! Dimensions of moving cell
+      data alx,aly /100000.,150000./
+
+      do k = 1, klev
+            du = abs(vu_f(k)-cx)/alx
+            dv = abs(vv_f(k)-cy)/aly
+            fact = dtime *(du+dv-du*dv*dtime)
+            d_t_adv(k) = fact * (t_f(k)-zt(k))
+            d_q_adv(k,1) = fact * (q_f(k,1)-zq(k,1))
+            d_q_adv(k,2) = fact * (q_f(k,2)-zq(k,2))
+            d_q_adv(k,3) = fact * (q_f(k,3)-zq(k,3))
+      enddo
+
+      return
+      end
+
+      SUBROUTINE copie(klevgcm,playgcm,psolgcm,file_forctl)
+      implicit none
+
+!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+! cette routine remplit les COMMON com1_phys_gcss et com2_phys_gcss.h
+!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+
+      INTEGER klev !nombre de niveau de pression du GCM
+      REAL play(100)  !pression en Pa au milieu de chaque couche GCM
+      INTEGER JM(100)
+      REAL coef1(100)   !coefficient d interpolation
+      REAL coef2(100)   !coefficient d interpolation
+
+      INTEGER nblvlm !nombre de niveau de pression du mesoNH
+      REAL playm(100) !pression en Pa au milieu de chaque couche Meso-NH
+      REAL hplaym(100)!pression en hecto-Pa des milieux de couche Meso-NH
+
+      COMMON/com1_phys_gcss/play,coef1,coef2,JM,klev
+      COMMON/com2_phys_gcss/playm,hplaym,nblvlm
+
+      integer k,klevgcm
+      real playgcm(klevgcm) ! pression en milieu de couche du gcm
+      real psolgcm
+      character*80 file_forctl
+
+      klev = klevgcm
+
+!---------------------------------------------------------------------
+! pression au milieu des couches du gcm dans la physiq
+! (SB: remplace le call conv_lipress_gcm(playgcm) )
+!---------------------------------------------------------------------
+
+       do k = 1, klev
+        play(k) = playgcm(k)
+        print*,'la pression gcm est:',play(k)
+       enddo
+
+!----------------------------------------------------------------------
+! lecture du descripteur des donnees Meso-NH (forcing.ctl):
+!  -> nb niveaux du meso.NH (nblvlm) + pressions meso.NH
+! (on remplit le COMMON com2_phys_gcss)
+!----------------------------------------------------------------------
+
+      call mesolupbis(file_forctl)
+
+      print*,'la valeur de nblvlm est:',nblvlm
+
+!----------------------------------------------------------------------
+! etude de la correspondance entre les niveaux meso.NH et GCM;
+! calcul des coefficients d interpolation coef1 et coef2
+! (on remplit le COMMON com1_phys_gcss)
+!----------------------------------------------------------------------
+
+      call corresbis(psolgcm)
+
+!---------------------------------------------------------
+! TEST sur le remplissage de com1_phys_gcss et com2_phys_gcss:
+!---------------------------------------------------------
+ 
+      write(*,*) ' '
+      write(*,*) 'TESTS com1_phys_gcss et com2_phys_gcss dans copie.F'
+      write(*,*) '--------------------------------------'
+      write(*,*) 'GCM: nb niveaux:',klev,' et pression, coeffs:'
+      do k = 1, klev
+      write(*,*) play(k), coef1(k), coef2(k)
+      enddo
+      write(*,*) 'MESO-NH: nb niveaux:',nblvlm,' et pression:'
+      do k = 1, nblvlm
+      write(*,*) playm(k), hplaym(k)
+      enddo
+      write(*,*) ' '
+
+      end
+      SUBROUTINE mesolupbis(file_forctl)
+      implicit none 
+!
+!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+!
+! Lecture descripteur des donnees MESO-NH (forcing.ctl):
+! -------------------------------------------------------
+!
+!     Cette subroutine lit dans le fichier de controle "essai.ctl"
+!     et affiche le nombre de niveaux du Meso-NH ainsi que les valeurs
+!     des pressions en milieu de couche du Meso-NH (en Pa puis en hPa).
+!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+!
+      INTEGER nblvlm !nombre de niveau de pression du mesoNH
+      REAL playm(100)  !pression en Pa milieu de chaque couche Meso-NH
+      REAL hplaym(100) !pression en hPa des milieux de couche Meso-NH
+      COMMON/com2_phys_gcss/playm,hplaym,nblvlm
+
+      INTEGER i,lu,mlz,mlzh
+ 
+      character*80 file_forctl
+
+      character*4 a
+      character*80 aaa,anblvl,spaces
+      integer nch
+
+      lu=9
+      open(lu,file=file_forctl,form='formatted')
+!
+      do i=1,1000
+      read(lu,1000,end=999) a
+      if (a .eq. 'ZDEF') go to 100
+      enddo
+!
+ 100  backspace(lu)
+      print*,'  DESCRIPTION DES 2 MODELES : '
+      print*,' '
+!
+      read(lu,2000) aaa
+ 2000  format (a80)
+       aaa=spaces(aaa,1)
+       call getsch(aaa,' ',' ',2,anblvl,nch)
+         read(anblvl,*) nblvlm
+
+!
+      print*,'nbre de niveaux de pression Meso-NH :',nblvlm
+      print*,' '
+      print*,'pression en Pa de chaque couche du meso-NH :'
+!
+      read(lu,*) (playm(mlz),mlz=1,nblvlm)
+!      Si la pression est en HPa, la multiplier par 100
+      if (playm(1) .lt. 10000.) then
+        do mlz = 1,nblvlm
+         playm(mlz) = playm(mlz)*100.
+        enddo
+      endif
+      print*,(playm(mlz),mlz=1,nblvlm)
+!
+ 1000 format (a4)
+ 1001 format(5x,i2)
+!
+      print*,' '
+      do mlzh=1,nblvlm
+      hplaym(mlzh)=playm(mlzh)/100.
+      enddo
+!
+      print*,'pression en hPa de chaque couche du meso-NH: '
+      print*,(hplaym(mlzh),mlzh=1,nblvlm)
+!
+      close (lu)
+      return
+!
+ 999  stop 'erreur lecture des niveaux pression des donnees'
+      end
+
+      SUBROUTINE rdgrads(itape,icount,nl,z,ht,hq,hw,hu,hv,hthtur,hqtur,     &
+     &  ts_fcg,ts,imp_fcg,Turb_fcg)
+      IMPLICIT none
+      INTEGER itape,icount,icomp, nl
+      real z(nl),ht(nl),hq(nl),hw(nl),hu(nl),hv(nl)
+      real hthtur(nl),hqtur(nl)
+      real ts
+!
+      INTEGER k
+!
+      LOGICAL imp_fcg,ts_fcg,Turb_fcg
+!
+      icomp = icount
+!
+!
+         do k=1,nl
+            icomp=icomp+1
+            read(itape,rec=icomp)z(k)
+            print *,'icomp,k,z(k) ',icomp,k,z(k)
+         enddo
+         do k=1,nl
+            icomp=icomp+1
+            read(itape,rec=icomp)hT(k)
+             print*, hT(k), k
+         enddo
+         do k=1,nl
+            icomp=icomp+1
+            read(itape,rec=icomp)hQ(k)
+         enddo
+!
+             if(turb_fcg) then
+         do k=1,nl
+            icomp=icomp+1
+           read(itape,rec=icomp)hThTur(k)
+         enddo
+         do k=1,nl
+            icomp=icomp+1
+           read(itape,rec=icomp)hqTur(k)
+         enddo
+             endif
+         print *,' apres lecture hthtur, hqtur'
+!
+          if(imp_fcg) then
+
+         do k=1,nl
+            icomp=icomp+1
+           read(itape,rec=icomp)hu(k)
+         enddo
+         do k=1,nl
+            icomp=icomp+1
+            read(itape,rec=icomp)hv(k)
+         enddo
+
+          endif
+!
+         do k=1,nl
+            icomp=icomp+1
+            read(itape,rec=icomp)hw(k)
+         enddo
+!
+              if(ts_fcg) then
+         icomp=icomp+1
+         read(itape,rec=icomp)ts
+              endif
+!
+      print *,' rdgrads ->'
+
+      RETURN
+      END
+
+      SUBROUTINE corresbis(psol)
+      implicit none
+
+!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+! Cette subroutine calcule et affiche les valeurs des coefficients
+! d interpolation qui serviront dans la formule d interpolation elle-
+! meme.
+!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+
+      INTEGER klev    !nombre de niveau de pression du GCM
+      REAL play(100)  !pression en Pa au milieu de chaque couche GCM
+      INTEGER JM(100)
+      REAL coef1(100) !coefficient d interpolation
+      REAL coef2(100) !coefficient d interpolation
+
+      INTEGER nblvlm !nombre de niveau de pression du mesoNH
+      REAL playm(100) !pression en Pa milieu de chaque couche Meso-NH
+      REAL hplaym(100)!pression en hPa des milieux de couche Meso-NH
+
+      COMMON/com1_phys_gcss/play,coef1,coef2,JM,klev
+      COMMON/com2_phys_gcss/playm,hplaym,nblvlm
+
+      REAL psol
+      REAL val
+      INTEGER k, mlz
+
+
+      do k=1,klev
+         val=play(k)
+       if (val .gt. playm(1)) then
+          mlz = 0
+          JM(1) = mlz
+          coef1(1)=(playm(mlz+1)-val)/(playm(mlz+1)-psol)
+          coef2(1)=(val-psol)/(playm(mlz+1)-psol)
+       else if (val .gt. playm(nblvlm)) then
+         do mlz=1,nblvlm
+          if (     val .le. playm(mlz).and. val .gt. playm(mlz+1))then
+           JM(k)=mlz
+           coef1(k)=(playm(mlz+1)-val)/(playm(mlz+1)-playm(mlz))
+           coef2(k)=(val-playm(mlz))/(playm(mlz+1)-playm(mlz))
+          endif
+         enddo
+       else
+         JM(k) = nblvlm-1
+         coef1(k) = 0.
+         coef2(k) = 0.
+       endif
+      enddo
+!
+!c      if (play(klev) .le. playm(nblvlm)) then
+!c         mlz=nblvlm-1
+!c         JM(klev)=mlz
+!c         coef1(klev)=(playm(mlz+1)-val)
+!c     *            /(playm(mlz+1)-playm(mlz))
+!c         coef2(klev)=(val-playm(mlz))
+!c     *            /(playm(mlz+1)-playm(mlz))
+!c      endif
+!
+      print*,' '
+      print*,'         INTERPOLATION  : '
+      print*,' '
+      print*,'correspondance de 9 niveaux du GCM sur les 53 du meso-NH:'
+      print*,(JM(k),k=1,klev)
+      print*,'correspondance de 9 niveaux du GCM sur les 53 du meso-NH:'
+      print*,(JM(k),k=1,klev)
+      print*,' '
+      print*,'vals du premier coef d"interpolation pour les 9 niveaux: '
+      print*,(coef1(k),k=1,klev)
+      print*,' '
+      print*,'valeurs du deuxieme coef d"interpolation pour les 9 niveaux:'
+      print*,(coef2(k),k=1,klev)
+!
+      return
+      end
+      SUBROUTINE GETSCH(STR,DEL,TRM,NTH,SST,NCH)
+!***************************************************************
+!*                                                             *
+!*                                                             *
+!* GETSCH                                                      *
+!*                                                             *
+!*                                                             *
+!* modified by :                                               *
+!***************************************************************
+!*   Return in SST the character string found between the NTH-1 and NTH
+!*   occurence of the delimiter 'DEL' but before the terminator 'TRM' in
+!*   the input string 'STR'. If TRM=DEL then STR is considered unlimited.
+!*   NCH=Length of the string returned in SST or =-1 if NTH is <1 or if
+!*   NTH is greater than the number of delimiters in STR.
+      IMPLICIT INTEGER (A-Z)
+      CHARACTER STR*(*),DEL*1,TRM*1,SST*(*)
+      NCH=-1
+      SST=' '
+      IF(NTH.GT.0) THEN
+        IF(TRM.EQ.DEL) THEN
+          LENGTH=LEN(STR)
+        ELSE
+          LENGTH=INDEX(STR,TRM)-1
+          IF(LENGTH.LT.0) LENGTH=LEN(STR)
+        ENDIF
+!*     Find beginning and end of the NTH DEL-limited substring in STR
+        END=-1
+        DO 1,N=1,NTH
+        IF(END.EQ.LENGTH) RETURN
+        BEG=END+2
+        END=BEG+INDEX(STR(BEG:LENGTH),DEL)-2
+        IF(END.EQ.BEG-2) END=LENGTH
+!*        PRINT *,'NTH,LENGTH,N,BEG,END=',NTH,LENGTH,N,BEG,END
+    1   CONTINUE
+        NCH=END-BEG+1
+        IF(NCH.GT.0) SST=STR(BEG:END)
+      ENDIF
+      END
+      CHARACTER*(*) FUNCTION SPACES(STR,NSPACE)
+!
+! CERN PROGLIB# M433    SPACES          .VERSION KERNFOR  4.14  860211
+! ORIG.  6/05/86 M.GOOSSENS/DD
+!
+!-    The function value SPACES returns the character string STR with
+!-    leading blanks removed and each occurence of one or more blanks
+!-    replaced by NSPACE blanks inside the string STR
+!
+      CHARACTER*(*) STR
+!
+      LENSPA = LEN(SPACES)
+      SPACES = ' '
+      IF (NSPACE.LT.0) NSPACE = 0
+      IBLANK = 1
+      ISPACE = 1
+  100 INONBL = INDEXC(STR(IBLANK:),' ')
+      IF (INONBL.EQ.0) THEN
+          SPACES(ISPACE:) = STR(IBLANK:)
+                                                    GO TO 999
+      ENDIF
+      INONBL = INONBL + IBLANK - 1
+      IBLANK = INDEX(STR(INONBL:),' ')
+      IF (IBLANK.EQ.0) THEN
+          SPACES(ISPACE:) = STR(INONBL:)
+                                                    GO TO 999
+      ENDIF
+      IBLANK = IBLANK + INONBL - 1
+      SPACES(ISPACE:) = STR(INONBL:IBLANK-1)
+      ISPACE = ISPACE + IBLANK - INONBL + NSPACE
+      IF (ISPACE.LE.LENSPA)                         GO TO 100
+  999 END
+      FUNCTION INDEXC(STR,SSTR)
+!
+! CERN PROGLIB# M433    INDEXC          .VERSION KERNFOR  4.14  860211
+! ORIG. 26/03/86 M.GOOSSENS/DD
+!
+!-    Find the leftmost position where substring SSTR does not match
+!-    string STR scanning forward
+!
+      CHARACTER*(*) STR,SSTR
+!
+      LENS   = LEN(STR)
+      LENSS  = LEN(SSTR)
+!
+      DO 10 I=1,LENS-LENSS+1
+          IF (STR(I:I+LENSS-1).NE.SSTR) THEN
+              INDEXC = I
+                                         GO TO 999
+          ENDIF
+   10 CONTINUE
+      INDEXC = 0
+!
+  999 END
Index: /LMDZ5/branches/testing/libf/phylmd/YOETHF.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/YOETHF.h	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/YOETHF.h	(revision 2056)
@@ -1,4 +1,4 @@
 !
-! $Header$
+! $Id$
 !
 !  ATTENTION!!!!: ce fichier include est compatible format fixe/format libre
@@ -17,5 +17,12 @@
       REAL R2ES, R3LES, R3IES, R4LES, R4IES, R5LES, R5IES
       REAL RVTMP2, RHOH2O
+      REAL R5ALVCP,R5ALSCP,RALVDCP,RALSDCP,RALFDCP,RTWAT,RTBER,RTBERCU
+      REAL RTICE,RTICECU,RTWAT_RTICE_R,RTWAT_RTICECU_R,RKOOP1,RKOOP2
       COMMON /YOETHF/R2ES, R3LES, R3IES, R4LES, R4IES, R5LES, R5IES,    &
-     &               RVTMP2, RHOH2O
+     &               RVTMP2, RHOH2O,                                    &
+     &               R5ALVCP,R5ALSCP,RALVDCP,RALSDCP,                   &
+     &               RALFDCP,RTWAT,RTBER,RTBERCU,                       &
+     &               RTICE,RTICECU,RTWAT_RTICE_R,RTWAT_RTICECU_R,RKOOP1,&
+     &	  	     RKOOP2
+
 !$OMP THREADPRIVATE(/YOETHF/)
Index: /LMDZ5/branches/testing/libf/phylmd/add_pbl_tend.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/add_pbl_tend.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/add_pbl_tend.F90	(revision 2056)
@@ -1,3 +1,3 @@
-SUBROUTINE add_pbl_tend(zdu, zdv, zdt, zdq, zdql, text)
+SUBROUTINE add_pbl_tend(zdu, zdv, zdt, zdq, zdql, paprs, text)
   ! ======================================================================
   ! Ajoute les tendances de couche limite, soit determinees par la
@@ -29,4 +29,5 @@
   REAL zdt(klon, klev), zdq(klon, klev), zdql(klon, klev)
   CHARACTER *(*) text
+  REAL paprs(klon,klev+1)
 
   ! Local :
@@ -45,7 +46,7 @@
     PRINT *, ' add_pbl_tend, zzdt ', zzdt
     PRINT *, ' add_pbl_tend, zzdq ', zzdq
-    CALL add_phys_tend(zdu, zdv, zzdt, zzdq, zdql, text)
+    CALL add_phys_tend(zdu, zdv, zzdt, zzdq, zdql, paprs, text)
   ELSE
-    CALL add_phys_tend(zdu, zdv, zdt, zdq, zdql, text)
+    CALL add_phys_tend(zdu, zdv, zdt, zdq, zdql, paprs, text)
   END IF
 
Index: /LMDZ5/branches/testing/libf/phylmd/add_phys_tend.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/add_phys_tend.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/add_phys_tend.F90	(revision 2056)
@@ -2,5 +2,5 @@
 ! $Id$
 !
-SUBROUTINE add_phys_tend (zdu,zdv,zdt,zdq,zdql,text)
+SUBROUTINE add_phys_tend (zdu,zdv,zdt,zdq,zdql,paprs,text)
 !======================================================================
 ! Ajoute les tendances des variables physiques aux variables 
@@ -18,5 +18,7 @@
 use phys_state_var_mod
 IMPLICIT none
-#include "iniprint.h"
+  include "iniprint.h"
+  include "YOMCST.h"
+  include "clesphys.h"
 
 ! Arguments :
@@ -24,4 +26,5 @@
 REAL zdu(klon,klev),zdv(klon,klev)
 REAL zdt(klon,klev),zdq(klon,klev),zdql(klon,klev)
+REAL paprs(klon,klev+1)
 CHARACTER*(*) text
 
@@ -29,4 +32,7 @@
 !--------
 REAL zt,zq
+REAL zq_int, zqp_int, zq_new
+
+REAL zqp(klev)
 
 INTEGER i, k,j
@@ -35,4 +41,6 @@
 INTEGER kadrs(klon*klev)
 INTEGER kqadrs(klon*klev)
+
+LOGICAL done(klon)
 
 integer debug_level
@@ -107,27 +115,59 @@
 !=====================================================================================
 IF (jqbad .GT. 0) THEN
+      done(:) = .false.                         !jyg
       DO j = 1, jqbad
-         i=jqadrs(j)
-         if(prt_level.ge.debug_level) THEN
-          print*,'WARNING  : EAU POUR LE POINT i rlon rlat =',i,rlon(i),rlat(i),text
-          print*,'l    T     dT       Q     dQ    '
-         endif
-         DO k = 1, klev
-           zq=q_seri(i,k)+zdq(i,k)
-           if (zq.lt.1.e-15) then
-              if (q_seri(i,k).lt.1.e-15) then
-               if(prt_level.ge.debug_level) THEN
-                print*,' cas q_seri<1.e-15 i k q_seri zq zdq :',i,k,q_seri(i,k),zq,zdq(i,k)
-               endif
-               q_seri(i,k)=1.e-15
-               zdq(i,k)=(1.e-15-q_seri(i,k))
+        i=jqadrs(j)
+          if(prt_level.ge.debug_level) THEN
+           print*,'WARNING  : EAU POUR LE POINT i rlon rlat =',i,rlon(i),rlat(i),text
+           print*,'l    T     dT       Q     dQ    '
+           DO k = 1, klev
+              write(*,'(i3,2f14.4,2e14.2)') k,t_seri(i,k),zdt(i,k),q_seri(i,k),zdq(i,k)
+           ENDDO
+          endif
+          IF (ok_conserv_q) THEN
+!jyg<20140228 Corrections pour conservation de l'eau
+            IF (.NOT.done(i)) THEN                  !jyg
+              DO k = 1, klev
+                zqp(k) = max(q_seri(i,k),1.e-15)
+              ENDDO
+              zq_int  = 0.
+              zqp_int = 0.
+              DO k = 1, klev
+                zq_int  = zq_int  + q_seri(i,k)*(paprs(i,k)-paprs(i,k+1))/Rg
+                zqp_int = zqp_int + zqp(k)     *(paprs(i,k)-paprs(i,k+1))/Rg
+              ENDDO
+              if(prt_level.ge.debug_level) THEN
+               print*,' cas q_seri<1.e-15 i k zq_int zqp_int zq_int/zqp_int :', &
+                                    i, kqadrs(j), zq_int, zqp_int, zq_int/zqp_int
               endif
-           endif
-!           zq=q_seri(i,k)+zdq(i,k)
-!           if (zq.lt.1.e-15) then
-!              zdq(i,k)=(1.e-15-q_seri(i,k))
-!           endif
-         ENDDO
-      ENDDO
+              DO k = 1, klev
+                zq_new = zqp(k)*zq_int/zqp_int
+                zdq(i,k) = zdq(i,k) + zq_new - q_seri(i,k)
+                q_seri(i,k) = zq_new
+              ENDDO
+              done(i) = .true.
+            ENDIF !(.NOT.done(i))
+          ELSE 
+!jyg>
+            DO k = 1, klev
+              zq=q_seri(i,k)+zdq(i,k)
+              if (zq.lt.1.e-15) then
+                 if (q_seri(i,k).lt.1.e-15) then
+                  if(prt_level.ge.debug_level) THEN
+                   print*,' cas q_seri<1.e-15 i k q_seri zq zdq :',i,k,q_seri(i,k),zq,zdq(i,k)
+                  endif
+                  q_seri(i,k)=1.e-15
+                  zdq(i,k)=(1.e-15-q_seri(i,k))
+                 endif
+              endif
+!              zq=q_seri(i,k)+zdq(i,k)
+!              if (zq.lt.1.e-15) then
+!                 zdq(i,k)=(1.e-15-q_seri(i,k))
+!              endif
+            ENDDO
+!jyg<20140228
+          ENDIF   !  (ok_conserv_q)
+!jyg>
+      ENDDO ! j = 1, jqbad
 ENDIF
 !
Index: /LMDZ5/branches/testing/libf/phylmd/aero_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/aero_mod.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/aero_mod.F90	(revision 2056)
@@ -2,13 +2,13 @@
 !
 MODULE aero_mod
-  ! Declaration des indices pour les aerosols 
+! Declaration des indices pour les aerosols 
 
-  ! Total number of aerosols
-!  INTEGER, PARAMETER :: naero_tot = 10 
-!--STRAT AER
+! 1/ Total number of aerosols for which an aerosol optical depth is provided
+!--strat aerosols are only prescribed naero_tot = 10 ==> 11 
+
   INTEGER, PARAMETER :: naero_tot = 11
 
-  ! Identification number used in aeropt_2bands and aeropt_5wv
-  ! corresponding to naero_tot
+! Identification number used in aeropt_2bands and aeropt_5wv
+! corresponding to naero_tot
   INTEGER, PARAMETER :: id_ASBCM    = 1
   INTEGER, PARAMETER :: id_ASPOMM   = 2
@@ -21,25 +21,25 @@
   INTEGER, PARAMETER :: id_AIBCM    = 9
   INTEGER, PARAMETER :: id_AIPOMM   = 10
-!--STRAT AER
-  INTEGER, PARAMETER :: id_strat   = 11
+  INTEGER, PARAMETER :: id_STRAT   = 11
 
+! Corresponding names for the aerosols
+  CHARACTER(len=7),DIMENSION(naero_tot), PARAMETER :: name_aero_tau=(/&
+       "ASBCM  ", &
+       "ASPOMM ", &
+       "SO4    ", &
+       "CSSO4M ", &
+       "SSSSM  ", &
+       "CSSSM  ", &
+       "ASSSM  ", &
+       "CIDUSTM", &
+       "AIBCM  ", &
+       "AIPOMM ", &
+       "STRAT  " /)
 
-  ! Total number of aerosols actually used in LMDZ 
-  ! 1 =  ASBCM
-  ! 2 =  ASPOMM
-  ! 3 =  ASSO4M ( = SO4) 
-  ! 4 =  CSSO4M 
-  ! 5 =  SSSSM 
-  ! 6 =  CSSSM
-  ! 7 =  ASSSM
-  ! 8 =  CIDUSTM
-  ! 9 =  AIBCM
-  !10 =  AIPOMM
-!--STRAT AER
-  !11 = aerosols stratos
-!  INTEGER, PARAMETER :: naero_spc = 10
-  INTEGER, PARAMETER :: naero_spc = 11
+! 2/ Total number of aerosols for which an aerosol mass is provided
 
-  ! Corresponding names for the aerosols
+  INTEGER, PARAMETER :: naero_spc = 10
+
+! Corresponding names for the aerosols
   CHARACTER(len=7),DIMENSION(naero_spc), PARAMETER :: name_aero=(/&
        "ASBCM  ", &
@@ -52,10 +52,8 @@
        "CIDUSTM", &
        "AIBCM  ", &
-!       "AIPOMM " /)
-       "AIPOMM ", &
-       "STRAT  " /)
+       "AIPOMM " /)
 
-
-  ! Number of aerosol groups
+! 3/ Number of aerosol groups
+  INTEGER, PARAMETER :: naero_grp = 9 
   ! 1 = ZERO    
   ! 2 = AER total    
@@ -67,11 +65,11 @@
   ! 8 = SS    
   ! 9 = NO3    
-  INTEGER, PARAMETER :: naero_grp = 9 
 
-  ! Number of  wavelengths
+! Number of  wavelengths
   INTEGER, PARAMETER :: nwave = 5
 
-  ! Number of modes spectral bands
+! Number of modes spectral bands
   INTEGER, parameter :: nbands = 2
+  INTEGER, parameter :: nbands_rrtm = 6
 
 END MODULE aero_mod
Index: /LMDZ5/branches/testing/libf/phylmd/aeropt_2bands.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/aeropt_2bands.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/aeropt_2bands.F90	(revision 2056)
@@ -928,5 +928,7 @@
     ENDDO  ! nb_aer  
 
-  DO m=1,nb_aer   
+!correction bug OB
+!  DO m=1,nb_aer   
+  DO m=1,naero_tot   
     IF (.NOT. used_aer(m)) THEN
       tau_ae(:,:,m,:)=0.
Index: /LMDZ5/branches/testing/libf/phylmd/clesphys.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/clesphys.h	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/clesphys.h	(revision 2056)
@@ -76,4 +76,5 @@
        LOGICAL :: ok_strato
        LOGICAL :: ok_hines, ok_gwd_rando
+       LOGICAL :: ok_conserv_q
 
        COMMON/clesphys/                                                 &
@@ -113,5 +114,6 @@
      &     , ok_lic_melt,           aer_type                            &
      &     , iflag_rrtm, ok_strato,ok_hines                             &
-     &     , iflag_ice_thermo, ok_gwd_rando, NSW
+     &     , iflag_ice_thermo, ok_gwd_rando, NSW                        &
+     &     , ok_conserv_q
      
        save /clesphys/
Index: /LMDZ5/branches/testing/libf/phylmd/coefcdrag.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/coefcdrag.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/coefcdrag.F90	(revision 2056)
@@ -52,4 +52,5 @@
       include "YOMCST.h"
       include "YOETHF.h"
+      INCLUDE "clesphys.h"
 ! Quelques constantes :
       REAL, parameter :: RKAR=0.40, CB=5.0, CC=5.0, CD=5.0, cepdu2=(0.1)**2
@@ -75,9 +76,11 @@
                  (1.+ RETV * max(q(i),0.0))))
        ztsolv(i) = ts(i)
-       ztvd(i) = t(i) * (psol(i)/pref(i))**RKAPPA
+!       ztvd(i) = t(i) * (psol(i)/pref(i))**RKAPPA
+       ztvd(i) = (t(i)+zdphi(i)/RCPD/(1.+RVTMP2*q(i))) &
+          *(1.+RETV*q(i))
        trm0(i) = 1. + RETV * max(qsurf(i),0.0)
        trm1(i) = 1. + RETV * max(q(i),0.0)
        ztsolv(i) = ztsolv(i) * trm0(i)
-       ztvd(i) = ztvd(i) * trm1(i)
+!       ztvd(i) = ztvd(i) * trm1(i)
        zri1(i) = zdphi(i)*(ztvd(i)-ztsolv(i))/(zdu2(i)*ztvd(i))
 !
@@ -110,5 +113,7 @@
            zcfm1(i) = cdran(i) * friv(i)
            frih(i) = max(1./ (1.+3.*CB*zri1(i)*zscf(i)), 0.1 )
-           zcfh1(i) = cdran(i) * frih(i)
+!           zcfh1(i) = cdran(i) * frih(i)
+           zcfh1(i) = f_cdrag_ter*cdran(i) * frih(i)
+           IF(nsrf.EQ.is_oce) zcfh1(i)=f_cdrag_oce*cdran(i)*frih(i)
            cdram(i) = zcfm1(i)
            cdrah(i) = zcfh1(i)
@@ -126,5 +131,6 @@
                  *(1.0+zdphi(i)/(RG*rugos(i)))))
            zcfm2(i) = cdran(i)*max((1.-2.0*CB*zri1(i)*zucf(i)),0.1)
-           zcfh2(i) = cdran(i)*max((1.-3.0*CB*zri1(i)*zucf(i)),0.1)
+!           zcfh2(i) = cdran(i)*max((1.-3.0*CB*zri1(i)*zucf(i)),0.1)
+           zcfh2(i) = f_cdrag_ter*cdran(i)*max((1.-3.0*CB*zri1(i)*zucf(i)),0.1)
            cdram(i) = zcfm2(i)
            cdrah(i) = zcfh2(i)
@@ -138,5 +144,7 @@
          zcr(i) = (0.0016/(cdran(i)*SQRT(zdu2(i))))*ABS(ztvd(i)-ztsolv(i)) &
                **(1./3.)
-         IF (nsrf.EQ.is_oce) cdrah(i) = cdran(i)*(1.0+zcr(i)**1.25) &
+!         IF (nsrf.EQ.is_oce) cdrah(i) = cdran(i)*(1.0+zcr(i)**1.25) &
+!                  **(1./1.25)
+         IF (nsrf.EQ.is_oce) cdrah(i)=f_cdrag_oce*cdran(i)*(1.0+zcr(i)**1.25) &
                   **(1./1.25)
        ENDIF
Index: /LMDZ5/branches/testing/libf/phylmd/compar1d.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/compar1d.h	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/compar1d.h	(revision 2056)
@@ -0,0 +1,46 @@
+!
+! $Id: compar1d.h 2010-08-04 17:02:56Z lahellec $
+!
+      integer :: forcing_type
+      real :: nat_surf
+      real :: tsurf
+      real :: rugos
+      real :: qsol(1:2)
+      real :: qsurf
+      real :: psurf
+      real :: zsurf
+      real :: albedo
+
+      real :: time
+      real :: time_ini
+      real :: xlat 
+      real :: xlon 
+      real :: airefi
+      real :: wtsurf 
+      real :: wqsurf 
+      real :: restart_runoff 
+      real :: xagesno 
+      real :: qsolinp 
+      real :: zpicinp 
+
+      logical :: restart
+      logical :: ok_old_disvert
+
+      common/com_par1d/                                                 &
+     & nat_surf,tsurf,rugos,                                            &
+     & qsol,qsurf,psurf,zsurf,albedo,time,time_ini,xlat,xlon,airefi,    &
+     & wtsurf,wqsurf,restart_runoff,xagesno,qsolinp,zpicinp,            &
+     & forcing_type,                                                    &
+     & restart,ok_old_disvert
+
+!$OMP THREADPRIVATE(/com_par1d/)
+
+
+
+
+
+
+
+
+
+
Index: /LMDZ5/branches/testing/libf/phylmd/concvl.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/concvl.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/concvl.F90	(revision 2056)
@@ -1,22 +1,28 @@
-SUBROUTINE concvl(iflag_clos, dtime, paprs, pplay, t, q, t_wake, q_wake, &
-    s_wake, u, v, tra, ntra, ale, alp, sig1, w01, d_t, d_q, d_u, d_v, d_tra, &
-    rain, snow, kbas, ktop, sigd, cbmf, plcl, plfc, wbeff, upwd, dnwd, &
-    dnwdbis, ma, mip, vprecip, cape, cin, tvp, tconv, iflag, pbase, bbase, &
-    dtvpdt1, dtvpdq1, dplcldt, dplcldr, qcondc, wd, pmflxr, pmflxs, & ! RomP
-                                                                      ! >>>
-  ! !     .             da,phi,mp,dd_t,dd_q,lalim_conv,wght_th)
-    da, phi, mp, phi2, d1a, dam, sij, clw, elij, & ! RomP
-    dd_t, dd_q, lalim_conv, wght_th, & ! RomP
-    evap, ep, epmlmmm, eplamm, &   ! RomP
-    wdtraina, wdtrainm) ! RomP
-  ! RomP <<<
-  ! **************************************************************
-  ! *
-  ! CONCVL                                                      *
-  ! *
-  ! *
-  ! written by   : Sandrine Bony-Lena, 17/05/2003, 11.16.04    *
-  ! modified by :                                               *
-  ! **************************************************************
+SUBROUTINE concvl(iflag_clos, &
+                  dtime, paprs, pplay, &
+                  t, q, t_wake, q_wake, s_wake, u, v, tra, ntra, &
+                  Ale, Alp, sig1, w01, &
+                  d_t, d_q, d_u, d_v, d_tra, &
+                  rain, snow, kbas, ktop, sigd, &
+                  cbmf, plcl, plfc, wbeff, upwd, dnwd, dnwdbis, &
+                  Ma, mip, Vprecip, &
+                  cape, cin, tvp, Tconv, iflag, &
+                  pbase, bbase, dtvpdt1, dtvpdq1, dplcldt, dplcldr, &
+                  qcondc, wd, pmflxr, pmflxs, &
+!RomP >>>
+!!     .             da,phi,mp,dd_t,dd_q,lalim_conv,wght_th)
+                  da, phi, mp, phi2, d1a, dam, sij, clw, elij, &     ! RomP
+                  dd_t, dd_q, lalim_conv, wght_th, &                 ! RomP
+                  evap, ep, epmlmMm, eplaMm, &                       ! RomP
+                  wdtrainA, wdtrainM, wght)                          ! RomP+RL
+!RomP <<<
+! **************************************************************
+! *
+! CONCVL                                                      *
+! *
+! *
+! written by   : Sandrine Bony-Lena, 17/05/2003, 11.16.04    *
+! modified by :                                               *
+! **************************************************************
 
 
@@ -24,44 +30,52 @@
   USE infotrac, ONLY: nbtr
   IMPLICIT NONE
-  ! ======================================================================
-  ! Auteur(s): S. Bony-Lena (LMD/CNRS) date: ???
-  ! Objet: schema de convection de Emanuel (1991) interface
-  ! ======================================================================
-  ! Arguments:
-  ! dtime--input-R-pas d'integration (s)
-  ! s-------input-R-la valeur "s" pour chaque couche
-  ! sigs----input-R-la valeur "sigma" de chaque couche
-  ! sig-----input-R-la valeur de "sigma" pour chaque niveau
-  ! psolpa--input-R-la pression au sol (en Pa)
-  ! pskapa--input-R-exponentiel kappa de psolpa
-  ! h-------input-R-enthalpie potentielle (Cp*T/P**kappa)
-  ! q-------input-R-vapeur d'eau (en kg/kg)
-
-  ! work*: input et output: deux variables de travail,
-  ! on peut les mettre a 0 au debut
-  ! ALE-----input-R-energie disponible pour soulevement
-  ! ALP-----input-R-puissance disponible pour soulevement
-
-  ! d_h-----output-R-increment de l'enthalpie potentielle (h)
-  ! d_q-----output-R-increment de la vapeur d'eau
-  ! rain----output-R-la pluie (mm/s)
-  ! snow----output-R-la neige (mm/s)
-  ! upwd----output-R-saturated updraft mass flux (kg/m**2/s)
-  ! dnwd----output-R-saturated downdraft mass flux (kg/m**2/s)
-  ! dnwd0---output-R-unsaturated downdraft mass flux (kg/m**2/s)
-  ! Ma------output-R-adiabatic ascent mass flux (kg/m2/s)
-  ! mip-----output-R-mass flux shed by adiabatic ascent (kg/m2/s)
-  ! Vprecip-output-R-vertical profile of precipitations (kg/m2/s)
-  ! Tconv---output-R-environment temperature seen by convective scheme (K)
-  ! Cape----output-R-CAPE (J/kg)
-  ! Cin ----output-R-CIN  (J/kg)
-  ! Tvp-----output-R-Temperature virtuelle d'une parcelle soulevee
-  ! adiabatiquement a partir du niveau 1 (K)
-  ! deltapb-output-R-distance entre LCL et base de la colonne (<0 ; Pa)
-  ! Ice_flag-input-L-TRUE->prise en compte de la thermodynamique de la glace
-  ! dd_t-----output-R-increment de la temperature du aux descentes
-  ! precipitantes
-  ! dd_q-----output-R-increment de la vapeur d'eau du aux desc precip
-  ! ======================================================================
+! ======================================================================
+! Auteur(s): S. Bony-Lena (LMD/CNRS) date: ???
+! Objet: schema de convection de Emanuel (1991) interface
+! ======================================================================
+! Arguments:
+! dtime--input-R-pas d'integration (s)
+! s-------input-R-la vAleur "s" pour chaque couche
+! sigs----input-R-la vAleur "sigma" de chaque couche
+! sig-----input-R-la vAleur de "sigma" pour chaque niveau
+! psolpa--input-R-la pression au sol (en Pa)
+! pskapa--input-R-exponentiel kappa de psolpa
+! h-------input-R-enthAlpie potentielle (Cp*T/P**kappa)
+! q-------input-R-vapeur d'eau (en kg/kg)
+
+! work*: input et output: deux variables de travail,
+! on peut les mettre a 0 au debut
+! ALE--------input-R-energie disponible pour soulevement
+! ALP--------input-R-puissance disponible pour soulevement
+
+! d_h--------output-R-increment de l'enthAlpie potentielle (h)
+! d_q--------output-R-increment de la vapeur d'eau
+! rain-------output-R-la pluie (mm/s)
+! snow-------output-R-la neige (mm/s)
+! upwd-------output-R-saturated updraft mass flux (kg/m**2/s)
+! dnwd-------output-R-saturated downdraft mass flux (kg/m**2/s)
+! dnwd0------output-R-unsaturated downdraft mass flux (kg/m**2/s)
+! Ma---------output-R-adiabatic ascent mass flux (kg/m2/s)
+! mip--------output-R-mass flux shed by adiabatic ascent (kg/m2/s)
+! Vprecip----output-R-vertical profile of precipitations (kg/m2/s)
+! Tconv------output-R-environment temperature seen by convective scheme (K)
+! Cape-------output-R-CAPE (J/kg)
+! Cin -------output-R-CIN  (J/kg)
+! Tvp--------output-R-Temperature virtuelle d'une parcelle soulevee
+! adiabatiquement a partir du niveau 1 (K)
+! deltapb----output-R-distance entre LCL et base de la colonne (<0 ; Pa)
+! Ice_flag---input-L-TRUE->prise en compte de la thermodynamique de la glace
+! dd_t-------output-R-increment de la temperature du aux descentes precipitantes
+! dd_q-------output-R-increment de la vapeur d'eau du aux desc precip
+! lalim_conv-
+! wght_th----
+! evap-------output-R
+! ep---------output-R
+! epmlmMm----output-R
+! eplaMm-----output-R
+! wdtrainA---output-R
+! wdtrainM---output-R
+! wght-------output-R
+! ======================================================================
 
 
@@ -79,5 +93,5 @@
   REAL sig1(klon, klev), w01(klon, klev), ptop2(klon)
   REAL pmflxr(klon, klev+1), pmflxs(klon, klev+1)
-  REAL ale(klon), alp(klon)
+  REAL Ale(klon), Alp(klon)
 
   REAL d_t(klon, klev), d_q(klon, klev), d_u(klon, klev), d_v(klon, klev)
@@ -90,20 +104,21 @@
   REAL upwd(klon, klev), dnwd(klon, klev), dnwdbis(klon, klev)
 
-  ! !       REAL Ma(klon,klev), mip(klon,klev),Vprecip(klon,klev)     !jyg
-  REAL ma(klon, klev), mip(klon, klev), vprecip(klon, klev+1) !jyg
+!!       REAL Ma(klon,klev), mip(klon,klev),Vprecip(klon,klev)     !jyg
+  REAL Ma(klon, klev), mip(klon, klev), Vprecip(klon, klev+1)      !jyg
+  REAL wght(klon, klev)                                            !RL
 
   REAL da(klon, klev), phi(klon, klev, klev), mp(klon, klev)
-  ! RomP >>>
+! RomP >>>
   REAL phi2(klon, klev, klev)
   REAL d1a(klon, klev), dam(klon, klev)
   REAL sij(klon, klev, klev), clw(klon, klev), elij(klon, klev, klev)
-  REAL wdtraina(klon, klev), wdtrainm(klon, klev)
+  REAL wdtrainA(klon, klev), wdtrainM(klon, klev)
   REAL evap(klon, klev), ep(klon, klev)
-  REAL epmlmmm(klon, klev, klev), eplamm(klon, klev)
-  ! RomP <<<
+  REAL epmlmMm(klon, klev, klev), eplaMm(klon, klev)
+! RomP <<<
   REAL cape(klon), cin(klon), tvp(klon, klev)
-  REAL tconv(klon, klev)
-
-  ! CR:test: on passe lentr et alim_star des thermiques
+  REAL Tconv(klon, klev)
+
+!CR:test: on passe lentr et alim_star des thermiques
   INTEGER lalim_conv(klon)
   REAL wght_th(klon, klev)
@@ -111,6 +126,6 @@
   REAL em_sig2feed ! sigma at upper bound of feeding layer
   REAL em_wght(klev) ! weight density determining the feeding mixture
-  ! on enleve le save
-  ! SAVE em_sig1feed,em_sig2feed,em_wght
+!on enleve le save
+! SAVE em_sig1feed,em_sig2feed,em_wght
 
   INTEGER iflag(klon)
@@ -127,64 +142,64 @@
   REAL zx_t, zdelta, zx_qs, zcor
 
-  ! INTEGER iflag_mix
-  ! SAVE iflag_mix
+!   INTEGER iflag_mix
+!   SAVE iflag_mix
   INTEGER noff, minorig
   INTEGER i, k, itra
   REAL qs(klon, klev), qs_wake(klon, klev)
   REAL cbmf(klon), plcl(klon), plfc(klon), wbeff(klon)
-  ! LF       SAVE cbmf
-  ! IM/JYG      REAL, SAVE, ALLOCATABLE :: cbmf(:)
-  ! cc$OMP THREADPRIVATE(cbmf)!
+!LF          SAVE cbmf
+!IM/JYG      REAL, SAVE, ALLOCATABLE :: cbmf(:)
+!!!$OMP THREADPRIVATE(cbmf)!
   REAL cbmflast(klon)
   INTEGER ifrst
   SAVE ifrst
   DATA ifrst/0/
-  !$OMP THREADPRIVATE(ifrst)
-
-
-  ! Variables supplementaires liees au bilan d'energie
-  ! Real paire(klon)
-  ! LF      Real ql(klon,klev)
-  ! Save paire
-  ! LF      Save ql
-  ! LF      Real t1(klon,klev),q1(klon,klev)
-  ! LF      Save t1,q1
-  ! Data paire /1./
+!$OMP THREADPRIVATE(ifrst)
+
+
+! Variables supplementaires liees au bilan d'energie
+! Real paire(klon)
+!LF      Real ql(klon,klev)
+! Save paire
+!LF      Save ql
+!LF      Real t1(klon,klev),q1(klon,klev)
+!LF      Save t1,q1
+! Data paire /1./
   REAL, SAVE, ALLOCATABLE :: ql(:, :), q1(:, :), t1(:, :)
-  !$OMP THREADPRIVATE(ql, q1, t1)
-
-  ! Variables liees au bilan d'energie et d'enthalpi
+!$OMP THREADPRIVATE(ql, q1, t1)
+
+! Variables liees au bilan d'energie et d'enthAlpi
   REAL ztsol(klon)
-  REAL h_vcol_tot, h_dair_tot, h_qw_tot, h_ql_tot, h_qs_tot, qw_tot, ql_tot, &
-    qs_tot, ec_tot
-  SAVE h_vcol_tot, h_dair_tot, h_qw_tot, h_ql_tot, h_qs_tot, qw_tot, ql_tot, &
-    qs_tot, ec_tot
-  !$OMP THREADPRIVATE(h_vcol_tot, h_dair_tot, h_qw_tot, h_ql_tot)
-  !$OMP THREADPRIVATE(h_qs_tot, qw_tot, ql_tot, qs_tot , ec_tot)
-  REAL d_h_vcol, d_h_dair, d_qt, d_qw, d_ql, d_qs, d_ec
-  REAL d_h_vcol_phy
-  REAL fs_bound, fq_bound
-  SAVE d_h_vcol_phy
-  !$OMP THREADPRIVATE(d_h_vcol_phy)
-  REAL zero_v(klon)
+  REAL        h_vcol_tot, h_dair_tot, h_qw_tot, h_ql_tot, &
+              h_qs_tot, qw_tot, ql_tot, qs_tot, ec_tot
+  SAVE        h_vcol_tot, h_dair_tot, h_qw_tot, h_ql_tot, &
+              h_qs_tot, qw_tot, ql_tot, qs_tot, ec_tot
+!$OMP THREADPRIVATE(h_vcol_tot, h_dair_tot, h_qw_tot, h_ql_tot)
+!$OMP THREADPRIVATE(h_qs_tot, qw_tot, ql_tot, qs_tot , ec_tot)
+  REAL        d_h_vcol, d_h_dair, d_qt, d_qw, d_ql, d_qs, d_ec
+  REAL        d_h_vcol_phy
+  REAL        fs_bound, fq_bound
+  SAVE        d_h_vcol_phy
+!$OMP THREADPRIVATE(d_h_vcol_phy)
+  REAL        zero_v(klon)
   CHARACTER *15 ztit
-  INTEGER ip_ebil ! PRINT level for energy conserv. diag.
-  SAVE ip_ebil
-  DATA ip_ebil/2/
-  !$OMP THREADPRIVATE(ip_ebil)
-  INTEGER if_ebil ! level for energy conserv. dignostics
-  SAVE if_ebil
-  DATA if_ebil/2/
-  !$OMP THREADPRIVATE(if_ebil)
-  ! +jld ec_conser
+  INTEGER     ip_ebil ! PRINT level for energy conserv. diag.
+  SAVE        ip_ebil
+  DATA        ip_ebil/2/
+!$OMP THREADPRIVATE(ip_ebil)
+  INTEGER     if_ebil ! level for energy conserv. dignostics
+  SAVE        if_ebil
+  DATA        if_ebil/2/
+!$OMP THREADPRIVATE(if_ebil)
+!+jld ec_conser
   REAL d_t_ec(klon, klev) ! tendance du a la conersion Ec -> E thermique
   REAL zrcpd
-  ! -jld ec_conser
-  ! LF
+!-jld ec_conser
+!LF
   INTEGER nloc
-  LOGICAL, SAVE :: first = .TRUE.
-  !$OMP THREADPRIVATE(first)
-  INTEGER, SAVE :: itap, igout
-  !$OMP THREADPRIVATE(itap, igout)
+  LOGICAL, SAVE            :: first = .TRUE.
+!$OMP THREADPRIVATE(first)
+  INTEGER, SAVE            :: itap, igout
+!$OMP THREADPRIVATE(itap, igout)
 
   include "YOMCST.h"
@@ -195,7 +210,7 @@
 
   IF (first) THEN
-    ! Allocate some variables LF 04/2008
-
-    ! IM/JYG allocate(cbmf(klon))
+! Allocate some variables LF 04/2008
+
+!IM/JYG allocate(cbmf(klon))
     ALLOCATE (ql(klon,klev))
     ALLOCATE (t1(klon,klev))
@@ -204,11 +219,11 @@
     igout = klon/2 + 1/klon
   END IF
-  ! Incrementer le compteur de la physique
+! Incrementer le compteur de la physique
   itap = itap + 1
 
-  ! Copy T into Tconv
+! Copy T into Tconv
   DO k = 1, klev
     DO i = 1, klon
-      tconv(i, k) = t(i, k)
+      Tconv(i, k) = t(i, k)
     END DO
   END DO
@@ -224,45 +239,44 @@
   END IF
 
-  ! ym
+! ym
   snow(:) = 0
 
-  ! IF (ifrst .EQ. 0) THEN
-  ! ifrst = 1
+! IF (ifrst .EQ. 0) THEN
+! ifrst = 1
   IF (first) THEN
     first = .FALSE.
 
-    ! ===========================================================================
-    ! READ IN PARAMETERS FOR THE CLOSURE AND THE MIXING DISTRIBUTION
-    ! ===========================================================================
+! ===========================================================================
+! READ IN PARAMETERS FOR THE CLOSURE AND THE MIXING DISTRIBUTION
+! ===========================================================================
 
     IF (iflag_con==3) THEN
-      ! CALL cv3_inicp()
+!      CALL cv3_inicp()
       CALL cv3_inip()
     END IF
 
-    ! ===========================================================================
-    ! READ IN PARAMETERS FOR CONVECTIVE INHIBITION BY TROPOS. DRYNESS
-    ! ===========================================================================
-
-    ! c$$$         open (56,file='supcrit.data')
-    ! c$$$         read (56,*) Supcrit1, Supcrit2
-    ! c$$$         close (56)
-
-    IF (prt_level>=10) WRITE (lunout, *) 'supcrit1, supcrit2', supcrit1, &
-      supcrit2
-
-    ! ===========================================================================
-    ! Initialisation pour les bilans d'eau et d'energie
-    ! ===========================================================================
+! ===========================================================================
+! READ IN PARAMETERS FOR CONVECTIVE INHIBITION BY TROPOS. DRYNESS
+! ===========================================================================
+
+! c$$$         open (56,file='supcrit.data')
+! c$$$         read (56,*) Supcrit1, Supcrit2
+! c$$$         close (56)
+
+    IF (prt_level>=10) WRITE (lunout, *) 'supcrit1, supcrit2', supcrit1, supcrit2
+
+! ===========================================================================
+! Initialisation pour les bilans d'eau et d'energie
+! ===========================================================================
     IF (if_ebil>=1) d_h_vcol_phy = 0.
 
     DO i = 1, klon
       cbmf(i) = 0.
-      ! !          plcl(i) = 0.
+!!          plcl(i) = 0.
       sigd(i) = 0.
     END DO
   END IF !(ifrst .EQ. 0)
 
-  ! Initialisation a chaque pas de temps
+! Initialisation a chaque pas de temps
   plfc(:) = 0.
   wbeff(:) = 100.
@@ -284,20 +298,20 @@
 
 
-  ! Feeding layer
+! Feeding layer
 
   em_sig1feed = 1.
   em_sig2feed = 0.97
-  ! em_sig2feed = 0.8
-  ! Relative Weight densities
+! em_sig2feed = 0.8
+! Relative Weight densities
   DO k = 1, klev
     em_wght(k) = 1.
   END DO
-  ! CRtest: couche alim des tehrmiques ponderee par a*
-  ! DO i = 1, klon
-  ! do k=1,lalim_conv(i)
-  ! em_wght(k)=wght_th(i,k)
-  ! print*,'em_wght=',em_wght(k),wght_th(i,k)
-  ! end do
-  ! END DO
+!CRtest: couche alim des tehrmiques ponderee par a*
+! DO i = 1, klon
+! do k=1,lalim_conv(i)
+! em_wght(k)=wght_th(i,k)
+! print*,'em_wght=',em_wght(k),wght_th(i,k)
+! end do
+! END DO
 
   IF (iflag_con==4) THEN
@@ -318,6 +332,5 @@
       END DO
     END DO
-  ELSE ! iflag_con=3 (modif de puristes qui fait la diffce pour la
-    ! convergence numerique)
+  ELSE ! iflag_con=3 (modif de puristes qui fait la diffce pour la convergence numerique)
     DO k = 1, klev
       DO i = 1, klon
@@ -342,47 +355,66 @@
   END IF ! iflag_con
 
-  ! ------------------------------------------------------------------
-
-  ! Main driver for convection:
-  ! iflag_con=3 -> nvlle version de KE (JYG)
-  ! iflag_con = 30  -> equivalent to convect3
-  ! iflag_con = 4  -> equivalent to convect1/2
+! ------------------------------------------------------------------
+
+! Main driver for convection:
+!                   iflag_con=3 -> nvlle version de KE (JYG)
+!                   iflag_con = 30  -> equivAlent to convect3
+!                   iflag_con = 4  -> equivAlent to convect1/2
 
 
   IF (iflag_con==30) THEN
 
-    ! print *, '-> cv_driver'      !jyg
-    CALL cv_driver(klon, klev, klevp1, ntra, iflag_con, t, q, qs, u, v, tra, &
-      em_p, em_ph, iflag, d_t, d_q, d_u, d_v, d_tra, rain, vprecip, cbmf, &
-      sig1, w01, &                 !jyg
-      kbas, ktop, dtime, ma, upwd, dnwd, dnwdbis, qcondc, wd, cape, da, phi, &
-      mp, phi2, d1a, dam, sij, clw, elij, & !RomP
-      evap, ep, epmlmmm, eplamm, & !RomP
-      wdtraina, wdtrainm) !RomP
-    ! print *, 'cv_driver ->'      !jyg
-
-    DO i = 1, klon
-      cbmf(i) = ma(i, kbas(i))
-    END DO
+! print *, '-> cv_driver'      !jyg
+    CALL cv_driver(klon, klev, klevp1, ntra, iflag_con, &
+                   t, q, qs, u, v, tra, &
+                   em_p, em_ph, iflag, &
+                   d_t, d_q, d_u, d_v, d_tra, rain, &
+                   Vprecip, cbmf, sig1, w01, & !jyg
+                   kbas, ktop, &
+                   dtime, Ma, upwd, dnwd, dnwdbis, qcondc, wd, cape, &
+                   da, phi, mp, phi2, d1a, dam, sij, clw, elij, &       !RomP
+                   evap, ep, epmlmMm, eplaMm, &                         !RomP
+                   wdtrainA, wdtrainM)                                  !RomP
+!           print *, 'cv_driver ->'      !jyg
+
+    DO i = 1, klon
+      cbmf(i) = Ma(i, kbas(i))
+    END DO
+
+!RL
+    wght(:, :) = 0.
+    DO i = 1, klon
+      wght(i, 1) = 1.
+    END DO
+!RL
 
   ELSE
 
-    ! LF   necessary for gathered fields
+!LF   necessary for gathered fields
     nloc = klon
-    CALL cva_driver(klon, klev, klev+1, ntra, nloc, iflag_con, iflag_mix, &
-      iflag_ice_thermo, iflag_clos, dtime, t, q, qs, t_wake, q_wake, qs_wake, &
-      s_wake, u, v, tra, em_p, em_ph, ale, alp, em_sig1feed, em_sig2feed, &
-      em_wght, iflag, d_t, d_q, d_u, d_v, d_tra, rain, kbas, ktop, cbmf, &
-      plcl, plfc, wbeff, sig1, w01, ptop2, sigd, ma, mip, vprecip, upwd, &
-      dnwd, dnwdbis, qcondc, wd, cape, cin, tvp, dd_t, dd_q, plim1, plim2, &
-      asupmax, supmax0, asupmaxmin, lalim_conv, & ! AC!+!RomP+jyg
-      da, phi, mp, phi2, d1a, dam, sij, clw, elij, & ! RomP
-      evap, ep, epmlmmm, eplamm, & ! RomP
-      wdtraina, wdtrainm) ! RomP
-    ! AC!+!RomP+jyg
+    CALL cva_driver(klon, klev, klev+1, ntra, nloc, &
+                    iflag_con, iflag_mix, iflag_ice_thermo, &
+                    iflag_clos, ok_conserv_q, dtime, &
+                    t, q, qs, t_wake, q_wake, qs_wake, s_wake, u, v, tra, &
+                    em_p, em_ph, &
+                    Ale, Alp, &
+                    em_sig1feed, em_sig2feed, em_wght, &
+                    iflag, d_t, d_q, d_u, d_v, d_tra, rain, kbas, ktop, &
+                    cbmf, plcl, plfc, wbeff, sig1, w01, ptop2, sigd, &
+                    Ma, mip, Vprecip, upwd, dnwd, dnwdbis, qcondc, wd, &
+                    cape, cin, tvp, &
+                    dd_t, dd_q, plim1, plim2, asupmax, supmax0, &
+                    asupmaxmin, lalim_conv, &
+!AC!+!RomP+jyg
+!!                   da,phi,mp,phi2,d1a,dam,sij,clw,elij, &               ! RomP
+!!                   evap,ep,epmlmMm,eplaMm,                              ! RomP
+                    da, phi, mp, phi2, d1a, dam, sij, wght, &           ! RomP+RL
+                    clw, elij, evap, ep, epmlmMm, eplaMm, &             ! RomP+RL
+                    wdtrainA, wdtrainM)                                 ! RomP
+!AC!+!RomP+jyg
   END IF
-  ! ------------------------------------------------------------------
-  IF (prt_level>=10) WRITE (lunout, *) ' cva_driver -> cbmf,plcl,plfc,wbeff ' &
-    , cbmf(1), plcl(1), plfc(1), wbeff(1)
+! ------------------------------------------------------------------
+  IF (prt_level>=10) WRITE (lunout, *) ' cva_driver -> cbmf,plcl,plfc,wbeff ', &
+                                         cbmf(1), plcl(1), plfc(1), wbeff(1)
 
   DO i = 1, klon
@@ -404,5 +436,6 @@
       DO k = 1, klev
         DO i = 1, klon
-          d_tra(i, k, itra) = dtime*d_tra(i, k, itra)
+!RL!            d_tra(i,k,itra) =dtime*d_tra(i,k,itra)
+          d_tra(i, k, itra) = 0.
         END DO
       END DO
@@ -410,15 +443,16 @@
   END IF
 
-  ! !AC!
+!!AC!
   IF (iflag_con==3) THEN
     DO itra = 1, ntra
       DO k = 1, klev
         DO i = 1, klon
-          d_tra(i, k, itra) = dtime*d_tra(i, k, itra)
+!RL!            d_tra(i,k,itra) =dtime*d_tra(i,k,itra)
+          d_tra(i, k, itra) = 0.
         END DO
       END DO
     END DO
   END IF
-  ! !AC!
+!!AC!
 
   DO k = 1, klev
@@ -428,30 +462,30 @@
     END DO
   END DO
-  ! !jyg
-  ! --Separation neige/pluie (pour diagnostics)       !jyg
-  DO k = 1, klev !jyg
-    DO i = 1, klon !jyg
-      IF (t1(i,k)<rtt) THEN !jyg
-        pmflxs(i, k) = vprecip(i, k) !jyg
-      ELSE !jyg
-        pmflxr(i, k) = vprecip(i, k) !jyg
-      END IF !jyg
-    END DO !jyg
-  END DO !jyg
-
-  ! c      IF (if_ebil.ge.2) THEN
-  ! c        ztit='after convect'
-  ! c        CALL diagetpq(paire,ztit,ip_ebil,2,2,dtime
-  ! c     e      , t1,q1,ql,qs,u,v,paprs,pplay
-  ! c     s      , d_h_vcol, d_qt, d_qw, d_ql, d_qs, d_ec)
-  ! c         call diagphy(paire,ztit,ip_ebil
-  ! c     e      , zero_v, zero_v, zero_v, zero_v, zero_v
-  ! c     e      , zero_v, rain, zero_v, ztsol
-  ! c     e      , d_h_vcol, d_qt, d_ec
-  ! c     s      , fs_bound, fq_bound )
-  ! c      END IF
-
-
-  ! les traceurs ne sont pas mis dans cette version de convect4:
+!                                                   !jyg
+! --Separation neige/pluie (pour diagnostics)       !jyg
+  DO k = 1, klev                                    !jyg
+    DO i = 1, klon                                  !jyg
+      IF (t1(i,k)<rtt) THEN                         !jyg
+        pmflxs(i, k) = Vprecip(i, k)                !jyg
+      ELSE                                          !jyg
+        pmflxr(i, k) = Vprecip(i, k)                !jyg
+      END IF                                        !jyg
+    END DO                                          !jyg
+  END DO                                            !jyg
+
+! c      IF (if_ebil.ge.2) THEN
+! c        ztit='after convect'
+! c        CALL diagetpq(paire,ztit,ip_ebil,2,2,dtime
+! c     e      , t1,q1,ql,qs,u,v,paprs,pplay
+! c     s      , d_h_vcol, d_qt, d_qw, d_ql, d_qs, d_ec)
+! c         call diagphy(paire,ztit,ip_ebil
+! c     e      , zero_v, zero_v, zero_v, zero_v, zero_v
+! c     e      , zero_v, rain, zero_v, ztsol
+! c     e      , d_h_vcol, d_qt, d_ec
+! c     s      , fs_bound, fq_bound )
+! c      END IF
+
+
+! les traceurs ne sont pas mis dans cette version de convect4:
   IF (iflag_con==4) THEN
     DO itra = 1, ntra
@@ -463,5 +497,5 @@
     END DO
   END IF
-  ! print*, 'concvl->: dd_t,dd_q ',dd_t(1,1),dd_q(1,1)
+! print*, 'concvl->: dd_t,dd_q ',dd_t(1,1),dd_q(1,1)
 
   DO k = 1, klev
@@ -478,25 +512,25 @@
   IF (prt_level>=20) THEN
     DO k = 1, klev
-      ! print*,'physiq apres_add_con i k it d_u d_v d_t d_q qdl0',igout
-      ! .,k,itap,d_u_con(igout,k) ,d_v_con(igout,k), d_t_con(igout,k),
-      ! .d_q_con(igout,k),dql0(igout,k)
-      ! print*,'phys apres_add_con itap Ma cin ALE ALP wak t q undi t q'
-      ! .,itap,Ma(igout,k),cin(igout),ALE(igout), ALP(igout),
-      ! . t_wake(igout,k),q_wake(igout,k),t_undi(igout,k),q_undi(igout,k)
-      ! print*,'phy apres_add_con itap CON rain snow EMA wk1 wk2 Vpp mip'
-      ! .,itap,rain_con(igout),snow_con(igout),ema_work1(igout,k),
-      ! .ema_work2(igout,k),Vprecip(igout,k), mip(igout,k)
-      ! print*,'phy apres_add_con itap upwd dnwd dnwd0 cape tvp Tconv '
-      ! .,itap,upwd(igout,k),dnwd(igout,k),dnwd0(igout,k),cape(igout),
-      ! .tvp(igout,k),Tconv(igout,k)
-      ! print*,'phy apres_add_con itap dtvpdt dtvdq dplcl dplcldr qcondc'
-      ! .,itap,dtvpdt1(igout,k),dtvpdq1(igout,k),dplcldt(igout),
-      ! .dplcldr(igout),qcondc(igout,k)
-      ! print*,'phy apres_add_con itap wd pmflxr Kpmflxr Kp1 Kpmflxs Kp1'
-      ! .,itap,wd(igout),pmflxr(igout,k),pmflxr(igout,k+1),pmflxs(igout,k)
-      ! .,pmflxs(igout,k+1)
-      ! print*,'phy apres_add_con itap da phi mp ftd fqd lalim wgth',
-      ! .itap,da(igout,k),phi(igout,k,k),mp(igout,k),ftd(igout,k),
-      ! . fqd(igout,k),lalim_conv(igout),wght_th(igout,k)
+! print*,'physiq apres_add_con i k it d_u d_v d_t d_q qdl0',igout, &
+!         k,itap,d_u_con(igout,k) ,d_v_con(igout,k), d_t_con(igout,k), &
+!         d_q_con(igout,k),dql0(igout,k)
+! print*,'phys apres_add_con itap Ma cin ALE ALP wak t q undi t q', &
+!         itap,Ma(igout,k),cin(igout),ALE(igout), ALP(igout), &
+!         t_wake(igout,k),q_wake(igout,k),t_undi(igout,k),q_undi(igout,k)
+! print*,'phy apres_add_con itap CON rain snow EMA wk1 wk2 Vpp mip', &
+!         itap,rain_con(igout),snow_con(igout),ema_work1(igout,k), &
+!         ema_work2(igout,k),Vprecip(igout,k), mip(igout,k)
+! print*,'phy apres_add_con itap upwd dnwd dnwd0 cape tvp Tconv ', &
+!         itap,upwd(igout,k),dnwd(igout,k),dnwd0(igout,k),cape(igout), &
+!         tvp(igout,k),Tconv(igout,k)
+! print*,'phy apres_add_con itap dtvpdt dtvdq dplcl dplcldr qcondc', &
+!         itap,dtvpdt1(igout,k),dtvpdq1(igout,k),dplcldt(igout), &
+!         dplcldr(igout),qcondc(igout,k)
+! print*,'phy apres_add_con itap wd pmflxr Kpmflxr Kp1 Kpmflxs Kp1', &
+!         itap,wd(igout),pmflxr(igout,k),pmflxr(igout,k+1),pmflxs(igout,k), &
+!         pmflxs(igout,k+1)
+! print*,'phy apres_add_con itap da phi mp ftd fqd lalim wgth', &
+!         itap,da(igout,k),phi(igout,k,k),mp(igout,k),ftd(igout,k), &
+!         fqd(igout,k),lalim_conv(igout),wght_th(igout,k)
     END DO
   END IF !(prt_level.EQ.20) THEN
Index: /LMDZ5/branches/testing/libf/phylmd/conf_phys_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/conf_phys_m.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/conf_phys_m.F90	(revision 2056)
@@ -114,5 +114,6 @@
     real,save :: seuil_inversion_omp
 
-    integer,SAVE :: iflag_thermals_ed_omp,iflag_thermals_optflux_omp
+    integer,SAVE :: iflag_thermals_ed_omp,iflag_thermals_optflux_omp,iflag_thermals_closure_omp
+    real, SAVE :: fact_thermals_ed_dz_omp
     integer,SAVE :: iflag_thermals_omp,nsplit_thermals_omp
     real,save :: tau_thermals_omp,alp_bl_k_omp
@@ -145,6 +146,8 @@
     INTEGER,SAVE :: iflag_pdf_omp
     INTEGER,SAVE :: iflag_ice_thermo_omp
+    INTEGER,SAVE :: iflag_t_glace_omp
     REAL,SAVE :: rad_froid_omp, rad_chau1_omp, rad_chau2_omp
     REAL,SAVE :: t_glace_min_omp, t_glace_max_omp
+    REAL,SAVE :: exposant_glace_omp
     REAL,SAVE :: rei_min_omp, rei_max_omp
     REAL,SAVE :: inertie_sol_omp,inertie_sno_omp,inertie_ice_omp
@@ -179,4 +182,5 @@
     INTEGER, SAVE :: nbapp_rad_omp, iflag_con_omp
     INTEGER, SAVE :: iflag_ener_conserv_omp
+    LOGICAL, SAVE :: ok_conserv_q_omp
     INTEGER, SAVE :: iflag_fisrtilp_qsat_omp
     LOGICAL,SAVE :: ok_strato_omp
@@ -693,4 +697,13 @@
     iflag_ener_conserv_omp = -1
     CALL getin('iflag_ener_conserv',iflag_ener_conserv_omp)
+
+    !Config  Key  = ok_conserv_q
+    !Config  Desc = Switch des corrections de conservation de l'eau
+    !Config  Def  = y
+    !Config  Help = Switch des corrections de conservation de l'eau
+    !Config         y -> corrections activees
+    !Config         n -> conformite avec versions anterieures au 1/4/2014
+    ok_conserv_q_omp = .FALSE.
+    CALL getin('ok_conserv_q',ok_conserv_q_omp)
 
     !Config  Key  = iflag_fisrtilp_qsat
@@ -1005,4 +1018,22 @@
 
     !
+    !Config Key  = exposant_glace
+    !Config Desc =  
+    !Config Def  = 2.
+    !Config Help = 
+    !
+    exposant_glace_omp = 1.
+    call getin('exposant_glace',exposant_glace_omp)
+
+    !
+    !Config Key  = iflag_t_glace
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_t_glace_omp = 0
+    call getin('iflag_t_glace',iflag_t_glace_omp)
+
+    !
     !Config Key  = iflag_ice_thermo
     !Config Desc =  
@@ -1142,4 +1173,13 @@
     call getin('iflag_thermals',iflag_thermals_omp)
     !
+    !Config Key  = iflag_thermals_ed
+    !Config Desc =
+    !Config Def  = 0
+    !Config Help =
+    !
+    fact_thermals_ed_dz_omp = 0.1
+
+    call getin('fact_thermals_ed_dz',fact_thermals_ed_dz_omp)
+    !
     !
     !Config Key  = iflag_thermals_ed
@@ -1159,4 +1199,14 @@
     iflag_thermals_optflux_omp = 0
     call getin('iflag_thermals_optflux',iflag_thermals_optflux_omp)
+    !
+    !Config Key  = iflag_thermals_closure
+    !Config Desc =
+    !Config Def  = 0
+    !Config Help =
+    !
+    iflag_thermals_closure_omp = 1
+    call getin('iflag_thermals_closure',iflag_thermals_closure_omp)
+    !
+    !
     !
     !
@@ -1718,4 +1768,5 @@
     iflag_con = iflag_con_omp
     iflag_ener_conserv = iflag_ener_conserv_omp
+    ok_conserv_q = ok_conserv_q_omp
     iflag_fisrtilp_qsat = iflag_fisrtilp_qsat_omp
 
@@ -1744,4 +1795,6 @@
     t_glace_min = t_glace_min_omp
     t_glace_max = t_glace_max_omp
+    exposant_glace = exposant_glace_omp
+    iflag_t_glace = iflag_t_glace_omp
     iflag_ice_thermo = iflag_ice_thermo_omp
     rei_min = rei_min_omp
@@ -1813,5 +1866,7 @@
     iflag_thermals = iflag_thermals_omp
     iflag_thermals_ed = iflag_thermals_ed_omp
+    fact_thermals_ed_dz = fact_thermals_ed_dz_omp
     iflag_thermals_optflux = iflag_thermals_optflux_omp
+    iflag_thermals_closure = iflag_thermals_closure_omp
     nsplit_thermals = nsplit_thermals_omp
     tau_thermals = tau_thermals_omp
@@ -1940,4 +1995,5 @@
     write(lunout,*)'iflag_con=',iflag_con
     write(lunout,*)'iflag_ener_conserv=',iflag_ener_conserv
+    write(lunout,*)'ok_conserv_q=',ok_conserv_q
     write(lunout,*)'iflag_fisrtilp_qsat=',iflag_fisrtilp_qsat
     write(lunout,*)' epmax = ', epmax
@@ -1971,4 +2027,6 @@
     write(lunout,*)' t_glace_min = ',t_glace_min
     write(lunout,*)' t_glace_max = ',t_glace_max
+    write(lunout,*)' exposant_glace = ',exposant_glace
+    write(lunout,*)' iflag_t_glace = ',iflag_t_glace
     write(lunout,*)' iflag_ice_thermo = ',iflag_ice_thermo
     write(lunout,*)' rei_min = ',rei_min
@@ -2004,5 +2062,7 @@
     write(lunout,*)' iflag_thermals = ', iflag_thermals
     write(lunout,*)' iflag_thermals_ed = ', iflag_thermals_ed
+    write(lunout,*)' fact_thermals_ed_dz = ', fact_thermals_ed_dz
     write(lunout,*)' iflag_thermals_optflux = ', iflag_thermals_optflux
+    write(lunout,*)' iflag_thermals_closure = ', iflag_thermals_closure
     write(lunout,*)' iflag_clos = ', iflag_clos
     write(lunout,*)' type_run = ',type_run 
Index: /LMDZ5/branches/testing/libf/phylmd/cv3_routines.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/cv3_routines.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/cv3_routines.F90	(revision 2056)
@@ -7,26 +7,26 @@
   IMPLICIT NONE
 
-  ! ------------------------------------------------------------
-  ! Set parameters for convectL for iflag_con = 3
-  ! ------------------------------------------------------------
-
-
-  ! ***  PBCRIT IS THE CRITICAL CLOUD DEPTH (MB) BENEATH WHICH THE ***
-  ! ***      PRECIPITATION EFFICIENCY IS ASSUMED TO BE ZERO     ***
-  ! ***  PTCRIT IS THE CLOUD DEPTH (MB) ABOVE WHICH THE PRECIP. ***
-  ! ***            EFFICIENCY IS ASSUMED TO BE UNITY            ***
-  ! ***  SIGD IS THE FRACTIONAL AREA COVERED BY UNSATURATED DNDRAFT  ***
-  ! ***  SPFAC IS THE FRACTION OF PRECIPITATION FALLING OUTSIDE ***
-  ! ***                        OF CLOUD                         ***
-
-  ! [TAU: CHARACTERISTIC TIMESCALE USED TO COMPUTE ALPHA & BETA]
-  ! ***    ALPHA AND BETA ARE PARAMETERS THAT CONTROL THE RATE OF ***
-  ! ***                 APPROACH TO QUASI-EQUILIBRIUM           ***
-  ! ***    (THEIR STANDARD VALUES ARE 1.0 AND 0.96, RESPECTIVELY) ***
-  ! ***           (BETA MUST BE LESS THAN OR EQUAL TO 1)        ***
-
-  ! ***    DTCRIT IS THE CRITICAL BUOYANCY (K) USED TO ADJUST THE ***
-  ! ***                 APPROACH TO QUASI-EQUILIBRIUM           ***
-  ! ***                     IT MUST BE LESS THAN 0              ***
+!------------------------------------------------------------
+!Set parameters for convectL for iflag_con = 3
+!------------------------------------------------------------
+
+
+!***  PBCRIT IS THE CRITICAL CLOUD DEPTH (MB) BENEATH WHICH THE ***
+!***      PRECIPITATION EFFICIENCY IS ASSUMED TO BE ZERO     ***
+!***  PTCRIT IS THE CLOUD DEPTH (MB) ABOVE WHICH THE PRECIP. ***
+!***            EFFICIENCY IS ASSUMED TO BE UNITY            ***
+!***  SIGD IS THE FRACTIONAL AREA COVERED BY UNSATURATED DNDRAFT  ***
+!***  SPFAC IS THE FRACTION OF PRECIPITATION FALLING OUTSIDE ***
+!***                        OF CLOUD                         ***
+
+![TAU: CHARACTERISTIC TIMESCALE USED TO COMPUTE ALPHA & BETA]
+!***    ALPHA AND BETA ARE PARAMETERS THAT CONTROL THE RATE OF ***
+!***                 APPROACH TO QUASI-EQUILIBRIUM           ***
+!***    (THEIR STANDARD VALUES ARE 1.0 AND 0.96, RESPECTIVELY) ***
+!***           (BETA MUST BE LESS THAN OR EQUAL TO 1)        ***
+
+!***    DTCRIT IS THE CRITICAL BUOYANCY (K) USED TO ADJUST THE ***
+!***                 APPROACH TO QUASI-EQUILIBRIUM           ***
+!***                     IT MUST BE LESS THAN 0              ***
 
   include "cv3param.h"
@@ -41,10 +41,10 @@
 
   LOGICAL, SAVE :: first = .TRUE.
-  !$OMP THREADPRIVATE(first)
-
-  ! noff: integer limit for convection (nd-noff)
-  ! minorig: First level of convection
-
-  ! -- limit levels for convection:
+!$OMP THREADPRIVATE(first)
+
+!glb  noff: integer limit for convection (nd-noff)
+! minorig: First level of convection
+
+! -- limit levels for convection:
 
   noff = 1
@@ -56,41 +56,40 @@
   IF (first) THEN
 
-    ! -- "microphysical" parameters:
+! -- "microphysical" parameters:
     sigdz = 0.01
     spfac = 0.15
     pbcrit = 150.0
     ptcrit = 500.0
-    ! IM beg: ajout fis. reglage ep
+! IM beg: ajout fis. reglage ep
     flag_epkeorig = 1
     elcrit = 0.0003
     tlcrit = -55.0
-    ! IM lu dans physiq.def via conf_phys.F90     epmax  = 0.993
+! IM lu dans physiq.def via conf_phys.F90     epmax  = 0.993
 
     omtrain = 45.0 ! used also for snow (no disctinction rain/snow)
 
-    ! -- misc:
+! -- misc:
 
     dtovsh = -0.2 ! dT for overshoot
     dpbase = -40. ! definition cloud base (400m above LCL)
-    ! cc      dttrig = 5.   ! (loose) condition for triggering
+! cc      dttrig = 5.   ! (loose) condition for triggering
     dttrig = 10. ! (loose) condition for triggering
     flag_wb = 1
     wbmax = 6. ! (m/s) adiab updraught speed at LFC (used in cv3p1_closure)
 
-    ! -- rate of approach to quasi-equilibrium:
+! -- rate of approach to quasi-equilibrium:
 
     dtcrit = -2.0
     tau = 8000.
 
-    ! -- interface cloud parameterization:
+! -- interface cloud parameterization:
 
     delta = 0.01 ! cld
 
-    ! -- interface with boundary-layer (gust factor): (sb)
+! -- interface with boundary-layer (gust factor): (sb)
 
     betad = 10.0 ! original value (from convect 4.3)
 
-    OPEN (99, FILE='conv_param.data', STATUS='old', FORM='formatted', &
-      ERR=9999)
+    OPEN (99, FILE='conv_param.data', STATUS='old', FORM='formatted', ERR=9999)
     READ (99, *, END=9998) dpbase
     READ (99, *, END=9998) pbcrit
@@ -113,5 +112,5 @@
     WRITE (*, *) 'wbmax =', wbmax
 
-    ! IM Lecture du fichier ep_param.data
+! IM Lecture du fichier ep_param.data
     OPEN (79, FILE='ep_param.data', STATUS='old', FORM='formatted', ERR=7999)
     READ (79, *, END=7998) flag_epkeorig
@@ -124,41 +123,43 @@
     WRITE (*, *) 'elcrit=', elcrit
     WRITE (*, *) 'tlcrit=', tlcrit
-    ! IM end: ajout fis. reglage ep
+! IM end: ajout fis. reglage ep
 
     first = .FALSE.
-  END IF
-
+
+  END IF ! (first)
+
+! print*,'tau=',tau
   beta = 1.0 - delt/tau
   alpha1 = 1.5E-3
-  ! jyg    Correction bug alpha
+!JYG    Correction bug alpha
   alpha1 = alpha1*1.5
   alpha = alpha1*delt/tau
-  ! jyg    Bug
-  ! cc increase alpha to compensate W decrease:
-  ! c      alpha  = alpha*1.5
+!JYG    Bug
+! cc increase alpha to compensate W decrease:
+! c      alpha  = alpha*1.5
 
   RETURN
 END SUBROUTINE cv3_param
 
-SUBROUTINE cv3_prelim(len, nd, ndp1, t, q, p, ph, lv, lf, cpn, tv, gz, h, hm, &
-    th)
+SUBROUTINE cv3_prelim(len, nd, ndp1, t, q, p, ph, &
+                      lv, lf, cpn, tv, gz, h, hm, th)
   IMPLICIT NONE
 
-  ! =====================================================================
-  ! --- CALCULATE ARRAYS OF GEOPOTENTIAL, HEAT CAPACITY & STATIC ENERGY
-  ! "ori": from convect4.3 (vectorized)
-  ! "convect3": to be exactly consistent with convect3
-  ! =====================================================================
-
-  ! inputs:
+! =====================================================================
+! --- CALCULATE ARRAYS OF GEOPOTENTIAL, HEAT CAPACITY & STATIC ENERGY
+! "ori": from convect4.3 (vectorized)
+! "convect3": to be exactly consistent with convect3
+! =====================================================================
+
+! inputs:
   INTEGER len, nd, ndp1
   REAL t(len, nd), q(len, nd), p(len, nd), ph(len, ndp1)
 
-  ! outputs:
+! outputs:
   REAL lv(len, nd), lf(len, nd), cpn(len, nd), tv(len, nd)
   REAL gz(len, nd), h(len, nd), hm(len, nd)
   REAL th(len, nd)
 
-  ! local variables:
+! local variables:
   INTEGER k, i
   REAL rdcp
@@ -170,15 +171,15 @@
 
 
-  ! ori      do 110 k=1,nlp
-  ! abderr     do 110 k=1,nl ! convect3
+! ori      do 110 k=1,nlp
+! abderr     do 110 k=1,nl ! convect3
   DO k = 1, nlp
 
     DO i = 1, len
-      ! debug          lv(i,k)= lv0-clmcpv*(t(i,k)-t0)
+! debug          lv(i,k)= lv0-clmcpv*(t(i,k)-t0)
       lv(i, k) = lv0 - clmcpv*(t(i,k)-273.15)
       lf(i, k) = lf0 - clmci*(t(i,k)-273.15)
       cpn(i, k) = cpd*(1.0-q(i,k)) + cpv*q(i, k)
       cpx(i, k) = cpd*(1.0-q(i,k)) + cl*q(i, k)
-      ! ori          tv(i,k)=t(i,k)*(1.0+q(i,k)*epsim1)
+! ori          tv(i,k)=t(i,k)*(1.0+q(i,k)*epsim1)
       tv(i, k) = t(i, k)*(1.0+q(i,k)/eps-q(i,k))
       rdcp = (rrd*(1.-q(i,k))+q(i,k)*rrv)/cpn(i, k)
@@ -187,28 +188,28 @@
   END DO
 
-  ! gz = phi at the full levels (same as p).
+! gz = phi at the full levels (same as p).
 
   DO i = 1, len
     gz(i, 1) = 0.0
   END DO
-  ! ori      do 140 k=2,nlp
+! ori      do 140 k=2,nlp
   DO k = 2, nl ! convect3
     DO i = 1, len
-      tvx = t(i, k)*(1.+q(i,k)/eps-q(i,k)) !convect3
-      tvy = t(i, k-1)*(1.+q(i,k-1)/eps-q(i,k-1)) !convect3
-      gz(i, k) = gz(i, k-1) + 0.5*rrd*(tvx+tvy) & !convect3
-        *(p(i,k-1)-p(i,k))/ph(i, k) !convect3
-
-      ! c        print *,' gz(',k,')',gz(i,k),' tvx',tvx,' tvy ',tvy
-
-      ! ori         gz(i,k)=gz(i,k-1)+hrd*(tv(i,k-1)+tv(i,k))
-      ! ori    &         *(p(i,k-1)-p(i,k))/ph(i,k)
-    END DO
-  END DO
-
-  ! h  = phi + cpT (dry static energy).
-  ! hm = phi + cp(T-Tbase)+Lq
-
-  ! ori      do 170 k=1,nlp
+      tvx = t(i, k)*(1.+q(i,k)/eps-q(i,k))         !convect3
+      tvy = t(i, k-1)*(1.+q(i,k-1)/eps-q(i,k-1))   !convect3
+      gz(i, k) = gz(i, k-1) + 0.5*rrd*(tvx+tvy)* & !convect3
+                 (p(i,k-1)-p(i,k))/ph(i, k)        !convect3
+
+! c        print *,' gz(',k,')',gz(i,k),' tvx',tvx,' tvy ',tvy
+
+! ori         gz(i,k)=gz(i,k-1)+hrd*(tv(i,k-1)+tv(i,k))
+! ori    &         *(p(i,k-1)-p(i,k))/ph(i,k)
+    END DO
+  END DO
+
+! h  = phi + cpT (dry static energy).
+! hm = phi + cp(T-Tbase)+Lq
+
+! ori      do 170 k=1,nlp
   DO k = 1, nl ! convect3
     DO i = 1, len
@@ -221,28 +222,31 @@
 END SUBROUTINE cv3_prelim
 
-SUBROUTINE cv3_feed(len, nd, t, q, u, v, p, ph, hm, gz, p1feed, p2feed, wght, &
-    wghti, tnk, thnk, qnk, qsnk, unk, vnk, cpnk, hnk, nk, icb, icbmax, iflag, &
-    gznk, plcl)
+SUBROUTINE cv3_feed(len, nd, ok_conserv_q, &
+                    t, q, u, v, p, ph, hm, gz, &
+                    p1feed, p2feed, wght, &
+                    wghti, tnk, thnk, qnk, qsnk, unk, vnk, &
+                    cpnk, hnk, nk, icb, icbmax, iflag, gznk, plcl)
   IMPLICIT NONE
 
-  ! ================================================================
-  ! Purpose: CONVECTIVE FEED
-
-  ! Main differences with cv_feed:
-  ! - ph added in input
-  ! - here, nk(i)=minorig
-  ! - icb defined differently (plcl compared with ph instead of p)
-
-  ! Main differences with convect3:
-  ! - we do not compute dplcldt and dplcldr of CLIFT anymore
-  ! - values iflag different (but tests identical)
-  ! - A,B explicitely defined (!...)
-  ! ================================================================
+! ================================================================
+! Purpose: CONVECTIVE FEED
+
+! Main differences with cv_feed:
+! - ph added in input
+! - here, nk(i)=minorig
+! - icb defined differently (plcl compared with ph instead of p)
+
+! Main differences with convect3:
+! - we do not compute dplcldt and dplcldr of CLIFT anymore
+! - values iflag different (but tests identical)
+! - A,B explicitely defined (!...)
+! ================================================================
 
   include "cv3param.h"
   include "cvthermo.h"
 
-  ! inputs:
+!inputs:
   INTEGER len, nd
+  LOGICAL ok_conserv_q
   REAL t(len, nd), q(len, nd), p(len, nd)
   REAL u(len, nd), v(len, nd)
@@ -250,11 +254,11 @@
   REAL ph(len, nd+1)
   REAL p1feed(len)
-  ! ,  wght(len)
+! ,  wght(len)
   REAL wght(nd)
-  ! input-output
+!input-output
   REAL p2feed(len)
-  ! outputs:
+!outputs:
   INTEGER iflag(len), nk(len), icb(len), icbmax
-  ! real   wghti(len)
+!   real   wghti(len)
   REAL wghti(len, nd)
   REAL tnk(len), thnk(len), qnk(len), qsnk(len)
@@ -263,5 +267,5 @@
   REAL plcl(len)
 
-  ! local variables:
+!local variables:
   INTEGER i, k, iter, niter
   INTEGER ihmin(len)
@@ -269,10 +273,34 @@
   REAL pup(len), plo(len), pfeed(len)
   REAL plclup(len), plcllo(len), plclfeed(len)
+  REAL pfeedmin(len)
   REAL posit(len)
   LOGICAL nocond(len)
 
-  ! -------------------------------------------------------------------
-  ! --- Origin level of ascending parcels for convect3:
-  ! -------------------------------------------------------------------
+!jyg20140217<
+  INTEGER iostat
+  LOGICAL, SAVE :: first
+  LOGICAL, SAVE :: ok_new_feed
+  REAL, SAVE :: dp_lcl_feed
+!$OMP THREADPRIVATE (first,ok_new_feed,dp_lcl_feed)
+  DATA first/.TRUE./
+  DATA dp_lcl_feed/2./
+
+  IF (first) THEN
+!$OMP MASTER
+    ok_new_feed = ok_conserv_q
+    OPEN (98, FILE='cv3feed_param.data', STATUS='old', FORM='formatted', IOSTAT=iostat)
+    IF (iostat==0) THEN
+      READ (98, *, END=998) ok_new_feed
+998   CONTINUE
+      CLOSE (98)
+    END IF
+    PRINT *, ' ok_new_feed: ', ok_new_feed
+    first = .FALSE.
+!$OMP END MASTER
+  END IF
+!jyg>
+! -------------------------------------------------------------------
+! --- Origin level of ascending parcels for convect3:
+! -------------------------------------------------------------------
 
   DO i = 1, len
@@ -281,26 +309,28 @@
   END DO
 
-  ! -------------------------------------------------------------------
-  ! --- Adjust feeding layer thickness so that lifting up to the top of
-  ! --- the feeding layer does not induce condensation (i.e. so that
-  ! --- plcl < p2feed).
-  ! --- Method : iterative secant method.
-  ! -------------------------------------------------------------------
-
-  ! 1- First bracketing of the solution : ph(nk+1), p2feed
-
-  ! 1.a- LCL associated to p2feed
+! -------------------------------------------------------------------
+! --- Adjust feeding layer thickness so that lifting up to the top of
+! --- the feeding layer does not induce condensation (i.e. so that
+! --- plcl < p2feed).
+! --- Method : iterative secant method.
+! -------------------------------------------------------------------
+
+! 1- First bracketing of the solution : ph(nk+1), p2feed
+
+! 1.a- LCL associated with p2feed
   DO i = 1, len
     pup(i) = p2feed(i)
   END DO
-  CALL cv3_vertmix(len, nd, iflag, p1feed, pup, p, ph, t, q, u, v, wght, &
-    wghti, nk, tnk, thnk, qnk, qsnk, unk, vnk, plclup)
-  ! 1.b- LCL associated to ph(nk+1)
+  CALL cv3_vertmix(len, nd, iflag, p1feed, pup, p, ph, &
+                   t, q, u, v, wght, &
+                   wghti, nk, tnk, thnk, qnk, qsnk, unk, vnk, plclup)
+! 1.b- LCL associated with ph(nk+1)
   DO i = 1, len
     plo(i) = ph(i, nk(i)+1)
   END DO
-  CALL cv3_vertmix(len, nd, iflag, p1feed, plo, p, ph, t, q, u, v, wght, &
-    wghti, nk, tnk, thnk, qnk, qsnk, unk, vnk, plcllo)
-  ! 2- Iterations
+  CALL cv3_vertmix(len, nd, iflag, p1feed, plo, p, ph, &
+                   t, q, u, v, wght, &
+                   wghti, nk, tnk, thnk, qnk, qsnk, unk, vnk, plcllo)
+! 2- Iterations
   niter = 5
   DO iter = 1, niter
@@ -314,17 +344,55 @@
         pfeed(i) = pup(i)
       ELSE
-        pfeed(i) = (pup(i)*(plo(i)-plcllo(i))+plo(i)*(plclup(i)-pup(i)))/ &
-          (plo(i)-plcllo(i)+plclup(i)-pup(i))
+!JYG20140217<
+        IF (ok_new_feed) THEN
+          pfeed(i) = (pup(i)*(plo(i)-plcllo(i)-dp_lcl_feed)+  &
+                      plo(i)*(plclup(i)-pup(i)+dp_lcl_feed))/ &
+                     (plo(i)-plcllo(i)+plclup(i)-pup(i))
+        ELSE
+          pfeed(i) = (pup(i)*(plo(i)-plcllo(i))+  &
+                      plo(i)*(plclup(i)-pup(i)))/ &
+                     (plo(i)-plcllo(i)+plclup(i)-pup(i))
+        END IF
+!JYG>
       END IF
     END DO
-    CALL cv3_vertmix(len, nd, iflag, p1feed, pfeed, p, ph, t, q, u, v, wght, &
-      wghti, nk, tnk, thnk, qnk, qsnk, unk, vnk, plclfeed)
+!jyg20140217<
+! For the last iteration, make sure that the top of the feeding layer
+! and LCL are not in the same layer:
+    IF (ok_new_feed) THEN
+      IF (iter==niter) THEN
+        DO k = minorig, nd
+          DO i = 1, len
+            IF (ph(i,k)>=plclfeed(i)) pfeedmin(i) = ph(i, k)
+          END DO
+        END DO
+        DO i = 1, len
+          pfeed(i) = max(pfeedmin(i), pfeed(i))
+        END DO
+      END IF
+    END IF
+!jyg>
+
+    CALL cv3_vertmix(len, nd, iflag, p1feed, pfeed, p, ph, &
+                   t, q, u, v, wght, &
+                   wghti, nk, tnk, thnk, qnk, qsnk, unk, vnk, plclfeed)
+!jyg20140217<
+    IF (ok_new_feed) THEN
+      DO i = 1, len
+        posit(i) = (sign(1.,plclfeed(i)-pfeed(i)+dp_lcl_feed)+1.)*0.5
+        IF (plclfeed(i)-pfeed(i)+dp_lcl_feed==0.) posit(i) = 1.
+      END DO
+    ELSE
+      DO i = 1, len
+        posit(i) = (sign(1.,plclfeed(i)-pfeed(i))+1.)*0.5
+        IF (plclfeed(i)==pfeed(i)) posit(i) = 1.
+      END DO
+    END IF
+!jyg>
     DO i = 1, len
-      posit(i) = (sign(1.,plclfeed(i)-pfeed(i))+1.)*0.5
-      IF (plclfeed(i)==pfeed(i)) posit(i) = 1.
-      ! - posit = 1 when lcl is below top of feeding layer (plclfeed>pfeed)
-      ! -               => pup=pfeed
-      ! - posit = 0 when lcl is above top of feeding layer (plclfeed<pfeed)
-      ! -               => plo=pfeed
+! - posit = 1 when lcl is below top of feeding layer (plclfeed>pfeed)
+! -               => pup=pfeed
+! - posit = 0 when lcl is above top of feeding layer (plclfeed<pfeed)
+! -               => plo=pfeed
       pup(i) = posit(i)*pfeed(i) + (1.-posit(i))*pup(i)
       plo(i) = (1.-posit(i))*pfeed(i) + posit(i)*plo(i)
@@ -343,30 +411,30 @@
   END DO
 
-  ! -------------------------------------------------------------------
-  ! --- Check whether parcel level temperature and specific humidity
-  ! --- are reasonable
-  ! -------------------------------------------------------------------
+! -------------------------------------------------------------------
+! --- Check whether parcel level temperature and specific humidity
+! --- are reasonable
+! -------------------------------------------------------------------
   DO i = 1, len
     IF (((tnk(i)<250.0) .OR. (qnk(i)<=0.0)) .AND. (iflag(i)==0)) iflag(i) = 7
   END DO
 
-  ! -------------------------------------------------------------------
-  ! --- Calculate first level above lcl (=icb)
-  ! -------------------------------------------------------------------
-
-  ! @      do 270 i=1,len
-  ! @       icb(i)=nlm
-  ! @ 270  continue
-  ! @c
-  ! @      do 290 k=minorig,nl
-  ! @        do 280 i=1,len
-  ! @          if((k.ge.(nk(i)+1)).and.(p(i,k).lt.plcl(i)))
-  ! @     &    icb(i)=min(icb(i),k)
-  ! @ 280    continue
-  ! @ 290  continue
-  ! @c
-  ! @      do 300 i=1,len
-  ! @        if((icb(i).ge.nlm).and.(iflag(i).eq.0))iflag(i)=9
-  ! @ 300  continue
+! -------------------------------------------------------------------
+! --- Calculate first level above lcl (=icb)
+! -------------------------------------------------------------------
+
+!@      do 270 i=1,len
+!@       icb(i)=nlm
+!@ 270  continue
+!@c
+!@      do 290 k=minorig,nl
+!@        do 280 i=1,len
+!@          if((k.ge.(nk(i)+1)).and.(p(i,k).lt.plcl(i)))
+!@     &    icb(i)=min(icb(i),k)
+!@ 280    continue
+!@ 290  continue
+!@c
+!@      do 300 i=1,len
+!@        if((icb(i).ge.nlm).and.(iflag(i).eq.0))iflag(i)=9
+!@ 300  continue
 
   DO i = 1, len
@@ -374,7 +442,7 @@
   END DO
 
-  ! la modification consiste a comparer plcl a ph et non a p:
-  ! icb est defini par :  ph(icb)<plcl<ph(icb-1)
-  ! @      do 290 k=minorig,nl
+! la modification consiste a comparer plcl a ph et non a p:
+! icb est defini par :  ph(icb)<plcl<ph(icb-1)
+!@      do 290 k=minorig,nl
   DO k = 3, nl - 1 ! modif pour que icb soit sup/egal a 2
     DO i = 1, len
@@ -384,10 +452,10 @@
 
 
-  ! print*,'icb dans cv3_feed '
-  ! write(*,'(64i2)') icb(2:len-1)
-  ! call dump2d(64,43,'plcl dans cv3_feed ',plcl(2:len-1))
+! print*,'icb dans cv3_feed '
+! write(*,'(64i2)') icb(2:len-1)
+! call dump2d(64,43,'plcl dans cv3_feed ',plcl(2:len-1))
 
   DO i = 1, len
-    ! @        if((icb(i).ge.nlm).and.(iflag(i).eq.0))iflag(i)=9
+!@        if((icb(i).ge.nlm).and.(iflag(i).eq.0))iflag(i)=9
     IF ((icb(i)==nlm) .AND. (iflag(i)==0)) iflag(i) = 9
   END DO
@@ -397,10 +465,10 @@
   END DO
 
-  ! Compute icbmax.
+! Compute icbmax.
 
   icbmax = 2
   DO i = 1, len
-    ! !        icbmax=max(icbmax,icb(i))
-    IF (iflag(i)<7) icbmax = max(icbmax, icb(i)) ! sb Jun7th02
+!!        icbmax=max(icbmax,icb(i))
+    IF (iflag(i)<7) icbmax = max(icbmax, icb(i))     ! sb Jun7th02
   END DO
 
@@ -409,24 +477,24 @@
 
 SUBROUTINE cv3_undilute1(len, nd, t, qs, gz, plcl, p, icb, tnk, qnk, gznk, &
-    tp, tvp, clw, icbs)
+                         tp, tvp, clw, icbs)
   IMPLICIT NONE
 
-  ! ----------------------------------------------------------------
-  ! Equivalent de TLIFT entre NK et ICB+1 inclus
-
-  ! Differences with convect4:
-  ! - specify plcl in input
-  ! - icbs is the first level above LCL (may differ from icb)
-  ! - in the iterations, used x(icbs) instead x(icb)
-  ! - many minor differences in the iterations
-  ! - tvp is computed in only one time
-  ! - icbs: first level above Plcl (IMIN de TLIFT) in output
-  ! - if icbs=icb, compute also tp(icb+1),tvp(icb+1) & clw(icb+1)
-  ! ----------------------------------------------------------------
+! ----------------------------------------------------------------
+! Equivalent de TLIFT entre NK et ICB+1 inclus
+
+! Differences with convect4:
+!    - specify plcl in input
+!    - icbs is the first level above LCL (may differ from icb)
+!    - in the iterations, used x(icbs) instead x(icb)
+!    - many minor differences in the iterations
+!    - tvp is computed in only one time
+!    - icbs: first level above Plcl (IMIN de TLIFT) in output
+!    - if icbs=icb, compute also tp(icb+1),tvp(icb+1) & clw(icb+1)
+! ----------------------------------------------------------------
 
   include "cvthermo.h"
   include "cv3param.h"
 
-  ! inputs:
+! inputs:
   INTEGER len, nd
   INTEGER icb(len)
@@ -436,8 +504,8 @@
   REAL plcl(len) ! convect3
 
-  ! outputs:
+! outputs:
   REAL tp(len, nd), tvp(len, nd), clw(len, nd)
 
-  ! local variables:
+! local variables:
   INTEGER i, k
   INTEGER icb1(len), icbs(len), icbsmax2 ! convect3
@@ -448,160 +516,159 @@
   REAL cpinv(len) ! convect3
 
-  ! -------------------------------------------------------------------
-  ! --- Calculates the lifted parcel virtual temperature at nk,
-  ! --- the actual temperature, and the adiabatic
-  ! --- liquid water content. The procedure is to solve the equation.
-  ! cp*tp+L*qp+phi=cp*tnk+L*qnk+gznk.
-  ! -------------------------------------------------------------------
-
-
-  ! ***  Calculate certain parcel quantities, including static energy   ***
+! -------------------------------------------------------------------
+! --- Calculates the lifted parcel virtual temperature at nk,
+! --- the actual temperature, and the adiabatic
+! --- liquid water content. The procedure is to solve the equation.
+!     cp*tp+L*qp+phi=cp*tnk+L*qnk+gznk.
+! -------------------------------------------------------------------
+
+
+! ***  Calculate certain parcel quantities, including static energy   ***
 
   DO i = 1, len
-    ah0(i) = (cpd*(1.-qnk(i))+cl*qnk(i))*tnk(i) + qnk(i)*(lv0-clmcpv*(tnk(i)- &
-      273.15)) + gznk(i)
+    ah0(i) = (cpd*(1.-qnk(i))+cl*qnk(i))*tnk(i) + qnk(i)*(lv0-clmcpv*(tnk(i)-273.15)) + gznk(i)
     cpp(i) = cpd*(1.-qnk(i)) + qnk(i)*cpv
     cpinv(i) = 1./cpp(i)
   END DO
 
-  ! ***   Calculate lifted parcel quantities below cloud base   ***
+! ***   Calculate lifted parcel quantities below cloud base   ***
+
+  DO i = 1, len                                           !convect3
+    icb1(i) = max(icb(i), 2)                              !convect3
+    icb1(i) = min(icb(i), nl)                             !convect3
+! if icb is below LCL, start loop at ICB+1:
+! (icbs est le premier niveau au-dessus du LCL)
+    icbs(i) = icb1(i)                                     !convect3
+    IF (plcl(i)<p(i,icb1(i))) THEN
+      icbs(i) = min(icbs(i)+1, nl)                        !convect3
+    END IF
+  END DO                                                  !convect3
 
   DO i = 1, len !convect3
-    icb1(i) = max(icb(i), 2) !convect3
-    icb1(i) = min(icb(i), nl) !convect3
-    ! if icb is below LCL, start loop at ICB+1:
-    ! (icbs est le premier niveau au-dessus du LCL)
-    icbs(i) = icb1(i) !convect3
-    IF (plcl(i)<p(i,icb1(i))) THEN
-      icbs(i) = min(icbs(i)+1, nl) !convect3
-    END IF
+    ticb(i) = t(i, icbs(i))                               !convect3
+    gzicb(i) = gz(i, icbs(i))                             !convect3
+    qsicb(i) = qs(i, icbs(i))                             !convect3
   END DO !convect3
 
-  DO i = 1, len !convect3
-    ticb(i) = t(i, icbs(i)) !convect3
-    gzicb(i) = gz(i, icbs(i)) !convect3
-    qsicb(i) = qs(i, icbs(i)) !convect3
-  END DO !convect3
-
-
-  ! Re-compute icbsmax (icbsmax2):        !convect3
-  ! !convect3
-  icbsmax2 = 2 !convect3
-  DO i = 1, len !convect3
-    icbsmax2 = max(icbsmax2, icbs(i)) !convect3
-  END DO !convect3
-
-  ! initialization outputs:
-
-  DO k = 1, icbsmax2 ! convect3
-    DO i = 1, len ! convect3
-      tp(i, k) = 0.0 ! convect3
-      tvp(i, k) = 0.0 ! convect3
-      clw(i, k) = 0.0 ! convect3
-    END DO ! convect3
-  END DO ! convect3
-
-  ! tp and tvp below cloud base:
+
+! Re-compute icbsmax (icbsmax2):                          !convect3
+!                                                         !convect3
+  icbsmax2 = 2                                            !convect3
+  DO i = 1, len                                           !convect3
+    icbsmax2 = max(icbsmax2, icbs(i))                     !convect3
+  END DO                                                  !convect3
+
+! initialization outputs:
+
+  DO k = 1, icbsmax2                                      ! convect3
+    DO i = 1, len                                         ! convect3
+      tp(i, k) = 0.0                                      ! convect3
+      tvp(i, k) = 0.0                                     ! convect3
+      clw(i, k) = 0.0                                     ! convect3
+    END DO                                                ! convect3
+  END DO                                                  ! convect3
+
+! tp and tvp below cloud base:
 
   DO k = minorig, icbsmax2 - 1
     DO i = 1, len
       tp(i, k) = tnk(i) - (gz(i,k)-gznk(i))*cpinv(i)
-      tvp(i, k) = tp(i, k)*(1.+qnk(i)/eps-qnk(i)) !whole thing (convect3)
-    END DO
-  END DO
-
-  ! ***  Find lifted parcel quantities above cloud base    ***
+      tvp(i, k) = tp(i, k)*(1.+qnk(i)/eps-qnk(i))        !whole thing (convect3)
+    END DO
+  END DO
+
+! ***  Find lifted parcel quantities above cloud base    ***
 
   DO i = 1, len
     tg = ticb(i)
-    ! ori         qg=qs(i,icb(i))
+! ori         qg=qs(i,icb(i))
     qg = qsicb(i) ! convect3
-    ! debug         alv=lv0-clmcpv*(ticb(i)-t0)
+! debug         alv=lv0-clmcpv*(ticb(i)-t0)
     alv = lv0 - clmcpv*(ticb(i)-273.15)
 
-    ! First iteration.
-
-    ! ori          s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i))
-    s = cpd*(1.-qnk(i)) + cl*qnk(i) & ! convect3
-      +alv*alv*qg/(rrv*ticb(i)*ticb(i)) ! convect3
+! First iteration.
+
+! ori          s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i))
+    s = cpd*(1.-qnk(i)) + cl*qnk(i) + &                   ! convect3
+        alv*alv*qg/(rrv*ticb(i)*ticb(i))                  ! convect3
     s = 1./s
-    ! ori          ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i)
+! ori          ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i)
     ahg = cpd*tg + (cl-cpd)*qnk(i)*tg + alv*qg + gzicb(i) ! convect3
     tg = tg + s*(ah0(i)-ahg)
-    ! ori          tg=max(tg,35.0)
-    ! debug          tc=tg-t0
+! ori          tg=max(tg,35.0)
+! debug          tc=tg-t0
     tc = tg - 273.15
     denom = 243.5 + tc
     denom = max(denom, 1.0) ! convect3
-    ! ori          if(tc.ge.0.0)then
+! ori          if(tc.ge.0.0)then
     es = 6.112*exp(17.67*tc/denom)
-    ! ori          else
-    ! ori           es=exp(23.33086-6111.72784/tg+0.15215*log(tg))
-    ! ori          endif
-    ! ori          qg=eps*es/(p(i,icb(i))-es*(1.-eps))
+! ori          else
+! ori           es=exp(23.33086-6111.72784/tg+0.15215*log(tg))
+! ori          endif
+! ori          qg=eps*es/(p(i,icb(i))-es*(1.-eps))
     qg = eps*es/(p(i,icbs(i))-es*(1.-eps))
 
-    ! Second iteration.
-
-
-    ! ori          s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i))
-    ! ori          s=1./s
-    ! ori          ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i)
+! Second iteration.
+
+
+! ori          s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i))
+! ori          s=1./s
+! ori          ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i)
     ahg = cpd*tg + (cl-cpd)*qnk(i)*tg + alv*qg + gzicb(i) ! convect3
     tg = tg + s*(ah0(i)-ahg)
-    ! ori          tg=max(tg,35.0)
-    ! debug          tc=tg-t0
+! ori          tg=max(tg,35.0)
+! debug          tc=tg-t0
     tc = tg - 273.15
     denom = 243.5 + tc
-    denom = max(denom, 1.0) ! convect3
-    ! ori          if(tc.ge.0.0)then
+    denom = max(denom, 1.0)                               ! convect3
+! ori          if(tc.ge.0.0)then
     es = 6.112*exp(17.67*tc/denom)
-    ! ori          else
-    ! ori           es=exp(23.33086-6111.72784/tg+0.15215*log(tg))
-    ! ori          end if
-    ! ori          qg=eps*es/(p(i,icb(i))-es*(1.-eps))
+! ori          else
+! ori           es=exp(23.33086-6111.72784/tg+0.15215*log(tg))
+! ori          end if
+! ori          qg=eps*es/(p(i,icb(i))-es*(1.-eps))
     qg = eps*es/(p(i,icbs(i))-es*(1.-eps))
 
     alv = lv0 - clmcpv*(ticb(i)-273.15)
 
-    ! ori c approximation here:
-    ! ori         tp(i,icb(i))=(ah0(i)-(cl-cpd)*qnk(i)*ticb(i)
-    ! ori     &   -gz(i,icb(i))-alv*qg)/cpd
-
-    ! convect3: no approximation:
+! ori c approximation here:
+! ori         tp(i,icb(i))=(ah0(i)-(cl-cpd)*qnk(i)*ticb(i)
+! ori     &   -gz(i,icb(i))-alv*qg)/cpd
+
+! convect3: no approximation:
     tp(i, icbs(i)) = (ah0(i)-gz(i,icbs(i))-alv*qg)/(cpd+(cl-cpd)*qnk(i))
 
-    ! ori         clw(i,icb(i))=qnk(i)-qg
-    ! ori         clw(i,icb(i))=max(0.0,clw(i,icb(i)))
+! ori         clw(i,icb(i))=qnk(i)-qg
+! ori         clw(i,icb(i))=max(0.0,clw(i,icb(i)))
     clw(i, icbs(i)) = qnk(i) - qg
     clw(i, icbs(i)) = max(0.0, clw(i,icbs(i)))
 
     rg = qg/(1.-qnk(i))
-    ! ori         tvp(i,icb(i))=tp(i,icb(i))*(1.+rg*epsi)
-    ! convect3: (qg utilise au lieu du vrai mixing ratio rg)
-    tvp(i, icbs(i)) = tp(i, icbs(i))*(1.+qg/eps-qnk(i)) !whole thing
-
-  END DO
-
-  ! ori      do 380 k=minorig,icbsmax2
-  ! ori       do 370 i=1,len
-  ! ori         tvp(i,k)=tvp(i,k)-tp(i,k)*qnk(i)
-  ! ori 370   continue
-  ! ori 380  continue
-
-
-  ! -- The following is only for convect3:
-
-  ! * icbs is the first level above the LCL:
-  ! if plcl<p(icb), then icbs=icb+1
-  ! if plcl>p(icb), then icbs=icb
-
-  ! * the routine above computes tvp from minorig to icbs (included).
-
-  ! * to compute buoybase (in cv3_trigger.F), both tvp(icb) and tvp(icb+1)
-  ! must be known. This is the case if icbs=icb+1, but not if icbs=icb.
-
-  ! * therefore, in the case icbs=icb, we compute tvp at level icb+1
-  ! (tvp at other levels will be computed in cv3_undilute2.F)
+! ori         tvp(i,icb(i))=tp(i,icb(i))*(1.+rg*epsi)
+! convect3: (qg utilise au lieu du vrai mixing ratio rg)
+    tvp(i, icbs(i)) = tp(i, icbs(i))*(1.+qg/eps-qnk(i))   !whole thing
+
+  END DO
+
+! ori      do 380 k=minorig,icbsmax2
+! ori       do 370 i=1,len
+! ori         tvp(i,k)=tvp(i,k)-tp(i,k)*qnk(i)
+! ori 370   continue
+! ori 380  continue
+
+
+! -- The following is only for convect3:
+
+! * icbs is the first level above the LCL:
+! if plcl<p(icb), then icbs=icb+1
+! if plcl>p(icb), then icbs=icb
+
+! * the routine above computes tvp from minorig to icbs (included).
+
+! * to compute buoybase (in cv3_trigger.F), both tvp(icb) and tvp(icb+1)
+! must be known. This is the case if icbs=icb+1, but not if icbs=icb.
+
+! * therefore, in the case icbs=icb, we compute tvp at level icb+1
+! (tvp at other levels will be computed in cv3_undilute2.F)
 
 
@@ -615,68 +682,68 @@
     tg = ticb(i)
     qg = qsicb(i) ! convect3
-    ! debug         alv=lv0-clmcpv*(ticb(i)-t0)
+! debug         alv=lv0-clmcpv*(ticb(i)-t0)
     alv = lv0 - clmcpv*(ticb(i)-273.15)
 
-    ! First iteration.
-
-    ! ori          s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i))
-    s = cpd*(1.-qnk(i)) + cl*qnk(i) & ! convect3
-      +alv*alv*qg/(rrv*ticb(i)*ticb(i)) ! convect3
+! First iteration.
+
+! ori          s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i))
+    s = cpd*(1.-qnk(i)) + cl*qnk(i) &                         ! convect3
+      +alv*alv*qg/(rrv*ticb(i)*ticb(i))                       ! convect3
     s = 1./s
-    ! ori          ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i)
-    ahg = cpd*tg + (cl-cpd)*qnk(i)*tg + alv*qg + gzicb(i) ! convect3
+! ori          ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i)
+    ahg = cpd*tg + (cl-cpd)*qnk(i)*tg + alv*qg + gzicb(i)     ! convect3
     tg = tg + s*(ah0(i)-ahg)
-    ! ori          tg=max(tg,35.0)
-    ! debug          tc=tg-t0
+! ori          tg=max(tg,35.0)
+! debug          tc=tg-t0
     tc = tg - 273.15
     denom = 243.5 + tc
-    denom = max(denom, 1.0) ! convect3
-    ! ori          if(tc.ge.0.0)then
+    denom = max(denom, 1.0)                                   ! convect3
+! ori          if(tc.ge.0.0)then
     es = 6.112*exp(17.67*tc/denom)
-    ! ori          else
-    ! ori           es=exp(23.33086-6111.72784/tg+0.15215*log(tg))
-    ! ori          endif
-    ! ori          qg=eps*es/(p(i,icb(i))-es*(1.-eps))
+! ori          else
+! ori           es=exp(23.33086-6111.72784/tg+0.15215*log(tg))
+! ori          endif
+! ori          qg=eps*es/(p(i,icb(i))-es*(1.-eps))
     qg = eps*es/(p(i,icb(i)+1)-es*(1.-eps))
 
-    ! Second iteration.
-
-
-    ! ori          s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i))
-    ! ori          s=1./s
-    ! ori          ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i)
-    ahg = cpd*tg + (cl-cpd)*qnk(i)*tg + alv*qg + gzicb(i) ! convect3
+! Second iteration.
+
+
+! ori          s=cpd+alv*alv*qg/(rrv*ticb(i)*ticb(i))
+! ori          s=1./s
+! ori          ahg=cpd*tg+(cl-cpd)*qnk(i)*ticb(i)+alv*qg+gzicb(i)
+    ahg = cpd*tg + (cl-cpd)*qnk(i)*tg + alv*qg + gzicb(i)     ! convect3
     tg = tg + s*(ah0(i)-ahg)
-    ! ori          tg=max(tg,35.0)
-    ! debug          tc=tg-t0
+! ori          tg=max(tg,35.0)
+! debug          tc=tg-t0
     tc = tg - 273.15
     denom = 243.5 + tc
-    denom = max(denom, 1.0) ! convect3
-    ! ori          if(tc.ge.0.0)then
+    denom = max(denom, 1.0)                                   ! convect3
+! ori          if(tc.ge.0.0)then
     es = 6.112*exp(17.67*tc/denom)
-    ! ori          else
-    ! ori           es=exp(23.33086-6111.72784/tg+0.15215*log(tg))
-    ! ori          end if
-    ! ori          qg=eps*es/(p(i,icb(i))-es*(1.-eps))
+! ori          else
+! ori           es=exp(23.33086-6111.72784/tg+0.15215*log(tg))
+! ori          end if
+! ori          qg=eps*es/(p(i,icb(i))-es*(1.-eps))
     qg = eps*es/(p(i,icb(i)+1)-es*(1.-eps))
 
     alv = lv0 - clmcpv*(ticb(i)-273.15)
 
-    ! ori c approximation here:
-    ! ori         tp(i,icb(i))=(ah0(i)-(cl-cpd)*qnk(i)*ticb(i)
-    ! ori     &   -gz(i,icb(i))-alv*qg)/cpd
-
-    ! convect3: no approximation:
+! ori c approximation here:
+! ori         tp(i,icb(i))=(ah0(i)-(cl-cpd)*qnk(i)*ticb(i)
+! ori     &   -gz(i,icb(i))-alv*qg)/cpd
+
+! convect3: no approximation:
     tp(i, icb(i)+1) = (ah0(i)-gz(i,icb(i)+1)-alv*qg)/(cpd+(cl-cpd)*qnk(i))
 
-    ! ori         clw(i,icb(i))=qnk(i)-qg
-    ! ori         clw(i,icb(i))=max(0.0,clw(i,icb(i)))
+! ori         clw(i,icb(i))=qnk(i)-qg
+! ori         clw(i,icb(i))=max(0.0,clw(i,icb(i)))
     clw(i, icb(i)+1) = qnk(i) - qg
     clw(i, icb(i)+1) = max(0.0, clw(i,icb(i)+1))
 
     rg = qg/(1.-qnk(i))
-    ! ori         tvp(i,icb(i))=tp(i,icb(i))*(1.+rg*epsi)
-    ! convect3: (qg utilise au lieu du vrai mixing ratio rg)
-    tvp(i, icb(i)+1) = tp(i, icb(i)+1)*(1.+qg/eps-qnk(i)) !whole thing
+! ori         tvp(i,icb(i))=tp(i,icb(i))*(1.+rg*epsi)
+! convect3: (qg utilise au lieu du vrai mixing ratio rg)
+    tvp(i, icb(i)+1) = tp(i, icb(i)+1)*(1.+qg/eps-qnk(i))     !whole thing
 
   END DO
@@ -685,26 +752,26 @@
 END SUBROUTINE cv3_undilute1
 
-SUBROUTINE cv3_trigger(len, nd, icb, plcl, p, th, tv, tvp, thnk, pbase, &
-    buoybase, iflag, sig, w0)
+SUBROUTINE cv3_trigger(len, nd, icb, plcl, p, th, tv, tvp, thnk, &
+                       pbase, buoybase, iflag, sig, w0)
   IMPLICIT NONE
 
-  ! -------------------------------------------------------------------
-  ! --- TRIGGERING
-
-  ! - computes the cloud base
-  ! - triggering (crude in this version)
-  ! - relaxation of sig and w0 when no convection
-
-  ! Caution1: if no convection, we set iflag=4
-  ! (it used to be 0 in convect3)
-
-  ! Caution2: at this stage, tvp (and thus buoy) are know up
-  ! through icb only!
-  ! -> the buoyancy below cloud base not (yet) set to the cloud base buoyancy
-  ! -------------------------------------------------------------------
+! -------------------------------------------------------------------
+! --- TRIGGERING
+
+! - computes the cloud base
+! - triggering (crude in this version)
+! - relaxation of sig and w0 when no convection
+
+! Caution1: if no convection, we set iflag=4
+! (it used to be 0 in convect3)
+
+! Caution2: at this stage, tvp (and thus buoy) are know up
+! through icb only!
+! -> the buoyancy below cloud base not (yet) set to the cloud base buoyancy
+! -------------------------------------------------------------------
 
   include "cv3param.h"
 
-  ! input:
+! input:
   INTEGER len, nd
   INTEGER icb(len)
@@ -713,57 +780,55 @@
   REAL thnk(len)
 
-  ! output:
+! output:
   REAL pbase(len), buoybase(len)
 
-  ! input AND output:
+! input AND output:
   INTEGER iflag(len)
   REAL sig(len, nd), w0(len, nd)
 
-  ! local variables:
+! local variables:
   INTEGER i, k
   REAL tvpbase, tvbase, tdif, ath, ath1
 
 
-  ! ***   set cloud base buoyancy at (plcl+dpbase) level buoyancy
+! ***   set cloud base buoyancy at (plcl+dpbase) level buoyancy
 
   DO i = 1, len
     pbase(i) = plcl(i) + dpbase
-    tvpbase = tvp(i, icb(i))*(pbase(i)-p(i,icb(i)+1))/ &
-      (p(i,icb(i))-p(i,icb(i)+1)) + tvp(i, icb(i)+1)*(p(i,icb(i))-pbase(i))/( &
-      p(i,icb(i))-p(i,icb(i)+1))
-    tvbase = tv(i, icb(i))*(pbase(i)-p(i,icb(i)+1))/ &
-      (p(i,icb(i))-p(i,icb(i)+1)) + tv(i, icb(i)+1)*(p(i,icb(i))-pbase(i))/(p &
-      (i,icb(i))-p(i,icb(i)+1))
+    tvpbase = tvp(i, icb(i))  *(pbase(i)-p(i,icb(i)+1))/(p(i,icb(i))-p(i,icb(i)+1)) + &
+              tvp(i, icb(i)+1)*(p(i,icb(i))-pbase(i))  /(p(i,icb(i))-p(i,icb(i)+1))
+    tvbase = tv(i, icb(i))  *(pbase(i)-p(i,icb(i)+1))/(p(i,icb(i))-p(i,icb(i)+1)) + &
+             tv(i, icb(i)+1)*(p(i,icb(i))-pbase(i))  /(p(i,icb(i))-p(i,icb(i)+1))
     buoybase(i) = tvpbase - tvbase
   END DO
 
 
-  ! ***   make sure that column is dry adiabatic between the surface  ***
-  ! ***    and cloud base, and that lifted air is positively buoyant  ***
-  ! ***                         at cloud base                         ***
-  ! ***       if not, return to calling program after resetting       ***
-  ! ***                        sig(i) and w0(i)                       ***
-
-
-  ! oct3      do 200 i=1,len
-  ! oct3
-  ! oct3       tdif = buoybase(i)
-  ! oct3       ath1 = th(i,1)
-  ! oct3       ath  = th(i,icb(i)-1) - dttrig
-  ! oct3
-  ! oct3       if (tdif.lt.dtcrit .or. ath.gt.ath1) then
-  ! oct3         do 60 k=1,nl
-  ! oct3            sig(i,k) = beta*sig(i,k) - 2.*alpha*tdif*tdif
-  ! oct3            sig(i,k) = AMAX1(sig(i,k),0.0)
-  ! oct3            w0(i,k)  = beta*w0(i,k)
-  ! oct3   60    continue
-  ! oct3         iflag(i)=4 ! pour version vectorisee
-  ! oct3c convect3         iflag(i)=0
-  ! oct3cccc         return
-  ! oct3       endif
-  ! oct3
-  ! oct3200   continue
-
-  ! -- oct3: on reecrit la boucle 200 (pour la vectorisation)
+! ***   make sure that column is dry adiabatic between the surface  ***
+! ***    and cloud base, and that lifted air is positively buoyant  ***
+! ***                         at cloud base                         ***
+! ***       if not, return to calling program after resetting       ***
+! ***                        sig(i) and w0(i)                       ***
+
+
+! oct3      do 200 i=1,len
+! oct3
+! oct3       tdif = buoybase(i)
+! oct3       ath1 = th(i,1)
+! oct3       ath  = th(i,icb(i)-1) - dttrig
+! oct3
+! oct3       if (tdif.lt.dtcrit .or. ath.gt.ath1) then
+! oct3         do 60 k=1,nl
+! oct3            sig(i,k) = beta*sig(i,k) - 2.*alpha*tdif*tdif
+! oct3            sig(i,k) = AMAX1(sig(i,k),0.0)
+! oct3            w0(i,k)  = beta*w0(i,k)
+! oct3   60    continue
+! oct3         iflag(i)=4 ! pour version vectorisee
+! oct3c convect3         iflag(i)=0
+! oct3cccc         return
+! oct3       endif
+! oct3
+! oct3200   continue
+
+! -- oct3: on reecrit la boucle 200 (pour la vectorisation)
 
   DO k = 1, nl
@@ -779,5 +844,5 @@
         w0(i, k) = beta*w0(i, k)
         iflag(i) = 4 ! pour version vectorisee
-        ! convect3         iflag(i)=0
+! convect3         iflag(i)=0
       END IF
 
@@ -785,14 +850,22 @@
   END DO
 
-  ! fin oct3 --
+! fin oct3 --
 
   RETURN
 END SUBROUTINE cv3_trigger
 
-SUBROUTINE cv3_compress(len, nloc, ncum, nd, ntra, iflag1, nk1, icb1, icbs1, &
-    plcl1, tnk1, qnk1, gznk1, pbase1, buoybase1, t1, q1, qs1, u1, v1, gz1, &
-    th1, tra1, h1, lv1, cpn1, p1, ph1, tv1, tp1, tvp1, clw1, sig1, w01, &
-    iflag, nk, icb, icbs, plcl, tnk, qnk, gznk, pbase, buoybase, t, q, qs, u, &
-    v, gz, th, tra, h, lv, cpn, p, ph, tv, tp, tvp, clw, sig, w0)
+SUBROUTINE cv3_compress(len, nloc, ncum, nd, ntra, &
+                        iflag1, nk1, icb1, icbs1, &
+                        plcl1, tnk1, qnk1, gznk1, pbase1, buoybase1, &
+                        t1, q1, qs1, u1, v1, gz1, th1, &
+                        tra1, &
+                        h1, lv1, cpn1, p1, ph1, tv1, tp1, tvp1, clw1, &
+                        sig1, w01, &
+                        iflag, nk, icb, icbs, &
+                        plcl, tnk, qnk, gznk, pbase, buoybase, &
+                        t, q, qs, u, v, gz, th, &
+                        tra, &
+                        h, lv, cpn, p, ph, tv, tp, tvp, clw, &
+                        sig, w0)
   IMPLICIT NONE
 
@@ -800,5 +873,5 @@
   include 'iniprint.h'
 
-  ! inputs:
+!inputs:
   INTEGER len, ncum, nd, ntra, nloc
   INTEGER iflag1(len), nk1(len), icb1(len), icbs1(len)
@@ -813,6 +886,6 @@
   REAL tra1(len, nd, ntra)
 
-  ! outputs:
-  ! en fait, on a nloc=len pour l'instant (cf cv_driver)
+!outputs:
+! en fait, on a nloc=len pour l'instant (cf cv_driver)
   INTEGER iflag(nloc), nk(nloc), icb(nloc), icbs(nloc)
   REAL plcl(nloc), tnk(nloc), qnk(nloc), gznk(nloc)
@@ -826,5 +899,5 @@
   REAL tra(nloc, nd, ntra)
 
-  ! local variables:
+!local variables:
   INTEGER i, k, nn, j
 
@@ -859,16 +932,16 @@
   END DO
 
-  ! AC!      do 121 j=1,ntra
-  ! AC!ccccc      do 111 k=1,nl+1
-  ! AC!      do 111 k=1,nd
-  ! AC!       nn=0
-  ! AC!      do 101 i=1,len
-  ! AC!      if(iflag1(i).eq.0)then
-  ! AC!       nn=nn+1
-  ! AC!       tra(nn,k,j)=tra1(i,k,j)
-  ! AC!      endif
-  ! AC! 101  continue
-  ! AC! 111  continue
-  ! AC! 121  continue
+!AC!      do 121 j=1,ntra
+!AC!ccccc      do 111 k=1,nl+1
+!AC!      do 111 k=1,nd
+!AC!       nn=0
+!AC!      do 101 i=1,len
+!AC!      if(iflag1(i).eq.0)then
+!AC!       nn=nn+1
+!AC!       tra(nn,k,j)=tra1(i,k,j)
+!AC!      endif
+!AC! 101  continue
+!AC! 111  continue
+!AC! 121  continue
 
   IF (nn/=ncum) THEN
@@ -902,7 +975,7 @@
 
 
-  ! JAM--------------------------------------------------------------------
-  ! Calcul de la quantité d'eau sous forme de glace
-  ! --------------------------------------------------------------------
+!JAM--------------------------------------------------------------------
+! Calcul de la quantité d'eau sous forme de glace
+! --------------------------------------------------------------------
   REAL qi(len, nl)
   REAL t(len, nl), clw(len, nl)
@@ -922,5 +995,5 @@
         END IF
       END IF
-      ! print*,t(i,k),qi(i,k),'temp,testglace'
+! print*,t(i,k),qi(i,k),'temp,testglace'
     END DO
   END DO
@@ -930,26 +1003,27 @@
 END SUBROUTINE icefrac
 
-SUBROUTINE cv3_undilute2(nloc, ncum, nd, icb, icbs, nk, tnk, qnk, gznk, hnk, &
-    t, q, qs, gz, p, h, tv, lv, lf, pbase, buoybase, plcl, inb, tp, tvp, clw, &
-    hp, ep, sigp, buoy, frac)
+SUBROUTINE cv3_undilute2(nloc, ncum, nd, icb, icbs, nk, &
+                         tnk, qnk, gznk, hnk, t, q, qs, gz, &
+                         p, h, tv, lv, lf, pbase, buoybase, plcl, &
+                         inb, tp, tvp, clw, hp, ep, sigp, buoy, frac)
   IMPLICIT NONE
 
-  ! ---------------------------------------------------------------------
-  ! Purpose:
-  ! FIND THE REST OF THE LIFTED PARCEL TEMPERATURES
-  ! &
-  ! COMPUTE THE PRECIPITATION EFFICIENCIES AND THE
-  ! FRACTION OF PRECIPITATION FALLING OUTSIDE OF CLOUD
-  ! &
-  ! FIND THE LEVEL OF NEUTRAL BUOYANCY
-
-  ! Main differences convect3/convect4:
-  ! - icbs (input) is the first level above LCL (may differ from icb)
-  ! - many minor differences in the iterations
-  ! - condensed water not removed from tvp in convect3
-  ! - vertical profile of buoyancy computed here (use of buoybase)
-  ! - the determination of inb is different
-  ! - no inb1, only inb in output
-  ! ---------------------------------------------------------------------
+! ---------------------------------------------------------------------
+! Purpose:
+! FIND THE REST OF THE LIFTED PARCEL TEMPERATURES
+! &
+! COMPUTE THE PRECIPITATION EFFICIENCIES AND THE
+! FRACTION OF PRECIPITATION FALLING OUTSIDE OF CLOUD
+! &
+! FIND THE LEVEL OF NEUTRAL BUOYANCY
+
+! Main differences convect3/convect4:
+!   - icbs (input) is the first level above LCL (may differ from icb)
+!   - many minor differences in the iterations
+!   - condensed water not removed from tvp in convect3
+!   - vertical profile of buoyancy computed here (use of buoybase)
+!   - the determination of inb is different
+!   - no inb1, only inb in output
+! ---------------------------------------------------------------------
 
   include "cvthermo.h"
@@ -958,5 +1032,5 @@
   include "cvflag.h"
 
-  ! inputs:
+!inputs:
   INTEGER ncum, nd, nloc, j
   INTEGER icb(nloc), icbs(nloc), nk(nloc)
@@ -968,5 +1042,5 @@
   REAL pbase(nloc), buoybase(nloc), plcl(nloc)
 
-  ! outputs:
+!outputs:
   INTEGER inb(nloc)
   REAL tp(nloc, nd), tvp(nloc, nd), clw(nloc, nd)
@@ -974,5 +1048,5 @@
   REAL buoy(nloc, nd)
 
-  ! local variables:
+!local variables:
   INTEGER i, k
   REAL tg, qg, ahg, alv, alf, s, tc, es, esi, denom, rg, tca, elacrit
@@ -986,7 +1060,7 @@
   REAL fracg
 
-  ! =====================================================================
-  ! --- SOME INITIALIZATIONS
-  ! =====================================================================
+! =====================================================================
+! --- SOME INITIALIZATIONS
+! =====================================================================
 
   DO k = 1, nl
@@ -998,84 +1072,83 @@
   END DO
 
-  ! =====================================================================
-  ! --- FIND THE REST OF THE LIFTED PARCEL TEMPERATURES
-  ! =====================================================================
-
-  ! ---       The procedure is to solve the equation.
-  ! cp*tp+L*qp+phi=cp*tnk+L*qnk+gznk.
-
-  ! ***  Calculate certain parcel quantities, including static energy   ***
+! =====================================================================
+! --- FIND THE REST OF THE LIFTED PARCEL TEMPERATURES
+! =====================================================================
+
+! ---       The procedure is to solve the equation.
+!                cp*tp+L*qp+phi=cp*tnk+L*qnk+gznk.
+
+! ***  Calculate certain parcel quantities, including static energy   ***
 
 
   DO i = 1, ncum
-    ah0(i) = (cpd*(1.-qnk(i))+cl*qnk(i))*tnk(i) & ! debug     &
-                                                  ! +qnk(i)*(lv0-clmcpv*(tnk(i)-t0))+gznk(i)
-      +qnk(i)*(lv0-clmcpv*(tnk(i)-273.15)) + gznk(i)
-  END DO
-
-
-  ! ***  Find lifted parcel quantities above cloud base    ***
+    ah0(i) = (cpd*(1.-qnk(i))+cl*qnk(i))*tnk(i)+ & 
+! debug          qnk(i)*(lv0-clmcpv*(tnk(i)-t0))+gznk(i)
+             qnk(i)*(lv0-clmcpv*(tnk(i)-273.15)) + gznk(i)
+  END DO
+
+
+! ***  Find lifted parcel quantities above cloud base    ***
 
 
   DO k = minorig + 1, nl
     DO i = 1, ncum
-      ! ori	    if(k.ge.(icb(i)+1))then
-      IF (k>=(icbs(i)+1)) THEN ! convect3
+! ori	    if(k.ge.(icb(i)+1))then
+      IF (k>=(icbs(i)+1)) THEN                                ! convect3
         tg = t(i, k)
         qg = qs(i, k)
-        ! debug	      alv=lv0-clmcpv*(t(i,k)-t0)
+! debug	      alv=lv0-clmcpv*(t(i,k)-t0)
         alv = lv0 - clmcpv*(t(i,k)-273.15)
 
-        ! First iteration.
-
-        ! ori	       s=cpd+alv*alv*qg/(rrv*t(i,k)*t(i,k))
-        s = cpd*(1.-qnk(i)) + cl*qnk(i) & ! convect3
-          +alv*alv*qg/(rrv*t(i,k)*t(i,k)) ! convect3
+! First iteration.
+
+! ori	       s=cpd+alv*alv*qg/(rrv*t(i,k)*t(i,k))
+        s = cpd*(1.-qnk(i)) + cl*qnk(i) + &                   ! convect3
+            alv*alv*qg/(rrv*t(i,k)*t(i,k))                    ! convect3
         s = 1./s
-        ! ori	       ahg=cpd*tg+(cl-cpd)*qnk(i)*t(i,k)+alv*qg+gz(i,k)
+! ori	       ahg=cpd*tg+(cl-cpd)*qnk(i)*t(i,k)+alv*qg+gz(i,k)
         ahg = cpd*tg + (cl-cpd)*qnk(i)*tg + alv*qg + gz(i, k) ! convect3
         tg = tg + s*(ah0(i)-ahg)
-        ! ori	       tg=max(tg,35.0)
-        ! debug	       tc=tg-t0
+! ori	       tg=max(tg,35.0)
+! debug	       tc=tg-t0
         tc = tg - 273.15
         denom = 243.5 + tc
-        denom = max(denom, 1.0) ! convect3
-        ! ori	       if(tc.ge.0.0)then
+        denom = max(denom, 1.0)                               ! convect3
+! ori	       if(tc.ge.0.0)then
         es = 6.112*exp(17.67*tc/denom)
-        ! ori	       else
-        ! ori			es=exp(23.33086-6111.72784/tg+0.15215*log(tg))
-        ! ori	       endif
+! ori	       else
+! ori			es=exp(23.33086-6111.72784/tg+0.15215*log(tg))
+! ori	       endif
         qg = eps*es/(p(i,k)-es*(1.-eps))
 
-        ! Second iteration.
-
-        ! ori	       s=cpd+alv*alv*qg/(rrv*t(i,k)*t(i,k))
-        ! ori	       s=1./s
-        ! ori	       ahg=cpd*tg+(cl-cpd)*qnk(i)*t(i,k)+alv*qg+gz(i,k)
+! Second iteration.
+
+! ori	       s=cpd+alv*alv*qg/(rrv*t(i,k)*t(i,k))
+! ori	       s=1./s
+! ori	       ahg=cpd*tg+(cl-cpd)*qnk(i)*t(i,k)+alv*qg+gz(i,k)
         ahg = cpd*tg + (cl-cpd)*qnk(i)*tg + alv*qg + gz(i, k) ! convect3
         tg = tg + s*(ah0(i)-ahg)
-        ! ori	       tg=max(tg,35.0)
-        ! debug	       tc=tg-t0
+! ori	       tg=max(tg,35.0)
+! debug	       tc=tg-t0
         tc = tg - 273.15
         denom = 243.5 + tc
-        denom = max(denom, 1.0) ! convect3
-        ! ori	       if(tc.ge.0.0)then
+        denom = max(denom, 1.0)                               ! convect3
+! ori	       if(tc.ge.0.0)then
         es = 6.112*exp(17.67*tc/denom)
-        ! ori	       else
-        ! ori			es=exp(23.33086-6111.72784/tg+0.15215*log(tg))
-        ! ori	       endif
+! ori	       else
+! ori			es=exp(23.33086-6111.72784/tg+0.15215*log(tg))
+! ori	       endif
         qg = eps*es/(p(i,k)-es*(1.-eps))
 
-        ! debug	       alv=lv0-clmcpv*(t(i,k)-t0)
+! debug	       alv=lv0-clmcpv*(t(i,k)-t0)
         alv = lv0 - clmcpv*(t(i,k)-273.15)
-        ! print*,'cpd dans convect2 ',cpd
-        ! print*,'tp(i,k),ah0(i),cl,cpd,qnk(i),t(i,k),gz(i,k),alv,qg,cpd'
-        ! print*,tp(i,k),ah0(i),cl,cpd,qnk(i),t(i,k),gz(i,k),alv,qg,cpd
-
-        ! ori c approximation here:
-        ! ori
-        ! tp(i,k)=(ah0(i)-(cl-cpd)*qnk(i)*t(i,k)-gz(i,k)-alv*qg)/cpd
-
-        ! convect3: no approximation:
+! print*,'cpd dans convect2 ',cpd
+! print*,'tp(i,k),ah0(i),cl,cpd,qnk(i),t(i,k),gz(i,k),alv,qg,cpd'
+! print*,tp(i,k),ah0(i),cl,cpd,qnk(i),t(i,k),gz(i,k),alv,qg,cpd
+
+! ori c approximation here:
+! ori        tp(i,k)=(ah0(i)-(cl-cpd)*qnk(i)*t(i,k)-gz(i,k)-alv*qg)/cpd
+
+! convect3: no approximation:
         IF (cvflag_ice) THEN
           tp(i, k) = max(0., (ah0(i)-gz(i,k)-alv*qg)/(cpd+(cl-cpd)*qnk(i)))
@@ -1087,6 +1160,6 @@
         clw(i, k) = max(0.0, clw(i,k))
         rg = qg/(1.-qnk(i))
-        ! ori               tvp(i,k)=tp(i,k)*(1.+rg*epsi)
-        ! convect3: (qg utilise au lieu du vrai mixing ratio rg):
+! ori               tvp(i,k)=tp(i,k)*(1.+rg*epsi)
+! convect3: (qg utilise au lieu du vrai mixing ratio rg):
         tvp(i, k) = tp(i, k)*(1.+qg/eps-qnk(i)) ! whole thing
         IF (cvflag_ice) THEN
@@ -1099,6 +1172,6 @@
 
       IF (cvflag_ice) THEN
-        ! CR:attention boucle en klon dans Icefrac
-        ! Call Icefrac(t,clw,qi,nl,nloc)
+!CR:attention boucle en klon dans Icefrac
+! Call Icefrac(t,clw,qi,nl,nloc)
         IF (t(i,k)>263.15) THEN
           qi(i, k) = 0.
@@ -1111,29 +1184,29 @@
           END IF
         END IF
-        ! CR: fin test
+!CR: fin test
         IF (t(i,k)<263.15) THEN
-          ! CR: on commente les calculs d'Arnaud car division par zero
-          ! nouveau calcul propose par JYG
-          ! alv=lv0-clmcpv*(t(i,k)-273.15)
-          ! alf=lf0-clmci*(t(i,k)-273.15)
-          ! tg=tp(i,k)
-          ! tc=tp(i,k)-273.15
-          ! denom=243.5+tc
-          ! do j=1,3
-          ! cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
-          ! il faudra que esi vienne en argument de la convection
-          ! cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
-          ! tbis=t(i,k)+(tp(i,k)-tg)
-          ! esi=exp(23.33086-(6111.72784/tbis)
-          ! :               +0.15215*log(tbis))
-          ! qsat_new=eps*esi/(p(i,k)-esi*(1.-eps))
-          ! snew=cpd*(1.-qnk(i))+cl*qnk(i)+alv*alv*qsat_new/
-          ! :                               (rrv*tbis*tbis)
-          ! snew=1./snew
-          ! print*,esi,qsat_new,snew,'esi,qsat,snew'
-          ! tp(i,k)=tg+(alf*qi(i,k)+alv*qg*(1.-(esi/es)))*snew
-          ! print*,k,tp(i,k),qnk(i),'avec glace'
-          ! print*,'tpNAN',tg,alf,qi(i,k),alv,qg,esi,es,snew
-          ! enddo
+!CR: on commente les calculs d'Arnaud car division par zero
+! nouveau calcul propose par JYG
+!       alv=lv0-clmcpv*(t(i,k)-273.15)
+!       alf=lf0-clmci*(t(i,k)-273.15)
+!       tg=tp(i,k)
+!       tc=tp(i,k)-273.15
+!       denom=243.5+tc
+!       do j=1,3
+! cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+! il faudra que esi vienne en argument de la convection
+! cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+!        tbis=t(i,k)+(tp(i,k)-tg)
+!        esi=exp(23.33086-(6111.72784/tbis) + &
+!                       0.15215*log(tbis))
+!        qsat_new=eps*esi/(p(i,k)-esi*(1.-eps))
+!        snew=cpd*(1.-qnk(i))+cl*qnk(i)+alv*alv*qsat_new/ &
+!                                       (rrv*tbis*tbis)
+!        snew=1./snew
+!        print*,esi,qsat_new,snew,'esi,qsat,snew'
+!        tp(i,k)=tg+(alf*qi(i,k)+alv*qg*(1.-(esi/es)))*snew
+!        print*,k,tp(i,k),qnk(i),'avec glace'
+!        print*,'tpNAN',tg,alf,qi(i,k),alv,qg,esi,es,snew
+!       enddo
 
           alv = lv0 - clmcpv*(t(i,k)-273.15)
@@ -1145,19 +1218,20 @@
             esi = exp(23.33086-(6111.72784/tp(i,k))+0.15215*log(tp(i,k)))
             qsat_new = eps*esi/(p(i,k)-esi*(1.-eps))
-            snew = cpd*(1.-qnk(i)) + cl*qnk(i) + alv*als*qsat_new/(rrv*tp(i,k &
-              )*tp(i,k))
+            snew = cpd*(1.-qnk(i)) + cl*qnk(i) + alv*als*qsat_new/ &
+                                                 (rrv*tp(i,k)*tp(i,k))
             snew = 1./snew
-            ! c             print*,esi,qsat_new,snew,'esi,qsat,snew'
-            tp(i, k) = tp(i, k) + ((cpd*(1.-qnk(i))+cl*qnk(i))*(tg-tp(i, &
-              k))+alv*(qg-qsat_new)+alf*qi(i,k))*snew
-            ! print*,k,tp(i,k),qsat_new,qnk(i),qi(i,k),
-            ! :             'k,tp,q,qt,qi avec glace'
+! c             print*,esi,qsat_new,snew,'esi,qsat,snew'
+            tp(i, k) = tp(i, k) + &
+                       ((cpd*(1.-qnk(i))+cl*qnk(i))*(tg-tp(i,k)) + &
+                        alv*(qg-qsat_new)+alf*qi(i,k))*snew
+! print*,k,tp(i,k),qsat_new,qnk(i),qi(i,k), &
+!              'k,tp,q,qt,qi avec glace'
           END DO
 
-          ! CR:reprise du code AJ
+!CR:reprise du code AJ
           clw(i, k) = qnk(i) - qsat_new
           clw(i, k) = max(0.0, clw(i,k))
           tvp(i, k) = max(0., tp(i,k)*(1.+qsat_new/eps-qnk(i)))
-          ! print*,tvp(i,k),'tvp'
+! print*,tvp(i,k),'tvp'
         END IF
         IF (clw(i,k)<1.E-11) THEN
@@ -1170,9 +1244,9 @@
   END DO
 
-  ! =====================================================================
-  ! --- SET THE PRECIPITATION EFFICIENCIES AND THE FRACTION OF
-  ! --- PRECIPITATION FALLING OUTSIDE OF CLOUD
-  ! --- THESE MAY BE FUNCTIONS OF TP(I), P(I) AND CLW(I)
-  ! =====================================================================
+! =====================================================================
+! --- SET THE PRECIPITATION EFFICIENCIES AND THE FRACTION OF
+! --- PRECIPITATION FALLING OUTSIDE OF CLOUD
+! --- THESE MAY BE FUNCTIONS OF TP(I), P(I) AND CLW(I)
+! =====================================================================
 
   IF (flag_epkeorig/=1) THEN
@@ -1205,37 +1279,37 @@
     END DO
   END IF
-  ! =====================================================================
-  ! --- CALCULATE VIRTUAL TEMPERATURE AND LIFTED PARCEL
-  ! --- VIRTUAL TEMPERATURE
-  ! =====================================================================
-
-  ! dans convect3, tvp est calcule en une seule fois, et sans retirer
-  ! l'eau condensee (~> reversible CAPE)
-
-  ! ori      do 340 k=minorig+1,nl
-  ! ori        do 330 i=1,ncum
-  ! ori        if(k.ge.(icb(i)+1))then
-  ! ori          tvp(i,k)=tvp(i,k)*(1.0-qnk(i)+ep(i,k)*clw(i,k))
-  ! oric         print*,'i,k,tvp(i,k),qnk(i),ep(i,k),clw(i,k)'
-  ! oric         print*, i,k,tvp(i,k),qnk(i),ep(i,k),clw(i,k)
-  ! ori        endif
-  ! ori 330    continue
-  ! ori 340  continue
-
-  ! ori      do 350 i=1,ncum
-  ! ori       tvp(i,nlp)=tvp(i,nl)-(gz(i,nlp)-gz(i,nl))/cpd
-  ! ori 350  continue
-
-  DO i = 1, ncum ! convect3
-    tp(i, nlp) = tp(i, nl) ! convect3
-  END DO ! convect3
-
-  ! =====================================================================
-  ! --- EFFECTIVE VERTICAL PROFILE OF BUOYANCY (convect3 only):
-  ! =====================================================================
-
-  ! -- this is for convect3 only:
-
-  ! first estimate of buoyancy:
+! =====================================================================
+! --- CALCULATE VIRTUAL TEMPERATURE AND LIFTED PARCEL
+! --- VIRTUAL TEMPERATURE
+! =====================================================================
+
+! dans convect3, tvp est calcule en une seule fois, et sans retirer
+! l'eau condensee (~> reversible CAPE)
+
+! ori      do 340 k=minorig+1,nl
+! ori        do 330 i=1,ncum
+! ori        if(k.ge.(icb(i)+1))then
+! ori          tvp(i,k)=tvp(i,k)*(1.0-qnk(i)+ep(i,k)*clw(i,k))
+! oric         print*,'i,k,tvp(i,k),qnk(i),ep(i,k),clw(i,k)'
+! oric         print*, i,k,tvp(i,k),qnk(i),ep(i,k),clw(i,k)
+! ori        endif
+! ori 330    continue
+! ori 340  continue
+
+! ori      do 350 i=1,ncum
+! ori       tvp(i,nlp)=tvp(i,nl)-(gz(i,nlp)-gz(i,nl))/cpd
+! ori 350  continue
+
+  DO i = 1, ncum                                           ! convect3
+    tp(i, nlp) = tp(i, nl)                                 ! convect3
+  END DO                                                   ! convect3
+
+! =====================================================================
+! --- EFFECTIVE VERTICAL PROFILE OF BUOYANCY (convect3 only):
+! =====================================================================
+
+! -- this is for convect3 only:
+
+! first estimate of buoyancy:
 
   DO i = 1, ncum
@@ -1245,6 +1319,6 @@
   END DO
 
-  ! set buoyancy=buoybase for all levels below base
-  ! for safety, set buoy(icb)=buoybase
+! set buoyancy=buoybase for all levels below base
+! for safety, set buoy(icb)=buoybase
 
   DO i = 1, ncum
@@ -1254,16 +1328,16 @@
       END IF
     END DO
-    ! buoy(icb(i),k)=buoybase(i)
+!    buoy(icb(i),k)=buoybase(i)
     buoy(i, icb(i)) = buoybase(i)
   END DO
 
-  ! -- end convect3
-
-  ! =====================================================================
-  ! --- FIND THE FIRST MODEL LEVEL (INB) ABOVE THE PARCEL'S
-  ! --- LEVEL OF NEUTRAL BUOYANCY
-  ! =====================================================================
-
-  ! -- this is for convect3 only:
+! -- end convect3
+
+! =====================================================================
+! --- FIND THE FIRST MODEL LEVEL (INB) ABOVE THE PARCEL'S
+! --- LEVEL OF NEUTRAL BUOYANCY
+! =====================================================================
+
+! -- this is for convect3 only:
 
   DO i = 1, ncum
@@ -1273,5 +1347,5 @@
 
 
-  ! --    iposit(i) = first level, above icb, with positive buoyancy
+! --    iposit(i) = first level, above icb, with positive buoyancy
   DO k = 1, nl - 1
     DO i = 1, ncum
@@ -1296,99 +1370,99 @@
   END DO
 
-  ! -- end convect3
-
-  ! ori      do 510 i=1,ncum
-  ! ori        cape(i)=0.0
-  ! ori        capem(i)=0.0
-  ! ori        inb(i)=icb(i)+1
-  ! ori        inb1(i)=inb(i)
-  ! ori 510  continue
-
-  ! Originial Code
-
-  ! do 530 k=minorig+1,nl-1
-  ! do 520 i=1,ncum
-  ! if(k.ge.(icb(i)+1))then
-  ! by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k)
-  ! byp=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1)
-  ! cape(i)=cape(i)+by
-  ! if(by.ge.0.0)inb1(i)=k+1
-  ! if(cape(i).gt.0.0)then
-  ! inb(i)=k+1
-  ! capem(i)=cape(i)
-  ! endif
-  ! endif
-  ! 520    continue
-  ! 530  continue
-  ! do 540 i=1,ncum
-  ! byp=(tvp(i,nl)-tv(i,nl))*dph(i,nl)/p(i,nl)
-  ! cape(i)=capem(i)+byp
-  ! defrac=capem(i)-cape(i)
-  ! defrac=max(defrac,0.001)
-  ! frac(i)=-cape(i)/defrac
-  ! frac(i)=min(frac(i),1.0)
-  ! frac(i)=max(frac(i),0.0)
-  ! 540   continue
-
-  ! K Emanuel fix
-
-  ! call zilch(byp,ncum)
-  ! do 530 k=minorig+1,nl-1
-  ! do 520 i=1,ncum
-  ! if(k.ge.(icb(i)+1))then
-  ! by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k)
-  ! cape(i)=cape(i)+by
-  ! if(by.ge.0.0)inb1(i)=k+1
-  ! if(cape(i).gt.0.0)then
-  ! inb(i)=k+1
-  ! capem(i)=cape(i)
-  ! byp(i)=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1)
-  ! endif
-  ! endif
-  ! 520    continue
-  ! 530  continue
-  ! do 540 i=1,ncum
-  ! inb(i)=max(inb(i),inb1(i))
-  ! cape(i)=capem(i)+byp(i)
-  ! defrac=capem(i)-cape(i)
-  ! defrac=max(defrac,0.001)
-  ! frac(i)=-cape(i)/defrac
-  ! frac(i)=min(frac(i),1.0)
-  ! frac(i)=max(frac(i),0.0)
-  ! 540   continue
-
-  ! J Teixeira fix
-
-  ! ori      call zilch(byp,ncum)
-  ! ori      do 515 i=1,ncum
-  ! ori        lcape(i)=.true.
-  ! ori 515  continue
-  ! ori      do 530 k=minorig+1,nl-1
-  ! ori        do 520 i=1,ncum
-  ! ori          if(cape(i).lt.0.0)lcape(i)=.false.
-  ! ori          if((k.ge.(icb(i)+1)).and.lcape(i))then
-  ! ori            by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k)
-  ! ori            byp(i)=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1)
-  ! ori            cape(i)=cape(i)+by
-  ! ori            if(by.ge.0.0)inb1(i)=k+1
-  ! ori            if(cape(i).gt.0.0)then
-  ! ori              inb(i)=k+1
-  ! ori              capem(i)=cape(i)
-  ! ori            endif
-  ! ori          endif
-  ! ori 520    continue
-  ! ori 530  continue
-  ! ori      do 540 i=1,ncum
-  ! ori          cape(i)=capem(i)+byp(i)
-  ! ori          defrac=capem(i)-cape(i)
-  ! ori          defrac=max(defrac,0.001)
-  ! ori          frac(i)=-cape(i)/defrac
-  ! ori          frac(i)=min(frac(i),1.0)
-  ! ori          frac(i)=max(frac(i),0.0)
-  ! ori 540  continue
-
-  ! =====================================================================
-  ! ---   CALCULATE LIQUID WATER STATIC ENERGY OF LIFTED PARCEL
-  ! =====================================================================
+! -- end convect3
+
+! ori      do 510 i=1,ncum
+! ori        cape(i)=0.0
+! ori        capem(i)=0.0
+! ori        inb(i)=icb(i)+1
+! ori        inb1(i)=inb(i)
+! ori 510  continue
+
+! Originial Code
+
+!    do 530 k=minorig+1,nl-1
+!     do 520 i=1,ncum
+!      if(k.ge.(icb(i)+1))then
+!       by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k)
+!       byp=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1)
+!       cape(i)=cape(i)+by
+!       if(by.ge.0.0)inb1(i)=k+1
+!       if(cape(i).gt.0.0)then
+!        inb(i)=k+1
+!        capem(i)=cape(i)
+!       endif
+!      endif
+!520    continue
+!530  continue
+!    do 540 i=1,ncum
+!     byp=(tvp(i,nl)-tv(i,nl))*dph(i,nl)/p(i,nl)
+!     cape(i)=capem(i)+byp
+!     defrac=capem(i)-cape(i)
+!     defrac=max(defrac,0.001)
+!     frac(i)=-cape(i)/defrac
+!     frac(i)=min(frac(i),1.0)
+!     frac(i)=max(frac(i),0.0)
+!540   continue
+
+!    K Emanuel fix
+
+!    call zilch(byp,ncum)
+!    do 530 k=minorig+1,nl-1
+!     do 520 i=1,ncum
+!      if(k.ge.(icb(i)+1))then
+!       by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k)
+!       cape(i)=cape(i)+by
+!       if(by.ge.0.0)inb1(i)=k+1
+!       if(cape(i).gt.0.0)then
+!        inb(i)=k+1
+!        capem(i)=cape(i)
+!        byp(i)=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1)
+!       endif
+!      endif
+!520    continue
+!530  continue
+!    do 540 i=1,ncum
+!     inb(i)=max(inb(i),inb1(i))
+!     cape(i)=capem(i)+byp(i)
+!     defrac=capem(i)-cape(i)
+!     defrac=max(defrac,0.001)
+!     frac(i)=-cape(i)/defrac
+!     frac(i)=min(frac(i),1.0)
+!     frac(i)=max(frac(i),0.0)
+!540   continue
+
+! J Teixeira fix
+
+! ori      call zilch(byp,ncum)
+! ori      do 515 i=1,ncum
+! ori        lcape(i)=.true.
+! ori 515  continue
+! ori      do 530 k=minorig+1,nl-1
+! ori        do 520 i=1,ncum
+! ori          if(cape(i).lt.0.0)lcape(i)=.false.
+! ori          if((k.ge.(icb(i)+1)).and.lcape(i))then
+! ori            by=(tvp(i,k)-tv(i,k))*dph(i,k)/p(i,k)
+! ori            byp(i)=(tvp(i,k+1)-tv(i,k+1))*dph(i,k+1)/p(i,k+1)
+! ori            cape(i)=cape(i)+by
+! ori            if(by.ge.0.0)inb1(i)=k+1
+! ori            if(cape(i).gt.0.0)then
+! ori              inb(i)=k+1
+! ori              capem(i)=cape(i)
+! ori            endif
+! ori          endif
+! ori 520    continue
+! ori 530  continue
+! ori      do 540 i=1,ncum
+! ori          cape(i)=capem(i)+byp(i)
+! ori          defrac=capem(i)-cape(i)
+! ori          defrac=max(defrac,0.001)
+! ori          frac(i)=-cape(i)/defrac
+! ori          frac(i)=min(frac(i),1.0)
+! ori          frac(i)=max(frac(i),0.0)
+! ori 540  continue
+
+! =====================================================================
+! ---   CALCULATE LIQUID WATER STATIC ENERGY OF LIFTED PARCEL
+! =====================================================================
 
   DO k = 1, nd
@@ -1405,6 +1479,6 @@
           frac(i, k) = 1. - (t(i,k)-243.15)/(263.15-243.15)
           frac(i, k) = min(max(frac(i,k),0.0), 1.0)
-          hp(i, k) = hnk(i) + (lv(i,k)+(cpd-cpv)*t(i,k)+frac(i,k)*lf(i,k))*ep &
-            (i, k)*clw(i, k)
+          hp(i, k) = hnk(i) + (lv(i,k)+(cpd-cpv)*t(i,k)+frac(i,k)*lf(i,k))* &
+                              ep(i, k)*clw(i, k)
 
         ELSE
@@ -1419,18 +1493,19 @@
 END SUBROUTINE cv3_undilute2
 
-SUBROUTINE cv3_closure(nloc, ncum, nd, icb, inb, pbase, p, ph, tv, buoy, sig, &
-    w0, cape, m, iflag)
+SUBROUTINE cv3_closure(nloc, ncum, nd, icb, inb, &
+                       pbase, p, ph, tv, buoy, &
+                       sig, w0, cape, m, iflag)
   IMPLICIT NONE
 
-  ! ===================================================================
-  ! ---  CLOSURE OF CONVECT3
-
-  ! vectorization: S. Bony
-  ! ===================================================================
+! ===================================================================
+! ---  CLOSURE OF CONVECT3
+!
+! vectorization: S. Bony
+! ===================================================================
 
   include "cvthermo.h"
   include "cv3param.h"
 
-  ! input:
+!input:
   INTEGER ncum, nd, nloc
   INTEGER icb(nloc), inb(nloc)
@@ -1439,13 +1514,13 @@
   REAL tv(nloc, nd), buoy(nloc, nd)
 
-  ! input/output:
+!input/output:
   REAL sig(nloc, nd), w0(nloc, nd)
   INTEGER iflag(nloc)
 
-  ! output:
+!output:
   REAL cape(nloc)
   REAL m(nloc, nd)
 
-  ! local variables:
+!local variables:
   INTEGER i, j, k, icbmax
   REAL deltap, fac, w, amu
@@ -1454,7 +1529,7 @@
 
 
-  ! -------------------------------------------------------
-  ! -- Initialization
-  ! -------------------------------------------------------
+! -------------------------------------------------------
+! -- Initialization
+! -------------------------------------------------------
 
   DO k = 1, nl
@@ -1464,15 +1539,15 @@
   END DO
 
-  ! -------------------------------------------------------
-  ! -- Reset sig(i) and w0(i) for i>inb and i<icb
-  ! -------------------------------------------------------
-
-  ! update sig and w0 above LNB:
+! -------------------------------------------------------
+! -- Reset sig(i) and w0(i) for i>inb and i<icb
+! -------------------------------------------------------
+
+! update sig and w0 above LNB:
 
   DO k = 1, nl - 1
     DO i = 1, ncum
       IF ((inb(i)<(nl-1)) .AND. (k>=(inb(i)+1))) THEN
-        sig(i, k) = beta*sig(i, k) + 2.*alpha*buoy(i, inb(i))*abs(buoy(i,inb( &
-          i)))
+        sig(i, k) = beta*sig(i, k) + &
+                    2.*alpha*buoy(i, inb(i))*abs(buoy(i,inb(i)))
         sig(i, k) = amax1(sig(i,k), 0.0)
         w0(i, k) = beta*w0(i, k)
@@ -1481,5 +1556,5 @@
   END DO
 
-  ! compute icbmax:
+! compute icbmax:
 
   icbmax = 2
@@ -1488,10 +1563,11 @@
   END DO
 
-  ! update sig and w0 below cloud base:
+! update sig and w0 below cloud base:
 
   DO k = 1, icbmax
     DO i = 1, ncum
       IF (k<=icb(i)) THEN
-        sig(i, k) = beta*sig(i, k) - 2.*alpha*buoy(i, icb(i))*buoy(i, icb(i))
+        sig(i, k) = beta*sig(i, k) - &
+                    2.*alpha*buoy(i, icb(i))*buoy(i, icb(i))
         sig(i, k) = max(sig(i,k), 0.0)
         w0(i, k) = beta*w0(i, k)
@@ -1500,23 +1576,23 @@
   END DO
 
-  ! !      if(inb.lt.(nl-1))then
-  ! !         do 85 i=inb+1,nl-1
-  ! !            sig(i)=beta*sig(i)+2.*alpha*buoy(inb)*
-  ! !     1              abs(buoy(inb))
-  ! !            sig(i)=max(sig(i),0.0)
-  ! !            w0(i)=beta*w0(i)
-  ! !   85    continue
-  ! !      end if
-
-  ! !      do 87 i=1,icb
-  ! !         sig(i)=beta*sig(i)-2.*alpha*buoy(icb)*buoy(icb)
-  ! !         sig(i)=max(sig(i),0.0)
-  ! !         w0(i)=beta*w0(i)
-  ! !   87 continue
-
-  ! -------------------------------------------------------------
-  ! -- Reset fractional areas of updrafts and w0 at initial time
-  ! -- and after 10 time steps of no convection
-  ! -------------------------------------------------------------
+!!      if(inb.lt.(nl-1))then
+!!         do 85 i=inb+1,nl-1
+!!            sig(i)=beta*sig(i)+2.*alpha*buoy(inb)*
+!!     1              abs(buoy(inb))
+!!            sig(i)=max(sig(i),0.0)
+!!            w0(i)=beta*w0(i)
+!!   85    continue
+!!      end if
+
+!!      do 87 i=1,icb
+!!         sig(i)=beta*sig(i)-2.*alpha*buoy(icb)*buoy(icb)
+!!         sig(i)=max(sig(i),0.0)
+!!         w0(i)=beta*w0(i)
+!!   87 continue
+
+! -------------------------------------------------------------
+! -- Reset fractional areas of updrafts and w0 at initial time
+! -- and after 10 time steps of no convection
+! -------------------------------------------------------------
 
   DO k = 1, nl - 1
@@ -1529,9 +1605,9 @@
   END DO
 
-  ! -------------------------------------------------------------
-  ! -- Calculate convective available potential energy (cape),
-  ! -- vertical velocity (w), fractional area covered by
-  ! -- undilute updraft (sig), and updraft mass flux (m)
-  ! -------------------------------------------------------------
+! -------------------------------------------------------------
+! -- Calculate convective available potential energy (cape),
+! -- vertical velocity (w), fractional area covered by
+! -- undilute updraft (sig), and updraft mass flux (m)
+! -------------------------------------------------------------
 
   DO i = 1, ncum
@@ -1539,5 +1615,5 @@
   END DO
 
-  ! compute dtmin (minimum buoyancy between ICB and given level k):
+! compute dtmin (minimum buoyancy between ICB and given level k):
 
   DO i = 1, ncum
@@ -1550,6 +1626,5 @@
     DO k = 1, nl
       DO j = minorig, nl
-        IF ((k>=(icb(i)+1)) .AND. (k<=inb(i)) .AND. (j>=icb(i)) .AND. (j<=(k- &
-            1))) THEN
+        IF ((k>=(icb(i)+1)) .AND. (k<=inb(i)) .AND. (j>=icb(i)) .AND. (j<=(k-1))) THEN
           dtmin(i, k) = amin1(dtmin(i,k), buoy(i,j))
         END IF
@@ -1558,5 +1633,5 @@
   END DO
 
-  ! the interval on which cape is computed starts at pbase :
+! the interval on which cape is computed starts at pbase :
 
   DO k = 1, nl
@@ -1570,8 +1645,8 @@
         sigold(i, k) = sig(i, k)
 
-        ! dtmin(i,k)=100.0
-        ! do 97 j=icb(i),k-1 ! mauvaise vectorisation
-        ! dtmin(i,k)=AMIN1(dtmin(i,k),buoy(i,j))
-        ! 97     continue
+! dtmin(i,k)=100.0
+! do 97 j=icb(i),k-1 ! mauvaise vectorisation
+! dtmin(i,k)=AMIN1(dtmin(i,k),buoy(i,j))
+! 97     continue
 
         sig(i, k) = beta*sig(i, k) + alpha*dtmin(i, k)*abs(dtmin(i,k))
@@ -1590,85 +1665,83 @@
   DO i = 1, ncum
     w0(i, icb(i)) = 0.5*w0(i, icb(i)+1)
-    m(i, icb(i)) = 0.5*m(i, icb(i)+1)*(ph(i,icb(i))-ph(i,icb(i)+1))/ &
-      (ph(i,icb(i)+1)-ph(i,icb(i)+2))
+    m(i, icb(i)) = 0.5*m(i, icb(i)+1)*(ph(i,icb(i))-ph(i,icb(i)+1))/(ph(i,icb(i)+1)-ph(i,icb(i)+2))
     sig(i, icb(i)) = sig(i, icb(i)+1)
     sig(i, icb(i)-1) = sig(i, icb(i))
   END DO
 
-  ! ccc 3. Compute final cloud base mass flux and set iflag to 3 if
-  ! ccc    cloud base mass flux is exceedingly small and is decreasing (i.e.
-  ! if
-  ! ccc    the final mass flux (cbmflast) is greater than the target mass
-  ! flux
-  ! ccc    (cbmf) ??).
-  ! cc
-  ! c      do i = 1,ncum
-  ! c       cbmflast(i) = 0.
-  ! c      enddo
-  ! cc
-  ! c      do k= 1,nl
-  ! c       do i = 1,ncum
-  ! c        IF (k .ge. icb(i) .and. k .le. inb(i)) THEN
-  ! c         cbmflast(i) = cbmflast(i)+M(i,k)
-  ! c        ENDIF
-  ! c       enddo
-  ! c      enddo
-  ! cc
-  ! c      do i = 1,ncum
-  ! c       IF (cbmflast(i) .lt. 1.e-6) THEN
-  ! c         iflag(i) = 3
-  ! c       ENDIF
-  ! c      enddo
-  ! cc
-  ! c      do k= 1,nl
-  ! c       do i = 1,ncum
-  ! c        IF (iflag(i) .ge. 3) THEN
-  ! c         M(i,k) = 0.
-  ! c         sig(i,k) = 0.
-  ! c         w0(i,k) = 0.
-  ! c        ENDIF
-  ! c       enddo
-  ! c      enddo
-  ! cc
-  ! !      cape=0.0
-  ! !      do 98 i=icb+1,inb
-  ! !         deltap = min(pbase,ph(i-1))-min(pbase,ph(i))
-  ! !         cape=cape+rrd*buoy(i-1)*deltap/p(i-1)
-  ! !         dcape=rrd*buoy(i-1)*deltap/p(i-1)
-  ! !         dlnp=deltap/p(i-1)
-  ! !         cape=max(0.0,cape)
-  ! !         sigold=sig(i)
-
-  ! !         dtmin=100.0
-  ! !         do 97 j=icb,i-1
-  ! !            dtmin=amin1(dtmin,buoy(j))
-  ! !   97    continue
-
-  ! !         sig(i)=beta*sig(i)+alpha*dtmin*abs(dtmin)
-  ! !         sig(i)=max(sig(i),0.0)
-  ! !         sig(i)=amin1(sig(i),0.01)
-  ! !         fac=amin1(((dtcrit-dtmin)/dtcrit),1.0)
-  ! !         w=(1.-beta)*fac*sqrt(cape)+beta*w0(i)
-  ! !         amu=0.5*(sig(i)+sigold)*w
-  ! !         m(i)=amu*0.007*p(i)*(ph(i)-ph(i+1))/tv(i)
-  ! !         w0(i)=w
-  ! !   98 continue
-  ! !      w0(icb)=0.5*w0(icb+1)
-  ! !      m(icb)=0.5*m(icb+1)*(ph(icb)-ph(icb+1))/(ph(icb+1)-ph(icb+2))
-  ! !      sig(icb)=sig(icb+1)
-  ! !      sig(icb-1)=sig(icb)
+! ccc 3. Compute final cloud base mass flux and set iflag to 3 if
+! ccc    cloud base mass flux is exceedingly small and is decreasing (i.e. if
+! ccc    the final mass flux (cbmflast) is greater than the target mass flux
+! ccc    (cbmf) ??).
+! cc
+! c      do i = 1,ncum
+! c       cbmflast(i) = 0.
+! c      enddo
+! cc
+! c      do k= 1,nl
+! c       do i = 1,ncum
+! c        IF (k .ge. icb(i) .and. k .le. inb(i)) THEN
+! c         cbmflast(i) = cbmflast(i)+M(i,k)
+! c        ENDIF
+! c       enddo
+! c      enddo
+! cc
+! c      do i = 1,ncum
+! c       IF (cbmflast(i) .lt. 1.e-6) THEN
+! c         iflag(i) = 3
+! c       ENDIF
+! c      enddo
+! cc
+! c      do k= 1,nl
+! c       do i = 1,ncum
+! c        IF (iflag(i) .ge. 3) THEN
+! c         M(i,k) = 0.
+! c         sig(i,k) = 0.
+! c         w0(i,k) = 0.
+! c        ENDIF
+! c       enddo
+! c      enddo
+! cc
+!!      cape=0.0
+!!      do 98 i=icb+1,inb
+!!         deltap = min(pbase,ph(i-1))-min(pbase,ph(i))
+!!         cape=cape+rrd*buoy(i-1)*deltap/p(i-1)
+!!         dcape=rrd*buoy(i-1)*deltap/p(i-1)
+!!         dlnp=deltap/p(i-1)
+!!         cape=max(0.0,cape)
+!!         sigold=sig(i)
+
+!!         dtmin=100.0
+!!         do 97 j=icb,i-1
+!!            dtmin=amin1(dtmin,buoy(j))
+!!   97    continue
+
+!!         sig(i)=beta*sig(i)+alpha*dtmin*abs(dtmin)
+!!         sig(i)=max(sig(i),0.0)
+!!         sig(i)=amin1(sig(i),0.01)
+!!         fac=amin1(((dtcrit-dtmin)/dtcrit),1.0)
+!!         w=(1.-beta)*fac*sqrt(cape)+beta*w0(i)
+!!         amu=0.5*(sig(i)+sigold)*w
+!!         m(i)=amu*0.007*p(i)*(ph(i)-ph(i+1))/tv(i)
+!!         w0(i)=w
+!!   98 continue
+!!      w0(icb)=0.5*w0(icb+1)
+!!      m(icb)=0.5*m(icb+1)*(ph(icb)-ph(icb+1))/(ph(icb+1)-ph(icb+2))
+!!      sig(icb)=sig(icb+1)
+!!      sig(icb-1)=sig(icb)
 
   RETURN
 END SUBROUTINE cv3_closure
 
-SUBROUTINE cv3_mixing(nloc, ncum, nd, na, ntra, icb, nk, inb, ph, t, rr, rs, &
-    u, v, tra, h, lv, lf, frac, qnk, unk, vnk, hp, tv, tvp, ep, clw, m, sig, &
-    ment, qent, uent, vent, nent, sij, elij, ments, qents, traent)
+SUBROUTINE cv3_mixing(nloc, ncum, nd, na, ntra, icb, nk, inb, &
+                      ph, t, rr, rs, u, v, tra, h, lv, lf, frac, qnk, &
+                      unk, vnk, hp, tv, tvp, ep, clw, m, sig, &
+                      ment, qent, uent, vent, nent, sij, elij, ments, qents, traent)
   IMPLICIT NONE
 
-  ! ---------------------------------------------------------------------
-  ! a faire:
-  ! - vectorisation de la partie normalisation des flux (do 789...)
-  ! ---------------------------------------------------------------------
+! ---------------------------------------------------------------------
+! a faire:
+! - vectorisation de la partie normalisation des flux (do 789...)
+! ---------------------------------------------------------------------
 
   include "cvthermo.h"
@@ -1676,5 +1749,5 @@
   include "cvflag.h"
 
-  ! inputs:
+!inputs:
   INTEGER ncum, nd, na, ntra, nloc
   INTEGER icb(nloc), inb(nloc), nk(nloc)
@@ -1690,5 +1763,5 @@
   REAL m(nloc, na) ! input of convect3
 
-  ! outputs:
+!outputs:
   REAL ment(nloc, na, na), qent(nloc, na, na)
   REAL uent(nloc, na, na), vent(nloc, na, na)
@@ -1699,5 +1772,5 @@
   INTEGER nent(nloc, nd)
 
-  ! local variables:
+!local variables:
   INTEGER i, j, k, il, im, jm
   INTEGER num1, num2
@@ -1710,19 +1783,19 @@
   LOGICAL lwork(nloc)
 
-  ! =====================================================================
-  ! --- INITIALIZE VARIOUS ARRAYS USED IN THE COMPUTATIONS
-  ! =====================================================================
-
-  ! ori        do 360 i=1,ncum*nlp
+! =====================================================================
+! --- INITIALIZE VARIOUS ARRAYS USED IN THE COMPUTATIONS
+! =====================================================================
+
+! ori        do 360 i=1,ncum*nlp
   DO j = 1, nl
     DO i = 1, ncum
       nent(i, j) = 0
-      ! in convect3, m is computed in cv3_closure
-      ! ori          m(i,1)=0.0
-    END DO
-  END DO
-
-  ! ori      do 400 k=1,nlp
-  ! ori       do 390 j=1,nlp
+! in convect3, m is computed in cv3_closure
+! ori          m(i,1)=0.0
+    END DO
+  END DO
+
+! ori      do 400 k=1,nlp
+! ori       do 390 j=1,nlp
   DO j = 1, nl
     DO k = 1, nl
@@ -1732,30 +1805,30 @@
         vent(i, k, j) = v(i, j)
         elij(i, k, j) = 0.0
-        ! ym            ment(i,k,j)=0.0
-        ! ym            sij(i,k,j)=0.0
+!ym            ment(i,k,j)=0.0
+!ym            sij(i,k,j)=0.0
       END DO
     END DO
   END DO
 
-  ! ym
+!ym
   ment(1:ncum, 1:nd, 1:nd) = 0.0
   sij(1:ncum, 1:nd, 1:nd) = 0.0
 
-  ! AC!      do k=1,ntra
-  ! AC!       do j=1,nd  ! instead nlp
-  ! AC!        do i=1,nd ! instead nlp
-  ! AC!         do il=1,ncum
-  ! AC!            traent(il,i,j,k)=tra(il,j,k)
-  ! AC!         enddo
-  ! AC!        enddo
-  ! AC!       enddo
-  ! AC!      enddo
+!AC!      do k=1,ntra
+!AC!       do j=1,nd  ! instead nlp
+!AC!        do i=1,nd ! instead nlp
+!AC!         do il=1,ncum
+!AC!            traent(il,i,j,k)=tra(il,j,k)
+!AC!         enddo
+!AC!        enddo
+!AC!       enddo
+!AC!      enddo
   zm(:, :) = 0.
 
-  ! =====================================================================
-  ! --- CALCULATE ENTRAINED AIR MASS FLUX (ment), TOTAL WATER MIXING
-  ! --- RATIO (QENT), TOTAL CONDENSED WATER (elij), AND MIXING
-  ! --- FRACTION (sij)
-  ! =====================================================================
+! =====================================================================
+! --- CALCULATE ENTRAINED AIR MASS FLUX (ment), TOTAL WATER MIXING
+! --- RATIO (QENT), TOTAL CONDENSED WATER (elij), AND MIXING
+! --- FRACTION (sij)
+! =====================================================================
 
   DO i = minorig + 1, nl
@@ -1763,6 +1836,5 @@
     DO j = minorig, nl
       DO il = 1, ncum
-        IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. (j>=(icb(il)- &
-            1)) .AND. (j<=inb(il))) THEN
+        IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. (j>=(icb(il)-1)) .AND. (j<=inb(il))) THEN
 
           rti = qnk(il) - ep(il, i)*clw(il, i)
@@ -1771,8 +1843,8 @@
 
           IF (cvflag_ice) THEN
-            ! print*,cvflag_ice,'cvflag_ice dans do 700'
+! print*,cvflag_ice,'cvflag_ice dans do 700'
             IF (t(il,j)<=263.15) THEN
-              bf2 = 1. + (lf(il,j)+lv(il,j))*(lv(il,j)+frac(il,j)*lf(il,j))* &
-                rs(il, j)/(rrv*t(il,j)*t(il,j)*cpd)
+              bf2 = 1. + (lf(il,j)+lv(il,j))*(lv(il,j)+frac(il,j)* &
+                   lf(il,j))*rs(il, j)/(rrv*t(il,j)*t(il,j)*cpd)
             END IF
           END IF
@@ -1791,6 +1863,5 @@
 
             IF (cvflag_ice) THEN
-              anum = anum - (lv(il,j)+frac(il,j)*lf(il,j))*(rti-rs(il,j)-cwat &
-                *bf2)
+              anum = anum - (lv(il,j)+frac(il,j)*lf(il,j))*(rti-rs(il,j)-cwat*bf2)
               denom = denom + (lv(il,j)+frac(il,j)*lf(il,j))*(rr(il,i)-rti)
             ELSE
@@ -1801,18 +1872,15 @@
             IF (abs(denom)<0.01) denom = 0.01
             sij(il, i, j) = anum/denom
-            altem = sij(il, i, j)*rr(il, i) + (1.-sij(il,i,j))*rti - &
-              rs(il, j)
+            altem = sij(il, i, j)*rr(il, i) + (1.-sij(il,i,j))*rti - rs(il, j)
             altem = altem - (bf2-1.)*cwat
           END IF
           IF (sij(il,i,j)>0.0 .AND. sij(il,i,j)<0.95) THEN
             qent(il, i, j) = sij(il, i, j)*rr(il, i) + (1.-sij(il,i,j))*rti
-            uent(il, i, j) = sij(il, i, j)*u(il, i) + &
-              (1.-sij(il,i,j))*unk(il)
-            vent(il, i, j) = sij(il, i, j)*v(il, i) + &
-              (1.-sij(il,i,j))*vnk(il)
-            ! !!!      do k=1,ntra
-            ! !!!      traent(il,i,j,k)=sij(il,i,j)*tra(il,i,k)
-            ! !!!     :      +(1.-sij(il,i,j))*tra(il,nk(il),k)
-            ! !!!      end do
+            uent(il, i, j) = sij(il, i, j)*u(il, i) + (1.-sij(il,i,j))*unk(il)
+            vent(il, i, j) = sij(il, i, j)*v(il, i) + (1.-sij(il,i,j))*vnk(il)
+!!!!      do k=1,ntra
+!!!!      traent(il,i,j,k)=sij(il,i,j)*tra(il,i,k)
+!!!!     :      +(1.-sij(il,i,j))*tra(il,nk(il),k)
+!!!!      end do
             elij(il, i, j) = altem
             elij(il, i, j) = max(0.0, elij(il,i,j))
@@ -1826,28 +1894,26 @@
     END DO
 
-    ! AC!       do k=1,ntra
-    ! AC!        do j=minorig,nl
-    ! AC!         do il=1,ncum
-    ! AC!          if( (i.ge.icb(il)).and.(i.le.inb(il)).and.
-    ! AC!     :       (j.ge.(icb(il)-1)).and.(j.le.inb(il)))then
-    ! AC!            traent(il,i,j,k)=sij(il,i,j)*tra(il,i,k)
-    ! AC!     :            +(1.-sij(il,i,j))*tra(il,nk(il),k)
-    ! AC!          endif
-    ! AC!         enddo
-    ! AC!        enddo
-    ! AC!       enddo
-
-
-    ! ***   if no air can entrain at level i assume that updraft detrains
-    ! ***
-    ! ***   at that level and calculate detrained air flux and properties
-    ! ***
-
-
-    ! @      do 170 i=icb(il),inb(il)
+!AC!       do k=1,ntra
+!AC!        do j=minorig,nl
+!AC!         do il=1,ncum
+!AC!          if( (i.ge.icb(il)).and.(i.le.inb(il)).and.
+!AC!     :       (j.ge.(icb(il)-1)).and.(j.le.inb(il)))then
+!AC!            traent(il,i,j,k)=sij(il,i,j)*tra(il,i,k)
+!AC!     :            +(1.-sij(il,i,j))*tra(il,nk(il),k)
+!AC!          endif
+!AC!         enddo
+!AC!        enddo
+!AC!       enddo
+
+
+! ***   if no air can entrain at level i assume that updraft detrains  ***
+! ***   at that level and calculate detrained air flux and properties  ***
+
+
+! @      do 170 i=icb(il),inb(il)
 
     DO il = 1, ncum
       IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. (nent(il,i)==0)) THEN
-        ! @      if(nent(il,i).eq.0)then
+! @      if(nent(il,i).eq.0)then
         ment(il, i, i) = m(il, i)
         qent(il, i, i) = qnk(il) - ep(il, i)*clw(il, i)
@@ -1855,5 +1921,5 @@
         vent(il, i, i) = vnk(il)
         elij(il, i, i) = clw(il, i)
-        ! MAF      sij(il,i,i)=1.0
+! MAF      sij(il,i,i)=1.0
         sij(il, i, i) = 0.0
       END IF
@@ -1861,20 +1927,18 @@
   END DO
 
-  ! AC!      do j=1,ntra
-  ! AC!       do i=minorig+1,nl
-  ! AC!        do il=1,ncum
-  ! AC!         if (i.ge.icb(il) .and. i.le.inb(il) .and. nent(il,i).eq.0)
-  ! then
-  ! AC!          traent(il,i,i,j)=tra(il,nk(il),j)
-  ! AC!         endif
-  ! AC!        enddo
-  ! AC!       enddo
-  ! AC!      enddo
+!AC!      do j=1,ntra
+!AC!       do i=minorig+1,nl
+!AC!        do il=1,ncum
+!AC!         if (i.ge.icb(il) .and. i.le.inb(il) .and. nent(il,i).eq.0) then
+!AC!          traent(il,i,i,j)=tra(il,nk(il),j)
+!AC!         endif
+!AC!        enddo
+!AC!       enddo
+!AC!      enddo
 
   DO j = minorig, nl
     DO i = minorig, nl
       DO il = 1, ncum
-        IF ((j>=(icb(il)-1)) .AND. (j<=inb(il)) .AND. (i>=icb(il)) .AND. (i<= &
-            inb(il))) THEN
+        IF ((j>=(icb(il)-1)) .AND. (j<=inb(il)) .AND. (i>=icb(il)) .AND. (i<=inb(il))) THEN
           sigij(il, i, j) = sij(il, i, j)
         END IF
@@ -1882,12 +1946,12 @@
     END DO
   END DO
-  ! @      enddo
-
-  ! @170   continue
-
-  ! =====================================================================
-  ! ---  NORMALIZE ENTRAINED AIR MASS FLUXES
-  ! ---  TO REPRESENT EQUAL PROBABILITIES OF MIXING
-  ! =====================================================================
+! @      enddo
+
+! @170   continue
+
+! =====================================================================
+! ---  NORMALIZE ENTRAINED AIR MASS FLUXES
+! ---  TO REPRESENT EQUAL PROBABILITIES OF MIXING
+! =====================================================================
 
   CALL zilch(asum, nloc*nd)
@@ -1915,14 +1979,14 @@
         IF (cvflag_ice) THEN
 
-          anum = h(il, i) - hp(il, i) - (lv(il,i)+frac(il,i)*lf(il,i))*(qp-rs &
-            (il,i)) + (cpv-cpd)*t(il, i)*(qp-rr(il,i))
-          denom = h(il, i) - hp(il, i) + (lv(il,i)+frac(il,i)*lf(il,i))*(rr( &
-            il,i)-qp) + (cpd-cpv)*t(il, i)*(rr(il,i)-qp)
+          anum = h(il, i) - hp(il, i) - (lv(il,i)+frac(il,i)*lf(il,i))* &
+                       (qp-rs(il,i)) + (cpv-cpd)*t(il, i)*(qp-rr(il,i))
+          denom = h(il, i) - hp(il, i) + (lv(il,i)+frac(il,i)*lf(il,i))* &
+                       (rr(il,i)-qp) + (cpd-cpv)*t(il, i)*(rr(il,i)-qp)
         ELSE
 
           anum = h(il, i) - hp(il, i) - lv(il, i)*(qp-rs(il,i)) + &
-            (cpv-cpd)*t(il, i)*(qp-rr(il,i))
+                       (cpv-cpd)*t(il, i)*(qp-rr(il,i))
           denom = h(il, i) - hp(il, i) + lv(il, i)*(rr(il,i)-qp) + &
-            (cpd-cpv)*t(il, i)*(rr(il,i)-qp)
+                       (cpd-cpv)*t(il, i)*(rr(il,i)-qp)
         END IF
 
@@ -1940,12 +2004,14 @@
       num2 = 0
       DO il = 1, ncum
-        IF (i>=icb(il) .AND. i<=inb(il) .AND. j>=(icb( &
-          il)-1) .AND. j<=inb(il) .AND. lwork(il)) num2 = num2 + 1
+        IF (i>=icb(il) .AND. i<=inb(il) .AND. &
+            j>=(icb(il)-1) .AND. j<=inb(il) .AND. &
+            lwork(il)) num2 = num2 + 1
       END DO
       IF (num2<=0) GO TO 175
 
       DO il = 1, ncum
-        IF (i>=icb(il) .AND. i<=inb(il) .AND. j>=(icb( &
-            il)-1) .AND. j<=inb(il) .AND. lwork(il)) THEN
+        IF (i>=icb(il) .AND. i<=inb(il) .AND. &
+            j>=(icb(il)-1) .AND. j<=inb(il) .AND. &
+            lwork(il)) THEN
 
           IF (sij(il,i,j)>1.0E-16 .AND. sij(il,i,j)<0.95) THEN
@@ -1988,6 +2054,6 @@
     DO j = minorig, nl
       DO il = 1, ncum
-        IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. j>=(icb( &
-            il)-1) .AND. j<=inb(il)) THEN
+        IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. &
+            j>=(icb(il)-1) .AND. j<=inb(il)) THEN
           ment(il, i, j) = ment(il, i, j)*asij(il)
         END IF
@@ -1997,6 +2063,6 @@
     DO j = minorig, nl
       DO il = 1, ncum
-        IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. j>=(icb( &
-            il)-1) .AND. j<=inb(il)) THEN
+        IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. &
+            j>=(icb(il)-1) .AND. j<=inb(il)) THEN
           asum(il, i) = asum(il, i) + ment(il, i, j)
           ment(il, i, j) = ment(il, i, j)*sig(il, j)
@@ -2015,6 +2081,6 @@
     DO j = minorig, nl
       DO il = 1, ncum
-        IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. j>=(icb( &
-            il)-1) .AND. j<=inb(il)) THEN
+        IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. &
+            j>=(icb(il)-1) .AND. j<=inb(il)) THEN
           ment(il, i, j) = ment(il, i, j)*asum(il, i)*bsum(il, i)
         END IF
@@ -2024,6 +2090,6 @@
     DO j = minorig, nl
       DO il = 1, ncum
-        IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. j>=(icb( &
-            il)-1) .AND. j<=inb(il)) THEN
+        IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. &
+            j>=(icb(il)-1) .AND. j<=inb(il)) THEN
           csum(il, i) = csum(il, i) + ment(il, i, j)
         END IF
@@ -2040,20 +2106,20 @@
         vent(il, i, i) = vnk(il)
         elij(il, i, i) = clw(il, i)
-        ! MAF        sij(il,i,i)=1.0
+! MAF        sij(il,i,i)=1.0
         sij(il, i, i) = 0.0
       END IF
     END DO ! il
 
-    ! AC!      do j=1,ntra
-    ! AC!       do il=1,ncum
-    ! AC!        if ( i.ge.icb(il) .and. i.le.inb(il) .and. lwork(il)
-    ! AC!     :     .and. csum(il,i).lt.m(il,i) ) then
-    ! AC!         traent(il,i,i,j)=tra(il,nk(il),j)
-    ! AC!        endif
-    ! AC!       enddo
-    ! AC!      enddo
+!AC!      do j=1,ntra
+!AC!       do il=1,ncum
+!AC!        if ( i.ge.icb(il) .and. i.le.inb(il) .and. lwork(il)
+!AC!     :     .and. csum(il,i).lt.m(il,i) ) then
+!AC!         traent(il,i,i,j)=tra(il,nk(il),j)
+!AC!        endif
+!AC!       enddo
+!AC!      enddo
 789 END DO
 
-  ! MAF: renormalisation de MENT
+! MAF: renormalisation de MENT
   CALL zilch(zm, nloc*na)
   DO jm = 1, nd
@@ -2087,8 +2153,11 @@
 END SUBROUTINE cv3_mixing
 
-SUBROUTINE cv3_unsat(nloc, ncum, nd, na, ntra, icb, inb, iflag, t, rr, rs, &
-    gz, u, v, tra, p, ph, th, tv, lv, lf, cpn, ep, sigp, clw, m, ment, elij, &
-    delt, plcl, coef_clos, mp, rp, up, vp, trap, wt, water, evap, fondue, &
-    ice, faci, b, sigd, wdtraina, wdtrainm) ! RomP
+SUBROUTINE cv3_unsat(nloc, ncum, nd, na, ntra, icb, inb, iflag, &
+                     t, rr, rs, gz, u, v, tra, p, ph, &
+                     th, tv, lv, lf, cpn, ep, sigp, clw, &
+                     m, ment, elij, delt, plcl, coef_clos, &
+                     mp, rp, up, vp, trap, wt, water, evap, fondue, ice, &
+                     faci, b, sigd, &
+                     wdtrainA, wdtrainM)                                      ! RomP
   IMPLICIT NONE
 
@@ -2098,5 +2167,5 @@
   include "cvflag.h"
 
-  ! inputs:
+!inputs:
   INTEGER ncum, nd, na, ntra, nloc
   INTEGER icb(nloc), inb(nloc)
@@ -2112,8 +2181,8 @@
   REAL coef_clos(nloc)
 
-  ! input/output
+!input/output
   INTEGER iflag(nloc)
 
-  ! outputs:
+!outputs:
   REAL mp(nloc, na), rp(nloc, na), up(nloc, na), vp(nloc, na)
   REAL water(nloc, na), evap(nloc, na), wt(nloc, na)
@@ -2121,11 +2190,11 @@
   REAL trap(nloc, na, ntra)
   REAL b(nloc, na), sigd(nloc)
-  ! 25/08/10 - RomP---- ajout des masses precipitantes ejectees
-  ! lascendance adiabatique et des flux melanges Pa et Pm.
-  ! Distinction des wdtrain
-  ! Pa = wdtrainA     Pm = wdtrainM
-  REAL wdtraina(nloc, na), wdtrainm(nloc, na)
-
-  ! local variables
+! 25/08/10 - RomP---- ajout des masses precipitantes ejectees
+! de l ascendance adiabatique et des flux melanges Pa et Pm.
+! Distinction des wdtrain
+! Pa = wdtrainA     Pm = wdtrainM
+  REAL wdtrainA(nloc, na), wdtrainM(nloc, na)
+
+!local variables
   INTEGER i, j, k, il, num1, ndp1
   REAL tinv, delti, coef
@@ -2143,5 +2212,5 @@
 
 
-  ! ------------------------------------------------------
+! ------------------------------------------------------
 
   delti = 1./delt
@@ -2170,31 +2239,31 @@
     END DO
   END DO
-  ! AC!        do k=1,ntra
-  ! AC!         do i=1,nd
-  ! AC!          do il=1,ncum
-  ! AC!           trap(il,i,k)=tra(il,i,k)
-  ! AC!          enddo
-  ! AC!         enddo
-  ! AC!        enddo
-  ! ! RomP >>>
+!AC!        do k=1,ntra
+!AC!         do i=1,nd
+!AC!          do il=1,ncum
+!AC!           trap(il,i,k)=tra(il,i,k)
+!AC!          enddo
+!AC!         enddo
+!AC!        enddo
+!! RomP >>>
   DO i = 1, nd
     DO il = 1, ncum
-      wdtraina(il, i) = 0.0
-      wdtrainm(il, i) = 0.0
-    END DO
-  END DO
-  ! ! RomP <<<
-
-  ! ***  check whether ep(inb)=0, if so, skip precipitating    ***
-  ! ***             downdraft calculation                      ***
+      wdtrainA(il, i) = 0.0
+      wdtrainM(il, i) = 0.0
+    END DO
+  END DO
+!! RomP <<<
+
+! ***  check whether ep(inb)=0, if so, skip precipitating    ***
+! ***             downdraft calculation                      ***
 
 
   DO il = 1, ncum
-    ! !          lwork(il)=.TRUE.
-    ! !          if(ep(il,inb(il)).lt.0.0001)lwork(il)=.FALSE.
+!!          lwork(il)=.TRUE.
+!!          if(ep(il,inb(il)).lt.0.0001)lwork(il)=.FALSE.
     lwork(il) = ep(il, inb(il)) >= 0.0001
   END DO
 
-  ! ***  Set the fractionnal area sigd of precipitating downdraughts
+! ***  Set the fractionnal area sigd of precipitating downdraughts
   DO il = 1, ncum
     sigd(il) = sigdz*coef_clos(il)
@@ -2202,9 +2271,9 @@
 
 
-  ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-  ! ***                    begin downdraft loop                    ***
-
-  ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+!
+! ***                    begin downdraft loop                    ***
+!
+! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
   DO i = nl + 1, 1, -1
@@ -2219,9 +2288,9 @@
 
 
-    ! ***  integrate liquid water equation to find condensed water   ***
-    ! ***                and condensed water flux                    ***
-
-
-    ! ***              calculate detrained precipitation             ***
+! ***  integrate liquid water equation to find condensed water   ***
+! ***                and condensed water flux                    ***
+!
+!
+! ***              calculate detrained precipitation             ***
 
     DO il = 1, ncum
@@ -2229,8 +2298,8 @@
         IF (cvflag_grav) THEN
           wdtrain(il) = grav*ep(il, i)*m(il, i)*clw(il, i)
-          wdtraina(il, i) = wdtrain(il)/grav !   Pa   RomP
+          wdtrainA(il, i) = wdtrain(il)/grav                        !   Pa   RomP
         ELSE
           wdtrain(il) = 10.0*ep(il, i)*m(il, i)*clw(il, i)
-          wdtraina(il, i) = wdtrain(il)/10. !   Pa   RomP
+          wdtrainA(il, i) = wdtrain(il)/10.                         !   Pa   RomP
         END IF
       END IF
@@ -2245,8 +2314,8 @@
             IF (cvflag_grav) THEN
               wdtrain(il) = wdtrain(il) + grav*awat*ment(il, j, i)
-              wdtrainm(il, i) = wdtrain(il)/grav - wdtraina(il, i) !   Pm  RomP
+              wdtrainM(il, i) = wdtrain(il)/grav - wdtrainA(il, i)  !   Pm  RomP
             ELSE
               wdtrain(il) = wdtrain(il) + 10.0*awat*ment(il, j, i)
-              wdtrainm(il, i) = wdtrain(il)/10. - wdtraina(il, i) !   Pm  RomP
+              wdtrainM(il, i) = wdtrain(il)/10. - wdtrainA(il, i)   !   Pm  RomP
             END IF
           END IF
@@ -2256,6 +2325,6 @@
 
 
-    ! ***    find rain water and evaporation using provisional   ***
-    ! ***              estimates of rp(i)and rp(i-1)             ***
+! ***    find rain water and evaporation using provisional   ***
+! ***              estimates of rp(i)and rp(i-1)             ***
 
 
@@ -2283,6 +2352,6 @@
           END IF
 
-          rp(il, i) = rp(il, i+1) + (cpd*(t(il,i+1)-t(il, &
-            i))+gz(il,i+1)-gz(il,i))/lv(il, i)
+          rp(il, i) = rp(il, i+1) + &
+                      (cpd*(t(il,i+1)-t(il,i))+gz(il,i+1)-gz(il,i))/lv(il, i)
           rp(il, i) = 0.5*(rp(il,i)+rr(il,i))
         END IF
@@ -2296,17 +2365,13 @@
           afac = p(il, 1)*(rs(il,1)-rp(il,1))/(1.0E4+2000.0*p(il,1)*rs(il,1))
           IF (cvflag_ice) THEN
-            afac1 = p(il, i)*(rs(il,1)-rp(il,1))/(1.0E4+2000.0*p(il,1)*rs(il, &
-              1))
+            afac1 = p(il, i)*(rs(il,1)-rp(il,1))/(1.0E4+2000.0*p(il,1)*rs(il,1))
           END IF
         ELSE
-          rp(il, i-1) = rp(il, i) + (cpd*(t(il,i)-t(il, &
-            i-1))+gz(il,i)-gz(il,i-1))/lv(il, i)
+          rp(il, i-1) = rp(il, i) + (cpd*(t(il,i)-t(il,i-1))+gz(il,i)-gz(il,i-1))/lv(il, i)
           rp(il, i-1) = 0.5*(rp(il,i-1)+rr(il,i-1))
           rp(il, i-1) = amin1(rp(il,i-1), rs(il,i-1))
           rp(il, i-1) = max(rp(il,i-1), 0.0)
-          afac1 = p(il, i)*(rs(il,i)-rp(il,i))/(1.0E4+2000.0*p(il,i)*rs(il,i) &
-            )
-          afac2 = p(il, i-1)*(rs(il,i-1)-rp(il,i-1))/ &
-            (1.0E4+2000.0*p(il,i-1)*rs(il,i-1))
+          afac1 = p(il, i)*(rs(il,i)-rp(il,i))/(1.0E4+2000.0*p(il,i)*rs(il,i))
+          afac2 = p(il, i-1)*(rs(il,i-1)-rp(il,i-1))/(1.0E4+2000.0*p(il,i-1)*rs(il,i-1))
           afac = 0.5*(afac1+afac2)
         END IF
@@ -2315,14 +2380,14 @@
         bfac = 1./(sigd(il)*wt(il,i))
 
-        ! jyg1
-        ! cc        sigt=1.0
-        ! cc        if(i.ge.icb)sigt=sigp(i)
-        ! prise en compte de la variation progressive de sigt dans
-        ! les couches icb et icb-1:
-        ! pour plcl<ph(i+1), pr1=0 & pr2=1
-        ! pour plcl>ph(i),   pr1=1 & pr2=0
-        ! pour ph(i+1)<plcl<ph(i), pr1 est la proportion a cheval
-        ! sur le nuage, et pr2 est la proportion sous la base du
-        ! nuage.
+!JYG1
+! cc        sigt=1.0
+! cc        if(i.ge.icb)sigt=sigp(i)
+! prise en compte de la variation progressive de sigt dans
+! les couches icb et icb-1:
+! pour plcl<ph(i+1), pr1=0 & pr2=1
+! pour plcl>ph(i),   pr1=1 & pr2=0
+! pour ph(i+1)<plcl<ph(i), pr1 est la proportion a cheval
+! sur le nuage, et pr2 est la proportion sous la base du
+! nuage.
         pr1 = (plcl(il)-ph(il,i+1))/(ph(il,i)-ph(il,i+1))
         pr1 = max(0., min(1.,pr1))
@@ -2330,40 +2395,39 @@
         pr2 = max(0., min(1.,pr2))
         sigt = sigp(il, i)*pr1 + pr2
-        ! jyg2
-
-        ! jyg----
-        ! b6 = bfac*100.*sigd(il)*(ph(il,i)-ph(il,i+1))*sigt*afac
-        ! c6 = water(il,i+1) + wdtrain(il)*bfac
-        ! c6 = prec(il,i+1) + wdtrain(il)*bfac
-        ! revap=0.5*(-b6+sqrt(b6*b6+4.*c6))
-        ! evap(il,i)=sigt*afac*revap
-        ! water(il,i)=revap*revap
-        ! prec(il,i)=revap*revap
-        ! c        print *,' i,b6,c6,revap,evap(il,i),water(il,i),wdtrain(il)
-        ! ',
-        ! c     $            i,b6,c6,revap,evap(il,i),water(il,i),wdtrain(il)
-        ! c---end jyg---
-
-        ! --------retour à la formulation originale d'Emanuel.
+!JYG2
+
+!JYG----
+!    b6 = bfac*100.*sigd(il)*(ph(il,i)-ph(il,i+1))*sigt*afac
+!    c6 = water(il,i+1) + wdtrain(il)*bfac
+!    c6 = prec(il,i+1) + wdtrain(il)*bfac
+!    revap=0.5*(-b6+sqrt(b6*b6+4.*c6))
+!    evap(il,i)=sigt*afac*revap
+!    water(il,i)=revap*revap
+!    prec(il,i)=revap*revap
+!!        print *,' i,b6,c6,revap,evap(il,i),water(il,i),wdtrain(il) ', &
+!!                 i,b6,c6,revap,evap(il,i),water(il,i),wdtrain(il)
+!!---end jyg---
+
+! --------retour à la formulation originale d'Emanuel.
         IF (cvflag_ice) THEN
 
-          ! b6=bfac*50.*sigd(il)*(ph(il,i)-ph(il,i+1))*sigt*afac
-          ! c6=prec(il,i+1)+bfac*wdtrain(il)
-          ! :    -50.*sigd(il)*bfac*(ph(il,i)-ph(il,i+1))*evap(il,i+1)
-          ! if(c6.gt.0.0)then
-          ! revap=0.5*(-b6+sqrt(b6*b6+4.*c6))
-
-          ! JAM  Attention: evap=sigt*E
-          ! Modification: evap devient l'évaporation en milieu de couche
-          ! car nécessaire dans cv3_yield
-          ! Du coup, il faut modifier pas mal d'équations...
-          ! et l'expression de afac qui devient afac1
-          ! revap=sqrt((prec(i+1)+prec(i))/2)
+!   b6=bfac*50.*sigd(il)*(ph(il,i)-ph(il,i+1))*sigt*afac
+!   c6=prec(il,i+1)+bfac*wdtrain(il) &
+!       -50.*sigd(il)*bfac*(ph(il,i)-ph(il,i+1))*evap(il,i+1)
+!   if(c6.gt.0.0)then
+!   revap=0.5*(-b6+sqrt(b6*b6+4.*c6))
+
+!JAM  Attention: evap=sigt*E
+!    Modification: evap devient l'évaporation en milieu de couche
+!    car nécessaire dans cv3_yield
+!    Du coup, il faut modifier pas mal d'équations...
+!    et l'expression de afac qui devient afac1
+!    revap=sqrt((prec(i+1)+prec(i))/2)
 
           b6 = bfac*50.*sigd(il)*(ph(il,i)-ph(il,i+1))*sigt*afac1
           c6 = prec(il, i+1) + 0.5*bfac*wdtrain(il)
-          ! print *,'bfac,sigd(il),sigt,afac1 ',bfac,sigd(il),sigt,afac1
-          ! print *,'prec(il,i+1),wdtrain(il) ',prec(il,i+1),wdtrain(il)
-          ! print *,'b6,c6,b6*b6+4.*c6 ',b6,c6,b6*b6+4.*c6
+! print *,'bfac,sigd(il),sigt,afac1 ',bfac,sigd(il),sigt,afac1
+! print *,'prec(il,i+1),wdtrain(il) ',prec(il,i+1),wdtrain(il)
+! print *,'b6,c6,b6*b6+4.*c6 ',b6,c6,b6*b6+4.*c6
           IF (c6>b6*b6+1.E-20) THEN
             revap = 2.*c6/(b6+sqrt(b6*b6+4.*c6))
@@ -2372,28 +2436,24 @@
           END IF
           prec(il, i) = max(0., 2.*revap*revap-prec(il,i+1))
-          ! print*,prec(il,i),'neige'
-
-          ! jyg    Dans sa formulation originale, Emanuel calcule
-          ! l'evaporation par:
-          ! c             evap(il,i)=sigt*afac*revap
-          ! ce qui n'est pas correct. Dans cv_routines, la formulation a été
-          ! modifiee.
-          ! Ici,l'evaporation evap est simplement calculee par l'equation de
-          ! conservation.
-          ! prec(il,i)=revap*revap
-          ! else
-          ! jyg----   Correction : si c6 <= 0, water(il,i)=0.
-          ! prec(il,i)=0.
-          ! endif
-
-          ! jyg---   Dans tous les cas, evaporation = [tt ce qui entre dans
-          ! la couche i]
-          ! moins [tt ce qui sort de la couche i]
-          ! print *, 'evap avec ice'
-          evap(il, i) = (wdtrain(il)+sigd(il)*wt(il,i)*(prec(il,i+1)-prec(il, &
-            i)))/(sigd(il)*(ph(il,i)-ph(il,i+1))*100.)
-
-          d6 = bfac*wdtrain(il) - 100.*sigd(il)*bfac*(ph(il,i)-ph(il,i+1))* &
-            evap(il, i)
+! print*,prec(il,i),'neige'
+
+!JYG    Dans sa formulation originale, Emanuel calcule l'evaporation par:
+! c             evap(il,i)=sigt*afac*revap
+! ce qui n'est pas correct. Dans cv_routines, la formulation a été modifiee.
+! Ici,l'evaporation evap est simplement calculee par l'equation de
+! conservation.
+! prec(il,i)=revap*revap
+! else
+!JYG----   Correction : si c6 <= 0, water(il,i)=0.
+! prec(il,i)=0.
+! endif
+
+!JYG---   Dans tous les cas, evaporation = [tt ce qui entre dans la couche i]
+! moins [tt ce qui sort de la couche i]
+! print *, 'evap avec ice'
+          evap(il, i) = (wdtrain(il)+sigd(il)*wt(il,i)*(prec(il,i+1)-prec(il,i))) / &
+                        (sigd(il)*(ph(il,i)-ph(il,i+1))*100.)
+
+          d6 = bfac*wdtrain(il) - 100.*sigd(il)*bfac*(ph(il,i)-ph(il,i+1))*evap(il, i)
           e6 = bfac*wdtrain(il)
           f6 = -100.*sigd(il)*bfac*(ph(il,i)-ph(il,i+1))*evap(il, i)
@@ -2415,22 +2475,22 @@
           END IF
 
-          ! water(il,i)=water(il,i+1)+(1.-fraci(il,i))*e6+(1.-faci(il,i))*f6
-          ! water(il,i)=max(water(il,i),0.)
-          ! ice(il,i)=ice(il,i+1)+fraci(il,i)*e6+faci(il,i)*f6
-          ! ice(il,i)=max(ice(il,i),0.)
-          ! fondue(il,i)=ice(il,i)*thaw
-          ! water(il,i)=water(il,i)+fondue(il,i)
-          ! ice(il,i)=ice(il,i)-fondue(il,i)
-
-          ! if((water(il,i)+ice(il,i)).lt.1.e-30)then
-          ! faci(il,i)=0.
-          ! else
-          ! faci(il,i)=ice(il,i)/(water(il,i)+ice(il,i))
-          ! endif
+!           water(il,i)=water(il,i+1)+(1.-fraci(il,i))*e6+(1.-faci(il,i))*f6
+!           water(il,i)=max(water(il,i),0.)
+!           ice(il,i)=ice(il,i+1)+fraci(il,i)*e6+faci(il,i)*f6
+!           ice(il,i)=max(ice(il,i),0.)
+!           fondue(il,i)=ice(il,i)*thaw
+!           water(il,i)=water(il,i)+fondue(il,i)
+!           ice(il,i)=ice(il,i)-fondue(il,i)
+            
+!           if((water(il,i)+ice(il,i)).lt.1.e-30)then
+!             faci(il,i)=0.
+!           else
+!             faci(il,i)=ice(il,i)/(water(il,i)+ice(il,i))
+!           endif
 
         ELSE
           b6 = bfac*50.*sigd(il)*(ph(il,i)-ph(il,i+1))*sigt*afac
-          c6 = water(il, i+1) + bfac*wdtrain(il) - 50.*sigd(il)*bfac*(ph(il,i &
-            )-ph(il,i+1))*evap(il, i+1)
+          c6 = water(il, i+1) + bfac*wdtrain(il) - &
+               50.*sigd(il)*bfac*(ph(il,i)-ph(il,i+1))*evap(il, i+1)
           IF (c6>0.0) THEN
             revap = 0.5*(-b6+sqrt(b6*b6+4.*c6))
@@ -2439,16 +2499,16 @@
             water(il, i) = 0.
           END IF
-          ! print *, 'evap sans ice'
-          evap(il, i) = (wdtrain(il)+sigd(il)*wt(il,i)*(water(il, &
-            i+1)-water(il,i)))/(sigd(il)*(ph(il,i)-ph(il,i+1))*100.)
+! print *, 'evap sans ice'
+          evap(il, i) = (wdtrain(il)+sigd(il)*wt(il,i)*(water(il,i+1)-water(il,i)))/ &
+                        (sigd(il)*(ph(il,i)-ph(il,i+1))*100.)
 
         END IF
       END IF !(i.le.inb(il) .and. lwork(il))
     END DO
-    ! ----------------------------------------------------------------
-
-    ! cc
-    ! ***  calculate precipitating downdraft mass flux under     ***
-    ! ***              hydrostatic approximation                 ***
+! ----------------------------------------------------------------
+
+! cc
+! ***  calculate precipitating downdraft mass flux under     ***
+! ***              hydrostatic approximation                 ***
 
     DO il = 1, ncum
@@ -2459,13 +2519,17 @@
         IF (cvflag_ice) THEN
           IF (cvflag_grav) THEN
-            mp(il, i) = 100.*ginv*(lvcp(il,i)*sigd(il)*tevap(il)*(p(il, &
-              i-1)-p(il,i))/delth+lfcp(il,i)*sigd(il)*faci(il,i)*tevap(il)*(p &
-              (il,i-1)-p(il,i))/delth+lfcp(il,i)*sigd(il)*wt(il,i)/100.* &
-              fondue(il,i)*(p(il,i-1)-p(il,i))/delth/(ph(il,i)-ph(il,i+1)))
+            mp(il, i) = 100.*ginv*(lvcp(il,i)*sigd(il)*tevap(il)* &
+                                               (p(il,i-1)-p(il,i))/delth + &
+                                   lfcp(il,i)*sigd(il)*faci(il,i)*tevap(il)* &
+                                               (p(il,i-1)-p(il,i))/delth + &
+                                   lfcp(il,i)*sigd(il)*wt(il,i)/100.*fondue(il,i)* &
+                                               (p(il,i-1)-p(il,i))/delth/(ph(il,i)-ph(il,i+1)))
           ELSE
-            mp(il, i) = 10.*(lvcp(il,i)*sigd(il)*tevap(il)*(p(il,i-1)-p(il, &
-              i))/delth+lfcp(il,i)*sigd(il)*faci(il,i)*tevap(il)*(p(il, &
-              i-1)-p(il,i))/delth+lfcp(il,i)*sigd(il)*wt(il,i)/100.*fondue(il &
-              ,i)*(p(il,i-1)-p(il,i))/delth/(ph(il,i)-ph(il,i+1)))
+            mp(il, i) = 10.*(lvcp(il,i)*sigd(il)*tevap(il)* &
+                                                (p(il,i-1)-p(il,i))/delth + &
+                             lfcp(il,i)*sigd(il)*faci(il,i)*tevap(il)* &
+                                                (p(il,i-1)-p(il,i))/delth + &
+                             lfcp(il,i)*sigd(il)*wt(il,i)/100.*fondue(il,i)* &
+                                                (p(il,i-1)-p(il,i))/delth/(ph(il,i)-ph(il,i+1)))
 
           END IF
@@ -2473,8 +2537,8 @@
           IF (cvflag_grav) THEN
             mp(il, i) = 100.*ginv*lvcp(il, i)*sigd(il)*tevap(il)* &
-              (p(il,i-1)-p(il,i))/delth
+                                                (p(il,i-1)-p(il,i))/delth
           ELSE
             mp(il, i) = 10.*lvcp(il, i)*sigd(il)*tevap(il)* &
-              (p(il,i-1)-p(il,i))/delth
+                                                (p(il,i-1)-p(il,i))/delth
           END IF
 
@@ -2483,9 +2547,9 @@
       END IF !(i.le.inb(il) .and. lwork(il) .and. i.ne.1)
     END DO
-    ! ----------------------------------------------------------------
-
-    ! ***           if hydrostatic assumption fails,             ***
-    ! ***   solve cubic difference equation for downdraft theta  ***
-    ! ***  and mass flux from two simultaneous differential eqns ***
+! ----------------------------------------------------------------
+
+! ***           if hydrostatic assumption fails,             ***
+! ***   solve cubic difference equation for downdraft theta  ***
+! ***  and mass flux from two simultaneous differential eqns ***
 
     DO il = 1, ncum
@@ -2493,22 +2557,21 @@
 
         amfac = sigd(il)*sigd(il)*70.0*ph(il, i)*(p(il,i-1)-p(il,i))* &
-          (th(il,i)-th(il,i-1))/(tv(il,i)*th(il,i))
+                         (th(il,i)-th(il,i-1))/(tv(il,i)*th(il,i))
         amp2 = abs(mp(il,i+1)*mp(il,i+1)-mp(il,i)*mp(il,i))
 
         IF (amp2>(0.1*amfac)) THEN
           xf = 100.0*sigd(il)*sigd(il)*sigd(il)*(ph(il,i)-ph(il,i+1))
-          tf = b(il, i) - 5.0*(th(il,i)-th(il,i-1))*t(il, i)/(lvcp(il,i)*sigd &
-            (il)*th(il,i))
+          tf = b(il, i) - 5.0*(th(il,i)-th(il,i-1))*t(il, i) / &
+                              (lvcp(il,i)*sigd(il)*th(il,i))
           af = xf*tf + mp(il, i+1)*mp(il, i+1)*tinv
 
           IF (cvflag_ice) THEN
             bf = 2.*(tinv*mp(il,i+1))**3 + tinv*mp(il, i+1)*xf*tf + &
-              50.*(p(il,i-1)-p(il,i))*xf*(tevap(il)*(1.+(lf(il,i)/lv(il,i))* &
-              faci(il,i))+(lf(il,i)/lv(il,i))*wt(il,i)/100.*fondue(il,i)/(ph( &
-              il,i)-ph(il,i+1)))
+                 50.*(p(il,i-1)-p(il,i))*xf*(tevap(il)*(1.+(lf(il,i)/lv(il,i))*faci(il,i)) + &
+                (lf(il,i)/lv(il,i))*wt(il,i)/100.*fondue(il,i)/(ph(il,i)-ph(il,i+1)))
           ELSE
 
             bf = 2.*(tinv*mp(il,i+1))**3 + tinv*mp(il, i+1)*xf*tf + &
-              50.*(p(il,i-1)-p(il,i))*xf*tevap(il)
+                                           50.*(p(il,i-1)-p(il,i))*xf*tevap(il)
           END IF
 
@@ -2522,5 +2585,5 @@
             IF ((0.5*bf-sru)<0.0) fac = -1.0
             mp(il, i) = mp(il, i+1)*tinv + (0.5*bf+sru)**tinv + &
-              fac*(abs(0.5*bf-sru))**tinv
+                                           fac*(abs(0.5*bf-sru))**tinv
           ELSE
             d = atan(2.*sqrt(-ur)/(bf+1.0E-28))
@@ -2532,30 +2595,34 @@
           IF (cvflag_ice) THEN
             IF (cvflag_grav) THEN
-              ! jyg : il y a vraisemblablement une erreur dans la ligne 2
-              ! suivante:
-              ! il faut diviser par (mp(il,i)*sigd(il)*grav) et non par
-              ! (mp(il,i)+sigd(il)*0.1).
-              ! Et il faut bien revoir les facteurs 100.
-              b(il, i-1) = b(il, i) + 100.0*(p(il,i-1)-p(il,i))*(tevap(il)*( &
-                1.+(lf(il,i)/lv(il,i))*faci(il,i))+(lf(il,i)/lv(il, &
-                i))*wt(il,i)/100.*fondue(il,i)/(ph(il,i)-ph(il, &
-                i+1)))/(mp(il,i)+sigd(il)*0.1) - 10.0*(th(il,i)-th(il,i-1))*t &
-                (il, i)/(lvcp(il,i)*sigd(il)*th(il,i))
+!JYG : il y a vraisemblablement une erreur dans la ligne 2 suivante:
+! il faut diviser par (mp(il,i)*sigd(il)*grav) et non par (mp(il,i)+sigd(il)*0.1).
+! Et il faut bien revoir les facteurs 100.
+              b(il, i-1) = b(il, i) + 100.0*(p(il,i-1)-p(il,i))* &
+                           (tevap(il)*(1.+(lf(il,i)/lv(il,i))*faci(il,i)) + &
+                           (lf(il,i)/lv(il,i))*wt(il,i)/100.*fondue(il,i) / &
+                           (ph(il,i)-ph(il,i+1))) / &
+                           (mp(il,i)+sigd(il)*0.1) - &
+                           10.0*(th(il,i)-th(il,i-1))*t(il, i) / &
+                           (lvcp(il,i)*sigd(il)*th(il,i))
             ELSE
-              b(il, i-1) = b(il, i) + 100.0*(p(il,i-1)-p(il,i))*(tevap(il)*( &
-                1.+(lf(il,i)/lv(il,i))*faci(il,i))+(lf(il,i)/lv(il, &
-                i))*wt(il,i)/100.*fondue(il,i)/(ph(il,i)-ph(il, &
-                i+1)))/(mp(il,i)+sigd(il)*0.1) - 10.0*(th(il,i)-th(il,i-1))*t &
-                (il, i)/(lvcp(il,i)*sigd(il)*th(il,i))
+              b(il, i-1) = b(il, i) + 100.0*(p(il,i-1)-p(il,i))*&
+                           (tevap(il)*(1.+(lf(il,i)/lv(il,i))*faci(il,i)) + &
+                           (lf(il,i)/lv(il,i))*wt(il,i)/100.*fondue(il,i) / &
+                           (ph(il,i)-ph(il,i+1))) / &
+                           (mp(il,i)+sigd(il)*0.1) - &
+                           10.0*(th(il,i)-th(il,i-1))*t(il, i) / &
+                           (lvcp(il,i)*sigd(il)*th(il,i))
             END IF
           ELSE
             IF (cvflag_grav) THEN
-              b(il, i-1) = b(il, i) + 100.0*(p(il,i-1)-p(il,i))*tevap(il)/(mp &
-                (il,i)+sigd(il)*0.1) - 10.0*(th(il,i)-th(il,i-1))*t(il, i)/( &
-                lvcp(il,i)*sigd(il)*th(il,i))
+              b(il, i-1) = b(il, i) + 100.0*(p(il,i-1)-p(il,i))*tevap(il) / &
+                           (mp(il,i)+sigd(il)*0.1) - &
+                           10.0*(th(il,i)-th(il,i-1))*t(il, i) / &
+                           (lvcp(il,i)*sigd(il)*th(il,i))
             ELSE
-              b(il, i-1) = b(il, i) + 100.0*(p(il,i-1)-p(il,i))*tevap(il)/(mp &
-                (il,i)+sigd(il)*0.1) - 10.0*(th(il,i)-th(il,i-1))*t(il, i)/( &
-                lvcp(il,i)*sigd(il)*th(il,i))
+              b(il, i-1) = b(il, i) + 100.0*(p(il,i-1)-p(il,i))*tevap(il) / &
+                           (mp(il,i)+sigd(il)*0.1) - &
+                           10.0*(th(il,i)-th(il,i-1))*t(il, i) / &
+                           (lvcp(il,i)*sigd(il)*th(il,i))
             END IF
           END IF
@@ -2564,5 +2631,5 @@
         END IF !(amp2.gt.(0.1*amfac))
 
-        ! ***         limit magnitude of mp(i) to meet cfl condition      ***
+! ***         limit magnitude of mp(i) to meet cfl condition      ***
 
         ampmax = 2.0*(ph(il,i)-ph(il,i+1))*delti
@@ -2571,12 +2638,11 @@
         mp(il, i) = min(mp(il,i), ampmax)
 
-        ! ***      force mp to decrease linearly to zero                 ***
-        ! ***       between cloud base and the surface                   ***
-
-
-        ! c      if(p(il,i).gt.p(il,icb(il)))then
-        ! c
-        ! mp(il,i)=mp(il,icb(il))*(p(il,1)-p(il,i))/(p(il,1)-p(il,icb(il)))
-        ! c      endif
+! ***      force mp to decrease linearly to zero                 ***
+! ***       between cloud base and the surface                   ***
+
+
+! c      if(p(il,i).gt.p(il,icb(il)))then
+! c       mp(il,i)=mp(il,icb(il))*(p(il,1)-p(il,i))/(p(il,1)-p(il,icb(il)))
+! c      endif
         IF (ph(il,i)>0.9*plcl(il)) THEN
           mp(il, i) = mp(il, i)*(ph(il,1)-ph(il,i))/(ph(il,1)-0.9*plcl(il))
@@ -2585,7 +2651,7 @@
       END IF ! (i.le.inb(il) .and. lwork(il) .and. i.ne.1)
     END DO
-    ! ----------------------------------------------------------------
-
-    ! ***       find mixing ratio of precipitating downdraft     ***
+! ----------------------------------------------------------------
+
+! ***       find mixing ratio of precipitating downdraft     ***
 
     DO il = 1, ncum
@@ -2603,18 +2669,14 @@
 
           IF (cvflag_grav) THEN
-            rp(il, i) = rp(il, i+1)*mp(il, i+1) + rr(il, i)*(mp(il,i)-mp(il,i &
-              +1)) + 100.*ginv*0.5*sigd(il)*(ph(il,i)-ph(il,i+1))*(evap(il,i+ &
-              1)+evap(il,i))
+            rp(il, i) = rp(il, i+1)*mp(il, i+1) + rr(il, i)*(mp(il,i)-mp(il,i+1)) + &
+              100.*ginv*0.5*sigd(il)*(ph(il,i)-ph(il,i+1))*(evap(il,i+1)+evap(il,i))
           ELSE
-            rp(il, i) = rp(il, i+1)*mp(il, i+1) + rr(il, i)*(mp(il,i)-mp(il,i &
-              +1)) + 5.*sigd(il)*(ph(il,i)-ph(il,i+1))*(evap(il,i+1)+evap(il, &
-              i))
+            rp(il, i) = rp(il, i+1)*mp(il, i+1) + rr(il, i)*(mp(il,i)-mp(il,i+1)) + &
+              5.*sigd(il)*(ph(il,i)-ph(il,i+1))*(evap(il,i+1)+evap(il,i))
           END IF
           rp(il, i) = rp(il, i)/mp(il, i)
-          up(il, i) = up(il, i+1)*mp(il, i+1) + u(il, i)*(mp(il,i)-mp(il,i+1) &
-            )
+          up(il, i) = up(il, i+1)*mp(il, i+1) + u(il, i)*(mp(il,i)-mp(il,i+1))
           up(il, i) = up(il, i)/mp(il, i)
-          vp(il, i) = vp(il, i+1)*mp(il, i+1) + v(il, i)*(mp(il,i)-mp(il,i+1) &
-            )
+          vp(il, i) = vp(il, i+1)*mp(il, i+1) + v(il, i)*(mp(il,i)-mp(il,i+1))
           vp(il, i) = vp(il, i)/mp(il, i)
 
@@ -2623,9 +2685,9 @@
           IF (mp(il,i+1)>1.0E-16) THEN
             IF (cvflag_grav) THEN
-              rp(il, i) = rp(il, i+1) + 100.*ginv*0.5*sigd(il)*(ph(il,i)-ph( &
-                il,i+1))*(evap(il,i+1)+evap(il,i))/mp(il, i+1)
+              rp(il, i) = rp(il,i+1) + 100.*ginv*0.5*sigd(il)*(ph(il,i)-ph(il,i+1)) * &
+                                       (evap(il,i+1)+evap(il,i))/mp(il,i+1)
             ELSE
-              rp(il, i) = rp(il, i+1) + 5.*sigd(il)*(ph(il,i)-ph(il,i+1))*( &
-                evap(il,i+1)+evap(il,i))/mp(il, i+1)
+              rp(il, i) = rp(il,i+1) + 5.*sigd(il)*(ph(il,i)-ph(il,i+1)) * &
+                                       (evap(il,i+1)+evap(il,i))/mp(il, i+1)
             END IF
             up(il, i) = up(il, i+1)
@@ -2639,32 +2701,32 @@
       END IF ! (i.lt.inb(il) .and. lwork(il))
     END DO
-    ! ----------------------------------------------------------------
-
-    ! ***       find tracer concentrations in precipitating downdraft     ***
-
-    ! AC!      do j=1,ntra
-    ! AC!       do il = 1,ncum
-    ! AC!       if (i.lt.inb(il) .and. lwork(il)) then
-    ! AC!c
-    ! AC!         if(mplus(il))then
-    ! AC!          trap(il,i,j)=trap(il,i+1,j)*mp(il,i+1)
-    ! AC!     :              +trap(il,i,j)*(mp(il,i)-mp(il,i+1))
-    ! AC!          trap(il,i,j)=trap(il,i,j)/mp(il,i)
-    ! AC!         else ! if (mplus(il))
-    ! AC!          if(mp(il,i+1).gt.1.0e-16)then
-    ! AC!           trap(il,i,j)=trap(il,i+1,j)
-    ! AC!          endif
-    ! AC!         endif ! (mplus(il)) else if (.not.mplus(il))
-    ! AC!c
-    ! AC!        endif ! (i.lt.inb(il) .and. lwork(il))
-    ! AC!       enddo
-    ! AC!      end do
+! ----------------------------------------------------------------
+
+! ***       find tracer concentrations in precipitating downdraft     ***
+
+!AC!      do j=1,ntra
+!AC!       do il = 1,ncum
+!AC!       if (i.lt.inb(il) .and. lwork(il)) then
+!AC!c
+!AC!         if(mplus(il))then
+!AC!          trap(il,i,j)=trap(il,i+1,j)*mp(il,i+1)
+!AC!     :              +trap(il,i,j)*(mp(il,i)-mp(il,i+1))
+!AC!          trap(il,i,j)=trap(il,i,j)/mp(il,i)
+!AC!         else ! if (mplus(il))
+!AC!          if(mp(il,i+1).gt.1.0e-16)then
+!AC!           trap(il,i,j)=trap(il,i+1,j)
+!AC!          endif
+!AC!         endif ! (mplus(il)) else if (.not.mplus(il))
+!AC!c
+!AC!        endif ! (i.lt.inb(il) .and. lwork(il))
+!AC!       enddo
+!AC!      end do
 
 400 END DO
-  ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-  ! ***                    end of downdraft loop                    ***
-
-  ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+! ***                    end of downdraft loop                    ***
+
+! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
 
@@ -2672,10 +2734,17 @@
 END SUBROUTINE cv3_unsat
 
-SUBROUTINE cv3_yield(nloc, ncum, nd, na, ntra, icb, inb, delt, t, rr, t_wake, &
-    rr_wake, s_wake, u, v, tra, gz, p, ph, h, hp, lv, lf, cpn, th, th_wake, &
-    ep, clw, m, tp, mp, rp, up, vp, trap, wt, water, ice, evap, fondue, faci, &
-    b, sigd, ment, qent, hent, iflag_mix, uent, vent, nent, elij, traent, &
-    sig, tv, tvp, wghti, iflag, precip, vprecip, ft, fr, fu, fv, ftra, cbmf, &
-    upwd, dnwd, dnwd0, ma, mip, tls, tps, qcondc, wd, ftd, fqd)
+SUBROUTINE cv3_yield(nloc, ncum, nd, na, ntra, ok_conserv_q, &
+                     icb, inb, delt, &
+                     t, rr, t_wake, rr_wake, s_wake, u, v, tra, &
+                     gz, p, ph, h, hp, lv, lf, cpn, th, th_wake, &
+                     ep, clw, m, tp, mp, rp, up, vp, trap, &
+                     wt, water, ice, evap, fondue, faci, b, sigd, &
+                     ment, qent, hent, iflag_mix, uent, vent, &
+                     nent, elij, traent, sig, &
+                     tv, tvp, wghti, &
+                     iflag, precip, Vprecip, ft, fr, fu, fv, ftra, &
+                     cbmf, upwd, dnwd, dnwd0, ma, mip, &
+                     tls, tps, qcondc, wd, &
+                     ftd, fqd)
 
   IMPLICIT NONE
@@ -2686,77 +2755,75 @@
   include "conema3.h"
 
-  ! inputs:
-  ! print*,'cv3_yield apres include'
-  INTEGER iflag_mix
-  INTEGER ncum, nd, na, ntra, nloc
-  INTEGER icb(nloc), inb(nloc)
-  REAL delt
-  REAL t(nloc, nd), rr(nloc, nd), u(nloc, nd), v(nloc, nd)
-  REAL t_wake(nloc, nd), rr_wake(nloc, nd)
-  REAL s_wake(nloc)
-  REAL tra(nloc, nd, ntra), sig(nloc, nd)
-  REAL gz(nloc, na), ph(nloc, nd+1), h(nloc, na), hp(nloc, na)
-  REAL th(nloc, na), p(nloc, nd), tp(nloc, na)
-  REAL lv(nloc, na), cpn(nloc, na), ep(nloc, na), clw(nloc, na)
-  REAL lf(nloc, na)
-  REAL m(nloc, na), mp(nloc, na), rp(nloc, na), up(nloc, na)
-  REAL vp(nloc, na), wt(nloc, nd), trap(nloc, nd, ntra)
-  REAL water(nloc, na), evap(nloc, na), b(nloc, na), sigd(nloc)
-  REAL fondue(nloc, na), faci(nloc, na), ice(nloc, na)
-  REAL ment(nloc, na, na), qent(nloc, na, na), uent(nloc, na, na)
-  REAL hent(nloc, na, na)
-  ! IM bug   real vent(nloc,na,na), nent(nloc,na), elij(nloc,na,na)
-  REAL vent(nloc, na, na), elij(nloc, na, na)
-  INTEGER nent(nloc, nd)
-  REAL traent(nloc, na, na, ntra)
-  REAL tv(nloc, nd), tvp(nloc, nd), wghti(nloc, nd)
-  ! print*,'cv3_yield declarations 1'
-  ! input/output:
-  INTEGER iflag(nloc)
-
-  ! outputs:
-  REAL precip(nloc)
-  REAL ft(nloc, nd), fr(nloc, nd), fu(nloc, nd), fv(nloc, nd)
-  REAL ftd(nloc, nd), fqd(nloc, nd)
-  REAL ftra(nloc, nd, ntra)
-  REAL upwd(nloc, nd), dnwd(nloc, nd), ma(nloc, nd)
-  REAL dnwd0(nloc, nd), mip(nloc, nd)
-  REAL vprecip(nloc, nd+1)
-  REAL tls(nloc, nd), tps(nloc, nd)
-  REAL qcondc(nloc, nd) ! cld
-  REAL wd(nloc) ! gust
-  REAL cbmf(nloc)
-  ! print*,'cv3_yield declarations 2'
-  ! local variables:
-  INTEGER i, k, il, n, j, num1
-  REAL rat, delti
-  REAL ax, bx, cx, dx, ex
-  REAL cpinv, rdcp, dpinv
-  REAL awat(nloc)
-  REAL lvcp(nloc, na), lfcp(nloc, na), mke(nloc, na)
-  REAL am(nloc), work(nloc), ad(nloc), amp1(nloc)
-  ! !!      real up1(nloc), dn1(nloc)
-  REAL up1(nloc, nd, nd), dn1(nloc, nd, nd)
-  REAL asum(nloc), bsum(nloc), csum(nloc), dsum(nloc)
-  REAL esum(nloc), fsum(nloc), gsum(nloc), hsum(nloc)
-  REAL th_wake(nloc, nd)
-  REAL alpha_qpos(nloc), alpha_qpos1(nloc)
-  REAL qcond(nloc, nd), nqcond(nloc, nd), wa(nloc, nd) ! cld
-  REAL siga(nloc, nd), sax(nloc, nd), mac(nloc, nd) ! cld
-
-  ! print*,'cv3_yield declarations 3'
-  ! -------------------------------------------------------------
-
-  ! initialization:
+!inputs:
+      INTEGER iflag_mix
+      INTEGER ncum, nd, na, ntra, nloc
+      LOGICAL ok_conserv_q
+      INTEGER icb(nloc), inb(nloc)
+      REAL delt
+      REAL t(nloc, nd), rr(nloc, nd), u(nloc, nd), v(nloc, nd)
+      REAL t_wake(nloc, nd), rr_wake(nloc, nd)
+      REAL s_wake(nloc)
+      REAL tra(nloc, nd, ntra), sig(nloc, nd)
+      REAL gz(nloc, na), ph(nloc, nd+1), h(nloc, na), hp(nloc, na)
+      REAL th(nloc, na), p(nloc, nd), tp(nloc, na)
+      REAL lv(nloc, na), cpn(nloc, na), ep(nloc, na), clw(nloc, na)
+      REAL lf(nloc, na)
+      REAL m(nloc, na), mp(nloc, na), rp(nloc, na), up(nloc, na)
+      REAL vp(nloc, na), wt(nloc, nd), trap(nloc, nd, ntra)
+      REAL water(nloc, na), evap(nloc, na), b(nloc, na), sigd(nloc)
+      REAL fondue(nloc, na), faci(nloc, na), ice(nloc, na)
+      REAL ment(nloc, na, na), qent(nloc, na, na), uent(nloc, na, na)
+      REAL hent(nloc, na, na)
+!IM bug   real vent(nloc,na,na), nent(nloc,na), elij(nloc,na,na)
+      REAL vent(nloc, na, na), elij(nloc, na, na)
+      INTEGER nent(nloc, nd)
+      REAL traent(nloc, na, na, ntra)
+      REAL tv(nloc, nd), tvp(nloc, nd), wghti(nloc, nd)
+!
+!input/output:
+      INTEGER iflag(nloc)
+!
+!outputs:
+      REAL precip(nloc)
+      REAL ft(nloc, nd), fr(nloc, nd), fu(nloc, nd), fv(nloc, nd)
+      REAL ftd(nloc, nd), fqd(nloc, nd)
+      REAL ftra(nloc, nd, ntra)
+      REAL upwd(nloc, nd), dnwd(nloc, nd), ma(nloc, nd)
+      REAL dnwd0(nloc, nd), mip(nloc, nd)
+      REAL Vprecip(nloc, nd+1)
+      REAL tls(nloc, nd), tps(nloc, nd)
+      REAL qcondc(nloc, nd) ! cld
+      REAL wd(nloc) ! gust
+      REAL cbmf(nloc)
+!
+!local variables:
+      INTEGER i, k, il, n, j, num1
+      REAL rat, delti
+      REAL ax, bx, cx, dx, ex
+      REAL cpinv, rdcp, dpinv
+      REAL awat(nloc)
+      REAL lvcp(nloc, na), lfcp(nloc, na), mke(nloc, na)
+      REAL am(nloc), work(nloc), ad(nloc), amp1(nloc)
+!!      real up1(nloc), dn1(nloc)
+      REAL up1(nloc, nd, nd), dn1(nloc, nd, nd)
+      REAL asum(nloc), bsum(nloc), csum(nloc), dsum(nloc)
+      REAL esum(nloc), fsum(nloc), gsum(nloc), hsum(nloc)
+      REAL th_wake(nloc, nd)
+      REAL alpha_qpos(nloc), alpha_qpos1(nloc)
+      REAL qcond(nloc, nd), nqcond(nloc, nd), wa(nloc, nd) ! cld
+      REAL siga(nloc, nd), sax(nloc, nd), mac(nloc, nd) ! cld
+
+      REAL sumdq !jyg
+! 
+! -------------------------------------------------------------
+
+! initialization:
 
   delti = 1.0/delt
-  ! print*,'cv3_yield initialisation delt', delt
-  ! precip,Vprecip,ft,fr,fu,fv,ftra
-  ! :                    ,cbmf,upwd,dnwd,dnwd0,ma,mip
-  ! :                    ,tls,tps,qcondc,wd
-  ! :                    ,ftd,fqd  )
+! print*,'cv3_yield initialisation delt', delt
+!
   DO il = 1, ncum
     precip(il) = 0.0
-    vprecip(il, nd+1) = 0.0
+    Vprecip(il, nd+1) = 0.0
     wd(il) = 0.0 ! gust
   END DO
@@ -2764,5 +2831,5 @@
   DO i = 1, nd
     DO il = 1, ncum
-      vprecip(il, i) = 0.0
+      Vprecip(il, i) = 0.0
       ft(il, i) = 0.0
       fr(il, i) = 0.0
@@ -2780,13 +2847,13 @@
     END DO
   END DO
-  ! print*,'cv3_yield initialisation 2'
-  ! AC!      do j=1,ntra
-  ! AC!       do i=1,nd
-  ! AC!        do il=1,ncum
-  ! AC!          ftra(il,i,j)=0.0
-  ! AC!        enddo
-  ! AC!       enddo
-  ! AC!      enddo
-  ! print*,'cv3_yield initialisation 3'
+! print*,'cv3_yield initialisation 2'
+!AC!      do j=1,ntra
+!AC!       do i=1,nd
+!AC!        do il=1,ncum
+!AC!          ftra(il,i,j)=0.0
+!AC!        enddo
+!AC!       enddo
+!AC!      enddo
+! print*,'cv3_yield initialisation 3'
   DO i = 1, nl
     DO il = 1, ncum
@@ -2798,29 +2865,21 @@
 
 
-  ! ***  calculate surface precipitation in mm/day     ***
+! ***  calculate surface precipitation in mm/day     ***
 
   DO il = 1, ncum
     IF (ep(il,inb(il))>=0.0001 .AND. iflag(il)<=1) THEN
       IF (cvflag_ice) THEN
-        IF (cvflag_grav) THEN
-          precip(il) = wt(il, 1)*sigd(il)*(water(il,1)+ice(il,1))*86400.* &
-            1000./(rowl*grav)
-        ELSE
-          precip(il) = wt(il, 1)*sigd(il)*(water(il,1)+ice(il,1))*8640.
-        END IF
+        precip(il) = wt(il, 1)*sigd(il)*(water(il,1)+ice(il,1)) &
+                              *86400.*1000./(rowl*grav)
       ELSE
-        IF (cvflag_grav) THEN
-          precip(il) = wt(il, 1)*sigd(il)*water(il, 1)*86400.*1000./ &
-            (rowl*grav)
-        ELSE
-          precip(il) = wt(il, 1)*sigd(il)*water(il, 1)*8640.
-        END IF
+        precip(il) = wt(il, 1)*sigd(il)*water(il, 1) &
+                              *86400.*1000./(rowl*grav)
       END IF
     END IF
   END DO
-  ! print*,'cv3_yield apres calcul precip'
-
-
-  ! ===  calculate vertical profile of  precipitation in kg/m2/s  ===
+! print*,'cv3_yield apres calcul precip'
+
+
+! ===  calculate vertical profile of  precipitation in kg/m2/s  ===
 
   DO i = 1, nl
@@ -2828,15 +2887,7 @@
       IF (ep(il,inb(il))>=0.0001 .AND. i<=inb(il) .AND. iflag(il)<=1) THEN
         IF (cvflag_ice) THEN
-          IF (cvflag_grav) THEN
-            vprecip(il, i) = wt(il, i)*sigd(il)*(water(il,i)+ice(il,i))/grav
-          ELSE
-            vprecip(il, i) = wt(il, i)*sigd(il)*(water(il,i)+ice(il,i))/10.
-          END IF
+          Vprecip(il, i) = wt(il, i)*sigd(il)*(water(il,i)+ice(il,i))/grav
         ELSE
-          IF (cvflag_grav) THEN
-            vprecip(il, i) = wt(il, i)*sigd(il)*water(il, i)/grav
-          ELSE
-            vprecip(il, i) = wt(il, i)*sigd(il)*water(il, i)/10.
-          END IF
+          Vprecip(il, i) = wt(il, i)*sigd(il)*water(il, i)/grav
         END IF
       END IF
@@ -2845,15 +2896,15 @@
 
 
-  ! ***  Calculate downdraft velocity scale    ***
-  ! ***  NE PAS UTILISER POUR L'INSTANT ***
-
-  ! !      do il=1,ncum
-  ! !        wd(il)=betad*abs(mp(il,icb(il)))*0.01*rrd*t(il,icb(il))
-  ! !     :                                  /(sigd(il)*p(il,icb(il)))
-  ! !      enddo
-
-
-  ! ***  calculate tendencies of lowest level potential temperature  ***
-  ! ***                      and mixing ratio                        ***
+! ***  Calculate downdraft velocity scale    ***
+! ***  NE PAS UTILISER POUR L'INSTANT ***
+
+!!      do il=1,ncum
+!!        wd(il)=betad*abs(mp(il,icb(il)))*0.01*rrd*t(il,icb(il)) &
+!!                                       /(sigd(il)*p(il,icb(il)))
+!!      enddo
+
+
+! ***  calculate tendencies of lowest level potential temperature  ***
+! ***                      and mixing ratio                        ***
 
   DO il = 1, ncum
@@ -2870,6 +2921,6 @@
   END DO
 
-  ! print*,'cv3_yield avant ft'
-  ! AM is the part of cbmf taken from the first level
+!    print*,'cv3_yield avant ft'
+! am is the part of cbmf taken from the first level
   DO il = 1, ncum
     am(il) = cbmf(il)*wghti(il, 1)
@@ -2878,46 +2929,33 @@
   DO il = 1, ncum
     IF (iflag(il)<=1) THEN
-      ! convect3      if((0.1*dpinv*am).ge.delti)iflag(il)=4
-      ! jyg  Correction pour conserver l'eau
-      ! cc       ft(il,1)=-0.5*lvcp(il,1)*sigd(il)*(evap(il,1)+evap(il,2))
-      ! !precip
+! convect3      if((0.1*dpinv*am).ge.delti)iflag(il)=4
+!JYG  Correction pour conserver l'eau
+! cc       ft(il,1)=-0.5*lvcp(il,1)*sigd(il)*(evap(il,1)+evap(il,2))          !precip
       IF (cvflag_ice) THEN
         ft(il, 1) = -lvcp(il, 1)*sigd(il)*evap(il, 1) - &
-          lfcp(il, 1)*sigd(il)*evap(il, 1)*faci(il, 1) - &
-          lfcp(il, 1)*sigd(il)*(fondue(il,1)*wt(il,1))/(100.*(ph(il,1)-ph(il, &
-          2))) !precip
+                     lfcp(il, 1)*sigd(il)*evap(il, 1)*faci(il, 1) - &
+                     lfcp(il, 1)*sigd(il)*(fondue(il,1)*wt(il,1)) / &
+                       (100.*(ph(il,1)-ph(il,2)))                             !precip
       ELSE
         ft(il, 1) = -lvcp(il, 1)*sigd(il)*evap(il, 1)
       END IF
 
-      IF (cvflag_grav) THEN
-        ft(il, 1) = ft(il, 1) - 0.009*grav*sigd(il)*mp(il, 2)*t_wake(il, 1)*b &
-          (il, 1)*work(il)
+      ft(il, 1) = ft(il, 1) - 0.009*grav*sigd(il)*mp(il, 2)*t_wake(il, 1)*b(il, 1)*work(il)
+
+      IF (cvflag_ice) THEN
+        ft(il, 1) = ft(il, 1) + 0.01*sigd(il)*wt(il, 1)*(cl-cpd)*water(il, 2) * &
+                                     (t_wake(il,2)-t_wake(il,1))*work(il)/cpn(il, 1) + &
+                                0.01*sigd(il)*wt(il, 1)*(ci-cpd)*ice(il, 2) * &
+                                     (t_wake(il,2)-t_wake(il,1))*work(il)/cpn(il, 1)
       ELSE
-        ft(il, 1) = ft(il, 1) - 0.09*sigd(il)*mp(il, 2)*t_wake(il, 1)*b(il, 1 &
-          )*work(il)
+        ft(il, 1) = ft(il, 1) + 0.01*sigd(il)*wt(il, 1)*(cl-cpd)*water(il, 2) * &
+                                     (t_wake(il,2)-t_wake(il,1))*work(il)/cpn(il, 1)
       END IF
 
-      IF (cvflag_ice) THEN
-        ft(il, 1) = ft(il, 1) + 0.01*sigd(il)*wt(il, 1)*(cl-cpd)*water(il, 2) &
-          *(t_wake(il,2)-t_wake(il,1))*work(il)/cpn(il, 1) + &
-          0.01*sigd(il)*wt(il, 1)*(ci-cpd)*ice(il, 2)* &
-          (t_wake(il,2)-t_wake(il,1))*work(il)/cpn(il, 1)
-      ELSE
-        ft(il, 1) = ft(il, 1) + 0.01*sigd(il)*wt(il, 1)*(cl-cpd)*water(il, 2) &
-          *(t_wake(il,2)-t_wake(il,1))*work(il)/cpn(il, 1)
-      END IF
-
-      ftd(il, 1) = ft(il, 1) ! fin precip
-
-      IF (cvflag_grav) THEN !sature
-        IF ((0.01*grav*work(il)*am(il))>=delti) iflag(il) = 1 !consist vect
-        ft(il, 1) = ft(il, 1) + 0.01*grav*work(il)*am(il)*(t(il,2)-t(il,1)+( &
-          gz(il,2)-gz(il,1))/cpn(il,1))
-      ELSE
-        IF ((0.1*work(il)*am(il))>=delti) iflag(il) = 1 !consistency vect
-        ft(il, 1) = ft(il, 1) + 0.1*work(il)*am(il)*(t(il,2)-t(il,1)+(gz(il, &
-          2)-gz(il,1))/cpn(il,1))
-      END IF
+      ftd(il, 1) = ft(il, 1)                                                  ! fin precip
+
+      IF ((0.01*grav*work(il)*am(il))>=delti) iflag(il) = 1 !consist vect
+      ft(il, 1) = ft(il, 1) + 0.01*grav*work(il)*am(il) * &
+                                   (t(il,2)-t(il,1)+(gz(il,2)-gz(il,1))/cpn(il,1))
     END IF ! iflag
   END DO
@@ -2927,117 +2965,86 @@
     IF (iflag_mix>0) THEN
       DO il = 1, ncum
-        ! FH WARNING a modifier :
+! FH WARNING a modifier :
         cpinv = 0.
-        ! cpinv=1.0/cpn(il,1)
+! cpinv=1.0/cpn(il,1)
         IF (j<=inb(il) .AND. iflag(il)<=1) THEN
-          IF (cvflag_grav) THEN
-            ft(il, 1) = ft(il, 1) + 0.01*grav*work(il)*ment(il, j, 1)*(hent( &
-              il,j,1)-h(il,1)+t(il,1)*(cpv-cpd)*(rr(il,1)-qent(il,j, &
-              1)))*cpinv
-          ELSE
-            ft(il, 1) = ft(il, 1) + 0.1*work(il)*ment(il, j, 1)*(hent(il,j,1) &
-              -h(il,1)+t(il,1)*(cpv-cpd)*(rr(il,1)-qent(il,j,1)))*cpinv
-          END IF ! cvflag_grav
+          ft(il, 1) = ft(il, 1) + 0.01*grav*work(il)*ment(il, j, 1) * &
+                     (hent(il,j,1)-h(il,1)+t(il,1)*(cpv-cpd)*(rr(il,1)-qent(il,j,1)))*cpinv
         END IF ! j
       END DO
     END IF
   END DO
-    ! fin sature
+! fin sature
 
 
   DO il = 1, ncum
     IF (iflag(il)<=1) THEN
-      IF (cvflag_grav) THEN
-        ! jyg1  Correction pour mieux conserver l'eau (conformite avec
-        ! CONVECT4.3)
-        fr(il, 1) = 0.01*grav*mp(il, 2)*(rp(il,2)-rr_wake(il,1))*work(il) + &
-          sigd(il)*evap(il, 1)
-        ! cc     :          +sigd(il)*0.5*(evap(il,1)+evap(il,2))
-
-        fqd(il, 1) = fr(il, 1) !precip
-
-        fr(il, 1) = fr(il, 1) + 0.01*grav*am(il)*(rr(il,2)-rr(il,1))*work(il) !sature
-
-        fu(il, 1) = fu(il, 1) + 0.01*grav*work(il)*(mp(il,2)*(up(il,2)-u(il, &
-          1))+am(il)*(u(il,2)-u(il,1)))
-        fv(il, 1) = fv(il, 1) + 0.01*grav*work(il)*(mp(il,2)*(vp(il,2)-v(il, &
-          1))+am(il)*(v(il,2)-v(il,1)))
-      ELSE ! cvflag_grav
-        fr(il, 1) = 0.1*mp(il, 2)*(rp(il,2)-rr_wake(il,1))*work(il) + &
-          sigd(il)*evap(il, 1)
-        ! cc     :          +sigd(il)*0.5*(evap(il,1)+evap(il,2))
-        fqd(il, 1) = fr(il, 1) !precip
-        fr(il, 1) = fr(il, 1) + 0.1*am(il)*(rr(il,2)-rr(il,1))*work(il)
-        fu(il, 1) = fu(il, 1) + 0.1*work(il)*(mp(il,2)*(up(il,2)-u(il, &
-          1))+am(il)*(u(il,2)-u(il,1)))
-        fv(il, 1) = fv(il, 1) + 0.1*work(il)*(mp(il,2)*(vp(il,2)-v(il, &
-          1))+am(il)*(v(il,2)-v(il,1)))
-      END IF ! cvflag_grav
+!JYG1  Correction pour mieux conserver l'eau (conformite avec CONVECT4.3)
+      fr(il, 1) = 0.01*grav*mp(il, 2)*(rp(il,2)-rr_wake(il,1))*work(il) + &
+                  sigd(il)*evap(il, 1)
+!!!                  sigd(il)*0.5*(evap(il,1)+evap(il,2))
+
+      fqd(il, 1) = fr(il, 1) !precip
+
+      fr(il, 1) = fr(il, 1) + 0.01*grav*am(il)*(rr(il,2)-rr(il,1))*work(il)        !sature
+
+      fu(il, 1) = fu(il, 1) + 0.01*grav*work(il)*(mp(il,2)*(up(il,2)-u(il,1)) + &
+                                                  am(il)*(u(il,2)-u(il,1)))
+      fv(il, 1) = fv(il, 1) + 0.01*grav*work(il)*(mp(il,2)*(vp(il,2)-v(il,1)) + &
+                                                  am(il)*(v(il,2)-v(il,1)))
     END IF ! iflag
   END DO ! il
 
 
-  ! AC!     do j=1,ntra
-  ! AC!      do il=1,ncum
-  ! AC!       if (iflag(il) .le. 1) then
-  ! AC!       if (cvflag_grav) then
-  ! AC!        ftra(il,1,j)=ftra(il,1,j)+0.01*grav*work(il)
-  ! AC!    :                     *(mp(il,2)*(trap(il,2,j)-tra(il,1,j))
-  ! AC!    :             +am(il)*(tra(il,2,j)-tra(il,1,j)))
-  ! AC!       else
-  ! AC!        ftra(il,1,j)=ftra(il,1,j)+0.1*work(il)
-  ! AC!    :                     *(mp(il,2)*(trap(il,2,j)-tra(il,1,j))
-  ! AC!    :             +am(il)*(tra(il,2,j)-tra(il,1,j)))
-  ! AC!       endif
-  ! AC!       endif  ! iflag
-  ! AC!      enddo
-  ! AC!     enddo
+!AC!     do j=1,ntra
+!AC!      do il=1,ncum
+!AC!       if (iflag(il) .le. 1) then
+!AC!       if (cvflag_grav) then
+!AC!        ftra(il,1,j)=ftra(il,1,j)+0.01*grav*work(il)
+!AC!    :                     *(mp(il,2)*(trap(il,2,j)-tra(il,1,j))
+!AC!    :             +am(il)*(tra(il,2,j)-tra(il,1,j)))
+!AC!       else
+!AC!        ftra(il,1,j)=ftra(il,1,j)+0.1*work(il)
+!AC!    :                     *(mp(il,2)*(trap(il,2,j)-tra(il,1,j))
+!AC!    :             +am(il)*(tra(il,2,j)-tra(il,1,j)))
+!AC!       endif
+!AC!       endif  ! iflag
+!AC!      enddo
+!AC!     enddo
 
   DO j = 2, nl
     DO il = 1, ncum
       IF (j<=inb(il) .AND. iflag(il)<=1) THEN
-        IF (cvflag_grav) THEN
-          fr(il, 1) = fr(il, 1) + 0.01*grav*work(il)*ment(il, j, 1)*(qent(il, &
-            j,1)-rr(il,1))
-          fu(il, 1) = fu(il, 1) + 0.01*grav*work(il)*ment(il, j, 1)*(uent(il, &
-            j,1)-u(il,1))
-          fv(il, 1) = fv(il, 1) + 0.01*grav*work(il)*ment(il, j, 1)*(vent(il, &
-            j,1)-v(il,1))
-        ELSE ! cvflag_grav
-          fr(il, 1) = fr(il, 1) + 0.1*work(il)*ment(il, j, 1)*(qent(il,j,1)- &
-            rr(il,1))
-          fu(il, 1) = fu(il, 1) + 0.1*work(il)*ment(il, j, 1)*(uent(il,j,1)-u &
-            (il,1))
-          fv(il, 1) = fv(il, 1) + 0.1*work(il)*ment(il, j, 1)*(vent(il,j,1)-v &
-            (il,1)) ! fin sature
-        END IF ! cvflag_grav
+        fr(il, 1) = fr(il, 1) + 0.01*grav*work(il)*ment(il, j, 1)*(qent(il,j,1)-rr(il,1))
+        fu(il, 1) = fu(il, 1) + 0.01*grav*work(il)*ment(il, j, 1)*(uent(il,j,1)-u(il,1))
+        fv(il, 1) = fv(il, 1) + 0.01*grav*work(il)*ment(il, j, 1)*(vent(il,j,1)-v(il,1))
       END IF ! j
     END DO
   END DO
 
-  ! AC!      do k=1,ntra
-  ! AC!       do j=2,nl
-  ! AC!        do il=1,ncum
-  ! AC!         if (j.le.inb(il) .and. iflag(il) .le. 1) then
-  ! AC!
-  ! AC!          if (cvflag_grav) then
-  ! AC!           ftra(il,1,k)=ftra(il,1,k)+0.01*grav*work(il)*ment(il,j,1)
-  ! AC!     :                *(traent(il,j,1,k)-tra(il,1,k))
-  ! AC!          else
-  ! AC!           ftra(il,1,k)=ftra(il,1,k)+0.1*work(il)*ment(il,j,1)
-  ! AC!     :                *(traent(il,j,1,k)-tra(il,1,k))
-  ! AC!          endif
-  ! AC!
-  ! AC!         endif
-  ! AC!        enddo
-  ! AC!       enddo
-  ! AC!      enddo
-  ! print*,'cv3_yield apres ft'
-
-  ! ***  calculate tendencies of potential temperature and mixing ratio  ***
-  ! ***               at levels above the lowest level                   ***
-
-  ! ***  first find the net saturated updraft and downdraft mass fluxes  ***
-  ! ***                      through each level                          ***
+!AC!      do k=1,ntra
+!AC!       do j=2,nl
+!AC!        do il=1,ncum
+!AC!         if (j.le.inb(il) .and. iflag(il) .le. 1) then
+!AC!
+!AC!          if (cvflag_grav) then
+!AC!           ftra(il,1,k)=ftra(il,1,k)+0.01*grav*work(il)*ment(il,j,1)
+!AC!     :                *(traent(il,j,1,k)-tra(il,1,k))
+!AC!          else
+!AC!           ftra(il,1,k)=ftra(il,1,k)+0.1*work(il)*ment(il,j,1)
+!AC!     :                *(traent(il,j,1,k)-tra(il,1,k))
+!AC!          endif
+!AC!
+!AC!         endif
+!AC!        enddo
+!AC!       enddo
+!AC!      enddo
+! print*,'cv3_yield apres ft'
+
+! ***  calculate tendencies of potential temperature and mixing ratio  ***
+! ***               at levels above the lowest level                   ***
+
+! ***  first find the net saturated updraft and downdraft mass fluxes  ***
+! ***                      through each level                          ***
 
 
@@ -3060,5 +3067,5 @@
           END IF
         ELSE
-          ! AMP1 is the part of cbmf taken from layers I and lower
+! AMP1 is the part of cbmf taken from layers I and lower
           IF (k<=i) THEN
             amp1(il) = amp1(il) + cbmf(il)*wghti(il, k)
@@ -3093,19 +3100,13 @@
         cpinv = 1.0/cpn(il, i)
 
-        ! convect3      if((0.1*dpinv*amp1).ge.delti)iflag(il)=4
-        IF (cvflag_grav) THEN
-          IF ((0.01*grav*dpinv*amp1(il))>=delti) iflag(il) = 1 ! vecto
-        ELSE
-          IF ((0.1*dpinv*amp1(il))>=delti) iflag(il) = 1 ! vecto
-        END IF
-
-          ! precip
-        ! cc       ft(il,i)=
-        ! -0.5*sigd(il)*lvcp(il,i)*(evap(il,i)+evap(il,i+1))
+! convect3      if((0.1*dpinv*amp1).ge.delti)iflag(il)=4
+        IF ((0.01*grav*dpinv*amp1(il))>=delti) iflag(il) = 1 ! vecto
+
+! precip
+! cc       ft(il,i)= -0.5*sigd(il)*lvcp(il,i)*(evap(il,i)+evap(il,i+1))
         IF (cvflag_ice) THEN
           ft(il, i) = -sigd(il)*lvcp(il, i)*evap(il, i) - &
-            sigd(il)*lfcp(il, i)*evap(il, i)*faci(il, i) - &
-            sigd(il)*lfcp(il, i)*fondue(il, i)*wt(il, i)/(100.*(p(il, &
-            i-1)-p(il,i)))
+                       sigd(il)*lfcp(il, i)*evap(il, i)*faci(il, i) - &
+                       sigd(il)*lfcp(il, i)*fondue(il, i)*wt(il, i)/(100.*(p(il,i-1)-p(il,i)))
         ELSE
           ft(il, i) = -sigd(il)*lvcp(il, i)*evap(il, i)
@@ -3114,123 +3115,74 @@
         rat = cpn(il, i-1)*cpinv
 
-        IF (cvflag_grav) THEN
-          ft(il, i) = ft(il, i) - 0.009*grav*sigd(il)*(mp(il,i+1)*t_wake(il,i &
-            )*b(il,i)-mp(il,i)*t_wake(il,i-1)*rat*b(il,i-1))*dpinv
-          IF (cvflag_ice) THEN
-            ft(il, i) = ft(il, i) + 0.01*sigd(il)*wt(il, i)*(cl-cpd)*water(il &
-              , i+1)*(t_wake(il,i+1)-t_wake(il,i))*dpinv*cpinv + &
-              0.01*sigd(il)*wt(il, i)*(ci-cpd)*ice(il, i+1)* &
-              (t_wake(il,i+1)-t_wake(il,i))*dpinv*cpinv
-          ELSE
-            ft(il, i) = ft(il, i) + 0.01*sigd(il)*wt(il, i)*(cl-cpd)*water(il &
-              , i+1)*(t_wake(il,i+1)-t_wake(il,i))*dpinv*cpinv
-          END IF
-
-          ftd(il, i) = ft(il, i)
-            ! fin precip
-
-            ! sature
-          ft(il, i) = ft(il, i) + 0.01*grav*dpinv*(amp1(il)*(t(il,i+1)-t(il, &
-            i)+(gz(il,i+1)-gz(il,i))*cpinv)-ad(il)*(t(il,i)-t(il, &
-            i-1)+(gz(il,i)-gz(il,i-1))*cpinv))
-
-
-          IF (iflag_mix==0) THEN
-            ft(il, i) = ft(il, i) + 0.01*grav*dpinv*ment(il, i, i)*(hp(il,i)- &
-              h(il,i)+t(il,i)*(cpv-cpd)*(rr(il,i)-qent(il,i,i)))*cpinv
-          END IF
-
-        ELSE ! cvflag_grav
-          ft(il, i) = ft(il, i) - 0.09*sigd(il)*(mp(il,i+1)*t_wake(il,i)*b(il &
-            ,i)-mp(il,i)*t_wake(il,i-1)*rat*b(il,i-1))*dpinv
-
-          IF (cvflag_ice) THEN
-            ft(il, i) = ft(il, i) + 0.01*sigd(il)*wt(il, i)*(cl-cpd)*water(il &
-              , i+1)*(t_wake(il,i+1)-t_wake(il,i))*dpinv*cpinv + &
-              0.01*sigd(il)*wt(il, i)*(ci-cpd)*ice(il, i+1)* &
-              (t_wake(il,i+1)-t_wake(il,i))*dpinv*cpinv
-          ELSE
-            ft(il, i) = ft(il, i) + 0.01*sigd(il)*wt(il, i)*(cl-cpd)*water(il &
-              , i+1)*(t_wake(il,i+1)-t_wake(il,i))*dpinv*cpinv
-          END IF
-
-          ftd(il, i) = ft(il, i)
-            ! fin precip
-
-            ! sature
-          ft(il, i) = ft(il, i) + 0.1*dpinv*(amp1(il)*(t(il,i+1)-t(il, &
-            i)+(gz(il,i+1)-gz(il,i))*cpinv)-ad(il)*(t(il,i)-t(il, &
-            i-1)+(gz(il,i)-gz(il,i-1))*cpinv))
-
-
-          IF (iflag_mix==0) THEN
-            ft(il, i) = ft(il, i) + 0.1*dpinv*ment(il, i, i)*(hp(il,i)-h(il,i &
-              )+t(il,i)*(cpv-cpd)*(rr(il,i)-qent(il,i,i)))*cpinv
-          END IF
-        END IF ! cvflag_grav
-
-
-        IF (cvflag_grav) THEN
-          ! sb: on ne fait pas encore la correction permettant de mieux
-          ! conserver l'eau:
-          ! jyg: correction permettant de mieux conserver l'eau:
-          ! cc         fr(il,i)=0.5*sigd(il)*(evap(il,i)+evap(il,i+1))
-          fr(il, i) = sigd(il)*evap(il, i) + 0.01*grav*(mp(il,i+1)*(rp(il, &
-            i+1)-rr_wake(il,i))-mp(il,i)*(rp(il,i)-rr_wake(il,i-1)))*dpinv
-          fqd(il, i) = fr(il, i) ! precip
-
-          fu(il, i) = 0.01*grav*(mp(il,i+1)*(up(il,i+1)-u(il, &
-            i))-mp(il,i)*(up(il,i)-u(il,i-1)))*dpinv
-          fv(il, i) = 0.01*grav*(mp(il,i+1)*(vp(il,i+1)-v(il, &
-            i))-mp(il,i)*(vp(il,i)-v(il,i-1)))*dpinv
-        ELSE ! cvflag_grav
-          ! cc         fr(il,i)=0.5*sigd(il)*(evap(il,i)+evap(il,i+1))
-          fr(il, i) = sigd(il)*evap(il, i) + 0.1*(mp(il,i+1)*(rp(il, &
-            i+1)-rr_wake(il,i))-mp(il,i)*(rp(il,i)-rr_wake(il,i-1)))*dpinv
-          fqd(il, i) = fr(il, i) ! precip
-
-          fu(il, i) = 0.1*(mp(il,i+1)*(up(il,i+1)-u(il,i))-mp(il,i)*(up(il, &
-            i)-u(il,i-1)))*dpinv
-          fv(il, i) = 0.1*(mp(il,i+1)*(vp(il,i+1)-v(il,i))-mp(il,i)*(vp(il, &
-            i)-v(il,i-1)))*dpinv
-        END IF ! cvflag_grav
-
-
-        IF (cvflag_grav) THEN
-          fr(il, i) = fr(il, i) + 0.01*grav*dpinv*(amp1(il)*(rr(il, &
-            i+1)-rr(il,i))-ad(il)*(rr(il,i)-rr(il,i-1)))
-          fu(il, i) = fu(il, i) + 0.01*grav*dpinv*(amp1(il)*(u(il,i+1)-u(il, &
-            i))-ad(il)*(u(il,i)-u(il,i-1)))
-          fv(il, i) = fv(il, i) + 0.01*grav*dpinv*(amp1(il)*(v(il,i+1)-v(il, &
-            i))-ad(il)*(v(il,i)-v(il,i-1)))
-        ELSE ! cvflag_grav
-          fr(il, i) = fr(il, i) + 0.1*dpinv*(amp1(il)*(rr(il,i+1)-rr(il, &
-            i))-ad(il)*(rr(il,i)-rr(il,i-1)))
-          fu(il, i) = fu(il, i) + 0.1*dpinv*(amp1(il)*(u(il,i+1)-u(il, &
-            i))-ad(il)*(u(il,i)-u(il,i-1)))
-          fv(il, i) = fv(il, i) + 0.1*dpinv*(amp1(il)*(v(il,i+1)-v(il, &
-            i))-ad(il)*(v(il,i)-v(il,i-1)))
-        END IF ! cvflag_grav
+        ft(il, i) = ft(il, i) - 0.009*grav*sigd(il) * &
+                     (mp(il,i+1)*t_wake(il,i)*b(il,i)-mp(il,i)*t_wake(il,i-1)*rat*b(il,i-1))*dpinv
+        IF (cvflag_ice) THEN
+          ft(il, i) = ft(il, i) + 0.01*sigd(il)*wt(il, i)*(cl-cpd)*water(il, i+1) * &
+                                       (t_wake(il,i+1)-t_wake(il,i))*dpinv*cpinv + &
+                                  0.01*sigd(il)*wt(il, i)*(ci-cpd)*ice(il, i+1) * &
+                                       (t_wake(il,i+1)-t_wake(il,i))*dpinv*cpinv
+        ELSE
+          ft(il, i) = ft(il, i) + 0.01*sigd(il)*wt(il, i)*(cl-cpd)*water(il, i+1) * &
+                                       (t_wake(il,i+1)-t_wake(il,i))*dpinv* &
+            cpinv
+        END IF
+
+        ftd(il, i) = ft(il, i)
+! fin precip
+
+! sature
+        ft(il, i) = ft(il, i) + 0.01*grav*dpinv * &
+                     (amp1(il)*(t(il,i+1)-t(il,i) + (gz(il,i+1)-gz(il,i))*cpinv) - &
+                      ad(il)*(t(il,i)-t(il,i-1)+(gz(il,i)-gz(il,i-1))*cpinv))
+
+
+        IF (iflag_mix==0) THEN
+          ft(il, i) = ft(il, i) + 0.01*grav*dpinv*ment(il, i, i)*(hp(il,i)-h(il,i) + &
+                                    t(il,i)*(cpv-cpd)*(rr(il,i)-qent(il,i,i)))*cpinv
+        END IF
+
+
+
+! sb: on ne fait pas encore la correction permettant de mieux
+! conserver l'eau:
+!JYG: correction permettant de mieux conserver l'eau:
+! cc         fr(il,i)=0.5*sigd(il)*(evap(il,i)+evap(il,i+1))
+        fr(il, i) = sigd(il)*evap(il, i) + 0.01*grav*(mp(il,i+1)*(rp(il,i+1)-rr_wake(il,i)) - &
+                                                      mp(il,i)*(rp(il,i)-rr_wake(il,i-1)))*dpinv
+        fqd(il, i) = fr(il, i)                                                                     ! precip
+
+        fu(il, i) = 0.01*grav*(mp(il,i+1)*(up(il,i+1)-u(il,i)) - &
+                               mp(il,i)*(up(il,i)-u(il,i-1)))*dpinv
+        fv(il, i) = 0.01*grav*(mp(il,i+1)*(vp(il,i+1)-v(il,i)) - &
+                               mp(il,i)*(vp(il,i)-v(il,i-1)))*dpinv
+
+
+        fr(il, i) = fr(il, i) + 0.01*grav*dpinv*(amp1(il)*(rr(il,i+1)-rr(il,i)) - &
+                                                 ad(il)*(rr(il,i)-rr(il,i-1)))
+        fu(il, i) = fu(il, i) + 0.01*grav*dpinv*(amp1(il)*(u(il,i+1)-u(il,i)) - &
+                                                 ad(il)*(u(il,i)-u(il,i-1)))
+        fv(il, i) = fv(il, i) + 0.01*grav*dpinv*(amp1(il)*(v(il,i+1)-v(il,i)) - &
+                                                 ad(il)*(v(il,i)-v(il,i-1)))
 
       END IF ! i
     END DO
 
-    ! AC!      do k=1,ntra
-    ! AC!       do il=1,ncum
-    ! AC!        if (i.le.inb(il) .and. iflag(il) .le. 1) then
-    ! AC!         dpinv=1.0/(ph(il,i)-ph(il,i+1))
-    ! AC!         cpinv=1.0/cpn(il,i)
-    ! AC!         if (cvflag_grav) then
-    ! AC!           ftra(il,i,k)=ftra(il,i,k)+0.01*grav*dpinv
-    ! AC!     :         *(amp1(il)*(tra(il,i+1,k)-tra(il,i,k))
-    ! AC!     :           -ad(il)*(tra(il,i,k)-tra(il,i-1,k)))
-    ! AC!         else
-    ! AC!           ftra(il,i,k)=ftra(il,i,k)+0.1*dpinv
-    ! AC!     :         *(amp1(il)*(tra(il,i+1,k)-tra(il,i,k))
-    ! AC!     :           -ad(il)*(tra(il,i,k)-tra(il,i-1,k)))
-    ! AC!         endif
-    ! AC!        endif
-    ! AC!       enddo
-    ! AC!      enddo
+!AC!      do k=1,ntra
+!AC!       do il=1,ncum
+!AC!        if (i.le.inb(il) .and. iflag(il) .le. 1) then
+!AC!         dpinv=1.0/(ph(il,i)-ph(il,i+1))
+!AC!         cpinv=1.0/cpn(il,i)
+!AC!         if (cvflag_grav) then
+!AC!           ftra(il,i,k)=ftra(il,i,k)+0.01*grav*dpinv
+!AC!     :         *(amp1(il)*(tra(il,i+1,k)-tra(il,i,k))
+!AC!     :           -ad(il)*(tra(il,i,k)-tra(il,i-1,k)))
+!AC!         else
+!AC!           ftra(il,i,k)=ftra(il,i,k)+0.1*dpinv
+!AC!     :         *(amp1(il)*(tra(il,i+1,k)-tra(il,i,k))
+!AC!     :           -ad(il)*(tra(il,i,k)-tra(il,i-1,k)))
+!AC!         endif
+!AC!        endif
+!AC!       enddo
+!AC!      enddo
 
     DO k = 1, i - 1
@@ -3246,16 +3198,8 @@
             dpinv = 1.0/(ph(il,i)-ph(il,i+1))
             cpinv = 1.0/cpn(il, i)
-            IF (cvflag_grav) THEN
-              ft(il, i) = ft(il, i) + 0.01*grav*dpinv*ment(il, k, i)*(hent(il &
-                ,k,i)-h(il,i)+t(il,i)*(cpv-cpd)*(rr(il,i)+awat(il)-qent(il,k, &
-                i)))*cpinv
-
-
-
-            ELSE
-              ft(il, i) = ft(il, i) + 0.1*dpinv*ment(il, k, i)*(hent(il,k,i)- &
-                h(il,i)+t(il,i)*(cpv-cpd)*(rr(il,i)+awat(il)-qent(il,k, &
-                i)))*cpinv
-            END IF !cvflag_grav
+            ft(il, i) = ft(il, i) + 0.01*grav*dpinv*ment(il, k, i) * &
+                 (hent(il,k,i)-h(il,i)+t(il,i)*(cpv-cpd)*(rr(il,i)+awat(il)-qent(il,k,i)))*cpinv
+!
+!
           END IF ! i
         END DO
@@ -3266,22 +3210,11 @@
           dpinv = 1.0/(ph(il,i)-ph(il,i+1))
           cpinv = 1.0/cpn(il, i)
-          IF (cvflag_grav) THEN
-            fr(il, i) = fr(il, i) + 0.01*grav*dpinv*ment(il, k, i)*(qent(il,k &
-              ,i)-awat(il)-rr(il,i))
-            fu(il, i) = fu(il, i) + 0.01*grav*dpinv*ment(il, k, i)*(uent(il,k &
-              ,i)-u(il,i))
-            fv(il, i) = fv(il, i) + 0.01*grav*dpinv*ment(il, k, i)*(vent(il,k &
-              ,i)-v(il,i))
-          ELSE ! cvflag_grav
-            fr(il, i) = fr(il, i) + 0.1*dpinv*ment(il, k, i)*(qent(il,k,i)- &
-              awat(il)-rr(il,i))
-            fu(il, i) = fu(il, i) + 0.01*grav*dpinv*ment(il, k, i)*(uent(il,k &
-              ,i)-u(il,i))
-            fv(il, i) = fv(il, i) + 0.1*dpinv*ment(il, k, i)*(vent(il,k,i)-v( &
-              il,i))
-          END IF ! cvflag_grav
-
-          ! (saturated updrafts resulting from mixing)        ! cld
-          qcond(il, i) = qcond(il, i) + (elij(il,k,i)-awat(il)) ! cld
+          fr(il, i) = fr(il, i) + 0.01*grav*dpinv*ment(il, k, i) * &
+                                                       (qent(il,k,i)-awat(il)-rr(il,i))
+          fu(il, i) = fu(il, i) + 0.01*grav*dpinv*ment(il, k, i)*(uent(il,k,i)-u(il,i))
+          fv(il, i) = fv(il, i) + 0.01*grav*dpinv*ment(il, k, i)*(vent(il,k,i)-v(il,i))
+
+! (saturated updrafts resulting from mixing)                                   ! cld
+          qcond(il, i) = qcond(il, i) + (elij(il,k,i)-awat(il))                ! cld
           nqcond(il, i) = nqcond(il, i) + 1. ! cld
         END IF ! i
@@ -3289,21 +3222,21 @@
     END DO
 
-    ! AC!      do j=1,ntra
-    ! AC!       do k=1,i-1
-    ! AC!        do il=1,ncum
-    ! AC!         if (i.le.inb(il) .and. iflag(il) .le. 1) then
-    ! AC!          dpinv=1.0/(ph(il,i)-ph(il,i+1))
-    ! AC!          cpinv=1.0/cpn(il,i)
-    ! AC!          if (cvflag_grav) then
-    ! AC!           ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv*ment(il,k,i)
-    ! AC!     :        *(traent(il,k,i,j)-tra(il,i,j))
-    ! AC!          else
-    ! AC!           ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv*ment(il,k,i)
-    ! AC!     :        *(traent(il,k,i,j)-tra(il,i,j))
-    ! AC!          endif
-    ! AC!         endif
-    ! AC!        enddo
-    ! AC!       enddo
-    ! AC!      enddo
+!AC!      do j=1,ntra
+!AC!       do k=1,i-1
+!AC!        do il=1,ncum
+!AC!         if (i.le.inb(il) .and. iflag(il) .le. 1) then
+!AC!          dpinv=1.0/(ph(il,i)-ph(il,i+1))
+!AC!          cpinv=1.0/cpn(il,i)
+!AC!          if (cvflag_grav) then
+!AC!           ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv*ment(il,k,i)
+!AC!     :        *(traent(il,k,i,j)-tra(il,i,j))
+!AC!          else
+!AC!           ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv*ment(il,k,i)
+!AC!     :        *(traent(il,k,i,j)-tra(il,i,j))
+!AC!          endif
+!AC!         endif
+!AC!        enddo
+!AC!       enddo
+!AC!      enddo
 
     DO k = i, nl + 1
@@ -3314,14 +3247,8 @@
             dpinv = 1.0/(ph(il,i)-ph(il,i+1))
             cpinv = 1.0/cpn(il, i)
-            IF (cvflag_grav) THEN
-              ft(il, i) = ft(il, i) + 0.01*grav*dpinv*ment(il, k, i)*(hent(il &
-                ,k,i)-h(il,i)+t(il,i)*(cpv-cpd)*(rr(il,i)-qent(il,k, &
-                i)))*cpinv
-
-
-            ELSE
-              ft(il, i) = ft(il, i) + 0.1*dpinv*ment(il, k, i)*(hent(il,k,i)- &
-                h(il,i)+t(il,i)*(cpv-cpd)*(rr(il,i)-qent(il,k,i)))*cpinv
-            END IF !cvflag_grav
+            ft(il, i) = ft(il, i) + 0.01*grav*dpinv*ment(il, k, i) * &
+                  (hent(il,k,i)-h(il,i)+t(il,i)*(cpv-cpd)*(rr(il,i)-qent(il,k,i)))*cpinv
+
+
           END IF ! i
         END DO
@@ -3333,49 +3260,37 @@
           cpinv = 1.0/cpn(il, i)
 
-          IF (cvflag_grav) THEN
-            fr(il, i) = fr(il, i) + 0.01*grav*dpinv*ment(il, k, i)*(qent(il,k &
-              ,i)-rr(il,i))
-            fu(il, i) = fu(il, i) + 0.01*grav*dpinv*ment(il, k, i)*(uent(il,k &
-              ,i)-u(il,i))
-            fv(il, i) = fv(il, i) + 0.01*grav*dpinv*ment(il, k, i)*(vent(il,k &
-              ,i)-v(il,i))
-          ELSE ! cvflag_grav
-            fr(il, i) = fr(il, i) + 0.1*dpinv*ment(il, k, i)*(qent(il,k,i)-rr &
-              (il,i))
-            fu(il, i) = fu(il, i) + 0.1*dpinv*ment(il, k, i)*(uent(il,k,i)-u( &
-              il,i))
-            fv(il, i) = fv(il, i) + 0.1*dpinv*ment(il, k, i)*(vent(il,k,i)-v( &
-              il,i))
-          END IF ! cvflag_grav
+          fr(il, i) = fr(il, i) + 0.01*grav*dpinv*ment(il, k, i)*(qent(il,k,i)-rr(il,i))
+          fu(il, i) = fu(il, i) + 0.01*grav*dpinv*ment(il, k, i)*(uent(il,k,i)-u(il,i))
+          fv(il, i) = fv(il, i) + 0.01*grav*dpinv*ment(il, k, i)*(vent(il,k,i)-v(il,i))
         END IF ! i and k
       END DO
     END DO
 
-    ! AC!      do j=1,ntra
-    ! AC!       do k=i,nl+1
-    ! AC!        do il=1,ncum
-    ! AC!         if (i.le.inb(il) .and. k.le.inb(il)
-    ! AC!     $                .and. iflag(il) .le. 1) then
-    ! AC!          dpinv=1.0/(ph(il,i)-ph(il,i+1))
-    ! AC!          cpinv=1.0/cpn(il,i)
-    ! AC!          if (cvflag_grav) then
-    ! AC!           ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv*ment(il,k,i)
-    ! AC!     :         *(traent(il,k,i,j)-tra(il,i,j))
-    ! AC!          else
-    ! AC!           ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv*ment(il,k,i)
-    ! AC!     :             *(traent(il,k,i,j)-tra(il,i,j))
-    ! AC!          endif
-    ! AC!         endif ! i and k
-    ! AC!        enddo
-    ! AC!       enddo
-    ! AC!      enddo
-
-    ! sb: interface with the cloud parameterization:          ! cld
+!AC!      do j=1,ntra
+!AC!       do k=i,nl+1
+!AC!        do il=1,ncum
+!AC!         if (i.le.inb(il) .and. k.le.inb(il)
+!AC!     $                .and. iflag(il) .le. 1) then
+!AC!          dpinv=1.0/(ph(il,i)-ph(il,i+1))
+!AC!          cpinv=1.0/cpn(il,i)
+!AC!          if (cvflag_grav) then
+!AC!           ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv*ment(il,k,i)
+!AC!     :         *(traent(il,k,i,j)-tra(il,i,j))
+!AC!          else
+!AC!           ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv*ment(il,k,i)
+!AC!     :             *(traent(il,k,i,j)-tra(il,i,j))
+!AC!          endif
+!AC!         endif ! i and k
+!AC!        enddo
+!AC!       enddo
+!AC!      enddo
+
+! sb: interface with the cloud parameterization:                               ! cld
 
     DO k = i + 1, nl
       DO il = 1, ncum
-        IF (k<=inb(il) .AND. i<=inb(il) .AND. iflag(il)<=1) THEN ! cld
-          ! (saturated downdrafts resulting from mixing)            ! cld
-          qcond(il, i) = qcond(il, i) + elij(il, k, i) ! cld
+        IF (k<=inb(il) .AND. i<=inb(il) .AND. iflag(il)<=1) THEN               ! cld
+! (saturated downdrafts resulting from mixing)                                 ! cld
+          qcond(il, i) = qcond(il, i) + elij(il, k, i)                         ! cld
           nqcond(il, i) = nqcond(il, i) + 1. ! cld
         END IF ! cld
@@ -3383,130 +3298,117 @@
     END DO ! cld
 
-    ! (particular case: no detraining level is found)         ! cld
-    DO il = 1, ncum ! cld
-      IF (i<=inb(il) .AND. nent(il,i)==0 .AND. iflag(il)<=1) THEN ! cld
-        qcond(il, i) = qcond(il, i) + (1.-ep(il,i))*clw(il, i) ! cld
-        nqcond(il, i) = nqcond(il, i) + 1. ! cld
-      END IF ! cld
-    END DO ! cld
-
-    DO il = 1, ncum ! cld
-      IF (i<=inb(il) .AND. nqcond(il,i)/=0 .AND. iflag(il)<=1) THEN ! cld
-        qcond(il, i) = qcond(il, i)/nqcond(il, i) ! cld
-      END IF ! cld
-    END DO
-
-    ! AC!      do j=1,ntra
-    ! AC!       do il=1,ncum
-    ! AC!        if (i.le.inb(il) .and. iflag(il) .le. 1) then
-    ! AC!         dpinv=1.0/(ph(il,i)-ph(il,i+1))
-    ! AC!         cpinv=1.0/cpn(il,i)
-    ! AC!
-    ! AC!         if (cvflag_grav) then
-    ! AC!          ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv
-    ! AC!     :     *(mp(il,i+1)*(trap(il,i+1,j)-tra(il,i,j))
-    ! AC!     :     -mp(il,i)*(trap(il,i,j)-trap(il,i-1,j)))
-    ! AC!         else
-    ! AC!          ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv
-    ! AC!     :     *(mp(il,i+1)*(trap(il,i+1,j)-tra(il,i,j))
-    ! AC!     :     -mp(il,i)*(trap(il,i,j)-trap(il,i-1,j)))
-    ! AC!         endif
-    ! AC!        endif ! i
-    ! AC!       enddo
-    ! AC!      enddo
+! (particular case: no detraining level is found)                              ! cld
+    DO il = 1, ncum                                                            ! cld
+      IF (i<=inb(il) .AND. nent(il,i)==0 .AND. iflag(il)<=1) THEN              ! cld
+        qcond(il, i) = qcond(il, i) + (1.-ep(il,i))*clw(il, i)                 ! cld
+        nqcond(il, i) = nqcond(il, i) + 1.                                     ! cld
+      END IF                                                                   ! cld
+    END DO                                                                     ! cld
+
+    DO il = 1, ncum                                                            ! cld
+      IF (i<=inb(il) .AND. nqcond(il,i)/=0 .AND. iflag(il)<=1) THEN            ! cld
+        qcond(il, i) = qcond(il, i)/nqcond(il, i)                              ! cld
+      END IF                                                                   ! cld
+    END DO
+
+!AC!      do j=1,ntra
+!AC!       do il=1,ncum
+!AC!        if (i.le.inb(il) .and. iflag(il) .le. 1) then
+!AC!         dpinv=1.0/(ph(il,i)-ph(il,i+1))
+!AC!         cpinv=1.0/cpn(il,i)
+!AC!
+!AC!         if (cvflag_grav) then
+!AC!          ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv
+!AC!     :     *(mp(il,i+1)*(trap(il,i+1,j)-tra(il,i,j))
+!AC!     :     -mp(il,i)*(trap(il,i,j)-trap(il,i-1,j)))
+!AC!         else
+!AC!          ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv
+!AC!     :     *(mp(il,i+1)*(trap(il,i+1,j)-tra(il,i,j))
+!AC!     :     -mp(il,i)*(trap(il,i,j)-trap(il,i-1,j)))
+!AC!         endif
+!AC!        endif ! i
+!AC!       enddo
+!AC!      enddo
 
 
 500 END DO
 
-
-  ! ***   move the detrainment at level inb down to level inb-1   ***
-  ! ***        in such a way as to preserve the vertically        ***
-  ! ***          integrated enthalpy and water tendencies         ***
-
-  ! Correction bug le 18-03-09
+!JYG<
+!Conservation de l'eau
+!   sumdq = 0.
+!   DO k = 1, nl
+!     sumdq = sumdq + fr(1, k)*100.*(ph(1,k)-ph(1,k+1))/grav
+!   END DO
+!   PRINT *, 'cv3_yield, apres 500, sum(dq), precip, somme ', sumdq, Vprecip(1, 1), sumdq + vprecip(1, 1)
+!JYG>
+! ***   move the detrainment at level inb down to level inb-1   ***
+! ***        in such a way as to preserve the vertically        ***
+! ***          integrated enthalpy and water tendencies         ***
+
+! Correction bug le 18-03-09
   DO il = 1, ncum
     IF (iflag(il)<=1) THEN
-      IF (cvflag_grav) THEN
-        ax = 0.01*grav*ment(il, inb(il), inb(il))*(hp(il,inb(il))-h(il,inb(il &
-          ))+t(il,inb(il))*(cpv-cpd)*(rr(il,inb(il))-qent(il,inb(il), &
-          inb(il))))/(cpn(il,inb(il))*(ph(il,inb(il))-ph(il,inb(il)+1)))
-        ft(il, inb(il)) = ft(il, inb(il)) - ax
-        ft(il, inb(il)-1) = ft(il, inb(il)-1) + ax*cpn(il, inb(il))*(ph(il, &
-          inb(il))-ph(il,inb(il)+1))/(cpn(il,inb(il)-1)*(ph(il, &
-          inb(il)-1)-ph(il,inb(il))))
-
-        bx = 0.01*grav*ment(il, inb(il), inb(il))*(qent(il,inb(il),inb(il))- &
-          rr(il,inb(il)))/(ph(il,inb(il))-ph(il,inb(il)+1))
-        fr(il, inb(il)) = fr(il, inb(il)) - bx
-        fr(il, inb(il)-1) = fr(il, inb(il)-1) + bx*(ph(il,inb(il))-ph(il,inb( &
-          il)+1))/(ph(il,inb(il)-1)-ph(il,inb(il)))
-
-        cx = 0.01*grav*ment(il, inb(il), inb(il))*(uent(il,inb(il),inb(il))-u &
-          (il,inb(il)))/(ph(il,inb(il))-ph(il,inb(il)+1))
-        fu(il, inb(il)) = fu(il, inb(il)) - cx
-        fu(il, inb(il)-1) = fu(il, inb(il)-1) + cx*(ph(il,inb(il))-ph(il,inb( &
-          il)+1))/(ph(il,inb(il)-1)-ph(il,inb(il)))
-
-        dx = 0.01*grav*ment(il, inb(il), inb(il))*(vent(il,inb(il),inb(il))-v &
-          (il,inb(il)))/(ph(il,inb(il))-ph(il,inb(il)+1))
-        fv(il, inb(il)) = fv(il, inb(il)) - dx
-        fv(il, inb(il)-1) = fv(il, inb(il)-1) + dx*(ph(il,inb(il))-ph(il,inb( &
-          il)+1))/(ph(il,inb(il)-1)-ph(il,inb(il)))
-      ELSE
-        ax = 0.1*ment(il, inb(il), inb(il))*(hp(il,inb(il))-h(il,inb(il))+t( &
-          il,inb(il))*(cpv-cpd)*(rr(il,inb(il))-qent(il,inb(il), &
-          inb(il))))/(cpn(il,inb(il))*(ph(il,inb(il))-ph(il,inb(il)+1)))
-        ft(il, inb(il)) = ft(il, inb(il)) - ax
-        ft(il, inb(il)-1) = ft(il, inb(il)-1) + ax*cpn(il, inb(il))*(ph(il, &
-          inb(il))-ph(il,inb(il)+1))/(cpn(il,inb(il)-1)*(ph(il, &
-          inb(il)-1)-ph(il,inb(il))))
-
-        bx = 0.1*ment(il, inb(il), inb(il))*(qent(il,inb(il),inb(il))-rr(il, &
-          inb(il)))/(ph(il,inb(il))-ph(il,inb(il)+1))
-        fr(il, inb(il)) = fr(il, inb(il)) - bx
-        fr(il, inb(il)-1) = fr(il, inb(il)-1) + bx*(ph(il,inb(il))-ph(il,inb( &
-          il)+1))/(ph(il,inb(il)-1)-ph(il,inb(il)))
-
-        cx = 0.1*ment(il, inb(il), inb(il))*(uent(il,inb(il),inb(il))-u(il, &
-          inb(il)))/(ph(il,inb(il))-ph(il,inb(il)+1))
-        fu(il, inb(il)) = fu(il, inb(il)) - cx
-        fu(il, inb(il)-1) = fu(il, inb(il)-1) + cx*(ph(il,inb(il))-ph(il,inb( &
-          il)+1))/(ph(il,inb(il)-1)-ph(il,inb(il)))
-
-        dx = 0.1*ment(il, inb(il), inb(il))*(vent(il,inb(il),inb(il))-v(il, &
-          inb(il)))/(ph(il,inb(il))-ph(il,inb(il)+1))
-        fv(il, inb(il)) = fv(il, inb(il)) - dx
-        fv(il, inb(il)-1) = fv(il, inb(il)-1) + dx*(ph(il,inb(il))-ph(il,inb( &
-          il)+1))/(ph(il,inb(il)-1)-ph(il,inb(il)))
-      END IF
+      ax = 0.01*grav*ment(il, inb(il), inb(il))* &
+           (hp(il,inb(il))-h(il,inb(il))+t(il,inb(il))*(cpv-cpd)*(rr(il,inb(il))-qent(il,inb(il),inb(il))))/ &
+                                (cpn(il,inb(il))*(ph(il,inb(il))-ph(il,inb(il)+1)))
+      ft(il, inb(il)) = ft(il, inb(il)) - ax
+      ft(il, inb(il)-1) = ft(il, inb(il)-1) + ax*cpn(il, inb(il))*(ph(il,inb(il))-ph(il,inb(il)+1))/ &
+                              (cpn(il,inb(il)-1)*(ph(il,inb(il)-1)-ph(il,inb(il))))
+
+      bx = 0.01*grav*ment(il, inb(il), inb(il))*(qent(il,inb(il),inb(il))-rr(il,inb(il)))/ &
+                                                 (ph(il,inb(il))-ph(il,inb(il)+1))
+      fr(il, inb(il)) = fr(il, inb(il)) - bx
+      fr(il, inb(il)-1) = fr(il, inb(il)-1) + bx*(ph(il,inb(il))-ph(il,inb(il)+1))/ &
+                                                 (ph(il,inb(il)-1)-ph(il,inb(il)))
+
+      cx = 0.01*grav*ment(il, inb(il), inb(il))*(uent(il,inb(il),inb(il))-u(il,inb(il)))/ &
+                                                 (ph(il,inb(il))-ph(il,inb(il)+1))
+      fu(il, inb(il)) = fu(il, inb(il)) - cx
+      fu(il, inb(il)-1) = fu(il, inb(il)-1) + cx*(ph(il,inb(il))-ph(il,inb(il)+1))/ &
+                                                 (ph(il,inb(il)-1)-ph(il,inb(il)))
+
+      dx = 0.01*grav*ment(il, inb(il), inb(il))*(vent(il,inb(il),inb(il))-v(il,inb(il)))/ &
+                                                 (ph(il,inb(il))-ph(il,inb(il)+1))
+      fv(il, inb(il)) = fv(il, inb(il)) - dx
+      fv(il, inb(il)-1) = fv(il, inb(il)-1) + dx*(ph(il,inb(il))-ph(il,inb(il)+1))/ &
+                                                 (ph(il,inb(il)-1)-ph(il,inb(il)))
     END IF !iflag
   END DO
 
-  ! AC!      do j=1,ntra
-  ! AC!       do il=1,ncum
-  ! AC!        IF (iflag(il) .le. 1) THEN
-  ! AC!	IF (cvflag_grav) then
-  ! AC!        ex=0.01*grav*ment(il,inb(il),inb(il))
-  ! AC!     :      *(traent(il,inb(il),inb(il),j)-tra(il,inb(il),j))
-  ! AC!     :      /(ph(i l,inb(il))-ph(il,inb(il)+1))
-  ! AC!        ftra(il,inb(il),j)=ftra(il,inb(il),j)-ex
-  ! AC!        ftra(il,inb(il)-1,j)=ftra(il,inb(il)-1,j)
-  ! AC!     :       +ex*(ph(il,inb(il))-ph(il,inb(il)+1))
-  ! AC!     :          /(ph(il,inb(il)-1)-ph(il,inb(il)))
-  ! AC!	else
-  ! AC!        ex=0.1*ment(il,inb(il),inb(il))
-  ! AC!     :      *(traent(il,inb(il),inb(il),j)-tra(il,inb(il),j))
-  ! AC!     :      /(ph(i l,inb(il))-ph(il,inb(il)+1))
-  ! AC!        ftra(il,inb(il),j)=ftra(il,inb(il),j)-ex
-  ! AC!        ftra(il,inb(il)-1,j)=ftra(il,inb(il)-1,j)
-  ! AC!     :       +ex*(ph(il,inb(il))-ph(il,inb(il)+1))
-  ! AC!     :          /(ph(il,inb(il)-1)-ph(il,inb(il)))
-  ! AC!        ENDIF   !cvflag grav
-  ! AC!        ENDIF    !iflag
-  ! AC!       enddo
-  ! AC!      enddo
-
-
-  ! ***    homogenize tendencies below cloud base    ***
+!JYG<
+!Conservation de l'eau
+!   sumdq = 0.
+!   DO k = 1, nl
+!     sumdq = sumdq + fr(1, k)*100.*(ph(1,k)-ph(1,k+1))/grav
+!   END DO
+!   PRINT *, 'cv3_yield, apres 503, sum(dq), precip, somme ', sumdq, Vprecip(1, 1), sumdq + vprecip(1, 1)
+!JYG>
+
+!AC!      do j=1,ntra
+!AC!       do il=1,ncum
+!AC!        IF (iflag(il) .le. 1) THEN
+!AC!	IF (cvflag_grav) then
+!AC!        ex=0.01*grav*ment(il,inb(il),inb(il))
+!AC!     :      *(traent(il,inb(il),inb(il),j)-tra(il,inb(il),j))
+!AC!     :      /(ph(i l,inb(il))-ph(il,inb(il)+1))
+!AC!        ftra(il,inb(il),j)=ftra(il,inb(il),j)-ex
+!AC!        ftra(il,inb(il)-1,j)=ftra(il,inb(il)-1,j)
+!AC!     :       +ex*(ph(il,inb(il))-ph(il,inb(il)+1))
+!AC!     :          /(ph(il,inb(il)-1)-ph(il,inb(il)))
+!AC!	else
+!AC!        ex=0.1*ment(il,inb(il),inb(il))
+!AC!     :      *(traent(il,inb(il),inb(il),j)-tra(il,inb(il),j))
+!AC!     :      /(ph(i l,inb(il))-ph(il,inb(il)+1))
+!AC!        ftra(il,inb(il),j)=ftra(il,inb(il),j)-ex
+!AC!        ftra(il,inb(il)-1,j)=ftra(il,inb(il)-1,j)
+!AC!     :       +ex*(ph(il,inb(il))-ph(il,inb(il)+1))
+!AC!     :          /(ph(il,inb(il)-1)-ph(il,inb(il)))
+!AC!        ENDIF   !cvflag grav
+!AC!        ENDIF    !iflag
+!AC!       enddo
+!AC!      enddo
+
+
+! ***    homogenize tendencies below cloud base    ***
 
 
@@ -3522,33 +3424,49 @@
   END DO
 
-  ! do i=1,nl
-  ! do il=1,ncum
-  ! th_wake(il,i)=t_wake(il,i)*(1000.0/p(il,i))**rdcp
-  ! enddo
-  ! enddo
+!do i=1,nl
+!do il=1,ncum
+!th_wake(il,i)=t_wake(il,i)*(1000.0/p(il,i))**rdcp
+!enddo
+!enddo
 
   DO i = 1, nl
     DO il = 1, ncum
       IF (i<=(icb(il)-1) .AND. iflag(il)<=1) THEN
-        ! jyg  Saturated part : use T profile
+!jyg  Saturated part : use T profile
         asum(il) = asum(il) + (ft(il,i)-ftd(il,i))*(ph(il,i)-ph(il,i+1))
-        bsum(il) = bsum(il) + (fr(il,i)-fqd(il,i))*(lv(il,i)+(cl-cpd)*(t(il, &
-          i)-t(il,1)))*(ph(il,i)-ph(il,i+1))
-        csum(il) = csum(il) + (lv(il,i)+(cl-cpd)*(t(il,i)-t(il, &
-          1)))*(ph(il,i)-ph(il,i+1))
+!jyg<20140311
+!Correction pour conserver l eau
+        IF (ok_conserv_q) THEN
+          bsum(il) = bsum(il) + (fr(il,i)-fqd(il,i))*(ph(il,i)-ph(il,i+1))
+          csum(il) = csum(il) + (ph(il,i)-ph(il,i+1))
+
+        ELSE
+          bsum(il)=bsum(il)+(fr(il,i)-fqd(il,i))*(lv(il,i)+(cl-cpd)*(t(il,i)-t(il,1)))* &
+                            (ph(il,i)-ph(il,i+1))
+          csum(il)=csum(il)+(lv(il,i)+(cl-cpd)*(t(il,i)-t(il,1)))* &
+                            (ph(il,i)-ph(il,i+1))
+        ENDIF ! (ok_conserv_q)
+!jyg>
         dsum(il) = dsum(il) + t(il, i)*(ph(il,i)-ph(il,i+1))/th(il, i)
-        ! jyg  Unsaturated part : use T_wake profile
+!jyg  Unsaturated part : use T_wake profile
         esum(il) = esum(il) + ftd(il, i)*(ph(il,i)-ph(il,i+1))
-        fsum(il) = fsum(il) + fqd(il, i)*(lv(il,i)+(cl-cpd)*(t_wake(il, &
-          i)-t_wake(il,1)))*(ph(il,i)-ph(il,i+1))
-        gsum(il) = gsum(il) + (lv(il,i)+(cl-cpd)*(t_wake(il,i)-t_wake(il, &
-          1)))*(ph(il,i)-ph(il,i+1))
-        hsum(il) = hsum(il) + t_wake(il, i)*(ph(il,i)-ph(il,i+1))/th_wake(il, &
-          i)
+!jyg<20140311
+!Correction pour conserver l eau
+        IF (ok_conserv_q) THEN
+          fsum(il) = fsum(il) + fqd(il, i)*(ph(il,i)-ph(il,i+1))
+          gsum(il) = gsum(il) + (ph(il,i)-ph(il,i+1))
+        ELSE
+          fsum(il)=fsum(il)+fqd(il,i)*(lv(il,i)+(cl-cpd)*(t_wake(il,i)-t_wake(il,1)))* &
+                            (ph(il,i)-ph(il,i+1))
+          gsum(il)=gsum(il)+(lv(il,i)+(cl-cpd)*(t_wake(il,i)-t_wake(il,1)))* &
+                            (ph(il,i)-ph(il,i+1))
+        ENDIF ! (ok_conserv_q)
+!jyg>
+        hsum(il) = hsum(il) + t_wake(il, i)*(ph(il,i)-ph(il,i+1))/th_wake(il, i)
       END IF
     END DO
   END DO
 
-  ! !!!      do 700 i=1,icb(il)-1
+!!!!      do 700 i=1,icb(il)-1
   DO i = 1, nl
     DO il = 1, ncum
@@ -3562,13 +3480,21 @@
   END DO
 
-
-  ! ***   Check that moisture stays positive. If not, scale tendencies
-  ! in order to ensure moisture positivity
+!jyg<
+!Conservation de l'eau
+!!  sumdq = 0.
+!!  DO k = 1, nl
+!!    sumdq = sumdq + fr(1, k)*100.*(ph(1,k)-ph(1,k+1))/grav
+!!  END DO
+!!  PRINT *, 'cv3_yield, apres hom, sum(dq), precip, somme ', sumdq, Vprecip(1, 1), sumdq + vprecip(1, 1)
+!jyg>
+
+
+! ***   Check that moisture stays positive. If not, scale tendencies
+! in order to ensure moisture positivity
   DO il = 1, ncum
     alpha_qpos(il) = 1.
     IF (iflag(il)<=1) THEN
       IF (fr(il,1)<=0.) THEN
-        alpha_qpos(il) = max(alpha_qpos(il), (-delt*fr(il, &
-          1))/(s_wake(il)*rr_wake(il,1)+(1.-s_wake(il))*rr(il,1)))
+        alpha_qpos(il) = max(alpha_qpos(il), (-delt*fr(il,1))/(s_wake(il)*rr_wake(il,1)+(1.-s_wake(il))*rr(il,1)))
       END IF
     END IF
@@ -3578,8 +3504,6 @@
       IF (iflag(il)<=1) THEN
         IF (fr(il,i)<=0.) THEN
-          alpha_qpos1(il) = max(1., (-delt*fr(il,i))/(s_wake(il)*rr_wake(il, &
-            i)+(1.-s_wake(il))*rr(il,i)))
-          IF (alpha_qpos1(il)>=alpha_qpos(il)) alpha_qpos(il) &
-            = alpha_qpos1(il)
+          alpha_qpos1(il) = max(1., (-delt*fr(il,i))/(s_wake(il)*rr_wake(il,i)+(1.-s_wake(il))*rr(il,i)))
+          IF (alpha_qpos1(il)>=alpha_qpos(il)) alpha_qpos(il) = alpha_qpos1(il)
         END IF
       END IF
@@ -3608,5 +3532,5 @@
         m(il, i) = m(il, i)/alpha_qpos(il)
         mp(il, i) = mp(il, i)/alpha_qpos(il)
-        vprecip(il, i) = vprecip(il, i)/alpha_qpos(il)
+        Vprecip(il, i) = vprecip(il, i)/alpha_qpos(il)
       END IF
     END DO
@@ -3622,16 +3546,16 @@
   END DO
 
-  ! AC!      DO j = 1,ntra
-  ! AC!      DO i = 1,nl
-  ! AC!       DO il = 1,ncum
-  ! AC!        IF (iflag(il) .le. 1) THEN
-  ! AC!         ftra(il,i,j) = ftra(il,i,j)/alpha_qpos(il)
-  ! AC!        ENDIF
-  ! AC!       ENDDO
-  ! AC!      ENDDO
-  ! AC!      ENDDO
-
-
-  ! ***           reset counter and return           ***
+!AC!      DO j = 1,ntra
+!AC!      DO i = 1,nl
+!AC!       DO il = 1,ncum
+!AC!        IF (iflag(il) .le. 1) THEN
+!AC!         ftra(il,i,j) = ftra(il,i,j)/alpha_qpos(il)
+!AC!        ENDIF
+!AC!       ENDDO
+!AC!      ENDDO
+!AC!      ENDDO
+
+
+! ***           reset counter and return           ***
 
   DO il = 1, ncum
@@ -3702,5 +3626,5 @@
           END IF
         END IF
-        ! c        print *,'cbmf',il,i,k,cbmf(il),wghti(il,k)
+! c        print *,'cbmf',il,i,k,cbmf(il),wghti(il,k)
       END DO
     END DO
@@ -3710,12 +3634,10 @@
     DO k = i, nl
       DO il = 1, ncum
-        ! test         if (i.ge.icb(il).and.i.le.inb(il).and.k.le.inb(il))
-        ! then
+! test         if (i.ge.icb(il).and.i.le.inb(il).and.k.le.inb(il)) then
         IF (i<=inb(il) .AND. k<=inb(il)) THEN
           upwd(il, i) = upwd(il, i) + up1(il, k, i)
           dnwd(il, i) = dnwd(il, i) + dn1(il, k, i)
         END IF
-        ! c         print
-        ! *,'upwd',il,i,k,inb(il),upwd(il,i),m(il,k),up1(il,k,i)
+! c         print *,'upwd',il,i,k,inb(il),upwd(il,i),m(il,k),up1(il,k,i)
       END DO
     END DO
@@ -3723,27 +3645,27 @@
 
 
-  ! !!!      DO il=1,ncum
-  ! !!!      do i=icb(il),inb(il)
-  ! !!!
-  ! !!!      upwd(il,i)=0.0
-  ! !!!      dnwd(il,i)=0.0
-  ! !!!      do k=i,inb(il)
-  ! !!!      up1=0.0
-  ! !!!      dn1=0.0
-  ! !!!      do n=1,i-1
-  ! !!!      up1=up1+ment(il,n,k)
-  ! !!!      dn1=dn1-ment(il,k,n)
-  ! !!!      enddo
-  ! !!!      upwd(il,i)=upwd(il,i)+m(il,k)+up1
-  ! !!!      dnwd(il,i)=dnwd(il,i)+dn1
-  ! !!!      enddo
-  ! !!!      enddo
-  ! !!!
-  ! !!!      ENDDO
-
-  ! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
-  ! determination de la variation de flux ascendant entre
-  ! deux niveau non dilue mip
-  ! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+!!!!      DO il=1,ncum
+!!!!      do i=icb(il),inb(il)
+!!!!
+!!!!      upwd(il,i)=0.0
+!!!!      dnwd(il,i)=0.0
+!!!!      do k=i,inb(il)
+!!!!      up1=0.0
+!!!!      dn1=0.0
+!!!!      do n=1,i-1
+!!!!      up1=up1+ment(il,n,k)
+!!!!      dn1=dn1-ment(il,k,n)
+!!!!      enddo
+!!!!      upwd(il,i)=upwd(il,i)+m(il,k)+up1
+!!!!      dnwd(il,i)=dnwd(il,i)+dn1
+!!!!      enddo
+!!!!      enddo
+!!!!
+!!!!      ENDDO
+
+! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+! determination de la variation de flux ascendant entre
+! deux niveau non dilue mip
+! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
 
   DO i = 1, nl
@@ -3787,8 +3709,8 @@
   END DO
 
-  ! cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
-  ! icb represente de niveau ou se trouve la
-  ! base du nuage , et inb le top du nuage
-  ! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+! cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+! icb represente de niveau ou se trouve la
+! base du nuage , et inb le top du nuage
+! ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
 
   DO i = 1, nd
@@ -3800,6 +3722,5 @@
   DO i = 1, nd
     DO il = 1, ncum
-      rdcp = (rrd*(1.-rr(il,i))-rr(il,i)*rrv)/(cpd*(1.-rr(il, &
-        i))+rr(il,i)*cpv)
+      rdcp = (rrd*(1.-rr(il,i))-rr(il,i)*rrv)/(cpd*(1.-rr(il,i))+rr(il,i)*cpv)
       tls(il, i) = t(il, i)*(1000.0/p(il,i))**rdcp
       tps(il, i) = tp(il, i)
@@ -3808,77 +3729,79 @@
 
 
-  ! *** diagnose the in-cloud mixing ratio   ***            ! cld
-  ! ***           of condensed water         ***            ! cld
-  ! ! cld
-
-  DO i = 1, nd ! cld
-    DO il = 1, ncum ! cld
-      mac(il, i) = 0.0 ! cld
-      wa(il, i) = 0.0 ! cld
-      siga(il, i) = 0.0 ! cld
-      sax(il, i) = 0.0 ! cld
-    END DO ! cld
-  END DO ! cld
-
-  DO i = minorig, nl ! cld
-    DO k = i + 1, nl + 1 ! cld
-      DO il = 1, ncum ! cld
+! *** diagnose the in-cloud mixing ratio   ***                       ! cld
+! ***           of condensed water         ***                       ! cld
+!! cld                                                               
+                                                                     
+  DO i = 1, nd                                                       ! cld
+    DO il = 1, ncum                                                  ! cld
+      mac(il, i) = 0.0                                               ! cld
+      wa(il, i) = 0.0                                                ! cld
+      siga(il, i) = 0.0                                              ! cld
+      sax(il, i) = 0.0                                               ! cld
+    END DO                                                           ! cld
+  END DO                                                             ! cld
+                                                                     
+  DO i = minorig, nl                                                 ! cld
+    DO k = i + 1, nl + 1                                             ! cld
+      DO il = 1, ncum                                                ! cld
         IF (i<=inb(il) .AND. k<=(inb(il)+1) .AND. iflag(il)<=1) THEN ! cld
-          mac(il, i) = mac(il, i) + m(il, k) ! cld
-        END IF ! cld
-      END DO ! cld
-    END DO ! cld
-  END DO ! cld
-
-  DO i = 1, nl ! cld
-    DO j = 1, i ! cld
-      DO il = 1, ncum ! cld
-        IF (i>=icb(il) .AND. i<=(inb(il)-1) & ! cld
-            .AND. j>=icb(il) .AND. iflag(il)<=1) THEN ! cld
-          sax(il, i) = sax(il, i) + rrd*(tvp(il,j)-tv(il,j)) & ! cld
-            *(ph(il,j)-ph(il,j+1))/p(il, j) ! cld
-        END IF ! cld
-      END DO ! cld
-    END DO ! cld
-  END DO ! cld
-
-  DO i = 1, nl ! cld
-    DO il = 1, ncum ! cld
-      IF (i>=icb(il) .AND. i<=(inb(il)-1) & ! cld
-          .AND. sax(il,i)>0.0 .AND. iflag(il)<=1) THEN ! cld
-        wa(il, i) = sqrt(2.*sax(il,i)) ! cld
-      END IF ! cld
-    END DO ! cld
-  END DO ! cld
-
-  DO i = 1, nl ! cld
-    DO il = 1, ncum ! cld
-      IF (wa(il,i)>0.0 .AND. iflag(il)<=1) & ! cld
-        siga(il, i) = mac(il, i)/wa(il, i) & ! cld
-        *rrd*tvp(il, i)/p(il, i)/100./delta ! cld
-      siga(il, i) = min(siga(il,i), 1.0) ! cld
-      ! IM cf. FH
-      IF (iflag_clw==0) THEN
-        qcondc(il, i) = siga(il, i)*clw(il, i)*(1.-ep(il,i)) & ! cld
-          +(1.-siga(il,i))*qcond(il, i) ! cld
-      ELSE IF (iflag_clw==1) THEN
-        qcondc(il, i) = qcond(il, i) ! cld
-      END IF
-
-    END DO ! cld
-  END DO
-  ! print*,'cv3_yield fin'
-    ! cld
+          mac(il, i) = mac(il, i) + m(il, k)                         ! cld
+        END IF                                                       ! cld
+      END DO                                                         ! cld
+    END DO                                                           ! cld
+  END DO                                                             ! cld
+
+  DO i = 1, nl                                                       ! cld
+    DO j = 1, i                                                      ! cld
+      DO il = 1, ncum                                                ! cld
+        IF (i>=icb(il) .AND. i<=(inb(il)-1) &                        ! cld
+            .AND. j>=icb(il) .AND. iflag(il)<=1) THEN                ! cld
+          sax(il, i) = sax(il, i) + rrd*(tvp(il,j)-tv(il,j)) &       ! cld
+            *(ph(il,j)-ph(il,j+1))/p(il, j)                          ! cld
+        END IF                                                       ! cld
+      END DO                                                         ! cld
+    END DO                                                           ! cld
+  END DO                                                             ! cld
+
+  DO i = 1, nl                                                       ! cld
+    DO il = 1, ncum                                                  ! cld
+      IF (i>=icb(il) .AND. i<=(inb(il)-1) &                          ! cld
+          .AND. sax(il,i)>0.0 .AND. iflag(il)<=1) THEN               ! cld
+        wa(il, i) = sqrt(2.*sax(il,i))                               ! cld
+      END IF                                                         ! cld
+    END DO                                                           ! cld
+  END DO                                                             ! cld
+
+  DO i = 1, nl                                                       ! cld
+    DO il = 1, ncum                                                  ! cld
+      IF (wa(il,i)>0.0 .AND. iflag(il)<=1) &                         ! cld
+        siga(il, i) = mac(il, i)/wa(il, i) &                         ! cld
+        *rrd*tvp(il, i)/p(il, i)/100./delta                          ! cld
+      siga(il, i) = min(siga(il,i), 1.0)                             ! cld
+! IM cf. FH                                                          
+      IF (iflag_clw==0) THEN                                         ! cld
+        qcondc(il, i) = siga(il, i)*clw(il, i)*(1.-ep(il,i)) &       ! cld
+          +(1.-siga(il,i))*qcond(il, i)                              ! cld
+      ELSE IF (iflag_clw==1) THEN                                    ! cld
+        qcondc(il, i) = qcond(il, i)                                 ! cld
+      END IF                                                         ! cld
+
+    END DO                                                           ! cld
+  END DO
+! print*,'cv3_yield fin'
+
   RETURN
 END SUBROUTINE cv3_yield
 
-! AC! et !RomP >>>
-SUBROUTINE cv3_tracer(nloc, len, ncum, nd, na, ment, sigij, da, phi, phi2, &
-    d1a, dam, ep, vprecip, elij, clw, epmlmmm, eplamm, icb, inb)
+!AC! et !RomP >>>
+SUBROUTINE cv3_tracer(nloc, len, ncum, nd, na, &
+                      ment, sigij, da, phi, phi2, d1a, dam, &
+                      ep, Vprecip, elij, clw, epmlmMm, eplaMm, &
+                      icb, inb)
   IMPLICIT NONE
 
   include "cv3param.h"
 
-  ! inputs:
+!inputs:
   INTEGER ncum, nd, na, nloc, len
   REAL ment(nloc, na, na), sigij(nloc, na, na)
@@ -3886,23 +3809,23 @@
   REAL ep(nloc, na)
   INTEGER icb(nloc), inb(nloc)
-  REAL vprecip(nloc, nd+1)
-  ! ouputs:
+  REAL Vprecip(nloc, nd+1)
+!ouputs:
   REAL da(nloc, na), phi(nloc, na, na)
   REAL phi2(nloc, na, na)
   REAL d1a(nloc, na), dam(nloc, na)
-  REAL epmlmmm(nloc, na, na), eplamm(nloc, na)
-  ! variables pour tracer dans precip de l'AA et des mel
-  ! local variables:
+  REAL epmlmMm(nloc, na, na), eplaMm(nloc, na)
+! variables pour tracer dans precip de l'AA et des mel
+!local variables:
   INTEGER i, j, k
   REAL epm(nloc, na, na)
 
-  ! variables d'Emanuel : du second indice au troisieme
-  ! --->    tab(i,k,j) -> de l origine k a l arrivee j
-  ! ment, sigij, elij
-  ! variables personnelles : du troisieme au second indice
-  ! --->    tab(i,j,k) -> de k a j
-  ! phi, phi2
-
-  ! initialisations
+! variables d'Emanuel : du second indice au troisieme
+! --->    tab(i,k,j) -> de l origine k a l arrivee j
+! ment, sigij, elij
+! variables personnelles : du troisieme au second indice
+! --->    tab(i,j,k) -> de k a j
+! phi, phi2
+
+! initialisations
 
   da(:, :) = 0.
@@ -3910,20 +3833,20 @@
   dam(:, :) = 0.
   epm(:, :, :) = 0.
-  eplamm(:, :) = 0.
-  epmlmmm(:, :, :) = 0.
+  eplaMm(:, :) = 0.
+  epmlmMm(:, :, :) = 0.
   phi(:, :, :) = 0.
   phi2(:, :, :) = 0.
 
-  ! fraction deau condensee dans les melanges convertie en precip : epm
-  ! et eau condensée précipitée dans masse d'air saturé : l_m*dM_m/dzdz.dzdz
+! fraction deau condensee dans les melanges convertie en precip : epm
+! et eau condensée précipitée dans masse d'air saturé : l_m*dM_m/dzdz.dzdz
   DO j = 1, na
     DO k = 1, na
       DO i = 1, ncum
-        IF (k>=icb(i) .AND. k<=inb(i) .AND. & ! !jyg     &
-                                              ! j.ge.k.and.j.le.inb(i)) then
-          ! !jyg             epm(i,j,k)=1.-(1.-ep(i,j))*clw(i,j)/elij(i,k,j)
+        IF (k>=icb(i) .AND. k<=inb(i) .AND. & 
+!!jyg              j.ge.k.and.j.le.inb(i)) then
+!!jyg             epm(i,j,k)=1.-(1.-ep(i,j))*clw(i,j)/elij(i,k,j)
             j>k .AND. j<=inb(i)) THEN
           epm(i, j, k) = 1. - (1.-ep(i,j))*clw(i, j)/max(elij(i,k,j), 1.E-16)
-          ! !
+!!
           epm(i, j, k) = max(epm(i,j,k), 0.0)
         END IF
@@ -3937,6 +3860,6 @@
       DO i = 1, ncum
         IF (k>=icb(i) .AND. k<=inb(i)) THEN
-          eplamm(i, j) = eplamm(i, j) + ep(i, j)*clw(i, j)*ment(i, j, k)*(1.- &
-            sigij(i,j,k))
+          eplaMm(i, j) = eplamm(i, j) + &
+                         ep(i, j)*clw(i, j)*ment(i, j, k)*(1.-sigij(i,j,k))
         END IF
       END DO
@@ -3948,5 +3871,5 @@
       DO i = 1, ncum
         IF (k>=icb(i) .AND. k<=inb(i) .AND. j<=inb(i)) THEN
-          epmlmmm(i, j, k) = epm(i, j, k)*elij(i, k, j)*ment(i, k, j)
+          epmlmMm(i, j, k) = epm(i, j, k)*elij(i, k, j)*ment(i, k, j)
         END IF
       END DO
@@ -3954,5 +3877,5 @@
   END DO
 
-  ! matrices pour calculer la tendance des concentrations dans cvltr.F90
+! matrices pour calculer la tendance des concentrations dans cvltr.F90
   DO j = 1, na
     DO k = 1, na
@@ -3962,7 +3885,5 @@
         d1a(i, j) = d1a(i, j) + ment(i, k, j)*ep(i, k)*(1.-sigij(i,k,j))
         IF (k<=j) THEN
-          dam(i, j) = dam(i, j) + ment(i, k, j)*epm(i, k, j)*(1.-ep(i,k))*(1. &
-            -sigij(i,k,j))
-
+          dam(i, j) = dam(i, j) + ment(i, k, j)*epm(i, k, j)*(1.-ep(i,k))*(1.-sigij(i,k,j))
           phi2(i, j, k) = phi(i, j, k)*epm(i, j, k)
         END IF
@@ -3973,15 +3894,20 @@
   RETURN
 END SUBROUTINE cv3_tracer
-! AC! et !RomP <<<
-
-SUBROUTINE cv3_uncompress(nloc, len, ncum, nd, ntra, idcum, iflag, precip, &
-    sig, w0, ft, fq, fu, fv, ftra, ma, upwd, dnwd, dnwd0, qcondc, wd, cape, &
-    iflag1, precip1, sig1, w01, ft1, fq1, fu1, fv1, ftra1, ma1, upwd1, dnwd1, &
-    dnwd01, qcondc1, wd1, cape1)
+!AC! et !RomP <<<
+
+SUBROUTINE cv3_uncompress(nloc, len, ncum, nd, ntra, idcum, &
+                          iflag, &
+                          precip, sig, w0, &
+                          ft, fq, fu, fv, ftra, &
+                          Ma, upwd, dnwd, dnwd0, qcondc, wd, cape, &
+                          iflag1, &
+                          precip1, sig1, w01, &
+                          ft1, fq1, fu1, fv1, ftra1, &
+                          Ma1, upwd1, dnwd1, dnwd01, qcondc1, wd1, cape1)
   IMPLICIT NONE
 
   include "cv3param.h"
 
-  ! inputs:
+!inputs:
   INTEGER len, ncum, nd, ntra, nloc
   INTEGER idcum(nloc)
@@ -3996,5 +3922,5 @@
   REAL wd(nloc), cape(nloc)
 
-  ! outputs:
+!outputs:
   INTEGER iflag1(len)
   REAL precip1(len)
@@ -4007,5 +3933,5 @@
   REAL wd1(nloc), cape1(nloc)
 
-  ! local variables:
+!local variables:
   INTEGER i, k, j
 
@@ -4038,12 +3964,13 @@
 
 
-  ! AC!        do 2100 j=1,ntra
-  ! AC!c oct3         do 2110 k=1,nl
-  ! AC!         do 2110 k=1,nd ! oct3
-  ! AC!          do 2120 i=1,ncum
-  ! AC!            ftra1(idcum(i),k,j)=ftra(i,k,j)
-  ! AC! 2120     continue
-  ! AC! 2110    continue
-  ! AC! 2100   continue
+!AC!        do 2100 j=1,ntra
+!AC!c oct3         do 2110 k=1,nl
+!AC!         do 2110 k=1,nd ! oct3
+!AC!          do 2120 i=1,ncum
+!AC!            ftra1(idcum(i),k,j)=ftra(i,k,j)
+!AC! 2120     continue
+!AC! 2110    continue
+!AC! 2100   continue
+!
   RETURN
 END SUBROUTINE cv3_uncompress
Index: /LMDZ5/branches/testing/libf/phylmd/cv3_vertmix.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/cv3_vertmix.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/cv3_vertmix.F90	(revision 2056)
@@ -1,4 +1,5 @@
-SUBROUTINE cv3_vertmix(len, nd, iflag, plim1, plim2, p, ph, t, q, u, v, w, &
-    wi, nk, tmix, thmix, qmix, qsmix, umix, vmix, plcl)
+SUBROUTINE cv3_vertmix(len, nd, iflag, plim1, plim2, p, ph, &
+                       t, q, u, v, w, &
+                       wi, nk, tmix, thmix, qmix, qsmix, umix, vmix, plcl)
   ! **************************************************************
   ! *
@@ -13,6 +14,9 @@
   ! ==============================================================
 
-  ! vertmix : determine theta et r du melange obtenu en brassant
-  ! adiabatiquement entre plim1 et plim2, avec une ponderation w.
+  ! vertmix : determines theta, t, q, qs, u and v of the mixture generated by
+  ! adiabatic mixing of air between plim1 and plim2 with weighting w.
+  ! If plim1 and plim2 fall within the same model layer, then theta, ... v
+  ! are those of that layer.
+  ! A minimum value (dpmin) is imposed upon plim1-plim2
 
   ! ===============================================================
@@ -22,32 +26,47 @@
   include "YOMCST.h"
   include "FCTTRE.h"
-  ! input :
-  INTEGER nd, len
-  INTEGER nk(len), iflag(len)
-  REAL t(len, nd), q(len, nd), w(nd)
-  REAL u(len, nd), v(len, nd)
-  REAL p(len, nd), ph(len, nd+1)
-  REAL plim1(len), plim2(len)
-  ! output :
-  REAL tmix(len), thmix(len), qmix(len), wi(len, nd)
-  REAL umix(len), vmix(len)
-  REAL qsmix(len)
-  REAL plcl(len)
-  ! internal variables :
-  INTEGER j1(len), j2(len), niflag7
-  REAL a, b
-  REAL ahm(len), dpw(len), coef(len)
-  REAL p1(len, nd), p2(len, nd)
-  REAL rdcp(len), a2(len), b2(len), pnk(len)
-  REAL rh(len), chi(len)
-  REAL cpn
-  REAL x, y, p0, p0m1, zdelta, zcor
-
+!inputs:
+  INTEGER, INTENT (IN)                      ::  nd, len
+  INTEGER, DIMENSION (len), INTENT (IN)     ::  nk
+  REAL, DIMENSION (nd), INTENT (IN)        ::  w
+  REAL, DIMENSION (len), INTENT (IN)        :: plim1, plim2
+  REAL, DIMENSION (len,nd), INTENT (IN)     :: t, q
+  REAL, DIMENSION (len,nd), INTENT (IN)     :: u, v
+  REAL, DIMENSION (len,nd), INTENT (IN)     :: p
+  REAL, DIMENSION (len,nd+1), INTENT (IN)   :: ph
+!input/output:
+  INTEGER, DIMENSION (len), INTENT (INOUT)  ::  iflag
+!outputs:
+  REAL, DIMENSION (len), INTENT (OUT)       :: tmix, thmix, qmix
+  REAL, DIMENSION (len), INTENT (OUT)       :: umix, vmix
+  REAL, DIMENSION (len), INTENT (OUT)       :: qsmix
+  REAL, DIMENSION (len), INTENT (OUT)       :: plcl
+  REAL, DIMENSION (len,nd), INTENT (OUT)    :: wi
+!internal variables :
   INTEGER i, j
-
+  INTEGER niflag7
+  INTEGER, DIMENSION(len)                   :: j1, j2
+  REAL                                      :: a, b
+  REAL                                      :: cpn
+  REAL                                      :: x, y, p0, p0m1, zdelta, zcor
+  REAL                                      :: dpmin=1.
+!$OMP THREADPRIVATE(dpmin)
+  REAL, DIMENSION(len)                      :: plim2p  ! = min(plim2(:),plim1(:)-dpmin)
+  REAL, DIMENSION(len)                      :: ahm, dpw, coef
+  REAL, DIMENSION(len)                      :: rdcp, a2, b2, pnk
+  REAL, DIMENSION(len)                      :: rh, chi
+  REAL, DIMENSION(len)                      :: eqwght
+  REAL, DIMENSION(len,nd)                   :: p1, p2
+
+
+!!  print *,' ->cv3_vertmix, plim1,plim2 ', plim1,plim2   !jyg
+  plim2p(:) = min(plim2(:),plim1(:)-dpmin)
+  j1(:)=nd
+  j2(:) = 0
   DO j = 1, nd
     DO i = 1, len
       IF (plim1(i)<=ph(i,j)) j1(i) = j
-      IF (plim2(i)>=ph(i,j+1) .AND. plim2(i)<ph(i,j)) j2(i) = j
+!!!      IF (plim2p(i)>=ph(i,j+1) .AND. plim2p(i)<ph(i,j)) j2(i) = j
+      IF (plim2p(i)< ph(i,j)) j2(i) = j
     END DO
   END DO
@@ -68,4 +87,5 @@
     pnk(i) = p(i, nk(i))
   END DO
+  eqwght(:) = 0.
 
   p0 = 1000.
@@ -73,6 +93,13 @@
 
   DO i = 1, len
-    coef(i) = 1./(plim1(i)-plim2(i))
-  END DO
+    IF (j2(i) < j1(i)) THEN
+      coef(i) = 1.
+      eqwght(i) = 1.
+    ELSE
+      coef(i) = 1./(plim1(i)-plim2p(i))
+    ENDIF
+  END DO
+
+!!  print *,'cv3_vertmix, j1,j2,coef ', j1,j2,coef  !jyg
 
   DO j = 1, nd
@@ -80,16 +107,20 @@
       IF (j>=j1(i) .AND. j<=j2(i)) THEN
         p1(i, j) = min(ph(i,j), plim1(i))
-        p2(i, j) = max(ph(i,j+1), plim2(i))
+        p2(i, j) = max(ph(i,j+1), plim2p(i))
         ! CRtest:couplage thermiques: deja normalise
         ! wi(i,j) = w(j)
         ! print*,'wi',wi(i,j)
-        wi(i, j) = w(j)*(p1(i,j)-p2(i,j))*coef(i)
+        wi(i, j) = w(j)*(p1(i,j)-p2(i,j))*coef(i)+eqwght(i)
         dpw(i) = dpw(i) + wi(i, j)
+
+!!  print *,'cv3_vertmix, j, wi(1,j),dpw ', j, wi(1,j),dpw  !jyg
+
       END IF
     END DO
   END DO
+
   ! CR:print
   ! do i=1,len
-  ! print*,'plim',plim1(i),plim2(i)
+  ! print*,'plim',plim1(i),plim2p(i)
   ! enddo
   DO j = 1, nd
@@ -108,4 +139,7 @@
     rdcp(i) = (rrd*(1.-qmix(i))+qmix(i)*rrv)/(cpd*(1.-qmix(i))+qmix(i)*cpv)
   END DO
+
+
+!!  print *,'cv3_vertmix, rdcp ', rdcp  !jyg
 
 
@@ -159,11 +193,11 @@
       rh(i) = max(rh(i), 0.)
       plcl(i) = pnk(i)*(rh(i)**chi(i))
-      IF (((plcl(i)<200.0) .OR. (plcl(i)>=2000.0)) .AND. (iflag(i)==0)) iflag &
-        (i) = 8
+      IF (((plcl(i)<200.0) .OR. (plcl(i)>=2000.0)) .AND. (iflag(i)==0)) &
+          iflag(i) = 8
 
     ELSE
 
       niflag7 = niflag7 + 1
-      plcl(i) = plim2(i)
+      plcl(i) = plim2p(i)
 
     END IF ! iflag=7
@@ -172,4 +206,7 @@
 
   END DO
+
+!!  print *,' cv3_vertmix->'  !jyg
+
 
   RETURN
Index: /LMDZ5/branches/testing/libf/phylmd/cv3p_mixing.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/cv3p_mixing.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/cv3p_mixing.F90	(revision 2056)
@@ -1,13 +1,15 @@
-SUBROUTINE cv3p_mixing(nloc, ncum, nd, na, ntra, icb, nk, inb, ph, t, rr, rs, &
-    u, v, tra, h, lv, qnk, unk, vnk, hp, tv, tvp, ep, clw, sig, ment, qent, &
-    hent, uent, vent, nent, sigij, elij, supmax, ments, qents, traent)
-  ! **************************************************************
-  ! *
-  ! CV3P_MIXING : compute mixed draught properties and,         *
-  ! within a scaling factor, mixed draught        *
-  ! mass fluxes.                                  *
-  ! written by  : VTJ Philips,JY Grandpeix, 21/05/2003, 09.14.15*
-  ! modified by :                                               *
-  ! **************************************************************
+SUBROUTINE cv3p_mixing(nloc, ncum, nd, na, ntra, icb, nk, inb, &
+                       ph, t, rr, rs, u, v, tra, h, lv, qnk, &
+                       unk, vnk, hp, tv, tvp, ep, clw, sig, &
+                       Ment, Qent, hent, uent, vent, nent, &
+                       Sigij, elij, supmax, Ments, Qents, traent)
+! **************************************************************
+! *
+! CV3P_MIXING : compute mixed draught properties and,         *
+! within a scaling factor, mixed draught        *
+! mass fluxes.                                  *
+! written by  : VTJ Philips,JY Grandpeix, 21/05/2003, 09.14.15*
+! modified by :                                               *
+! **************************************************************
 
   IMPLICIT NONE
@@ -17,112 +19,114 @@
   include "YOMCST2.h"
 
-  ! inputs:
-  INTEGER ncum, nd, na, ntra, nloc
-  INTEGER icb(nloc), inb(nloc), nk(nloc)
-  REAL sig(nloc, nd)
-  REAL qnk(nloc), unk(nloc), vnk(nloc)
-  REAL ph(nloc, nd+1)
-  REAL t(nloc, nd), rr(nloc, nd), rs(nloc, nd)
-  REAL u(nloc, nd), v(nloc, nd)
-  REAL tra(nloc, nd, ntra) ! input of convect3
-  REAL lv(nloc, na)
-  REAL h(nloc, na) !liquid water static energy of environment
-  REAL hp(nloc, na) !liquid water static energy of air shed from adiab. asc.
-  REAL tv(nloc, na), tvp(nloc, na), ep(nloc, na), clw(nloc, na)
-
-  ! outputs:
-  REAL ment(nloc, na, na), qent(nloc, na, na)
-  REAL uent(nloc, na, na), vent(nloc, na, na)
-  REAL sigij(nloc, na, na), elij(nloc, na, na)
-  REAL supmax(nloc, na) ! Highest mixing fraction of mixed updraughts
-    ! with the sign of (h-hp)
-  REAL traent(nloc, nd, nd, ntra)
-  REAL ments(nloc, nd, nd), qents(nloc, nd, nd)
-  REAL hent(nloc, nd, nd)
-  INTEGER nent(nloc, nd)
-
-  ! local variables:
+!inputs:
+  INTEGER, INTENT (IN)                               :: ncum, nd, na
+  INTEGER, INTENT (IN)                               :: ntra, nloc
+  INTEGER, DIMENSION (nloc), INTENT (IN)             :: icb, inb, nk
+  REAL, DIMENSION (nloc, nd), INTENT (IN)            :: sig
+  REAL, DIMENSION (nloc), INTENT (IN)                :: qnk, unk, vnk
+  REAL, DIMENSION (nloc, nd+1), INTENT (IN)          :: ph
+  REAL, DIMENSION (nloc, nd), INTENT (IN)            :: t, rr, rs
+  REAL, DIMENSION (nloc, nd), INTENT (IN)            :: u, v
+  REAL, DIMENSION (nloc, nd, ntra), INTENT (IN)      :: tra ! input of convect3
+  REAL, DIMENSION (nloc, na), INTENT (IN)            :: lv
+  REAL, DIMENSION (nloc, na), INTENT (IN)            :: h  !liquid water static energy of environMent
+  REAL, DIMENSION (nloc, na), INTENT (IN)            :: hp !liquid water static energy of air shed from adiab. asc.
+  REAL, DIMENSION (nloc, na), INTENT (IN)            :: tv, tvp
+  REAL, DIMENSION (nloc, na), INTENT (IN)            :: ep, clw
+
+!outputs:
+  REAL, DIMENSION (nloc, na, na), INTENT (OUT)       :: Ment, Qent
+  REAL, DIMENSION (nloc, na, na), INTENT (OUT)       :: uent, vent
+  REAL, DIMENSION (nloc, na, na), INTENT (OUT)       :: Sigij, elij
+  REAL, DIMENSION (nloc, na), INTENT (OUT)           :: supmax(nloc, na) ! Highest mixing fraction of mixed
+                                                                         ! updraughts with the sign of (h-hp)
+  REAL, DIMENSION (nloc, nd, nd, ntra), INTENT (OUT) :: traent
+  REAL, DIMENSION (nloc, nd, nd), INTENT (OUT)       :: Ments, Qents
+  REAL, DIMENSION (nloc, nd, nd), INTENT (OUT)       :: hent
+  INTEGER, DIMENSION (nloc, nd), INTENT (OUT)        :: nent
+
+!local variables:
   INTEGER i, j, k, il, im, jm
   INTEGER num1, num2
-  REAL rti, bf2, anum, denom, dei, altem, cwat, stemp, qp
-  REAL alt, delp, delm
-  REAL qmixmax(nloc), rmixmax(nloc), sqmrmax(nloc)
-  REAL qmixmin(nloc), rmixmin(nloc), sqmrmin(nloc)
-  REAL signhpmh(nloc)
-  REAL sx(nloc), scrit2
-  REAL smid(nloc), sjmin(nloc), sjmax(nloc)
-  REAL sbef(nloc), sup(nloc), smin(nloc)
-  REAL asij(nloc), smax(nloc), scrit(nloc)
-  REAL sij(nloc, nd, nd)
-  REAL csum(nloc, nd)
-  REAL awat
-  LOGICAL lwork(nloc)
+  REAL                               :: rti, bf2, anum, denom, dei, altem, cwat, stemp, qp
+  REAL                               :: alt, delp, delm
+  REAL, DIMENSION (nloc)             :: Qmixmax, Rmixmax, sqmrmax
+  REAL, DIMENSION (nloc)             :: Qmixmin, Rmixmin, sqmrmin
+  REAL, DIMENSION (nloc)             :: signhpmh
+  REAL, DIMENSION (nloc)             :: Sx
+  REAL                               :: Scrit2
+  REAL, DIMENSION (nloc)             :: Smid, Sjmin, Sjmax
+  REAL, DIMENSION (nloc)             :: Sbef, sup, smin
+  REAL, DIMENSION (nloc)             :: ASij, smax, Scrit
+  REAL, DIMENSION (nloc, nd, nd)     :: Sij
+  REAL, DIMENSION (nloc, nd)         :: csum
+  REAL                               :: awat
+  LOGICAL, DIMENSION (nloc)          :: lwork
 
   REAL amxupcrit, df, ff
   INTEGER nstep
 
-  ! --   Mixing probability distribution functions
-
-  REAL qcoef1, qcoef2, qff, qfff, qmix, rmix, qmix1, rmix1, qmix2, rmix2, f
-
-  qcoef1(f) = tanh(f/gammas)
-  qcoef2(f) = (tanh(f/gammas)+gammas*log(cosh((1.-f)/gammas)/cosh(f/gammas)))
-  qff(f) = max(min(f,1.), 0.)
-  qfff(f) = min(qff(f), scut)
-  qmix1(f) = (tanh((qff(f)-fmax)/gammas)+qcoef1max)/qcoef2max
-  rmix1(f) = (gammas*log(cosh((qff(f)-fmax)/gammas))+qff(f)*qcoef1max)/ &
-    qcoef2max
-  qmix2(f) = -log(1.-qfff(f))/scut
-  rmix2(f) = (qfff(f)+(1.-qff(f))*log(1.-qfff(f)))/scut
-  qmix(f) = qqa1*qmix1(f) + qqa2*qmix2(f)
-  rmix(f) = qqa1*rmix1(f) + qqa2*rmix2(f)
+! --   Mixing probability distribution functions
+
+  REAL Qcoef1, Qcoef2, QFF, QFFF, Qmix, Rmix, Qmix1, Rmix1, Qmix2, Rmix2, F
+
+  Qcoef1(F) = tanh(F/gammas)
+  Qcoef2(F) = (tanh(F/gammas)+gammas*log(cosh((1.-F)/gammas)/cosh(F/gammas)))
+  QFF(F) = max(min(F,1.), 0.)
+  QFFf(F) = min(QFF(F), scut)
+  Qmix1(F) = (tanh((QFF(F)-Fmax)/gammas)+Qcoef1max)/Qcoef2max
+  Rmix1(F) = (gammas*log(cosh((QFF(F)-Fmax)/gammas))+QFF(F)*Qcoef1max)/Qcoef2max
+  Qmix2(F) = -log(1.-QFFf(F))/scut
+  Rmix2(F) = (QFFf(F)+(1.-QFF(F))*log(1.-QFFf(F)))/scut
+  Qmix(F) = qqa1*Qmix1(F) + qqa2*Qmix2(F)
+  Rmix(F) = qqa1*Rmix1(F) + qqa2*Rmix2(F)
 
   INTEGER, SAVE :: ifrst
   DATA ifrst/0/
-  !$OMP THREADPRIVATE(ifrst)
-
-
-  ! =====================================================================
-  ! --- INITIALIZE VARIOUS ARRAYS USED IN THE COMPUTATIONS
-  ! =====================================================================
-
-  ! -- Initialize mixing PDF coefficients
+!$OMP THREADPRIVATE(ifrst)
+
+
+! =====================================================================
+! --- INITIALIZE VARIOUS ARRAYS USED IN THE COMPUTATIONS
+! =====================================================================
+
+! -- Initialize mixing PDF coefficients
   IF (ifrst==0) THEN
     ifrst = 1
-    qcoef1max = qcoef1(fmax)
-    qcoef2max = qcoef2(fmax)
+    Qcoef1max = Qcoef1(Fmax)
+    Qcoef2max = Qcoef2(Fmax)
 
   END IF
 
 
-  ! ori        do 360 i=1,ncum*nlp
+! ori        do 360 i=1,ncum*nlp
   DO j = 1, nl
     DO i = 1, ncum
       nent(i, j) = 0
-      ! in convect3, m is computed in cv3_closure
-      ! ori          m(i,1)=0.0
-    END DO
-  END DO
-
-  ! ori      do 400 k=1,nlp
-  ! ori       do 390 j=1,nlp
+! in convect3, m is computed in cv3_closure
+! ori          m(i,1)=0.0
+    END DO
+  END DO
+
+! ori      do 400 k=1,nlp
+! ori       do 390 j=1,nlp
   DO j = 1, nl
     DO k = 1, nl
       DO i = 1, ncum
-        qent(i, k, j) = rr(i, j)
+        Qent(i, k, j) = rr(i, j)
         uent(i, k, j) = u(i, j)
         vent(i, k, j) = v(i, j)
         elij(i, k, j) = 0.0
         hent(i, k, j) = 0.0
-        ! AC!            ment(i,k,j)=0.0
-        ! AC!            sij(i,k,j)=0.0
-      END DO
-    END DO
-  END DO
-
-  ! AC!
-  ment(1:ncum, 1:nd, 1:nd) = 0.0
-  sij(1:ncum, 1:nd, 1:nd) = 0.0
-  ! AC!
+!AC!            Ment(i,k,j)=0.0
+!AC!            Sij(i,k,j)=0.0
+      END DO
+    END DO
+  END DO
+
+!AC!
+  Ment(1:ncum, 1:nd, 1:nd) = 0.0
+  Sij(1:ncum, 1:nd, 1:nd) = 0.0
+!AC!
 
   DO k = 1, ntra
@@ -136,9 +140,9 @@
   END DO
 
-  ! =====================================================================
-  ! --- CALCULATE ENTRAINED AIR MASS FLUX (ment), TOTAL WATER MIXING
-  ! --- RATIO (QENT), TOTAL CONDENSED WATER (elij), AND MIXING
-  ! --- FRACTION (sij)
-  ! =====================================================================
+! =====================================================================
+! --- CALCULATE ENTRAINED AIR MASS FLUX (Ment), TOTAL WATER MIXING
+! --- RATIO (QENT), TOTAL CONDENSED WATER (elij), AND MIXING
+! --- FRACTION (Sij)
+! =====================================================================
 
   DO i = minorig + 1, nl
@@ -146,6 +150,6 @@
     DO j = minorig, nl
       DO il = 1, ncum
-        IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. (j>=(icb(il)- &
-            1)) .AND. (j<=inb(il))) THEN
+        IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. (j>=(icb(il)-1)) &
+                         .AND. (j<=inb(il))) THEN
 
           rti = qnk(il) - ep(il, i)*clw(il, i)
@@ -155,22 +159,21 @@
           dei = denom
           IF (abs(dei)<0.01) dei = 0.01
-          sij(il, i, j) = anum/dei
-          sij(il, i, i) = 1.0
-          altem = sij(il, i, j)*rr(il, i) + (1.-sij(il,i,j))*rti - rs(il, j)
+          Sij(il, i, j) = anum/dei
+          Sij(il, i, i) = 1.0
+          altem = Sij(il, i, j)*rr(il, i) + (1.-Sij(il,i,j))*rti - rs(il, j)
           altem = altem/bf2
           cwat = clw(il, j)*(1.-ep(il,j))
-          stemp = sij(il, i, j)
+          stemp = Sij(il, i, j)
           IF ((stemp<0.0 .OR. stemp>1.0 .OR. altem>cwat) .AND. j>i) THEN
             anum = anum - lv(il, j)*(rti-rs(il,j)-cwat*bf2)
             denom = denom + lv(il, j)*(rr(il,i)-rti)
             IF (abs(denom)<0.01) denom = 0.01
-            sij(il, i, j) = anum/denom
-            altem = sij(il, i, j)*rr(il, i) + (1.-sij(il,i,j))*rti - &
-              rs(il, j)
+            Sij(il, i, j) = anum/denom
+            altem = Sij(il, i, j)*rr(il, i) + (1.-Sij(il,i,j))*rti - rs(il, j)
             altem = altem - (bf2-1.)*cwat
           END IF
-          IF (sij(il,i,j)>0.0) THEN
-            ! cc                 ment(il,i,j)=m(il,i)
-            ment(il, i, j) = 1.
+          IF (Sij(il,i,j)>0.0) THEN
+!!!                 Ment(il,i,j)=m(il,i)
+            Ment(il, i, j) = 1.
             elij(il, i, j) = altem
             elij(il, i, j) = amax1(0.0, elij(il,i,j))
@@ -178,6 +181,6 @@
           END IF
 
-          sij(il, i, j) = amax1(0.0, sij(il,i,j))
-          sij(il, i, j) = amin1(1.0, sij(il,i,j))
+          Sij(il, i, j) = amax1(0.0, Sij(il,i,j))
+          Sij(il, i, j) = amin1(1.0, Sij(il,i,j))
         END IF ! new
       END DO
@@ -185,22 +188,20 @@
 
 
-    ! ***   if no air can entrain at level i assume that updraft detrains
-    ! ***
-    ! ***   at that level and calculate detrained air flux and properties
-    ! ***
-
-
-    ! @      do 170 i=icb(il),inb(il)
+! ***   if no air can entrain at level i assume that updraft detrains  ***
+! ***   at that level and calculate detrained air flux and properties  ***
+
+
+! @      do 170 i=icb(il),inb(il)
 
     DO il = 1, ncum
       IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. (nent(il,i)==0)) THEN
-        ! @      if(nent(il,i).eq.0)then
-        ! cc      ment(il,i,i)=m(il,i)
-        ment(il, i, i) = 1.
-        qent(il, i, i) = qnk(il) - ep(il, i)*clw(il, i)
+! @      if(nent(il,i).eq.0)then
+!!!       Ment(il,i,i)=m(il,i)
+        Ment(il, i, i) = 1.
+        Qent(il, i, i) = qnk(il) - ep(il, i)*clw(il, i)
         uent(il, i, i) = unk(il)
         vent(il, i, i) = vnk(il)
         elij(il, i, i) = clw(il, i)*(1.-ep(il,i))
-        sij(il, i, i) = 0.0
+        Sij(il, i, i) = 0.0
       END IF
     END DO
@@ -220,19 +221,19 @@
     DO i = minorig, nl
       DO il = 1, ncum
-        IF ((j>=(icb(il)-1)) .AND. (j<=inb(il)) .AND. (i>=icb(il)) .AND. (i<= &
-            inb(il))) THEN
-          sigij(il, i, j) = sij(il, i, j)
-        END IF
-      END DO
-    END DO
-  END DO
-  ! @      enddo
-
-  ! @170   continue
-
-  ! =====================================================================
-  ! ---  NORMALIZE ENTRAINED AIR MASS FLUXES
-  ! ---  TO REPRESENT EQUAL PROBABILITIES OF MIXING
-  ! =====================================================================
+        IF ((j>=(icb(il)-1)) .AND. (j<=inb(il)) .AND. &
+            (i>=icb(il)) .AND. (i<=inb(il))) THEN
+          Sigij(il, i, j) = Sij(il, i, j)
+        END IF
+      END DO
+    END DO
+  END DO
+! @      enddo
+
+! @170   continue
+
+! =====================================================================
+! ---  NORMALIZE ENTRAINED AIR MASS FLUXES
+! ---  TO REPRESENT EQUAL PROBABILITIES OF MIXING
+! =====================================================================
 
   CALL zilch(csum, nloc*nd)
@@ -242,7 +243,7 @@
   END DO
 
-  ! ---------------------------------------------------------------
-  DO i = minorig + 1, nl !Loop on origin level "i"
-    ! ---------------------------------------------------------------
+! ---------------------------------------------------------------
+  DO i = minorig + 1, nl      !Loop on origin level "i"
+! ---------------------------------------------------------------
 
     num1 = 0
@@ -253,12 +254,12 @@
 
 
-    ! jyg1    Find maximum of SIJ for J>I, if any.
-
-    sx(:) = 0.
+!JYG1    Find maximum of SIJ for J>I, if any.
+
+    Sx(:) = 0.
 
     DO il = 1, ncum
       IF (i>=icb(il) .AND. i<=inb(il)) THEN
         signhpmh(il) = sign(1., hp(il,i)-h(il,i))
-        sbef(il) = max(0., signhpmh(il))
+        Sbef(il) = max(0., signhpmh(il))
       END IF
     END DO
@@ -267,8 +268,8 @@
       DO il = 1, ncum
         IF (i>=icb(il) .AND. i<=inb(il) .AND. j<=inb(il)) THEN
-          IF (sbef(il)<sij(il,i,j)) THEN
-            sx(il) = max(sij(il,i,j), sx(il))
-          END IF
-          sbef(il) = sij(il, i, j)
+          IF (Sbef(il)<Sij(il,i,j)) THEN
+            Sx(il) = max(Sij(il,i,j), Sx(il))
+          END IF
+          Sbef(il) = Sij(il, i, j)
         END IF
       END DO
@@ -279,172 +280,169 @@
       IF (i>=icb(il) .AND. i<=inb(il)) THEN
         lwork(il) = (nent(il,i)/=0)
-        qp = qnk(il) - ep(il, i)*clw(il, i)
-        anum = h(il, i) - hp(il, i) - lv(il, i)*(qp-rs(il,i)) + &
-          (cpv-cpd)*t(il, i)*(qp-rr(il,i))
-        denom = h(il, i) - hp(il, i) + lv(il, i)*(rr(il,i)-qp) + &
-          (cpd-cpv)*t(il, i)*(rr(il,i)-qp)
+        rti = qnk(il) - ep(il, i)*clw(il, i)
+        anum = h(il, i) - hp(il, i) - lv(il, i)*(rti-rs(il,i)) + &
+               (cpv-cpd)*t(il, i)*(rti-rr(il,i))
+        denom = h(il, i) - hp(il, i) + lv(il, i)*(rr(il,i)-rti) + &
+                (cpd-cpv)*t(il, i)*(rr(il,i)-rti)
         IF (abs(denom)<0.01) denom = 0.01
-        scrit(il) = min(anum/denom, 1.)
-        alt = qp - rs(il, i) + scrit(il)*(rr(il,i)-qp)
-
-        ! jyg1    Find new critical value Scrit2
-        ! such that : Sij > Scrit2  => mixed draught will detrain at J<I
-        ! Sij < Scrit2  => mixed draught will detrain at J>I
-
-        scrit2 = min(scrit(il), sx(il))*max(0., -signhpmh(il)) + &
-          scrit(il)*max(0., signhpmh(il))
-
-        scrit(il) = scrit2
-
-        ! jyg    Correction pour la nouvelle logique; la correction pour ALT
-        ! est un peu au hazard
-        IF (scrit(il)<=0.0) scrit(il) = 0.0
-        IF (alt<=0.0) scrit(il) = 1.0
+        Scrit(il) = min(anum/denom, 1.)
+        alt = rti - rs(il, i) + Scrit(il)*(rr(il,i)-rti)
+
+!JYG1    Find new critical value Scrit2
+!         such that : Sij > Scrit2  => mixed draught will detrain at J<I
+!                     Sij < Scrit2  => mixed draught will detrain at J>I
+
+        Scrit2 = min(Scrit(il), Sx(il))*max(0., -signhpmh(il)) + &
+                 Scrit(il)*max(0., signhpmh(il))
+
+        Scrit(il) = Scrit2
+
+!JYG    Correction pour la nouvelle logique; la correction pour ALT
+! est un peu au hazard
+        IF (Scrit(il)<=0.0) Scrit(il) = 0.0
+        IF (alt<=0.0) Scrit(il) = 1.0
 
         smax(il) = 0.0
-        asij(il) = 0.0
-        sup(il) = 0. ! upper S-value reached by descending draughts
-      END IF
-    END DO
-
-    ! ---------------------------------------------------------------
-    DO j = minorig, nl !Loop on destination level "j"
-      ! ---------------------------------------------------------------
+        ASij(il) = 0.0
+        sup(il) = 0.      ! upper S-value reached by descending draughts
+      END IF
+    END DO
+
+! ---------------------------------------------------------------
+    DO j = minorig, nl         !Loop on destination level "j"
+! ---------------------------------------------------------------
 
       num2 = 0
       DO il = 1, ncum
-        IF (i>=icb(il) .AND. i<=inb(il) .AND. j>=(icb( &
-          il)-1) .AND. j<=inb(il) .AND. lwork(il)) num2 = num2 + 1
+        IF (i>=icb(il) .AND. i<=inb(il) .AND. &
+            j>=(icb(il)-1) .AND. j<=inb(il) .AND. &
+            lwork(il)) num2 = num2 + 1
       END DO
       IF (num2<=0) GO TO 175
 
-      ! -----------------------------------------------
+! -----------------------------------------------
       IF (j>i) THEN
-        ! -----------------------------------------------
+! -----------------------------------------------
         DO il = 1, ncum
-          IF (i>=icb(il) .AND. i<=inb(il) .AND. j>=(icb( &
-              il)-1) .AND. j<=inb(il) .AND. lwork(il)) THEN
-            IF (sij(il,i,j)>0.0) THEN
-              smid(il) = min(sij(il,i,j), scrit(il))
-              sjmax(il) = smid(il)
-              sjmin(il) = smid(il)
-              IF (smid(il)<smin(il) .AND. sij(il,i,j+1)<smid(il)) THEN
-                smin(il) = smid(il)
-                sjmax(il) = min((sij(il,i,j+1)+sij(il,i, &
-                  j))/2., sij(il,i,j), scrit(il))
-                sjmin(il) = max((sbef(il)+sij(il,i,j))/2., sij(il,i,j))
-                sjmin(il) = min(sjmin(il), scrit(il))
-                sbef(il) = sij(il, i, j)
+          IF (i>=icb(il) .AND. i<=inb(il) .AND. &
+              j>=(icb(il)-1) .AND. j<=inb(il) .AND. &
+              lwork(il)) THEN
+            IF (Sij(il,i,j)>0.0) THEN
+              Smid(il) = min(Sij(il,i,j), Scrit(il))
+              Sjmax(il) = Smid(il)
+              Sjmin(il) = Smid(il)
+              IF (Smid(il)<smin(il) .AND. Sij(il,i,j+1)<Smid(il)) THEN
+                smin(il) = Smid(il)
+                Sjmax(il) = min((Sij(il,i,j+1)+Sij(il,i,j))/2., Sij(il,i,j), Scrit(il))
+                Sjmin(il) = max((Sbef(il)+Sij(il,i,j))/2., Sij(il,i,j))
+                Sjmin(il) = min(Sjmin(il), Scrit(il))
+                Sbef(il) = Sij(il, i, j)
               END IF
             END IF
           END IF
         END DO
-        ! -----------------------------------------------
+! -----------------------------------------------
       ELSE IF (j==i) THEN
-        ! -----------------------------------------------
+! -----------------------------------------------
         DO il = 1, ncum
-          IF (i>=icb(il) .AND. i<=inb(il) .AND. j>=(icb( &
-              il)-1) .AND. j<=inb(il) .AND. lwork(il)) THEN
-            IF (sij(il,i,j)>0.0) THEN
-              smid(il) = 1.
-              sjmin(il) = max((sij(il,i,j-1)+smid(il))/2., scrit(il))*max(0., &
-                -signhpmh(il)) + min((sij(il,i,j+1)+smid(il))/2., scrit(il))* &
-                max(0., signhpmh(il))
-              sjmin(il) = max(sjmin(il), sup(il))
-              sjmax(il) = 1.
-
-              ! -           preparation des variables Scrit, Smin et Sbef
-              ! pour la partie j>i
-              scrit(il) = min(sjmin(il), sjmax(il), scrit(il))
+          IF (i>=icb(il) .AND. i<=inb(il) .AND. &
+              j>=(icb(il)-1) .AND. j<=inb(il) .AND. &
+              lwork(il)) THEN
+            IF (Sij(il,i,j)>0.0) THEN
+              Smid(il) = 1.
+              Sjmin(il) = max((Sij(il,i,j-1)+Smid(il))/2., Scrit(il))*max(0., -signhpmh(il)) + &
+                          min((Sij(il,i,j+1)+Smid(il))/2., Scrit(il))*max(0., signhpmh(il))
+              Sjmin(il) = max(Sjmin(il), sup(il))
+              Sjmax(il) = 1.
+
+! -             preparation des variables Scrit, Smin et Sbef pour la partie j>i
+              Scrit(il) = min(Sjmin(il), Sjmax(il), Scrit(il))
 
               smin(il) = 1.
-              sbef(il) = max(0., signhpmh(il))
-              supmax(il, i) = sign(scrit(il), -signhpmh(il))
-            END IF
-          END IF
-        END DO
-        ! -----------------------------------------------
+              Sbef(il) = max(0., signhpmh(il))
+              supmax(il, i) = sign(Scrit(il), -signhpmh(il))
+            END IF
+          END IF
+        END DO
+! -----------------------------------------------
       ELSE IF (j<i) THEN
-        ! -----------------------------------------------
+! -----------------------------------------------
         DO il = 1, ncum
-          IF (i>=icb(il) .AND. i<=inb(il) .AND. j>=(icb( &
-              il)-1) .AND. j<=inb(il) .AND. lwork(il)) THEN
-            IF (sij(il,i,j)>0.0) THEN
-              smid(il) = max(sij(il,i,j), scrit(il))
-              sjmax(il) = smid(il)
-              sjmin(il) = smid(il)
-              IF (smid(il)>smax(il) .AND. sij(il,i,j+1)>smid(il)) THEN
-                smax(il) = smid(il)
-                sjmax(il) = max((sij(il,i,j+1)+sij(il,i,j))/2., sij(il,i,j))
-                sjmax(il) = max(sjmax(il), scrit(il))
-                sjmin(il) = min((sbef(il)+sij(il,i,j))/2., sij(il,i,j))
-                sjmin(il) = max(sjmin(il), scrit(il))
-                sbef(il) = sij(il, i, j)
+          IF (i>=icb(il) .AND. i<=inb(il) .AND. &
+              j>=(icb(il)-1) .AND. j<=inb(il) .AND. &
+              lwork(il)) THEN
+            IF (Sij(il,i,j)>0.0) THEN
+              Smid(il) = max(Sij(il,i,j), Scrit(il))
+              Sjmax(il) = Smid(il)
+              Sjmin(il) = Smid(il)
+              IF (Smid(il)>smax(il) .AND. Sij(il,i,j+1)>Smid(il)) THEN
+                smax(il) = Smid(il)
+                Sjmax(il) = max((Sij(il,i,j+1)+Sij(il,i,j))/2., Sij(il,i,j))
+                Sjmax(il) = max(Sjmax(il), Scrit(il))
+                Sjmin(il) = min((Sbef(il)+Sij(il,i,j))/2., Sij(il,i,j))
+                Sjmin(il) = max(Sjmin(il), Scrit(il))
+                Sbef(il) = Sij(il, i, j)
               END IF
-              IF (abs(sjmin(il)-sjmax(il))>1.E-10) sup(il) = max(sjmin(il), &
-                sjmax(il), sup(il))
-            END IF
-          END IF
-        END DO
-        ! -----------------------------------------------
-      END IF
-      ! -----------------------------------------------
-
-
-      DO il = 1, ncum
-        IF (i>=icb(il) .AND. i<=inb(il) .AND. j>=(icb( &
-            il)-1) .AND. j<=inb(il) .AND. lwork(il)) THEN
-          IF (sij(il,i,j)>0.0) THEN
+              IF (abs(Sjmin(il)-Sjmax(il))>1.E-10) &
+                             sup(il) = max(Sjmin(il), Sjmax(il), sup(il))
+            END IF
+          END IF
+        END DO
+! -----------------------------------------------
+      END IF
+! -----------------------------------------------
+
+
+      DO il = 1, ncum
+        IF (i>=icb(il) .AND. i<=inb(il) .AND. &
+            j>=(icb(il)-1) .AND. j<=inb(il) .AND. &
+            lwork(il)) THEN
+          IF (Sij(il,i,j)>0.0) THEN
             rti = qnk(il) - ep(il, i)*clw(il, i)
-            qmixmax(il) = qmix(sjmax(il))
-            qmixmin(il) = qmix(sjmin(il))
-            rmixmax(il) = rmix(sjmax(il))
-            rmixmin(il) = rmix(sjmin(il))
-            sqmrmax(il) = sjmax(il)*qmix(sjmax(il)) - rmix(sjmax(il))
-            sqmrmin(il) = sjmin(il)*qmix(sjmin(il)) - rmix(sjmin(il))
-
-            ment(il, i, j) = abs(qmixmax(il)-qmixmin(il))*ment(il, i, j)
-
-            ! Sigij(i,j) is the 'true' mixing fraction of mixture Ment(i,j)
-            IF (abs(qmixmax(il)-qmixmin(il))>1.E-10) THEN
-              sigij(il, i, j) = (sqmrmax(il)-sqmrmin(il))/ &
-                (qmixmax(il)-qmixmin(il))
+            Qmixmax(il) = Qmix(Sjmax(il))
+            Qmixmin(il) = Qmix(Sjmin(il))
+            Rmixmax(il) = Rmix(Sjmax(il))
+            Rmixmin(il) = Rmix(Sjmin(il))
+            sqmrmax(il) = Sjmax(il)*Qmix(Sjmax(il)) - Rmix(Sjmax(il))
+            sqmrmin(il) = Sjmin(il)*Qmix(Sjmin(il)) - Rmix(Sjmin(il))
+
+            Ment(il, i, j) = abs(Qmixmax(il)-Qmixmin(il))*Ment(il, i, j)
+
+! Sigij(i,j) is the 'true' mixing fraction of mixture Ment(i,j)
+            IF (abs(Qmixmax(il)-Qmixmin(il))>1.E-10) THEN
+              Sigij(il, i, j) = (sqmrmax(il)-sqmrmin(il))/(Qmixmax(il)-Qmixmin(il))
             ELSE
-              sigij(il, i, j) = 0.
-            END IF
-
-            ! --    Compute Qent, uent, vent according to the true mixing
-            ! fraction
-            qent(il, i, j) = (1.-sigij(il,i,j))*rti + &
-              sigij(il, i, j)*rr(il, i)
-            uent(il, i, j) = (1.-sigij(il,i,j))*unk(il) + &
-              sigij(il, i, j)*u(il, i)
-            vent(il, i, j) = (1.-sigij(il,i,j))*vnk(il) + &
-              sigij(il, i, j)*v(il, i)
-
-            ! --     Compute liquid water static energy of mixed draughts
-            ! IF (j .GT. i) THEN
-            ! awat=elij(il,i,j)-(1.-ep(il,j))*clw(il,j)
-            ! awat=amax1(awat,0.0)
-            ! ELSE
-            ! awat = 0.
-            ! ENDIF
-            ! Hent(il,i,j) = (1.-Sigij(il,i,j))*HP(il,i)
-            ! :         + Sigij(il,i,j)*H(il,i)
-            ! :         + (LV(il,j)+(cpd-cpv)*t(il,j))*awat
-            ! IM 301008 beg
-            hent(il, i, j) = (1.-sigij(il,i,j))*hp(il, i) + &
-              sigij(il, i, j)*h(il, i)
-
-            elij(il, i, j) = qent(il, i, j) - rs(il, j)
-            elij(il, i, j) = elij(il, i, j) + ((h(il,j)-hent(il,i, &
-              j))*rs(il,j)*lv(il,j)/((cpd*(1.-qent(il,i,j))+ &
-              qent(il,i,j)*cpv)*rrv*t(il,j)*t(il,j)))
-            elij(il, i, j) = elij(il, i, j)/(1.+lv(il,j)*lv(il,j)*rs(il,j)/(( &
-              cpd*(1.-qent(il,i,j))+qent(il,i,j)*cpv)*rrv*t(il,j)*t(il,j)))
+              Sigij(il, i, j) = 0.
+            END IF
+
+! --    Compute Qent, uent, vent according to the true mixing fraction
+            Qent(il, i, j) = (1.-Sigij(il,i,j))*rti     + Sigij(il, i, j)*rr(il, i)
+            uent(il, i, j) = (1.-Sigij(il,i,j))*unk(il) + Sigij(il, i, j)*u(il, i)
+            vent(il, i, j) = (1.-Sigij(il,i,j))*vnk(il) + Sigij(il, i, j)*v(il, i)
+
+! --     Compute liquid water static energy of mixed draughts
+!    IF (j .GT. i) THEN
+!      awat=elij(il,i,j)-(1.-ep(il,j))*clw(il,j)
+!      awat=amax1(awat,0.0)
+!    ELSE
+!      awat = 0.
+!    ENDIF
+!    Hent(il,i,j) = (1.-Sigij(il,i,j))*HP(il,i)
+!    :         + Sigij(il,i,j)*H(il,i)
+!    :         + (LV(il,j)+(cpd-cpv)*t(il,j))*awat
+!IM 301008 beg
+            hent(il, i, j) = (1.-Sigij(il,i,j))*hp(il, i) + Sigij(il, i, j)*h(il, i)
+
+            elij(il, i, j) = Qent(il, i, j) - rs(il, j)
+            elij(il, i, j) = elij(il, i, j) + &
+                             ((h(il,j)-hent(il,i,j))*rs(il,j)*lv(il,j) / &
+                              ((cpd*(1.-Qent(il,i,j))+Qent(il,i,j)*cpv)*rrv*t(il,j)*t(il,j)))
+            elij(il, i, j) = elij(il, i, j) / &
+                             (1.+lv(il,j)*lv(il,j)*rs(il,j) / &
+                              ((cpd*(1.-Qent(il,i,j))+Qent(il,i,j)*cpv)*rrv*t(il,j)*t(il,j)))
 
             elij(il, i, j) = max(elij(il,i,j), 0.)
 
-            elij(il, i, j) = min(elij(il,i,j), qent(il,i,j))
+            elij(il, i, j) = min(elij(il,i,j), Qent(il,i,j))
 
             IF (j>i) THEN
@@ -455,19 +453,16 @@
             END IF
 
-            ! print
-            ! *,h(il,j)-hent(il,i,j),LV(il,j)*rs(il,j)/(cpd*rrv*t(il,j)*
-            ! :         t(il,j))
-
-            hent(il, i, j) = hent(il, i, j) + (lv(il,j)+(cpd-cpv)*t(il,j))* &
-              awat
-            ! IM 301008 end
-
-            ! print *,'mix : i,j,hent(il,i,j),sigij(il,i,j) ',
-            ! :               i,j,hent(il,i,j),sigij(il,i,j)
-
-            ! --      ASij is the integral of P(F) over the relevant F
-            ! interval
-            asij(il) = asij(il) + abs(qmixmax(il)*(1.-sjmax(il))+rmixmax(il)- &
-              qmixmin(il)*(1.-sjmin(il))-rmixmin(il))
+! print *,h(il,j)-hent(il,i,j),LV(il,j)*rs(il,j)/(cpd*rrv*t(il,j)*
+! :         t(il,j))
+
+            hent(il, i, j) = hent(il, i, j) + (lv(il,j)+(cpd-cpv)*t(il,j))*awat
+!IM 301008 end
+
+! print *,'mix : i,j,hent(il,i,j),Sigij(il,i,j) ',
+! :               i,j,hent(il,i,j),Sigij(il,i,j)
+
+! --      ASij is the integral of P(F) over the relevant F interval
+            ASij(il) = ASij(il) + abs(Qmixmax(il)*(1.-Sjmax(il))+Rmixmax(il) - &
+                                      Qmixmin(il)*(1.-Sjmin(il))-Rmixmin(il))
 
           END IF
@@ -476,33 +471,33 @@
       DO k = 1, ntra
         DO il = 1, ncum
-          IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. (j>=(icb(il)- &
-              1)) .AND. (j<=inb(il)) .AND. lwork(il)) THEN
-            IF (sij(il,i,j)>0.0) THEN
-              traent(il, i, j, k) = sigij(il, i, j)*tra(il, i, k) + &
-                (1.-sigij(il,i,j))*tra(il, nk(il), k)
-            END IF
-          END IF
-        END DO
-      END DO
-
-      ! --    If I=J (detrainement and entrainement at the same level), then
-      ! only the
-      ! --    adiabatic ascent part of the mixture is considered
+          IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. &
+              (j>=(icb(il)-1)) .AND. (j<=inb(il)) .AND. &
+              lwork(il)) THEN
+            IF (Sij(il,i,j)>0.0) THEN
+              traent(il, i, j, k) = Sigij(il, i, j)*tra(il, i, k) + &
+                                    (1.-Sigij(il,i,j))*tra(il, nk(il), k)
+            END IF
+          END IF
+        END DO
+      END DO
+
+! --    If I=J (detrainement and entrainement at the same level), then only the
+! --    adiabatic ascent part of the mixture is considered
       IF (i==j) THEN
         DO il = 1, ncum
-          IF (i>=icb(il) .AND. i<=inb(il) .AND. j>=(icb( &
-              il)-1) .AND. j<=inb(il) .AND. lwork(il)) THEN
-            IF (sij(il,i,j)>0.0) THEN
+          IF (i>=icb(il) .AND. i<=inb(il) .AND. &
+              j>=(icb(il)-1) .AND. j<=inb(il) .AND. &
+              lwork(il)) THEN
+            IF (Sij(il,i,j)>0.0) THEN
               rti = qnk(il) - ep(il, i)*clw(il, i)
-              ! cc          Ment(il,i,i) =
-              ! m(il,i)*abs(Qmixmax(il)*(1.-Sjmax(il))
-              ment(il, i, i) = abs(qmixmax(il)*(1.-sjmax( &
-                il))+rmixmax(il)-qmixmin(il)*(1.-sjmin(il))-rmixmin(il))
-              qent(il, i, i) = rti
+!!!             Ment(il,i,i) = m(il,i)*abs(Qmixmax(il)*(1.-Sjmax(il))
+              Ment(il, i, i) = abs(Qmixmax(il)*(1.-Sjmax(il))+Rmixmax(il) - &
+                                   Qmixmin(il)*(1.-Sjmin(il))-Rmixmin(il))
+              Qent(il, i, i) = rti
               uent(il, i, i) = unk(il)
               vent(il, i, i) = vnk(il)
               hent(il, i, i) = hp(il, i)
               elij(il, i, i) = clw(il, i)*(1.-ep(il,i))
-              sigij(il, i, i) = 0.
+              Sigij(il, i, i) = 0.
             END IF
           END IF
@@ -510,7 +505,8 @@
         DO k = 1, ntra
           DO il = 1, ncum
-            IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. (j>=(icb(il)- &
-                1)) .AND. (j<=inb(il)) .AND. lwork(il)) THEN
-              IF (sij(il,i,j)>0.0) THEN
+            IF ((i>=icb(il)) .AND. (i<=inb(il)) .AND. &
+                (j>=(icb(il)-1)) .AND. (j<=inb(il)) .AND. &
+                lwork(il)) THEN
+              IF (Sij(il,i,j)>0.0) THEN
                 traent(il, i, i, k) = tra(il, nk(il), k)
               END IF
@@ -521,10 +517,12 @@
       END IF
 
-175 END DO
+! ---------------------------------------------------------------
+175 END DO        ! End loop on destination level "j"
+! ---------------------------------------------------------------
 
     DO il = 1, ncum
       IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il)) THEN
-        asij(il) = amax1(1.0E-16, asij(il))
-        asij(il) = 1.0/asij(il)
+        ASij(il) = amax1(1.0E-16, ASij(il))
+        ASij(il) = 1.0/ASij(il)
         csum(il, i) = 0.0
       END IF
@@ -533,7 +531,7 @@
     DO j = minorig, nl
       DO il = 1, ncum
-        IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. j>=(icb( &
-            il)-1) .AND. j<=inb(il)) THEN
-          ment(il, i, j) = ment(il, i, j)*asij(il)
+        IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. &
+            j>=(icb(il)-1) .AND. j<=inb(il)) THEN
+          Ment(il, i, j) = Ment(il, i, j)*ASij(il)
         END IF
       END DO
@@ -542,7 +540,7 @@
     DO j = minorig, nl
       DO il = 1, ncum
-        IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. j>=(icb( &
-            il)-1) .AND. j<=inb(il)) THEN
-          csum(il, i) = csum(il, i) + ment(il, i, j)
+        IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. &
+            j>=(icb(il)-1) .AND. j<=inb(il)) THEN
+          csum(il, i) = csum(il, i) + Ment(il, i, j)
         END IF
       END DO
@@ -550,15 +548,14 @@
 
     DO il = 1, ncum
-      IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. csum(il,i)<1.) &
-          THEN
-        ! cc     :     .and. csum(il,i).lt.m(il,i) ) then
+      IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. csum(il,i)<1.) THEN
+! cc     :     .and. csum(il,i).lt.m(il,i) ) then
         nent(il, i) = 0
-        ! cc        ment(il,i,i)=m(il,i)
-        ment(il, i, i) = 1.
-        qent(il, i, i) = qnk(il) - ep(il, i)*clw(il, i)
+! cc        Ment(il,i,i)=m(il,i)
+        Ment(il, i, i) = 1.
+        Qent(il, i, i) = qnk(il) - ep(il, i)*clw(il, i)
         uent(il, i, i) = unk(il)
         vent(il, i, i) = vnk(il)
         elij(il, i, i) = clw(il, i)*(1.-ep(il,i))
-        sij(il, i, i) = 0.0
+        Sij(il, i, i) = 0.0
       END IF
     END DO ! il
@@ -566,7 +563,6 @@
     DO j = 1, ntra
       DO il = 1, ncum
-        IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. csum(il,i)<1.) &
-            THEN
-          ! cc     :     .and. csum(il,i).lt.m(il,i) ) then
+        IF (i>=icb(il) .AND. i<=inb(il) .AND. lwork(il) .AND. csum(il,i)<1.) THEN
+! cc     :     .and. csum(il,i).lt.m(il,i) ) then
           traent(il, i, i, j) = tra(il, nk(il), j)
         END IF
@@ -574,5 +570,8 @@
     END DO
 
-789 END DO
+! ---------------------------------------------------------------
+789 END DO              ! End loop on origin level "i"
+! ---------------------------------------------------------------
+
 
   RETURN
Index: /LMDZ5/branches/testing/libf/phylmd/cva_driver.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/cva_driver.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/cva_driver.F90	(revision 2056)
@@ -2,161 +2,156 @@
 ! $Id$
 
-SUBROUTINE cva_driver(len, nd, ndp1, ntra, nloc, iflag_con, iflag_mix, &
-    iflag_ice_thermo, iflag_clos, delt, t1, q1, qs1, t1_wake, q1_wake, &
-    qs1_wake, s1_wake, u1, v1, tra1, p1, ph1, ale1, alp1, sig1feed1, &
-    sig2feed1, wght1, iflag1, ft1, fq1, fu1, fv1, ftra1, precip1, kbas1, &
-    ktop1, cbmf1, plcl1, plfc1, wbeff1, sig1, w01, & !input/output
-    ptop21, sigd1, ma1, mip1, vprecip1, upwd1, dnwd1, dnwd01, qcondc1, wd1, &
-    cape1, cin1, tvp1, ftd1, fqd1, plim11, plim21, asupmax1, supmax01, &
-    asupmaxmin1, lalim_conv, da1, phi1, mp1, phi21, d1a1, dam1, sigij1, clw1, & ! RomP
-    elij1, evap1, ep1, epmlmmm1, eplamm1, & ! RomP
-    wdtraina1, wdtrainm1) ! RomP
-  ! **************************************************************
-  ! *
-  ! CV_DRIVER                                                   *
-  ! *
-  ! *
-  ! written by   : Sandrine Bony-Lena , 17/05/2003, 11.19.41    *
-  ! modified by :                                               *
-  ! **************************************************************
-  ! **************************************************************
+SUBROUTINE cva_driver(len, nd, ndp1, ntra, nloc, &
+                      iflag_con, iflag_mix, iflag_ice_thermo, iflag_clos, ok_conserv_q, &
+                      delt, t1, q1, qs1, t1_wake, q1_wake, qs1_wake, s1_wake, &
+                      u1, v1, tra1, &
+                      p1, ph1, &
+                      Ale1, Alp1, &
+                      sig1feed1, sig2feed1, wght1, &
+                      iflag1, ft1, fq1, fu1, fv1, ftra1, &
+                      precip1, kbas1, ktop1, &
+                      cbmf1, plcl1, plfc1, wbeff1, &
+                      sig1, w01, & !input/output
+                      ptop21, sigd1, &
+                      ma1, mip1, Vprecip1, upwd1, dnwd1, dnwd01, &
+                      qcondc1, wd1, &
+                      cape1, cin1, tvp1, &
+                      ftd1, fqd1, &
+                      Plim11, Plim21, asupmax1, supmax01, asupmaxmin1, &
+                      lalim_conv, & 
+!!                      da1,phi1,mp1,phi21,d1a1,dam1,sigij1,clw1, &        ! RomP
+!!                      elij1,evap1,ep1,epmlmMm1,eplaMm1, &                ! RomP
+                      da1, phi1, mp1, phi21, d1a1, dam1, sigij1, wghti1, & ! RomP, RL
+                      clw1, elij1, evap1, ep1, epmlmMm1, eplaMm1, &        ! RomP, RL
+                      wdtrainA1, wdtrainM1)                                ! RomP
+! **************************************************************
+! *
+! CV_DRIVER                                                   *
+! *
+! *
+! written by   : Sandrine Bony-Lena , 17/05/2003, 11.19.41    *
+! modified by :                                               *
+! **************************************************************
+! **************************************************************
 
   USE dimphy
   IMPLICIT NONE
 
-  ! .............................START PROLOGUE............................
-
-
-  ! All argument names (except len,nd,ntra,nloc,delt and the flags) have a
-  ! "1" appended.
-  ! The "1" is removed for the corresponding compressed variables.
-  ! PARAMETERS:
-  ! Name            Type         Usage            Description
-  ! ----------      ----------     -------  ----------------------------
-
-  ! len           Integer        Input        first (i) dimension
-  ! nd            Integer        Input        vertical (k) dimension
-  ! ndp1          Integer        Input        nd + 1
-  ! ntra          Integer        Input        number of tracors
-  ! iflag_con     Integer        Input        version of convect (3/4)
-  ! iflag_mix     Integer        Input        version of mixing  (0/1/2)
-  ! iflag_ice_thermo Integer        Input        accounting for ice
-  ! thermodynamics (0/1)
-  ! iflag_clos    Integer        Input        version of closure (0/1)
-  ! delt          Real           Input        time step
-  ! t1            Real           Input        temperature (sat draught envt)
-  ! q1            Real           Input        specific hum (sat draught envt)
-  ! qs1           Real           Input        sat specific hum (sat draught
-  ! envt)
-  ! t1_wake       Real           Input        temperature (unsat draught
-  ! envt)
-  ! q1_wake       Real           Input        specific hum(unsat draught
-  ! envt)
-  ! qs1_wake      Real           Input        sat specific hum(unsat draughts
-  ! envt)
-  ! s1_wake       Real           Input        fractionnal area covered by
-  ! wakes
-  ! u1            Real           Input        u-wind
-  ! v1            Real           Input        v-wind
-  ! tra1          Real           Input        tracors
-  ! p1            Real           Input        full level pressure
-  ! ph1           Real           Input        half level pressure
-  ! ALE1          Real           Input        Available lifting Energy
-  ! ALP1          Real           Input        Available lifting Power
-  ! sig1feed1     Real           Input        sigma coord at lower bound of
-  ! feeding layer
-  ! sig2feed1     Real           Input        sigma coord at upper bound of
-  ! feeding layer
-  ! wght1         Real           Input        weight density determining the
-  ! feeding mixture
-  ! iflag1        Integer        Output       flag for Emanuel conditions
-  ! ft1           Real           Output       temp tend
-  ! fq1           Real           Output       spec hum tend
-  ! fu1           Real           Output       u-wind tend
-  ! fv1           Real           Output       v-wind tend
-  ! ftra1         Real           Output       tracor tend
-  ! precip1       Real           Output       precipitation
-  ! kbas1         Integer        Output       cloud base level
-  ! ktop1         Integer        Output       cloud top level
-  ! cbmf1         Real           Output       cloud base mass flux
-  ! sig1          Real           In/Out       section adiabatic updraft
-  ! w01           Real           In/Out       vertical velocity within adiab
-  ! updraft
-  ! ptop21        Real           In/Out       top of entraining zone
-  ! Ma1           Real           Output       mass flux adiabatic updraft
-  ! mip1          Real           Output       mass flux shed by the adiabatic
-  ! updraft
-  ! Vprecip1      Real           Output       vertical profile of
-  ! precipitations
-  ! upwd1         Real           Output       total upward mass flux
-  ! (adiab+mixed)
-  ! dnwd1         Real           Output       saturated downward mass flux
-  ! (mixed)
-  ! dnwd01        Real           Output       unsaturated downward mass flux
-  ! qcondc1       Real           Output       in-cld mixing ratio of
-  ! condensed water
-  ! wd1           Real           Output       downdraft velocity scale for
-  ! sfc fluxes
-  ! cape1         Real           Output       CAPE
-  ! cin1          Real           Output       CIN
-  ! tvp1          Real           Output       adiab lifted parcell virt temp
-  ! ftd1          Real           Output       precip temp tend
-  ! fqt1          Real           Output       precip spec hum tend
-  ! Plim11        Real           Output
-  ! Plim21        Real           Output
-  ! asupmax1      Real           Output
-  ! supmax01      Real           Output
-  ! asupmaxmin1   Real           Output
-
-  ! ftd1          Real           Output  Array of temperature tendency due to
-  ! precipitations (K/s) of dimension ND,
-  ! defined at same grid levels as T, Q, QS and P.
-
-  ! fqd1          Real           Output  Array of specific humidity
-  ! tendencies due to precipitations ((gm/gm)/s)
-  ! of dimension ND, defined at same grid levels as T, Q, QS and P.
-
-  ! wdtrainA1     Real           Output   precipitation detrained from
-  ! adiabatic draught;
-  ! used in tracer transport (cvltr)
-  ! wdtrainM1     Real           Output   precipitation detrained from mixed
-  ! draughts;
-  ! used in tracer transport (cvltr)
-  ! da1           Real           Output   used in tracer transport (cvltr)
-  ! phi1          Real           Output   used in tracer transport (cvltr)
-  ! mp1           Real           Output   used in tracer transport (cvltr)
-
-  ! phi21         Real           Output   used in tracer transport (cvltr)
-
-  ! d1a1          Real           Output   used in tracer transport (cvltr)
-  ! dam1          Real           Output   used in tracer transport (cvltr)
-
-  ! epmlmMm1      Real           Output   used in tracer transport (cvltr)
-  ! eplaMm1       Real           Output   used in tracer transport (cvltr)
-
-  ! evap1         Real           Output
-  ! ep1           Real           Output
-  ! sigij1        Real           Output
-  ! elij1         Real           Output
-
-
-  ! S. Bony, Mar 2002:
-  ! * Several modules corresponding to different physical processes
-  ! * Several versions of convect may be used:
-  ! - iflag_con=3: version lmd  (previously named convect3)
-  ! - iflag_con=4: version 4.3b (vect. version, previously convect1/2)
-  ! + tard: 	- iflag_con=5: version lmd with ice (previously named convectg)
-  ! S. Bony, Oct 2002:
-  ! * Vectorization of convect3 (ie version lmd)
-
-  ! ..............................END PROLOGUE.............................
+! .............................START PROLOGUE............................
+
+
+! All argument names (except len,nd,ntra,nloc,delt and the flags) have a "1" appended.
+! The "1" is removed for the corresponding compressed variables.
+! PARAMETERS:
+! Name            Type         Usage            Description
+! ----------      ----------     -------  ----------------------------
+
+! len           Integer        Input        first (i) dimension
+! nd            Integer        Input        vertical (k) dimension
+! ndp1          Integer        Input        nd + 1
+! ntra          Integer        Input        number of tracors
+! iflag_con     Integer        Input        version of convect (3/4)
+! iflag_mix     Integer        Input        version of mixing  (0/1/2)
+! iflag_ice_thermo Integer        Input        accounting for ice thermodynamics (0/1)
+! iflag_clos    Integer        Input        version of closure (0/1)
+! ok_conserv_q  Logical        Input        when true corrections for water conservation are swtiched on
+! delt          Real           Input        time step
+! t1            Real           Input        temperature (sat draught envt)
+! q1            Real           Input        specific hum (sat draught envt)
+! qs1           Real           Input        sat specific hum (sat draught envt)
+! t1_wake       Real           Input        temperature (unsat draught envt)
+! q1_wake       Real           Input        specific hum(unsat draught envt)
+! qs1_wake      Real           Input        sat specific hum(unsat draughts envt)
+! s1_wake       Real           Input        fractionnal area covered by wakes
+! u1            Real           Input        u-wind
+! v1            Real           Input        v-wind
+! tra1          Real           Input        tracors
+! p1            Real           Input        full level pressure
+! ph1           Real           Input        half level pressure
+! ALE1          Real           Input        Available lifting Energy
+! ALP1          Real           Input        Available lifting Power
+! sig1feed1     Real           Input        sigma coord at lower bound of feeding layer
+! sig2feed1     Real           Input        sigma coord at upper bound of feeding layer
+! wght1         Real           Input        weight density determining the feeding mixture
+! iflag1        Integer        Output       flag for Emanuel conditions
+! ft1           Real           Output       temp tend
+! fq1           Real           Output       spec hum tend
+! fu1           Real           Output       u-wind tend
+! fv1           Real           Output       v-wind tend
+! ftra1         Real           Output       tracor tend
+! precip1       Real           Output       precipitation
+! kbas1         Integer        Output       cloud base level
+! ktop1         Integer        Output       cloud top level
+! cbmf1         Real           Output       cloud base mass flux
+! sig1          Real           In/Out       section adiabatic updraft
+! w01           Real           In/Out       vertical velocity within adiab updraft
+! ptop21        Real           In/Out       top of entraining zone
+! Ma1           Real           Output       mass flux adiabatic updraft
+! mip1          Real           Output       mass flux shed by the adiabatic updraft
+! Vprecip1      Real           Output       vertical profile of precipitations
+! upwd1         Real           Output       total upward mass flux (adiab+mixed)
+! dnwd1         Real           Output       saturated downward mass flux (mixed)
+! dnwd01        Real           Output       unsaturated downward mass flux
+! qcondc1       Real           Output       in-cld mixing ratio of condensed water
+! wd1           Real           Output       downdraft velocity scale for sfc fluxes
+! cape1         Real           Output       CAPE
+! cin1          Real           Output       CIN
+! tvp1          Real           Output       adiab lifted parcell virt temp
+! ftd1          Real           Output       precip temp tend
+! fqt1          Real           Output       precip spec hum tend
+! Plim11        Real           Output
+! Plim21        Real           Output
+! asupmax1      Real           Output
+! supmax01      Real           Output
+! asupmaxmin1   Real           Output
+
+! ftd1          Real           Output  Array of temperature tendency due to precipitations (K/s) of dimension ND,
+!                                      defined at same grid levels as T, Q, QS and P.
+
+! fqd1          Real           Output  Array of specific humidity tendencies due to precipitations ((gm/gm)/s)
+!                                      of dimension ND, defined at same grid levels as T, Q, QS and P.
+
+! wdtrainA1     Real           Output   precipitation detrained from adiabatic draught;
+!                                         used in tracer transport (cvltr)
+! wdtrainM1     Real           Output   precipitation detrained from mixed draughts;
+!                                         used in tracer transport (cvltr)
+! da1           Real           Output     used in tracer transport (cvltr)
+! phi1          Real           Output     used in tracer transport (cvltr)
+! mp1           Real           Output     used in tracer transport (cvltr)
+                                         
+! phi21         Real           Output     used in tracer transport (cvltr)
+                                         
+! d1a1          Real           Output     used in tracer transport (cvltr)
+! dam1          Real           Output     used in tracer transport (cvltr)
+                                         
+! epmlmMm1      Real           Output     used in tracer transport (cvltr)
+! eplaMm1       Real           Output     used in tracer transport (cvltr)
+                                         
+! evap1         Real           Output    
+! ep1           Real           Output    
+! sigij1        Real           Output     used in tracer transport (cvltr)
+! elij1         Real           Output
+! wghti1        Real           Output   final weight of the feeding layers,
+!                                         used in tracer transport (cvltr)
+
+
+! S. Bony, Mar 2002:
+! * Several modules corresponding to different physical processes
+! * Several versions of convect may be used:
+!         - iflag_con=3: version lmd  (previously named convect3)
+!         - iflag_con=4: version 4.3b (vect. version, previously convect1/2)
+! + tard: - iflag_con=5: version lmd with ice (previously named convectg)
+! S. Bony, Oct 2002:
+! * Vectorization of convect3 (ie version lmd)
+
+! ..............................END PROLOGUE.............................
 
 
   include "dimensions.h"
-  ! cccc#include "dimphy.h"
+!!!!!#include "dimphy.h"
   include 'iniprint.h'
 
 
-  ! Input
+! Input
   INTEGER len
   INTEGER nd
@@ -167,4 +162,5 @@
   INTEGER iflag_ice_thermo
   INTEGER iflag_clos
+  LOGICAL ok_conserv_q
   REAL delt
   REAL t1(len, nd)
@@ -180,11 +176,11 @@
   REAL p1(len, nd)
   REAL ph1(len, ndp1)
-  REAL ale1(len)
-  REAL alp1(len)
+  REAL Ale1(len)
+  REAL Alp1(len)
   REAL sig1feed1 ! pressure at lower bound of feeding layer
   REAL sig2feed1 ! pressure at upper bound of feeding layer
   REAL wght1(nd) ! weight density determining the feeding mixture
 
-  ! Output
+! Output
   INTEGER iflag1(len)
   REAL ft1(len, nd)
@@ -206,5 +202,5 @@
   REAL ma1(len, nd)
   REAL mip1(len, nd)
-  ! real Vprecip1(len,nd)
+! real Vprecip1(len,nd)
   REAL vprecip1(len, nd+1)
   REAL upwd1(len, nd)
@@ -217,156 +213,156 @@
   REAL tvp1(len, nd)
 
-  ! AC!
-  ! !      real da1(len,nd),phi1(len,nd,nd)
-  ! !      real da(len,nd),phi(len,nd,nd)
-  ! AC!
+!AC!
+!!      real da1(len,nd),phi1(len,nd,nd)
+!!      real da(len,nd),phi(len,nd,nd)
+!AC!
   REAL ftd1(len, nd)
   REAL fqd1(len, nd)
-  REAL plim11(len)
-  REAL plim21(len)
+  REAL Plim11(len)
+  REAL Plim21(len)
   REAL asupmax1(len, nd)
   REAL supmax01(len)
   REAL asupmaxmin1(len)
   INTEGER lalim_conv(len)
-  ! RomP >>>
-  REAL wdtraina1(len, nd), wdtrainm1(len, nd)
+! RomP >>>
+  REAL wdtrainA1(len, nd), wdtrainM1(len, nd)
   REAL da1(len, nd), phi1(len, nd, nd), mp1(len, nd)
-  REAL epmlmmm1(len, nd, nd), eplamm1(len, nd)
+  REAL epmlmMm1(len, nd, nd), eplaMm1(len, nd)
   REAL evap1(len, nd), ep1(len, nd)
   REAL sigij1(len, nd, nd), elij1(len, nd, nd)
+!JYG,RL
+  REAL wghti1(len, nd) ! final weight of the feeding layers
+!JYG,RL
   REAL phi21(len, nd, nd)
   REAL d1a1(len, nd), dam1(len, nd)
-  ! RomP <<<
-
-  ! -------------------------------------------------------------------
-  ! Prolog by Kerry Emanuel.
-  ! -------------------------------------------------------------------
-  ! --- ARGUMENTS
-  ! -------------------------------------------------------------------
-  ! --- On input:
-
-  ! t:   Array of absolute temperature (K) of dimension ND, with first
-  ! index corresponding to lowest model level. Note that this array
-  ! will be altered by the subroutine if dry convective adjustment
-  ! occurs and if IPBL is not equal to 0.
-
-  ! q:   Array of specific humidity (gm/gm) of dimension ND, with first
-  ! index corresponding to lowest model level. Must be defined
-  ! at same grid levels as T. Note that this array will be altered
-  ! if dry convective adjustment occurs and if IPBL is not equal to 0.
-
-  ! qs:  Array of saturation specific humidity of dimension ND, with first
-  ! index corresponding to lowest model level. Must be defined
-  ! at same grid levels as T. Note that this array will be altered
-  ! if dry convective adjustment occurs and if IPBL is not equal to 0.
-
-  ! t_wake: Array of absolute temperature (K), seen by unsaturated draughts,
-  ! of dimension ND, with first index corresponding to lowest model level.
-
-  ! q_wake: Array of specific humidity (gm/gm), seen by unsaturated draughts,
-  ! of dimension ND, with first index corresponding to lowest model level.
-  ! Must be defined at same grid levels as T.
-
-  ! qs_wake: Array of saturation specific humidity, seen by unsaturated
-  ! draughts,
-  ! of dimension ND, with first index corresponding to lowest model level.
-  ! Must be defined at same grid levels as T.
-
-  ! s_wake: Array of fractionnal area occupied by the wakes.
-
-  ! u:   Array of zonal wind velocity (m/s) of dimension ND, witth first
-  ! index corresponding with the lowest model level. Defined at
-  ! same levels as T. Note that this array will be altered if
-  ! dry convective adjustment occurs and if IPBL is not equal to 0.
-
-  ! v:   Same as u but for meridional velocity.
-
-  ! tra: Array of passive tracer mixing ratio, of dimensions (ND,NTRA),
-  ! where NTRA is the number of different tracers. If no
-  ! convective tracer transport is needed, define a dummy
-  ! input array of dimension (ND,1). Tracers are defined at
-  ! same vertical levels as T. Note that this array will be altered
-  ! if dry convective adjustment occurs and if IPBL is not equal to 0.
-
-  ! p:   Array of pressure (mb) of dimension ND, with first
-  ! index corresponding to lowest model level. Must be defined
-  ! at same grid levels as T.
-
-  ! ph:  Array of pressure (mb) of dimension ND+1, with first index
-  ! corresponding to lowest level. These pressures are defined at
-  ! levels intermediate between those of P, T, Q and QS. The first
-  ! value of PH should be greater than (i.e. at a lower level than)
-  ! the first value of the array P.
-
-  ! ALE:  Available lifting Energy
-
-  ! ALP:  Available lifting Power
-
-  ! nl:  The maximum number of levels to which convection can penetrate, plus
-  ! 1.
-  ! NL MUST be less than or equal to ND-1.
-
-  ! delt: The model time step (sec) between calls to CONVECT
-
-  ! ----------------------------------------------------------------------------
-  ! ---   On Output:
-
-  ! iflag: An output integer whose value denotes the following:
-  ! VALUE   INTERPRETATION
-  ! -----   --------------
-  ! 0     Moist convection occurs.
-  ! 1     Moist convection occurs, but a CFL condition
-  ! on the subsidence warming is violated. This
-  ! does not cause the scheme to terminate.
-  ! 2     Moist convection, but no precip because ep(inb) lt 0.0001
-  ! 3     No moist convection because new cbmf is 0 and old cbmf is 0.
-  ! 4     No moist convection; atmosphere is not
-  ! unstable
-  ! 6     No moist convection because ihmin le minorig.
-  ! 7     No moist convection because unreasonable
-  ! parcel level temperature or specific humidity.
-  ! 8     No moist convection: lifted condensation
-  ! level is above the 200 mb level.
-  ! 9     No moist convection: cloud base is higher
-  ! then the level NL-1.
-
-  ! ft:   Array of temperature tendency (K/s) of dimension ND, defined at
-  ! same
-  ! grid levels as T, Q, QS and P.
-
-  ! fq:   Array of specific humidity tendencies ((gm/gm)/s) of dimension ND,
-  ! defined at same grid levels as T, Q, QS and P.
-
-  ! fu:   Array of forcing of zonal velocity (m/s^2) of dimension ND,
-  ! defined at same grid levels as T.
-
-  ! fv:   Same as FU, but for forcing of meridional velocity.
-
-  ! ftra: Array of forcing of tracer content, in tracer mixing ratio per
-  ! second, defined at same levels as T. Dimensioned (ND,NTRA).
-
-  ! precip: Scalar convective precipitation rate (mm/day).
-
-  ! wd:   A convective downdraft velocity scale. For use in surface
-  ! flux parameterizations. See convect.ps file for details.
-
-  ! tprime: A convective downdraft temperature perturbation scale (K).
-  ! For use in surface flux parameterizations. See convect.ps
-  ! file for details.
-
-  ! qprime: A convective downdraft specific humidity
-  ! perturbation scale (gm/gm).
-  ! For use in surface flux parameterizations. See convect.ps
-  ! file for details.
-
-  ! cbmf: The cloud base mass flux ((kg/m**2)/s). THIS SCALAR VALUE MUST
-  ! BE STORED BY THE CALLING PROGRAM AND RETURNED TO CONVECT AT
-  ! ITS NEXT CALL. That is, the value of CBMF must be "remembered"
-  ! by the calling program between calls to CONVECT.
-
-  ! det:   Array of detrainment mass flux of dimension ND.
-  ! -------------------------------------------------------------------
-
-  ! Local arrays
+! RomP <<<
+
+! -------------------------------------------------------------------
+! Prolog by Kerry Emanuel.
+! -------------------------------------------------------------------
+! --- ARGUMENTS
+! -------------------------------------------------------------------
+! --- On input:
+
+! t:   Array of absolute temperature (K) of dimension ND, with first
+! index corresponding to lowest model level. Note that this array
+! will be altered by the subroutine if dry convective adjustment
+! occurs and if IPBL is not equal to 0.
+
+! q:   Array of specific humidity (gm/gm) of dimension ND, with first
+! index corresponding to lowest model level. Must be defined
+! at same grid levels as T. Note that this array will be altered
+! if dry convective adjustment occurs and if IPBL is not equal to 0.
+
+! qs:  Array of saturation specific humidity of dimension ND, with first
+! index corresponding to lowest model level. Must be defined
+! at same grid levels as T. Note that this array will be altered
+! if dry convective adjustment occurs and if IPBL is not equal to 0.
+
+! t_wake: Array of absolute temperature (K), seen by unsaturated draughts,
+! of dimension ND, with first index corresponding to lowest model level.
+
+! q_wake: Array of specific humidity (gm/gm), seen by unsaturated draughts,
+! of dimension ND, with first index corresponding to lowest model level.
+! Must be defined at same grid levels as T.
+
+! qs_wake: Array of saturation specific humidity, seen by unsaturated draughts,
+! of dimension ND, with first index corresponding to lowest model level.
+! Must be defined at same grid levels as T.
+
+! s_wake: Array of fractionnal area occupied by the wakes.
+
+! u:   Array of zonal wind velocity (m/s) of dimension ND, witth first
+! index corresponding with the lowest model level. Defined at
+! same levels as T. Note that this array will be altered if
+! dry convective adjustment occurs and if IPBL is not equal to 0.
+
+! v:   Same as u but for meridional velocity.
+
+! tra: Array of passive tracer mixing ratio, of dimensions (ND,NTRA),
+! where NTRA is the number of different tracers. If no
+! convective tracer transport is needed, define a dummy
+! input array of dimension (ND,1). Tracers are defined at
+! same vertical levels as T. Note that this array will be altered
+! if dry convective adjustment occurs and if IPBL is not equal to 0.
+
+! p:   Array of pressure (mb) of dimension ND, with first
+! index corresponding to lowest model level. Must be defined
+! at same grid levels as T.
+
+! ph:  Array of pressure (mb) of dimension ND+1, with first index
+! corresponding to lowest level. These pressures are defined at
+! levels intermediate between those of P, T, Q and QS. The first
+! value of PH should be greater than (i.e. at a lower level than)
+! the first value of the array P.
+
+! ALE:  Available lifting Energy
+
+! ALP:  Available lifting Power
+
+! nl:  The maximum number of levels to which convection can penetrate, plus 1.
+!       NL MUST be less than or equal to ND-1.
+
+! delt: The model time step (sec) between calls to CONVECT
+
+! ----------------------------------------------------------------------------
+! ---   On Output:
+
+! iflag: An output integer whose value denotes the following:
+!       VALUE   INTERPRETATION
+!       -----   --------------
+!         0     Moist convection occurs.
+!         1     Moist convection occurs, but a CFL condition
+!               on the subsidence warming is violated. This
+!               does not cause the scheme to terminate.
+!         2     Moist convection, but no precip because ep(inb) lt 0.0001
+!         3     No moist convection because new cbmf is 0 and old cbmf is 0.
+!         4     No moist convection; atmosphere is not
+!               unstable
+!         6     No moist convection because ihmin le minorig.
+!         7     No moist convection because unreasonable
+!               parcel level temperature or specific humidity.
+!         8     No moist convection: lifted condensation
+!               level is above the 200 mb level.
+!         9     No moist convection: cloud base is higher
+!               then the level NL-1.
+
+! ft:   Array of temperature tendency (K/s) of dimension ND, defined at same
+!       grid levels as T, Q, QS and P.
+
+! fq:   Array of specific humidity tendencies ((gm/gm)/s) of dimension ND,
+!       defined at same grid levels as T, Q, QS and P.
+
+! fu:   Array of forcing of zonal velocity (m/s^2) of dimension ND,
+!      defined at same grid levels as T.
+
+! fv:   Same as FU, but for forcing of meridional velocity.
+
+! ftra: Array of forcing of tracer content, in tracer mixing ratio per
+!       second, defined at same levels as T. Dimensioned (ND,NTRA).
+
+! precip: Scalar convective precipitation rate (mm/day).
+
+! wd:   A convective downdraft velocity scale. For use in surface
+!       flux parameterizations. See convect.ps file for details.
+
+! tprime: A convective downdraft temperature perturbation scale (K).
+!         For use in surface flux parameterizations. See convect.ps
+!         file for details.
+
+! qprime: A convective downdraft specific humidity
+!         perturbation scale (gm/gm).
+!         For use in surface flux parameterizations. See convect.ps
+!         file for details.
+
+! cbmf: The cloud base mass flux ((kg/m**2)/s). THIS SCALAR VALUE MUST
+!       BE STORED BY THE CALLING PROGRAM AND RETURNED TO CONVECT AT
+!       ITS NEXT CALL. That is, the value of CBMF must be "remembered"
+!       by the calling program between calls to CONVECT.
+
+! det:   Array of detrainment mass flux of dimension ND.
+! -------------------------------------------------------------------
+
+! Local (non compressed) arrays
 
 
@@ -380,5 +376,5 @@
   LOGICAL ok_inhib ! True => possible inhibition of convection by dryness
   LOGICAL, SAVE :: debut = .TRUE.
-  !$OMP THREADPRIVATE(debut)
+!$OMP THREADPRIVATE(debut)
 
   REAL tnk1(klon)
@@ -414,10 +410,12 @@
   REAL p1feed1(len) ! pressure at lower bound of feeding layer
   REAL p2feed1(len) ! pressure at upper bound of feeding layer
-  REAL wghti1(len, nd) ! weights of the feeding layers
-
-  ! (local) compressed fields:
+!JYG,RL
+!!      real wghti1(len,nd) ! weights of the feeding layers
+!JYG,RL
+
+! (local) compressed fields:
 
   INTEGER nloc
-  ! parameter (nloc=klon) ! pour l'instant
+! parameter (nloc=klon) ! pour l'instant
 
   INTEGER idcum(nloc)
@@ -456,15 +454,15 @@
   REAL elij(nloc, klev, klev)
   REAL supmax(nloc, klev)
-  REAL ale(nloc), alp(nloc), coef_clos(nloc)
+  REAL Ale(nloc), Alp(nloc), coef_clos(nloc)
   REAL sigd(nloc)
-  ! real mp(nloc,klev), qp(nloc,klev), up(nloc,klev), vp(nloc,klev)
-  ! real wt(nloc,klev), water(nloc,klev), evap(nloc,klev), ice(nloc,klev)
-  ! real b(nloc,klev), sigd(nloc)
-  ! save mp,qp,up,vp,wt,water,evap,b
+! real mp(nloc,klev), qp(nloc,klev), up(nloc,klev), vp(nloc,klev)
+! real wt(nloc,klev), water(nloc,klev), evap(nloc,klev), ice(nloc,klev)
+! real b(nloc,klev), sigd(nloc)
+! save mp,qp,up,vp,wt,water,evap,b
   REAL, SAVE, ALLOCATABLE :: mp(:, :), qp(:, :), up(:, :), vp(:, :)
   REAL, SAVE, ALLOCATABLE :: wt(:, :), water(:, :), evap(:, :)
   REAL, SAVE, ALLOCATABLE :: ice(:, :), fondue(:, :), b(:, :)
   REAL, SAVE, ALLOCATABLE :: frac(:, :), faci(:, :)
-  !$OMP THREADPRIVATE(mp,qp,up,vp,wt,water,evap,ice,fondue,b,frac,faci)
+!$OMP THREADPRIVATE(mp,qp,up,vp,wt,water,evap,ice,fondue,b,frac,faci)
   REAL ft(nloc, klev), fq(nloc, klev)
   REAL ftd(nloc, klev), fqd(nloc, klev)
@@ -474,11 +472,11 @@
   REAL tps(nloc, klev), qprime(nloc), tprime(nloc)
   REAL precip(nloc)
-  ! real Vprecip(nloc,klev)
+! real Vprecip(nloc,klev)
   REAL vprecip(nloc, klev+1)
   REAL tra(nloc, klev, ntra), trap(nloc, klev, ntra)
   REAL ftra(nloc, klev, ntra), traent(nloc, klev, klev, ntra)
-  REAL qcondc(nloc, klev) ! cld
-  REAL wd(nloc) ! gust
-  REAL plim1(nloc), plim2(nloc)
+  REAL qcondc(nloc, klev)      ! cld
+  REAL wd(nloc)                ! gust
+  REAL Plim1(nloc), plim2(nloc)
   REAL asupmax(nloc, klev)
   REAL supmax0(nloc)
@@ -489,24 +487,24 @@
   REAL hnk(nloc), unk(nloc), vnk(nloc)
 
-  ! RomP >>>
-  REAL wdtraina(nloc, klev), wdtrainm(nloc, klev)
+! RomP >>>
+  REAL wdtrainA(nloc, klev), wdtrainM(nloc, klev)
   REAL da(len, nd), phi(len, nd, nd)
-  REAL epmlmmm(nloc, klev, klev), eplamm(nloc, klev)
+  REAL epmlmMm(nloc, klev, klev), eplaMm(nloc, klev)
   REAL phi2(len, nd, nd)
   REAL d1a(len, nd), dam(len, nd)
-  ! RomP <<<
+! RomP <<<
 
   LOGICAL, SAVE :: first = .TRUE.
-  !$OMP THREADPRIVATE(first)
+!$OMP THREADPRIVATE(first)
   CHARACTER (LEN=20) :: modname = 'cva_driver'
   CHARACTER (LEN=80) :: abort_message
 
 
-  ! print *, 't1, t1_wake ',(k,t1(1,k),t1_wake(1,k),k=1,klev)
-  ! print *, 'q1, q1_wake ',(k,q1(1,k),q1_wake(1,k),k=1,klev)
-
-  ! -------------------------------------------------------------------
-  ! --- SET CONSTANTS AND PARAMETERS
-  ! -------------------------------------------------------------------
+! print *, 't1, t1_wake ',(k,t1(1,k),t1_wake(1,k),k=1,klev)
+! print *, 'q1, q1_wake ',(k,q1(1,k),q1_wake(1,k),k=1,klev)
+
+! -------------------------------------------------------------------
+! --- SET CONSTANTS AND PARAMETERS
+! -------------------------------------------------------------------
 
   IF (first) THEN
@@ -518,19 +516,19 @@
     first = .FALSE.
   END IF
-  ! -- set simulation flags:
-  ! (common cvflag)
+! -- set simulation flags:
+! (common cvflag)
 
   CALL cv_flag(iflag_ice_thermo)
 
-  ! -- set thermodynamical constants:
-  ! (common cvthermo)
+! -- set thermodynamical constants:
+! (common cvthermo)
 
   CALL cv_thermo(iflag_con)
 
-  ! -- set convect parameters
-
-  ! includes microphysical parameters and parameters that
-  ! control the rate of approach to quasi-equilibrium)
-  ! (common cvparam)
+! -- set convect parameters
+
+! includes microphysical parameters and parameters that
+! control the rate of approach to quasi-equilibrium)
+! (common cvparam)
 
   IF (iflag_con==3) THEN
@@ -543,7 +541,7 @@
   END IF
 
-  ! ---------------------------------------------------------------------
-  ! --- INITIALIZE OUTPUT ARRAYS AND PARAMETERS
-  ! ---------------------------------------------------------------------
+! ---------------------------------------------------------------------
+! --- INITIALIZE OUTPUT ARRAYS AND PARAMETERS
+! ---------------------------------------------------------------------
   nword1 = len
   nword2 = len*nd
@@ -576,6 +574,6 @@
   ftd1(:, :) = 0.
   fqd1(:, :) = 0.
-  plim11(:) = 0.
-  plim21(:) = 0.
+  Plim11(:) = 0.
+  Plim21(:) = 0.
   asupmax1(:, :) = 0.
   supmax01(:) = 0.
@@ -594,11 +592,11 @@
   END IF
 
-  ! RomP >>>
-  wdtraina1(:, :) = 0.
-  wdtrainm1(:, :) = 0.
+! RomP >>>
+  wdtrainA1(:, :) = 0.
+  wdtrainM1(:, :) = 0.
   da1(:, :) = 0.
   phi1(:, :, :) = 0.
-  epmlmmm1(:, :, :) = 0.
-  eplamm1(:, :) = 0.
+  epmlmMm1(:, :, :) = 0.
+  eplaMm1(:, :) = 0.
   mp1(:, :) = 0.
   evap1(:, :) = 0.
@@ -609,8 +607,8 @@
   d1a1(:, :) = 0.
   dam1(:, :) = 0.
-  ! RomP <<<
-  ! ---------------------------------------------------------------------
-  ! --- INITIALIZE LOCAL ARRAYS AND PARAMETERS
-  ! ---------------------------------------------------------------------
+! RomP <<<
+! ---------------------------------------------------------------------
+! --- INITIALIZE LOCAL ARRAYS AND PARAMETERS
+! ---------------------------------------------------------------------
 
   DO il = 1, nloc
@@ -618,7 +616,7 @@
   END DO
 
-  ! --------------------------------------------------------------------
-  ! --- CALCULATE ARRAYS OF GEOPOTENTIAL, HEAT CAPACITY & STATIC ENERGY
-  ! --------------------------------------------------------------------
+! --------------------------------------------------------------------
+! --- CALCULATE ARRAYS OF GEOPOTENTIAL, HEAT CAPACITY & STATIC ENERGY
+! --------------------------------------------------------------------
 
   IF (iflag_con==3) THEN
@@ -627,13 +625,12 @@
       PRINT *, 'Emanuel version 3 nouvelle'
     END IF
-    ! print*,'t1, q1 ',t1,q1
-    CALL cv3_prelim(len, nd, ndp1, t1, q1, p1, ph1 & ! nd->na
-      , lv1, lf1, cpn1, tv1, gz1, h1, hm1, th1)
-
-
-    CALL cv3_prelim(len, nd, ndp1, t1_wake, q1_wake, p1, ph1 & !
-                                                               ! nd->na
-      , lv1_wake, lf1_wake, cpn1_wake, tv1_wake, gz1_wake, h1_wake, bid, &
-      th1_wake)
+! print*,'t1, q1 ',t1,q1
+    CALL cv3_prelim(len, nd, ndp1, t1, q1, p1, ph1, &           ! nd->na
+                    lv1, lf1, cpn1, tv1, gz1, h1, hm1, th1)
+
+
+    CALL cv3_prelim(len, nd, ndp1, t1_wake, q1_wake, p1, ph1, & ! nd->na
+                    lv1_wake, lf1_wake, cpn1_wake, tv1_wake, gz1_wake, &
+                    h1_wake, bid, th1_wake)
 
   END IF
@@ -641,17 +638,17 @@
   IF (iflag_con==4) THEN
     PRINT *, 'Emanuel version 4 '
-    CALL cv_prelim(len, nd, ndp1, t1, q1, p1, ph1, lv1, cpn1, tv1, gz1, h1, &
-      hm1)
-  END IF
-
-  ! --------------------------------------------------------------------
-  ! --- CONVECTIVE FEED
-  ! --------------------------------------------------------------------
-
-  ! compute feeding layer potential temperature and mixing ratio :
-
-  ! get bounds of feeding layer
-
-  ! test niveaux couche alimentation KE
+    CALL cv_prelim(len, nd, ndp1, t1, q1, p1, ph1, &
+                   lv1, cpn1, tv1, gz1, h1, hm1)
+  END IF
+
+! --------------------------------------------------------------------
+! --- CONVECTIVE FEED
+! --------------------------------------------------------------------
+
+! compute feeding layer potential temperature and mixing ratio :
+
+! get bounds of feeding layer
+
+! test niveaux couche alimentation KE
   IF (sig1feed1==sig2feed1) THEN
     WRITE (lunout, *) 'impossible de choisir sig1feed=sig2feed'
@@ -664,11 +661,11 @@
     p1feed1(i) = sig1feed1*ph1(i, 1)
     p2feed1(i) = sig2feed1*ph1(i, 1)
-    ! test maf
-    ! p1feed1(i)=ph1(i,1)
-    ! p2feed1(i)=ph1(i,2)
-    ! p2feed1(i)=ph1(i,3)
-    ! testCR: on prend la couche alim des thermiques
-    ! p2feed1(i)=ph1(i,lalim_conv(i)+1)
-    ! print*,'lentr=',lentr(i),ph1(i,lentr(i)+1),ph1(i,2)
+!test maf
+!   p1feed1(i)=ph1(i,1)
+!   p2feed1(i)=ph1(i,2)
+!   p2feed1(i)=ph1(i,3)
+!testCR: on prend la couche alim des thermiques
+!   p2feed1(i)=ph1(i,lalim_conv(i)+1)
+!   print*,'lentr=',lentr(i),ph1(i,lentr(i)+1),ph1(i,2)
   END DO
 
@@ -676,66 +673,66 @@
   END IF
   DO i = 1, len
-    ! print*,'avant cv3_feed plim',p1feed1(i),p2feed1(i)
+! print*,'avant cv3_feed Plim',p1feed1(i),p2feed1(i)
   END DO
   IF (iflag_con==3) THEN
 
-    ! print*, 'IFLAG1 avant cv3_feed'
-    ! print*,'len,nd',len,nd
-    ! write(*,'(64i1)') iflag1(2:klon-1)
-
-    CALL cv3_feed(len, nd, t1, q1, u1, v1, p1, ph1, hm1, gz1 & !
-                                                               ! nd->na
-      , p1feed1, p2feed1, wght1, wghti1, tnk1, thnk1, qnk1, qsnk1, unk1, &
-      vnk1, cpnk1, hnk1, nk1, icb1, icbmax, iflag1, gznk1, plcl1)
-  END IF
-
-  ! print*, 'IFLAG1 apres cv3_feed'
-  ! print*,'len,nd',len,nd
-  ! write(*,'(64i1)') iflag1(2:klon-1)
+! print*, 'IFLAG1 avant cv3_feed'
+! print*,'len,nd',len,nd
+! write(*,'(64i1)') iflag1(2:klon-1)
+
+    CALL cv3_feed(len, nd, ok_conserv_q, &                 ! nd->na
+                  t1, q1, u1, v1, p1, ph1, hm1, gz1, & 
+                  p1feed1, p2feed1, wght1, &
+                  wghti1, tnk1, thnk1, qnk1, qsnk1, unk1, vnk1, &
+                  cpnk1, hnk1, nk1, icb1, icbmax, iflag1, gznk1, plcl1)
+  END IF
+
+! print*, 'IFLAG1 apres cv3_feed'
+! print*,'len,nd',len,nd
+! write(*,'(64i1)') iflag1(2:klon-1)
 
   IF (iflag_con==4) THEN
-    CALL cv_feed(len, nd, t1, q1, qs1, p1, hm1, gz1, nk1, icb1, icbmax, &
-      iflag1, tnk1, qnk1, gznk1, plcl1)
-  END IF
-
-  ! print *, 'cv3_feed-> iflag1, plcl1 ',iflag1(1),plcl1(1)
-
-  ! --------------------------------------------------------------------
-  ! --- UNDILUTE (ADIABATIC) UPDRAFT / 1st part
-  ! (up through ICB for convect4, up through ICB+1 for convect3)
-  ! Calculates the lifted parcel virtual temperature at nk, the
-  ! actual temperature, and the adiabatic liquid water content.
-  ! --------------------------------------------------------------------
+    CALL cv_feed(len, nd, t1, q1, qs1, p1, hm1, gz1, &
+                 nk1, icb1, icbmax, iflag1, tnk1, qnk1, gznk1, plcl1)
+  END IF
+
+! print *, 'cv3_feed-> iflag1, plcl1 ',iflag1(1),plcl1(1)
+
+! --------------------------------------------------------------------
+! --- UNDILUTE (ADIABATIC) UPDRAFT / 1st part
+! (up through ICB for convect4, up through ICB+1 for convect3)
+! Calculates the lifted parcel virtual temperature at nk, the
+! actual temperature, and the adiabatic liquid water content.
+! --------------------------------------------------------------------
 
   IF (iflag_con==3) THEN
 
-    CALL cv3_undilute1(len, nd, t1, qs1, gz1, plcl1, p1, icb1, tnk1, qnk1 & ! nd->na
-      , gznk1, tp1, tvp1, clw1, icbs1)
+    CALL cv3_undilute1(len, nd, t1, qs1, gz1, plcl1, p1, icb1, tnk1, qnk1, & ! nd->na
+                       gznk1, tp1, tvp1, clw1, icbs1)
   END IF
 
 
   IF (iflag_con==4) THEN
-    CALL cv_undilute1(len, nd, t1, q1, qs1, gz1, p1, nk1, icb1, icbmax, tp1, &
-      tvp1, clw1)
-  END IF
-
-  ! -------------------------------------------------------------------
-  ! --- TRIGGERING
-  ! -------------------------------------------------------------------
-
-  ! print *,' avant triggering, iflag_con ',iflag_con
+    CALL cv_undilute1(len, nd, t1, q1, qs1, gz1, p1, nk1, icb1, icbmax, &
+                      tp1, tvp1, clw1)
+  END IF
+
+! -------------------------------------------------------------------
+! --- TRIGGERING
+! -------------------------------------------------------------------
+
+! print *,' avant triggering, iflag_con ',iflag_con
 
   IF (iflag_con==3) THEN
 
-    CALL cv3_trigger(len, nd, icb1, plcl1, p1, th1, tv1, tvp1, thnk1 & !
-                                                                       ! nd->na
-      , pbase1, buoybase1, iflag1, sig1, w01)
-
-
-    ! print*, 'IFLAG1 apres cv3_triger'
-    ! print*,'len,nd',len,nd
-    ! write(*,'(64i1)') iflag1(2:klon-1)
-
-    ! call dump2d(iim,jjm-1,sig1(2)
+    CALL cv3_trigger(len, nd, icb1, plcl1, p1, th1, tv1, tvp1, thnk1, & ! nd->na
+                      pbase1, buoybase1, iflag1, sig1, w01)
+
+
+! print*, 'IFLAG1 apres cv3_triger'
+! print*,'len,nd',len,nd
+! write(*,'(64i1)') iflag1(2:klon-1)
+
+! call dump2d(iim,jjm-1,sig1(2)
   END IF
 
@@ -745,7 +742,7 @@
 
 
-  ! =====================================================================
-  ! --- IF THIS POINT IS REACHED, MOIST CONVECTIVE ADJUSTMENT IS NECESSARY
-  ! =====================================================================
+! =====================================================================
+! --- IF THIS POINT IS REACHED, MOIST CONVECTIVE ADJUSTMENT IS NECESSARY
+! =====================================================================
 
   ncum = 0
@@ -757,78 +754,98 @@
   END DO
 
-  ! print*,'klon, ncum = ',len,ncum
+! print*,'klon, ncum = ',len,ncum
 
   IF (ncum>0) THEN
 
-    ! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-    ! --- COMPRESS THE FIELDS
-    ! (-> vectorization over convective gridpoints)
-    ! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+! --- COMPRESS THE FIELDS
+!       (-> vectorization over convective gridpoints)
+! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
     IF (iflag_con==3) THEN
-      ! print*,'ncum tv1 ',ncum,tv1
-      ! print*,'tvp1 ',tvp1
-      CALL cv3a_compress(len, nloc, ncum, nd, ntra, iflag1, nk1, icb1, icbs1, &
-        plcl1, tnk1, qnk1, gznk1, hnk1, unk1, vnk1, wghti1, pbase1, &
-        buoybase1, t1, q1, qs1, t1_wake, q1_wake, qs1_wake, s1_wake, u1, v1, &
-        gz1, th1, th1_wake, tra1, h1, lv1, lf1, cpn1, p1, ph1, tv1, tp1, &
-        tvp1, clw1, h1_wake, lv1_wake, lf1_wake, cpn1_wake, tv1_wake, sig1, &
-        w01, ptop21, ale1, alp1, iflag, nk, icb, icbs, plcl, tnk, qnk, gznk, &
-        hnk, unk, vnk, wghti, pbase, buoybase, t, q, qs, t_wake, q_wake, &
-        qs_wake, s_wake, u, v, gz, th, th_wake, tra, h, lv, lf, cpn, p, ph, &
-        tv, tp, tvp, clw, h_wake, lv_wake, lf_wake, cpn_wake, tv_wake, sig, &
-        w0, ptop2, ale, alp)
-
-      ! print*,'tv ',tv
-      ! print*,'tvp ',tvp
+! print*,'ncum tv1 ',ncum,tv1
+! print*,'tvp1 ',tvp1
+      CALL cv3a_compress(len, nloc, ncum, nd, ntra, &
+                         iflag1, nk1, icb1, icbs1, &
+                         plcl1, tnk1, qnk1, gznk1, hnk1, unk1, vnk1, &
+                         wghti1, pbase1, buoybase1, &
+                         t1, q1, qs1, t1_wake, q1_wake, qs1_wake, s1_wake, &
+                         u1, v1, gz1, th1, th1_wake, &
+                         tra1, &
+                         h1, lv1, lf1, cpn1, p1, ph1, tv1, tp1, tvp1, clw1, &
+                         h1_wake, lv1_wake, lf1_wake, cpn1_wake, tv1_wake, &
+                         sig1, w01, ptop21, &
+                         Ale1, Alp1, &
+                         iflag, nk, icb, icbs, &
+                         plcl, tnk, qnk, gznk, hnk, unk, vnk, &
+                         wghti, pbase, buoybase, &
+                         t, q, qs, t_wake, q_wake, qs_wake, s_wake, &
+                         u, v, gz, th, th_wake, &
+                         tra, &
+                         h, lv, lf, cpn, p, ph, tv, tp, tvp, clw, &
+                         h_wake, lv_wake, lf_wake, cpn_wake, tv_wake, &
+                         sig, w0, ptop2, &
+                         Ale, Alp)
+
+! print*,'tv ',tv
+! print*,'tvp ',tvp
 
     END IF
 
     IF (iflag_con==4) THEN
-      CALL cv_compress(len, nloc, ncum, nd, iflag1, nk1, icb1, cbmf1, plcl1, &
-        tnk1, qnk1, gznk1, t1, q1, qs1, u1, v1, gz1, h1, lv1, cpn1, p1, ph1, &
-        tv1, tp1, tvp1, clw1, iflag, nk, icb, cbmf, plcl, tnk, qnk, gznk, t, &
-        q, qs, u, v, gz, h, lv, cpn, p, ph, tv, tp, tvp, clw, dph)
-    END IF
-
-    ! -------------------------------------------------------------------
-    ! --- UNDILUTE (ADIABATIC) UPDRAFT / second part :
-    ! ---   FIND THE REST OF THE LIFTED PARCEL TEMPERATURES
-    ! ---   &
-    ! ---   COMPUTE THE PRECIPITATION EFFICIENCIES AND THE
-    ! ---   FRACTION OF PRECIPITATION FALLING OUTSIDE OF CLOUD
-    ! ---   &
-    ! ---   FIND THE LEVEL OF NEUTRAL BUOYANCY
-    ! -------------------------------------------------------------------
+      CALL cv_compress(len, nloc, ncum, nd, &
+                       iflag1, nk1, icb1, &
+                       cbmf1, plcl1, tnk1, qnk1, gznk1, &
+                       t1, q1, qs1, u1, v1, gz1, &
+                       h1, lv1, cpn1, p1, ph1, tv1, tp1, tvp1, clw1, &
+                       iflag, nk, icb, &
+                       cbmf, plcl, tnk, qnk, gznk, &
+                       t, q, qs, u, v, gz, h, lv, cpn, p, ph, tv, tp, tvp, clw, &
+                       dph)
+    END IF
+
+! -------------------------------------------------------------------
+! --- UNDILUTE (ADIABATIC) UPDRAFT / second part :
+! ---   FIND THE REST OF THE LIFTED PARCEL TEMPERATURES
+! ---   &
+! ---   COMPUTE THE PRECIPITATION EFFICIENCIES AND THE
+! ---   FRACTION OF PRECIPITATION FALLING OUTSIDE OF CLOUD
+! ---   &
+! ---   FIND THE LEVEL OF NEUTRAL BUOYANCY
+! -------------------------------------------------------------------
 
     IF (iflag_con==3) THEN
-      CALL cv3_undilute2(nloc, ncum, nd, icb, icbs, nk & !na->nd
-        , tnk, qnk, gznk, hnk, t, q, qs, gz, p, h, tv, lv, lf, pbase, &
-        buoybase, plcl, inb, tp, tvp, clw, hp, ep, sigp, buoy, frac)
+      CALL cv3_undilute2(nloc, ncum, nd, icb, icbs, nk, &              !na->nd
+                         tnk, qnk, gznk, hnk, t, q, qs, gz, &
+                         p, h, tv, lv, lf, pbase, buoybase, plcl, &
+                         inb, tp, tvp, clw, hp, ep, sigp, buoy, &
+                         frac)
 
     END IF
 
     IF (iflag_con==4) THEN
-      CALL cv_undilute2(nloc, ncum, nd, icb, nk, tnk, qnk, gznk, t, q, qs, &
-        gz, p, dph, h, tv, lv, inb, inbis, tp, tvp, clw, hp, ep, sigp, frac)
-    END IF
-
-    ! -------------------------------------------------------------------
-    ! --- MIXING(1)   (if iflag_mix .ge. 1)
-    ! -------------------------------------------------------------------
+      CALL cv_undilute2(nloc, ncum, nd, icb, nk, &
+                        tnk, qnk, gznk, t, q, qs, gz, &
+                        p, dph, h, tv, lv, &
+                        inb, inbis, tp, tvp, clw, hp, ep, sigp, frac)
+    END IF
+
+! -------------------------------------------------------------------
+! --- MIXING(1)   (if iflag_mix .ge. 1)
+! -------------------------------------------------------------------
     IF (iflag_con==3) THEN
       IF ((iflag_ice_thermo==1) .AND. (iflag_mix/=0)) THEN
-        WRITE (*, *) ' iflag_ice_thermo==1 requires iflag_mix==0', &
-          ' but iflag_mix=', iflag_mix, '. Might as well stop here.'
+        WRITE (*, *) ' iflag_ice_thermo==1 requires iflag_mix==0', ' but iflag_mix=', iflag_mix, &
+          '. Might as well stop here.'
         STOP
       END IF
       IF (iflag_mix>=1) THEN
         CALL zilch(supmax, nloc*klev)
-        CALL cv3p_mixing(nloc, ncum, nd, nd, ntra, icb, nk, inb & !
-                                                                  ! na->nd
-          , ph, t, q, qs, u, v, tra, h, lv, qnk, unk, vnk, hp, tv, tvp, ep, &
-          clw, sig, ment, qent, hent, uent, vent, nent, sigij, elij, supmax, &
-          ments, qents, traent)
-        ! print*, 'cv3p_mixing-> supmax ', (supmax(1,k), k=1,nd)
+        CALL cv3p_mixing(nloc, ncum, nd, nd, ntra, icb, nk, inb, &           ! na->nd
+                         ph, t, q, qs, u, v, tra, h, lv, qnk, &
+                         unk, vnk, hp, tv, tvp, ep, clw, sig, &
+                         ment, qent, hent, uent, vent, nent, &
+                         sigij, elij, supmax, ments, qents, traent)
+! print*, 'cv3p_mixing-> supmax ', (supmax(1,k), k=1,nd)
 
       ELSE
@@ -836,13 +853,14 @@
       END IF
     END IF
-    ! -------------------------------------------------------------------
-    ! --- CLOSURE
-    ! -------------------------------------------------------------------
+! -------------------------------------------------------------------
+! --- CLOSURE
+! -------------------------------------------------------------------
 
 
     IF (iflag_con==3) THEN
       IF (iflag_clos==0) THEN
-        CALL cv3_closure(nloc, ncum, nd, icb, inb & ! na->nd
-          , pbase, p, ph, tv, buoy, sig, w0, cape, m, iflag)
+        CALL cv3_closure(nloc, ncum, nd, icb, inb, &           ! na->nd
+                         pbase, p, ph, tv, buoy, &
+                         sig, w0, cape, m, iflag)
       END IF
 
@@ -851,15 +869,16 @@
       IF (iflag_clos==1) THEN
         PRINT *, ' pas d appel cv3p_closure'
-        ! c        CALL cv3p_closure(nloc,ncum,nd,icb,inb              !
-        ! na->nd
-        ! c    :                       ,pbase,plcl,p,ph,tv,tvp,buoy
-        ! c    :                       ,supmax
-        ! c    o                       ,sig,w0,ptop2,cape,cin,m)
+! c        CALL cv3p_closure(nloc,ncum,nd,icb,inb              ! na->nd
+! c    :                       ,pbase,plcl,p,ph,tv,tvp,buoy
+! c    :                       ,supmax
+! c    o                       ,sig,w0,ptop2,cape,cin,m)
       END IF
       IF (iflag_clos==2) THEN
-        CALL cv3p1_closure(nloc, ncum, nd, icb, inb & ! na->nd
-          , pbase, plcl, p, ph, tv, tvp, buoy, supmax, ok_inhib, ale, alp, &
-          sig, w0, ptop2, cape, cin, m, iflag, coef_clos, plim1, plim2, &
-          asupmax, supmax0, asupmaxmin, cbmf, plfc, wbeff)
+        CALL cv3p1_closure(nloc, ncum, nd, icb, inb, &         ! na->nd
+                           pbase, plcl, p, ph, tv, tvp, buoy, &
+                           supmax, ok_inhib, Ale, Alp, &
+                           sig, w0, ptop2, cape, cin, m, iflag, coef_clos, &
+                           Plim1, plim2, asupmax, supmax0, &
+                           asupmaxmin, cbmf, plfc, wbeff)
 
         PRINT *, 'cv3p1_closure-> plfc,wbeff ', plfc(1), wbeff(1)
@@ -868,21 +887,21 @@
 
     IF (iflag_con==4) THEN
-      CALL cv_closure(nloc, ncum, nd, nk, icb, tv, tvp, p, ph, dph, plcl, &
-        cpn, iflag, cbmf)
-    END IF
-
-    ! print *,'cv_closure-> cape ',cape(1)
-
-    ! -------------------------------------------------------------------
-    ! --- MIXING(2)
-    ! -------------------------------------------------------------------
+      CALL cv_closure(nloc, ncum, nd, nk, icb, &
+                         tv, tvp, p, ph, dph, plcl, cpn, &
+                         iflag, cbmf)
+    END IF
+
+! print *,'cv_closure-> cape ',cape(1)
+
+! -------------------------------------------------------------------
+! --- MIXING(2)
+! -------------------------------------------------------------------
 
     IF (iflag_con==3) THEN
       IF (iflag_mix==0) THEN
-        CALL cv3_mixing(nloc, ncum, nd, nd, ntra, icb, nk, inb & !
-                                                                 ! na->nd
-          , ph, t, q, qs, u, v, tra, h, lv, lf, frac, qnk, unk, vnk, hp, tv, &
-          tvp, ep, clw, m, sig, ment, qent, uent, vent, nent, sigij, elij, &
-          ments, qents, traent)
+        CALL cv3_mixing(nloc, ncum, nd, nd, ntra, icb, nk, inb, &             ! na->nd
+                        ph, t, q, qs, u, v, tra, h, lv, lf, frac, qnk, &
+                        unk, vnk, hp, tv, tvp, ep, clw, m, sig, &
+                        ment, qent, uent, vent, nent, sigij, elij, ments, qents, traent)
         CALL zilch(hent, nloc*klev*klev)
       ELSE
@@ -895,19 +914,20 @@
 
     IF (iflag_con==4) THEN
-      CALL cv_mixing(nloc, ncum, nd, icb, nk, inb, inbis, ph, t, q, qs, u, v, &
-        h, lv, qnk, hp, tv, tvp, ep, clw, cbmf, m, ment, qent, uent, vent, &
-        nent, sigij, elij)
-    END IF
+      CALL cv_mixing(nloc, ncum, nd, icb, nk, inb, inbis, &
+                     ph, t, q, qs, u, v, h, lv, qnk, &
+                     hp, tv, tvp, ep, clw, cbmf, &
+                     m, ment, qent, uent, vent, nent, sigij, elij)
+    END IF                                                                                         
 
     IF (debut) THEN
       PRINT *, ' cv_mixing ->'
     END IF !(debut) THEN
-    ! do i = 1,klev
-    ! print*,'cv_mixing-> i,ment ',i,(ment(1,i,j),j=1,klev)
-    ! enddo
-
-    ! -------------------------------------------------------------------
-    ! --- UNSATURATED (PRECIPITATING) DOWNDRAFTS
-    ! -------------------------------------------------------------------
+! do i = 1,klev
+! print*,'cv_mixing-> i,ment ',i,(ment(1,i,j),j=1,klev)
+! enddo
+
+! -------------------------------------------------------------------
+! --- UNSATURATED (PRECIPITATING) DOWNDRAFTS
+! -------------------------------------------------------------------
     IF (iflag_con==3) THEN
       IF (debut) THEN
@@ -915,15 +935,18 @@
       END IF !(debut) THEN
 
-      CALL cv3_unsat(nloc, ncum, nd, nd, ntra, icb, inb, iflag & !
-                                                                 ! na->nd
-        , t_wake, q_wake, qs_wake, gz, u, v, tra, p, ph, th_wake, tv_wake, &
-        lv_wake, lf_wake, cpn_wake, ep, sigp, clw, m, ment, elij, delt, plcl, &
-        coef_clos, mp, qp, up, vp, trap, wt, water, evap, fondue, ice, faci, &
-        b, sigd, wdtraina, wdtrainm) ! RomP
+      CALL cv3_unsat(nloc, ncum, nd, nd, ntra, icb, inb, iflag, &              ! na->nd
+                     t_wake, q_wake, qs_wake, gz, u, v, tra, p, ph, &
+                     th_wake, tv_wake, lv_wake, lf_wake, cpn_wake, &
+                     ep, sigp, clw, &
+                     m, ment, elij, delt, plcl, coef_clos, &
+                     mp, qp, up, vp, trap, wt, water, evap, fondue, ice, &
+                     faci, b, sigd, &
+                     wdtrainA, wdtrainM)                                       ! RomP
     END IF
 
     IF (iflag_con==4) THEN
-      CALL cv_unsat(nloc, ncum, nd, inb, t, q, qs, gz, u, v, p, ph, h, lv, &
-        ep, sigp, clw, m, ment, elij, iflag, mp, qp, up, vp, wt, water, evap)
+      CALL cv_unsat(nloc, ncum, nd, inb, t, q, qs, gz, u, v, p, ph, &
+                     h, lv, ep, sigp, clw, m, ment, elij, &
+                     iflag, mp, qp, up, vp, wt, water, evap)
     END IF
 
@@ -932,21 +955,27 @@
     END IF !(debut) THEN
 
-    ! print *,'cv_unsat-> mp ',mp
-    ! print *,'cv_unsat-> water ',water
-    ! -------------------------------------------------------------------
-    ! --- YIELD
-    ! (tendencies, precipitation, variables of interface with other
-    ! processes, etc)
-    ! -------------------------------------------------------------------
+! print *,'cv_unsat-> mp ',mp
+! print *,'cv_unsat-> water ',water
+! -------------------------------------------------------------------
+! --- YIELD
+! (tendencies, precipitation, variables of interface with other
+! processes, etc)
+! -------------------------------------------------------------------
 
     IF (iflag_con==3) THEN
 
-      CALL cv3_yield(nloc, ncum, nd, nd, ntra & ! na->nd
-        , icb, inb, delt, t, q, t_wake, q_wake, s_wake, u, v, tra, gz, p, ph, &
-        h, hp, lv, lf, cpn, th, th_wake, ep, clw, m, tp, mp, qp, up, vp, &
-        trap, wt, water, ice, evap, fondue, faci, b, sigd, ment, qent, hent, &
-        iflag_mix, uent, vent, nent, elij, traent, sig, tv, tvp, wghti, &
-        iflag, precip, vprecip, ft, fq, fu, fv, ftra, cbmf, upwd, dnwd, &
-        dnwd0, ma, mip, tls, tps, qcondc, wd, ftd, fqd)
+      CALL cv3_yield(nloc, ncum, nd, nd, ntra, ok_conserv_q, &                      ! na->nd
+                     icb, inb, delt, &
+                     t, q, t_wake, q_wake, s_wake, u, v, tra, &
+                     gz, p, ph, h, hp, lv, lf, cpn, th, th_wake, &
+                     ep, clw, m, tp, mp, qp, up, vp, trap, &
+                     wt, water, ice, evap, fondue, faci, b, sigd, &
+                     ment, qent, hent, iflag_mix, uent, vent, &
+                     nent, elij, traent, sig, &
+                     tv, tvp, wghti, &
+                     iflag, precip, vprecip, ft, fq, fu, fv, ftra, &
+                     cbmf, upwd, dnwd, dnwd0, ma, mip, &
+                     tls, tps, qcondc, wd, &
+                     ftd, fqd)
     END IF
 
@@ -956,50 +985,74 @@
 
     IF (iflag_con==4) THEN
-      CALL cv_yield(nloc, ncum, nd, nk, icb, inb, delt, t, q, u, v, gz, p, &
-        ph, h, hp, lv, cpn, ep, clw, frac, m, mp, qp, up, vp, wt, water, &
-        evap, ment, qent, uent, vent, nent, elij, tv, tvp, iflag, wd, qprime, &
-        tprime, precip, cbmf, ft, fq, fu, fv, ma, qcondc)
-    END IF
-
-    ! AC!
-    ! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-    ! --- passive tracers
-    ! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+      CALL cv_yield(nloc, ncum, nd, nk, icb, inb, delt, &
+                     t, q, u, v, &
+                     gz, p, ph, h, hp, lv, cpn, &
+                     ep, clw, frac, m, mp, qp, up, vp, &
+                     wt, water, evap, &
+                     ment, qent, uent, vent, nent, elij, &
+                     tv, tvp, &
+                     iflag, wd, qprime, tprime, &
+                     precip, cbmf, ft, fq, fu, fv, ma, qcondc)
+    END IF
+
+!AC!
+!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+!--- passive tracers
+!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
     IF (iflag_con==3) THEN
-      ! RomP >>>
-      CALL cv3_tracer(nloc, len, ncum, nd, nd, ment, sigij, da, phi, phi2, &
-        d1a, dam, ep, vprecip, elij, clw, epmlmmm, eplamm, icb, inb)
-      ! RomP <<<
-    END IF
-
-    ! AC!
-
-    ! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-    ! --- UNCOMPRESS THE FIELDS
-    ! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+!RomP >>>
+      CALL cv3_tracer(nloc, len, ncum, nd, nd, &
+                     ment, sigij, da, phi, phi2, d1a, dam, &
+                     ep, vprecip, elij, clw, epmlmMm, eplaMm, &
+                     icb, inb)
+!RomP <<<
+    END IF
+
+!AC!
+
+! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+! --- UNCOMPRESS THE FIELDS
+! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 
     IF (iflag_con==3) THEN
-      CALL cv3a_uncompress(nloc, len, ncum, nd, ntra, idcum, iflag, icb, inb, &
-        precip, cbmf, plcl, plfc, wbeff, sig, w0, ptop2, ft, fq, fu, fv, &
-        ftra, sigd, ma, mip, vprecip, upwd, dnwd, dnwd0, qcondc, wd, cape, &
-        cin, tvp, ftd, fqd, plim1, plim2, asupmax, supmax0, asupmaxmin, da, &
-        phi, mp, phi2, d1a, dam, sigij & ! RomP
-        , clw, elij, evap, ep, epmlmmm, eplamm & ! RomP
-        , wdtraina, wdtrainm &     ! RomP
-        , iflag1, kbas1, ktop1, precip1, cbmf1, plcl1, plfc1, wbeff1, sig1, &
-        w01, ptop21, ft1, fq1, fu1, fv1, ftra1, sigd1, ma1, mip1, vprecip1, &
-        upwd1, dnwd1, dnwd01, qcondc1, wd1, cape1, cin1, tvp1, ftd1, fqd1, &
-        plim11, plim21, asupmax1, supmax01, asupmaxmin1, da1, phi1, mp1, &
-        phi21, d1a1, dam1, sigij1 & ! RomP
-        , clw1, elij1, evap1, ep1, epmlmmm1, eplamm1 & ! RomP
-        , wdtraina1, wdtrainm1) ! RomP
+      CALL cv3a_uncompress(nloc, len, ncum, nd, ntra, idcum, &
+                           iflag, icb, inb, &
+                           precip, cbmf, plcl, plfc, wbeff, sig, w0, ptop2, &
+                           ft, fq, fu, fv, ftra, &
+                           sigd, ma, mip, vprecip, upwd, dnwd, dnwd0, &
+                           qcondc, wd, cape, cin, &
+                           tvp, &
+                           ftd, fqd, &
+                           Plim1, plim2, asupmax, supmax0, &
+                           asupmaxmin, &
+                           da, phi, mp, phi2, d1a, dam, sigij, &         ! RomP
+                           clw, elij, evap, ep, epmlmMm, eplaMm, &       ! RomP
+                           wdtrainA, wdtrainM, &                         ! RomP
+                           iflag1, kbas1, ktop1, &
+                           precip1, cbmf1, plcl1, plfc1, wbeff1, sig1, w01, ptop21, &
+                           ft1, fq1, fu1, fv1, ftra1, &
+                           sigd1, ma1, mip1, vprecip1, upwd1, dnwd1, dnwd01, &
+                           qcondc1, wd1, cape1, cin1, &
+                           tvp1, &
+                           ftd1, fqd1, &
+                           Plim11, plim21, asupmax1, supmax01, &
+                           asupmaxmin1, &
+                           da1, phi1, mp1, phi21, d1a1, dam1, sigij1,  & ! RomP
+                           clw1, elij1, evap1, ep1, epmlmMm1, eplaMm1, & ! RomP
+                           wdtrainA1, wdtrainM1)                         ! RomP
     END IF
 
     IF (iflag_con==4) THEN
-      CALL cv_uncompress(nloc, len, ncum, nd, idcum, iflag, precip, cbmf, ft, &
-        fq, fu, fv, ma, qcondc, iflag1, precip1, cbmf1, ft1, fq1, fu1, fv1, &
-        ma1, qcondc1)
+      CALL cv_uncompress(nloc, len, ncum, nd, idcum, &
+                           iflag, &
+                           precip, cbmf, &
+                           ft, fq, fu, fv, &
+                           ma, qcondc, &
+                           iflag1, &
+                           precip1,cbmf1, &
+                           ft1, fq1, fu1, fv1, &
+                           ma1, qcondc1)
     END IF
 
@@ -1009,5 +1062,6 @@
     PRINT *, ' cv_compress -> '
     debut = .FALSE.
-  END IF !(debut) THEN
+  END IF  !(debut) THEN
+
 
   RETURN
Index: /LMDZ5/branches/testing/libf/phylmd/cvltr.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/cvltr.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/cvltr.F90	(revision 2056)
@@ -3,5 +3,6 @@
 !
 SUBROUTINE cvltr(pdtime, da, phi,phi2,d1a,dam, mpIN,epIN, &
-           sigd,sij,clw,elij,epmlmMm,eplaMm,              &
+!!           sigd,sij,clw,elij,epmlmMm,eplaMm,              &   !RL
+           sigd,sij,wght_cvfd,clw,elij,epmlmMm,eplaMm,    &     !RL
            pmflxrIN,pmflxsIN,ev,te,wdtrainA,wdtrainM,     &
            paprs,it,tr,upd,dnd,inb,icb,                   &
@@ -47,4 +48,5 @@
   REAL,DIMENSION(klon,klev),INTENT(IN)      :: te 
   REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: sij        ! fraction dair de lenv
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: wght_cvfd  ! weights of the layers feeding convection
   REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: elij       ! contenu en eau condensée spécifique/conc deau condensée massique
   REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: epmlmMm    ! eau condensee precipitee dans mel masse dair sat
@@ -71,4 +73,5 @@
   REAL,DIMENSION(klon,klev,nbtr)    :: zmfd,zmfa
   REAL,DIMENSION(klon,klev,nbtr)    :: zmfp,zmfu
+  REAL,DIMENSION(klon,nbtr)         :: qfeed     ! tracer concentration feeding convection
 
   REAL,DIMENSION(klon,klev,nbtr),INTENT(OUT)    :: zmfd1a
@@ -168,5 +171,5 @@
    scavtrac = 0.
    uscavtrac = 0.
-
+   qfeed(:,it) = 0.              !RL
   DO j=1,klev
    DO i=1,klon
@@ -330,9 +333,23 @@
 ! calcul des tendances liees aux courants satures   j <-> z ; k <-> z'
 ! =========================================
+!
+!RL
+!  Feeding concentrations
   DO j=1,klev
      DO i=1,klon
-        zmfa(i,j,it)=da(i,j)*(tr(i,1,it)-tr(i,j,it))                     ! da
-     END DO
-  END DO
+        qfeed(i,it)=qfeed(i,it)+wght_cvfd(i,j)*tr(i,j,it)
+     END DO
+  END DO
+!RL
+!
+  DO j=1,klev
+     DO i=1,klon
+!RL
+!!        zmfa(i,j,it)=da(i,j)*(tr(i,1,it)-tr(i,j,it))                     ! da
+        zmfa(i,j,it)=da(i,j)*(qfeed(i,it)-tr(i,j,it))                     ! da
+!RL
+     END DO
+  END DO
+!
   DO k=1,klev
      DO j=1,klev
Index: /LMDZ5/branches/testing/libf/phylmd/cvltr_noscav.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/cvltr_noscav.F90	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/cvltr_noscav.F90	(revision 2056)
@@ -0,0 +1,197 @@
+!
+! $Id $
+!
+SUBROUTINE cvltr_noscav(it,pdtime,da, phi, mp,wght_cvfd,paprs,pplay,x,upd,dnd,dx)
+  USE dimphy
+  USE infotrac, ONLY : nbtr
+  IMPLICIT NONE 
+!=====================================================================
+! Objet : convection des traceurs / KE
+! Auteurs: M-A Filiberti and J-Y Grandpeix
+!=====================================================================
+  include "YOMCST.h"
+  include "YOECUMF.h" 
+
+! Entree
+  REAL,INTENT(IN)                           :: pdtime
+  INTEGER, INTENT(IN)                       :: it
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: da
+  REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: phi
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: mp
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: wght_cvfd  ! weights of the layers feeding convection
+  REAL,DIMENSION(klon,klev+1),INTENT(IN)    :: paprs ! pression aux 1/2 couches (bas en haut)
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: pplay ! pression pour le milieu de chaque couche
+  REAL,DIMENSION(klon,klev,nbtr),INTENT(IN)      :: x     ! q de traceur (bas en haut) 
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: upd   ! saturated updraft mass flux
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: dnd   ! saturated downdraft mass flux
+
+! Sortie
+  REAL,DIMENSION(klon,klev,nbtr),INTENT(OUT) :: dx ! tendance de traceur  (bas en haut)
+
+! Variables locales     
+! REAL,DIMENSION(klon,klev)       :: zed
+  REAL,DIMENSION(klon,klev,klev)  :: zmd
+  REAL,DIMENSION(klon,klev,klev)  :: za
+  REAL,DIMENSION(klon,klev)       :: zmfd,zmfa
+  REAL,DIMENSION(klon,klev)       :: zmfp,zmfu
+  REAL,DIMENSION(klon,nbtr)       :: qfeed     ! tracer concentration feeding convection
+  REAL,DIMENSION(klon,klev)       :: deltap
+  INTEGER                         :: i,k,j 
+  REAL                            :: pdtimeRG
+  real conserv
+  real smfd
+  real smfu
+  real smfa
+  real smfp
+! =========================================
+! calcul des tendances liees au downdraft
+! =========================================
+!cdir collapse
+  qfeed(:,it) = 0.
+  DO j=1,klev
+  DO i=1,klon
+!   zed(i,j)=0.
+    zmfd(i,j)=0.
+    zmfa(i,j)=0.
+    zmfu(i,j)=0.
+    zmfp(i,j)=0.
+  END DO
+  END DO
+!cdir collapse
+  DO k=1,klev
+  DO j=1,klev
+  DO i=1,klon
+    zmd(i,j,k)=0.
+    za (i,j,k)=0.
+  END DO
+  END DO
+  END DO
+! entrainement
+! DO k=1,klev-1
+!    DO i=1,klon
+!       zed(i,k)=max(0.,mp(i,k)-mp(i,k+1))
+!    END DO
+! END DO
+
+! calcul de la matrice d echange
+! matrice de distribution de la masse entrainee en k
+
+  DO k=1,klev-1
+     DO i=1,klon
+        zmd(i,k,k)=max(0.,mp(i,k)-mp(i,k+1))
+     END DO
+  END DO
+  DO k=2,klev
+     DO j=k-1,1,-1
+        DO i=1,klon
+           if(mp(i,j+1).ne.0) then
+              zmd(i,j,k)=zmd(i,j+1,k)*min(1.,mp(i,j)/mp(i,j+1))
+           ENDif
+        END DO
+     END DO
+  END DO
+  DO k=1,klev
+     DO j=1,klev-1
+        DO i=1,klon
+           za(i,j,k)=max(0.,zmd(i,j+1,k)-zmd(i,j,k))
+        END DO
+     END DO
+  END DO
+!
+! rajout du terme lie a l ascendance induite
+!
+  DO j=2,klev
+     DO i=1,klon
+        za(i,j,j-1)=za(i,j,j-1)+mp(i,j)
+     END DO
+  END DO
+!
+! tendances
+!            
+  DO k=1,klev
+     DO j=1,klev
+        DO i=1,klon
+           zmfd(i,j)=zmfd(i,j)+za(i,j,k)*(x(i,k,it)-x(i,j,it))
+        END DO
+     END DO
+  END DO
+!
+! =========================================
+! calcul des tendances liees aux flux satures
+! =========================================
+!RL
+!  Feeding concentrations
+  DO j=1,klev
+     DO i=1,klon
+        qfeed(i,it)=qfeed(i,it)+wght_cvfd(i,j)*x(i,j,it)
+     END DO
+  END DO
+!RL
+!
+  DO j=1,klev
+     DO i=1,klon
+!RL
+!!        zmfa(i,j,it)=da(i,j)*(x(i,1,it)-x(i,j,it))                     ! da
+        zmfa(i,j)=da(i,j)*(qfeed(i,it)-x(i,j,it))                     ! da
+!RL
+     END DO
+  END DO
+!
+!!  print *,'it, qfeed(1,it), x(1,1,it) ', it, qfeed(1,it), x(1,1,it)  !jyg
+!!  print *,'wght_cvfd ', (j, wght_cvfd(1,j), j=1,5)                     !jyg
+!
+  DO k=1,klev
+     DO j=1,klev
+        DO i=1,klon
+           zmfp(i,j)=zmfp(i,j)+phi(i,j,k)*(x(i,k,it)-x(i,j,it))
+        END DO
+     END DO
+  END DO
+  DO j=1,klev-1
+     DO i=1,klon
+        zmfu(i,j)=max(0.,upd(i,j+1)+dnd(i,j+1))*(x(i,j+1,it)-x(i,j,it))
+     END DO
+  END DO
+  DO j=2,klev
+     DO i=1,klon
+        zmfu(i,j)=zmfu(i,j)+min(0.,upd(i,j)+dnd(i,j))*(x(i,j,it)-x(i,j-1,it))
+     END DO
+  END DO
+
+! =========================================
+! calcul final des tendances
+! =========================================
+  DO k=1, klev
+     DO i=1, klon
+        deltap(i,k)=paprs(i,k)-paprs(i,k+1)
+     ENDDO
+  ENDDO
+  pdtimeRG=pdtime*RG
+!cdir collapse
+  DO k=1, klev
+     DO i=1, klon
+        dx(i,k,it)=(zmfd(i,k)+zmfu(i,k)       &
+                +zmfa(i,k)+zmfp(i,k))*pdtimeRG/deltap(i,k)
+     ENDDO
+  ENDDO
+
+!! test de conservation du traceur
+      conserv=0.
+      smfd = 0.
+      smfu = 0.
+      smfa = 0.
+      smfp = 0.
+      DO k=1, klev
+        DO i=1, klon
+         conserv=conserv+dx(i,k,it)*   &
+          deltap(i,k)/RG
+         smfd = smfd + zmfd(i,k)*pdtime
+         smfu = smfu + zmfu(i,k)*pdtime
+         smfa = smfa + zmfa(i,k)*pdtime
+         smfp = smfp + zmfp(i,k)*pdtime
+        ENDDO
+      ENDDO
+!!      print *,'it',it,'cvltr_noscav conserv, smfd, smfu, smfa, smfp ',conserv,  &
+!!               smfd, smfu, smfa, smfp
+     
+END SUBROUTINE cvltr_noscav
Index: /LMDZ5/branches/testing/libf/phylmd/ener_conserv.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/ener_conserv.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/ener_conserv.F90	(revision 2056)
@@ -20,5 +20,6 @@
 ! From module
 USE phys_local_var_mod, ONLY : d_u_vdf,d_v_vdf,d_t_vdf,d_u_ajs,d_v_ajs,d_t_ajs,d_u_con,d_v_con,d_t_con,d_t_diss
-USE phys_output_var_mod, ONLY : bils_ec,bils_tke,bils_kinetic,bils_enthalp,bils_latent,bils_diss
+USE phys_local_var_mod, ONLY : d_t_eva,d_t_lsc,d_q_eva,d_q_lsc
+USE phys_output_var_mod, ONLY : bils_ec,bils_ech,bils_tke,bils_kinetic,bils_enthalp,bils_latent,bils_diss
 
 IMPLICIT none
@@ -41,5 +42,5 @@
 REAL, DIMENSION(klon,klev+1) :: fluxu,fluxv,fluxt
 REAL, DIMENSION(klon,klev+1) :: dddu,dddv,dddt
-REAL, DIMENSION(klon,klev) :: d_u,d_v,d_t,zv,zu
+REAL, DIMENSION(klon,klev) :: d_u,d_v,d_t,zv,zu,d_t_ech
 REAL ZRCPD
 
@@ -131,8 +132,7 @@
 
    do k=1,klev
-      d_t_ec(:,k)=-(dddu(:,k)+dddu(:,k+1)+dddv(:,k)+dddv(:,k+1) &
-   &  +rcpd*(dddt(:,k)+dddt(:,k+1)))/(2.*rcpd*masse(:,k))
+      d_t_ech(:,k)=-(rcpd*(dddt(:,k)+dddt(:,k+1)))/(2.*rcpd*masse(:,k))
+      d_t_ec(:,k)=-(dddu(:,k)+dddu(:,k+1)+dddv(:,k)+dddv(:,k+1))/(2.*rcpd*masse(:,k))+d_t_ech(:,k)
    enddo
-! d_t_ec=0.
 
 ENDIF
@@ -141,4 +141,13 @@
 !  Computation of integrated enthalpie and kinetic energy variation
 !  FH (hourdin@lmd.jussieu.fr), 2013/04/25
+!  bils_ec : energie conservation term
+!  bils_ech : part of this term linked to temperature
+!  bils_tke : change of TKE
+!  bils_diss : dissipation of TKE (when activated)
+!  bils_kinetic : change of kinetic energie of the column
+!  bils_enthalp : change of enthalpie
+!  bils_latent  : change of latent heat. Computed between
+!          after reevaporation (at the beginning of the physics)
+!          and before large scale condensation (fisrtilp)
 !================================================================
 
@@ -157,7 +166,9 @@
      &            -puo(:,k)*puo(:,k)-pvo(:,k)*pvo(:,k))
         bils_enthalp(:)= &
-     &  bils_enthalp(:)+masse(:,k)*(ptn(:,k)-pto(:,k)+d_t_ec(:,k))
+     &  bils_enthalp(:)+masse(:,k)*(ptn(:,k)-pto(:,k)+d_t_ec(:,k)-d_t_eva(:,k)-d_t_lsc(:,k))
+!    &  bils_enthalp(:)+masse(:,k)*(ptn(:,k)-pto(:,k)+d_t_ec(:,k))
         bils_latent(:)=bils_latent(:)+masse(:,k)* &
-     &             (pqn(:,k)-pqo(:,k))
+!    &             (pqn(:,k)-pqo(:,k))
+     &             (pqn(:,k)-pqo(:,k)-d_q_eva(:,k)-d_q_lsc(:,k))
       ENDDO
       bils_ec(:)=rcpd*bils_ec(:)/pdtphys
@@ -167,4 +178,13 @@
       bils_enthalp(:)=rcpd*bils_enthalp(:)/pdtphys
       bils_latent(:)=rlvtt*bils_latent(:)/pdtphys
+
+IF (iflag_ener_conserv>=1) THEN
+      bils_ech(:)=0.
+      DO k=1,klev
+        bils_ech(:)=bils_ech(:)-d_t_ech(:,k)*masse(:,k)
+      ENDDO
+      bils_ech(:)=rcpd*bils_ech(:)/pdtphys
+ENDIF
+
 RETURN
 
Index: /LMDZ5/branches/testing/libf/phylmd/etat0_netcdf.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/etat0_netcdf.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/etat0_netcdf.F90	(revision 2056)
@@ -29,4 +29,7 @@
   USE netcdf, ONLY : NF90_OPEN, NF90_NOWRITE, NF90_CLOSE, NF90_NOERR
   USE indice_sol_mod
+  use exner_hyb_m, only: exner_hyb
+  use exner_milieu_m, only: exner_milieu
+  use test_disvert_m, only: test_disvert
 #endif
   IMPLICIT NONE
@@ -74,5 +77,5 @@
   CHARACTER(LEN=80)                        :: x, fmt
   INTEGER                                  :: i, j, l, ji
-  REAL,    DIMENSION(iip1,jjp1,llm)        :: alpha, beta, pk, pls, y
+  REAL,    DIMENSION(iip1,jjp1,llm)        :: pk, pls, y
   REAL,    DIMENSION(ip1jmp1)              :: pks
 
@@ -150,4 +153,5 @@
 
   CALL iniconst()
+  if (pressure_exner) call test_disvert
   CALL inigeom()
 
@@ -253,7 +257,7 @@
   CALL pression(ip1jmp1, ap, bp, psol, p3d)
   if (pressure_exner) then
-    CALL exner_hyb(ip1jmp1, psol, p3d, alpha, beta, pks, pk, y)
+    CALL exner_hyb(ip1jmp1, psol, p3d, pks, pk)
   else
-    CALL exner_milieu(ip1jmp1,psol,p3d,beta,pks,pk,y)
+    CALL exner_milieu(ip1jmp1,psol,p3d, pks,pk)
   endif
   pls(:,:,:)=preff*(pk(:,:,:)/cpp)**(1./kappa)
Index: /LMDZ5/branches/testing/libf/phylmd/fcg_gcssold.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/fcg_gcssold.h	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/fcg_gcssold.h	(revision 2056)
@@ -0,0 +1,46 @@
+!
+! $Id: fcg_gcssold.h 2010-08-10 17:02:56Z lahellec $
+!
+      logical :: imp_fcg_gcssold,ts_fcg_gcssold,Tp_fcg_gcssold
+      logical :: Tp_ini_gcssold
+      logical :: xTurb_fcg_gcssold
+
+      common /fcg_gcssold/imp_fcg_gcssold,ts_fcg_gcssold,Tp_fcg_gcssold,        & 
+     & Tp_ini_gcssold,                                                          &
+     & xTurb_fcg_gcssold
+
+!$OMP THREADPRIVATE(/fcg_gcssold/)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /LMDZ5/branches/testing/libf/phylmd/fcg_racmo.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/fcg_racmo.h	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/fcg_racmo.h	(revision 2056)
@@ -0,0 +1,45 @@
+!
+! $Id: fcg_racmo.h 2011-02-16 17:02:56Z cheruy $
+!
+      real   :: a_guide 
+      logical :: ok_invertp 
+      integer :: forc_trb
+      character*31 :: fich_racmo
+
+      common /fcg_racmo/forc_trb,ok_invertp,a_guide,fich_racmo
+
+!$OMP THREADPRIVATE(/fcg_racmo/)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /LMDZ5/branches/testing/libf/phylmd/fisrtilp.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/fisrtilp.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/fisrtilp.F90	(revision 2056)
@@ -13,4 +13,5 @@
   !
   USE dimphy
+  USE microphys_mod ! cloud microphysics (JBM 3/14)
   IMPLICIT none
   !======================================================================
@@ -26,4 +27,5 @@
   include "tracstoke.h"
   include "fisrtilp.h"
+  include "nuage.h" ! JBM (3/14)
   include "iniprint.h"
 
@@ -111,6 +113,10 @@
   REAL zoliq(klon), zcond(klon), zq(klon), zqn(klon), zdelq 
   REAL zoliqp(klon), zoliqi(klon)
-  REAL ztglace, zt(klon)
-  INTEGER nexpo ! exponentiel pour glace/eau
+  REAL zt(klon)
+! JBM (3/14) nexpo is replaced by exposant_glace
+! REAL nexpo ! exponentiel pour glace/eau
+! INTEGER, PARAMETER :: nexpo=6
+  INTEGER exposant_glace_old
+  REAL t_glace_min_old
   REAL zdz(klon),zrho(klon),ztot      , zrhol(klon)
   REAL zchau      ,zfroi      ,zfice(klon),zneb(klon)
@@ -202,11 +208,17 @@
   !  nexpo regle la raideur de la transition eau liquide / eau glace.
   !
-  ztglace = RTT - 15.0
-!AJ<
-  IF (ice_thermo) THEN
-    nexpo = 2
-  ELSE
-    nexpo = 6
+  IF (iflag_t_glace.EQ.0) THEN
+!   ztglace = RTT - 15.0
+    t_glace_min_old = RTT - 15.0
+    !AJ<
+    IF (ice_thermo) THEN
+!     nexpo = 2
+      exposant_glace_old = 2
+    ELSE
+!     nexpo = 6
+      exposant_glace_old = 6
+    ENDIF
   ENDIF
+  
 !!  RLVTT = 2.501e6 ! pas de redefinition des constantes physiques (jyg)
 !!  RLSTT = 2.834e6 ! pas de redefinition des constantes physiques (jyg)
@@ -710,9 +722,11 @@
         endif
      ELSE
+       IF (iflag_t_glace.EQ.0) THEN
          if (iflag_fisrtilp_qsat.lt.1) then
            DO i = 1, klon
-              zfice(i) = 1.0 - (zt(i)-ztglace) / (273.15-ztglace)
+              zfice(i) = 1.0 - (zt(i)-t_glace_min_old) / (273.15-t_glace_min_old)
               zfice(i) = MIN(MAX(zfice(i),0.0),1.0)
-              zfice(i) = zfice(i)**nexpo
+              zfice(i) = zfice(i)**exposant_glace_old
+!             zfice(i) = zfice(i)**nexpo
               zt(i) = zt(i) + (1.-zfice(i))*zcond(i) * RLVTT/RCPD/(1.0+RVTMP2*zq(i)) &
                        +zfice(i)*zcond(i) * RLSTT/RCPD/(1.0+RVTMP2*zq(i))
@@ -720,7 +734,8 @@
          else
            DO i=1, klon
-              zfice(i) = 1.0 - (zt(i)-ztglace) / (273.15-ztglace)
+              zfice(i) = 1.0 - (zt(i)-t_glace_min_old) / (273.15-t_glace_min_old)
               zfice(i) = MIN(MAX(zfice(i),0.0),1.0)
-              zfice(i) = zfice(i)**nexpo
+              zfice(i) = zfice(i)**exposant_glace_old
+!             zfice(i) = zfice(i)**nexpo
 !CR: ATTENTION zt different de Tbef: à corriger
               zt(i) = zt(i) + (1.-zfice(i))*zcond(i) * RLVTT/RCPD/(1.0+RVTMP2*(zq(i)+zcond(i))) &
@@ -729,4 +744,25 @@
          endif
 !         print*,zt(i),zrfl(i),zifl(i),'temp1'
+       ELSE ! of IF (iflag_t_glace.EQ.0)
+         if (iflag_fisrtilp_qsat.lt.1) then
+           DO i = 1, klon
+! JBM: icefrac_lsc is now a function contained in microphys_mod
+              zfice(i) = icefrac_lsc(zt(i), t_glace_min, &
+                                     t_glace_max, exposant_glace)
+              zt(i) = zt(i) + (1.-zfice(i))*zcond(i) * RLVTT/RCPD/(1.0+RVTMP2*zq(i)) &
+                       +zfice(i)*zcond(i) * RLSTT/RCPD/(1.0+RVTMP2*zq(i))
+           ENDDO
+         else
+           DO i=1, klon
+! JBM: icefrac_lsc is now a function contained in microphys_mod
+              zfice(i) = icefrac_lsc(zt(i), t_glace_min, &
+                                     t_glace_max, exposant_glace)
+!CR: ATTENTION zt different de Tbef: à corriger
+              zt(i) = zt(i) + (1.-zfice(i))*zcond(i) * RLVTT/RCPD/(1.0+RVTMP2*(zq(i)+zcond(i))) &
+                       +zfice(i)*zcond(i) * RLSTT/RCPD/(1.0+RVTMP2*(zq(i)+zcond(i)))
+           ENDDO
+         endif
+!         print*,zt(i),zrfl(i),zifl(i),'temp1'
+       ENDIF
      ENDIF
 !>AJ
@@ -743,12 +779,23 @@
 !AJ<
      IF (.NOT. ice_thermo) THEN
-     DO i = 1, klon
-        IF (rneb(i,k).GT.0.0) THEN
-           zfice(i) = 1.0 - (zt(i)-ztglace) / (273.13-ztglace)
-           zfice(i) = MIN(MAX(zfice(i),0.0),1.0)
-           zfice(i) = zfice(i)**nexpo
-     !!      zfice(i)=0.
-        ENDIF
-     ENDDO
+       IF (iflag_t_glace.EQ.0) THEN
+         DO i = 1, klon
+            IF (rneb(i,k).GT.0.0) THEN
+               zfice(i) = 1.0 - (zt(i)-t_glace_min_old) / (273.13-t_glace_min_old)
+               zfice(i) = MIN(MAX(zfice(i),0.0),1.0)
+               zfice(i) = zfice(i)**exposant_glace_old
+!              zfice(i) = zfice(i)**nexpo
+         !!      zfice(i)=0.
+            ENDIF
+         ENDDO
+       ELSE ! of IF (iflag_t_glace.EQ.0)
+         DO i = 1, klon
+            IF (rneb(i,k).GT.0.0) THEN
+! JBM: icefrac_lsc is now a function contained in microphys_mod
+              zfice(i) = icefrac_lsc(zt(i), t_glace_min, &
+                                     t_glace_max, exposant_glace)
+            ENDIF
+         ENDDO
+       ENDIF
      ENDIF
      DO i = 1, klon
@@ -895,9 +942,17 @@
         IF (rneb(i,k).GT.0.0.and.zprec_cond(i).gt.0.) THEN
            !AA lessivage nucleation LMD5 dans la couche elle-meme
-           if (t(i,k) .GE. ztglace) THEN
+          IF (iflag_t_glace.EQ.0) THEN
+           if (t(i,k) .GE. t_glace_min_old) THEN
               zalpha_tr = a_tr_sca(3)
            else
               zalpha_tr = a_tr_sca(4)
            endif
+          ELSE ! of IF (iflag_t_glace.EQ.0)
+           if (t(i,k) .GE. t_glace_min) THEN
+              zalpha_tr = a_tr_sca(3)
+           else
+              zalpha_tr = a_tr_sca(4)
+           endif
+          ENDIF
            zfrac_lessi = 1. - EXP(zalpha_tr*zprec_cond(i)/zneb(i))
            pfrac_nucl(i,k)=pfrac_nucl(i,k)*(1.-zneb(i)*zfrac_lessi)
@@ -915,9 +970,17 @@
         DO i = 1, klon
            IF (rneb(i,k).GT.0.0.and.zprec_cond(i).gt.0.) THEN
-              if (t(i,kk) .GE. ztglace) THEN
+             IF (iflag_t_glace.EQ.0) THEN
+              if (t(i,kk) .GE. t_glace_min_old) THEN
                  zalpha_tr = a_tr_sca(1)
               else
                  zalpha_tr = a_tr_sca(2)
               endif
+             ELSE ! of IF (iflag_t_glace.EQ.0)
+              if (t(i,kk) .GE. t_glace_min) THEN
+                 zalpha_tr = a_tr_sca(1)
+              else
+                 zalpha_tr = a_tr_sca(2)
+              endif
+             ENDIF
               zfrac_lessi = 1. - EXP(zalpha_tr*zprec_cond(i)/zneb(i))
               pfrac_impa(i,kk)=pfrac_impa(i,kk)*(1.-zneb(i)*zfrac_lessi)
Index: /LMDZ5/branches/testing/libf/phylmd/iophy.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/iophy.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/iophy.F90	(revision 2056)
@@ -568,4 +568,5 @@
     INCLUDE "temps.h"
     INCLUDE "clesphys.h"
+    INCLUDE "iniprint.h"
 
     INTEGER                          :: iff
@@ -602,6 +603,12 @@
 
 #ifdef CPP_XIOS
+      IF ( var%flag(iff)<=lev_files(iff) ) THEN
         CALL wxios_add_field_to_file(var%name, 2, iff, phys_out_filenames(iff), &
         var%description, var%unit, var%flag(iff), typeecrit)
+        IF (prt_level >= 10) THEN
+          WRITE(lunout,*) 'histdef2d: call wxios_add_field_to_file var%name iff: ', &
+                          trim(var%name),iff
+        ENDIF
+      ENDIF
 #endif
 #ifndef CPP_NO_IOIPSL 
@@ -628,4 +635,5 @@
     END IF
   END SUBROUTINE histdef2d
+
   SUBROUTINE histdef3d (iff,var)
 
@@ -645,4 +653,5 @@
     INCLUDE "temps.h"
     INCLUDE "clesphys.h"
+    INCLUDE "iniprint.h"
 
     INTEGER                          :: iff
@@ -679,6 +688,12 @@
 
 #ifdef CPP_XIOS
+      IF ( var%flag(iff)<=lev_files(iff) ) THEN
         CALL wxios_add_field_to_file(var%name, 3, iff, phys_out_filenames(iff), &
         var%description, var%unit, var%flag(iff), typeecrit)
+        IF (prt_level >= 10) THEN
+          WRITE(lunout,*) 'histdef3d: call wxios_add_field_to_file var%name iff: ', &
+                          trim(var%name),iff
+        ENDIF
+      ENDIF
 #endif
 #ifndef CPP_NO_IOIPSL 
@@ -868,5 +883,5 @@
                                  nid_files
 #ifdef CPP_XIOS
-  USE wxios, only: wxios_write_2D
+  USE xios, only: xios_send_field
 #endif
 
@@ -881,5 +896,7 @@
       
     INTEGER :: iff, iff_beg, iff_end
-      
+    LOGICAL, SAVE  :: firstx
+!$OMP THREADPRIVATE(firstx)
+
     REAL,DIMENSION(klon_mpi) :: buffer_omp
     INTEGER, allocatable, DIMENSION(:) :: index2d
@@ -889,6 +906,7 @@
     REAL, ALLOCATABLE, DIMENSION(:) :: fieldok
 
-    IF (prt_level >= 10) WRITE(lunout,*)'Begin histwrite2d_phy ',trim(var%name)
-
+    IF (prt_level >= 10) THEN
+      WRITE(lunout,*)'Begin histwrite2d_phy for ',trim(var%name)
+    ENDIF
 ! ug RUSTINE POUR LES STD LEVS.....
       IF (PRESENT(STD_iff)) THEN
@@ -925,7 +943,20 @@
 
 ! La boucle sur les fichiers:
+      firstx=.true.
       DO iff=iff_beg, iff_end
             IF (var%flag(iff) <= lev_files(iff) .AND. clef_files(iff)) THEN 
-    
+
+#ifdef CPP_XIOS
+               IF (firstx) THEN
+                  if (prt_level >= 10) then
+                     write(lunout,*)'Dans iophy histwrite2D,iff,var%name ',&
+                                    iff,trim(var%name)                       
+                     write(lunout,*)"histwrite2d_phy:.NOT.clef_stations(iff)and iff==iff_beg, call xios_send_field"
+                  endif
+                  CALL xios_send_field(var%name, Field2d)
+                  firstx=.false.
+               ENDIF
+#endif
+
                   IF(.NOT.clef_stations(iff)) THEN
                         ALLOCATE(index2d(iim*jj_nb))
@@ -934,12 +965,12 @@
                         CALL histwrite(nid_files(iff),var%name,itau_iophy,Field2d,iim*jj_nb,index2d)
 #endif
-#ifdef CPP_XIOS
-                        IF (iff == iff_beg) THEN
-                          if (prt_level >= 10) then
-                            write(lunout,*)"histwrite2d_phy: .NOT.clef_stations(iff) and iff==iff_beg, call wxios_write_2D"
-                          endif
-                          CALL wxios_write_2D(var%name, Field2d)
-                        ENDIF
-#endif
+!#ifdef CPP_XIOS
+!                        IF (iff == iff_beg) THEN
+!                          if (prt_level >= 10) then
+!                            write(lunout,*)"histwrite2d_phy: .NOT.clef_stations(iff) and iff==iff_beg, call xios_send_field"
+!                          endif
+!                          CALL xios_send_field(var%name, Field2d)
+!                        ENDIF
+!#endif
                   ELSE 
                         ALLOCATE(fieldok(npstn))
@@ -988,5 +1019,5 @@
                                  nid_files
 #ifdef CPP_XIOS
-  USE wxios, only: wxios_write_3D
+  USE xios, only: xios_send_field
 #endif
 
@@ -1001,8 +1032,9 @@
       
     INTEGER :: iff, iff_beg, iff_end
-
+    LOGICAL, SAVE  :: firstx
+!$OMP THREADPRIVATE(firstx)
     REAL,DIMENSION(klon_mpi,SIZE(field,2)) :: buffer_omp
     REAL :: Field3d(iim,jj_nb,SIZE(field,2))
-    INTEGER :: ip, n, nlev
+    INTEGER :: ip, n, nlev, nlevx
     INTEGER, ALLOCATABLE, DIMENSION(:) :: index3d
     REAL,ALLOCATABLE, DIMENSION(:,:) :: fieldok
@@ -1033,5 +1065,9 @@
     IF (SIZE(field,1)/=klon) CALL abort_gcm('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)
     nlev=SIZE(field,2)
-
+    if (nlev.eq.klev+1) then
+        nlevx=klev
+    else
+        nlevx=nlev
+    endif
 
     CALL Gather_omp(field,buffer_omp)
@@ -1041,6 +1077,20 @@
 
 ! BOUCLE SUR LES FICHIERS
+     firstx=.true.
      DO iff=iff_beg, iff_end
             IF (var%flag(iff) <= lev_files(iff) .AND. clef_files(iff)) THEN
+#ifdef CPP_XIOS
+              IF (firstx) THEN
+                if (prt_level >= 10) then
+                  write(lunout,*)'Dans iophy, histwrite3D iff nlev klev firstx', &
+                                  iff,nlev,klev, firstx                       
+                  write(lunout,*)'histwrite3d_phy: call xios_send_field for ', &
+                                  trim(var%name), ' with iim jjm nlevx = ', &
+                                  iim,jj_nb,nlevx
+                endif
+                CALL xios_send_field(var%name, Field3d(:,:,1:nlevx))
+                            firstx=.false.
+              ENDIF
+#endif
                 IF (.NOT.clef_stations(iff)) THEN
                         ALLOCATE(index3d(iim*jj_nb*nlev))
@@ -1051,10 +1101,10 @@
 #endif
 
-#ifdef CPP_XIOS
-                        IF (iff == 1) THEN
-                              CALL wxios_write_3D(var%name, Field3d(:,:,1:klev))
-                        ENDIF
-#endif
-                        
+!#ifdef CPP_XIOS
+!                        IF (iff == 1) THEN
+!                              CALL xios_send_field(var%name, Field3d(:,:,1:klev))
+!                        ENDIF
+!#endif
+!                        
                 ELSE 
                         nlev=size(field,2)
@@ -1099,5 +1149,5 @@
                                 is_sequential, klon_mpi_begin, klon_mpi_end, &
                                 jj_nb, klon_mpi
-  USE wxios, only: wxios_write_2D
+  USE xios, only: xios_send_field
 
 
@@ -1134,5 +1184,5 @@
 
 
-        CALL wxios_write_2D(field_name, Field2d)
+        CALL xios_send_field(field_name, Field2d)
 
     ELSE 
@@ -1170,5 +1220,5 @@
                                 is_sequential, klon_mpi_begin, klon_mpi_end, &
                                 jj_nb, klon_mpi
-  USE wxios, only: wxios_write_3D
+  USE xios, only: xios_send_field
 
 
@@ -1204,5 +1254,5 @@
         ALLOCATE(index3d(iim*jj_nb*nlev))
         ALLOCATE(fieldok(iim*jj_nb,nlev))
-        CALL wxios_write_3D(field_name, Field3d(:,:,1:klev))
+        CALL xios_send_field(field_name, Field3d(:,:,1:nlev))
                         
     ELSE 
Index: /LMDZ5/branches/testing/libf/phylmd/lmdz1d.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/lmdz1d.F90	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/lmdz1d.F90	(revision 2056)
@@ -0,0 +1,972 @@
+#ifdef CPP_1D
+#include "../dyn3d/mod_const_mpi.F90"
+#include "../dyn3d_common/control_mod.F90"
+#include "../dyn3d_common/infotrac.F90"
+#include "../dyn3d_common/disvert.F90"
+
+
+      PROGRAM lmdz1d
+
+      USE ioipsl, only: ju2ymds, ymds2ju, ioconf_calendar
+      use phys_state_var_mod
+      use comgeomphy
+      use dimphy
+      use surface_data, only : type_ocean,ok_veget
+      use pbl_surface_mod, only : ftsoil, pbl_surface_init,                     &
+     &                            pbl_surface_final
+      use fonte_neige_mod, only : fonte_neige_init, fonte_neige_final 
+
+      use infotrac ! new
+      use control_mod
+      USE indice_sol_mod
+      USE phyaqua_mod
+
+      implicit none
+#include "dimensions.h"
+#include "YOMCST.h"
+#include "temps.h"
+!!#include "control.h"
+#include "iniprint.h"
+#include "clesphys.h"
+#include "dimsoil.h"
+!#include "indicesol.h"
+
+#include "comvert.h"
+#include "compar1d.h"
+#include "flux_arp.h"
+#include "tsoilnudge.h"
+#include "fcg_gcssold.h"
+!!!#include "fbforcing.h"
+
+!=====================================================================
+! DECLARATIONS
+!=====================================================================
+
+!---------------------------------------------------------------------
+!  Externals
+!---------------------------------------------------------------------
+      external fq_sat
+      real fq_sat
+
+!---------------------------------------------------------------------
+!  Arguments d' initialisations de la physique (USER DEFINE)
+!---------------------------------------------------------------------
+
+      integer, parameter :: ngrid=1
+      real :: zcufi    = 1.
+      real :: zcvfi    = 1.
+
+!-      real :: nat_surf
+!-      logical :: ok_flux_surf
+!-      real :: fsens
+!-      real :: flat
+!-      real :: tsurf
+!-      real :: rugos
+!-      real :: qsol(1:2)
+!-      real :: qsurf
+!-      real :: psurf
+!-      real :: zsurf
+!-      real :: albedo
+!-
+!-      real :: time     = 0.
+!-      real :: time_ini
+!-      real :: xlat 
+!-      real :: xlon 
+!-      real :: wtsurf 
+!-      real :: wqsurf 
+!-      real :: restart_runoff 
+!-      real :: xagesno 
+!-      real :: qsolinp 
+!-      real :: zpicinp 
+!-
+      real :: fnday 
+      real :: day, daytime 
+      real :: day1
+      real :: heure
+      integer :: jour
+      integer :: mois
+      integer :: an
+ 
+!---------------------------------------------------------------------
+!  Declarations related to forcing and initial profiles 
+!---------------------------------------------------------------------
+
+        integer :: kmax = llm
+        integer llm700,nq1,nq2
+        INTEGER, PARAMETER :: nlev_max=1000, nqmx=1000
+        real timestep, frac
+        real height(nlev_max),tttprof(nlev_max),qtprof(nlev_max)
+        real  uprof(nlev_max),vprof(nlev_max),e12prof(nlev_max)
+        real  ugprof(nlev_max),vgprof(nlev_max),wfls(nlev_max)
+        real  dqtdxls(nlev_max),dqtdyls(nlev_max)
+        real  dqtdtls(nlev_max),thlpcar(nlev_max)
+        real  qprof(nlev_max,nqmx)
+
+!        integer :: forcing_type
+        logical :: forcing_les     = .false.
+        logical :: forcing_armcu   = .false.
+        logical :: forcing_rico    = .false.
+        logical :: forcing_radconv = .false.
+        logical :: forcing_toga    = .false.
+        logical :: forcing_twpice  = .false.
+        logical :: forcing_amma    = .false.
+        logical :: forcing_GCM2SCM = .false.
+        logical :: forcing_GCSSold = .false.
+        logical :: forcing_sandu   = .false.
+        logical :: forcing_astex   = .false.
+        logical :: forcing_fire    = .false.
+        integer :: type_ts_forcing ! 0 = SST constant; 1 = SST read from a file
+!                                                            (cf read_tsurf1d.F)
+
+!vertical advection computation
+!       real d_t_z(llm), d_q_z(llm)
+!       real d_t_dyn_z(llm), d_q_dyn_z(llm)
+!       real zz(llm)
+!       real zfact
+
+!flag forcings
+        logical :: nudge_wind=.true.
+        logical :: nudge_thermo=.false.
+        logical :: cptadvw=.true.
+!=====================================================================
+! DECLARATIONS FOR EACH CASE
+!=====================================================================
+!
+#include "1D_decl_cases.h"
+!
+!---------------------------------------------------------------------
+!  Declarations related to vertical discretization:
+!---------------------------------------------------------------------
+      real :: pzero=1.e5
+      real :: play (llm),zlay (llm),sig_s(llm),plev(llm+1)
+      real :: playd(llm),zlayd(llm),ap_amma(llm+1),bp_amma(llm+1),poub
+
+!---------------------------------------------------------------------
+!  Declarations related to variables
+!---------------------------------------------------------------------
+
+      real :: phi(llm)
+      real :: teta(llm),tetal(llm),temp(llm),u(llm),v(llm),w(llm)
+      real :: rlat_rad(1),rlon_rad(1)
+      real :: omega(llm+1),omega2(llm),rho(llm+1)
+      real :: ug(llm),vg(llm),fcoriolis
+      real :: sfdt, cfdt
+      real :: du_phys(llm),dv_phys(llm),dt_phys(llm)
+      real :: dt_dyn(llm)
+      real :: dt_cooling(llm),d_th_adv(llm)
+      real :: alpha
+      real :: ttt
+
+      REAL, ALLOCATABLE, DIMENSION(:,:):: q
+      REAL, ALLOCATABLE, DIMENSION(:,:):: dq
+      REAL, ALLOCATABLE, DIMENSION(:,:):: dq_dyn
+      REAL, ALLOCATABLE, DIMENSION(:,:):: d_q_adv
+!     REAL, ALLOCATABLE, DIMENSION(:):: d_th_adv
+
+!---------------------------------------------------------------------
+!  Initialization of surface variables
+!---------------------------------------------------------------------
+      real :: run_off_lic_0(1)
+      real :: fder(1),snsrf(1,nbsrf),qsurfsrf(1,nbsrf)
+      real :: evap(1,nbsrf),frugs(1,nbsrf)
+      real :: tsoil(1,nsoilmx,nbsrf)
+      real :: agesno(1,nbsrf)
+
+!---------------------------------------------------------------------
+!  Call to phyredem
+!---------------------------------------------------------------------
+      logical :: ok_writedem =.true.
+      
+!---------------------------------------------------------------------
+!  Call to physiq
+!---------------------------------------------------------------------
+      integer, parameter :: longcles=20
+      logical :: firstcall=.true.
+      logical :: lastcall=.false.
+      real :: phis    = 0.0
+      real :: clesphy0(longcles) = 0.0
+      real :: dpsrf 
+
+!---------------------------------------------------------------------
+!  Initializations of boundary conditions 
+!---------------------------------------------------------------------
+      integer, parameter :: yd = 360
+      real :: phy_nat (yd) = 0.0 ! 0=ocean libre,1=land,2=glacier,3=banquise
+      real :: phy_alb (yd)  ! Albedo land only (old value condsurf_jyg=0.3)
+      real :: phy_sst (yd)  ! SST (will not be used; cf read_tsurf1d.F)
+      real :: phy_bil (yd) = 1.0 ! Ne sert que pour les slab_ocean
+      real :: phy_rug (yd) ! Longueur rugosite utilisee sur land only
+      real :: phy_ice (yd) = 0.0 ! Fraction de glace
+      real :: phy_fter(yd) = 0.0 ! Fraction de terre
+      real :: phy_foce(yd) = 0.0 ! Fraction de ocean
+      real :: phy_fsic(yd) = 0.0 ! Fraction de glace
+      real :: phy_flic(yd) = 0.0 ! Fraction de glace
+
+!---------------------------------------------------------------------
+!  Fichiers et d'autres variables
+!---------------------------------------------------------------------
+      integer :: k,l,i,it=1,mxcalc
+      integer jjmp1
+      parameter (jjmp1=jjm+1-1/jjm)
+      REAL dudyn(iim+1,jjmp1,llm)
+      INTEGER read_climoz 
+!Al1
+      integer ecrit_slab_oc !1=ecrit,-1=lit,0=no file
+      data ecrit_slab_oc/-1/
+
+!=====================================================================
+! INITIALIZATIONS 
+!=====================================================================
+! Initialization of Common turb_forcing
+       dtime_frcg = 0.
+       Turb_fcg_gcssold=.false.
+       hthturb_gcssold = 0.
+       hqturb_gcssold = 0.
+
+!---------------------------------------------------------------------
+! OPTIONS OF THE 1D SIMULATION (lmdz1d.def => unicol.def)
+!---------------------------------------------------------------------
+!Al1
+        call conf_unicol
+!Al1 moves this gcssold var from common fcg_gcssold to 
+        Turb_fcg_gcssold = xTurb_fcg_gcssold
+! --------------------------------------------------------------------
+        close(1)
+!Al1
+        write(*,*) 'lmdz1d.def lu => unicol.def'
+
+! forcing_type defines the way the SCM is forced:
+!forcing_type = 0 ==> forcing_les = .true.
+!             initial profiles from file prof.inp.001
+!             no forcing by LS convergence ; 
+!             surface temperature imposed ;
+!             radiative cooling may be imposed (iflag_radia=0 in physiq.def)
+!forcing_type = 1 ==> forcing_radconv = .true.
+!             idem forcing_type = 0, but the imposed radiative cooling 
+!             is set to 0 (hence, if iflag_radia=0 in physiq.def, 
+!             then there is no radiative cooling at all)
+!forcing_type = 2 ==> forcing_toga = .true.
+!             initial profiles from TOGA-COARE IFA files 
+!             LS convergence and SST imposed from TOGA-COARE IFA files 
+!forcing_type = 3 ==> forcing_GCM2SCM = .true.
+!             initial profiles from the GCM output
+!             LS convergence imposed from the GCM output
+!forcing_type = 4 ==> forcing_twpice = .true.
+!             initial profiles from TWP-ICE cdf file 
+!             LS convergence, omega and SST imposed from TWP-ICE files 
+!forcing_type = 5 ==> forcing_rico = .true.
+!             initial profiles from RICO files 
+!             LS convergence imposed from RICO files 
+!forcing_type = 6 ==> forcing_amma = .true.
+!             initial profiles from AMMA nc file 
+!             LS convergence, omega and surface fluxes imposed from AMMA file  
+!forcing_type = 40 ==> forcing_GCSSold = .true.
+!             initial profile from GCSS file
+!             LS convergence imposed from GCSS file
+!forcing_type = 50 ==> forcing_fire = .true.
+!             forcing from fire.nc
+!forcing_type = 59 ==> forcing_sandu = .true.
+!             initial profiles from sanduref file: see prof.inp.001
+!             SST varying with time and divergence constante: see ifa_sanduref.txt file
+!             Radiation has to be computed interactively
+!forcing_type = 60 ==> forcing_astex = .true.
+!             initial profiles from file: see prof.inp.001 
+!             SST,divergence,ug,vg,ufa,vfa varying with time : see ifa_astex.txt file
+!             Radiation has to be computed interactively
+!forcing_type = 61 ==> forcing_armcu = .true.
+!             initial profiles from file: see prof.inp.001 
+!             sensible and latent heat flux imposed: see ifa_arm_cu_1.txt
+!             large scale advective forcing & radiative tendencies applied below 1000m: see ifa_arm_cu_2.txt
+!             use geostrophic wind ug=10m/s vg=0m/s. Duration of the case 53100s 
+!             Radiation to be switched off
+!
+      if (forcing_type .eq.0) THEN
+       forcing_les = .true.
+      elseif (forcing_type .eq.1) THEN
+       forcing_radconv = .true.
+      elseif (forcing_type .eq.2) THEN
+       forcing_toga    = .true.
+      elseif (forcing_type .eq.3) THEN
+       forcing_GCM2SCM = .true.
+      elseif (forcing_type .eq.4) THEN
+       forcing_twpice = .true.
+      elseif (forcing_type .eq.5) THEN
+       forcing_rico = .true.
+      elseif (forcing_type .eq.6) THEN
+       forcing_amma = .true.
+      elseif (forcing_type .eq.40) THEN
+       forcing_GCSSold = .true.
+      elseif (forcing_type .eq.50) THEN
+       forcing_fire = .true.
+      elseif (forcing_type .eq.59) THEN
+       forcing_sandu   = .true.
+      elseif (forcing_type .eq.60) THEN
+       forcing_astex   = .true.
+      elseif (forcing_type .eq.61) THEN
+       forcing_armcu = .true.
+       IF(llm.NE.19.AND.llm.NE.40) stop 'Erreur nombre de niveaux !!'
+      else
+       write (*,*) 'ERROR : unknown forcing_type ', forcing_type
+       stop 'Forcing_type should be 0,1,2,3,4,5,6 or 40,59,60,61'
+      ENDIF
+      print*,"forcing type=",forcing_type
+
+! if type_ts_forcing=0, the surface temp of 1D simulation is constant in time
+! (specified by tsurf in lmdz1d.def); if type_ts_forcing=1, the surface temperature
+! varies in time according to a forcing (e.g. forcing_toga) and is passed to read_tsurf1d.F
+! through the common sst_forcing.
+
+        type_ts_forcing = 0
+        if (forcing_toga.or.forcing_sandu.or.forcing_astex)                 &
+     &    type_ts_forcing = 1
+
+!---------------------------------------------------------------------
+!  Definition of the run
+!---------------------------------------------------------------------
+
+      call conf_gcm( 99, .TRUE. , clesphy0 )
+!-----------------------------------------------------------------------
+!   Choix du calendrier
+!   -------------------
+
+!      calend = 'earth_365d'
+      if (calend == 'earth_360d') then
+        call ioconf_calendar('360d')
+        write(*,*)'CALENDRIER CHOISI: Terrestre a 360 jours/an'
+      else if (calend == 'earth_365d') then
+        call ioconf_calendar('noleap')
+        write(*,*)'CALENDRIER CHOISI: Terrestre a 365 jours/an'
+      else if (calend == 'earth_366d') then
+        call ioconf_calendar('all_leap')
+        write(*,*)'CALENDRIER CHOISI: Terrestre bissextile'
+      else if (calend == 'gregorian') then
+        call ioconf_calendar('gregorian') ! not to be used by normal users
+        write(*,*)'CALENDRIER CHOISI: Gregorien'
+      else
+        write (*,*) 'ERROR : unknown calendar ', calend
+        stop 'calend should be 360d,earth_365d,earth_366d,gregorian'
+      endif
+!-----------------------------------------------------------------------
+!
+!c Date :
+!      La date est supposee donnee sous la forme [annee, numero du jour dans 
+!      l annee] ; l heure est donnee dans time_ini, lu dans lmdz1d.def.
+!      On appelle ymds2ju pour convertir [annee, jour] en [jour Julien].
+!      Le numero du jour est dans "day". L heure est traitee separement.
+!      La date complete est dans "daytime" (l'unite est le jour).
+      if (nday>0) then
+         fnday=nday
+      else
+         fnday=-nday/float(day_step)
+      endif
+
+! Special case for arm_cu which lasts less than one day : 53100s !! (MPL 20111026)
+      IF(forcing_type .EQ. 61) fnday=53100./86400.
+! Special case for amma which lasts less than one day : 64800s !! (MPL 20120216)
+      IF(forcing_type .EQ. 6) fnday=64800./86400.
+      annee_ref = anneeref
+      mois = 1
+      day_ref = dayref
+      heure = 0.
+      itau_dyn = 0
+      itau_phy = 0
+      call ymds2ju(annee_ref,mois,day_ref,heure,day)
+      day_ini = int(day)
+      day_end = day_ini + fnday
+
+      IF (forcing_type .eq.2) THEN
+! Convert the initial date of Toga-Coare to Julian day
+      call ymds2ju                                                          &
+     & (year_ini_toga,mth_ini_toga,day_ini_toga,heure,day_ju_ini_toga)
+
+      ELSEIF (forcing_type .eq.4) THEN
+! Convert the initial date of TWPICE to Julian day
+      call ymds2ju                                                          &
+     & (year_ini_twpi,mth_ini_twpi,day_ini_twpi,heure_ini_twpi              &
+     & ,day_ju_ini_twpi)
+      ELSEIF (forcing_type .eq.6) THEN
+! Convert the initial date of AMMA to Julian day
+      call ymds2ju                                                          &
+     & (year_ini_amma,mth_ini_amma,day_ini_amma,heure_ini_amma              &
+     & ,day_ju_ini_amma)
+
+      ELSEIF (forcing_type .eq.59) THEN
+! Convert the initial date of Sandu case to Julian day
+      call ymds2ju                                                          &
+     &   (year_ini_sandu,mth_ini_sandu,day_ini_sandu,                       &
+     &    time_ini*3600.,day_ju_ini_sandu)
+
+      ELSEIF (forcing_type .eq.60) THEN
+! Convert the initial date of Astex case to Julian day
+      call ymds2ju                                                          &
+     &   (year_ini_astex,mth_ini_astex,day_ini_astex,                        &
+     &    time_ini*3600.,day_ju_ini_astex)
+
+      ELSEIF (forcing_type .eq.61) THEN
+
+! Convert the initial date of Arm_cu case to Julian day
+      call ymds2ju                                                          &
+     & (year_ini_armcu,mth_ini_armcu,day_ini_armcu,heure_ini_armcu          &
+     & ,day_ju_ini_armcu)
+      ENDIF
+
+      daytime = day + time_ini/24. ! 1st day and initial time of the simulation 
+! Print out the actual date of the beginning of the simulation :
+      call ju2ymds(daytime,year_print, month_print,day_print,sec_print)
+      print *,' Time of beginning : ',                                      &
+     &        year_print, month_print, day_print, sec_print
+
+!---------------------------------------------------------------------
+! Initialization of dimensions, geometry and initial state
+!---------------------------------------------------------------------
+      call init_phys_lmdz(1,1,llm,1,(/1/))
+      call suphel
+      call initcomgeomphy
+      call infotrac_init 
+
+      if (nqtot>nqmx) STOP'Augmenter nqmx dans lmdz1d.F'
+      allocate(q(llm,nqtot)) ; q(:,:)=0.
+      allocate(dq(llm,nqtot)) 
+      allocate(dq_dyn(llm,nqtot)) 
+      allocate(d_q_adv(llm,nqtot)) 
+!     allocate(d_th_adv(llm)) 
+
+!
+!   No ozone climatology need be read in this pre-initialization
+!          (phys_state_var_init is called again in physiq)
+      read_climoz = 0
+!
+      call phys_state_var_init(read_climoz)
+
+      if (ngrid.ne.klon) then
+         print*,'stop in inifis'
+         print*,'Probleme de dimensions :'
+         print*,'ngrid = ',ngrid
+         print*,'klon  = ',klon
+         stop
+      endif
+!!!=====================================================================
+!!! Feedback forcing values for Gateaux differentiation (al1)
+!!!=====================================================================
+!!! Surface Planck forcing bracketing call radiation
+!!      surf_Planck = 0.
+!!      surf_Conv   = 0.
+!!      write(*,*) 'Gateaux-dif Planck,Conv:',surf_Planck,surf_Conv
+!!! a mettre dans le lmdz1d.def ou autre
+!!
+!!
+      qsol = qsolinp
+      qsurf = fq_sat(tsurf,psurf/100.)
+      rlat=xlat
+      rlon=xlon
+      day1= day_ini
+      time=daytime-day
+      ts_toga(1)=tsurf ! needed by read_tsurf1d.F
+      rho(1)=psurf/(rd*tsurf*(1.+(rv/rd-1.)*qsurf)) 
+
+!
+!! mpl et jyg le 22/08/2012 : 
+!!  pour que les cas a flux de surface imposes marchent
+      IF(.NOT.ok_flux_surf.or.max(abs(wtsurf),abs(wqsurf))>0.) THEN
+       fsens=-wtsurf*rcpd*rho(1)
+       flat=-wqsurf*rlvtt*rho(1)
+       print *,'Flux: ok_flux wtsurf wqsurf',ok_flux_surf,wtsurf,wqsurf
+      ENDIF
+      print*,'Flux sol ',fsens,flat
+!!      ok_flux_surf=.false.
+!!      fsens=-wtsurf*rcpd*rho(1)
+!!      flat=-wqsurf*rlvtt*rho(1)
+!!!!
+
+! Vertical discretization and pressure levels at half and mid levels:
+
+      pa   = 5e4
+!!      preff= 1.01325e5
+      preff = psurf
+      IF (ok_old_disvert) THEN
+        call disvert0(pa,preff,ap,bp,dpres,presnivs,nivsigs,nivsig)
+        print *,'On utilise disvert0'
+      ELSE
+        call disvert()
+        print *,'On utilise disvert'
+!       Nouvelle version disvert permettant d imposer ap,bp (modif L.Guez) MPL 18092012
+!       Dans ce cas, on lit ap,bp dans le fichier hybrid.txt
+      ENDIF
+      sig_s=presnivs/preff
+      plev =ap+bp*psurf
+      play = 0.5*(plev(1:llm)+plev(2:llm+1))
+!cc      zlay=-rd*300.*log(play/psurf)/rg ! moved after reading profiles
+
+      IF (forcing_type .eq. 59) THEN
+! pour forcing_sandu, on cherche l'indice le plus proche de 700hpa#3000m
+      write(*,*) '***********************'
+      do l = 1, llm
+       write(*,*) 'l,play(l),presnivs(l): ',l,play(l),presnivs(l)
+       if (trouve_700 .and. play(l).le.70000) then
+         llm700=l
+         print *,'llm700,play=',llm700,play(l)/100.
+         trouve_700= .false.
+       endif
+      enddo
+      write(*,*) '***********************'
+      ENDIF
+
+!
+!=====================================================================
+! EVENTUALLY, READ FORCING DATA :
+!=====================================================================
+
+#include "1D_read_forc_cases.h"
+
+      if (forcing_GCM2SCM) then
+        write (*,*) 'forcing_GCM2SCM not yet implemented'
+        stop 'in initialization'
+      endif ! forcing_GCM2SCM
+
+      print*,'mxcalc=',mxcalc
+      print*,'zlay=',zlay(mxcalc)
+      print*,'play=',play(mxcalc)
+
+!Al1 pour SST forced, appellé depuis ocean_forced_noice
+      ts_cur = tsurf ! SST used in read_tsurf1d
+!=====================================================================
+! Initialisation de la physique : 
+!=====================================================================
+
+!  Rq: conf_phys.F90 lit tous les flags de physiq.def; conf_phys appele depuis physiq.F
+!
+! day_step, iphysiq lus dans gcm.def ci-dessus
+! timestep: calcule ci-dessous from rday et day_step
+! ngrid=1
+! llm: defini dans .../modipsl/modeles/LMDZ4/libf/grid/dimension
+! rday: defini dans suphel.F (86400.)
+! day_ini: lu dans run.def (dayref)
+! rlat_rad,rlon-rad: transformes en radian de rlat,rlon lus dans lmdz1d.def (en degres)
+! airefi,zcufi,zcvfi initialises au debut de ce programme
+! rday,ra,rg,rd,rcpd declares dans YOMCST.h et calcules dans suphel.F
+      day_step = float(nsplit_phys)*day_step/float(iphysiq)
+      write (*,*) 'Time step divided by nsplit_phys (=',nsplit_phys,')'
+      timestep =rday/day_step
+      dtime_frcg = timestep
+!
+      zcufi=airefi
+      zcvfi=airefi
+!
+      rlat_rad(:)=rlat(:)*rpi/180.
+      rlon_rad(:)=rlon(:)*rpi/180.
+
+      call iniphysiq(ngrid,llm,rday,day_ini,timestep,                        &
+     &     rlat_rad,rlon_rad,airefi,zcufi,zcvfi,ra,rg,rd,rcpd,(/1/))
+      print*,'apres iniphysiq'
+
+! 2 PARAMETRES QUI DEVRAIENT ETRE LUS DANS run.def MAIS NE LE SONT PAS ICI:
+      co2_ppm= 330.0
+      solaire=1370.0
+
+! Ecriture du startphy avant le premier appel a la physique.
+! On le met juste avant pour avoir acces a tous les champs
+! NB: les clesphy0 seront remplies dans phyredem d'apres les flags lus dans gcm.def
+
+      if (ok_writedem) then
+
+!--------------------------------------------------------------------------
+! pbl_surface_init (called here) and pbl_surface_final (called by phyredem)
+! need : qsol fder snow qsurf evap rugos agesno ftsoil
+!--------------------------------------------------------------------------
+
+        type_ocean = "force"
+        run_off_lic_0(1) = restart_runoff 
+        call fonte_neige_init(run_off_lic_0)
+
+        fder=0.
+        snsrf(1,:)=0.        ! couverture de neige des sous surface
+        qsurfsrf(1,:)=qsurf ! humidite de l'air des sous surface
+        evap=0.
+        frugs(1,:)=rugos     ! couverture de neige des sous surface
+        agesno  = xagesno
+        tsoil(:,:,:)=tsurf
+!------ AMMA 2e run avec modele sol et rayonnement actif (MPL 23052012)
+!       tsoil(1,1,1)=299.18
+!       tsoil(1,2,1)=300.08
+!       tsoil(1,3,1)=301.88
+!       tsoil(1,4,1)=305.48
+!       tsoil(1,5,1)=308.00
+!       tsoil(1,6,1)=308.00
+!       tsoil(1,7,1)=308.00
+!       tsoil(1,8,1)=308.00
+!       tsoil(1,9,1)=308.00
+!       tsoil(1,10,1)=308.00
+!       tsoil(1,11,1)=308.00
+!-----------------------------------------------------------------------
+        call pbl_surface_init(qsol, fder, snsrf, qsurfsrf,                  &
+     &                                    evap, frugs, agesno, tsoil)
+
+!------------------ prepare limit conditions for limit.nc -----------------
+!--   Ocean force
+
+        print*,'avant phyredem'
+        pctsrf(1,:)=0.
+        if (nat_surf.eq.0.) then
+          pctsrf(1,is_oce)=1.
+          pctsrf(1,is_ter)=0.
+        else
+          pctsrf(1,is_oce)=0.
+          pctsrf(1,is_ter)=1.
+        end if
+
+        print*,'nat_surf,pctsrf(1,is_oce),pctsrf(1,is_ter)',nat_surf         &
+     &        ,pctsrf(1,is_oce),pctsrf(1,is_ter)
+
+        zmasq=pctsrf(1,is_ter)+pctsrf(1,is_lic)
+        zpic = zpicinp
+        ftsol=tsurf
+        falb1 = albedo                            
+        falb2 = albedo                            
+        rugoro=rugos 
+        t_ancien(1,:)=temp(:)
+        q_ancien(1,:)=q(:,1)
+        pbl_tke=1.e-8
+
+        rain_fall=0.
+        snow_fall=0.
+        solsw=0.
+        sollw=0.
+        radsol=0.
+        rnebcon=0.
+        ratqs=0.
+        clwcon=0.
+        zmea=0.
+        zstd=0.
+        zsig=0.
+        zgam=0.
+        zval=0. 
+        zthe=0. 
+        sig1=0.
+        w01=0.
+        u_ancien(1,:)=u(:)
+        v_ancien(1,:)=v(:)
+ 
+!------------------------------------------------------------------------
+! Make file containing restart for the physics (startphy.nc)
+!
+! NB: List of the variables to be written by phyredem (via put_field):
+! rlon,rlat,zmasq,pctsrf(:,is_ter),pctsrf(:,is_lic),pctsrf(:,is_oce)
+! pctsrf(:,is_sic),ftsol(:,nsrf),tsoil(:,isoil,nsrf),qsurf(:,nsrf)
+! qsol,falb1(:,nsrf),falb2(:,nsrf),evap(:,nsrf),snow(:,nsrf)
+! radsol,solsw,sollw,fder,rain_fall,snow_fall,frugs(:,nsrf)
+! agesno(:,nsrf),zmea,zstd,zsig,zgam,zthe,zpic,zval,rugoro
+! t_ancien,q_ancien,frugs(:,is_oce),clwcon(:,1),rnebcon(:,1),ratqs(:,1)
+! run_off_lic_0,pbl_tke(:,1:klev,nsrf),zmax0,f0,sig1,w01
+! wake_deltat,wake_deltaq,wake_s,wake_cstar,wake_fip
+!------------------------------------------------------------------------
+!Al1 =============== restart option ==========================
+        if (.not.restart) then
+          call phyredem ("startphy.nc")
+        else
+! (desallocations)
+        print*,'callin surf final'
+          call pbl_surface_final(qsol, fder, snsrf, qsurfsrf,               &
+     &                                    evap, frugs, agesno, tsoil)
+        print*,'after surf final'
+          CALL fonte_neige_final(run_off_lic_0)
+        endif
+
+        ok_writedem=.false.
+        print*,'apres phyredem'
+
+      endif ! ok_writedem
+      
+!------------------------------------------------------------------------
+! Make file containing boundary conditions (limit.nc) **Al1->restartdyn***
+! --------------------------------------------------
+! NB: List of the variables to be written in limit.nc 
+!     (by writelim.F, subroutine of 1DUTILS.h):
+!        phy_nat,phy_alb,phy_sst,phy_bil,phy_rug,phy_ice,
+!        phy_fter,phy_foce,phy_flic,phy_fsic)
+!------------------------------------------------------------------------
+      do i=1,yd
+        phy_nat(i)  = nat_surf
+        phy_alb(i)  = albedo
+        phy_sst(i)  = tsurf ! read_tsurf1d will be used instead
+        phy_rug(i)  = rugos
+        phy_fter(i) = pctsrf(1,is_ter)
+        phy_foce(i) = pctsrf(1,is_oce)
+        phy_fsic(i) = pctsrf(1,is_sic)
+        phy_flic(i) = pctsrf(1,is_lic)
+      enddo
+
+! fabrication de limit.nc
+      call writelim (1,phy_nat,phy_alb,phy_sst,phy_bil,phy_rug,             &
+     &               phy_ice,phy_fter,phy_foce,phy_flic,phy_fsic)
+
+
+      call phys_state_var_end
+!Al1
+      if (restart) then
+        print*,'call to restart dyn 1d'
+        Call dyn1deta0("start1dyn.nc",plev,play,phi,phis,presnivs,          &
+     &              u,v,temp,q,omega2)
+
+       print*,'fnday,annee_ref,day_ref,day_ini',                            &
+     &     fnday,annee_ref,day_ref,day_ini
+!**      call ymds2ju(annee_ref,mois,day_ini,heure,day)
+       day = day_ini
+       day_end = day_ini + nday
+       daytime = day + time_ini/24. ! 1st day and initial time of the simulation 
+
+! Print out the actual date of the beginning of the simulation :
+       call ju2ymds(daytime, an, mois, jour, heure)
+       print *,' Time of beginning : y m d h',an, mois,jour,heure/3600.
+
+       day = int(daytime)
+       time=daytime-day
+  
+       print*,'****** intialised fields from restart1dyn *******'
+       print*,'plev,play,phi,phis,presnivs,u,v,temp,q,omega2'
+       print*,'temp(1),q(1,1),u(1),v(1),plev(1),phis :'
+       print*,temp(1),q(1,1),u(1),v(1),plev(1),phis
+! raz for safety
+       do l=1,llm
+         dq_dyn(l,1) = 0.
+       enddo
+      endif
+!Al1 ================  end restart =================================
+      IF (ecrit_slab_oc.eq.1) then
+         open(97,file='div_slab.dat',STATUS='UNKNOWN')
+       elseif (ecrit_slab_oc.eq.0) then
+         open(97,file='div_slab.dat',STATUS='OLD')
+       endif
+!=====================================================================
+! START OF THE TEMPORAL LOOP :
+!=====================================================================
+           
+      do while(it.le.nint(fnday*day_step))
+
+       if (prt_level.ge.1) then
+         print*,'XXXXXXXXXXXXXXXXXXX ITAP,day,time=',                       &
+     &                                it,day,time,nint(fnday*day_step)
+         print*,'PAS DE TEMPS ',timestep
+       endif
+!Al1 demande de restartphy.nc
+       if (it.eq.nint(fnday*day_step)) lastcall=.True.
+
+!---------------------------------------------------------------------
+! Interpolation of forcings in time and onto model levels
+!---------------------------------------------------------------------
+
+#include "1D_interp_cases.h"
+
+      if (forcing_GCM2SCM) then
+        write (*,*) 'forcing_GCM2SCM not yet implemented'
+        stop 'in time loop'
+      endif ! forcing_GCM2SCM
+
+!---------------------------------------------------------------------
+!  Geopotential :
+!---------------------------------------------------------------------
+
+        phi(1)=RD*temp(1)*(plev(1)-play(1))/(.5*(plev(1)+play(1)))
+        do l = 1, llm-1
+          phi(l+1)=phi(l)+RD*(temp(l)+temp(l+1))*                           &
+     &    (play(l)-play(l+1))/(play(l)+play(l+1))
+        enddo
+
+!---------------------------------------------------------------------
+! Listing output for debug prt_level>=1
+!---------------------------------------------------------------------
+       if (prt_level>=1) then
+         print *,' avant physiq : -------- day time ',day,time
+         write(*,*) 'firstcall,lastcall,phis',                               &
+     &               firstcall,lastcall,phis
+         write(*,'(a10,2a4,4a13)') 'BEFOR1 IT=','it','l',                   &
+     &        'presniv','plev','play','phi'
+         write(*,'(a10,2i4,4f13.2)') ('BEFOR1 IT= ',it,l,                   &
+     &         presnivs(l),plev(l),play(l),phi(l),l=1,llm)
+         write(*,'(a11,2a4,a11,6a8)') 'BEFOR2','it','l',                    &
+     &         'presniv','u','v','temp','q1','q2','omega2'
+         write(*,'(a11,2i4,f11.2,5f8.2,e10.2)') ('BEFOR2 IT= ',it,l,         &
+     &   presnivs(l),u(l),v(l),temp(l),q(l,1),q(l,2),omega2(l),l=1,llm)
+       endif
+
+!---------------------------------------------------------------------
+!   Call physiq :
+!---------------------------------------------------------------------
+
+        call physiq(ngrid,llm,                                              &
+     &              firstcall,lastcall,                                     &
+     &              day,time,timestep,                                      &
+     &              plev,play,phi,phis,presnivs,clesphy0,                   &
+     &              u,v,temp,q,omega2,                                      &
+     &              du_phys,dv_phys,dt_phys,dq,dpsrf,                        &
+     &              dudyn)
+        firstcall=.false.
+
+!---------------------------------------------------------------------
+! Listing output for debug prt_level>=1
+!---------------------------------------------------------------------
+        if (prt_level>=1) then
+          write(*,'(a11,2a4,4a13)') 'AFTER1 IT=','it','l',                  &
+     &        'presniv','plev','play','phi'
+          write(*,'(a11,2i4,4f13.2)') ('AFTER1 it= ',it,l,                  &
+     &    presnivs(l),plev(l),play(l),phi(l),l=1,llm)
+          write(*,'(a11,2a4,a11,6a8)') 'AFTER2','it','l',                   &
+     &         'presniv','u','v','temp','q1','q2','omega2'
+          write(*,'(a11,2i4,f11.2,5f8.2,e10.2)') ('AFTER2 it= ',it,l,       &
+     &    presnivs(l),u(l),v(l),temp(l),q(l,1),q(l,2),omega2(l),l=1,llm)
+          write(*,'(a11,2a4,a11,5a8)') 'AFTER3','it','l',                   &
+     &         'presniv','du_phys','dv_phys','dt_phys','dq1','dq2'    
+           write(*,'(a11,2i4,f11.2,5f8.2)') ('AFTER3 it= ',it,l,            &
+     &      presnivs(l),86400*du_phys(l),86400*dv_phys(l),                   &
+     &       86400*dt_phys(l),86400*dq(l,1),dq(l,2),l=1,llm)
+          write(*,*) 'dpsrf',dpsrf
+        endif
+!---------------------------------------------------------------------
+!   Add physical tendencies :
+!---------------------------------------------------------------------
+
+       fcoriolis=2.*sin(rpi*xlat/180.)*romega
+       if (forcing_radconv .or. forcing_fire) then
+         fcoriolis=0.0
+         dt_cooling=0.0
+         d_th_adv=0.0
+         d_q_adv=0.0
+       endif
+
+       if (forcing_toga .or. forcing_GCSSold .or. forcing_twpice            &
+     &    .or.forcing_amma) then
+         fcoriolis=0.0 ; ug=0. ; vg=0.
+       endif
+         if(forcing_rico) then
+          dt_cooling=0.
+        endif
+
+      print*, 'fcoriolis ', fcoriolis, xlat
+
+        du_age(1:mxcalc)=fcoriolis*(v(1:mxcalc)-vg(1:mxcalc))
+       dv_age(1:mxcalc)=-fcoriolis*(u(1:mxcalc)-ug(1:mxcalc))
+
+!!!!!!!!!!!!!!!!!!!!!!!!
+! Geostrophic wind
+!!!!!!!!!!!!!!!!!!!!!!!!
+       sfdt = sin(0.5*fcoriolis*timestep)
+       cfdt = cos(0.5*fcoriolis*timestep)
+!
+        du_age(1:mxcalc)= -2.*sfdt/timestep*                                &
+     &          (sfdt*(u(1:mxcalc)-ug(1:mxcalc)) -                          &
+     &           cfdt*(v(1:mxcalc)-vg(1:mxcalc))  )
+!!     : fcoriolis*(v(1:mxcalc)-vg(1:mxcalc))
+!
+       dv_age(1:mxcalc)= -2.*sfdt/timestep*                                 &
+     &          (cfdt*(u(1:mxcalc)-ug(1:mxcalc)) +                           &
+     &           sfdt*(v(1:mxcalc)-vg(1:mxcalc))  )
+!!     : -fcoriolis*(u(1:mxcalc)-ug(1:mxcalc))
+!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!         call  writefield_phy('dv_age' ,dv_age,llm)
+!         call  writefield_phy('du_age' ,du_age,llm)
+!         call  writefield_phy('du_phys' ,du_phys,llm)
+!         call  writefield_phy('u_tend' ,u,llm)
+!         call  writefield_phy('u_g' ,ug,llm)
+!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Increment state variables
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! pour les cas sandu et astex, on reclacule u,v,q,temp et teta dans 1D_nudge_sandu_astex.h
+! au dessus de 700hpa, on relaxe vers les profils initiaux
+      if (forcing_sandu .OR. forcing_astex) then
+#include "1D_nudge_sandu_astex.h"
+      else
+        u(1:mxcalc)=u(1:mxcalc) + timestep*(                                &
+     &              du_phys(1:mxcalc)                                       &
+     &             +du_age(1:mxcalc) )            
+        v(1:mxcalc)=v(1:mxcalc) + timestep*(                                 &
+     &              dv_phys(1:mxcalc)                                       &
+     &             +dv_age(1:mxcalc) )
+        q(1:mxcalc,:)=q(1:mxcalc,:)+timestep*(                              &
+     &                dq(1:mxcalc,:)                                        &
+     &               +d_q_adv(1:mxcalc,:) )
+
+        if (prt_level.ge.1) then
+          print *,                                                          &
+     &    'physiq-> temp(1),dt_phys(1),d_th_adv(1),dt_cooling(1) ',         &
+     &              temp(1),dt_phys(1),d_th_adv(1),dt_cooling(1)
+           print*,du_phys
+           print*, v
+           print*, vg
+        endif
+
+        temp(1:mxcalc)=temp(1:mxcalc)+timestep*(                            &
+     &              dt_phys(1:mxcalc)                                       &
+     &             +d_th_adv(1:mxcalc)                                      &
+     &             +dt_cooling(1:mxcalc))  ! Taux de chauffage ou refroid.
+
+      endif  ! forcing_sandu or forcing_astex
+
+        teta=temp*(pzero/play)**rkappa
+!
+!---------------------------------------------------------------------
+!   Nudge soil temperature if requested
+!---------------------------------------------------------------------
+
+      IF (nudge_tsoil) THEN
+       ftsoil(1,isoil_nudge,:) = ftsoil(1,isoil_nudge,:)                     &
+     &  -timestep/tau_soil_nudge*(ftsoil(1,isoil_nudge,:)-Tsoil_nudge)
+      ENDIF
+
+!---------------------------------------------------------------------
+!   Add large-scale tendencies (advection, etc) :
+!---------------------------------------------------------------------
+
+!cc nrlmd
+!cc        tmpvar=teta
+!cc        call advect_vert(llm,omega,timestep,tmpvar,plev)
+!cc
+!cc        teta(1:mxcalc)=tmpvar(1:mxcalc)
+!cc        tmpvar(:)=q(:,1)
+!cc        call advect_vert(llm,omega,timestep,tmpvar,plev)
+!cc        q(1:mxcalc,1)=tmpvar(1:mxcalc)
+!cc        tmpvar(:)=q(:,2)
+!cc        call advect_vert(llm,omega,timestep,tmpvar,plev)
+!cc        q(1:mxcalc,2)=tmpvar(1:mxcalc)
+
+!---------------------------------------------------------------------
+!   Air temperature :
+!---------------------------------------------------------------------        
+        if (lastcall) then
+          print*,'Pas de temps final ',it
+          call ju2ymds(daytime, an, mois, jour, heure)
+          print*,'a la date : a m j h',an, mois, jour ,heure/3600.
+        endif
+
+!  incremente day time
+!        print*,'daytime bef',daytime,1./day_step
+        daytime = daytime+1./day_step
+!Al1dbg
+        day = int(daytime+0.1/day_step)
+!        time = max(daytime-day,0.0)
+!Al1&jyg: correction de bug
+!cc        time = real(mod(it,day_step))/day_step
+        time = time_ini/24.+real(mod(it,day_step))/day_step
+!        print*,'daytime nxt time',daytime,time
+        it=it+1
+
+      enddo
+
+!Al1
+      if (ecrit_slab_oc.ne.-1) close(97)
+
+!Al1 Call to 1D equivalent of dynredem (an,mois,jour,heure ?)
+! -------------------------------------
+       call dyn1dredem("restart1dyn.nc",                                    &
+     &              plev,play,phi,phis,presnivs,                            &
+     &              u,v,temp,q,omega2)
+
+        CALL abort_gcm ('lmdz1d   ','The End  ',0)
+
+      end
+
+#include "1DUTILS.h"
+#include "1Dconv.h"
+
+#endif
+
Index: /LMDZ5/branches/testing/libf/phylmd/microphys_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/microphys_mod.F90	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/microphys_mod.F90	(revision 2056)
@@ -0,0 +1,31 @@
+!
+! $Header$
+!
+MODULE microphys_mod
+
+CONTAINS
+!*******************************************************************
+
+FUNCTION icefrac_lsc(temp, tmin, tmax, nexpo)
+  IMPLICIT NONE
+  !
+  ! Compute the ice fraction 1-xliq (see e.g.
+  ! Doutriaux-Boucher & Quaas 2004, section 2.2.)
+  !
+  ! (JBM 3/14)
+  REAL :: icefrac_lsc ! ice fraction 
+  REAL :: temp ! temperature
+  REAL :: tmin ! if T < Tmin, the cloud is only made of water ice
+  REAL :: tmax ! if T > Tmax, the cloud is only made of liquid water
+  REAL :: nexpo ! controls the sharpness of the transition
+
+  icefrac_lsc = 1.0 - (temp-tmin) / (tmax-tmin)
+  icefrac_lsc = MIN(MAX(icefrac_lsc,0.0),1.0)
+  icefrac_lsc = icefrac_lsc**nexpo
+
+  RETURN
+END FUNCTION icefrac_lsc
+
+!*******************************************************************
+!
+END MODULE microphys_mod
Index: /LMDZ5/branches/testing/libf/phylmd/newmicro.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/newmicro.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/newmicro.F90	(revision 2056)
@@ -12,4 +12,5 @@
     reffclwc, cldnvi, lcc3d, lcc3dcon, lcc3dstra
   USE phys_state_var_mod, ONLY: rnebcon, clwcon
+  USE microphys_mod ! cloud microphysics (JBM 3/14)
   IMPLICIT NONE
   ! ======================================================================
@@ -106,7 +107,11 @@
   PARAMETER (seuil_neb=0.001)
 
-  INTEGER nexpo ! exponentiel pour glace/eau
-  PARAMETER (nexpo=6)
-  ! PARAMETER (nexpo=1)
+! JBM (3/14) nexpo is replaced by exposant_glace
+! INTEGER nexpo ! exponentiel pour glace/eau
+! PARAMETER (nexpo=6)
+! PARAMETER (nexpo=1)
+! if iflag_t_glace=0, the old values are used:
+  REAL, PARAMETER :: t_glace_min_old = 258.
+  REAL, PARAMETER :: t_glace_max_old = 273.13
 
   REAL rel, tc, rei
@@ -180,18 +185,35 @@
   reice_pi = 0.
 
-  DO k = 1, klev
-    DO i = 1, klon
-      ! -layer calculation
-      rhodz(i, k) = (paprs(i,k)-paprs(i,k+1))/rg ! kg/m2
-      zrho(i, k) = pplay(i, k)/t(i, k)/rd ! kg/m3
-      dh(i, k) = rhodz(i, k)/zrho(i, k) ! m
-      ! -Fraction of ice in cloud using a linear transition
-      zfice(i, k) = 1.0 - (t(i,k)-t_glace_min)/(t_glace_max-t_glace_min)
-      zfice(i, k) = min(max(zfice(i,k),0.0), 1.0)
-      ! -IM Total Liquid/Ice water content
-      xflwc(i, k) = (1.-zfice(i,k))*pqlwp(i, k)
-      xfiwc(i, k) = zfice(i, k)*pqlwp(i, k)
-    END DO
-  END DO
+  IF (iflag_t_glace.EQ.0) THEN
+    DO k = 1, klev
+      DO i = 1, klon
+        ! -layer calculation
+        rhodz(i, k) = (paprs(i,k)-paprs(i,k+1))/rg ! kg/m2
+        zrho(i, k) = pplay(i, k)/t(i, k)/rd ! kg/m3
+        dh(i, k) = rhodz(i, k)/zrho(i, k) ! m
+        ! -Fraction of ice in cloud using a linear transition
+        zfice(i, k) = 1.0 - (t(i,k)-t_glace_min_old)/(t_glace_max_old-t_glace_min_old)
+        zfice(i, k) = min(max(zfice(i,k),0.0), 1.0)
+        ! -IM Total Liquid/Ice water content
+        xflwc(i, k) = (1.-zfice(i,k))*pqlwp(i, k)
+        xfiwc(i, k) = zfice(i, k)*pqlwp(i, k)
+      END DO
+    END DO
+  ELSE ! of IF (iflag_t_glace.EQ.0)
+    DO k = 1, klev
+      DO i = 1, klon
+        ! -layer calculation
+        rhodz(i, k) = (paprs(i,k)-paprs(i,k+1))/rg ! kg/m2
+        zrho(i, k) = pplay(i, k)/t(i, k)/rd ! kg/m3
+        dh(i, k) = rhodz(i, k)/zrho(i, k) ! m
+        ! JBM: icefrac_lsc is now a function contained in microphys_mod
+        zfice(i, k) = icefrac_lsc(t(i,k), t_glace_min, &
+                                  t_glace_max, exposant_glace)
+        ! -IM Total Liquid/Ice water content
+        xflwc(i, k) = (1.-zfice(i,k))*pqlwp(i, k)
+        xfiwc(i, k) = zfice(i, k)*pqlwp(i, k)
+      END DO
+    END DO
+  ENDIF
 
   IF (ok_cdnc) THEN
Index: /LMDZ5/branches/testing/libf/phylmd/nuage.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/nuage.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/nuage.F90	(revision 2056)
@@ -5,4 +5,5 @@
     cldtaupi, re, fl)
   USE dimphy
+  USE microphys_mod ! cloud microphysics (JBM 3/14)
   IMPLICIT NONE
   ! ======================================================================
@@ -34,4 +35,5 @@
 
   include "YOMCST.h"
+  include "nuage.h" ! JBM 3/14
 
   ! ym#include "dimensions.h"
@@ -54,14 +56,20 @@
   REAL zflwp, zradef, zfice, zmsac
 
-  REAL radius, rad_froid, rad_chaud, rad_chau1, rad_chau2
-  PARAMETER (rad_chau1=13.0, rad_chau2=9.0, rad_froid=35.0)
+  REAL radius, rad_chaud
+! JBM (3/14) parameters already defined in nuage.h:
+! REAL rad_froid, rad_chau1, rad_chau2
+! PARAMETER (rad_chau1=13.0, rad_chau2=9.0, rad_froid=35.0)
   ! cc      PARAMETER (rad_chaud=15.0, rad_froid=35.0)
   ! sintex initial      PARAMETER (rad_chaud=10.0, rad_froid=30.0)
   REAL coef, coef_froi, coef_chau
   PARAMETER (coef_chau=0.13, coef_froi=0.09)
-  REAL seuil_neb, t_glace
-  PARAMETER (seuil_neb=0.001, t_glace=273.0-15.0)
-  INTEGER nexpo ! exponentiel pour glace/eau
-  PARAMETER (nexpo=6)
+  REAL seuil_neb
+  PARAMETER (seuil_neb=0.001)
+! JBM (3/14) nexpo is replaced by exposant_glace
+! REAL nexpo ! exponentiel pour glace/eau
+! PARAMETER (nexpo=6.)
+  REAL, PARAMETER :: t_glace_min_old = 258.
+  INTEGER, PARAMETER :: exposant_glace_old = 6
+
 
   ! jq for the aerosol indirect effect
@@ -96,7 +104,13 @@
       pclc(i, k) = max(pclc(i,k), seuil_neb)
       zflwp = 1000.*pqlwp(i, k)/rg/pclc(i, k)*(paprs(i,k)-paprs(i,k+1))
-      zfice = 1.0 - (t(i,k)-t_glace)/(273.13-t_glace)
-      zfice = min(max(zfice,0.0), 1.0)
-      zfice = zfice**nexpo
+      IF (iflag_t_glace.EQ.0) THEN
+        zfice = 1.0 - (t(i,k)-t_glace_min_old)/(273.13-t_glace_min_old)
+        zfice = min(max(zfice,0.0), 1.0)
+        zfice = zfice**exposant_glace_old
+      ELSE ! of IF (iflag_t_glace.EQ.0)
+! JBM: icefrac_lsc is now a function contained in microphys_mod
+        zfice = icefrac_lsc(t(i,k), t_glace_min, &
+                            t_glace_max, exposant_glace)
+      ENDIF
 
       IF (ok_aie) THEN
Index: /LMDZ5/branches/testing/libf/phylmd/nuage.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/nuage.h	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/nuage.h	(revision 2056)
@@ -3,7 +3,11 @@
 !
       REAL rad_froid, rad_chau1, rad_chau2, t_glace_max, t_glace_min
+      REAL exposant_glace
       REAL rei_min,rei_max
 
+      INTEGER iflag_t_glace
+
       common /nuagecom/ rad_froid,rad_chau1, rad_chau2,t_glace_max,     &
-     &                  t_glace_min,rei_min,rei_max
+     &                  t_glace_min,exposant_glace,rei_min,rei_max,     &
+     &                  iflag_t_glace
 !$OMP THREADPRIVATE(/nuagecom/)
Index: /LMDZ5/branches/testing/libf/phylmd/oasis.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/oasis.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/oasis.F90	(revision 2056)
@@ -96,4 +96,8 @@
     USE surface_data, ONLY : version_ocean
     USE carbon_cycle_mod, ONLY : carbon_cycle_cpl
+#ifdef CPP_XIOS
+    USE wxios, ONLY : wxios_context_init 
+#endif
+
 
     INCLUDE "dimensions.h"
@@ -128,5 +132,5 @@
 ! Define the model name
 !
-    clmodnam = 'lmdz.x'       ! as in $NBMODEL in Cpl/Nam/namcouple.tmp
+    clmodnam = 'LMDZ'       ! as in $NBMODEL in Cpl/Nam/namcouple.tmp
 
 
@@ -298,4 +302,8 @@
     ENDIF
 
+#ifdef CPP_XIOS
+    CALL wxios_context_init()
+#endif
+
 !$OMP END MASTER
     
Index: /LMDZ5/branches/testing/libf/phylmd/orografi_strato.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/orografi_strato.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/orografi_strato.F90	(revision 2056)
@@ -1873,4 +1873,5 @@
   PRINT *, ' DANS SUGWD nktopg=', nktopg
   PRINT *, ' DANS SUGWD nstra=', nstra
+  if (nstra == 0) call abort_gcm("sugwd_strato", "no level in stratosphere", 1)
 
   gsigcr = 0.80
Index: /LMDZ5/branches/testing/libf/phylmd/phyetat0.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/phyetat0.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/phyetat0.F90	(revision 2056)
@@ -195,6 +195,6 @@
              'coherente ', i, zmasq(i) , pctsrf(i, is_oce) &
              , pctsrf(i, is_sic)
-        WRITE(*, *) 'Je force la coherence zmasq=fractint'
-        zmasq(i) = fractint(i)
+        WRITE(*, *) 'Je force la coherence zmasq=1.-fractint'
+        zmasq(i) = 1. - fractint(i)
      ENDIF
   END DO
@@ -1048,6 +1048,4 @@
   CALL close_startphy
 
-  CALL init_iophy_new(rlat, rlon)
-
   ! Initialize module pbl_surface_mod 
 
@@ -1060,6 +1058,7 @@
   ENDIF
 
+  CALL init_iophy_new(rlat, rlon)
+
   ! Initilialize module fonte_neige_mod      
-
   CALL fonte_neige_init(run_off_lic_0)
 
Index: /LMDZ5/branches/testing/libf/phylmd/phys_local_var_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/phys_local_var_mod.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/phys_local_var_mod.F90	(revision 2056)
@@ -334,6 +334,9 @@
       allocate(topswcf_aero(klon,3), solswcf_aero(klon,3))
       allocate(d_u_hin(klon,klev),d_v_hin(klon,klev),d_t_hin(klon,klev))
-      allocate(tausum_aero(klon,nwave,naero_spc))
-      allocate(tau3d_aero(klon,klev,nwave,naero_spc)) 
+!      allocate(tausum_aero(klon,nwave,naero_spc))
+!      allocate(tau3d_aero(klon,klev,nwave,naero_spc)) 
+!--correction mini bug OB
+      allocate(tausum_aero(klon,nwave,naero_tot))
+      allocate(tau3d_aero(klon,klev,nwave,naero_tot)) 
       allocate(scdnc(klon, klev))
       allocate(cldncl(klon))
Index: /LMDZ5/branches/testing/libf/phylmd/phys_output_ctrlout_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 2056)
@@ -3,5 +3,5 @@
   USE phys_output_var_mod
   USE indice_sol_mod
-  USE aero_mod, only : naero_spc,name_aero
+  USE aero_mod, only : naero_tot,name_aero_tau
 
 
@@ -237,5 +237,7 @@
     'bils_diss', 'Surf. total heat flux', 'W/m2', (/ ('', i=1, 9) /))
   TYPE(ctrl_out), SAVE :: o_bils_ec = ctrl_out((/ 1, 2, 10, 5, 10, 10, 11, 11, 11 /), &
-    'bils_ec', 'Surf. total heat flux', 'W/m2', (/ ('', i=1, 9) /))
+    'bils_ec', 'Surf. total heat flux correction', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_bils_ech = ctrl_out((/ 1, 2, 10, 5, 10, 10, 11, 11, 11 /), &
+    'bils_ech', 'Surf. total heat flux correction', 'W/m2', (/ ('', i=1, 9) /))
   TYPE(ctrl_out), SAVE :: o_bils_kinetic = ctrl_out((/ 1, 2, 10, 5, 10, 10, 11, 11, 11 /), &
     'bils_kinetic', 'Surf. total heat flux', 'W/m2', (/ ('', i=1, 9) /))
@@ -723,29 +725,28 @@
     'solswai', 'AIE at SFR', 'W/m2', (/ ('', i=1, 9) /))
 
-!  type(ctrl_out),save,dimension(10) :: o_tausumaero  = (/ ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_ASBCM', &
-!    (/ ('', i=1, 9) /)), &
-  type(ctrl_out),save,dimension(11) :: o_tausumaero  =                           & 
+  type(ctrl_out),save,dimension(naero_tot) :: o_tausumaero  =                           & 
     (/ ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_ASBCM',                        &
-      "Aerosol Optical depth at 550 nm "//name_aero(1),"1", (/ ('', i=1, 9) /)), &
+      "Aerosol Optical depth at 550 nm "//name_aero_tau(1),"1", (/ ('', i=1, 9) /)), &
        ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_ASPOMM',                       &
-      "Aerosol Optical depth at 550 nm "//name_aero(2),"1", (/ ('', i=1, 9) /)), &
+      "Aerosol Optical depth at 550 nm "//name_aero_tau(2),"1", (/ ('', i=1, 9) /)), &
        ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_ASSO4M',                       &
-      "Aerosol Optical depth at 550 nm "//name_aero(3),"1", (/ ('', i=1, 9) /)), &
+      "Aerosol Optical depth at 550 nm "//name_aero_tau(3),"1", (/ ('', i=1, 9) /)), &
        ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_CSSO4M',                       &
-      "Aerosol Optical depth at 550 nm "//name_aero(4),"1", (/ ('', i=1, 9) /)), &
+      "Aerosol Optical depth at 550 nm "//name_aero_tau(4),"1", (/ ('', i=1, 9) /)), &
        ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_SSSSM',                        &
-      "Aerosol Optical depth at 550 nm "//name_aero(5),"1", (/ ('', i=1, 9) /)), &
+      "Aerosol Optical depth at 550 nm "//name_aero_tau(5),"1", (/ ('', i=1, 9) /)), &
        ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_ASSSM',                        &
-      "Aerosol Optical depth at 550 nm "//name_aero(6),"1", (/ ('', i=1, 9) /)), &
+      "Aerosol Optical depth at 550 nm "//name_aero_tau(6),"1", (/ ('', i=1, 9) /)), &
        ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_CSSSM',                        &
-      "Aerosol Optical depth at 550 nm "//name_aero(7),"1", (/ ('', i=1, 9) /)), &
+      "Aerosol Optical depth at 550 nm "//name_aero_tau(7),"1", (/ ('', i=1, 9) /)), &
        ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_CIDUSTM',                      &
-      "Aerosol Optical depth at 550 nm "//name_aero(8),"1", (/ ('', i=1, 9) /)), &
+      "Aerosol Optical depth at 550 nm "//name_aero_tau(8),"1", (/ ('', i=1, 9) /)), &
        ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_AIBCM',                        &
-      "Aerosol Optical depth at 550 nm "//name_aero(9),"1", (/ ('', i=1, 9) /)), &
+      "Aerosol Optical depth at 550 nm "//name_aero_tau(9),"1", (/ ('', i=1, 9) /)), &
        ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_AIPOMM',                       &
-      "Aerosol Optical depth at 550 nm "//name_aero(10),"1", (/ ('', i=1, 9) /)),&
+      "Aerosol Optical depth at 550 nm "//name_aero_tau(10),"1", (/ ('', i=1, 9) /)),&
        ctrl_out((/ 2, 2, 10, 10, 10, 10, 11, 11, 11 /),'OD550_STRAT',                        &
-      "Aerosol Optical depth at 550 nm "//name_aero(11),"1", (/ ('', i=1, 9) /)) /)
+      "Aerosol Optical depth at 550 nm "//name_aero_tau(11),"1", (/ ('', i=1, 9) /)) /)
+!
   TYPE(ctrl_out), SAVE :: o_od550aer = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
     'od550aer', 'Total aerosol optical depth at 550nm', '-', (/ ('', i=1, 9) /))
Index: /LMDZ5/branches/testing/libf/phylmd/phys_output_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/phys_output_mod.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/phys_output_mod.F90	(revision 2056)
@@ -26,6 +26,5 @@
 
   SUBROUTINE phys_output_open(rlon,rlat,pim,tabij,ipt,jpt,plon,plat, &
-       jjmp1,nlevSTD,clevSTD,rlevSTD,nbteta, &
-       ctetaSTD, dtime, ok_veget, &
+       jjmp1,nlevSTD,clevSTD,rlevSTD, dtime, ok_veget, &
        type_ocean, iflag_pbl,ok_mensuel,ok_journe, &
        ok_hf,ok_instan,ok_LES,ok_ade,ok_aie, read_climoz, &
@@ -82,5 +81,5 @@
 
     INTEGER                               :: jjmp1
-    INTEGER                               :: nbteta, nlevSTD, radpas
+    INTEGER                               :: nlevSTD, radpas
     LOGICAL                               :: ok_mensuel, ok_journe, ok_hf, ok_instan
     LOGICAL                               :: ok_LES,ok_ade,ok_aie,flag_aerosol_strat
@@ -106,5 +105,4 @@
     CHARACTER(LEN=2)                      :: bb3
     CHARACTER(LEN=6)                      :: type_ocean
-    CHARACTER(LEN=3)                      :: ctetaSTD(nbteta)
     INTEGER, DIMENSION(iim*jjmp1)         ::  ndex2d
     INTEGER, DIMENSION(iim*jjmp1*klev)    :: ndex3d
@@ -306,20 +304,25 @@
 #ifdef CPP_XIOS
 !!! Ouverture de chaque fichier XIOS !!!!!!!!!!!
+    if (prt_level >= 10) then
+      print*,'phys_output_open: call wxios_add_file with phys_out_filenames(iff)=',trim(phys_out_filenames(iff))                                                                        
+    endif
     CALL wxios_add_file(phys_out_filenames(iff),chtimestep(iff),lev_files(iff))  
-    print*,'wxios_add_file phys_out_filenames(iff)',phys_out_filenames(iff)                                                                        
 
 !!! Declaration des axes verticaux de chaque fichier:
-    print*,'Declaration des axes verticaux de chaque fichier '
+    if (prt_level >= 10) then
+      print*,'phys_output_open: Declare vertical axes for each file'
+    endif
    if (iff.le.6) then
-    CALL wxios_add_vaxis("presnivs", phys_out_filenames(iff), &
+    CALL wxios_add_vaxis("presnivs", &
             levmax(iff) - levmin(iff) + 1, presnivs(levmin(iff):levmax(iff)))
-    CALL wxios_add_vaxis("Ahyb", phys_out_filenames(iff), &
+    CALL wxios_add_vaxis("Ahyb", &
             levmax(iff) - levmin(iff) + 1, Ahyb)
-    CALL wxios_add_vaxis("Bhyb", phys_out_filenames(iff), &
+    CALL wxios_add_vaxis("Bhyb", &
             levmax(iff) - levmin(iff) + 1, Bhyb)
-    CALL wxios_add_vaxis("Ahyb", phys_out_filenames(iff), &
+    CALL wxios_add_vaxis("Alt", &
             levmax(iff) - levmin(iff) + 1, Alt)
    else
-    CALL wxios_add_vaxis("plev", phys_out_filenames(iff), &
+    ! NMC files
+    CALL wxios_add_vaxis("plev", &
             levmax(iff) - levmin(iff) + 1, rlevSTD(levmin(iff):levmax(iff)))
    endif
@@ -362,6 +365,8 @@
           else IF (clef_stations(iff)) THEN
 
-             WRITE(lunout,*)'phys_output_mod phys_out_filenames=',phys_out_filenames(iff)
-
+             if (prt_level >= 10) then
+             WRITE(lunout,*)'phys_output_open: iff=',iff,'  phys_out_filenames(iff)=',phys_out_filenames(iff)
+             endif
+             
              CALL histbeg_phy_all(rlon,rlat,pim,tabij,ipt,jpt,plon,plat,plon_bounds,plat_bounds, &
                   phys_out_filenames(iff), &
@@ -491,6 +496,8 @@
     ecrit_ins = ecrit_files(6)
 
-    WRITE(lunout,*)'swaero_diag=',swaero_diag
-    WRITE(lunout,*)'Fin phys_output_mod.F90'
+    if (prt_level >= 10) then
+      WRITE(lunout,*)'swaero_diag=',swaero_diag
+      WRITE(lunout,*)'phys_output_open: ends here'
+    endif
 
   end SUBROUTINE phys_output_open
Index: /LMDZ5/branches/testing/libf/phylmd/phys_output_var_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/phys_output_var_mod.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/phys_output_var_mod.F90	(revision 2056)
@@ -17,4 +17,5 @@
   !$OMP THREADPRIVATE(itau_con)
   REAL, ALLOCATABLE :: bils_ec(:) ! Contribution of energy conservation
+  REAL, ALLOCATABLE :: bils_ech(:) ! Contribution of energy conservation
   REAL, ALLOCATABLE :: bils_tke(:) ! Contribution of energy conservation
   REAL, ALLOCATABLE :: bils_diss(:) ! Contribution of energy conservation
@@ -22,5 +23,5 @@
   REAL, ALLOCATABLE :: bils_enthalp(:) ! bilan de chaleur au sol
   REAL, ALLOCATABLE :: bils_latent(:) ! bilan de chaleur au sol
-  !$OMP THREADPRIVATE(bils_ec,bils_tke,bils_diss,bils_kinetic,bils_enthalp,bils_latent)
+  !$OMP THREADPRIVATE(bils_ec,bils_ech,bils_tke,bils_diss,bils_kinetic,bils_enthalp,bils_latent)
 
 
@@ -83,5 +84,5 @@
     allocate(snow_o(klon), zfra_o(klon))
     allocate(itau_con(klon))
-    allocate (bils_ec(klon),bils_tke(klon),bils_diss(klon),bils_kinetic(klon),bils_enthalp(klon),bils_latent(klon))
+    allocate (bils_ec(klon),bils_ech(klon),bils_tke(klon),bils_diss(klon),bils_kinetic(klon),bils_enthalp(klon),bils_latent(klon))
 
     IF (ok_gwd_rando) allocate(zustr_gwd_rando(klon), zvstr_gwd_rando(klon))
@@ -95,5 +96,5 @@
 
     deallocate(snow_o,zfra_o,itau_con)
-    deallocate (bils_ec,bils_tke,bils_diss,bils_kinetic,bils_enthalp,bils_latent)
+    deallocate (bils_ec,bils_ech,bils_tke,bils_diss,bils_kinetic,bils_enthalp,bils_latent)
 
   END SUBROUTINE phys_output_var_end
Index: /LMDZ5/branches/testing/libf/phylmd/phys_output_write_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/phys_output_write_mod.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/phys_output_write_mod.F90	(revision 2056)
@@ -19,5 +19,5 @@
        ok_ade, ok_aie, ivap, new_aod, ok_sync, &
        ptconv, read_climoz, clevSTD, ptconvth, &
-       d_t, qx, d_qx, zmasse, flag_aerosol_strat)
+       d_t, qx, d_qx, zmasse, flag_aerosol, flag_aerosol_strat, ok_cdnc)
 
     ! This subroutine does the actual writing of diagnostics that were
@@ -45,5 +45,5 @@
          o_LWupSFC, o_LWdnSFC, o_LWupSFCclr, &
          o_LWdnSFCclr, o_bils, o_bils_diss, &
-         o_bils_ec, o_bils_tke, o_bils_kinetic, &
+         o_bils_ec,o_bils_ech, o_bils_tke, o_bils_kinetic, &
          o_bils_latent, o_bils_enthalp, o_sens, &
          o_fder, o_ffonte, o_fqcalving, o_fqfonte, &
@@ -217,5 +217,5 @@
 
     USE phys_output_var_mod, only: vars_defined, snow_o, zfra_o, bils_diss, &
-         bils_ec, bils_tke, bils_kinetic, bils_latent, bils_enthalp, &
+         bils_ec,bils_ech, bils_tke, bils_kinetic, bils_latent, bils_enthalp, &
          itau_con, nfiles, clef_files, nid_files, zvstr_gwd_rando
     USE indice_sol_mod, only: nbsrf
@@ -223,5 +223,6 @@
     USE comgeomphy, only: airephy
     USE surface_data, only: type_ocean, ok_veget, ok_snow
-    USE aero_mod, only: naero_spc
+!    USE aero_mod, only: naero_spc
+    USE aero_mod, only: naero_tot
     USE ioipsl, only: histend, histsync
     USE iophy, only: set_itau_iophy, histwrite_phy
@@ -230,5 +231,6 @@
 #ifdef CPP_XIOS
     ! ug Pour les sorties XIOS
-    USE wxios, only: wxios_update_calendar, wxios_closedef
+    USE xios, ONLY: xios_update_calendar
+    USE wxios, only: wxios_closedef
 #endif
     USE phys_cal_mod, only : mth_len
@@ -259,4 +261,6 @@
     REAL, DIMENSION(klon, llm) :: zmasse
     LOGICAL :: flag_aerosol_strat
+    INTEGER :: flag_aerosol 
+    LOGICAL :: ok_cdnc
     REAL, DIMENSION(3) :: freq_moyNMC
 
@@ -292,7 +296,7 @@
        IF (vars_defined) THEN
           if (prt_level >= 10) then
-             write(lunout,*)"phys_output_write: call wxios_update_calendar, itau_w=",itau_w
+             write(lunout,*)"phys_output_write: call xios_update_calendar, itau_w=",itau_w
           endif
-          CALL wxios_update_calendar(itau_w)
+          CALL xios_update_calendar(itau_w)
        END IF
        !$OMP END MASTER
@@ -463,4 +467,7 @@
        CALL histwrite_phy(o_bils_diss, bils_diss)
        CALL histwrite_phy(o_bils_ec, bils_ec)
+       IF (iflag_ener_conserv>=1) THEN
+         CALL histwrite_phy(o_bils_ech, bils_ech)
+       ENDIF
        CALL histwrite_phy(o_bils_tke, bils_tke)
        CALL histwrite_phy(o_bils_kinetic, bils_kinetic)
@@ -770,5 +777,5 @@
        ! OD550 per species
        IF (new_aod .and. (.not. aerosol_couple)) THEN
-          IF (ok_ade.OR.ok_aie) THEN
+          IF (flag_aerosol.GT.0) THEN
              CALL histwrite_phy(o_od550aer, od550aer)
              CALL histwrite_phy(o_od865aer, od865aer)
@@ -792,6 +799,8 @@
              !--STRAT AER
           ENDIF
-          IF (ok_ade.OR.ok_aie.OR.flag_aerosol_strat) THEN
-             DO naero = 1, naero_spc
+          IF (flag_aerosol.GT.0.OR.flag_aerosol_strat) THEN
+!             DO naero = 1, naero_spc
+!--correction mini bug OB
+             DO naero = 1, naero_tot
                 CALL histwrite_phy(o_tausumaero(naero), &
                      tausum_aero(:,2,naero) )
@@ -830,4 +839,6 @@
           CALL histwrite_phy(o_topswai, topswai_aero)
           CALL histwrite_phy(o_solswai, solswai_aero)
+       ENDIF
+       IF (flag_aerosol.GT.0.AND.ok_cdnc) THEN
           CALL histwrite_phy(o_scdnc, scdnc)
           CALL histwrite_phy(o_cldncl, cldncl)
Index: /LMDZ5/branches/testing/libf/phylmd/phys_state_var_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/phys_state_var_mod.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/phys_state_var_mod.F90	(revision 2056)
@@ -349,4 +349,6 @@
       REAL,SAVE,ALLOCATABLE :: tau_aero(:,:,:,:), piz_aero(:,:,:,:), cg_aero(:,:,:,:)
 !$OMP THREADPRIVATE(tau_aero, piz_aero, cg_aero)
+      REAL,SAVE,ALLOCATABLE :: tau_aero_rrtm(:,:,:,:), piz_aero_rrtm(:,:,:,:), cg_aero_rrtm(:,:,:,:)
+!$OMP THREADPRIVATE(tau_aero_rrtm, piz_aero_rrtm, cg_aero_rrtm)
       REAL,SAVE,ALLOCATABLE :: ccm(:,:,:)
 !$OMP THREADPRIVATE(ccm)
@@ -517,4 +519,6 @@
       ALLOCATE(topswai(klon), solswai(klon))
       ALLOCATE(tau_aero(klon,klev,naero_grp,nbands),piz_aero(klon,klev,naero_grp,nbands),cg_aero(klon,klev,naero_grp,nbands))
+      ALLOCATE(tau_aero_rrtm(klon,klev,2,nbands_rrtm),piz_aero_rrtm(klon,klev,2,nbands_rrtm))
+      ALLOCATE(cg_aero_rrtm(klon,klev,2,nbands_rrtm))
       ALLOCATE(ccm(klon,klev,nbands))
 
@@ -631,4 +635,5 @@
       deallocate(topswai, solswai)
       deallocate(tau_aero,piz_aero,cg_aero)
+      deallocate(tau_aero_rrtm,piz_aero_rrtm,cg_aero_rrtm)
       deallocate(ccm)
       if (ok_gwd_rando) deallocate(du_gwd_rando, dv_gwd_rando)
Index: /LMDZ5/branches/testing/libf/phylmd/physiq.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/physiq.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/physiq.F90	(revision 2056)
@@ -8,6 +8,5 @@
      flxmass_w, &
      d_u, d_v, d_t, d_qx, d_ps &
-     , dudyn &
-     , PVteta)
+     , dudyn)
 
   USE ioipsl, only: histbeg, histvert, histdef, histend, histsync, &
@@ -52,4 +51,8 @@
   USE indice_sol_mod
   USE phytrac_mod, ONLY : phytrac
+
+#ifdef CPP_RRTM
+  USE YOERAD   , ONLY : NRADLP
+#endif
 
   !IM stations CFMIP
@@ -100,6 +103,4 @@
   !! d_qx----output-R-tendance physique de "qx" (kg/kg/s)
   !! d_ps----output-R-tendance physique de la pression au sol
-  !!IM
-  !! PVteta--output-R-vorticite potentielle a des thetas constantes
   !!======================================================================
   include "dimensions.h"
@@ -235,4 +236,5 @@
   ! Variables pour le transport convectif
   real da(klon,klev),phi(klon,klev,klev),mp(klon,klev)
+  real wght_cvfd(klon,klev)
   ! Variables pour le lessivage convectif
   ! RomP >>> 
@@ -245,28 +247,5 @@
   !IM definition dynamique o_trac dans phys_output_open
   !      type(ctrl_out) :: o_trac(nqtot)
-  !
-  !IM Amip2 PV a theta constante 
-  !
-  INTEGER nbteta
-  PARAMETER(nbteta=3)
-  CHARACTER*3 ctetaSTD(nbteta)
-  DATA ctetaSTD/'350','380','405'/
-  SAVE ctetaSTD
-  !$OMP THREADPRIVATE(ctetaSTD)
-  REAL rtetaSTD(nbteta)
-  DATA rtetaSTD/350., 380., 405./
-  SAVE rtetaSTD
-  !$OMP THREADPRIVATE(rtetaSTD)     
-  !
-  REAL PVteta(klon,nbteta)
-  !
-  !MI Amip2 PV a theta constante
-
-  !ym      INTEGER klevp1, klevm1
-  !ym      PARAMETER(klevp1=klev+1,klevm1=klev-1)
-  !ym      include "raddim.h"
-  !
-  !
-  !IM Amip2
+
   ! variables a une pression donnee
   !
@@ -510,5 +489,6 @@
   EXTERNAL fisrtilp  ! schema de condensation a grande echelle (pluie)
   !AA 
-  EXTERNAL fisrtilp_tr ! schema de condensation a grande echelle (pluie)
+! JBM (3/14) fisrtilp_tr not loaded
+! EXTERNAL fisrtilp_tr ! schema de condensation a grande echelle (pluie)
   !                          ! stockage des coefficients necessaires au
   !                          ! lessivage OFF-LINE et ON-LINE
@@ -1250,6 +1230,5 @@
      call phys_output_open(rlon,rlat,nCFMIP,tabijGCM, &
           iGCM,jGCM,lonGCM,latGCM, &
-          jjmp1,nlevSTD,clevSTD,rlevSTD, &
-          nbteta, ctetaSTD, dtime,ok_veget, &
+          jjmp1,nlevSTD,clevSTD,rlevSTD, dtime,ok_veget, &
           type_ocean,iflag_pbl,ok_mensuel,ok_journe, &
           ok_hf,ok_instan,ok_LES,ok_ade,ok_aie,  &
@@ -1785,8 +1764,8 @@
      IF (klon_glo==1) THEN
         CALL add_pbl_tend &
-          (d_u_vdf,d_v_vdf,d_t_vdf+d_t_diss,d_q_vdf,dql0,'vdf')
+          (d_u_vdf,d_v_vdf,d_t_vdf+d_t_diss,d_q_vdf,dql0,paprs,'vdf')
      ELSE
         CALL add_phys_tend &
-          (d_u_vdf,d_v_vdf,d_t_vdf+d_t_diss,d_q_vdf,dql0,'vdf')
+          (d_u_vdf,d_v_vdf,d_t_vdf+d_t_diss,d_q_vdf,dql0,paprs,'vdf')
      ENDIF
      !--------------------------------------------------------------------
@@ -2058,5 +2037,5 @@
              ftd,fqd,lalim_conv,wght_th, &
              ev, ep,epmlmMm,eplaMm, &
-             wdtrainA,wdtrainM)
+             wdtrainA,wdtrainM,wght_cvfd)
         ! RomP <<<
 
@@ -2155,5 +2134,5 @@
   !-----------------------------------------------------------------------------------------
   ! ajout des tendances de la diffusion turbulente
-  CALL add_phys_tend(d_u_con,d_v_con,d_t_con,d_q_con,dql0,'con')
+  CALL add_phys_tend(d_u_con,d_v_con,d_t_con,d_q_con,dql0,paprs,'con')
   !-----------------------------------------------------------------------------------------
 
@@ -2272,5 +2251,5 @@
      d_t_wake(:,:)=dt_wake(:,:)*dtime
      d_q_wake(:,:)=dq_wake(:,:)*dtime
-     CALL add_phys_tend(du0,dv0,d_t_wake,d_q_wake,dql0,'wake')
+     CALL add_phys_tend(du0,dv0,d_t_wake,d_q_wake,dql0,paprs,'wake')
      !-----------------------------------------------------------------------------------------
 
@@ -2372,4 +2351,5 @@
            ENDIF
 
+
            !----Initialisations
            do i=1,klon
@@ -2389,4 +2369,7 @@
                    s_trig,s2,n2
            ENDIF
+ 
+!Option pour re-activer l'ancien calcul de Ale_bl (iflag_trig_bl=2)
+           IF (iflag_trig_bl.eq.1) then
 
            !----Tirage al\'eatoire et calcul de ale_bl_trig
@@ -2407,4 +2390,26 @@
               endif
            enddo
+
+           ELSE IF (iflag_trig_bl.eq.2) then
+
+           do i=1,klon
+              if ( (Ale_bl(i) .gt. abs(cin(i))+1.e-10) )  then
+                 proba_notrig(i)=(1.-exp(-s_trig/s2(i)))** &
+                      (n2(i)*dtime/tau_trig(i))
+                 !        print *, 'proba_notrig(i) ',proba_notrig(i)
+                 if (random_notrig(i) .ge. proba_notrig(i)) then 
+                    ale_bl_trig(i)=Ale_bl(i)
+                 else
+                    ale_bl_trig(i)=0.
+                 endif
+              else
+                 proba_notrig(i)=1.
+                 random_notrig(i)=0.
+                 ale_bl_trig(i)=0.
+              endif
+           enddo
+
+           ENDIF
+
            !
            IF (prt_level .GE. 10) THEN
@@ -2416,6 +2421,16 @@
 
         !-----------Statistical closure-----------
-        if (iflag_clos_bl.ge.1) then 
-
+        if (iflag_clos_bl.eq.1) then 
+
+           do i=1,klon
+!CR: alp probabiliste
+               if (ale_bl_trig(i).gt.0.) then
+                  alp_bl(i)=alp_bl(i)/(1.-min(proba_notrig(i),0.999))
+               endif
+           enddo        
+  
+        else if (iflag_clos_bl.eq.2) then
+
+!CR: alp calculee dans thermcell_main
            do i=1,klon
               alp_bl(i)=alp_bl_stat(i)
@@ -2454,5 +2469,7 @@
 
         do i=1,klon
-           zmax_th(i)=pphi(i,lmax_th(i))/rg
+!           zmax_th(i)=pphi(i,lmax_th(i))/rg
+!CR:04/05/12:correction calcul zmax
+         zmax_th(i)=zmax0(i) 
         enddo
 
@@ -2494,5 +2511,5 @@
         !-----------------------------------------------------------------------------------------
         ! ajout des tendances de l'ajustement sec ou des thermiques
-        CALL add_phys_tend(du0,dv0,d_t_ajsb,d_q_ajsb,dql0,'ajsb')
+        CALL add_phys_tend(du0,dv0,d_t_ajsb,d_q_ajsb,dql0,paprs,'ajsb')
         d_t_ajs(:,:)=d_t_ajs(:,:)+d_t_ajsb(:,:)
         d_q_ajs(:,:)=d_q_ajs(:,:)+d_q_ajsb(:,:)
@@ -2552,5 +2569,5 @@
   !-----------------------------------------------------------------------------------------
   ! ajout des tendances de la diffusion turbulente
-  CALL add_phys_tend(du0,dv0,d_t_lsc,d_q_lsc,d_ql_lsc,'lsc')
+  CALL add_phys_tend(du0,dv0,d_t_lsc,d_q_lsc,d_ql_lsc,paprs,'lsc')
   !-----------------------------------------------------------------------------------------
   DO k = 1, klev
@@ -2659,5 +2676,7 @@
      !jq - Johannes Quaas, 27/11/2003 (quaas@lmd.jussieu.fr)
      IF (flag_aerosol .gt. 0) THEN
-        IF (.NOT. aerosol_couple) &
+        IF (.NOT. aerosol_couple) THEN
+           IF (iflag_rrtm .EQ. 0) THEN !--old radiation
+!
              CALL readaerosol_optic( &
              debut, new_aod, flag_aerosol, itap, jD_cur-jD_ref, &
@@ -2666,9 +2685,33 @@
              tau_aero, piz_aero, cg_aero,  &
              tausum_aero, tau3d_aero)
+!
+           ELSE                       ! RRTM radiation
+!
+#ifdef CPP_RRTM
+             CALL readaerosol_optic_rrtm( &
+             debut, new_aod, flag_aerosol, itap, jD_cur-jD_ref, &
+             pdtphys, pplay, paprs, t_seri, rhcl, presnivs,  &
+             mass_solu_aero, mass_solu_aero_pi,  &
+             tau_aero_rrtm, piz_aero_rrtm, cg_aero_rrtm,  &
+             tausum_aero, tau3d_aero)
+#else
+
+            abort_message='You should compile with -rrtm if running with iflag_rrtm=1'
+            call abort_gcm(modname,abort_message,1)
+#endif
+!
+           ENDIF
+        ENDIF
      ELSE
         tausum_aero(:,:,:) = 0.
-        tau_aero(:,:,:,:) = 0.
-        piz_aero(:,:,:,:) = 0.
-        cg_aero(:,:,:,:)  = 0.
+        IF (iflag_rrtm .EQ. 0) THEN !--old radiation
+          tau_aero(:,:,:,:) = 0.
+          piz_aero(:,:,:,:) = 0.
+          cg_aero(:,:,:,:)  = 0.
+        ELSE
+          tau_aero_rrtm(:,:,:,:)=0.0
+          piz_aero_rrtm(:,:,:,:)=0.0
+          cg_aero_rrtm(:,:,:,:)=0.0
+        ENDIF
      ENDIF
      !
@@ -2677,5 +2720,15 @@
      IF (flag_aerosol_strat) THEN
         PRINT *,'appel a readaerosolstrat', mth_cur
-        CALL readaerosolstrato(debut)
+        IF (iflag_rrtm.EQ.0) THEN
+         CALL readaerosolstrato(debut)
+        ELSE
+#ifdef CPP_RRTM
+         CALL readaerosolstrato_rrtm(debut)
+#else
+
+         abort_message='You should compile with -rrtm if running with iflag_rrtm=1'
+         call abort_gcm(modname,abort_message,1)
+#endif
+        ENDIF
      ENDIF
      !--fin STRAT AEROSOL
@@ -2896,4 +2949,16 @@
 
   if (ok_newmicro) then
+     IF (iflag_rrtm.NE.0) THEN 
+#ifdef CPP_RRTM
+       IF (ok_cdnc.AND.NRADLP.NE.3) THEN
+         abort_message='RRTM choix incoherent NRADLP doit etre egal a 3 pour ok_cdnc' 
+         call abort_gcm(modname,abort_message,1)
+       endif
+#else
+
+       abort_message='You should compile with -rrtm if running with iflag_rrtm=1'
+       call abort_gcm(modname,abort_message,1)
+#endif
+     ENDIF
      CALL newmicro (ok_cdnc, bl95_b0, bl95_b1, &
           paprs, pplay, t_seri, cldliq, cldfra, &
@@ -3037,4 +3102,5 @@
              flag_aerosol_strat, &
              tau_aero, piz_aero, cg_aero, &
+             tau_aero_rrtm, piz_aero_rrtm, cg_aero_rrtm,&     ! Rajoute par OB pour RRTM
              cldtaupirad,new_aod, &
              zqsat, flwc, fiwc, &
@@ -3083,4 +3149,5 @@
                    flag_aerosol_strat, &
                    tau_aero, piz_aero, cg_aero, &
+                   tau_aero_rrtm, piz_aero_rrtm, cg_aero_rrtm,&     ! Rajoute par OB pour RRTM
                    cldtaupi,new_aod, &
                    zqsat, flwc, fiwc, &
@@ -3220,5 +3287,5 @@
      !-----------------------------------------------------------------------------------------
      ! ajout des tendances de la trainee de l'orographie
-     CALL add_phys_tend(d_u_oro,d_v_oro,d_t_oro,dq0,dql0,'oro')
+     CALL add_phys_tend(d_u_oro,d_v_oro,d_t_oro,dq0,dql0,paprs,'oro')
      !-----------------------------------------------------------------------------------------
      !
@@ -3266,5 +3333,5 @@
      !-----------------------------------------------------------------------------------------
      ! ajout des tendances de la portance de l'orographie
-     CALL add_phys_tend(d_u_lif,d_v_lif,d_t_lif,dq0,dql0,'lif')
+     CALL add_phys_tend(d_u_lif,d_v_lif,d_t_lif,dq0,dql0,paprs,'lif')
      !-----------------------------------------------------------------------------------------
      !
@@ -3280,5 +3347,5 @@
      !
      !  ajout des tendances
-     CALL add_phys_tend(d_u_hin,d_v_hin,d_t_hin,dq0,dql0,'hin')
+     CALL add_phys_tend(d_u_hin,d_v_hin,d_t_hin,dq0,dql0,paprs,'hin')
 
   ENDIF
@@ -3288,5 +3355,5 @@
           rain_fall + snow_fall, zustr_gwd_rando, zvstr_gwd_rando, &
           du_gwd_rando, dv_gwd_rando)
-     CALL add_phys_tend(du_gwd_rando, dv_gwd_rando, dt0, dq0, dql0, &
+     CALL add_phys_tend(du_gwd_rando, dv_gwd_rando, dt0, dq0, dql0,paprs, &
           'flott_gwd_rando')
   end if
@@ -3408,5 +3475,5 @@
        pmflxr,   pmflxs,    prfl,     psfl, &
        da,       phi,       mp,       upwd, &
-       phi2,     d1a,       dam,      sij, &        !<<RomP
+       phi2,     d1a,       dam,      sij, wght_cvfd, &        !<<RomP+RL
        wdtrainA, wdtrainM,  sigd,     clw,elij, &   !<<RomP
        ev,       ep,        epmlmMm,  eplaMm, &     !<<RomP
@@ -3708,5 +3775,5 @@
        ptconv, read_climoz, clevSTD,                   &
        ptconvth, d_t, qx, d_qx, zmasse,                &
-       flag_aerosol_strat)
+       flag_aerosol, flag_aerosol_strat, ok_cdnc)
 
 
Index: /LMDZ5/branches/testing/libf/phylmd/phytrac_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/phytrac_mod.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/phytrac_mod.F90	(revision 2056)
@@ -54,27 +54,27 @@
 CONTAINS
 
-SUBROUTINE phytrac(                            &
-     nstep,     julien,   gmtime,   debutphy,  &
-     lafin,     pdtphys,  u, v,     t_seri,    &
-     paprs,     pplay,    pmfu,     pmfd,      &
-     pen_u,     pde_u,    pen_d,    pde_d,     &
-     cdragh,    coefh,    fm_therm, entr_therm,&
-     yu1,       yv1,      ftsol,    pctsrf,    &
-     ustar,     u10m,      v10m,               &
-     wstar,     ale_bl,      ale_wake,         &
-     xlat,      xlon,                          &
-     frac_impa,frac_nucl,beta_fisrt,beta_v1,   &
-     presnivs,  pphis,    pphi,     albsol,    &
-     sh,        rh,       cldfra,   rneb,      &
-     diafra,    cldliq,   itop_con, ibas_con,  &
-     pmflxr,    pmflxs,   prfl,     psfl,      &
-     da,        phi,      mp,       upwd,      &
-     phi2,      d1a,      dam,      sij,       &   ! RomP
-     wdtrainA,  wdtrainM, sigd,     clw,elij,  &   ! RomP 
-     evap,      ep,       epmlmMm,  eplaMm,    &   ! RomP
-     dnwd,      aerosol_couple,     flxmass_w, &
-     tau_aero,  piz_aero,  cg_aero, ccm,       &
-     rfname,                                   &
-     d_tr_dyn,                                 &   ! RomP
+SUBROUTINE phytrac(                                 &
+     nstep,     julien,   gmtime,   debutphy,       &
+     lafin,     pdtphys,  u, v,     t_seri,         &
+     paprs,     pplay,    pmfu,     pmfd,           &
+     pen_u,     pde_u,    pen_d,    pde_d,          &
+     cdragh,    coefh,    fm_therm, entr_therm,     &
+     yu1,       yv1,      ftsol,    pctsrf,         &
+     ustar,     u10m,      v10m,                    &
+     wstar,     ale_bl,      ale_wake,              &
+     xlat,      xlon,                               &
+     frac_impa,frac_nucl,beta_fisrt,beta_v1,        &
+     presnivs,  pphis,    pphi,     albsol,         &
+     sh,        rh,       cldfra,   rneb,           &
+     diafra,    cldliq,   itop_con, ibas_con,       &
+     pmflxr,    pmflxs,   prfl,     psfl,           &
+     da,        phi,      mp,       upwd,           &
+     phi2,      d1a,      dam,      sij, wght_cvfd, &   ! RomP +RL
+     wdtrainA,  wdtrainM, sigd,     clw, elij,      &   ! RomP 
+     evap,      ep,       epmlmMm,  eplaMm,         &   ! RomP
+     dnwd,      aerosol_couple,     flxmass_w,      &
+     tau_aero,  piz_aero,  cg_aero, ccm,            &
+     rfname,                                        &
+     d_tr_dyn,                                      &   ! RomP
      tr_seri)         
 !
@@ -190,4 +190,5 @@
   REAL,DIMENSION(klon,klev),INTENT(IN)      :: ep
   REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: sij
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: wght_cvfd          !RL
   REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: elij
   REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: epmlmMm
@@ -507,5 +508,6 @@
 !
           CALL cvltr(pdtphys, da, phi,phi2,d1a,dam, mp,ep,              &
-               sigd,sij,clw,elij,epmlmMm,eplaMm,                        &
+!!               sigd,sij,clw,elij,epmlmMm,eplaMm,                        &   !RL
+               sigd,sij,wght_cvfd,clw,elij,epmlmMm,eplaMm,              &     !RL
                pmflxr,pmflxs,evap,t_seri,wdtrainA,wdtrainM,             &   
                paprs,it,tr_seri,upwd,dnwd,itop_con,ibas_con,            &
@@ -514,6 +516,8 @@
                zmfd1a,zmfphi2,zmfdam)
         else  !pas de lessivage convectif ou n'est pas un aerosol
-           CALL cvltrorig(it,pdtphys, da, phi,mp,paprs,pplay,tr_seri,&
-                    upwd,dnwd,d_tr_cv)
+!!           CALL cvltrorig(it,pdtphys, da, phi,mp,paprs,pplay,tr_seri,&      !jyg
+!!                    upwd,dnwd,d_tr_cv)                                      !jyg
+           CALL cvltr_noscav(it,pdtphys, da, phi,mp,wght_cvfd,paprs,pplay, &  !jyg
+                    tr_seri,upwd,dnwd,d_tr_cv)                                !jyg
         endif
         END IF
Index: /LMDZ5/branches/testing/libf/phylmd/radlwsw_aero.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/radlwsw_aero.F90	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/radlwsw_aero.F90	(revision 2056)
@@ -0,0 +1,875 @@
+!
+! $Id$
+!
+SUBROUTINE radlwsw_aero( &
+   dist, rmu0, fract, &
+   paprs, pplay,tsol,alb1, alb2,&
+   t,q,wo,&
+   cldfra, cldemi, cldtaupd,&
+   ok_ade, ok_aie,&
+   tau_aero, piz_aero, cg_aero,&
+   cldtaupi, new_aod, &
+   heat,heat0,cool,cool0,radsol,albpla,&
+   topsw,toplw,solsw,sollw,&
+   sollwdown,&
+   topsw0,toplw0,solsw0,sollw0,&
+   lwdn0, lwdn, lwup0, lwup,&
+   swdn0, swdn, swup0, swup,&
+   topswad_aero, solswad_aero,&
+   topswai_aero, solswai_aero, &
+   topswad0_aero, solswad0_aero,&
+   topsw_aero, topsw0_aero,&
+   solsw_aero, solsw0_aero,qsat,flwc,fiwc)
+
+
+
+  USE DIMPHY
+  USE comgeomphy
+  USE write_field_phy
+!    modules necessaires au rayonnement 
+!    -----------------------------------------
+! USE YOMCST   , ONLY : RG       ,RD       ,RTT      ,RPI
+! USE YOERAD   , ONLY : NSW      ,LRRTM    ,LINHOM   , LCCNL,LCCNO,
+! USE YOERAD   , ONLY : NSW      ,LRRTM    ,LCCNL    ,LCCNO ,&
+! NSW mis dans .def MPL 20140211
+#ifdef CPP_RRTM
+!  USE YOERAD   , ONLY : LRRTM    ,LCCNL    ,LCCNO ,&
+!      NRADIP   , NRADLP , NICEOPT, NLIQOPT ,RCCNLND  , RCCNSEA
+!  USE YOELW    , ONLY : NSIL     ,NTRA     ,NUA      ,TSTAND   ,XP
+!  USE YOESW    , ONLY : RYFWCA   ,RYFWCB   ,RYFWCC   ,RYFWCD,&   
+!      RYFWCE   ,RYFWCF   ,REBCUA   ,REBCUB   ,REBCUC,&   
+!      REBCUD   ,REBCUE   ,REBCUF   ,REBCUI   ,REBCUJ,&  
+!      REBCUG   ,REBCUH   ,RHSAVI   ,RFULIO   ,RFLAA0,&  
+!      RFLAA1   ,RFLBB0   ,RFLBB1   ,RFLBB2   ,RFLBB3,&  
+!      RFLCC0   ,RFLCC1   ,RFLCC2   ,RFLCC3   ,RFLDD0,&  
+!      RFLDD1   ,RFLDD2   ,RFLDD3   ,RFUETA   ,RASWCA,& 
+!      RASWCB   ,RASWCC   ,RASWCD   ,RASWCE   ,RASWCF
+!&    RASWCB   ,RASWCC   ,RASWCD   ,RASWCE   ,RASWCF, RLINLI
+!  USE YOERDU   , ONLY : NUAER  ,NTRAER ,REPLOG ,REPSC  ,REPSCW ,DIFF
+!  USE YOETHF   , ONLY : RTICE
+!  USE YOERRTWN , ONLY : DELWAVE   ,TOTPLNK      
+  USE YOMPHY3  , ONLY : RII0
+#endif
+      
+  IMPLICIT NONE
+
+  !======================================================================
+  ! Auteur(s): Z.X. Li (LMD/CNRS) date: 19960719
+  ! Objet: interface entre le modele et les rayonnements
+  ! Arguments:
+  ! dist-----input-R- distance astronomique terre-soleil
+  ! rmu0-----input-R- cosinus de l'angle zenithal
+  ! fract----input-R- duree d'ensoleillement normalisee
+  ! co2_ppm--input-R- concentration du gaz carbonique (en ppm)
+  ! solaire--input-R- constante solaire (W/m**2)
+  ! paprs----input-R- pression a inter-couche (Pa)
+  ! pplay----input-R- pression au milieu de couche (Pa)
+  ! tsol-----input-R- temperature du sol (en K)
+  ! alb1-----input-R- albedo du sol(entre 0 et 1) dans l'interval visible
+  ! alb2-----input-R- albedo du sol(entre 0 et 1) dans l'interval proche infra-rouge
+  ! t--------input-R- temperature (K)
+  ! q--------input-R- vapeur d'eau (en kg/kg)
+  ! wo-------input-R- contenu en ozone (en kg/kg) correction MPL 100505
+  ! cldfra---input-R- fraction nuageuse (entre 0 et 1)
+  ! cldtaupd---input-R- epaisseur optique des nuages dans le visible (present-day value)
+  ! cldemi---input-R- emissivite des nuages dans l'IR (entre 0 et 1)
+  ! ok_ade---input-L- apply the Aerosol Direct Effect or not?
+  ! ok_aie---input-L- apply the Aerosol Indirect Effect or not?
+  ! tau_ae, piz_ae, cg_ae-input-R- aerosol optical properties (calculated in aeropt.F)
+  ! cldtaupi-input-R- epaisseur optique des nuages dans le visible
+  !                   calculated for pre-industrial (pi) aerosol concentrations, i.e. with smaller
+  !                   droplet concentration, thus larger droplets, thus generally cdltaupi cldtaupd
+  !                   it is needed for the diagnostics of the aerosol indirect radiative forcing      
+  !
+  ! heat-----output-R- echauffement atmospherique (visible) (K/jour)
+  ! cool-----output-R- refroidissement dans l'IR (K/jour)
+  ! radsol---output-R- bilan radiatif net au sol (W/m**2) (+ vers le bas)
+  ! albpla---output-R- albedo planetaire (entre 0 et 1)
+  ! topsw----output-R- flux solaire net au sommet de l'atm.
+  ! toplw----output-R- ray. IR montant au sommet de l'atmosphere
+  ! solsw----output-R- flux solaire net a la surface
+  ! sollw----output-R- ray. IR montant a la surface
+  ! solswad---output-R- ray. solaire net absorbe a la surface (aerosol dir)
+  ! topswad---output-R- ray. solaire absorbe au sommet de l'atm. (aerosol dir)
+  ! solswai---output-R- ray. solaire net absorbe a la surface (aerosol ind)
+  ! topswai---output-R- ray. solaire absorbe au sommet de l'atm. (aerosol ind)
+  !
+  ! ATTENTION: swai and swad have to be interpreted in the following manner:
+  ! ---------
+  ! ok_ade=F & ok_aie=F -both are zero
+  ! ok_ade=T & ok_aie=F -aerosol direct forcing is F_{AD} = topsw-topswad
+  !                        indirect is zero
+  ! ok_ade=F & ok_aie=T -aerosol indirect forcing is F_{AI} = topsw-topswai
+  !                        direct is zero
+  ! ok_ade=T & ok_aie=T -aerosol indirect forcing is F_{AI} = topsw-topswai
+  !                        aerosol direct forcing is F_{AD} = topswai-topswad
+  !
+  
+  !======================================================================
+  
+  ! ====================================================================
+  ! Adapte au modele de chimie INCA par Celine Deandreis & Anne Cozic -- 2009
+  ! 1 = ZERO    
+  ! 2 = AER total    
+  ! 3 = NAT    
+  ! 4 = BC    
+  ! 5 = SO4    
+  ! 6 = POM    
+  ! 7 = DUST    
+  ! 8 = SS    
+  ! 9 = NO3    
+  ! 
+  ! ====================================================================
+  include "YOETHF.h"
+  include "YOMCST.h"
+  include "clesphys.h" 
+
+! Input arguments
+! REAL,    INTENT(in)  :: solaire
+  REAL,    INTENT(in)  :: dist
+  REAL,    INTENT(in)  :: rmu0(KLON), fract(KLON)
+  REAL,    INTENT(in)  :: paprs(KLON,KLEV+1), pplay(KLON,KLEV)
+  REAL,    INTENT(in)  :: alb1(KLON), alb2(KLON),tsol(KLON)
+  REAL,    INTENT(in)  :: t(KLON,KLEV), q(KLON,KLEV), wo(KLON,KLEV)
+  LOGICAL, INTENT(in)  :: ok_ade, ok_aie                                 ! switches whether to use aerosol direct (indirect) effects or not
+  REAL,    INTENT(in)  :: cldfra(KLON,KLEV), cldemi(KLON,KLEV), cldtaupd(KLON,KLEV)
+  REAL,    INTENT(in)  :: tau_aero(KLON,KLEV,9,2)                        ! aerosol optical properties (see aeropt.F)
+  REAL,    INTENT(in)  :: piz_aero(KLON,KLEV,9,2)                        ! aerosol optical properties (see aeropt.F)
+  REAL,    INTENT(in)  :: cg_aero(KLON,KLEV,9,2)                         ! aerosol optical properties (see aeropt.F)
+  REAL,    INTENT(in)  :: cldtaupi(KLON,KLEV)                            ! cloud optical thickness for pre-industrial aerosol concentrations
+!MPL input supplementaires pour RECMWFL
+! flwc, fiwc = Liquid Water Content & Ice Water Content (kg/kg)
+  REAL*8  GEMU(klon)
+  REAL*8  qsat(klon,klev),flwc(klon,klev),fiwc(klon,klev)
+!MPL input RECMWFL: 
+!Tableaux aux niveaux inverses pour respecter convention Arpege
+  REAL*8  paprs_i(klon,klev+1)
+  REAL*8  pplay_i(klon,klev)
+  REAL*8  cldfra_i(klon,klev)
+  REAL*8  POZON_i(kdlon,kflev)
+!!!!! Modif MPL 6.01.09 avec RRTM, on passe de 5 a 6      
+  REAL*8  PAER_i(kdlon,kflev,6)
+  REAL*8  PDP_i(klon,klev)
+  REAL*8  t_i(klon,klev),q_i(klon,klev),qsat_i(klon,klev)
+  REAL*8  flwc_i(klon,klev),fiwc_i(klon,klev)
+! new_aod: flag pour retrouver les resultats exacts de l'AR4 dans le cas ou l'on ne travaille qu'avec les sulfates
+  LOGICAL, INTENT(in)  :: new_aod 
+  LOGICAL lldebug
+
+! Output arguments
+  REAL,    INTENT(out) :: heat(KLON,KLEV), cool(KLON,KLEV)
+  REAL,    INTENT(out) :: heat0(KLON,KLEV), cool0(KLON,KLEV)
+  REAL,    INTENT(out) :: radsol(KLON), topsw(KLON), toplw(KLON)
+  REAL,    INTENT(out) :: solsw(KLON), sollw(KLON), albpla(KLON)
+  REAL,    INTENT(out) :: topsw0(KLON), toplw0(KLON), solsw0(KLON), sollw0(KLON)
+  REAL,    INTENT(out) :: sollwdown(KLON)
+  REAL,    INTENT(out) :: swdn(KLON,kflev+1),swdn0(KLON,kflev+1)
+  REAL,    INTENT(out) :: swup(KLON,kflev+1),swup0(KLON,kflev+1)
+  REAL,    INTENT(out) :: lwdn(KLON,kflev+1),lwdn0(KLON,kflev+1)
+  REAL,    INTENT(out) :: lwup(KLON,kflev+1),lwup0(KLON,kflev+1)
+  REAL,    INTENT(out) :: topswad_aero(KLON), solswad_aero(KLON)         ! output: aerosol direct forcing at TOA and surface
+  REAL,    INTENT(out) :: topswai_aero(KLON), solswai_aero(KLON)         ! output: aerosol indirect forcing atTOA and surface
+  REAL, DIMENSION(klon), INTENT(out)    :: topswad0_aero 
+  REAL, DIMENSION(klon), INTENT(out)    :: solswad0_aero
+  REAL, DIMENSION(kdlon,9), INTENT(out) :: topsw_aero
+  REAL, DIMENSION(kdlon,9), INTENT(out) :: topsw0_aero
+  REAL, DIMENSION(kdlon,9), INTENT(out) :: solsw_aero
+  REAL, DIMENSION(kdlon,9), INTENT(out) :: solsw0_aero
+! --------- output RECMWFL
+!  ZEMTD (KPROMA,KLEV+1)         ; TOTAL DOWNWARD LONGWAVE EMISSIVITY
+!  ZEMTU (KPROMA,KLEV+1)         ; TOTAL UPWARD   LONGWAVE EMISSIVITY
+!  ZTRSO (KPROMA,KLEV+1)         ; TOTAL SHORTWAVE TRANSMISSIVITY
+!  ZTH   (KPROMA,KLEV+1)         ; HALF LEVEL TEMPERATURE
+!  ZCTRSO(KPROMA,2)              ; CLEAR-SKY SHORTWAVE TRANSMISSIVITY
+!  ZCEMTR(KPROMA,2)              ; CLEAR-SKY NET LONGWAVE EMISSIVITY
+!  ZTRSOD(KPROMA)                ; TOTAL-SKY SURFACE SW TRANSMISSITY
+!  ZLWFC (KPROMA,2)              ; CLEAR-SKY LONGWAVE FLUXES
+!  ZLWFT (KPROMA,KLEV+1)         ; TOTAL-SKY LONGWAVE FLUXES
+!  ZLWFT0(KPROMA,KLEV+1)         ; CLEAR-SKY LONGWAVE FLUXES      ! added by MPL 090109
+!  ZSWFC (KPROMA,2)              ; CLEAR-SKY SHORTWAVE FLUXES
+!  ZSWFT (KPROMA,KLEV+1)         ; TOTAL-SKY SHORTWAVE FLUXES
+!  ZSWFT0(KPROMA,KLEV+1)         ; CLEAR-SKY SHORTWAVE FLUXES     ! added by MPL 090109
+!  ZFLUX (KLON,2,KLEV+1)         ; TOTAL LW FLUXES  1=up, 2=DWN   ! added by MPL 080411
+!  ZFLUC (KLON,2,KLEV+1)         ; CLEAR SKY LW FLUXES            ! added by MPL 080411
+!  ZFSDWN(klon,KLEV+1)           ; TOTAL SW  DWN FLUXES           ! added by MPL 080411
+!  ZFCDWN(klon,KLEV+1)           ; CLEAR SKY SW  DWN FLUXES       ! added by MPL 080411
+!  ZFSUP (klon,KLEV+1)           ; TOTAL SW  UP  FLUXES           ! added by MPL 080411
+!  ZFCUP (klon,KLEV+1)           ; CLEAR SKY SW  UP  FLUXES       ! added by MPL 080411
+!MPL output RECMWFL:
+  REAL*8  ZEMTD (klon,klev+1),ZEMTD_i (klon,klev+1)       
+  REAL*8  ZEMTU (klon,klev+1),ZEMTU_i (klon,klev+1)      
+  REAL*8  ZTRSO (klon,klev+1),ZTRSO_i (klon,klev+1)    
+  REAL*8  ZTH   (klon,klev+1),ZTH_i   (klon,klev+1)   
+  REAL*8  ZCTRSO(klon,2)       
+  REAL*8  ZCEMTR(klon,2)     
+  REAL*8  ZTRSOD(klon)        
+  REAL*8  ZLWFC (klon,2)      
+  REAL*8  ZLWFT (klon,klev+1),ZLWFT_i (klon,klev+1)    
+  REAL*8  ZSWFC (klon,2)      
+  REAL*8  ZSWFT (klon,klev+1),ZSWFT_i (klon,klev+1)
+  REAL*8  ZSWFT0(klon,klev+1),ZLWFT0 (klon,klev+1)
+  REAL*8  PPIZA_DST(klon,klev,NSW)
+  REAL*8  PCGA_DST(klon,klev,NSW)
+  REAL*8  PTAUREL_DST(klon,klev,NSW)
+  REAL*8  PSFSWDIR(klon,NSW)
+  REAL*8  PSFSWDIF(klon,NSW)
+  REAL*8  PFSDNN(klon)
+  REAL*8  PFSDNV(klon)
+!MPL On ne redefinit pas les tableaux ZFLUX,ZFLUC,
+!MPL ZFSDWN,ZFCDWN,ZFSUP,ZFCUP car ils existent deja
+!MPL sous les noms de ZFLDN,ZFLDN0,ZFLUP,ZFLUP0,
+!MPL ZFSDN,ZFSDN0,ZFSUP,ZFSUP0
+  REAL*8  ZFLUX_i (klon,2,klev+1)
+  REAL*8  ZFLUC_i (klon,2,klev+1)
+  REAL*8  ZFSDWN_i (klon,klev+1)
+  REAL*8  ZFCDWN_i (klon,klev+1)
+  REAL*8  ZFSUP_i (klon,klev+1)
+  REAL*8  ZFCUP_i (klon,klev+1)
+
+! Local variables
+  REAL*8 ZFSUP(KDLON,KFLEV+1)
+  REAL*8 ZFSDN(KDLON,KFLEV+1)
+  REAL*8 ZFSUP0(KDLON,KFLEV+1)
+  REAL*8 ZFSDN0(KDLON,KFLEV+1)
+  REAL*8 ZFLUP(KDLON,KFLEV+1)
+  REAL*8 ZFLDN(KDLON,KFLEV+1)
+  REAL*8 ZFLUP0(KDLON,KFLEV+1)
+  REAL*8 ZFLDN0(KDLON,KFLEV+1)
+  REAL*8 zx_alpha1, zx_alpha2
+  INTEGER k, kk, i, j, iof, nb_gr
+  INTEGER ist,iend,ktdia,kmode
+  INTEGER , SAVE :: iprint=0
+  REAL*8 PSCT
+  REAL*8 PALBD(kdlon,2), PALBP(kdlon,2)
+  REAL*8 PALBD_NEW(kdlon,NSW), PALBP_NEW(kdlon,NSW)
+  REAL*8 PEMIS(kdlon), PDT0(kdlon), PVIEW(kdlon)
+  REAL*8 PPSOL(kdlon), PDP(kdlon,KLEV)
+  REAL*8 PTL(kdlon,kflev+1), PPMB(kdlon,kflev+1)
+  REAL*8 PTAVE(kdlon,kflev)
+  REAL*8 PWV(kdlon,kflev), PQS(kdlon,kflev), POZON(kdlon,kflev)
+!!!!! Modif MPL 6.01.09 avec RRTM, on passe de 5 a 6 
+  REAL*8 PAER(kdlon,kflev,6)
+  REAL*8 PCLDLD(kdlon,kflev)
+  REAL*8 PCLDLU(kdlon,kflev)
+  REAL*8 PCLDSW(kdlon,kflev)
+  REAL*8 PTAU(kdlon,2,kflev)
+  REAL*8 POMEGA(kdlon,2,kflev)
+  REAL*8 PCG(kdlon,2,kflev)
+  REAL*8 zfract(kdlon), zrmu0(kdlon), zdist
+  REAL*8 zheat(kdlon,kflev), zcool(kdlon,kflev)
+  REAL*8 zheat0(kdlon,kflev), zcool0(kdlon,kflev)
+  REAL*8 ztopsw(kdlon), ztoplw(kdlon)
+  REAL*8 zsolsw(kdlon), zsollw(kdlon), zalbpla(kdlon)
+  REAL*8 zsollwdown(kdlon)
+  REAL*8 ztopsw0(kdlon), ztoplw0(kdlon)
+  REAL*8 zsolsw0(kdlon), zsollw0(kdlon)
+  REAL*8 zznormcp
+  REAL*8 tauaero(kdlon,kflev,9,2)                     ! aer opt properties
+  REAL*8 pizaero(kdlon,kflev,9,2)
+  REAL*8 cgaero(kdlon,kflev,9,2)
+  REAL*8 PTAUA(kdlon,2,kflev)                         ! present-day value of cloud opt thickness (PTAU is pre-industrial value), local use
+  REAL*8 POMEGAA(kdlon,2,kflev)                       ! dito for single scatt albedo
+  REAL*8 ztopswadaero(kdlon), zsolswadaero(kdlon)     ! Aerosol direct forcing at TOAand surface
+  REAL*8 ztopswad0aero(kdlon), zsolswad0aero(kdlon)   ! Aerosol direct forcing at TOAand surface
+  REAL*8 ztopswaiaero(kdlon), zsolswaiaero(kdlon)     ! dito, indirect
+  REAL*8 ztopsw_aero(kdlon,9), ztopsw0_aero(kdlon,9)
+  REAL*8 zsolsw_aero(kdlon,9), zsolsw0_aero(kdlon,9)
+
+  CHARACTER (LEN=20) :: modname
+  CHARACTER (LEN=80) :: abort_message
+
+  ! initialisation
+  ist=1
+  iend=klon
+  ktdia=1
+  kmode=ist  
+  lldebug=.FALSE.
+  ! initialisation
+  tauaero(:,:,:,:)=0.
+  pizaero(:,:,:,:)=0.
+  cgaero(:,:,:,:)=0.
+  
+  !
+  !-------------------------------------------
+  nb_gr = KLON / kdlon
+  IF (nb_gr*kdlon .NE. KLON) THEN
+      PRINT*, "kdlon mauvais:", KLON, kdlon, nb_gr
+      CALL abort
+  ENDIF
+  IF (kflev .NE. KLEV) THEN
+      PRINT*, "kflev differe de KLEV, kflev, KLEV"
+      CALL abort
+  ENDIF
+  !-------------------------------------------
+!     print *,'Entree de radlwsw, iflag_rrtm tsol=',iflag_rrtm,tsol
+  IF (iprint>10) THEN
+  DO k = 1, KLEV
+    DO i = 1, KLON
+!        print *,'En entree de radlwsw: k tsol temp',k,tsol,t(1,k)
+      heat(i,k)=0.
+      cool(i,k)=0.
+      heat0(i,k)=0.
+      cool0(i,k)=0.
+    ENDDO
+  ENDDO
+  ENDIF
+  !
+  zdist = dist
+  !
+  PSCT = solaire/zdist/zdist
+  DO j = 1, nb_gr
+    iof = kdlon*(j-1)
+    DO i = 1, kdlon
+      zfract(i) = fract(iof+i)
+      zrmu0(i) = rmu0(iof+i)
+      PALBD(i,1) = alb1(iof+i)
+!     PALBD(i,2) = alb1(iof+i)
+      PALBD(i,2) = alb2(iof+i)
+!
+      PALBD_NEW(i,1) = alb1(iof+i)
+      DO kk=2,NSW
+        PALBD_NEW(i,kk) = alb2(iof+i)
+      ENDDO
+!     PALBD_NEW(i,2) = alb2(iof+i)
+!     PALBD_NEW(i,3) = alb2(iof+i)
+!     PALBD_NEW(i,4) = alb2(iof+i)
+!     PALBD_NEW(i,5) = alb2(iof+i)
+!     PALBD_NEW(i,6) = alb2(iof+i)
+!
+      PALBP(i,1) = alb1(iof+i)
+!     PALBP(i,2) = alb1(iof+i)
+      PALBP(i,2) = alb2(iof+i)
+!
+      PALBP_NEW(i,1) = alb1(iof+i)
+      DO kk=2,NSW
+        PALBP_NEW(i,kk) = alb2(iof+i)
+      ENDDO
+!     PALBP_NEW(i,2) = alb2(iof+i)
+!     PALBP_NEW(i,3) = alb2(iof+i)
+!     PALBP_NEW(i,4) = alb2(iof+i)
+!     PALBP_NEW(i,5) = alb2(iof+i)
+!     PALBP_NEW(i,6) = alb2(iof+i)
+      PEMIS(i) = 1.0 
+      PVIEW(i) = 1.66
+      PPSOL(i) = paprs(iof+i,1)
+      zx_alpha1 = (paprs(iof+i,1)-pplay(iof+i,2))/(pplay(iof+i,1)-pplay(iof+i,2))
+      zx_alpha2 = 1.0 - zx_alpha1
+      PTL(i,1) = t(iof+i,1) * zx_alpha1 + t(iof+i,2) * zx_alpha2
+      PTL(i,KLEV+1) = t(iof+i,KLEV)
+      PDT0(i) = tsol(iof+i) - PTL(i,1)
+    ENDDO
+    DO k = 2, kflev
+      DO i = 1, kdlon
+        PTL(i,k) = (t(iof+i,k)+t(iof+i,k-1))*0.5
+      ENDDO
+    ENDDO
+    DO k = 1, kflev
+      DO i = 1, kdlon
+        PDP(i,k) = paprs(iof+i,k)-paprs(iof+i,k+1)
+        PTAVE(i,k) = t(iof+i,k)
+        PWV(i,k) = MAX (q(iof+i,k), 1.0e-12)
+        PQS(i,k) = PWV(i,k)
+        ! wo:    cm.atm (epaisseur en cm dans la situation standard)
+        ! POZON: kg/kg
+        POZON(i,k) = MAX(wo(iof+i,k),1.0e-12)*RG/46.6968 &
+           /(paprs(iof+i,k)-paprs(iof+i,k+1))&
+           *(paprs(iof+i,1)/101325.0)
+        PCLDLD(i,k) = cldfra(iof+i,k)*cldemi(iof+i,k)
+        PCLDLU(i,k) = cldfra(iof+i,k)*cldemi(iof+i,k)
+        PCLDSW(i,k) = cldfra(iof+i,k)
+        PTAU(i,1,k) = MAX(cldtaupi(iof+i,k), 1.0e-05)! 1e-12 serait instable
+        PTAU(i,2,k) = MAX(cldtaupi(iof+i,k), 1.0e-05)! pour 32-bit machines
+        POMEGA(i,1,k) = 0.9999 - 5.0e-04 * EXP(-0.5 * PTAU(i,1,k))
+        POMEGA(i,2,k) = 0.9988 - 2.5e-03 * EXP(-0.05 * PTAU(i,2,k))
+        PCG(i,1,k) = 0.865
+        PCG(i,2,k) = 0.910
+        !-
+        ! Introduced for aerosol indirect forcings.
+        ! The following values use the cloud optical thickness calculated from
+        ! present-day aerosol concentrations whereas the quantities without the
+        ! "A" at the end are for pre-industial (natural-only) aerosol concentrations
+        !
+        PTAUA(i,1,k) = MAX(cldtaupd(iof+i,k), 1.0e-05)! 1e-12 serait instable
+        PTAUA(i,2,k) = MAX(cldtaupd(iof+i,k), 1.0e-05)! pour 32-bit machines
+        POMEGAA(i,1,k) = 0.9999 - 5.0e-04 * EXP(-0.5 * PTAUA(i,1,k))
+        POMEGAA(i,2,k) = 0.9988 - 2.5e-03 * EXP(-0.05 * PTAUA(i,2,k))
+      ENDDO
+    ENDDO
+    !
+    DO k = 1, kflev+1
+      DO i = 1, kdlon
+        PPMB(i,k) = paprs(iof+i,k)/100.0
+      ENDDO
+    ENDDO
+    !
+!!!!! Modif MPL 6.01.09 avec RRTM, on passe de 5 a 6  
+    DO kk = 1, 6
+      DO k = 1, kflev
+        DO i = 1, kdlon
+          PAER(i,k,kk) = 1.0E-15
+        ENDDO
+      ENDDO
+    ENDDO
+    DO k = 1, kflev
+      DO i = 1, kdlon
+        tauaero(i,k,:,1)=tau_aero(iof+i,k,:,1)
+        pizaero(i,k,:,1)=piz_aero(iof+i,k,:,1)
+        cgaero(i,k,:,1) =cg_aero(iof+i,k,:,1)
+        tauaero(i,k,:,2)=tau_aero(iof+i,k,:,2)
+        pizaero(i,k,:,2)=piz_aero(iof+i,k,:,2)
+        cgaero(i,k,:,2) =cg_aero(iof+i,k,:,2)
+      ENDDO
+    ENDDO
+!
+!======================================================================
+!===== si iflag_rrtm=0 ================================================
+!IM ctes ds clesphys.h   CALL LW(RCO2,RCH4,RN2O,RCFC11,RCFC12,
+!IM ctes ds clesphys.h   CALL SW(PSCT, RCO2, zrmu0, zfract,
+!      
+      IF (iflag_rrtm.eq.0) then
+
+!----- Mise a zero des tableaux output du rayonnement LW-AR4 ----------              
+      DO k = 1, kflev+1
+      DO i = 1, kdlon
+      ZFLUP(i,k)=0.
+      ZFLDN(i,k)=0.
+      ZFLUP0(i,k)=0.
+      ZFLDN0(i,k)=0.
+      ENDDO
+      ENDDO
+      DO k = 1, kflev
+      DO i = 1, kdlon
+      zcool(i,k)=0.
+      zcool0(i,k)=0.
+      ENDDO
+      ENDDO
+      DO i = 1, kdlon
+      ztoplw(i)=0.
+      zsollw(i)=0.
+      ztoplw0(i)=0.
+      zsollw0(i)=0.
+      zsollwdown(i)=0.
+      ENDDO
+!
+    CALL LW_LMDAR4(&
+       PPMB, PDP,&
+       PPSOL,PDT0,PEMIS,&
+       PTL, PTAVE, PWV, POZON, PAER,&
+       PCLDLD,PCLDLU,&
+       PVIEW,&
+       zcool, zcool0,&
+       ztoplw,zsollw,ztoplw0,zsollw0,&
+       zsollwdown,&
+       ZFLUP, ZFLDN, ZFLUP0,ZFLDN0)
+
+!----- Mise a zero des tableaux output du rayonnement SW-AR4 ----------              
+      DO k = 1, kflev+1
+      DO i = 1, kdlon
+      ZFSUP(i,k)=0.
+      ZFSDN(i,k)=0.
+      ZFSUP0(i,k)=0.
+      ZFSDN0(i,k)=0.
+      ENDDO
+      ENDDO
+      DO k = 1, kflev
+      DO i = 1, kdlon
+      zheat(i,k)=0.
+      zheat0(i,k)=0.
+      ENDDO
+      ENDDO
+      DO i = 1, kdlon
+      zalbpla(i)=0.
+      ztopsw(i)=0.
+      zsolsw(i)=0.
+      ztopsw0(i)=0.
+      zsolsw0(i)=0.
+      ztopswadaero(i)=0.
+      zsolswadaero(i)=0.
+      ztopswaiaero(i)=0.
+      zsolswaiaero(i)=0.
+      ENDDO
+    IF (.NOT. new_aod) THEN 
+       ! use old version
+        CALL SW_LMDAR4(PSCT, zrmu0, zfract,&
+           PPMB, PDP, &
+           PPSOL, PALBD, PALBP,&
+           PTAVE, PWV, PQS, POZON, PAER,&
+           PCLDSW, PTAU, POMEGA, PCG,&
+           zheat, zheat0,&
+           zalbpla,ztopsw,zsolsw,ztopsw0,zsolsw0,&
+           ZFSUP,ZFSDN,ZFSUP0,ZFSDN0,&
+           tau_aero(:,:,5,:), piz_aero(:,:,5,:), cg_aero(:,:,5,:),& 
+           PTAUA, POMEGAA,&
+           ztopswadaero,zsolswadaero,&
+           ztopswaiaero,zsolswaiaero,& 
+           ok_ade, ok_aie) 
+    ELSE
+
+        CALL SW_AERO(PSCT, zrmu0, zfract,&
+           PPMB, PDP,&
+           PPSOL, PALBD, PALBP,&
+           PTAVE, PWV, PQS, POZON, PAER,&
+           PCLDSW, PTAU, POMEGA, PCG,&
+           zheat, zheat0,&
+           zalbpla,ztopsw,zsolsw,ztopsw0,zsolsw0,&
+           ZFSUP,ZFSDN,ZFSUP0,ZFSDN0,&
+           tauaero, pizaero, cgaero, &
+           PTAUA, POMEGAA,&
+           ztopswadaero,zsolswadaero,&
+           ztopswad0aero,zsolswad0aero,&
+           ztopswaiaero,zsolswaiaero, & 
+           ztopsw_aero,ztopsw0_aero,&
+           zsolsw_aero,zsolsw0_aero,&
+           ok_ade, ok_aie) 
+    
+    ENDIF
+
+!===== si iflag_rrtm=1, on passe dans SW via RECMWFL ===============
+!----- Mise a zero des tableaux output de RECMWF -------------------              
+
+      else
+#ifdef CPP_RRTM
+      DO k = 1, kflev+1
+      DO i = 1, kdlon
+      ZEMTD_i(i,k)=0.
+      ZEMTU_i(i,k)=0.
+      ZTRSO_i(i,k)=0.
+      ZTH_i(i,k)=0.
+      ZLWFT_i(i,k)=0.
+      ZSWFT_i(i,k)=0.
+      ZFLUX_i(i,1,k)=0.
+      ZFLUX_i(i,2,k)=0.
+      ZFLUC_i(i,1,k)=0.
+      ZFLUC_i(i,2,k)=0.
+      ZFSDWN_i(i,k)=0.
+      ZFCDWN_i(i,k)=0.
+      ZFSUP_i(i,k)=0.
+      ZFCUP_i(i,k)=0.
+      ENDDO
+      ENDDO
+!      
+      DO k = 1, kflev
+      DO i = 1, kdlon
+      DO kk = 1, NSW
+      PPIZA_DST(i,k,kk)=0.
+      PCGA_DST(i,k,kk)=0.
+      PTAUREL_DST(i,k,kk)=0.
+      ENDDO
+      ENDDO
+      ENDDO
+!      
+      DO i = 1, kdlon
+      ZCTRSO(i,1)=0.
+      ZCTRSO(i,2)=0.
+      ZCEMTR(i,1)=0.
+      ZCEMTR(i,2)=0.
+      ZTRSOD(i)=0.
+      ZLWFC(i,1)=0.
+      ZLWFC(i,2)=0.
+      ZSWFC(i,1)=0.
+      ZSWFC(i,2)=0.
+      PFSDNN(i)=0.
+      PFSDNV(i)=0.
+      DO kk = 1, NSW
+      PSFSWDIR(i,kk)=0.
+      PSFSWDIF(i,kk)=0.
+      ENDDO
+      ENDDO
+!----- Fin des mises a zero des tableaux output de RECMWF -------------------              
+         GEMU(1:klon)=sin(rlatd(1:klon))
+! On met les donnees dans l'ordre des niveaux arpege
+         paprs_i(:,1)=paprs(:,klev+1)
+         DO k=1,klev
+            paprs_i(1:klon,k+1) =paprs(1:klon,klev+1-k)
+            pplay_i(1:klon,k)   =pplay(1:klon,klev+1-k)
+            cldfra_i(1:klon,k)  =cldfra(1:klon,klev+1-k)
+            PDP_i(1:klon,k)     =PDP(1:klon,klev+1-k)
+            t_i(1:klon,k)       =t(1:klon,klev+1-k)
+            q_i(1:klon,k)       =q(1:klon,klev+1-k)
+            qsat_i(1:klon,k)    =qsat(1:klon,klev+1-k)
+            flwc_i(1:klon,k)    =flwc(1:klon,klev+1-k)
+            fiwc_i(1:klon,k)    =fiwc(1:klon,klev+1-k)
+         ENDDO
+         DO k=1,kflev
+            POZON_i(1:klon,k)=POZON(1:klon,kflev+1-k)
+!           print *,'Juste avant RECMWFL: k tsol temp',k,tsol,t(1,k)
+!!!!! Modif MPL 6.01.09 avec RRTM, on passe de 5 a 6      
+            DO i=1,6
+            PAER_i(1:klon,k,i)=PAER(1:klon,kflev+1-k,i)
+            ENDDO
+         ENDDO
+!        print *,'RADLWSW: avant RECMWFL, RI0,rmu0 =',solaire,rmu0
+
+!  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+! La version ARPEGE1D utilise differentes valeurs de la constante
+! solaire suivant le rayonnement utilise.
+! A controler ...
+! SOLAR FLUX AT THE TOP (/YOMPHY3/)
+! introduce season correction
+!--------------------------------------
+! RII0 = RIP0
+! IF(LRAYFM)
+! RII0 = RIP0M   ! =rip0m if Morcrette non-each time step call.
+! IF(LRAYFM15)
+! RII0 = RIP0M15 ! =rip0m if Morcrette non-each time step call.
+         RII0=solaire
+!  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+! Ancien appel a RECMWF (celui du cy25)
+!        CALL RECMWF (ist , iend, klon , ktdia , klev   , kmode ,
+!    s   PALBD    , PALBP   , paprs_i , pplay_i , RCO2   , cldfra_i,
+!    s   POZON_i  , PAER_i  , PDP_i   , PEMIS   , GEMU   , rmu0,
+!    s    q_i     , qsat_i  , fiwc_i  , flwc_i  , zmasq  , t_i  ,tsol,
+!    s   ZEMTD_i  , ZEMTU_i , ZTRSO_i ,
+!    s   ZTH_i    , ZCTRSO  , ZCEMTR  , ZTRSOD  ,
+!    s   ZLWFC    , ZLWFT_i , ZSWFC   , ZSWFT_i ,
+!    s   ZFLUX_i  , ZFLUC_i , ZFSDWN_i, ZFSUP_i , ZFCDWN_i,ZFCUP_i)
+!    s   'RECMWF ')
+!
+      IF(lldebug) then
+        call writefield_phy('paprs_i',paprs_i,klev+1)
+        call writefield_phy('pplay_i',pplay_i,klev)
+        call writefield_phy('cldfra_i',cldfra_i,klev)
+        call writefield_phy('pozon_i',POZON_i,klev)
+        call writefield_phy('paer_i',PAER_i,klev)
+        call writefield_phy('pdp_i',PDP_i,klev)
+        call writefield_phy('q_i',q_i,klev)
+        call writefield_phy('qsat_i',qsat_i,klev)
+        call writefield_phy('fiwc_i',fiwc_i,klev)
+        call writefield_phy('flwc_i',flwc_i,klev)
+        call writefield_phy('t_i',t_i,klev)
+        call writefield_phy('palbd_new',PALBD_NEW,NSW)
+        call writefield_phy('palbp_new',PALBP_NEW,NSW)
+      ENDIF
+
+! Nouvel appel a RECMWF (celui du cy32t0)
+         CALL RECMWF (ist , iend, klon , ktdia  , klev   , kmode ,&
+         PALBD_NEW,PALBP_NEW, paprs_i , pplay_i , RCO2   , cldfra_i,&
+         POZON_i  , PAER_i  , PDP_i   , PEMIS   , rmu0   ,&
+          q_i     , qsat_i  , fiwc_i  , flwc_i  , zmasq  , t_i  ,tsol,&
+         ZEMTD_i  , ZEMTU_i , ZTRSO_i ,&
+         ZTH_i    , ZCTRSO  , ZCEMTR  , ZTRSOD  ,&
+         ZLWFC    , ZLWFT_i , ZSWFC   , ZSWFT_i ,&
+         PSFSWDIR , PSFSWDIF, PFSDNN  , PFSDNV  ,&
+         PPIZA_DST, PCGA_DST,PTAUREL_DST,ZFLUX_i  , ZFLUC_i ,&
+         ZFSDWN_i , ZFSUP_i , ZFCDWN_i, ZFCUP_i)
+            
+         print *,'RADLWSW: apres RECMWF'
+      IF(lldebug) THEN
+        call writefield_phy('zemtd_i',ZEMTD_i,klev+1)
+        call writefield_phy('zemtu_i',ZEMTU_i,klev+1)
+        call writefield_phy('ztrso_i',ZTRSO_i,klev+1)
+        call writefield_phy('zth_i',ZTH_i,klev+1)
+        call writefield_phy('zctrso',ZCTRSO,2)
+        call writefield_phy('zcemtr',ZCEMTR,2)
+        call writefield_phy('ztrsod',ZTRSOD,1)
+        call writefield_phy('zlwfc',ZLWFC,2)
+        call writefield_phy('zlwft_i',ZLWFT_i,klev+1)
+        call writefield_phy('zswfc',ZSWFC,2)
+        call writefield_phy('zswft_i',ZSWFT_i,klev+1)
+        call writefield_phy('psfswdir',PSFSWDIR,6)
+        call writefield_phy('psfswdif',PSFSWDIF,6)
+        call writefield_phy('pfsdnn',PFSDNN,1)
+        call writefield_phy('pfsdnv',PFSDNV,1)
+        call writefield_phy('ppiza_dst',PPIZA_DST,klev)
+        call writefield_phy('pcga_dst',PCGA_DST,klev)
+        call writefield_phy('ptaurel_dst',PTAUREL_DST,klev)
+        call writefield_phy('zflux_i',ZFLUX_i,klev+1)
+        call writefield_phy('zfluc_i',ZFLUC_i,klev+1)
+        call writefield_phy('zfsdwn_i',ZFSDWN_i,klev+1)
+        call writefield_phy('zfsup_i',ZFSUP_i,klev+1)
+        call writefield_phy('zfcdwn_i',ZFCDWN_i,klev+1)
+        call writefield_phy('zfcup_i',ZFCUP_i,klev+1)
+      ENDIF
+! --------- output RECMWFL
+!  ZEMTD        (KPROMA,KLEV+1)  ; TOTAL DOWNWARD LONGWAVE EMISSIVITY
+!  ZEMTU        (KPROMA,KLEV+1)  ; TOTAL UPWARD   LONGWAVE EMISSIVITY
+!  ZTRSO        (KPROMA,KLEV+1)  ; TOTAL SHORTWAVE TRANSMISSIVITY
+!  ZTH          (KPROMA,KLEV+1)  ; HALF LEVEL TEMPERATURE
+!  ZCTRSO       (KPROMA,2)       ; CLEAR-SKY SHORTWAVE TRANSMISSIVITY
+!  ZCEMTR       (KPROMA,2)       ; CLEAR-SKY NET LONGWAVE EMISSIVITY
+!  ZTRSOD       (KPROMA)         ; TOTAL-SKY SURFACE SW TRANSMISSITY
+!  ZLWFC        (KPROMA,2)       ; CLEAR-SKY LONGWAVE FLUXES
+!  ZLWFT        (KPROMA,KLEV+1)  ; TOTAL-SKY LONGWAVE FLUXES
+!  ZSWFC        (KPROMA,2)       ; CLEAR-SKY SHORTWAVE FLUXES
+!  ZSWFT        (KPROMA,KLEV+1)  ; TOTAL-SKY SHORTWAVE FLUXES
+!  PPIZA_DST    (KPROMA,KLEV,NSW); Single scattering albedo of dust 
+!  PCGA_DST     (KPROMA,KLEV,NSW); Assymetry factor for dust 
+!  PTAUREL_DST  (KPROMA,KLEV,NSW); Optical depth of dust relative to at 550nm
+!  PSFSWDIR     (KPROMA,NSW)     ;
+!  PSFSWDIF     (KPROMA,NSW)     ;
+!  PFSDNN       (KPROMA)         ;
+!  PFSDNV       (KPROMA)         ;
+! ---------
+! On retablit l'ordre des niveaux lmd pour les tableaux de sortie
+      DO k=0,klev
+         ZEMTD(1:klon,k+1)  = ZEMTD_i(1:klon,k+1)
+         ZEMTU(1:klon,k+1)  = ZEMTU_i(1:klon,k+1)
+         ZTRSO(1:klon,k+1)  = ZTRSO_i(1:klon,k+1)
+         ZTH(1:klon,k+1)    = ZTH_i(1:klon,k+1)
+!        ZLWFT(1:klon,k+1)  = ZLWFT_i(1:klon,klev+1-k)
+!        ZSWFT(1:klon,k+1)  = ZSWFT_i(1:klon,klev+1-k) 
+         ZFLUP(1:klon,k+1)  = ZFLUX_i(1:klon,1,k+1)
+         ZFLDN(1:klon,k+1)  = ZFLUX_i(1:klon,2,k+1)
+         ZFLUP0(1:klon,k+1) = ZFLUC_i(1:klon,1,k+1)
+         ZFLDN0(1:klon,k+1) = ZFLUC_i(1:klon,2,k+1)
+         ZFSDN(1:klon,k+1)  = ZFSDWN_i(1:klon,k+1)
+         ZFSDN0(1:klon,k+1) = ZFCDWN_i(1:klon,k+1)
+         ZFSUP (1:klon,k+1) = ZFSUP_i(1:klon,k+1)
+         ZFSUP0(1:klon,k+1) = ZFCUP_i(1:klon,k+1)
+!   Nouveau calcul car visiblement ZSWFT et ZSWFC sont nuls dans RRTM cy32 
+!   en sortie de radlsw.F90 - MPL 7.01.09
+         ZSWFT(1:klon,k+1)  = ZFSDWN_i(1:klon,k+1)-ZFSUP_i(1:klon,k+1)
+         ZSWFT0(1:klon,k+1) = ZFCDWN_i(1:klon,k+1)-ZFCUP_i(1:klon,k+1)
+!        WRITE(*,'("FSDN FSUP FCDN FCUP: ",4E12.5)') ZFSDWN_i(1:klon,k+1),&
+!        ZFSUP_i(1:klon,k+1),ZFCDWN_i(1:klon,k+1),ZFCUP_i(1:klon,k+1)
+         ZLWFT(1:klon,k+1) =-ZFLUX_i(1:klon,2,k+1)-ZFLUX_i(1:klon,1,k+1)
+         ZLWFT0(1:klon,k+1)=-ZFLUC_i(1:klon,2,k+1)-ZFLUC_i(1:klon,1,k+1)
+!        print *,'FLUX2 FLUX1 FLUC2 FLUC1',ZFLUX_i(1:klon,2,k+1),
+!    s ZFLUX_i(1:klon,1,k+1),ZFLUC_i(1:klon,2,k+1),ZFLUC_i(1:klon,1,k+1)
+      ENDDO  
+      print*,'OK1'
+! ---------
+! On renseigne les champs LMDz, pour avoir la meme chose qu'en sortie de
+! LW_LMDAR4 et SW_LMDAR4
+      DO i = 1, kdlon
+         zsolsw(i)    = ZSWFT(i,1)
+         zsolsw0(i)   = ZSWFT0(i,1)
+!        zsolsw0(i)   = ZFSDN0(i,1)     -ZFSUP0(i,1)
+         ztopsw(i)    = ZSWFT(i,klev+1)
+         ztopsw0(i)   = ZSWFT0(i,klev+1)
+!        ztopsw0(i)   = ZFSDN0(i,klev+1)-ZFSUP0(i,klev+1)
+!         
+!        zsollw(i)    = ZFLDN(i,1)      -ZFLUP(i,1)
+!        zsollw0(i)   = ZFLDN0(i,1)     -ZFLUP0(i,1)
+!        ztoplw(i)    = ZFLDN(i,klev+1) -ZFLUP(i,klev+1)
+!        ztoplw0(i)   = ZFLDN0(i,klev+1)-ZFLUP0(i,klev+1)
+         zsollw(i)    = ZLWFT(i,1)
+         zsollw0(i)   = ZLWFT0(i,1)
+         ztoplw(i)    = ZLWFT(i,klev+1)
+         ztoplw0(i)   = ZLWFT0(i,klev+1)
+!         
+         zalbpla(i)   = ZFSUP(i,klev+1)/ZFSDN(i,klev+1)
+         zsollwdown(i)= ZFLDN(i,1)
+      ENDDO
+      print*,'OK2'
+
+! extrait de SW_AR4
+!     DO k = 1, KFLEV
+!        kpl1 = k+1
+!        DO i = 1, KDLON
+!           PHEAT(i,k) = -(ZFSUP(i,kpl1)-ZFSUP(i,k)) -(ZFSDN(i,k)-ZFSDN(i,kpl1))
+!           PHEAT(i,k) = PHEAT(i,k) * RDAY*RG/RCPD / PDP(i,k)
+! ZLWFT(klon,k),ZSWFT
+
+      DO k=1,kflev
+         DO i=1,kdlon
+           zheat(i,k)=(ZSWFT(i,k+1)-ZSWFT(i,k))*RDAY*RG/RCPD/PDP(i,k)
+           zheat0(i,k)=(ZSWFT0(i,k+1)-ZSWFT0(i,k))*RDAY*RG/RCPD/PDP(i,k)
+           zcool(i,k)=(ZLWFT(i,k)-ZLWFT(i,k+1))*RDAY*RG/RCPD/PDP(i,k)
+           zcool0(i,k)=(ZLWFT0(i,k)-ZLWFT0(i,k+1))*RDAY*RG/RCPD/PDP(i,k)
+!          print *,'heat cool heat0 coOl0 '&
+!         ,zheat(i,k),zcool(i,k),zheat0(i,k),zcool0(i,k)
+         ENDDO
+      ENDDO
+#else
+
+            abort_message='You should compile with -rrtm if running with iflag_rrtm=1'
+            call abort_gcm(modname,abort_message,1)
+#endif
+      ENDIF   ! if(iflag_rrtm=0)
+         print*,'OK3'
+!======================================================================
+!  PSOLSW(i)   = ZFSDN(i,1) - ZFSUP(i,1)
+!  PSOLSW0(i)  = ZFSDN0(i,1) - ZFSUP0(i,1)
+!  PSOLSWAD(i) = ZFSDNAD(i,1) - ZFSUPAD(i,1)
+!  PSOLSWAI(i) = ZFSDNAI(i,1) - ZFSUPAI(i,1)
+!  PTOPSW(i)   = ZFSDN(i,KFLEV+1) - ZFSUP(i,KFLEV+1)
+!  PTOPSW0(i)  = ZFSDN0(i,KFLEV+1) - ZFSUP0(i,KFLEV+1)
+!  PTOPSWAD(i) = ZFSDNAD(i,KFLEV+1) - ZFSUPAD(i,KFLEV+1)
+!  PTOPSWAI(i) = ZFSDNAI(i,KFLEV+1) - ZFSUPAI(i,KFLEV+1)      
+!======================================================================
+    DO i = 1, kdlon
+      radsol(iof+i) = zsolsw(i) + zsollw(i)
+      topsw(iof+i) = ztopsw(i)
+      toplw(iof+i) = ztoplw(i)
+      solsw(iof+i) = zsolsw(i)
+      sollw(iof+i) = zsollw(i)
+      sollwdown(iof+i) = zsollwdown(i)
+      DO k = 1, kflev+1
+        lwdn0 ( iof+i,k)   = ZFLDN0 ( i,k)
+        lwdn  ( iof+i,k)   = ZFLDN  ( i,k)
+        lwup0 ( iof+i,k)   = ZFLUP0 ( i,k)
+        lwup  ( iof+i,k)   = ZFLUP  ( i,k)
+      ENDDO
+      topsw0(iof+i) = ztopsw0(i)
+      toplw0(iof+i) = ztoplw0(i)
+      solsw0(iof+i) = zsolsw0(i)
+      sollw0(iof+i) = zsollw0(i)
+      albpla(iof+i) = zalbpla(i)
+
+      DO k = 1, kflev+1
+        swdn0 ( iof+i,k)   = ZFSDN0 ( i,k)
+        swdn  ( iof+i,k)   = ZFSDN  ( i,k)
+        swup0 ( iof+i,k)   = ZFSUP0 ( i,k)
+        swup  ( iof+i,k)   = ZFSUP  ( i,k)
+      ENDDO
+    ENDDO
+         print*,'OK4'
+    !-transform the aerosol forcings, if they have
+    ! to be calculated
+    IF (ok_ade) THEN
+        DO i = 1, kdlon
+          topswad_aero(iof+i) = ztopswadaero(i)
+          topswad0_aero(iof+i) = ztopswad0aero(i)
+          solswad_aero(iof+i) = zsolswadaero(i)
+          solswad0_aero(iof+i) = zsolswad0aero(i)
+          topsw_aero(iof+i,:) = ztopsw_aero(iof+i,:)
+          topsw0_aero(iof+i,:) = ztopsw0_aero(iof+i,:)
+          solsw_aero(iof+i,:) = zsolsw_aero(iof+i,:)
+          solsw0_aero(iof+i,:) = zsolsw0_aero(iof+i,:)
+          
+        ENDDO
+    ELSE
+        DO i = 1, kdlon
+          topswad_aero(iof+i) = 0.0
+          solswad_aero(iof+i) = 0.0
+          topswad0_aero(iof+i) = 0.0
+          solswad0_aero(iof+i) = 0.0
+          topsw_aero(iof+i,:) = 0.
+          topsw0_aero(iof+i,:) =0.
+          solsw_aero(iof+i,:) = 0.
+          solsw0_aero(iof+i,:) = 0.
+        ENDDO
+    ENDIF
+    IF (ok_aie) THEN
+        DO i = 1, kdlon
+          topswai_aero(iof+i) = ztopswaiaero(i)
+          solswai_aero(iof+i) = zsolswaiaero(i)
+        ENDDO
+    ELSE
+        DO i = 1, kdlon
+          topswai_aero(iof+i) = 0.0
+          solswai_aero(iof+i) = 0.0
+        ENDDO
+    ENDIF
+         print*,'OK5'
+    DO k = 1, kflev
+      DO i = 1, kdlon
+        !        scale factor to take into account the difference between
+        !        dry air and watter vapour scpecifi! heat capacity
+        zznormcp=1.0+RVTMP2*PWV(i,k)
+        heat(iof+i,k) = zheat(i,k)/zznormcp
+        cool(iof+i,k) = zcool(i,k)/zznormcp
+        heat0(iof+i,k) = zheat0(i,k)/zznormcp
+        cool0(iof+i,k) = zcool0(i,k)/zznormcp
+      ENDDO
+    ENDDO
+         print*,'OK6'
+    !
+  ENDDO
+       print*,'OK7'
+
+
+ENDSUBROUTINE radlwsw_aero
+
+
Index: /LMDZ5/branches/testing/libf/phylmd/radlwsw_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/radlwsw_m.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/radlwsw_m.F90	(revision 2056)
@@ -1,2 +1,5 @@
+!
+! $Id$
+!
 module radlwsw_m
 
@@ -13,4 +16,5 @@
    flag_aerosol_strat,&
    tau_aero, piz_aero, cg_aero,&
+   tau_aero_rrtm, piz_aero_rrtm, cg_aero_rrtm,& ! rajoute par OB pour RRTM
    cldtaupi, new_aod, &
    qsat, flwc, fiwc, &
@@ -60,5 +64,5 @@
 !    &    RASWCB   ,RASWCC   ,RASWCD   ,RASWCE   ,RASWCF, RLINLI
       USE YOERDU   , ONLY : NUAER  ,NTRAER ,REPLOG ,REPSC  ,REPSCW ,DIFF
-      USE YOETHF   , ONLY : RTICE
+!      USE YOETHF   , ONLY : RTICE
       USE YOERRTWN , ONLY : DELWAVE   ,TOTPLNK      
       USE YOMPHY3  , ONLY : RII0
@@ -177,4 +181,9 @@
   REAL,    INTENT(in)  :: piz_aero(KLON,KLEV,9,2)                        ! aerosol optical properties (see aeropt.F)
   REAL,    INTENT(in)  :: cg_aero(KLON,KLEV,9,2)                         ! aerosol optical properties (see aeropt.F)
+!--OB
+  REAL,    INTENT(in)  :: tau_aero_rrtm(KLON,KLEV,2,NSW)                 ! aerosol optical properties RRTM
+  REAL,    INTENT(in)  :: piz_aero_rrtm(KLON,KLEV,2,NSW)                 ! aerosol optical properties RRTM
+  REAL,    INTENT(in)  :: cg_aero_rrtm(KLON,KLEV,2,NSW)                  ! aerosol optical properties RRTM
+!--OB fin
   REAL,    INTENT(in)  :: cldtaupi(KLON,KLEV)                            ! cloud optical thickness for pre-industrial aerosol concentrations
   LOGICAL, INTENT(in)  :: new_aod                                        ! flag pour retrouver les resultats exacts de l'AR4 dans le cas ou l'on ne travaille qu'avec les sulfates
@@ -273,4 +282,8 @@
       REAL(KIND=8) ref_liq_i(klon,klev) ! cloud droplet radius present-day from newmicro (inverted)
       REAL(KIND=8) ref_ice_i(klon,klev) ! ice crystal radius present-day from newmicro (inverted)
+!--OB
+      REAL(KIND=8) ref_liq_pi_i(klon,klev) ! cloud droplet radius pre-industrial from newmicro (inverted)
+      REAL(KIND=8) ref_ice_pi_i(klon,klev) ! ice crystal radius pre-industrial from newmicro (inverted)
+!--end OB
       REAL(KIND=8) paprs_i(klon,klev+1)
       REAL(KIND=8) pplay_i(klon,klev)
@@ -297,7 +310,10 @@
       REAL(KIND=8) ZSWFT (klon,klev+1),ZSWFT_i (klon,klev+1)
       REAL(KIND=8) ZFLUCDWN_i(klon,klev+1),ZFLUCUP_i(klon,klev+1)
-      REAL(KIND=8) PPIZA_DST(klon,klev,NSW)
-      REAL(KIND=8) PCGA_DST(klon,klev,NSW)
-      REAL(KIND=8) PTAUREL_DST(klon,klev,NSW)
+      REAL(KIND=8) PPIZA_TOT(klon,klev,NSW)
+      REAL(KIND=8) PCGA_TOT(klon,klev,NSW)
+      REAL(KIND=8) PTAU_TOT(klon,klev,NSW)
+      REAL(KIND=8) PPIZA_NAT(klon,klev,NSW)
+      REAL(KIND=8) PCGA_NAT(klon,klev,NSW)
+      REAL(KIND=8) PTAU_NAT(klon,klev,NSW)
       REAL(KIND=8) PSFSWDIR(klon,NSW)
       REAL(KIND=8) PSFSWDIF(klon,NSW)
@@ -319,8 +335,6 @@
 !      REAL(KIND=8) SUN_FRACT(2)
   real, parameter:: dobson_u = 2.1415e-05 ! Dobson unit, in kg m-2
-!--OB
-      REAL tau(6), alt, zdz, zrho
-      character (len=20) :: modname='radlwsw'
-      character (len=80) :: abort_message
+  CHARACTER (LEN=80) :: abort_message
+  CHARACTER (LEN=80) :: modname='radlwsw_m'
 
   call assert(size(wo, 1) == klon, size(wo, 2) == klev, "radlwsw wo")
@@ -621,56 +635,26 @@
       ENDDO
       ENDDO
-!      
-!--OB Valeurs de tau(NSW) calculees par O.Boucher (MPL 20130417)
-!-- voir aod_2bands.F90, aod_4bands.F90, aod_6bands.F90 dans BENCH48x36x19
-      SELECT CASE (NSW)
-      CASE (2)
-       tau(1)=0.22017828
-       tau(2)=0.110565394
-      CASE (4)
-       tau(1)=0.22017743
-       tau(2)=0.12738435
-       tau(3)=0.07157799
-       tau(4)=0.03301198
-      CASE (6)
-       tau(1)=0.49999997
-       tau(2)=0.28593913
-       tau(3)=0.20057647
-       tau(4)=0.12738435
-       tau(5)=0.07157799
-       tau(6)=0.03301198
-      END SELECT
-!     tau1=0.2099  ! anciennes valeurs de Nicolas Huneeus (20130326)
-!     tau2=0.1022
-!     tau(1)=1.0e-15
-!     tau(2)=1.0e-15
-!     tau(3)=1.0e-15
-!     tau(4)=1.0e-15
-!     tau(5)=1.0e-15
-!     tau(6)=1.0e-15
-      print *,'Radlwsw: NSW tau= ',NSW,tau(:)
-      DO i = 1, kdlon
-      alt=0.0
+!
+!--OB
+!--aerosol TOT  - anthropogenic+natural
+!--aerosol NAT  - natural only
+!
+      DO i = 1, kdlon
       DO k = 1, kflev
-      zrho=pplay(i,k)/t(i,k)/RD
-      zdz=(paprs(i,k)-paprs(i,k+1))/zrho/RG
       DO kk=1, NSW
-      PTAUREL_DST(i,kflev+1-k,kk)=(tau(kk)/2000.0)*max(0.0,min(zdz,2000.0-alt))
-      PTAUREL_DST(i,kflev+1-k,kk)=MAX(PTAUREL_DST(i,kflev+1-k,kk), 1e-15)
-      ENDDO
-      alt=alt+zdz
-      ENDDO
-      ENDDO
-
-!
-      DO k = 1, kflev
-      DO i = 1, kdlon
-      DO kk = 1, NSW
-!     PPIZA_DST(i,k,kk)=1.0   
-      PPIZA_DST(i,k,kk)=0.8   
-      PCGA_DST(i,k,kk)=0.7
-      ENDDO
-      ENDDO
-      ENDDO
+!
+      PTAU_TOT(i,kflev+1-k,kk)=tau_aero_rrtm(i,k,2,kk)
+      PPIZA_TOT(i,kflev+1-k,kk)=piz_aero_rrtm(i,k,2,kk)
+      PCGA_TOT(i,kflev+1-k,kk)=cg_aero_rrtm(i,k,2,kk)
+!
+      PTAU_NAT(i,kflev+1-k,kk)=tau_aero_rrtm(i,k,1,kk)
+      PPIZA_NAT(i,kflev+1-k,kk)=piz_aero_rrtm(i,k,1,kk)
+      PCGA_NAT(i,kflev+1-k,kk)=cg_aero_rrtm(i,k,1,kk)
+!
+      ENDDO
+      ENDDO
+      ENDDO
+!-end OB
+!
 !      
       DO i = 1, kdlon
@@ -707,4 +691,7 @@
             ref_liq_i(1:klon,k) =ref_liq(1:klon,klev+1-k)
             ref_ice_i(1:klon,k) =ref_ice(1:klon,klev+1-k)
+!-OB
+            ref_liq_pi_i(1:klon,k) =ref_liq_pi(1:klon,klev+1-k)
+            ref_ice_pi_i(1:klon,k) =ref_ice_pi(1:klon,klev+1-k)
          enddo
          do k=1,kflev
@@ -762,15 +749,23 @@
 
 ! Nouvel appel a RECMWF (celui du cy32t0)
-         CALL RECMWF (ist , iend, klon , ktdia  , klev   , kmode ,&
+         CALL RECMWF_AERO (ist , iend, klon , ktdia  , klev   , kmode ,&
          PALBD_NEW,PALBP_NEW, paprs_i , pplay_i , RCO2   , cldfra_i,&
          POZON_i  , PAER_i  , PDP_i   , PEMIS   , rmu0   ,&
           q_i     , qsat_i  , fiwc_i  , flwc_i  , zmasq  , t_i  ,tsol,&
          ref_liq_i, ref_ice_i, &
+         ref_liq_pi_i, ref_ice_pi_i, &   ! rajoute par OB pour diagnostiquer effet indirect
          ZEMTD_i  , ZEMTU_i , ZTRSO_i ,&
          ZTH_i    , ZCTRSO  , ZCEMTR  , ZTRSOD  ,&
          ZLWFC    , ZLWFT_i , ZSWFC   , ZSWFT_i ,&
          PSFSWDIR , PSFSWDIF, PFSDNN  , PFSDNV  ,&
-         PPIZA_DST, PCGA_DST,PTAUREL_DST,ZFLUX_i  , ZFLUC_i ,&
-         ZFSDWN_i , ZFSUP_i , ZFCDWN_i, ZFCUP_i)
+         PPIZA_TOT, PCGA_TOT,PTAU_TOT,&
+         PPIZA_NAT, PCGA_NAT,PTAU_NAT,           &  ! rajoute par OB pour diagnostiquer effet direct
+         ZFLUX_i  , ZFLUC_i ,&
+         ZFSDWN_i , ZFSUP_i , ZFCDWN_i, ZFCUP_i,&
+         ZTOPSWADAERO,ZSOLSWADAERO,&  ! rajoute par OB pour diagnostics
+         ZTOPSWAD0AERO,ZSOLSWAD0AERO,&
+         ZTOPSWAIAERO,ZSOLSWAIAERO, &
+         ZTOPSWCF_AERO,ZSOLSWCF_AERO, &
+         ok_ade, ok_aie, flag_aerosol,flag_aerosol_strat) ! flags aerosols
             
          print *,'RADLWSW: apres RECMWF'
@@ -791,7 +786,7 @@
         CALL writefield_phy('pfsdnn',PFSDNN,1)
         CALL writefield_phy('pfsdnv',PFSDNV,1)
-        CALL writefield_phy('ppiza_dst',PPIZA_DST,klev)
-        CALL writefield_phy('pcga_dst',PCGA_DST,klev)
-        CALL writefield_phy('ptaurel_dst',PTAUREL_DST,klev)
+        CALL writefield_phy('ppiza_dst',PPIZA_TOT,klev)
+        CALL writefield_phy('pcga_dst',PCGA_TOT,klev)
+        CALL writefield_phy('ptaurel_dst',PTAU_TOT,klev)
         CALL writefield_phy('zflux_i',ZFLUX_i,klev+1)
         CALL writefield_phy('zfluc_i',ZFLUC_i,klev+1)
@@ -813,7 +808,10 @@
 !  ZSWFC        (KPROMA,2)       ; CLEAR-SKY SHORTWAVE FLUXES
 !  ZSWFT        (KPROMA,KLEV+1)  ; TOTAL-SKY SHORTWAVE FLUXES
-!  PPIZA_DST    (KPROMA,KLEV,NSW); Single scattering albedo of dust 
-!  PCGA_DST     (KPROMA,KLEV,NSW); Assymetry factor for dust 
-!  PTAUREL_DST  (KPROMA,KLEV,NSW); Optical depth of dust relative to at 550nm
+!  PPIZA_TOT    (KPROMA,KLEV,NSW); Single scattering albedo of total aerosols 
+!  PCGA_TOT     (KPROMA,KLEV,NSW); Assymetry factor for total aerosols 
+!  PTAU_TOT     (KPROMA,KLEV,NSW); Optical depth of total aerosols 
+!  PPIZA_NAT    (KPROMA,KLEV,NSW); Single scattering albedo of natural aerosols 
+!  PCGA_NAT     (KPROMA,KLEV,NSW); Assymetry factor for natural aerosols 
+!  PTAU_NAT     (KPROMA,KLEV,NSW); Optical depth of natiral aerosols 
 !  PSFSWDIR     (KPROMA,NSW)     ;
 !  PSFSWDIF     (KPROMA,NSW)     ;
@@ -854,4 +852,18 @@
          ENDDO
       ENDDO
+
+!--ajout OB
+      ZTOPSWADAERO(:) =ZTOPSWADAERO(:) *fract(:)
+      ZSOLSWADAERO(:) =ZSOLSWADAERO(:) *fract(:)
+      ZTOPSWAD0AERO(:)=ZTOPSWAD0AERO(:)*fract(:)
+      ZSOLSWAD0AERO(:)=ZSOLSWAD0AERO(:)*fract(:)
+      ZTOPSWAIAERO(:) =ZTOPSWAIAERO(:) *fract(:)
+      ZSOLSWAIAERO(:) =ZSOLSWAIAERO(:) *fract(:)
+      ZTOPSWCF_AERO(:,1)=ZTOPSWCF_AERO(:,1)*fract(:) 
+      ZTOPSWCF_AERO(:,2)=ZTOPSWCF_AERO(:,2)*fract(:) 
+      ZTOPSWCF_AERO(:,3)=ZTOPSWCF_AERO(:,3)*fract(:) 
+      ZSOLSWCF_AERO(:,1)=ZSOLSWCF_AERO(:,1)*fract(:)
+      ZSOLSWCF_AERO(:,2)=ZSOLSWCF_AERO(:,2)*fract(:)
+      ZSOLSWCF_AERO(:,3)=ZSOLSWCF_AERO(:,3)*fract(:)
 
 !     print*,'SW_RRTM ZFSDN0 1 , klev:',ZFSDN0(1:klon,1),ZFSDN0(1:klon,klev)
Index: /LMDZ5/branches/testing/libf/phylmd/readaerosol_optic.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/readaerosol_optic.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/readaerosol_optic.F90	(revision 2056)
@@ -40,6 +40,9 @@
   REAL, DIMENSION(klon,klev,naero_grp,nbands), INTENT(OUT) :: piz_aero    ! Single scattering albedo aerosol
   REAL, DIMENSION(klon,klev,naero_grp,nbands), INTENT(OUT) :: cg_aero     ! asymmetry parameter aerosol
-  REAL, DIMENSION(klon,nwave,naero_spc), INTENT(OUT)       :: tausum_aero
-  REAL, DIMENSION(klon,klev,nwave,naero_spc), INTENT(OUT)  :: tau3d_aero
+!  REAL, DIMENSION(klon,nwave,naero_spc), INTENT(OUT)       :: tausum_aero
+!  REAL, DIMENSION(klon,klev,nwave,naero_spc), INTENT(OUT)  :: tau3d_aero
+!--correction mini bug OB
+  REAL, DIMENSION(klon,nwave,naero_tot), INTENT(OUT)       :: tausum_aero
+  REAL, DIMENSION(klon,klev,nwave,naero_tot), INTENT(OUT)  :: tau3d_aero
 
 ! Local variables
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/aeropt_5wv_rrtm.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/aeropt_5wv_rrtm.F90	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/aeropt_5wv_rrtm.F90	(revision 2056)
@@ -0,0 +1,413 @@
+!
+! $Id$
+!
+
+SUBROUTINE AEROPT_5WV_RRTM(&
+   pdel, m_allaer, delt, &
+   RHcl, ai, flag_aerosol, &
+   pplay, t_seri, &
+   tausum, tau )
+
+  USE DIMPHY
+  USE aero_mod
+  USE phys_local_var_mod, only: od550aer,od865aer,ec550aer,od550lt1aer
+
+  !
+  !    Yves Balkanski le 12 avril 2006
+  !    Celine Deandreis
+  !    Anne Cozic  Avril 2009
+  !    a partir d'une sous-routine de Johannes Quaas pour les sulfates
+  !    Olivier Boucher mars 2014 pour adaptation RRTM
+  !
+  ! Refractive indices for seasalt come from Shettle and Fenn (1979)
+  !
+  ! Refractive indices from water come from Hale and Querry (1973)
+  !
+  ! Refractive indices from Ammonium Sulfate Toon and Pollack (1976)
+  !
+  ! Refractive indices for Dust, internal mixture of minerals coated with 1.5% hematite 
+  ! by Volume (Balkanski et al., 2006)
+  !
+  ! Refractive indices for POM: Kinne (pers. Communication 
+  !
+  ! Refractive index for BC from Shettle and Fenn (1979)
+  !
+  ! Shettle, E. P., & Fenn, R. W. (1979), Models for the aerosols of the lower atmosphere and 
+  ! the effects of humidity variations on their optical properties, U.S. Air Force Geophysics 
+  ! Laboratory Rept. AFGL-TR-79-0214, Hanscomb Air Force Base, MA.
+  !
+  ! Hale, G. M. and M. R. Querry, Optical constants of water in the 200-nm to 200-m 
+  ! wavelength region, Appl. Opt., 12, 555-563, 1973.
+  !
+  ! Toon, O. B. and J. B. Pollack, The optical constants of several atmospheric aerosol species:
+  ! Ammonium sulfate, aluminum oxide, and sodium chloride, J. Geohys. Res., 81, 5733-5748,
+  ! 1976.
+  !
+  ! Balkanski, Y., M. Schulz, T. Claquin And O. Boucher, Reevaluation of mineral aerosol 
+  ! radiative forcings suggests a better agreement with satellite and AERONET data, Atmospheric 
+  ! Chemistry and Physics Discussions., 6, pp 8383-8419, 2006.
+  !
+  IMPLICIT NONE
+  INCLUDE "YOMCST.h"
+  !
+  ! Input arguments:
+  !
+  REAL, DIMENSION(klon,klev), INTENT(in)   :: pdel
+  REAL, INTENT(in)                         :: delt
+  REAL, DIMENSION(klon,klev,naero_spc), INTENT(in) :: m_allaer
+  REAL, DIMENSION(klon,klev), INTENT(in)   :: RHcl     ! humidite relative ciel clair
+  INTEGER,INTENT(in)                       :: flag_aerosol
+  REAL, DIMENSION(klon,klev), INTENT(in)   :: pplay
+  REAL, DIMENSION(klon,klev), INTENT(in)   :: t_seri
+  !
+  ! Output arguments:
+  !
+  REAL, DIMENSION(klon), INTENT(out)                      :: ai      ! POLDER aerosol index 
+  REAL, DIMENSION(klon,nwave,naero_tot), INTENT(out)      :: tausum
+  REAL, DIMENSION(klon,klev,nwave,naero_tot), INTENT(out) :: tau
+
+  !
+  ! Local
+  !
+  INTEGER, PARAMETER :: las = nwave
+  LOGICAL :: soluble
+  
+  INTEGER :: i, k, m
+  INTEGER :: spsol, spinsol, la
+  INTEGER :: RH_num(klon,klev)
+  INTEGER, PARAMETER :: la443 = 1
+  INTEGER, PARAMETER :: la550 = 2
+  INTEGER, PARAMETER :: la670 = 3
+  INTEGER, PARAMETER :: la765 = 4
+  INTEGER, PARAMETER :: la865 = 5
+  INTEGER, PARAMETER :: nbre_RH=12
+  INTEGER, PARAMETER :: naero_soluble=7   !  1- BC soluble; 2- POM soluble; 3- SO4 acc.
+                                          !  4- SO4 coarse; 5 seasalt super-C; 6 seasalt coarse; 7 seasalt acc.
+  INTEGER, PARAMETER :: naero_insoluble=3 !  1- Dust; 2- BC insoluble; 3- POM insoluble
+
+  REAL :: zrho
+
+  REAL, PARAMETER :: RH_tab(nbre_RH)=(/0.,10.,20.,30.,40.,50.,60.,70.,80.,85.,90.,95./)
+  REAL, PARAMETER :: RH_MAX=95.
+  REAL :: delta(klon,klev), rh(klon,klev)
+  REAL :: tau_ae5wv_int   ! Intermediate computation of epaisseur optique aerosol
+  REAL :: od670aer(klon)  ! epaisseur optique aerosol extinction 670 nm
+  REAL :: fac
+  REAL :: zdp1(klon,klev) 
+  INTEGER, ALLOCATABLE, DIMENSION(:)  :: aerosol_name
+  INTEGER :: nb_aer
+  
+  REAL :: dh(KLON,KLEV)
+  
+   ! Soluble components 1- BC soluble; 2- POM soluble; 3- SO4 acc.; 4- SO4 coarse; 5 seasalt super-coarse; 6 seasalt coarse; 7 seasalt acc.
+  REAL :: alpha_aers_5wv(nbre_RH,las,naero_soluble)   ! Ext. coeff. ** m2/g 
+   ! Insoluble components 1- Dust: 2- BC; 3- POM
+  REAL :: alpha_aeri_5wv(las,naero_insoluble)         ! Ext. coeff. ** m2/g 
+
+  REAL, DIMENSION(klon,klev,naero_spc) :: mass_temp
+  
+  !
+  ! Proprietes optiques
+  !
+  REAL :: fact_RH(nbre_RH)
+  LOGICAL :: used_tau(naero_tot)
+  INTEGER :: n
+  
+! From here on we look at the optical parameters at 5 wavelengths:  
+! 443nm, 550, 670, 765 and 865 nm 
+!                                   le 12 AVRIL 2006 
+!  
+ DATA alpha_aers_5wv/ & 
+                                ! bc soluble 
+       7.930,7.930,7.930,7.930,7.930,7.930,     & 
+       7.930,7.930,10.893,12.618,14.550,16.613, & 
+       7.658,7.658,7.658,7.658,7.658,7.658,     & 
+       7.658,7.658,10.351,11.879,13.642,15.510, & 
+       7.195,7.195,7.195,7.195,7.195,7.195,     & 
+       7.195,7.195,9.551,10.847,12.381,13.994,  & 
+       6.736,6.736,6.736,6.736,6.736,6.736,     & 
+       6.736,6.736,8.818,9.938,11.283,12.687,   & 
+       6.277,6.277,6.277,6.277,6.277,6.277,     & 
+       6.277,6.277,8.123,9.094,10.275,11.501,   & 
+                                ! pom soluble 
+       6.676,6.676,6.676,6.676,6.710,6.934,   & 
+       7.141,7.569,8.034,8.529,9.456,10.511,  & 
+       5.109,5.109,5.109,5.109,5.189,5.535,   & 
+       5.960,6.852,8.008,9.712,12.897,19.676, & 
+       3.718,3.718,3.718,3.718,3.779,4.042,   & 
+       4.364,5.052,5.956,7.314,9.896,15.688,  & 
+       2.849,2.849,2.849,2.849,2.897,3.107,   & 
+       3.365,3.916,4.649,5.760,7.900,12.863,  & 
+       2.229,2.229,2.229,2.229,2.268,2.437,   & 
+       2.645,3.095,3.692,4.608,6.391,10.633,  & 
+                                ! Sulfate (Accumulation) 
+       5.751,6.215,6.690,7.024,7.599,8.195,      & 
+       9.156,10.355,12.660,14.823,18.908,24.508, & 
+       4.320,4.675,5.052,5.375,5.787,6.274,      & 
+       7.066,8.083,10.088,12.003,15.697,21.133,  & 
+       3.079,3.351,3.639,3.886,4.205,4.584,      & 
+       5.206,6.019,7.648,9.234,12.391,17.220,    & 
+       2.336,2.552,2.781,2.979,3.236,3.540,      & 
+       4.046,4.711,6.056,7.388,10.093,14.313,    & 
+       1.777,1.949,2.134,2.292,2.503,2.751,      & 
+       3.166,3.712,4.828,5.949,8.264,11.922,     & 
+                                ! Sulfate (Coarse) 
+       5.751,6.215,6.690,7.024,7.599,8.195,      & 
+       9.156,10.355,12.660,14.823,18.908,24.508, & 
+       4.320,4.675,5.052,5.375,5.787,6.274,      & 
+       7.066,8.083,10.088,12.003,15.697,21.133,  & 
+       3.079,3.351,3.639,3.886,4.205,4.584,      & 
+       5.206,6.019,7.648,9.234,12.391,17.220,    & 
+       2.336,2.552,2.781,2.979,3.236,3.540,      & 
+       4.046,4.711,6.056,7.388,10.093,14.313,    & 
+       1.777,1.949,2.134,2.292,2.503,2.751,      & 
+       3.166,3.712,4.828,5.949,8.264,11.922,     & 
+                           ! seasalt seasalt Super Coarse Soluble (SS)
+        0.218, 0.240, 0.262, 0.311, 0.391, 0.452, &
+        0.544, 0.614, 0.886, 1.018, 1.260, 2.336, &
+        0.221, 0.243, 0.266, 0.315, 0.396, 0.455, &
+        0.551, 0.622, 0.896, 1.029, 1.270, 2.352, &
+        0.224, 0.246, 0.270, 0.319, 0.400, 0.461, &
+        0.558, 0.626, 0.904, 1.039, 1.278, 2.362, &
+        0.227, 0.249, 0.272, 0.322, 0.404, 0.466, &
+        0.560, 0.632, 0.907, 1.041, 1.284, 2.375, &
+        0.230, 0.252, 0.276, 0.325, 0.408, 0.469, &
+        0.567, 0.636, 0.917, 1.052, 1.293, 2.383, &
+                           ! seasalt seasalt Coarse Soluble (CS)      
+        0.578, 0.632, 0.691, 0.814, 1.017, 1.171, &
+        1.407, 1.585, 2.264, 2.594, 3.197, 5.882, &
+        0.598, 0.654, 0.711, 0.836, 1.041, 1.201, &
+        1.445, 1.622, 2.313, 2.647, 3.256, 5.961, &
+        0.619, 0.676, 0.736, 0.862, 1.072, 1.234, &
+        1.484, 1.659, 2.361, 2.698, 3.304, 6.014, &
+        0.633, 0.692, 0.754, 0.884, 1.095, 1.262, &
+        1.510, 1.693, 2.395, 2.734, 3.352, 6.090, &
+        0.648, 0.708, 0.771, 0.902, 1.119, 1.288, &
+        1.545, 1.725, 2.441, 2.784, 3.402, 6.144, &
+                           ! seasalt seasalt Accumulation Soluble (AS)
+        4.432, 5.160, 5.940, 7.646,10.520,11.464, &
+       14.686,16.949,25.977,30.118,37.327,65.333, &
+        3.298, 3.916, 4.594, 6.127, 8.845, 9.446, &
+       12.511,14.710,24.073,28.546,36.578,69.050, &
+        2.340, 2.826, 3.371, 4.638, 6.992, 7.360, &
+       10.047,12.016,20.909,25.349,33.605,69.554, &
+        1.789, 2.185, 2.633, 3.698, 5.733, 5.994, &
+        8.345,10.094,18.293,22.511,30.548,67.717, &
+        1.359, 1.676, 2.040, 2.916, 4.637, 4.829, &
+        6.843, 8.364,15.723,19.614,27.195,64.359 /
+
+  DATA alpha_aeri_5wv/ &
+                                 ! dust insoluble 
+        0.759, 0.770, 0.775, 0.775, 0.772, & 
+                                 !!jb bc insoluble 
+        11.536,10.033, 8.422, 7.234, 6.270, & 
+                                 ! pom insoluble 
+        5.042, 3.101, 1.890, 1.294, 0.934/ 
+  ! 
+  ! Initialisations
+  ai(:) = 0.
+  tausum(:,:,:) = 0.
+
+  DO k=1, klev
+    DO i=1, klon
+      zrho=pplay(i,k)/t_seri(i,k)/RD                  ! kg/m3
+      dh(i,k)=pdel(i,k)/(RG*zrho)
+!CDIR UNROLL=naero_spc
+      mass_temp(i,k,:) = m_allaer(i,k,:) / zrho / 1.e+9
+      zdp1(i,k)=pdel(i,k)/(RG*delt)     ! air mass auxiliary  variable --> zdp1 [kg/(m^2 *s)]
+    ENDDO
+  ENDDO
+
+  IF (flag_aerosol .EQ. 1) THEN 
+     nb_aer = 2
+     ALLOCATE (aerosol_name(nb_aer)) 
+     aerosol_name(1) = id_ASSO4M
+     aerosol_name(2) = id_CSSO4M
+  ELSEIF (flag_aerosol .EQ. 2) THEN
+     nb_aer = 2
+     ALLOCATE (aerosol_name(nb_aer)) 
+     aerosol_name(1) = id_ASBCM
+     aerosol_name(2) = id_AIBCM
+  ELSEIF (flag_aerosol .EQ. 3) THEN 
+     nb_aer = 2
+     ALLOCATE (aerosol_name(nb_aer)) 
+     aerosol_name(1) = id_ASPOMM
+     aerosol_name(2) = id_AIPOMM
+  ELSEIF (flag_aerosol .EQ. 4) THEN 
+     nb_aer = 3
+     ALLOCATE (aerosol_name(nb_aer)) 
+     aerosol_name(1) = id_CSSSM
+     aerosol_name(2) = id_SSSSM
+     aerosol_name(3) = id_ASSSM
+  ELSEIF (flag_aerosol .EQ. 5) THEN 
+     nb_aer = 1
+     ALLOCATE (aerosol_name(nb_aer)) 
+     aerosol_name(1) = id_CIDUSTM
+  ELSEIF (flag_aerosol .EQ. 6) THEN 
+     nb_aer = 10
+     ALLOCATE (aerosol_name(nb_aer)) 
+     aerosol_name(1) = id_ASSO4M      
+     aerosol_name(2) = id_ASBCM
+     aerosol_name(3) = id_AIBCM
+     aerosol_name(4) = id_ASPOMM
+     aerosol_name(5) = id_AIPOMM
+     aerosol_name(6) = id_CSSSM
+     aerosol_name(7) = id_SSSSM
+     aerosol_name(8) = id_ASSSM
+     aerosol_name(9) = id_CIDUSTM
+     aerosol_name(10) = id_CSSO4M
+  ENDIF
+
+  ! 
+  ! Loop over modes, use of precalculated nmd and corresponding sigma
+  !    loop over wavelengths
+  !    for each mass species in mode
+  !      interpolate from Sext to retrieve Sext_at_gridpoint_per_species
+  !      compute optical_thickness_at_gridpoint_per_species
+  !
+  ! Calculations that need to be done since we are not in the subroutines INCA
+  !      
+
+!CDIR ON_ADB(RH_tab)
+!CDIR ON_ADB(fact_RH)
+!CDIR NOVECTOR
+  DO n=1,nbre_RH-1
+    fact_RH(n)=1./(RH_tab(n+1)-RH_tab(n))
+  ENDDO
+   
+  DO k=1, KLEV
+!CDIR ON_ADB(RH_tab)
+!CDIR ON_ADB(fact_RH)
+    DO i=1, KLON
+      rh(i,k)=MIN(RHcl(i,k)*100.,RH_MAX)
+      RH_num(i,k) = INT( rh(i,k)/10. + 1.)
+      IF (rh(i,k).GT.85.) RH_num(i,k)=10
+      IF (rh(i,k).GT.90.) RH_num(i,k)=11
+      delta(i,k)=(rh(i,k)-RH_tab(RH_num(i,k)))*fact_RH(RH_num(i,k))
+    ENDDO
+  ENDDO
+
+!CDIR SHORTLOOP  
+  used_tau(:)=.FALSE.
+    
+  DO m=1,nb_aer   ! tau is only computed for each mass    
+    fac=1.0
+    IF (aerosol_name(m).EQ.id_ASBCM) THEN
+        soluble=.TRUE.
+        spsol=1
+    ELSEIF (aerosol_name(m).EQ.id_ASPOMM) THEN 
+        soluble=.TRUE.
+        spsol=2 
+    ELSEIF (aerosol_name(m).EQ.id_ASSO4M) THEN
+        soluble=.TRUE.
+        spsol=3
+        fac=1.375    ! (NH4)2-SO4/SO4 132/96 mass conversion factor for OD
+    ELSEIF (aerosol_name(m).EQ.id_CSSO4M) THEN
+        soluble=.TRUE.
+        spsol=4
+        fac=1.375    ! (NH4)2-SO4/SO4 132/96 mass conversion factor for OD
+    ELSEIF (aerosol_name(m).EQ.id_SSSSM) THEN 
+        soluble=.TRUE.
+        spsol=5
+    ELSEIF (aerosol_name(m).EQ.id_CSSSM) THEN 
+        soluble=.TRUE.
+        spsol=6
+    ELSEIF (aerosol_name(m).EQ.id_ASSSM) THEN
+        soluble=.TRUE.
+        spsol=7
+    ELSEIF (aerosol_name(m).EQ.id_CIDUSTM) THEN 
+        soluble=.FALSE.
+        spinsol=1
+    ELSEIF  (aerosol_name(m).EQ.id_AIBCM) THEN 
+        soluble=.FALSE.
+        spinsol=2
+    ELSEIF (aerosol_name(m).EQ.id_AIPOMM) THEN 
+        soluble=.FALSE.
+        spinsol=3
+    ELSE 
+        CYCLE
+    ENDIF
+
+    IF (soluble) then
+      used_tau(spsol)=.TRUE.
+    ELSE
+      used_tau(naero_soluble+spinsol)=.TRUE.
+    ENDIF
+
+    DO la=1,las
+
+      IF (soluble) THEN            ! For soluble aerosol
+
+          DO k=1, KLEV
+            DO i=1, KLON
+              tau_ae5wv_int = alpha_aers_5wv(RH_num(i,k),la,spsol)+DELTA(i,k)* &
+                             (alpha_aers_5wv(RH_num(i,k)+1,la,spsol) - & 
+                              alpha_aers_5wv(RH_num(i,k),la,spsol))
+              tau(i,k,la,spsol) = mass_temp(i,k,spsol)*1000.*zdp1(i,k)   &
+                                 *tau_ae5wv_int*delt*fac
+              tausum(i,la,spsol)=tausum(i,la,spsol)+tau(i,k,la,spsol)
+            ENDDO
+          ENDDO
+
+      ELSE                         ! For insoluble aerosol
+
+        DO k=1, KLEV
+          DO i=1, KLON
+            tau_ae5wv_int = alpha_aeri_5wv(la,spinsol)
+            tau(i,k,la,naero_soluble+spinsol) = mass_temp(i,k,naero_soluble+spinsol)*1000.*zdp1(i,k)* &
+                                                tau_ae5wv_int*delt*fac
+            tausum(i,la,naero_soluble+spinsol)= tausum(i,la,naero_soluble+spinsol)  &
+                                               +tau(i,k,la,naero_soluble+spinsol)
+          ENDDO
+        ENDDO
+
+      ENDIF
+
+    ENDDO   ! Boucle sur les longueurs d'onde
+  ENDDO     ! Boucle sur les masses de traceurs
+
+  DO m=1,naero_tot
+    IF (.NOT.used_tau(m)) tau(:,:,:,m)=0.
+  ENDDO  
+
+  DO i=1, klon
+     od550aer(i)=0.
+     DO m=1,naero_tot
+        od550aer(i)=od550aer(i)+tausum(i,la550,m)
+     END DO
+  END DO
+
+  DO i=1, klon
+     od670aer(i)=0.
+     DO m=1,naero_tot
+        od670aer(i)=od670aer(i)+tausum(i,la670,m)
+     END DO
+  END DO
+
+  DO i=1, klon
+     od865aer(i)=0.
+     DO m=1,naero_tot
+        od865aer(i)=od865aer(i)+tausum(i,la865,m)
+     END DO
+  END DO
+
+  DO i=1, klon
+     DO k=1, KLEV
+        ec550aer(i,k)=0.
+        DO m=1,naero_tot
+           ec550aer(i,k)=ec550aer(i,k)+tau(i,k,la550,m)/dh(i,k)
+        END DO
+     END DO
+  END DO
+  
+  DO i=1, klon
+    ai(i)=-LOG(MAX(od670aer(i),1.e-8)/MAX(od865aer(i),1.e-8))/LOG(670./865.)
+  ENDDO
+
+  od550lt1aer(:)=tausum(:,la550,id_ASSO4M)+tausum(:,la550,id_ASBCM) +tausum(:,la550,id_AIBCM)+ &
+                 tausum(:,la550,id_ASPOMM)+tausum(:,la550,id_AIPOMM)+tausum(:,la550,id_ASSSM)+ &
+                 0.03*tausum(:,la550,id_CSSSM)+0.4*tausum(:,la550,id_CIDUSTM)
+
+  DEALLOCATE(aerosol_name) 
+  
+END SUBROUTINE AEROPT_5WV_RRTM
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/aeropt_6bands_rrtm.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/aeropt_6bands_rrtm.F90	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/aeropt_6bands_rrtm.F90	(revision 2056)
@@ -0,0 +1,550 @@
+!
+! $Id$
+!
+SUBROUTINE AEROPT_6BANDS_RRTM ( &
+     pdel, m_allaer, delt, RHcl, &
+     tau_allaer, piz_allaer, &
+     cg_allaer, m_allaer_pi, &
+     flag_aerosol, pplay, t_seri )
+
+  USE dimphy
+  USE aero_mod
+  USE phys_local_var_mod, only: absvisaer
+
+  !    Yves Balkanski le 12 avril 2006
+  !    Celine Deandreis
+  !    Anne Cozic Avril 2009
+  !    a partir d'une sous-routine de Johannes Quaas pour les sulfates
+  !    Olivier Boucher février 2014 pour passage à RRTM
+  !    a partir des propriétés optiques fournies par Yves Balkanski
+  !
+  IMPLICIT NONE
+
+  INCLUDE "YOMCST.h"
+  INCLUDE "iniprint.h"
+  INCLUDE "clesphys.h"
+
+  !
+  ! Input arguments:
+  !
+  REAL, DIMENSION(klon,klev),     INTENT(in)  :: pdel
+  REAL,                           INTENT(in)  :: delt
+  REAL, DIMENSION(klon,klev,naero_spc),   INTENT(in)  :: m_allaer
+  REAL, DIMENSION(klon,klev,naero_spc),   INTENT(in)  :: m_allaer_pi
+  REAL, DIMENSION(klon,klev),     INTENT(in)  :: RHcl       ! humidite relative ciel clair
+  INTEGER,                        INTENT(in)  :: flag_aerosol
+  REAL, DIMENSION(klon,klev),     INTENT(in)  :: pplay
+  REAL, DIMENSION(klon,klev),     INTENT(in)  :: t_seri
+  !
+  ! Output arguments:
+  ! 1= total aerosols 
+  ! 2= natural aerosols
+  !
+  REAL, DIMENSION(klon,klev,2,nbands_rrtm), INTENT(out) :: tau_allaer ! epaisseur optique aerosol
+  REAL, DIMENSION(klon,klev,2,nbands_rrtm), INTENT(out) :: piz_allaer ! single scattering albedo aerosol
+  REAL, DIMENSION(klon,klev,2,nbands_rrtm), INTENT(out) :: cg_allaer  ! asymmetry parameter aerosol
+
+  !
+  ! Local
+  !
+  LOGICAL ::  soluble
+  INTEGER :: i, k,n, inu, m
+  INTEGER :: spsol, spinsol
+  INTEGER :: RH_num(klon,klev)
+
+  INTEGER, PARAMETER :: nb_level=19 ! number of vertical levels in DATA
+
+  INTEGER, PARAMETER :: naero_soluble=7    ! 1- BC soluble; 2- POM soluble; 3- SO4. acc. 4- SO4 coarse
+                                           ! 5- seasalt super coarse  6- seasalt coarse   7- seasalt acc.
+  INTEGER, PARAMETER :: naero_insoluble=3  ! 1- Dust; 2- BC insoluble; 3- POM insoluble
+
+  INTEGER, PARAMETER :: nbre_RH=12
+  REAL,PARAMETER :: RH_tab(nbre_RH)=(/0.,10.,20.,30.,40.,50.,60.,70.,80.,85.,90.,95./)
+  REAL, PARAMETER :: RH_MAX=95.
+  REAL :: delta(klon,klev), rh(klon,klev)
+  REAL :: tau_ae2b_int   ! Intermediate computation of epaisseur optique aerosol
+  REAL :: piz_ae2b_int   ! Intermediate computation of Single scattering albedo
+  REAL :: cg_ae2b_int    ! Intermediate computation of Assymetry parameter
+  REAL :: Fact_RH(nbre_RH)
+  REAL :: zrho
+  REAL :: fac
+  REAL :: zdp1(klon,klev) 
+  INTEGER, ALLOCATABLE, DIMENSION(:)   :: aerosol_name
+  INTEGER :: nb_aer
+
+  REAL, DIMENSION(klon,klev,naero_spc) :: mass_temp
+  REAL, DIMENSION(klon,klev,naero_spc) :: mass_temp_pi
+  REAL, DIMENSION(klon,klev,naero_tot,nbands_rrtm) ::  tau_ae
+  REAL, DIMENSION(klon,klev,naero_tot,nbands_rrtm) ::  tau_ae_pi
+  REAL, DIMENSION(klon,klev,naero_tot,nbands_rrtm) ::  piz_ae
+  REAL, DIMENSION(klon,klev,naero_tot,nbands_rrtm) ::  cg_ae
+
+
+  !
+  ! Proprietes optiques
+  !
+  REAL:: alpha_aers_6bands(nbre_RH,nbands_rrtm,naero_soluble)   !--unit m2/g SO4
+  REAL:: alpha_aeri_6bands(nbands_rrtm,naero_insoluble)
+  REAL:: cg_aers_6bands(nbre_RH,nbands_rrtm,naero_soluble)      !--unit 
+  REAL:: cg_aeri_6bands(nbands_rrtm,naero_insoluble)
+  REAL:: piz_aers_6bands(nbre_RH,nbands_rrtm,naero_soluble)     !-- unit
+  REAL:: piz_aeri_6bands(nbands_rrtm,naero_insoluble)        !-- unit
+
+  INTEGER :: id
+  LOGICAL :: used_aer(naero_tot)
+  REAL :: tmp_var, tmp_var_pi
+
+!***************************************************************************
+!--the order of the soluble   species has to follow the spsol   index below
+!--the order of the insoluble species has to follow the spinsol index below
+
+  DATA alpha_aers_6bands/  & 
+       ! bc soluble AS
+  6.497, 6.497, 6.497, 6.497, 6.497, 7.160, 7.875, 9.356,10.811,10.974,11.149,12.734, &
+  6.497, 6.497, 6.497, 6.497, 6.497, 7.160, 7.875, 9.356,10.811,10.974,11.149,12.734, &
+  5.900, 5.900, 5.900, 5.900, 5.900, 6.502, 7.151, 8.496, 9.818, 9.965,10.124,11.564, &
+  4.284, 4.284, 4.284, 4.284, 4.284, 4.721, 5.193, 6.169, 7.129, 7.236, 7.352, 8.397, &
+  2.163, 2.163, 2.163, 2.163, 2.163, 2.384, 2.622, 3.115, 3.600, 3.654, 3.712, 4.240, &
+  0.966, 0.966, 0.966, 0.966, 0.966, 1.065, 1.171, 1.392, 1.608, 1.632, 1.658, 1.894, &
+       ! pom soluble AS
+  6.443, 6.443, 6.443, 6.443, 6.443, 7.100, 7.809, 9.277,10.721,10.882,11.056,12.628, &
+  6.443, 6.443, 6.443, 6.443, 6.443, 7.100, 7.809, 9.277,10.721,10.882,11.056,12.628, &
+  4.381, 4.381, 4.381, 4.381, 4.381, 4.828, 5.310, 6.309, 7.290, 7.400, 7.518, 8.587, &
+  1.846, 1.846, 1.846, 1.846, 1.846, 2.034, 2.237, 2.658, 3.072, 3.118, 3.168, 3.618, &
+  0.377, 0.377, 0.377, 0.377, 0.377, 0.415, 0.456, 0.542, 0.627, 0.636, 0.646, 0.738, &
+  0.052, 0.052, 0.052, 0.052, 0.052, 0.057, 0.063, 0.075, 0.087, 0.088, 0.089, 0.102, &
+       ! sulfate AS   
+  6.554, 6.554, 6.554, 7.223, 7.931, 8.665, 9.438,10.736,14.275,17.755,17.755,31.722, &
+  6.554, 6.554, 6.554, 7.223, 7.931, 8.665, 9.438,10.736,14.275,17.755,17.755,31.722, &
+  4.381, 4.381, 4.381, 4.828, 5.301, 5.792, 6.309, 7.176, 9.542,11.868,11.868,21.204, &
+  1.727, 1.727, 1.727, 1.903, 2.090, 2.283, 2.487, 2.829, 3.762, 4.679, 4.679, 8.359, &
+  0.312, 0.312, 0.312, 0.344, 0.378, 0.413, 0.450, 0.511, 0.680, 0.846, 0.846, 1.511, &
+  0.121, 0.121, 0.121, 0.134, 0.147, 0.161, 0.175, 0.199, 0.264, 0.329, 0.329, 0.588, &
+       ! sulfate coarse CS
+  0.693, 0.693, 0.693, 0.764, 0.839, 0.917, 0.999, 1.136, 1.510, 1.879, 1.879, 3.356, &
+  0.693, 0.693, 0.693, 0.764, 0.839, 0.917, 0.999, 1.136, 1.510, 1.879, 1.879, 3.356, &
+  0.715, 0.715, 0.715, 0.788, 0.865, 0.945, 1.029, 1.171, 1.557, 1.936, 1.936, 3.459, &
+  0.736, 0.736, 0.736, 0.811, 0.891, 0.973, 1.060, 1.206, 1.603, 1.994, 1.994, 3.563, &
+  0.711, 0.711, 0.711, 0.783, 0.860, 0.939, 1.023, 1.164, 1.548, 1.925, 1.925, 3.439, &
+  0.602, 0.602, 0.602, 0.664, 0.729, 0.796, 0.867, 0.986, 1.312, 1.631, 1.631, 2.915, &
+       ! seasalt seasalt Super Coarse Soluble (SS)
+  0.214, 0.235, 0.257, 0.305, 0.385, 0.444, 0.537, 0.606, 0.876, 1.006, 1.243, 2.313, &
+  0.217, 0.238, 0.261, 0.309, 0.389, 0.448, 0.543, 0.612, 0.882, 1.015, 1.255, 2.327, &
+  0.221, 0.243, 0.266, 0.315, 0.396, 0.456, 0.552, 0.621, 0.895, 1.028, 1.269, 2.351, &
+  0.230, 0.253, 0.276, 0.326, 0.408, 0.469, 0.568, 0.638, 0.918, 1.053, 1.298, 2.389, &
+  0.250, 0.273, 0.298, 0.349, 0.435, 0.501, 0.601, 0.674, 0.960, 1.098, 1.349, 2.466, &
+  0.279, 0.307, 0.336, 0.396, 0.493, 0.566, 0.679, 0.760, 1.072, 1.221, 1.486, 2.652, &
+       ! seasalt seasalt Coarse Soluble (CS)      
+  0.550, 0.605, 0.661, 0.782, 0.980, 1.131, 1.362, 1.536, 2.204, 2.528, 3.115, 5.773, &
+  0.568, 0.622, 0.681, 0.802, 1.004, 1.155, 1.393, 1.568, 2.246, 2.574, 3.174, 5.846, &
+  0.599, 0.655, 0.714, 0.838, 1.044, 1.202, 1.446, 1.621, 2.312, 2.645, 3.249, 5.950, &
+  0.647, 0.708, 0.771, 0.904, 1.121, 1.290, 1.546, 1.731, 2.447, 2.791, 3.416, 6.166, &
+  0.663, 0.735, 0.809, 0.964, 1.215, 1.386, 1.677, 1.883, 2.681, 3.059, 3.733, 6.647, &
+  0.479, 0.549, 0.623, 0.787, 1.065, 1.174, 1.491, 1.717, 2.648, 3.094, 3.901, 7.382, &
+       ! seasalt seasalt Accumulation Soluble (AS)
+  6.128, 6.867, 7.624, 9.184,11.602,13.194,15.955,17.858,24.856,28.034,33.562,56.971, &
+  5.080, 5.837, 6.636, 8.347,11.144,12.321,15.463,17.649,26.080,29.896,36.491,62.414, &
+  3.290, 3.899, 4.567, 6.075, 8.744, 9.355,12.369,14.532,23.747,28.159,36.101,68.531, &
+  1.389, 1.706, 2.070, 2.942, 4.643, 4.846, 6.836, 8.334,15.546,19.346,26.738,62.978, &
+  0.309, 0.394, 0.495, 0.754, 1.312, 1.377, 2.087, 2.654, 5.732, 7.538,11.368,35.212, &
+  0.021, 0.028, 0.036, 0.059, 0.114, 0.126, 0.208, 0.279, 0.718, 1.009, 1.691, 7.271  /
+
+  DATA alpha_aeri_6bands/  & 
+       ! dust insoluble CI
+  0.751, 0.751, 0.769, 0.772, 0.672, 0.437, &
+       ! bc insoluble AI
+  6.497, 6.497, 5.900, 4.284, 2.163, 0.966, &
+       ! pom insoluble AI
+  6.443, 6.443, 4.381, 1.846, 0.377, 0.052 /
+
+  DATA cg_aers_6bands/ &
+       ! bc soluble AS
+  0.721, 0.721, 0.721, 0.729, 0.735, 0.741, 0.746, 0.754, 0.762, 0.766, 0.769, 0.775, &
+  0.721, 0.721, 0.721, 0.729, 0.735, 0.741, 0.746, 0.754, 0.762, 0.766, 0.769, 0.775, &
+  0.643, 0.643, 0.643, 0.654, 0.662, 0.670, 0.677, 0.688, 0.698, 0.704, 0.707, 0.715, &
+  0.513, 0.513, 0.513, 0.522, 0.530, 0.536, 0.542, 0.552, 0.560, 0.565, 0.568, 0.575, &
+  0.321, 0.321, 0.321, 0.323, 0.325, 0.327, 0.328, 0.331, 0.333, 0.334, 0.335, 0.337, &
+  0.153, 0.153, 0.153, 0.149, 0.145, 0.142, 0.139, 0.135, 0.130, 0.128, 0.127, 0.123, &
+       ! pom soluble AS
+  0.687, 0.687, 0.687, 0.687, 0.687, 0.700, 0.710, 0.726, 0.736, 0.737, 0.738, 0.745, &
+  0.687, 0.687, 0.687, 0.687, 0.687, 0.700, 0.710, 0.726, 0.736, 0.737, 0.738, 0.745, &
+  0.658, 0.658, 0.658, 0.658, 0.658, 0.667, 0.674, 0.685, 0.692, 0.692, 0.693, 0.698, &
+  0.564, 0.564, 0.564, 0.564, 0.564, 0.566, 0.568, 0.571, 0.573, 0.573, 0.573, 0.574, &
+  0.363, 0.363, 0.363, 0.363, 0.363, 0.360, 0.357, 0.352, 0.350, 0.349, 0.349, 0.347, &
+  0.142, 0.142, 0.142, 0.142, 0.142, 0.139, 0.137, 0.133, 0.131, 0.131, 0.130, 0.129, &
+       ! sulfate AS 
+  0.675, 0.675, 0.675, 0.689, 0.701, 0.711, 0.720, 0.735, 0.748, 0.756, 0.760, 0.771, &
+  0.675, 0.675, 0.675, 0.689, 0.701, 0.711, 0.720, 0.735, 0.748, 0.756, 0.760, 0.771, &
+  0.653, 0.653, 0.653, 0.662, 0.670, 0.676, 0.683, 0.692, 0.701, 0.706, 0.709, 0.716, &
+  0.563, 0.563, 0.563, 0.565, 0.567, 0.569, 0.570, 0.573, 0.575, 0.576, 0.577, 0.579, &
+  0.362, 0.362, 0.362, 0.359, 0.356, 0.354, 0.352, 0.348, 0.345, 0.343, 0.342, 0.340, &
+  0.137, 0.137, 0.137, 0.135, 0.133, 0.132, 0.130, 0.128, 0.126, 0.125, 0.124, 0.122, &
+       ! sulfate coarse CS
+  0.803, 0.803, 0.803, 0.792, 0.783, 0.776, 0.769, 0.758, 0.747, 0.742, 0.738, 0.730, &
+  0.803, 0.803, 0.803, 0.792, 0.783, 0.776, 0.769, 0.758, 0.747, 0.742, 0.738, 0.730, &
+  0.799, 0.799, 0.799, 0.787, 0.777, 0.768, 0.760, 0.747, 0.736, 0.729, 0.725, 0.716, &
+  0.797, 0.797, 0.797, 0.782, 0.770, 0.760, 0.750, 0.735, 0.722, 0.714, 0.709, 0.698, &
+  0.810, 0.810, 0.810, 0.794, 0.781, 0.770, 0.759, 0.743, 0.728, 0.719, 0.714, 0.702, &
+  0.803, 0.803, 0.803, 0.790, 0.779, 0.770, 0.762, 0.748, 0.736, 0.729, 0.725, 0.715, &
+       ! seasalt seasalt Super Coarse Soluble (SS)
+  0.797, 0.799, 0.800, 0.803, 0.805, 0.823, 0.827, 0.830, 0.836, 0.838, 0.840, 0.845, &
+  0.788, 0.790, 0.792, 0.795, 0.798, 0.817, 0.821, 0.824, 0.830, 0.832, 0.835, 0.841, &
+  0.773, 0.776, 0.777, 0.782, 0.786, 0.805, 0.811, 0.814, 0.821, 0.824, 0.829, 0.835, &
+  0.746, 0.748, 0.752, 0.757, 0.764, 0.786, 0.792, 0.797, 0.806, 0.810, 0.815, 0.826, &
+  0.706, 0.710, 0.713, 0.718, 0.726, 0.752, 0.760, 0.766, 0.778, 0.783, 0.790, 0.806, &
+  0.681, 0.681, 0.681, 0.683, 0.685, 0.723, 0.728, 0.733, 0.740, 0.744, 0.751, 0.767, &
+       ! seasalt seasalt Coarse Soluble (CS)       
+  0.756, 0.759, 0.761, 0.766, 0.772, 0.792, 0.799, 0.802, 0.813, 0.816, 0.820, 0.828, &
+  0.736, 0.740, 0.742, 0.749, 0.756, 0.778, 0.785, 0.789, 0.800, 0.804, 0.810, 0.821, &
+  0.712, 0.714, 0.717, 0.724, 0.732, 0.757, 0.765, 0.770, 0.783, 0.788, 0.794, 0.809, &
+  0.690, 0.691, 0.693, 0.697, 0.703, 0.734, 0.742, 0.746, 0.758, 0.763, 0.769, 0.788, &
+  0.682, 0.682, 0.682, 0.683, 0.684, 0.725, 0.729, 0.733, 0.739, 0.742, 0.746, 0.759, &
+  0.669, 0.671, 0.672, 0.675, 0.678, 0.721, 0.727, 0.732, 0.737, 0.740, 0.743, 0.745, &
+       ! seasalt seasalt Accumulation Soluble (AS)
+  0.694, 0.694, 0.693, 0.690, 0.685, 0.733, 0.733, 0.735, 0.729, 0.728, 0.727, 0.732, &
+  0.685, 0.688, 0.690, 0.692, 0.693, 0.738, 0.742, 0.746, 0.745, 0.744, 0.742, 0.731, &
+  0.650, 0.656, 0.662, 0.672, 0.681, 0.722, 0.733, 0.740, 0.750, 0.753, 0.755, 0.748, &
+  0.561, 0.573, 0.584, 0.603, 0.626, 0.661, 0.681, 0.693, 0.721, 0.730, 0.741, 0.758, &
+  0.392, 0.408, 0.424, 0.453, 0.490, 0.517, 0.548, 0.567, 0.619, 0.637, 0.662, 0.716, &
+  0.144, 0.155, 0.167, 0.190, 0.223, 0.237, 0.268, 0.287, 0.353, 0.379, 0.418, 0.530  /
+
+  DATA cg_aeri_6bands/ &
+       ! dust insoluble CI
+  0.718, 0.718, 0.699, 0.661, 0.676, 0.670, &
+       ! bc insoluble AI
+  0.721, 0.721, 0.643, 0.513, 0.321, 0.153, &
+       ! pom insoluble AI
+  0.687, 0.687, 0.658, 0.564, 0.363, 0.142  /
+
+  DATA piz_aers_6bands/&
+       ! bc soluble AS
+  0.460, 0.460, 0.460, 0.460, 0.460, 0.534, 0.594, 0.688, 0.748, 0.754, 0.760, 0.803, &
+  0.460, 0.460, 0.460, 0.460, 0.460, 0.534, 0.594, 0.688, 0.748, 0.754, 0.760, 0.803, &
+  0.445, 0.445, 0.445, 0.445, 0.445, 0.521, 0.583, 0.679, 0.741, 0.747, 0.753, 0.798, &
+  0.394, 0.394, 0.394, 0.394, 0.394, 0.477, 0.545, 0.649, 0.718, 0.724, 0.730, 0.779, &
+  0.267, 0.267, 0.267, 0.267, 0.267, 0.365, 0.446, 0.571, 0.652, 0.660, 0.667, 0.725, &
+  0.121, 0.121, 0.121, 0.121, 0.121, 0.139, 0.155, 0.178, 0.193, 0.195, 0.196, 0.207, &
+       ! pom soluble AS
+  0.973, 0.973, 0.973, 0.973, 0.973, 0.977, 0.980, 0.984, 0.987, 0.988, 0.988, 0.990, &
+  0.973, 0.973, 0.973, 0.973, 0.973, 0.977, 0.980, 0.984, 0.987, 0.988, 0.988, 0.990, &
+  0.972, 0.972, 0.972, 0.972, 0.972, 0.976, 0.979, 0.984, 0.987, 0.987, 0.988, 0.990, &
+  0.940, 0.940, 0.940, 0.940, 0.940, 0.948, 0.955, 0.965, 0.972, 0.973, 0.973, 0.978, &
+  0.816, 0.816, 0.816, 0.816, 0.816, 0.839, 0.859, 0.888, 0.908, 0.910, 0.911, 0.925, &
+  0.663, 0.663, 0.663, 0.663, 0.663, 0.607, 0.562, 0.492, 0.446, 0.441, 0.437, 0.404, &
+       ! sulfate AS
+  1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, &
+  1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, &
+  1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, &
+  1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, &
+  0.988, 0.988, 0.988, 0.989, 0.990, 0.990, 0.991, 0.992, 0.993, 0.993, 0.994, 0.994, &
+  0.256, 0.256, 0.256, 0.263, 0.268, 0.273, 0.277, 0.284, 0.290, 0.294, 0.296, 0.301, &
+       ! sulfate coarse CS
+  1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, &
+  1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, &
+  1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, &
+  1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, &
+  0.996, 0.996, 0.996, 0.996, 0.996, 0.996, 0.996, 0.996, 0.996, 0.996, 0.996, 0.996, &
+  0.877, 0.877, 0.877, 0.873, 0.870, 0.867, 0.864, 0.860, 0.856, 0.854, 0.852, 0.849, &
+       ! seasalt seasalt Super Coarse Soluble (SS)
+  0.983, 0.982, 0.982, 0.982, 0.981, 0.992, 0.993, 0.994, 0.995, 0.996, 0.997, 0.998, &
+  0.984, 0.983, 0.983, 0.983, 0.982, 0.992, 0.993, 0.995, 0.996, 0.996, 0.997, 0.998, &
+  0.986, 0.985, 0.985, 0.985, 0.984, 0.993, 0.994, 0.995, 0.996, 0.997, 0.997, 0.998, &
+  0.989, 0.989, 0.988, 0.988, 0.987, 0.995, 0.995, 0.996, 0.997, 0.997, 0.998, 0.999, &
+  0.994, 0.993, 0.993, 0.992, 0.992, 0.997, 0.997, 0.997, 0.998, 0.998, 0.998, 0.999, &
+  0.997, 0.997, 0.997, 0.997, 0.996, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, &
+       ! seasalt seasalt Coarse Soluble (CS)      
+  0.988, 0.988, 0.988, 0.987, 0.986, 0.994, 0.995, 0.996, 0.996, 0.997, 0.998, 0.998, &
+  0.990, 0.990, 0.990, 0.989, 0.988, 0.995, 0.996, 0.996, 0.997, 0.997, 0.998, 0.999, &
+  0.993, 0.993, 0.992, 0.992, 0.991, 0.996, 0.997, 0.997, 0.998, 0.998, 0.998, 0.999, &
+  0.996, 0.995, 0.995, 0.994, 0.994, 0.998, 0.998, 0.998, 0.998, 0.999, 0.999, 0.999, &
+  0.998, 0.997, 0.997, 0.997, 0.997, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, &
+  0.999, 0.999, 0.998, 0.998, 0.998, 0.999, 0.999, 1.000, 1.000, 1.000, 1.000, 1.000, &
+       ! seasalt seasalt Accumulation Soluble (AS)
+  0.999, 0.999, 0.998, 0.998, 0.998, 0.999, 0.999, 0.999, 0.999, 1.000, 1.000, 1.000, &
+  0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, &
+  0.999, 0.999, 0.999, 0.999, 0.999, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, &
+  0.999, 0.999, 0.999, 0.999, 0.999, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, &
+  0.997, 0.997, 0.998, 0.998, 0.998, 0.999, 0.999, 1.000, 1.000, 1.000, 1.000, 1.000, &
+  0.985, 0.987, 0.988, 0.991, 0.993, 0.997, 0.998, 0.998, 0.999, 0.999, 1.000, 1.000  /
+
+  DATA piz_aeri_6bands/ &
+       ! dust insoluble CI
+  0.954, 0.954, 0.965, 0.981, 0.996, 0.990, &
+       ! bc insoluble AI
+  0.460, 0.460, 0.445, 0.394, 0.267, 0.121, &
+       ! pom insoluble AI
+  0.973, 0.973, 0.972, 0.940, 0.816, 0.663 /
+
+!----BEGINNING OF CALCULATIONS
+
+  spsol = 0
+  spinsol = 0 
+  if(NSW.NE.nbands_rrtm) then
+     print *,'Erreur NSW doit etre egal a 6 pour cette routine'
+     stop
+  endif
+
+  DO k=1, klev
+    DO i=1, klon
+      zrho=pplay(i,k)/t_seri(i,k)/RD                  ! kg/m3
+!CDIR UNROLL=naero_spc
+      mass_temp(i,k,:) = m_allaer(i,k,:) / zrho / 1.e+9
+!CDIR UNROLL=naero_spc
+      mass_temp_pi(i,k,:) = m_allaer_pi(i,k,:) / zrho / 1.e+9
+      zdp1(i,k)=pdel(i,k)/(RG*delt)      ! air mass auxiliary  variable --> zdp1 [kg/(m^2 *s)]
+    ENDDO
+  ENDDO
+
+  IF (flag_aerosol .EQ. 1) THEN 
+     nb_aer = 2
+     ALLOCATE (aerosol_name(nb_aer)) 
+     aerosol_name(1) = id_ASSO4M
+     aerosol_name(2) = id_CSSO4M
+  ELSEIF (flag_aerosol .EQ. 2) THEN
+     nb_aer = 2
+     ALLOCATE (aerosol_name(nb_aer)) 
+     aerosol_name(1) = id_ASBCM
+     aerosol_name(2) = id_AIBCM
+  ELSEIF (flag_aerosol .EQ. 3) THEN 
+     nb_aer = 2
+     ALLOCATE (aerosol_name(nb_aer)) 
+     aerosol_name(1) = id_ASPOMM
+     aerosol_name(2) = id_AIPOMM
+  ELSEIF (flag_aerosol .EQ. 4) THEN 
+     nb_aer = 3
+     ALLOCATE (aerosol_name(nb_aer)) 
+     aerosol_name(1) = id_CSSSM
+     aerosol_name(2) = id_SSSSM
+     aerosol_name(3) = id_ASSSM
+  ELSEIF (flag_aerosol .EQ. 5) THEN 
+     nb_aer = 1
+     ALLOCATE (aerosol_name(nb_aer)) 
+     aerosol_name(1) = id_CIDUSTM
+  ELSEIF (flag_aerosol .EQ. 6) THEN 
+     nb_aer = 10
+     ALLOCATE (aerosol_name(nb_aer)) 
+     aerosol_name(1) = id_ASSO4M      
+     aerosol_name(2) = id_ASBCM
+     aerosol_name(3) = id_AIBCM
+     aerosol_name(4) = id_ASPOMM
+     aerosol_name(5) = id_AIPOMM
+     aerosol_name(6) = id_CSSSM
+     aerosol_name(7) = id_SSSSM
+     aerosol_name(8) = id_ASSSM
+     aerosol_name(9) = id_CIDUSTM
+     aerosol_name(10)= id_CSSO4M
+  ENDIF
+
+  !
+  ! loop over modes, use of precalculated nmd and corresponding sigma
+  !    loop over wavelengths
+  !    for each mass species in mode
+  !      interpolate from Sext to retrieve Sext_at_gridpoint_per_species
+  !      compute optical_thickness_at_gridpoint_per_species
+
+!!CDIR ON_ADB(RH_tab)
+!CDIR ON_ADB(fact_RH)
+!CDIR SHORTLOOP
+  DO n=1,nbre_RH-1
+    fact_RH(n)=1./(RH_tab(n+1)-RH_tab(n))
+  ENDDO
+   
+  DO k=1, KLEV
+!CDIR ON_ADB(fact_RH)
+    DO i=1, KLON
+      rh(i,k)=MIN(RHcl(i,k)*100.,RH_MAX)
+      RH_num(i,k) = INT( rh(i,k)/10. + 1.)
+      IF (rh(i,k).GT.85.) RH_num(i,k)=10
+      IF (rh(i,k).GT.90.) RH_num(i,k)=11
+      delta(i,k)=(rh(i,k)-RH_tab(RH_num(i,k)))*fact_RH(RH_num(i,k))
+    ENDDO
+  ENDDO
+
+  used_aer(:)=.FALSE.
+    
+  DO m=1,nb_aer   ! tau is only computed for each mass
+     fac=1.0
+     IF (aerosol_name(m).EQ.id_ASBCM) THEN
+        soluble=.TRUE.
+        spsol=1
+     ELSEIF (aerosol_name(m).EQ.id_ASPOMM) THEN 
+        soluble=.TRUE.
+        spsol=2 
+     ELSEIF (aerosol_name(m).EQ.id_ASSO4M) THEN 
+        soluble=.TRUE.
+        spsol=3
+        fac=1.375    ! (NH4)2-SO4/SO4 132/96 mass conversion factor for OD
+     ELSEIF  (aerosol_name(m).EQ.id_CSSO4M) THEN
+        soluble=.TRUE.
+        spsol=4
+        fac=1.375    ! (NH4)2-SO4/SO4 132/96 mass conversion factor for OD
+     ELSEIF (aerosol_name(m).EQ.id_SSSSM) THEN 
+         soluble=.TRUE.
+         spsol=5
+     ELSEIF (aerosol_name(m).EQ.id_CSSSM) THEN 
+         soluble=.TRUE.
+         spsol=6
+     ELSEIF (aerosol_name(m).EQ.id_ASSSM) THEN
+         soluble=.TRUE.
+         spsol=7
+     ELSEIF (aerosol_name(m).EQ.id_CIDUSTM) THEN 
+         soluble=.FALSE.
+         spinsol=1
+     ELSEIF  (aerosol_name(m).EQ.id_AIBCM) THEN 
+         soluble=.FALSE.
+         spinsol=2
+     ELSEIF (aerosol_name(m).EQ.id_AIPOMM) THEN 
+         soluble=.FALSE.
+         spinsol=3
+     ELSE 
+         CYCLE
+     ENDIF
+
+    id=aerosol_name(m)
+    used_aer(id)=.TRUE.
+
+    IF (soluble) THEN
+
+       DO k=1, KLEV
+         DO i=1, KLON
+           tmp_var=mass_temp(i,k,spsol)*1000.*zdp1(i,k)*delt*fac
+           tmp_var_pi=mass_temp_pi(i,k,spsol)*1000.*zdp1(i,k)*delt*fac
+
+           DO inu=1,NSW
+
+             tau_ae2b_int= alpha_aers_6bands(RH_num(i,k),inu,spsol)+ & 
+                           delta(i,k)* (alpha_aers_6bands(RH_num(i,k)+1,inu,spsol) - & 
+                           alpha_aers_6bands(RH_num(i,k),inu,spsol))
+                   
+             piz_ae2b_int = piz_aers_6bands(RH_num(i,k),inu,spsol) + & 
+                            delta(i,k)* (piz_aers_6bands(RH_num(i,k)+1,inu,spsol) - & 
+                            piz_aers_6bands(RH_num(i,k),inu,spsol))
+                   
+             cg_ae2b_int = cg_aers_6bands(RH_num(i,k),inu,spsol) + & 
+                           delta(i,k)* (cg_aers_6bands(RH_num(i,k)+1,inu,spsol) - & 
+                           cg_aers_6bands(RH_num(i,k),inu,spsol))
+
+             tau_ae(i,k,id,inu)    = tmp_var*tau_ae2b_int
+             tau_ae_pi(i,k,id,inu) = tmp_var_pi* tau_ae2b_int
+             piz_ae(i,k,id,inu)    = piz_ae2b_int
+             cg_ae(i,k,id,inu)     = cg_ae2b_int
+                      
+           ENDDO
+         ENDDO
+       ENDDO
+        
+     ELSE    ! For all aerosol insoluble components
+
+       DO k=1, KLEV
+         DO i=1, KLON
+           tmp_var=mass_temp(i,k,naero_soluble+ spinsol)*1000.*zdp1(i,k)*delt*fac
+           tmp_var_pi=mass_temp_pi(i,k,naero_soluble+spinsol)*1000.*zdp1(i,k)*delt*fac
+
+           DO inu=1,NSW
+             tau_ae2b_int = alpha_aeri_6bands(inu,spinsol)
+             piz_ae2b_int = piz_aeri_6bands(inu,spinsol)
+             cg_ae2b_int = cg_aeri_6bands(inu,spinsol) 
+
+             tau_ae(i,k,id,inu) = tmp_var*tau_ae2b_int
+             tau_ae_pi(i,k,id,inu) = tmp_var_pi*tau_ae2b_int
+             piz_ae(i,k,id,inu) = piz_ae2b_int
+             cg_ae(i,k,id,inu)= cg_ae2b_int
+           ENDDO
+         ENDDO
+       ENDDO
+
+     ENDIF ! soluble / insoluble
+
+  ENDDO  ! nb_aer  
+
+  DO m=1,naero_tot
+    IF (.NOT. used_aer(m)) THEN
+      tau_ae(:,:,m,:)=0.
+      tau_ae_pi(:,:,m,:)=0.
+      piz_ae(:,:,m,:)=0.
+      cg_ae(:,:,m,:)=0.
+    ENDIF
+  ENDDO
+
+  DO inu=1, NSW 
+     DO k=1, KLEV
+       DO i=1, KLON
+!--anthropogenic aerosol
+         tau_allaer(i,k,2,inu)=tau_ae(i,k,id_ASSO4M,inu)+tau_ae(i,k,id_CSSO4M,inu)+ &
+                               tau_ae(i,k,id_ASBCM,inu)+tau_ae(i,k,id_AIBCM,inu)+   &
+                               tau_ae(i,k,id_ASPOMM,inu)+tau_ae(i,k,id_AIPOMM,inu)+ &
+                               tau_ae(i,k,id_ASSSM,inu)+tau_ae(i,k,id_CSSSM,inu)+   &
+                               tau_ae(i,k,id_SSSSM,inu)+ tau_ae(i,k,id_CIDUSTM,inu)
+         tau_allaer(i,k,2,inu)=MAX(tau_allaer(i,k,2,inu),1e-5)
+
+         piz_allaer(i,k,2,inu)=(tau_ae(i,k,id_ASSO4M,inu)*piz_ae(i,k,id_ASSO4M,inu)+ &
+                                tau_ae(i,k,id_CSSO4M,inu)*piz_ae(i,k,id_CSSO4M,inu)+ &
+                                tau_ae(i,k,id_ASBCM,inu)*piz_ae(i,k,id_ASBCM,inu)+ &
+                                tau_ae(i,k,id_AIBCM,inu)*piz_ae(i,k,id_AIBCM,inu)+ &
+                                tau_ae(i,k,id_ASPOMM,inu)*piz_ae(i,k,id_ASPOMM,inu)+ &
+                                tau_ae(i,k,id_AIPOMM,inu)*piz_ae(i,k,id_AIPOMM,inu)+ &
+                                tau_ae(i,k,id_ASSSM,inu)*piz_ae(i,k,id_ASSSM,inu)+ &
+                                tau_ae(i,k,id_CSSSM,inu)*piz_ae(i,k,id_CSSSM,inu)+ &
+                                tau_ae(i,k,id_SSSSM,inu)*piz_ae(i,k,id_SSSSM,inu)+ &
+                                tau_ae(i,k,id_CIDUSTM,inu)*piz_ae(i,k,id_CIDUSTM,inu)) &
+                                /tau_allaer(i,k,2,inu)
+         piz_allaer(i,k,2,inu)=MAX(piz_allaer(i,k,2,inu),0.1)
+
+         cg_allaer(i,k,2,inu)=(tau_ae(i,k,id_ASSO4M,inu)*piz_ae(i,k,id_ASSO4M,inu)*cg_ae(i,k,id_ASSO4M,inu)+ &
+                               tau_ae(i,k,id_CSSO4M,inu)*piz_ae(i,k,id_CSSO4M,inu)*cg_ae(i,k,id_CSSO4M,inu)+ &
+                               tau_ae(i,k,id_ASBCM,inu)*piz_ae(i,k,id_ASBCM,inu)*cg_ae(i,k,id_ASBCM,inu)+ &
+                               tau_ae(i,k,id_AIBCM,inu)*piz_ae(i,k,id_AIBCM,inu)*cg_ae(i,k,id_AIBCM,inu)+ &
+                               tau_ae(i,k,id_ASPOMM,inu)*piz_ae(i,k,id_ASPOMM,inu)*cg_ae(i,k,id_ASPOMM,inu)+ &
+                               tau_ae(i,k,id_AIPOMM,inu)*piz_ae(i,k,id_AIPOMM,inu)*cg_ae(i,k,id_AIPOMM,inu)+ &
+                               tau_ae(i,k,id_ASSSM,inu)*piz_ae(i,k,id_ASSSM,inu)*cg_ae(i,k,id_ASSSM,inu)+ &
+                               tau_ae(i,k,id_CSSSM,inu)*piz_ae(i,k,id_CSSSM,inu)*cg_ae(i,k,id_CSSSM,inu)+ &
+                               tau_ae(i,k,id_SSSSM,inu)*piz_ae(i,k,id_SSSSM,inu)*cg_ae(i,k,id_SSSSM,inu)+ &
+                               tau_ae(i,k,id_CIDUSTM,inu)*piz_ae(i,k,id_CIDUSTM,inu)*cg_ae(i,k,id_CIDUSTM,inu))/ &
+                               (tau_allaer(i,k,2,inu)*piz_allaer(i,k,2,inu))
+
+!--natural aerosol
+         tau_allaer(i,k,1,inu)=tau_ae_pi(i,k,id_ASSO4M,inu)+tau_ae_pi(i,k,id_CSSO4M,inu)+ &
+                               tau_ae_pi(i,k,id_ASBCM,inu)+tau_ae_pi(i,k,id_AIBCM,inu)+   &
+                               tau_ae_pi(i,k,id_ASPOMM,inu)+tau_ae_pi(i,k,id_AIPOMM,inu)+ &
+                               tau_ae_pi(i,k,id_ASSSM,inu)+tau_ae_pi(i,k,id_CSSSM,inu)+   &
+                               tau_ae_pi(i,k,id_SSSSM,inu)+ tau_ae_pi(i,k,id_CIDUSTM,inu)
+         tau_allaer(i,k,1,inu)=MAX(tau_allaer(i,k,1,inu),1e-5)
+
+         piz_allaer(i,k,1,inu)=(tau_ae_pi(i,k,id_ASSO4M,inu)*piz_ae(i,k,id_ASSO4M,inu)+ &
+                                tau_ae_pi(i,k,id_CSSO4M,inu)*piz_ae(i,k,id_CSSO4M,inu)+ &
+                                tau_ae_pi(i,k,id_ASBCM,inu)*piz_ae(i,k,id_ASBCM,inu)+ &
+                                tau_ae_pi(i,k,id_AIBCM,inu)*piz_ae(i,k,id_AIBCM,inu)+ &
+                                tau_ae_pi(i,k,id_ASPOMM,inu)*piz_ae(i,k,id_ASPOMM,inu)+ &
+                                tau_ae_pi(i,k,id_AIPOMM,inu)*piz_ae(i,k,id_AIPOMM,inu)+ &
+                                tau_ae_pi(i,k,id_ASSSM,inu)*piz_ae(i,k,id_ASSSM,inu)+ &
+                                tau_ae_pi(i,k,id_CSSSM,inu)*piz_ae(i,k,id_CSSSM,inu)+ &
+                                tau_ae_pi(i,k,id_SSSSM,inu)*piz_ae(i,k,id_SSSSM,inu)+ &
+                                tau_ae_pi(i,k,id_CIDUSTM,inu)*piz_ae(i,k,id_CIDUSTM,inu)) &
+                                /tau_allaer(i,k,1,inu)
+         piz_allaer(i,k,1,inu)=MAX(piz_allaer(i,k,1,inu),0.1)
+
+         cg_allaer(i,k,1,inu)=(tau_ae_pi(i,k,id_ASSO4M,inu)*piz_ae(i,k,id_ASSO4M,inu)*cg_ae(i,k,id_ASSO4M,inu)+ &
+                               tau_ae_pi(i,k,id_CSSO4M,inu)*piz_ae(i,k,id_CSSO4M,inu)*cg_ae(i,k,id_CSSO4M,inu)+ &
+                               tau_ae_pi(i,k,id_ASBCM,inu)*piz_ae(i,k,id_ASBCM,inu)*cg_ae(i,k,id_ASBCM,inu)+ &
+                               tau_ae_pi(i,k,id_AIBCM,inu)*piz_ae(i,k,id_AIBCM,inu)*cg_ae(i,k,id_AIBCM,inu)+ &
+                               tau_ae_pi(i,k,id_ASPOMM,inu)*piz_ae(i,k,id_ASPOMM,inu)*cg_ae(i,k,id_ASPOMM,inu)+ &
+                               tau_ae_pi(i,k,id_AIPOMM,inu)*piz_ae(i,k,id_AIPOMM,inu)*cg_ae(i,k,id_AIPOMM,inu)+ &
+                               tau_ae_pi(i,k,id_ASSSM,inu)*piz_ae(i,k,id_ASSSM,inu)*cg_ae(i,k,id_ASSSM,inu)+ &
+                               tau_ae_pi(i,k,id_CSSSM,inu)*piz_ae(i,k,id_CSSSM,inu)*cg_ae(i,k,id_CSSSM,inu)+ &
+                               tau_ae_pi(i,k,id_SSSSM,inu)*piz_ae(i,k,id_SSSSM,inu)*cg_ae(i,k,id_SSSSM,inu)+ &
+                               tau_ae_pi(i,k,id_CIDUSTM,inu)*piz_ae(i,k,id_CIDUSTM,inu)*cg_ae(i,k,id_CIDUSTM,inu))/ &
+                               (tau_allaer(i,k,1,inu)*piz_allaer(i,k,1,inu))
+
+        ENDDO
+      ENDDO
+    ENDDO
+   
+!--???????
+  inu=1
+  DO i=1, KLON
+     absvisaer(i)=SUM((1-piz_allaer(i,:,:,inu))*tau_allaer(i,:,:,inu))
+  END DO	
+
+  DEALLOCATE(aerosol_name) 
+
+END SUBROUTINE AEROPT_6BANDS_RRTM
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/eq_regions_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/eq_regions_mod.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/eq_regions_mod.F90	(revision 2056)
@@ -78,4 +78,7 @@
 integer(kind=jpim) :: my_region_ew
 integer(kind=jpim),allocatable :: n_regions(:)
+
+
+!$OMP THREADPRIVATE(l_regions_debug,my_region_ew,my_region_ns,n_regions_ew,n_regions_ns,pi,n_regions)
 
 CONTAINS
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/gfl_subs.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/gfl_subs.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/gfl_subs.F90	(revision 2056)
@@ -53,4 +53,6 @@
 TYPE(TYPE_GFL_COMP)  :: YCPF_SAVE ! For saving status of cloud fields
 LOGICAL :: L_CLD_DEACT=.FALSE.
+
+!$OMP THREADPRIVATE(l_cld_deact,ya_save,ycpf_save,yi_save,yl_save,ylastgflc,yptrc,yr_save,ys_save)
 
 #include "abor1.intfb.h"
@@ -115,4 +117,6 @@
 LOGICAL,SAVE :: LLFIRSTCALL = .TRUE.
 REAL(KIND=JPRB) :: ZHOOK_HANDLE
+!$OMP THREADPRIVATE(llfirstcall)
+
 
 !-------------------------------------------------------------------------
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/lwu.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/lwu.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/lwu.F90	(revision 2056)
@@ -1,2 +1,5 @@
+!
+! $Id$
+!
 SUBROUTINE LWU &
  & ( KIDIA, KFDIA, KLON, KLEV,&
@@ -69,6 +72,7 @@
  & ALWT     ,BLWT     ,RO3T     ,RT1      ,TREF     ,&
  & RVGCO2   ,RVGH2O   ,RVGO3  
-USE YOERDI   , ONLY : RCH4     ,RN2O     ,RCFC11   ,RCFC12
+!USE YOERDI   , ONLY : RCH4     ,RN2O     ,RCFC11   ,RCFC12
 USE YOERDU   , ONLY : R10E     ,REPSCO   ,REPSCQ
+
 
 IMPLICIT NONE
@@ -87,4 +91,6 @@
 REAL(KIND=JPRB)   ,INTENT(IN)    :: PWV(KLON,KLEV) 
 REAL(KIND=JPRB)   ,INTENT(OUT)   :: PABCU(KLON,NUA,3*KLEV+1) 
+
+#include "clesphys.h"
 !-----------------------------------------------------------------------
 
@@ -115,4 +121,5 @@
  & ZUPMH2O, ZUPMO3, ZZABLY  
 REAL(KIND=JPRB) :: ZHOOK_HANDLE
+
 
 !-----------------------------------------------------------------------
@@ -331,4 +338,6 @@
 !      print *,'END OF LWU'
 
+
+
 !-----------------------------------------------------------------------
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/mod_const_para.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/mod_const_para.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/mod_const_para.F90	(revision 2056)
@@ -3,5 +3,6 @@
   INTEGER :: COMM_LMDZ
   INTEGER :: MPI_REAL_LMDZ
- 
+
+!$OMP THREADPRIVATE(comm_lmdz,mpi_real_lmdz)
 
 CONTAINS 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/radlsw.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/radlsw.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/radlsw.F90	(revision 2056)
@@ -144,5 +144,5 @@
  & RLILIA   ,RLILIB  
 USE YOERDU        , ONLY : NUAER    ,NTRAER   ,REPLOG   ,REPSC    ,REPSCW   ,DIFF
-USE YOETHF        , ONLY : RTICE
+!USE YOETHF        , ONLY : RTICE
 USE YOEPHLI       , ONLY : LPHYLIN
 USE YOERRTWN      , ONLY :                     DELWAVE   ,TOTPLNK   
@@ -154,5 +154,5 @@
 
 include "clesphys.h"
-
+include "YOETHF.h"
 INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
 INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/readaerosol_optic_rrtm.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/readaerosol_optic_rrtm.F90	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/readaerosol_optic_rrtm.F90	(revision 2056)
@@ -0,0 +1,215 @@
+! $Id$
+!
+SUBROUTINE readaerosol_optic_rrtm(debut, new_aod, flag_aerosol, itap, rjourvrai, &
+     pdtphys, pplay, paprs, t_seri, rhcl, presnivs, &
+     mass_solu_aero, mass_solu_aero_pi, &
+     tau_aero, piz_aero, cg_aero, &
+     tausum_aero, tau3d_aero )
+
+! This routine will :
+! 1) recevie the aerosols(already read and interpolated) corresponding to flag_aerosol
+! 2) calculate the optical properties for the aerosols
+!
+  
+  USE dimphy
+  USE aero_mod
+  USE phys_local_var_mod, only: sconcso4,sconcoa,sconcbc,sconcss,sconcdust, &
+      concso4,concoa,concbc,concss,concdust,loadso4,loadoa,loadbc,loadss,loaddust, &
+      load_tmp1,load_tmp2,load_tmp3,load_tmp4,load_tmp5,load_tmp6,load_tmp7
+  IMPLICIT NONE
+  include "clesphys.h"
+
+! Input arguments
+!****************************************************************************************
+  LOGICAL, INTENT(IN)                      :: debut
+  LOGICAL, INTENT(IN)                      :: new_aod
+  INTEGER, INTENT(IN)                      :: flag_aerosol
+  INTEGER, INTENT(IN)                      :: itap
+  REAL, INTENT(IN)                         :: rjourvrai
+  REAL, INTENT(IN)                         :: pdtphys
+  REAL, DIMENSION(klon,klev), INTENT(IN)   :: pplay
+  REAL, DIMENSION(klon,klev+1), INTENT(IN) :: paprs
+  REAL, DIMENSION(klon,klev), INTENT(IN)   :: t_seri
+  REAL, DIMENSION(klon,klev), INTENT(IN)   :: rhcl   ! humidite relative ciel clair
+  REAL, DIMENSION(klev), INTENT(IN)        :: presnivs
+
+! Output arguments
+!****************************************************************************************
+  REAL, DIMENSION(klon,klev), INTENT(OUT)     :: mass_solu_aero    ! Total mass for all soluble aerosols
+  REAL, DIMENSION(klon,klev), INTENT(OUT)     :: mass_solu_aero_pi !     -"-     preindustrial values
+  REAL, DIMENSION(klon,klev,2,NSW), INTENT(OUT) :: tau_aero    ! Aerosol optical thickness
+  REAL, DIMENSION(klon,klev,2,NSW), INTENT(OUT) :: piz_aero    ! Single scattering albedo aerosol
+  REAL, DIMENSION(klon,klev,2,NSW), INTENT(OUT) :: cg_aero     ! asymmetry parameter aerosol
+!  REAL, DIMENSION(klon,nwave,naero_spc), INTENT(OUT)       :: tausum_aero
+!  REAL, DIMENSION(klon,klev,nwave,naero_spc), INTENT(OUT)  :: tau3d_aero
+!--correction minibug OB
+  REAL, DIMENSION(klon,nwave,naero_tot), INTENT(OUT)       :: tausum_aero
+  REAL, DIMENSION(klon,klev,nwave,naero_tot), INTENT(OUT)  :: tau3d_aero
+
+! Local variables
+!****************************************************************************************
+  REAL, DIMENSION(klon)        :: aerindex ! POLDER aerosol index 
+  REAL, DIMENSION(klon,klev)   :: sulfate  ! SO4 aerosol concentration [ug/m3]
+  REAL, DIMENSION(klon,klev)   :: bcsol    ! BC soluble concentration [ug/m3]
+  REAL, DIMENSION(klon,klev)   :: bcins    ! BC insoluble concentration [ug/m3]
+  REAL, DIMENSION(klon,klev)   :: pomsol   ! POM soluble concentration [ug/m3]
+  REAL, DIMENSION(klon,klev)   :: pomins   ! POM insoluble concentration [ug/m3]
+  REAL, DIMENSION(klon,klev)   :: cidust    ! DUST aerosol concentration  [ug/m3]
+  REAL, DIMENSION(klon,klev)   :: sscoarse  ! SS Coarse concentration [ug/m3]
+  REAL, DIMENSION(klon,klev)   :: sssupco   ! SS Super Coarse concentration [ug/m3]
+  REAL, DIMENSION(klon,klev)   :: ssacu     ! SS Acumulation concentration [ug/m3]
+  REAL, DIMENSION(klon,klev)   :: sulfate_pi
+  REAL, DIMENSION(klon,klev)   :: bcsol_pi
+  REAL, DIMENSION(klon,klev)   :: bcins_pi
+  REAL, DIMENSION(klon,klev)   :: pomsol_pi
+  REAL, DIMENSION(klon,klev)   :: pomins_pi
+  REAL, DIMENSION(klon,klev)   :: cidust_pi
+  REAL, DIMENSION(klon,klev)   :: sscoarse_pi
+  REAL, DIMENSION(klon,klev)   :: sssupco_pi
+  REAL, DIMENSION(klon,klev)   :: ssacu_pi
+  REAL, DIMENSION(klon,klev)   :: pdel
+  REAL, DIMENSION(klon,klev,naero_spc) :: m_allaer
+  REAL, DIMENSION(klon,klev,naero_spc) :: m_allaer_pi !RAF  
+!  REAL, DIMENSION(klon,naero_tot)      :: fractnat_allaer !RAF delete??
+
+  INTEGER :: k, i
+  
+!****************************************************************************************
+! 1) Get aerosol mass
+!    
+!****************************************************************************************
+! Read and interpolate sulfate
+  IF ( flag_aerosol .EQ. 1 .OR. &
+       flag_aerosol .EQ. 6 ) THEN 
+
+     CALL readaerosol_interp(id_ASSO4M, itap, pdtphys, rjourvrai, debut, pplay, paprs, t_seri, sulfate, sulfate_pi,loadso4)
+  ELSE
+     sulfate(:,:) = 0. ; sulfate_pi(:,:) = 0.
+     loadso4=0.
+  END IF
+
+! Read and interpolate bcsol and bcins
+  IF ( flag_aerosol .EQ. 2 .OR. &
+       flag_aerosol .EQ. 6 ) THEN 
+
+     ! Get bc aerosol distribution 
+     CALL readaerosol_interp(id_ASBCM, itap, pdtphys, rjourvrai, debut, pplay, paprs, t_seri, bcsol, bcsol_pi, load_tmp1 )
+     CALL readaerosol_interp(id_AIBCM, itap, pdtphys, rjourvrai, debut, pplay, paprs, t_seri, bcins, bcins_pi, load_tmp2 )
+     loadbc(:)=load_tmp1(:)+load_tmp2(:)
+  ELSE
+     bcsol(:,:) = 0. ; bcsol_pi(:,:) = 0.
+     bcins(:,:) = 0. ; bcins_pi(:,:) = 0.
+     loadbc=0.
+  END IF
+
+
+! Read and interpolate pomsol and pomins
+  IF ( flag_aerosol .EQ. 3 .OR. &
+       flag_aerosol .EQ. 6 ) THEN
+
+     CALL readaerosol_interp(id_ASPOMM, itap, pdtphys, rjourvrai, debut, pplay, paprs, t_seri, pomsol, pomsol_pi, load_tmp3)
+     CALL readaerosol_interp(id_AIPOMM, itap, pdtphys, rjourvrai, debut, pplay, paprs, t_seri, pomins, pomins_pi, load_tmp4)
+     loadoa(:)=load_tmp3(:)+load_tmp4(:)
+  ELSE
+     pomsol(:,:) = 0. ; pomsol_pi(:,:) = 0.
+     pomins(:,:) = 0. ; pomins_pi(:,:) = 0.
+     loadoa=0.
+  END IF
+
+
+! Read and interpolate csssm, ssssm, assssm
+  IF (flag_aerosol .EQ. 4 .OR. &
+      flag_aerosol .EQ. 6 ) THEN 
+
+      CALL readaerosol_interp(id_SSSSM ,itap, pdtphys, rjourvrai, debut, pplay, paprs, t_seri, sssupco, sssupco_pi, load_tmp5) 
+      CALL readaerosol_interp(id_CSSSM ,itap, pdtphys, rjourvrai, debut, pplay, paprs, t_seri, sscoarse,sscoarse_pi, load_tmp6) 
+      CALL readaerosol_interp(id_ASSSM ,itap, pdtphys, rjourvrai, debut, pplay, paprs, t_seri, ssacu, ssacu_pi, load_tmp7) 
+     loadss(:)=load_tmp5(:)+load_tmp6(:)+load_tmp7(:)
+  ELSE
+     sscoarse(:,:) = 0. ; sscoarse_pi(:,:) = 0. 
+     ssacu(:,:)    = 0. ; ssacu_pi(:,:) = 0. 
+     sssupco(:,:)  = 0. ; sssupco_pi = 0. 
+     loadss=0.
+  ENDIF
+
+! Read and interpolate cidustm
+  IF (flag_aerosol .EQ. 5 .OR.  &
+      flag_aerosol .EQ. 6 ) THEN 
+
+      CALL readaerosol_interp(id_CIDUSTM, itap, pdtphys, rjourvrai, debut, pplay, paprs, t_seri, cidust, cidust_pi, loaddust) 
+
+  ELSE
+      cidust(:,:) = 0. ; cidust_pi(:,:) = 0. 
+      loaddust=0.
+  ENDIF
+
+!
+! Store all aerosols in one variable
+!
+  m_allaer(:,:,id_ASBCM)  = bcsol(:,:)        ! ASBCM
+  m_allaer(:,:,id_ASPOMM) = pomsol(:,:)       ! ASPOMM
+  m_allaer(:,:,id_ASSO4M) = sulfate(:,:)      ! ASSO4M (= SO4) 
+  m_allaer(:,:,id_CSSO4M) = 0.                ! CSSO4M 
+  m_allaer(:,:,id_SSSSM)  = sssupco(:,:)      ! SSSSM
+  m_allaer(:,:,id_CSSSM)  = sscoarse(:,:)     ! CSSSM
+  m_allaer(:,:,id_ASSSM)  = ssacu(:,:)        ! ASSSM
+  m_allaer(:,:,id_CIDUSTM)= cidust(:,:)       ! CIDUSTM
+  m_allaer(:,:,id_AIBCM)  = bcins(:,:)        ! AIBCM
+  m_allaer(:,:,id_AIPOMM) = pomins(:,:)       ! AIPOMM
+
+!RAF
+  m_allaer_pi(:,:,1)  = bcsol_pi(:,:)        ! ASBCM pre-ind
+  m_allaer_pi(:,:,2)  = pomsol_pi(:,:)       ! ASPOMM pre-ind
+  m_allaer_pi(:,:,3)  = sulfate_pi(:,:)      ! ASSO4M (= SO4) pre-ind
+  m_allaer_pi(:,:,4)  = 0.                   ! CSSO4M pre-ind
+  m_allaer_pi(:,:,5)  = sssupco_pi(:,:)      ! SSSSM pre-ind
+  m_allaer_pi(:,:,6)  = sscoarse_pi(:,:)     ! CSSSM pre-ind
+  m_allaer_pi(:,:,7)  = ssacu_pi(:,:)        ! ASSSM pre-ind
+  m_allaer_pi(:,:,8)  = cidust_pi(:,:)       ! CIDUSTM pre-ind
+  m_allaer_pi(:,:,9)  = bcins_pi(:,:)        ! AIBCM pre-ind
+  m_allaer_pi(:,:,10) = pomins_pi(:,:)       ! AIPOMM pre-ind
+
+!
+! Calculate the total mass of all soluble aersosols
+!
+  mass_solu_aero(:,:)    = sulfate(:,:)    + bcsol(:,:)    + pomsol(:,:) !   + &
+!       sscoarse(:,:)    + ssacu(:,:)    + sssupco(:,:) 
+  mass_solu_aero_pi(:,:) = sulfate_pi(:,:) + bcsol_pi(:,:) + pomsol_pi(:,:) ! + &
+!       sscoarse_pi(:,:) + ssacu_pi(:,:) + sssupco_pi(:,:)
+
+!****************************************************************************************
+! 2) Calculate optical properties for the aerosols
+!
+!****************************************************************************************
+  DO k = 1, klev
+     DO i = 1, klon
+        pdel(i,k) = paprs(i,k) - paprs (i,k+1)
+     END DO
+  END DO
+
+  CALL aeropt_6bands_rrtm( &
+          pdel, m_allaer, pdtphys, rhcl, & 
+          tau_aero, piz_aero, cg_aero,   &
+          m_allaer_pi, flag_aerosol, &
+          pplay, t_seri, presnivs) 
+     
+     ! aeropt_5wv only for validation and diagnostics.
+     CALL aeropt_5wv_rrtm(                    &
+          pdel, m_allaer,                &
+          pdtphys, rhcl, aerindex,       & 
+          flag_aerosol, pplay, t_seri,   &
+          tausum_aero, tau3d_aero )
+
+! Diagnostics calculation for CMIP5 protocol
+  sconcso4(:)=m_allaer(:,1,id_ASSO4M)*1.e-9
+  sconcoa(:)=(m_allaer(:,1,id_ASPOMM)+m_allaer(:,1,id_AIPOMM))*1.e-9
+  sconcbc(:)=(m_allaer(:,1,id_ASBCM)+m_allaer(:,1,id_AIBCM))*1.e-9
+  sconcss(:)=(m_allaer(:,1,id_ASSSM)+m_allaer(:,1,id_CSSSM)+m_allaer(:,1,id_SSSSM))*1.e-9
+  sconcdust(:)=m_allaer(:,1,id_CIDUSTM)*1.e-9
+  concso4(:,:)=m_allaer(:,:,id_ASSO4M)*1.e-9
+  concoa(:,:)=(m_allaer(:,:,id_ASPOMM)+m_allaer(:,:,id_AIPOMM))*1.e-9
+  concbc(:,:)=(m_allaer(:,:,id_ASBCM)+m_allaer(:,:,id_AIBCM))*1.e-9
+  concss(:,:)=(m_allaer(:,:,id_ASSSM)+m_allaer(:,:,id_CSSSM)+m_allaer(:,:,id_SSSSM))*1.e-9
+  concdust(:,:)=m_allaer(:,:,id_CIDUSTM)*1.e-9
+
+END SUBROUTINE readaerosol_optic_rrtm
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/readaerosolstrato_rrtm.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/readaerosolstrato_rrtm.F90	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/readaerosolstrato_rrtm.F90	(revision 2056)
@@ -0,0 +1,175 @@
+!
+! $Id$
+!
+subroutine readaerosolstrato_rrtm(debut)
+
+    use netcdf95, only: nf95_close, nf95_gw_var, nf95_inq_dimid, & 
+                        nf95_inq_varid, nf95_open
+    use netcdf, only: nf90_get_var, nf90_noerr, nf90_nowrite
+
+    USE phys_cal_mod, ONLY : mth_cur
+    USE mod_grid_phy_lmdz
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    USE mod_phys_lmdz_para 
+    USE phys_state_var_mod
+    USE phys_local_var_mod
+    USE aero_mod
+    USE dimphy
+
+    implicit none
+
+    include "YOMCST.h"
+    include "dimensions.h"
+
+! Variable input
+    logical debut
+
+! Variables locales
+    integer n_lat   ! number of latitudes in the input data
+    integer n_lon   ! number of longitudes in the input data
+    integer n_lev   ! number of levels in the input data
+    integer n_month ! number of months in the input data
+    real, pointer:: latitude(:)
+    real, pointer:: longitude(:)
+    real, pointer:: time(:)
+    real, pointer:: lev(:)
+    integer k, band, wave
+    integer, save :: mth_pre
+
+    real, allocatable, dimension(:,:), save :: tau_aer_strat
+!$OMP THREADPRIVATE(tau_aer_strat)
+
+! Champs reconstitues
+    real, allocatable:: tauaerstrat(:, :, :, :)
+    real, allocatable:: tauaerstrat_mois(:, :, :)
+    real, allocatable:: tauaerstrat_mois_glo(:, :)
+    real, allocatable:: tauaerstrat_mois_glo_bands(:,:,:)
+
+! For NetCDF:
+    integer ncid_in  ! IDs for input files
+    integer varid, ncerr
+
+! Stratospheric aerosols optical properties
+! alpha_strat over the 2 bands is normalised by the 550 nm extinction coefficient
+! alpha_strat_wave is *not* normalised by the 550 nm extinction coefficient
+    real, dimension(nbands_rrtm) :: alpha_strat, piz_strat, cg_strat
+    data alpha_strat/0.938538969, 0.990073204, 0.992904723, 0.829215884, 0.439313501, 0.156857833/
+    data cg_strat   /0.699142992, 0.716326416, 0.735462785, 0.736726701, 0.712068975, 0.575097859/
+    data piz_strat  /1.000000000, 1.000000000, 1.000000000, 1.000000000, 0.997781098, 0.452584684/
+    real, dimension(nwave) :: alpha_strat_wave
+    data alpha_strat_wave/3.36780953,3.34667683,3.20444202,3.0293026,2.82108808/
+
+!--------------------------------------------------------
+
+    IF (.not.ALLOCATED(tau_aer_strat)) ALLOCATE(tau_aer_strat(klon,klev))
+
+    IF (is_mpi_root) THEN
+
+    IF (debut.OR.mth_cur.NE.mth_pre) THEN
+
+    IF (nbands_rrtm.NE.6) THEN 
+        print *,'nbands_rrtm doit etre egal a 6 dans readaerosolstrat_rrtm'
+        STOP
+    ENDIF
+
+    CALL nf95_open("taustrat.nc", nf90_nowrite, ncid_in)
+
+    CALL nf95_inq_varid(ncid_in, "LEV", varid)
+    CALL nf95_gw_var(ncid_in, varid, lev)
+    n_lev = size(lev)
+    IF (n_lev.NE.klev) THEN 
+       print *,'Le nombre de niveaux n est pas egal a klev'
+       STOP
+    ENDIF
+
+    CALL nf95_inq_varid(ncid_in, "LAT", varid)
+    CALL nf95_gw_var(ncid_in, varid, latitude)
+    n_lat = size(latitude)
+    print *, 'LAT aerosol strato=', n_lat, latitude
+    IF (n_lat.NE.jjm+1) THEN 
+       print *,'Le nombre de lat n est pas egal a jjm+1'
+       STOP
+    ENDIF
+
+    CALL nf95_inq_varid(ncid_in, "LON", varid)
+    CALL nf95_gw_var(ncid_in, varid, longitude)
+    n_lon = size(longitude)
+    print *, 'LON aerosol strato=', n_lon, longitude
+    IF (n_lon.NE.iim) THEN 
+       print *,'Le nombre de lon n est pas egal a iim'
+       STOP
+    ENDIF
+
+    CALL nf95_inq_varid(ncid_in, "TIME", varid)
+    CALL nf95_gw_var(ncid_in, varid, time)
+    n_month = size(time)
+    print *, 'TIME aerosol strato=', n_month, time
+    IF (n_month.NE.12) THEN 
+       print *,'Le nombre de month n est pas egal a 12'
+       STOP
+    ENDIF
+
+    ALLOCATE(tauaerstrat(n_lon, n_lat, n_lev, n_month))
+    ALLOCATE(tauaerstrat_mois(n_lon, n_lat, n_lev))
+    ALLOCATE(tauaerstrat_mois_glo(klon_glo, n_lev))
+    ALLOCATE(tauaerstrat_mois_glo_bands(klon_glo, n_lev,nbands_rrtm))
+
+!--reading stratospheric AOD at 550 nm
+    CALL nf95_inq_varid(ncid_in, "TAUSTRAT", varid)
+    ncerr = nf90_get_var(ncid_in, varid, tauaerstrat)
+    print *,'code erreur readaerosolstrato=', ncerr, varid
+
+    CALL nf95_close(ncid_in)
+
+!---select the correct month
+    IF (mth_cur.LT.1.OR.mth_cur.GT.12) THEN
+      print *,'probleme avec le mois dans readaerosolstrat =', mth_cur
+    ENDIF
+    tauaerstrat_mois(:,:,:) = tauaerstrat(:,:,:,mth_cur)
+
+!---reduce to a klon_glo grid 
+    CALL grid2dTo1d_glo(tauaerstrat_mois,tauaerstrat_mois_glo)
+
+!--scatter on all proc
+    CALL scatter(tauaerstrat_mois_glo,tau_aer_strat)
+
+    DEALLOCATE(tauaerstrat)
+    DEALLOCATE(tauaerstrat_mois)
+    DEALLOCATE(tauaerstrat_mois_glo)
+  
+    mth_pre=mth_cur
+
+    ENDIF !--debut ou nouveau mois
+
+    ENDIF !--is_mpi_root
+
+!--total vertical aod at the 5 wavelengths
+    DO wave=1, nwave
+    DO k=1, klev
+    tausum_aero(:,wave,id_strat)=tausum_aero(:,wave,id_strat)+tau_aer_strat(:,k)*alpha_strat_wave(wave)/alpha_strat_wave(2)
+    ENDDO
+    ENDDO
+
+!--weighted average for cg, piz and tau, adding strat aerosols on top of tropospheric ones
+    DO band=1, nbands_rrtm
+!--anthropogenic aerosols bands 1 to nbands_rrtm 
+    cg_aero_rrtm(:,:,2,band)  = ( cg_aero_rrtm(:,:,2,band)*piz_aero_rrtm(:,:,2,band)*tau_aero_rrtm(:,:,2,band) + &
+                                  cg_strat(band)*piz_strat(band)*alpha_strat(band)*tau_aer_strat(:,:) ) /        &
+                             MAX( piz_aero_rrtm(:,:,2,band)*tau_aero_rrtm(:,:,2,band) +                          &
+                                  piz_strat(band)*alpha_strat(band)*tau_aer_strat(:,:), 1.e-15 )
+    piz_aero_rrtm(:,:,2,band)  = ( piz_aero_rrtm(:,:,2,band)*tau_aero_rrtm(:,:,2,band) +                         &
+                              piz_strat(band)*alpha_strat(band)*tau_aer_strat(:,:) ) /                           &
+                              MAX( tau_aero_rrtm(:,:,2,band) + alpha_strat(band)*tau_aer_strat(:,:), 1.e-15 )
+    tau_aero_rrtm(:,:,2,band)  = tau_aero_rrtm(:,:,2,band) + alpha_strat(band)*tau_aer_strat(:,:)
+!--natural aerosols bands 1 to nbands_rrtm
+    cg_aero_rrtm(:,:,1,band)  = ( cg_aero_rrtm(:,:,1,band)*piz_aero_rrtm(:,:,1,band)*tau_aero_rrtm(:,:,1,band) + &
+                             cg_strat(band)*piz_strat(band)*alpha_strat(band)*tau_aer_strat(:,:) ) /             &
+                             MAX( piz_aero_rrtm(:,:,1,band)*tau_aero_rrtm(:,:,1,band) +                          &
+                                  piz_strat(band)*alpha_strat(band)*tau_aer_strat(:,:), 1.e-15 )
+    piz_aero_rrtm(:,:,1,band)  = ( piz_aero_rrtm(:,:,1,band)*tau_aero_rrtm(:,:,1,band) +                         & 
+                              piz_strat(band)*alpha_strat(band)*tau_aer_strat(:,:) ) /                           &
+                              MAX( tau_aero_rrtm(:,:,1,band) + alpha_strat(band)*tau_aer_strat(:,:),1.e-15 )
+    tau_aero_rrtm(:,:,1,band)  = tau_aero_rrtm(:,:,1,band) + alpha_strat(band)*tau_aer_strat(:,:)
+    ENDDO
+
+end subroutine readaerosolstrato_rrtm
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/recmwf_aero.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/recmwf_aero.F90	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/recmwf_aero.F90	(revision 2056)
@@ -0,0 +1,795 @@
+!
+! $Id$
+!
+!OPTIONS XOPT(NOEVAL)
+SUBROUTINE RECMWF_AERO (KST, KEND, KPROMA, KTDIA , KLEV,&
+ & KMODE,&
+ & PALBD , PALBP , PAPRS , PAPRSF , PCCO2 , PCLFR,&
+ & PQO3  , PAER  , PDP   , PEMIS  , PMU0,&
+ & PQ    , PQS   , PQIWP , PQLWP , PSLM   , PT    , PTS,&
+ & PREF_LIQ, PREF_ICE,&
+!--OB
+ & PREF_LIQ_PI, PREF_ICE_PI,&
+!--fin
+ & PEMTD , PEMTU , PTRSO,&
+ & PTH   , PCTRSO, PCEMTR, PTRSOD,&
+ & PLWFC, PLWFT, PSWFC, PSWFT, PSFSWDIR, PSFSWDIF,&
+ & PFSDNN, PFSDNV,&  
+ & PPIZA_TOT,PCGA_TOT,PTAU_TOT, & 
+!--OB
+ & PPIZA_NAT,PCGA_NAT,PTAU_NAT, & 
+!--fin OB 
+ & PFLUX,PFLUC,&
+ & PFSDN ,PFSUP , PFSCDN , PFSCUP,&
+!--OB diagnostics
+ & PTOPSWADAERO,PSOLSWADAERO,&
+ & PTOPSWAD0AERO,PSOLSWAD0AERO,&
+ & PTOPSWAIAERO,PSOLSWAIAERO,&
+ & PTOPSWCFAERO,PSOLSWCFAERO,&
+ & ok_ade, ok_aie, flag_aerosol,flag_aerosol_strat)
+!--fin
+
+!**** *RECMWF* - METEO-FRANCE RADIATION INTERFACE TO ECMWF RADIATION SCHEME
+
+!     PURPOSE.
+!     --------
+!           SIMPLE INTERFACE TO RADLSW (NO INTERPOLATION)
+
+!**   INTERFACE.
+!     ----------
+
+!     EXPLICIT ARGUMENTS :
+!        --------------------
+! KST    : START INDEX OF DATA IN KPROMA-LONG VECTOR
+! KEND   : END   INDEX OF DATA IN KPROMA-LONG VECTOR
+! KPROMA : VECTOR LENGTH
+! KTDIA  : INDEX OF TOP LEVEL FROM WHICH COMPUTATIONS ARE ACTIVE
+! KLEV   : NUMBER OF LEVELS
+! PAER   : (KPROMA,KLEV ,6)     ; OPTICAL THICKNESS OF THE AEROSOLS
+! PALBD  : (KPROMA,NSW)         ; DIFFUSE ALBEDO IN THE 2 SW INTERVALS
+! PALBP  : (KPROMA,NSW)         ; PARALLEL ALBEDO IN THE 2 SW INTERVALS
+! PAPRS  : (KPROMA,KLEV+1)      ; HALF LEVEL PRESSURE
+! PAPRSF : (KPROMA,KLEV )       ; FULL LEVEL PRESSURE
+! PCCO2  :                      ; CONCENTRATION IN CO2 (PA/PA)
+! PCLFR  : (KPROMA,KLEV )       ; CLOUD FRACTIONAL COVER
+! PQO3   : (KPROMA,KLEV )       ; OZONE MIXING RATIO (MASS)
+! PDP    : (KPROMA,KLEV)        ; LAYER PRESSURE THICKNESS
+! PEMIS  : (KPROMA)             ; SURFACE EMISSIVITY
+! PMU0   : (KPROMA)             ; SOLAR ANGLE
+! PQ     : (KPROMA,KLEV )       ; SPECIFIC HUMIDITY PA/PA
+! PQS    : (KPROMA,KLEV )       ; SATURATION SPECIFIC HUMIDITY PA/PA
+! PQIWP  : (KPROMA,KLEV )       ; ICE    WATER KG/KG
+! PQLWP  : (KPROMA,KLEV )       ; LIQUID WATER KG/KG
+! PSLM   : (KPROMA)             ; LAND-SEA MASK
+! PT     : (KPROMA,KLEV)        ; FULL LEVEL TEMPERATURE
+! PTS    : (KPROMA)             ; SURFACE TEMPERATURE
+! PPIZA_TOT  : (KPROMA,KLEV,NSW); Single scattering albedo of total aerosol
+! PCGA_TOT   : (KPROMA,KLEV,NSW); Assymetry factor for total aerosol
+! PTAU_TOT: (KPROMA,KLEV,NSW)   ; Optical depth of total aerosol
+! PREF_LIQ (KPROMA,KLEV)        ; Liquid droplet radius (um) - present-day
+! PREF_ICE (KPROMA,KLEV)        ; Ice crystal radius (um) - present-day
+!--OB
+! PREF_LIQ_PI (KPROMA,KLEV)     ; Liquid droplet radius (um) - pre-industrial 
+! PREF_ICE_PI (KPROMA,KLEV)     ; Ice crystal radius (um) - pre-industrial 
+! ok_ade---input-L- apply the Aerosol Direct Effect or not?
+! ok_aie---input-L- apply the Aerosol Indirect Effect or not?
+! flag_aerosol-input-I- aerosol flag from 0 to 6
+! flag_aerosol_strat-input-I- use stratospheric aerosols flag (T/F)
+! PPIZA_NAT  : (KPROMA,KLEV,NSW); Single scattering albedo of natural aerosol
+! PCGA_NAT   : (KPROMA,KLEV,NSW); Assymetry factor for natural aerosol
+! PTAU_NAT: (KPROMA,KLEV,NSW)   ; Optical depth of natural aerosol
+!--fin OB
+
+!     ==== OUTPUTS ===
+! PEMTD (KPROMA,KLEV+1)         ; TOTAL DOWNWARD LONGWAVE EMISSIVITY
+! PEMTU (KPROMA,KLEV+1)         ; TOTAL UPWARD   LONGWAVE EMISSIVITY
+! PTRSO (KPROMA,KLEV+1)         ; TOTAL SHORTWAVE TRANSMISSIVITY
+! PTH   (KPROMA,KLEV+1)         ; HALF LEVEL TEMPERATURE
+! PCTRSO(KPROMA,2)              ; CLEAR-SKY SHORTWAVE TRANSMISSIVITY
+! PCEMTR(KPROMA,2)              ; CLEAR-SKY NET LONGWAVE EMISSIVITY
+! PTRSOD(KPROMA)                ; TOTAL-SKY SURFACE SW TRANSMISSITY
+! PLWFC (KPROMA,2)              ; CLEAR-SKY LONGWAVE FLUXES
+! PLWFT (KPROMA,KLEV+1)         ; TOTAL-SKY LONGWAVE FLUXES
+! PSWFC (KPROMA,2)              ; CLEAR-SKY SHORTWAVE FLUXES
+! PSWFT (KPROMA,KLEV+1)         ; TOTAL-SKY SHORTWAVE FLUXES
+! Ajout flux LW et SW montants et descendants, et ciel clair (MPL 19.12.08)
+! PFLUX (KPROMA,2,KLEV+1)       ; LW total sky flux (1=up, 2=down)
+! PFLUC (KPROMA,2,KLEV+1)       ; LW clear sky flux (1=up, 2=down)
+! PFSDN(KPROMA,KLEV+1)          ; SW total sky flux down
+! PFSUP(KPROMA,KLEV+1)          ; SW total sky flux up
+! PFSCDN(KPROMA,KLEV+1)         ; SW clear sky flux down
+! PFSCUP(KPROMA,KLEV+1)         ; SW clear sky flux up
+
+
+!        IMPLICIT ARGUMENTS :   NONE
+!        --------------------
+
+!     METHOD.
+!     -------
+!     SEE DOCUMENTATION
+
+!     EXTERNALS.
+!     ----------
+
+!     REFERENCE.
+!     ----------
+!     ECMWF RESEARCH DEPARTMENT DOCUMENTATION OF THE IFS
+
+!     AUTHORS.
+!     --------
+!     ORIGINAL BY  B. RITTER   *ECMWF*        83-10-13
+!     REWRITING FOR IFS BY J.-J. MORCRETTE    94-11-15
+!     96-11: Ph. Dandin. Meteo-France
+!     REWRITING FOR DM  BY J.PH. PIEDELIEVRE   1998-07
+!     Duplication of RFMR to use present (cy25) ECMWF radiation scheme : Y. Bouteloup 09-2003
+!     Use of 6 aerosols & introduce NSW : F. Bouyssel 09-2004
+!     04-11-18 : 4 New arguments for AROME : Y. Seity 
+!     2005-10-10 Y. Seity : 3 optional arguments for dust optical properties 
+!     JJMorcrette 20060721 PP of clear-sky PAR and TOA incident solar radiation (ECMWF)
+!     Olivier Boucher: added LMD radiation diagnostics 2014-03
+
+!-----------------------------------------------------------------------
+
+USE PARKIND1  ,ONLY : JPIM     ,JPRB
+USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
+USE YOEAERD  , ONLY : RCAEROS
+USE YOMCST   , ONLY :         RMD      ,RMO3
+USE YOMPHY3  , ONLY : RII0
+USE YOERAD   , ONLY : NAER, RCCNLND  ,RCCNSEA  
+USE YOERDU   , ONLY : REPSCQ
+USE YOMGEM   , ONLY : NGPTOT
+USE YOERDI   , ONLY : RRAE   ,REPCLC    ,REPH2O
+USE YOMARPHY , ONLY : LRDUST 
+USE phys_output_mod, ONLY : swaero_diag
+
+!-----------------------------------------------------------------------
+
+!*       0.1   ARGUMENTS.
+!              ----------
+
+IMPLICIT NONE
+INCLUDE "clesphys.h"
+
+INTEGER(KIND=JPIM),INTENT(IN)    :: KPROMA 
+INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV
+INTEGER(KIND=JPIM),INTENT(IN)    :: KST 
+INTEGER(KIND=JPIM),INTENT(IN)    :: KEND 
+INTEGER(KIND=JPIM)               :: KTDIA ! Argument NOT used
+INTEGER(KIND=JPIM),INTENT(IN)    :: KMODE
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PALBD(KPROMA,NSW) 
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PALBP(KPROMA,NSW) 
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPRS(KPROMA,KLEV+1)
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPRSF(KPROMA,KLEV) 
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PCCO2
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PCLFR(KPROMA,KLEV) 
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PQO3(KPROMA,KLEV) 
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PAER(KPROMA,KLEV,6) 
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PDP(KPROMA,KLEV) 
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PEMIS(KPROMA) 
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PMU0(KPROMA) 
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PQ(KPROMA,KLEV) 
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PQS(KPROMA,KLEV)
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PQIWP(KPROMA,KLEV) 
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PQLWP(KPROMA,KLEV) 
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PSLM(KPROMA)
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PT(KPROMA,KLEV) 
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PTS(KPROMA)
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PPIZA_TOT(KPROMA,KLEV,NSW)
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PCGA_TOT(KPROMA,KLEV,NSW)
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAU_TOT(KPROMA,KLEV,NSW)
+!--OB
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PPIZA_NAT(KPROMA,KLEV,NSW)
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PCGA_NAT(KPROMA,KLEV,NSW)
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAU_NAT(KPROMA,KLEV,NSW)
+REAL(KIND=JPRB)                  :: PPIZA_ZERO(KPROMA,KLEV,NSW)
+REAL(KIND=JPRB)                  :: PCGA_ZERO(KPROMA,KLEV,NSW)
+REAL(KIND=JPRB)                  :: PTAU_ZERO(KPROMA,KLEV,NSW)
+!--fin
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PREF_LIQ(KPROMA,KLEV)
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PREF_ICE(KPROMA,KLEV)
+!--OB
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PREF_LIQ_PI(KPROMA,KLEV)
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PREF_ICE_PI(KPROMA,KLEV)
+LOGICAL, INTENT(in)  :: ok_ade, ok_aie         ! switches whether to use aerosol direct (indirect) effects or not
+INTEGER, INTENT(in)  :: flag_aerosol           ! takes value 0 (no aerosol) or 1 to 6 (aerosols)
+LOGICAL, INTENT(in)  :: flag_aerosol_strat     ! use stratospheric aerosols
+REAL(KIND=JPRB)   ,INTENT(out)   :: PTOPSWADAERO(KPROMA), PSOLSWADAERO(KPROMA)       ! Aerosol direct forcing at TOA and surface
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTOPSWAD0AERO(KPROMA), PSOLSWAD0AERO(KPROMA)     ! Aerosol direct forcing at TOA and surface
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTOPSWAIAERO(KPROMA), PSOLSWAIAERO(KPROMA)       ! ditto, indirect
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTOPSWCFAERO(KPROMA,3), PSOLSWCFAERO(KPROMA,3) !--do we keep this ?
+!--fin
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PEMTD(KPROMA,KLEV+1) 
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PEMTU(KPROMA,KLEV+1) 
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTRSO(KPROMA,KLEV+1) 
+REAL(KIND=JPRB)   ,INTENT(INOUT) :: PTH(KPROMA,KLEV+1)
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCTRSO(KPROMA,2) 
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCEMTR(KPROMA,2) 
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTRSOD(KPROMA) 
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PLWFC(KPROMA,2) 
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PLWFT(KPROMA,KLEV+1) 
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSWFC(KPROMA,2) 
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSWFT(KPROMA,KLEV+1) 
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSFSWDIR(KPROMA,NSW)
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSFSWDIF(KPROMA,NSW)
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSDNN(KPROMA)
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSDNV(KPROMA)
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFLUX(KPROMA,2,KLEV+1) ! LW total sky flux (1=up, 2=down)
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFLUC(KPROMA,2,KLEV+1) ! LW clear sky flux (1=up, 2=down)
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSDN(KPROMA,KLEV+1)   ! SW total sky flux down
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSUP(KPROMA,KLEV+1)   ! SW total sky flux up
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSCDN(KPROMA,KLEV+1)  ! SW clear sky flux down
+REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSCUP(KPROMA,KLEV+1)  ! SW clear sky flux up
+
+!     ==== COMPUTED IN RADITE ===
+!     ------------------------------------------------------------------
+!*       0.2   LOCAL ARRAYS.
+!              -------------
+REAL(KIND=JPRB) :: ZRAER  (KPROMA,6,KLEV)
+REAL(KIND=JPRB) :: ZRCLC  (KPROMA,KLEV)
+REAL(KIND=JPRB) :: ZRMU0  (KPROMA)
+REAL(KIND=JPRB) :: ZRPR   (KPROMA,KLEV)
+REAL(KIND=JPRB) :: ZRTI   (KPROMA,KLEV)
+REAL(KIND=JPRB) :: ZQLWP (KPROMA,KLEV ) , ZQIWP (KPROMA,KLEV )
+
+REAL(KIND=JPRB) :: ZPQO3 (KPROMA,KLEV)
+REAL(KIND=JPRB) :: ZQOZ (NGPTOT,KLEV)
+REAL(KIND=JPRB) :: ZQS    (KPROMA,KLEV)
+REAL(KIND=JPRB) :: ZQ     (KPROMA,KLEV)
+REAL(KIND=JPRB) :: ZEMTD  (KPROMA,KLEV+1)
+REAL(KIND=JPRB) :: ZEMTU  (KPROMA,KLEV+1)
+REAL(KIND=JPRB) :: ZTRSOC (KPROMA,2)
+REAL(KIND=JPRB) :: ZEMTC  (KPROMA,2)
+
+REAL(KIND=JPRB) :: ZNBAS  (KPROMA)
+REAL(KIND=JPRB) :: ZNTOP  (KPROMA)
+REAL(KIND=JPRB) :: ZQRAIN (KPROMA,KLEV)
+REAL(KIND=JPRB) :: ZQRAINT(KPROMA,KLEV)
+REAL(KIND=JPRB) :: ZCCNL  (KPROMA)
+REAL(KIND=JPRB) :: ZCCNO  (KPROMA)
+
+!  output of radlsw
+
+REAL(KIND=JPRB) :: ZEMIT  (KPROMA)
+REAL(KIND=JPRB) :: ZFCT   (KPROMA,KLEV+1)
+REAL(KIND=JPRB) :: ZFLT   (KPROMA,KLEV+1)
+REAL(KIND=JPRB) :: ZFCS   (KPROMA,KLEV+1)
+REAL(KIND=JPRB) :: ZFLS   (KPROMA,KLEV+1)
+REAL(KIND=JPRB) :: ZFRSOD (KPROMA),ZSUDU(KPROMA)
+REAL(KIND=JPRB) :: ZPARF  (KPROMA),ZUVDF(KPROMA),ZPARCF(KPROMA),ZTINCF(KPROMA)
+
+INTEGER(KIND=JPIM) :: IBEG, IEND, JK, JL
+
+REAL(KIND=JPRB) :: ZCRAE, ZRII0, ZEMIW(KPROMA)
+REAL(KIND=JPRB) :: ZHOOK_HANDLE
+
+!---aerosol radiative diagnostics
+! Key to define the aerosol effect acting on climate
+! OB: AEROSOLFEEDBACK_ACTIVE is now a LOGICAL
+! TRUE: fluxes use natural and/or anthropogenic aerosols according to ok_ade and ok_aie, DEFAULT
+! FALSE: fluxes use no aerosols (case 1) 
+! to be used only for maintaining bit reproducibility with aerosol diagnostics activated
+LOGICAL :: AEROSOLFEEDBACK_ACTIVE = .TRUE.
+
+!OB - Fluxes including aerosol effects
+!              |        direct effect
+!ind effect    | no aerosol  NATural  TOTal
+!standard      |   5
+!natural (PI)  |               1       3     
+!total   (PD)  |               2       4   
+! so we need which case when ?
+! if flag_aerosol is on
+! ok_ade and ok_aie         = 4-2, 4-3 and 4 to proceed
+! ok_ade and not ok_aie     = 3-1 and 3 to proceed
+! not ok_ade and ok_aie     = 2-1 and 2 to proceed
+! not ok_ade and not ok_aie = 1 to proceed
+! therefore the cases have the following corresponding switches
+! 1 = not ok_ade or not ok_aie
+! 2 = ok_aie
+! 3 = ok_ade
+! 4 = ok_ade and ok_aie
+! 5 = no aerosol feedback wanted or no aerosol at all 
+! if they are called in this order then the correct call is used to proceed
+
+REAL(KIND=JPRB) ::  ZFSUP_AERO(KPROMA,KLEV+1,5)
+REAL(KIND=JPRB) ::  ZFSDN_AERO(KPROMA,KLEV+1,5)
+REAL(KIND=JPRB) ::  ZFSUP0_AERO(KPROMA,KLEV+1,5)
+REAL(KIND=JPRB) ::  ZFSDN0_AERO(KPROMA,KLEV+1,5)
+
+#include "radlsw.intfb.h"
+
+IF (LHOOK) CALL DR_HOOK('RECMWF_AERO',0,ZHOOK_HANDLE)
+IBEG=KST
+IEND=KEND
+
+!*       1.    PREPARATORY WORK
+!              ----------------
+!--OB
+!        1.0    INITIALIZATIONS
+!               --------------
+
+ZFSUP_AERO (:,:,:)=0.
+ZFSDN_AERO (:,:,:)=0.
+ZFSUP0_AERO(:,:,:)=0.
+ZFSDN0_AERO(:,:,:)=0.
+
+PTAU_ZERO(:,:,:) =1.e-15
+PPIZA_ZERO(:,:,:)=1.0
+PCGA_ZERO(:,:,:) =0.0
+
+
+!*       1.1    LOCAL CONSTANTS
+!                ---------------
+
+ZRII0=RII0
+ZCRAE=RRAE*(RRAE+2.0_JPRB)
+
+!*       2.1    FULL-LEVEL QUANTITIES
+
+ZRPR =PAPRSF
+
+DO JK=1,KLEV
+  DO JL=IBEG,IEND
+!   ZPQO3(JL,JK)=PQO3(JL,JK)*PDP(JL,JK)*RMD/RMO3
+    ZPQO3(JL,JK)=PQO3(JL,JK)*PDP(JL,JK)
+    ZRCLC(JL,JK)=MAX( 0.0_JPRB ,MIN( 1.0_JPRB ,PCLFR(JL,JK)))
+    IF (ZRCLC(JL,JK) > REPCLC) THEN
+      ZQLWP(JL,JK)=PQLWP(JL,JK)
+      ZQIWP(JL,JK)=PQIWP(JL,JK)
+    ELSE
+      ZQLWP(JL,JK)=REPH2O*ZRCLC(JL,JK)
+      ZQIWP(JL,JK)=REPH2O*ZRCLC(JL,JK)
+    ENDIF
+    ZQRAIN(JL,JK)=0.
+    ZQRAINT(JL,JK)=0.
+    ZRTI(JL,JK) =PT(JL,JK)
+    ZQS (JL,JK)=MAX(2.0_JPRB*REPH2O,PQS(JL,JK))
+    ZQ  (JL,JK)=MAX(REPH2O,MIN(PQ(JL,JK),ZQS(JL,JK)*(1.0_JPRB-REPH2O)))
+    ZEMIW(JL)=PEMIS(JL)
+  ENDDO
+ENDDO
+
+IF (NAER == 0) THEN
+  ZRAER=RCAEROS
+ELSE
+  DO JK=1,KLEV
+    DO JL=IBEG,IEND
+      ZRAER(JL,1,JK)=PAER(JL,JK,1)
+      ZRAER(JL,2,JK)=PAER(JL,JK,2)
+      ZRAER(JL,3,JK)=PAER(JL,JK,3)
+      ZRAER(JL,4,JK)=PAER(JL,JK,4)
+      ZRAER(JL,5,JK)=RCAEROS
+      ZRAER(JL,6,JK)=PAER(JL,JK,6)
+    ENDDO
+  ENDDO
+ENDIF
+
+!*       2.2    HALF-LEVEL QUANTITIES
+
+DO JK=2,KLEV
+  DO JL=IBEG,IEND
+    PTH(JL,JK)=&
+     & (PT(JL,JK-1)*PAPRSF(JL,JK-1)*(PAPRSF(JL,JK)-PAPRS(JL,JK))&
+     & +PT(JL,JK)*PAPRSF(JL,JK)*(PAPRS(JL,JK)-PAPRSF(JL,JK-1)))&
+     & *(1.0_JPRB/(PAPRS(JL,JK)*(PAPRSF(JL,JK)-PAPRSF(JL,JK-1))))  
+  ENDDO
+ENDDO
+
+!*       2.3     QUANTITIES AT BOUNDARIES
+
+DO JL=IBEG,IEND
+  PTH(JL,KLEV+1)=PTS(JL)
+  PTH(JL,1)=PT(JL,1)-PAPRSF(JL,1)*(PT(JL,1)-PTH(JL,2))&
+   & /(PAPRSF(JL,1)-PAPRS(JL,2))  
+  ZNBAS(JL)=1. 
+  ZNTOP(JL)=1.
+  ZCCNL(JL)=RCCNLND
+  ZCCNO(JL)=RCCNSEA
+ENDDO
+
+!*       3.1     SOLAR ZENITH ANGLE IS EARTH'S CURVATURE
+!                CORRECTED
+
+! CCMVAL: on impose ZRMU0=PMU0 MPL 25032010
+! 2eme essai en 3D MPL 20052010
+!DO JL=IBEG,IEND
+! ZRMU0(JL)=PMU0(JL)
+!ENDDO
+!!!!! A REVOIR MPL 20091201: enleve cette correction pour comparer a AR4
+ DO JL=IBEG,IEND
+   IF (PMU0(JL) > 1.E-10_JPRB) THEN
+     ZRMU0(JL)=RRAE/(SQRT(PMU0(JL)**2+ZCRAE)-PMU0(JL))
+   ELSE
+     ZRMU0(JL)= RRAE/SQRT(ZCRAE)
+   ENDIF   
+ ENDDO   
+
+!*         4.1     CALL TO ACTUAL RADIATION SCHEME
+!
+!----now we make multiple calls to the radiation according to which 
+!----aerosol flags are on
+
+IF (flag_aerosol .GT. 0 .OR. flag_aerosol_strat) THEN
+
+IF ( .not. ok_ade .or. .not. ok_aie ) THEN
+
+! natural aerosols for direct and indirect effect 
+! PI cloud optical properties
+! use PREF_LIQ_PI and PREF_ICE_PI
+! use NAT aerosol optical properties
+! store fluxes in index 1
+
+CALL RADLSW (&
+ & IBEG  , IEND   , KPROMA  , KLEV  , KMODE , NAER,&
+ & ZRII0 ,&
+ & ZRAER , PALBD  , PALBP   , PAPRS , ZRPR  ,&
+ & ZCCNL , ZCCNO  ,&
+ & PCCO2 , ZRCLC  , PDP     , PEMIS , ZEMIW ,PSLM    , ZRMU0 , ZPQO3,&
+ & ZQ    , ZQIWP  , ZQLWP   , ZQS   , ZQRAIN,ZQRAINT ,&
+ & PTH   , ZRTI   , PTS     , ZNBAS , ZNTOP ,&
+ & PREF_LIQ_PI, PREF_ICE_PI,&
+ & ZEMIT , ZFCT   , ZFLT    , ZFCS    , ZFLS  ,&
+ & ZFRSOD, ZSUDU  , ZUVDF   , ZPARF   , ZPARCF, ZTINCF, PSFSWDIR,&
+ & PSFSWDIF,PFSDNN, PFSDNV  ,&  
+ & LRDUST,PPIZA_NAT,PCGA_NAT,PTAU_NAT,PFLUX,PFLUC,&
+ & PFSDN , PFSUP  , PFSCDN  , PFSCUP )
+
+!* SAVE VARIABLES IN INTERIM VARIABLES A LA SW_AEROAR4
+ZFSUP0_AERO(:,:,1) = PFSCUP(:,:)
+ZFSDN0_AERO(:,:,1) = PFSCDN(:,:)
+
+ZFSUP_AERO(:,:,1) =  PFSUP(:,:)
+ZFSDN_AERO(:,:,1) =  PFSDN(:,:)
+
+ENDIF 
+
+IF (ok_aie) THEN
+
+! natural aerosols for direct indirect effect 
+! use NAT aerosol optical properties 
+! PD cloud optical properties
+! use PREF_LIQ and PREF_ICE
+! store fluxes in index 2
+
+CALL RADLSW (&
+ & IBEG  , IEND   , KPROMA  , KLEV  , KMODE , NAER,&
+ & ZRII0 ,&
+ & ZRAER , PALBD  , PALBP   , PAPRS , ZRPR  ,&
+ & ZCCNL , ZCCNO  ,&
+ & PCCO2 , ZRCLC  , PDP     , PEMIS , ZEMIW ,PSLM    , ZRMU0 , ZPQO3,&
+ & ZQ    , ZQIWP  , ZQLWP   , ZQS   , ZQRAIN,ZQRAINT ,&
+ & PTH   , ZRTI   , PTS     , ZNBAS , ZNTOP ,&
+ & PREF_LIQ, PREF_ICE,&
+ & ZEMIT , ZFCT   , ZFLT    , ZFCS    , ZFLS  ,&
+ & ZFRSOD, ZSUDU  , ZUVDF   , ZPARF   , ZPARCF, ZTINCF, PSFSWDIR,&
+ & PSFSWDIF,PFSDNN, PFSDNV  ,&  
+ & LRDUST,PPIZA_NAT,PCGA_NAT,PTAU_NAT,PFLUX,PFLUC,&
+ & PFSDN , PFSUP  , PFSCDN  , PFSCUP )
+
+!* SAVE VARIABLES IN INTERIM VARIABLES A LA SW_AEROAR4
+ZFSUP0_AERO(:,:,2) = PFSCUP(:,:)
+ZFSDN0_AERO(:,:,2) = PFSCDN(:,:)
+
+ZFSUP_AERO(:,:,2) =  PFSUP(:,:)
+ZFSDN_AERO(:,:,2) =  PFSDN(:,:)
+
+ENDIF ! ok_aie      
+
+IF (ok_ade) THEN
+
+! direct effect of total aerosol activated
+! TOT aerosols for direct effect
+! PI cloud optical properties
+! use PREF_LIQ_PI and PREF_ICE_PI
+! STORE fluxes in index 3
+ 
+CALL RADLSW (&
+ & IBEG  , IEND   , KPROMA  , KLEV  , KMODE , NAER,&
+ & ZRII0 ,&
+ & ZRAER , PALBD  , PALBP   , PAPRS , ZRPR  ,&
+ & ZCCNL , ZCCNO  ,&
+ & PCCO2 , ZRCLC  , PDP     , PEMIS , ZEMIW ,PSLM    , ZRMU0 , ZPQO3,&
+ & ZQ    , ZQIWP  , ZQLWP   , ZQS   , ZQRAIN,ZQRAINT ,&
+ & PTH   , ZRTI   , PTS     , ZNBAS , ZNTOP ,&
+ & PREF_LIQ_PI, PREF_ICE_PI,&
+ & ZEMIT , ZFCT   , ZFLT    , ZFCS    , ZFLS  ,&
+ & ZFRSOD, ZSUDU  , ZUVDF   , ZPARF   , ZPARCF, ZTINCF, PSFSWDIR,&
+ & PSFSWDIF,PFSDNN, PFSDNV  ,&  
+ & LRDUST,PPIZA_TOT,PCGA_TOT,PTAU_TOT,PFLUX,PFLUC,&
+ & PFSDN , PFSUP  , PFSCDN  , PFSCUP )
+
+!* SAVE VARIABLES IN INTERIM VARIABLES A LA SW_AEROAR4
+ZFSUP0_AERO(:,:,3) = PFSCUP(:,:)
+ZFSDN0_AERO(:,:,3) = PFSCDN(:,:)
+
+ZFSUP_AERO(:,:,3) =  PFSUP(:,:)
+ZFSDN_AERO(:,:,3) =  PFSDN(:,:)
+
+ENDIF !-end ok_ade
+
+IF (ok_ade .and. ok_aie) THEN
+
+! total aerosols for direct indirect effect 
+! use TOT aerosol optical properties 
+! PD cloud optical properties
+! use PREF_LIQ and PREF_ICE
+! store fluxes in index 4 
+
+CALL RADLSW (&
+ & IBEG  , IEND   , KPROMA  , KLEV  , KMODE , NAER,&
+ & ZRII0 ,&
+ & ZRAER , PALBD  , PALBP   , PAPRS , ZRPR  ,&
+ & ZCCNL , ZCCNO  ,&
+ & PCCO2 , ZRCLC  , PDP     , PEMIS , ZEMIW ,PSLM    , ZRMU0 , ZPQO3,&
+ & ZQ    , ZQIWP  , ZQLWP   , ZQS   , ZQRAIN,ZQRAINT ,&
+ & PTH   , ZRTI   , PTS     , ZNBAS , ZNTOP ,&
+ & PREF_LIQ, PREF_ICE,&
+ & ZEMIT , ZFCT   , ZFLT    , ZFCS    , ZFLS  ,&
+ & ZFRSOD, ZSUDU  , ZUVDF   , ZPARF   , ZPARCF, ZTINCF, PSFSWDIR,&
+ & PSFSWDIF,PFSDNN, PFSDNV  ,&  
+ & LRDUST,PPIZA_TOT,PCGA_TOT,PTAU_TOT,PFLUX,PFLUC,&
+ & PFSDN , PFSUP  , PFSCDN  , PFSCUP )
+
+!* SAVE VARIABLES IN INTERIM VARIABLES A LA SW_AEROAR4
+ZFSUP0_AERO(:,:,4) = PFSCUP(:,:)
+ZFSDN0_AERO(:,:,4) = PFSCDN(:,:)
+
+ZFSUP_AERO(:,:,4) =  PFSUP(:,:)
+ZFSDN_AERO(:,:,4) =  PFSDN(:,:)
+
+ENDIF ! ok_ade .and. ok_aie
+
+ENDIF !--if flag_aerosol GT 0 OR flag_aerosol_strat
+
+! case with no aerosols at all is also computed IF ACTIVEFEEDBACK_ACTIVE is false 
+!IF (swaero_diag .OR. .not. AEROSOLFEEDBACK_ACTIVE .OR. flag_aerosol .EQ. 0 ) THEN    
+IF (.not. AEROSOLFEEDBACK_ACTIVE .OR. flag_aerosol .EQ. 0 ) THEN    
+
+! ZERO aerosol effect
+! ZERO aerosol optical depth
+! STANDARD cloud optical properties
+! STORE fluxes in index 5
+
+CALL RADLSW (&
+ & IBEG  , IEND   , KPROMA  , KLEV  , KMODE , NAER,&
+ & ZRII0 ,&
+ & ZRAER , PALBD  , PALBP   , PAPRS , ZRPR  ,&
+ & ZCCNL , ZCCNO  ,&
+ & PCCO2 , ZRCLC  , PDP     , PEMIS , ZEMIW ,PSLM    , ZRMU0 , ZPQO3,&
+ & ZQ    , ZQIWP  , ZQLWP   , ZQS   , ZQRAIN,ZQRAINT ,&
+ & PTH   , ZRTI   , PTS     , ZNBAS , ZNTOP ,&
+!--this needs to be changed to fixed cloud optical properties
+ & PREF_LIQ_PI, PREF_ICE_PI,&
+ & ZEMIT , ZFCT   , ZFLT    , ZFCS    , ZFLS  ,&
+ & ZFRSOD, ZSUDU  , ZUVDF   , ZPARF   , ZPARCF, ZTINCF, PSFSWDIR,&
+ & PSFSWDIF,PFSDNN, PFSDNV  ,&  
+ & LRDUST,PPIZA_ZERO,PCGA_ZERO,PTAU_ZERO,PFLUX,PFLUC,&
+ & PFSDN , PFSUP  , PFSCDN  , PFSCUP )
+
+!* SAVE VARIABLES IN INTERIM VARIABLES A LA SW_AEROAR4
+ZFSUP0_AERO(:,:,5) = PFSCUP(:,:)
+ZFSDN0_AERO(:,:,5) = PFSCDN(:,:)
+
+ZFSUP_AERO(:,:,5) =  PFSUP(:,:)
+ZFSDN_AERO(:,:,5) =  PFSDN(:,:)
+
+ENDIF ! .not. AEROSOLFEEDBACK_ACTIVE
+
+!*         4.2     TRANSFORM FLUXES TO MODEL HISTORICAL VARIABLES
+
+DO JK=1,KLEV+1
+  DO JL=IBEG,IEND
+    PSWFT(JL,JK)=ZFLS(JL,JK)/(ZRII0*ZRMU0(JL))
+    PLWFT(JL,JK)=ZFLT(JL,JK)
+  ENDDO
+ENDDO
+
+ZEMTD=PLWFT
+ZEMTU=PLWFT
+
+DO JL=IBEG,IEND
+  ZTRSOC(JL, 1)=ZFCS(JL,     1)/(ZRII0*ZRMU0(JL))
+  ZTRSOC(JL, 2)=ZFCS(JL,KLEV+1)/(ZRII0*ZRMU0(JL))
+  ZEMTC (JL, 1)=ZFCT(JL,     1)
+  ZEMTC (JL, 2)=ZFCT(JL,KLEV+1)
+ENDDO
+
+!                 ------------ -- ------- -- ---- -----
+!*         5.1    STORAGE OF TRANSMISSIVITY AND EMISSIVITIES
+!*                IN KPROMA-LONG ARRAYS
+
+DO JK=1,KLEV+1
+  DO JL=IBEG,IEND
+    PEMTD(JL,JK)=ZEMTD(JL,JK)
+    PEMTU(JL,JK)=ZEMTU(JL,JK)
+    PTRSO(JL,JK)=MAX(0.0_JPRB,MIN(1.0_JPRB,PSWFT(JL,JK)))
+  ENDDO
+ENDDO
+DO JK=1,2
+  DO JL=IBEG,IEND
+    PCEMTR(JL,JK)=ZEMTC (JL,JK)
+    PCTRSO(JL,JK)=MAX( 0.0_JPRB,MIN(1.0_JPRB,ZTRSOC(JL,JK)))
+  ENDDO
+ENDDO
+DO JL=IBEG,IEND
+  PTRSOD(JL)=MAX(0.0_JPRB,MIN(1.0_JPRB,ZFRSOD(JL)/(ZRII0*ZRMU0(JL))))
+ENDDO
+
+!*         7.3   RECONSTRUCT FLUXES FOR DIAGNOSTICS
+
+DO JL=IBEG,IEND
+  IF (PMU0(JL) < 1.E-10_JPRB) ZRMU0(JL)=0.0_JPRB
+ENDDO
+DO JK=1,KLEV+1
+  DO JL=IBEG,IEND
+    PLWFT(JL,JK)=PEMTD(JL,JK)
+    PSWFT(JL,JK)=ZRMU0(JL)*ZRII0*PTRSO(JL,JK)
+  ENDDO
+ENDDO
+DO JK=1,2
+  DO JL=IBEG,IEND
+    PSWFC(JL,JK)=ZRMU0(JL)*ZRII0*PCTRSO(JL,JK)
+    PLWFC(JL,JK)=PCEMTR(JL,JK)
+  ENDDO
+ENDDO
+
+!*  8.0 DIAGNOSTICS
+!---Now we copy back the correct fields to proceed to the next timestep
+
+IF  ( AEROSOLFEEDBACK_ACTIVE .AND. (flag_aerosol .GT. 0 .OR. flag_aerosol_strat) ) THEN
+
+  IF ( ok_ade .and. ok_aie  ) THEN
+    PFSUP(:,:) =    ZFSUP_AERO(:,:,4)
+    PFSDN(:,:) =    ZFSDN_AERO(:,:,4)
+    PFSCUP(:,:) =   ZFSUP0_AERO(:,:,4)
+    PFSCDN(:,:) =   ZFSDN0_AERO(:,:,4)
+  ENDIF
+
+  IF ( ok_ade .and. (.not. ok_aie) )  THEN
+    PFSUP(:,:) =    ZFSUP_AERO(:,:,3)
+    PFSDN(:,:) =    ZFSDN_AERO(:,:,3)
+    PFSCUP(:,:) =   ZFSUP0_AERO(:,:,3)
+    PFSCDN(:,:) =   ZFSDN0_AERO(:,:,3)
+  ENDIF
+
+  IF ( (.not. ok_ade) .and. ok_aie  )  THEN
+    PFSUP(:,:) =    ZFSUP_AERO(:,:,2)
+    PFSDN(:,:) =    ZFSDN_AERO(:,:,2)
+    PFSCUP(:,:) =   ZFSUP0_AERO(:,:,2)
+    PFSCDN(:,:) =   ZFSDN0_AERO(:,:,2)
+  ENDiF
+
+  IF ((.not. ok_ade) .and. (.not. ok_aie)) THEN
+    PFSUP(:,:) =    ZFSUP_AERO(:,:,1)
+    PFSDN(:,:) =    ZFSDN_AERO(:,:,1)
+    PFSCUP(:,:) =   ZFSUP0_AERO(:,:,1)
+    PFSCDN(:,:) =   ZFSDN0_AERO(:,:,1)
+  ENDIF
+
+! The following allows to compute the forcing diagostics without
+! letting the aerosol forcing act on the meteorology
+! SEE logic above
+
+ELSE  !--not AEROSOLFEEDBACK_ACTIVE
+
+    PFSUP(:,:) =    ZFSUP_AERO(:,:,5)
+    PFSDN(:,:) =    ZFSDN_AERO(:,:,5)
+    PFSCUP(:,:) =   ZFSUP0_AERO(:,:,5)
+    PFSCDN(:,:) =   ZFSDN0_AERO(:,:,5)
+
+ENDIF
+
+!OB- HERE CHECK WITH MP IF BOTTOM AND TOP INDICES ARE OK !!!!!!!!!!!!!!!!!!
+! net anthropogenic forcing direct and 1st indirect effect diagnostics
+! requires a natural aerosol field read and used 
+! Difference of net fluxes from double call to radiation
+! Will need to be extended to LW radiation
+
+IF (flag_aerosol .GT. 0 .OR. flag_aerosol_strat) THEN
+
+IF (ok_ade.AND.ok_aie) THEN
+
+! direct anthropogenic forcing
+     PSOLSWADAERO(:)  = (ZFSDN_AERO(:,1,4)      -ZFSUP_AERO(:,1,4))      -(ZFSDN_AERO(:,1,2)      -ZFSUP_AERO(:,1,2))
+     PTOPSWADAERO(:)  = (ZFSDN_AERO(:,KLEV+1,4) -ZFSUP_AERO(:,KLEV+1,4)) -(ZFSDN_AERO(:,KLEV+1,2) -ZFSUP_AERO(:,KLEV+1,2))
+     PSOLSWAD0AERO(:) = (ZFSDN0_AERO(:,1,4)     -ZFSUP0_AERO(:,1,4))     -(ZFSDN0_AERO(:,1,2)     -ZFSUP0_AERO(:,1,2))
+     PTOPSWAD0AERO(:) = (ZFSDN0_AERO(:,KLEV+1,4)-ZFSUP0_AERO(:,KLEV+1,4))-(ZFSDN0_AERO(:,KLEV+1,2)-ZFSUP0_AERO(:,KLEV+1,2))
+
+! indirect anthropogenic forcing
+     PSOLSWAIAERO(:) = (ZFSDN_AERO(:,1,4)     -ZFSUP_AERO(:,1,4))     -(ZFSDN_AERO(:,1,3)     -ZFSUP_AERO(:,1,3))
+     PTOPSWAIAERO(:) = (ZFSDN_AERO(:,KLEV+1,4)-ZFSUP_AERO(:,KLEV+1,4))-(ZFSDN_AERO(:,KLEV+1,3)-ZFSUP_AERO(:,KLEV+1,3))
+
+! Cloud radiative forcing with natural aerosol for direct effect 
+     PSOLSWCFAERO(:,1) = (ZFSDN_AERO(:,1,2)     -ZFSUP_AERO(:,1,2))     -(ZFSDN0_AERO(:,1,2)     -ZFSUP0_AERO(:,1,2))
+     PTOPSWCFAERO(:,1) = (ZFSDN_AERO(:,KLEV+1,2)-ZFSUP_AERO(:,KLEV+1,2))-(ZFSDN0_AERO(:,KLEV+1,2)-ZFSUP0_AERO(:,KLEV+1,2))
+! Cloud radiative forcing with anthropogenic aerosol for direct effect 
+     PSOLSWCFAERO(:,2) = (ZFSDN_AERO(:,1,4)     -ZFSUP_AERO(:,1,4))     -(ZFSDN0_AERO(:,1,4)     -ZFSUP0_AERO(:,1,4))
+     PTOPSWCFAERO(:,2) = (ZFSDN_AERO(:,KLEV+1,4)-ZFSUP_AERO(:,KLEV+1,4))-(ZFSDN0_AERO(:,KLEV+1,4)-ZFSUP0_AERO(:,KLEV+1,4))
+! Cloud radiative forcing with no direct effect at all 
+     PSOLSWCFAERO(:,3) = 0.0
+     PTOPSWCFAERO(:,3) = 0.0
+
+ENDIF
+
+IF (ok_ade.AND..NOT.ok_aie) THEN
+
+! direct anthropogenic forcing
+     PSOLSWADAERO(:)  = (ZFSDN_AERO(:,1,3)      -ZFSUP_AERO(:,1,3))      -(ZFSDN_AERO(:,1,1)      -ZFSUP_AERO(:,1,1))
+     PTOPSWADAERO(:)  = (ZFSDN_AERO(:,KLEV+1,3) -ZFSUP_AERO(:,KLEV+1,3)) -(ZFSDN_AERO(:,KLEV+1,1) -ZFSUP_AERO(:,KLEV+1,1))
+     PSOLSWAD0AERO(:) = (ZFSDN0_AERO(:,1,3)     -ZFSUP0_AERO(:,1,3))     -(ZFSDN0_AERO(:,1,1)     -ZFSUP0_AERO(:,1,1))
+     PTOPSWAD0AERO(:) = (ZFSDN0_AERO(:,KLEV+1,3)-ZFSUP0_AERO(:,KLEV+1,3))-(ZFSDN0_AERO(:,KLEV+1,1)-ZFSUP0_AERO(:,KLEV+1,1))
+
+! indirect anthropogenic forcing
+     PSOLSWAIAERO(:) = 0.0
+     PTOPSWAIAERO(:) = 0.0 
+
+! Cloud radiative forcing with natural aerosol for direct effect 
+     PSOLSWCFAERO(:,1) = (ZFSDN_AERO(:,1,1)     -ZFSUP_AERO(:,1,1))     -(ZFSDN0_AERO(:,1,1)     -ZFSUP0_AERO(:,1,1))
+     PTOPSWCFAERO(:,1) = (ZFSDN_AERO(:,KLEV+1,1)-ZFSUP_AERO(:,KLEV+1,1))-(ZFSDN0_AERO(:,KLEV+1,1)-ZFSUP0_AERO(:,KLEV+1,1))
+! Cloud radiative forcing with anthropogenic aerosol for direct effect 
+     PSOLSWCFAERO(:,2) = (ZFSDN_AERO(:,1,3)     -ZFSUP_AERO(:,1,3))     -(ZFSDN0_AERO(:,1,3)     -ZFSUP0_AERO(:,1,3))
+     PTOPSWCFAERO(:,2) = (ZFSDN_AERO(:,KLEV+1,3)-ZFSUP_AERO(:,KLEV+1,3))-(ZFSDN0_AERO(:,KLEV+1,3)-ZFSUP0_AERO(:,KLEV+1,3))
+! Cloud radiative forcing with no direct effect at all 
+     PSOLSWCFAERO(:,3) = 0.0
+     PTOPSWCFAERO(:,3) = 0.0
+
+ENDIF
+
+IF (.NOT.ok_ade.AND.ok_aie) THEN
+
+! direct anthropogenic forcing
+     PSOLSWADAERO(:)  = 0.0
+     PTOPSWADAERO(:)  = 0.0
+     PSOLSWAD0AERO(:) = 0.0
+     PTOPSWAD0AERO(:) = 0.0
+
+! indirect anthropogenic forcing
+     PSOLSWAIAERO(:) = (ZFSDN_AERO(:,1,2)     -ZFSUP_AERO(:,1,2))     -(ZFSDN_AERO(:,1,1)     -ZFSUP_AERO(:,1,1))
+     PTOPSWAIAERO(:) = (ZFSDN_AERO(:,KLEV+1,2)-ZFSUP_AERO(:,KLEV+1,2))-(ZFSDN_AERO(:,KLEV+1,1)-ZFSUP_AERO(:,KLEV+1,1))
+
+! Cloud radiative forcing with natural aerosol for direct effect 
+     PSOLSWCFAERO(:,1) = (ZFSDN_AERO(:,1,2)     -ZFSUP_AERO(:,1,2))     -(ZFSDN0_AERO(:,1,2)     -ZFSUP0_AERO(:,1,2))
+     PTOPSWCFAERO(:,1) = (ZFSDN_AERO(:,KLEV+1,2)-ZFSUP_AERO(:,KLEV+1,2))-(ZFSDN0_AERO(:,KLEV+1,2)-ZFSUP0_AERO(:,KLEV+1,2))
+! Cloud radiative forcing with anthropogenic aerosol for direct effect 
+     PSOLSWCFAERO(:,2) = 0.0
+     PTOPSWCFAERO(:,2) = 0.0
+! Cloud radiative forcing with no direct effect at all 
+     PSOLSWCFAERO(:,3) = 0.0
+     PTOPSWCFAERO(:,3) = 0.0
+
+ENDIF
+
+IF (.NOT.ok_ade.AND..NOT.ok_aie) THEN
+
+! direct anthropogenic forcing
+     PSOLSWADAERO(:)  = 0.0
+     PTOPSWADAERO(:)  = 0.0
+     PSOLSWAD0AERO(:) = 0.0
+     PTOPSWAD0AERO(:) = 0.0
+
+! indirect anthropogenic forcing
+     PSOLSWAIAERO(:) = 0.0 
+     PTOPSWAIAERO(:) = 0.0
+
+! Cloud radiative forcing with natural aerosol for direct effect 
+     PSOLSWCFAERO(:,1) = (ZFSDN_AERO(:,1,1)     -ZFSUP_AERO(:,1,1))     -(ZFSDN0_AERO(:,1,1)     -ZFSUP0_AERO(:,1,1))
+     PTOPSWCFAERO(:,1) = (ZFSDN_AERO(:,KLEV+1,1)-ZFSUP_AERO(:,KLEV+1,1))-(ZFSDN0_AERO(:,KLEV+1,1)-ZFSUP0_AERO(:,KLEV+1,1))
+! Cloud radiative forcing with anthropogenic aerosol for direct effect 
+     PSOLSWCFAERO(:,2) = 0.0
+     PTOPSWCFAERO(:,2) = 0.0
+! Cloud radiative forcing with no direct effect at all 
+     PSOLSWCFAERO(:,3) = 0.0
+     PTOPSWCFAERO(:,3) = 0.0
+
+ENDIF
+
+ENDIF
+
+!IF (swaero_diag .OR. .NOT. AEROSOLFEEDBACK_ACTIVE) THEN
+IF (.NOT. AEROSOLFEEDBACK_ACTIVE) THEN
+! Cloudforcing without aerosol at all
+     PSOLSWCFAERO(:,3) = (ZFSDN_AERO(:,1,5)     -ZFSUP_AERO(:,1,5))     -(ZFSDN0_AERO(:,1,5)     -ZFSUP0_AERO(:,1,5))
+     PTOPSWCFAERO(:,3) = (ZFSDN_AERO(:,KLEV+1,5)-ZFSUP_AERO(:,KLEV+1,5))-(ZFSDN0_AERO(:,KLEV+1,5)-ZFSUP0_AERO(:,KLEV+1,5))
+ENDIF
+
+IF (LHOOK) CALL DR_HOOK('RECMWF_AERO',1,ZHOOK_HANDLE)
+END SUBROUTINE RECMWF_AERO
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/rrtm_ecrt_140gp.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/rrtm_ecrt_140gp.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/rrtm_ecrt_140gp.F90	(revision 2056)
@@ -1,2 +1,5 @@
+!
+! $Id$
+!
 !****************** SUBROUTINE RRTM_ECRT_140GP **************************
 
@@ -26,11 +29,14 @@
  & JPINPX  
 USE YOERAD   , ONLY : NOVLP
-USE YOERDI   , ONLY :    RCH4     ,RN2O    ,RCFC11  ,RCFC12
+!USE YOERDI   , ONLY :    RCH4     ,RN2O    ,RCFC11  ,RCFC12
 USE YOESW    , ONLY : RAER
 
 !------------------------------Arguments--------------------------------
 
+
+
 IMPLICIT NONE
 
+#include "clesphys.h"
 INTEGER(KIND=JPIM),INTENT(IN)    :: KLON! Number of atmospheres (longitudes) 
 INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV! Number of atmospheric layers 
@@ -384,4 +390,6 @@
 !     ------------------------------------------------------------------
 
+
+
 IF (LHOOK) CALL DR_HOOK('RRTM_ECRT_140GP',1,ZHOOK_HANDLE)
 END SUBROUTINE RRTM_ECRT_140GP
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/rrtm_taumol1.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/rrtm_taumol1.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/rrtm_taumol1.F90	(revision 2056)
@@ -189,4 +189,10 @@
 
 IF (LHOOK) CALL DR_HOOK('RRTM_TAUMOL1',0,ZHOOK_HANDLE)
+!--ajout OB 
+IF (K_LAYTROP.GT.100) THEN 
+PRINT *,'ATTENTION KLAY_TROP > 100 PROBLEME ARRAY DANS RRTM ON ARRETE'
+STOP
+!--fin ajout OB
+ENDIF
 DO I_LAY = 1, K_LAYTROP
   IND0(I_LAY) = ((K_JP(I_LAY)-1)*5+(K_JT(I_LAY)-1))*NSPA(1) + 1
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/srtm_srtm_224gp.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/srtm_srtm_224gp.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/srtm_srtm_224gp.F90	(revision 2056)
@@ -1,2 +1,5 @@
+!
+! $Id$
+!
 SUBROUTINE SRTM_SRTM_224GP &
  & ( KIDIA , KFDIA  , KLON  , KLEV  , KSW , KOVLP ,&
@@ -15,5 +18,5 @@
 
 USE PARSRTM  , ONLY : JPLAY
-USE YOERDI   , ONLY : RCH4   , RN2O   
+!USE YOERDI   , ONLY : RCH4   , RN2O   
 USE YOERAD   , ONLY : NAER
 USE YOESRTAER, ONLY : RSRTAUA, RSRPIZA, RSRASYA
@@ -21,5 +24,9 @@
 USE YOMCST   , ONLY : RI0 
 
+
+
 IMPLICIT NONE
+
+#include "clesphys.h"
 
 !-- Input arguments
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/sucst.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/sucst.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/sucst.F90	(revision 2056)
@@ -289,5 +289,5 @@
   WRITE(KULOUT,'(10(1X,E10.4))') (ESW(RTT+10._JPRB*J),J=-4,4)
   WRITE(KULOUT,'(10(1X,E10.4))') (ESS(RTT+10._JPRB*J),J=-4,4)
-  call flush()       !!!!! A REVOIR (MPL) les 7 lignes qui suivent
+!  call flush(0)       !!!!! A REVOIR (MPL) les 7 lignes qui suivent
    do j=1,9
      print*,'TEST J',j
@@ -295,5 +295,5 @@
      print*,'ES(RTT...',ES(RTT+10._JPRB*(J-5))
    enddo
-  call flush()
+  call flush(0)
 
   WRITE(KULOUT,'(10(1X,E10.4))') (ES (RTT+10._JPRB*J),J=-4,4)
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/suecrad.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/suecrad.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/suecrad.F90	(revision 2056)
@@ -1,2 +1,5 @@
+!
+! $Id$
+!
 SUBROUTINE SUECRAD (KULOUT, KLEV, PETAH )
 
@@ -303,4 +306,7 @@
 !       LECMWF = .FALSE. 
 ENDIF
+
+!LRRTM  = .FALSE.
+
 !- SRTM as SW scheme
 !!!!! A REVOIR (MPL) verifier signification de LSRTM
@@ -1520,4 +1526,5 @@
 !     ------------------------------------------------------------------
 
+
 IF (LHOOK) CALL DR_HOOK('SUECRAD',1,ZHOOK_HANDLE)
 END SUBROUTINE SUECRAD
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/suphec.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/suphec.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/suphec.F90	(revision 2056)
@@ -69,10 +69,10 @@
 USE YOMCST   , ONLY : RD       ,RV       ,RCPD     ,&
  & RLVTT    ,RLSTT    ,RLMLT    ,RTT      ,RATM 
-USE YOETHF   , ONLY : R2ES     ,R3LES    ,R3IES    ,R4LES    ,&
- & R4IES    ,R5LES    ,R5IES    ,RVTMP2   ,RHOH2O   ,&
- & R5ALVCP  ,R5ALSCP  ,RALVDCP  ,RALSDCP  ,RALFDCP  ,&
- & RTWAT    ,RTBER    ,RTBERCU  ,RTICE    ,RTICECU  ,&
- & RTWAT_RTICE_R      ,RTWAT_RTICECU_R    ,&
- & RKOOP1   ,RKOOP2 
+!USE YOETHF   , ONLY : R2ES     ,R3LES    ,R3IES    ,R4LES    ,&
+! & R4IES    ,R5LES    ,R5IES    ,RVTMP2   ,RHOH2O   ,&
+! & R5ALVCP  ,R5ALSCP  ,RALVDCP  ,RALSDCP  ,RALFDCP  ,&
+! & RTWAT    ,RTBER    ,RTBERCU  ,RTICE    ,RTICECU  ,&
+! & RTWAT_RTICE_R      ,RTWAT_RTICECU_R    ,&
+! & RKOOP1   ,RKOOP2 
 USE YOMPHY   , ONLY : LRAYFM15
 !USE YOERAD   , ONLY : NSW      ,NTSW     ,&
@@ -89,5 +89,5 @@
 
 IMPLICIT NONE
-
+include "YOETHF.h"
 include "clesphys.h"
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/surdi.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/surdi.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/surdi.F90	(revision 2056)
@@ -1,2 +1,5 @@
+!
+! $Id$
+!
 SUBROUTINE SURDI
 
@@ -50,10 +53,13 @@
 
 USE YOERDI   , ONLY : RRAE     ,&
- & RCARDI   ,RCH4     ,RN2O     ,RO3      ,RCFC11   ,&
- & RCFC12   ,REPCLC   ,REPH2O   ,RSUNDUR  ,&
+! & RCARDI   ,RCH4     ,RN2O     ,RO3      ,RCFC11   ,&
+ & RCFC12, &   
+ & REPCLC   ,REPH2O   ,RSUNDUR  ,&
  & RCCO2    ,RCCH4    ,RCN2O    ,RCCFC11  ,RCCFC12
+
 
 IMPLICIT NONE
 
+!#include "clesphys.h"
 REAL(KIND=JPRB) :: ZAIRMWG, ZC11MWG, ZC12MWG, ZCH4MWG, ZCO2MWG, ZN2OMWG, ZO3MWG
 REAL(KIND=JPRB) :: ZHOOK_HANDLE
@@ -95,13 +101,15 @@
 !RCFC12  = 484.E-12_JPRB*ZC12MWG/ZAIRMWG
 
-RCARDI  = RCCO2   * ZCO2MWG/ZAIRMWG
-RCH4    = RCCH4   * ZCH4MWG/ZAIRMWG
-RN2O    = RCN2O   * ZN2OMWG/ZAIRMWG
-RO3     = 1.E-06_JPRB*ZO3MWG /ZAIRMWG
-RCFC11  = RCCFC11 * ZC11MWG/ZAIRMWG
-RCFC12  = RCCFC12 * ZC12MWG/ZAIRMWG
+!RCARDI  = RCCO2   * ZCO2MWG/ZAIRMWG
+!RCH4    = RCCH4   * ZCH4MWG/ZAIRMWG
+!RN2O    = RCN2O   * ZN2OMWG/ZAIRMWG
+!RO3     = 1.E-06_JPRB*ZO3MWG /ZAIRMWG
+!RCFC11  = RCCFC11 * ZC11MWG/ZAIRMWG
+!RCFC12  = RCCFC12 * ZC12MWG/ZAIRMWG
+
 
 REPCLC=1.E-12_JPRB
 REPH2O=1.E-12_JPRB
+
 
 !     -----------------------------------------------------------------
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/surface_fields.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/surface_fields.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/surface_fields.F90	(revision 2056)
@@ -505,4 +505,16 @@
 TYPE(TYPE_SFL_VEXTR2)  :: YSD_X2
 
+!$OMP THREADPRIVATE(ndimsurf,ndimsurfl,nofftraj,nofftraj_cst,nprogsurf)
+!$OMP THREADPRIVATE(nprogsurfl,nptrsurf,nstrajgrib,nsurf,nsurfl,ysd_va,ysd_vad)
+!$OMP THREADPRIVATE(ysd_vc,ysd_vcd,ysd_vd,ysd_vdd,ysd_vf,ysd_vfd,ysd_vh,ysd_vhd)
+!$OMP THREADPRIVATE(ysd_vn,ysd_vnd,ysd_vp,ysd_vpd,ysd_vv,ysd_vvd,ysd_vx,ysd_vxd)
+!$OMP THREADPRIVATE(ysd_ws,ysd_wsd,ysd_x2,ysd_x2d,ysd_xa,ysd_xad,ysp_ci,ysp_cid)
+!$OMP THREADPRIVATE(ysp_ep,ysp_epd,ysp_rr,ysp_rrd,ysp_sb,ysp_sbd,ysp_sg,ysp_sgd)
+!$OMP THREADPRIVATE(ysp_x2,ysp_x2d)
+
+!$OMP THREADPRIVATE(sd_va,sd_vc,sd_vd,sd_vf,sd_vh,sd_vn,sd_vp,sd_vv,sd_vx,sd_ws)
+!$OMP THREADPRIVATE(sd_x2,sd_xa,sp_ci,sp_ep,sp_rr,sp_sb,sp_sg,sp_x2,surf_store_array)
+
+
 !-------------------------------------------------------------------------
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/susw15.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/susw15.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/susw15.F90	(revision 2056)
@@ -62,4 +62,6 @@
 REAL(KIND=JPRB)   :: ZPRH2O=30000._JPRB
 REAL(KIND=JPRB)   :: ZPRUMG=30000._JPRB
+
+!$OMP THREADPRIVATE(zpdh2o,zpdumg,zprh2o,zprumg)
 
 REAL(KIND=JPRB) :: ZH2O, ZUMG
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/sw.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/sw.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/sw.F90	(revision 2056)
@@ -80,4 +80,5 @@
 
 integer, save :: icount=0
+!$OMP THREADPRIVATE(icount)
 INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
 INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/swclr.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/swclr.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/swclr.F90	(revision 2056)
@@ -5,5 +5,5 @@
  & PRK   , PRMU0 , PTAUAZ, PTRA1 , PTRA2 , PTRCLR, &
 !++MODIFCODE
-  & LRDUST,PPIZA_DST, PCGA_DST, PTAUREL_DST )
+  & LDDUST,PPIZA_DST, PCGA_DST, PTAU_DST )
 !--MODIFCODE
 
@@ -58,4 +58,5 @@
 !        Y.Seity 05-10-10 : add add 3 optional arg. for dust SW properties
 !        Y.Seity 06-09-09 : add modset from O.Thouron (MesoNH) under NOVLP tests
+!        O.Boucher fev.2014: modification sur les aerosols pour utiliser les variables DST
 !     ------------------------------------------------------------------
 
@@ -71,6 +72,5 @@
 
 IMPLICIT NONE
-
-include "clesphys.h"
+INCLUDE "clesphys.h"
 
 INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
@@ -86,8 +86,8 @@
 REAL(KIND=JPRB)   ,INTENT(IN)    :: PSEC(KLON) 
 !++MODIFCODE
-LOGICAL           ,INTENT(IN)    :: LRDUST                   ! flag for DUST
+LOGICAL           ,INTENT(IN)    :: LDDUST                   ! flag for DUST
 REAL(KIND=JPRB)   ,INTENT(IN)    :: PPIZA_DST(KLON,KLEV)
 REAL(KIND=JPRB)   ,INTENT(IN)    :: PCGA_DST(KLON,KLEV)
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAUREL_DST(KLON,KLEV)
+REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAU_DST(KLON,KLEV)
 !--MODIFCODE
 REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCGAZ(KLON,KLEV) 
@@ -157,48 +157,59 @@
 
 !++MODIFCODE  
+!--OB on fait passer les aerosols LMDZ dans la variable DST
   IF(NOVLP < 5)THEN !ECMWF VERSION
-  DO JAE=1,6
+!  DO JAE=1,6
       DO JL = KIDIA,KFDIA
-        PTAUAZ(JL,JK)=PTAUAZ(JL,JK)+PAER(JL,JAE,IKL)*RTAUA(KNU,JAE)
-        PPIZAZ(JL,JK)=PPIZAZ(JL,JK)+PAER(JL,JAE,IKL)&
-         & * RTAUA(KNU,JAE)*RPIZA(KNU,JAE)  
-        PCGAZ(JL,JK) =  PCGAZ(JL,JK) +PAER(JL,JAE,IKL)&
-         & * RTAUA(KNU,JAE)*RPIZA(KNU,JAE)*RCGA(KNU,JAE)  
+!        PTAUAZ(JL,JK)=PTAUAZ(JL,JK)+PAER(JL,JAE,IKL)*RTAUA(KNU,JAE)
+        PTAUAZ(JL,JK)=PTAU_DST(JL,IKL)
+!        PPIZAZ(JL,JK)=PPIZAZ(JL,JK)+PAER(JL,JAE,IKL)&
+!         & * RTAUA(KNU,JAE)*RPIZA(KNU,JAE)  
+        PPIZAZ(JL,JK)=PTAU_DST(JL,IKL)*PPIZA_DST(JL,IKL)
+!        PCGAZ(JL,JK) =  PCGAZ(JL,JK) +PAER(JL,JAE,IKL)&
+!         & * RTAUA(KNU,JAE)*RPIZA(KNU,JAE)*RCGA(KNU,JAE)  
+        PCGAZ(JL,JK)=PTAU_DST(JL,IKL)*PPIZA_DST(JL,IKL)*PCGA_DST(JL,IKL)
       ENDDO
-    ENDDO
+!    ENDDO
   ELSE ! MESONH VERSION
-     DO JAE=1,6
+!--OB on utilise directement les aerosols LMDZ
+!     DO JAE=1,6
         DO JL = KIDIA,KFDIA
            !Special optical properties for dust
-           IF (LRDUST.AND.(JAE==3)) THEN
+!           IF (LDDUST.AND.(JAE==3)) THEN
            !Ponderation of aerosol optical properties:first step 
            !ti
-            PTAUAZ(JL,JK)=PTAUAZ(JL,JK) + PAER(JL,JAE,IKL) * PTAUREL_DST(JL,IKL)
+!            PTAUAZ(JL,JK)=PTAUAZ(JL,JK) + PAER(JL,JAE,IKL) * PTAUREL_DST(JL,IKL)
+            PTAUAZ(JL,JK)= PTAU_DST(JL,IKL)
            !wi*ti
-             PPIZAZ(JL,JK)=PPIZAZ(JL,JK) + PAER(JL,JAE,IKL)  &
-                   & *PTAUREL_DST(JL,IKL)*PPIZA_DST(JL,IKL)
+!             PPIZAZ(JL,JK)=PPIZAZ(JL,JK) + PAER(JL,JAE,IKL)  &
+!                   & *PTAUREL_DST(JL,IKL)*PPIZA_DST(JL,IKL)
+             PPIZAZ(JL,JK)=PTAU_DST(JL,IKL)*PPIZA_DST(JL,IKL)
            !wi*ti*gi
-             PCGAZ(JL,JK) = PCGAZ(JL,JK) + PAER(JL,JAE,IKL) &
-                &  *PTAUREL_DST(JL,IKL)*PPIZA_DST(JL,IKL)*PCGA_DST(JL,IKL)
+!             PCGAZ(JL,JK) = PCGAZ(JL,JK) + PAER(JL,JAE,IKL) &
+!                &  *PTAUREL_DST(JL,IKL)*PPIZA_DST(JL,IKL)*PCGA_DST(JL,IKL)
+             PCGAZ(JL,JK) = PTAU_DST(JL,IKL)*PPIZA_DST(JL,IKL)*PCGA_DST(JL,IKL)
            !wi*ti*(gi**2)
-             ZFACOA_NEW(JL,JK)= ZFACOA_NEW(JL,JK)+PAER(JL, JAE, IKL)&
-                & *PTAUREL_DST(JL,IKL) *PPIZA_DST(JL,IKL)*PCGA_DST(JL,IKL)*&
+!             ZFACOA_NEW(JL,JK)= ZFACOA_NEW(JL,JK)+PAER(JL, JAE, IKL)&
+!                & *PTAUREL_DST(JL,IKL) *PPIZA_DST(JL,IKL)*PCGA_DST(JL,IKL)*&
+!                & PCGA_DST(JL,IKL)
+             ZFACOA_NEW(JL,JK)= ZFACOA_NEW(JL,JK)+&
+                & PTAU_DST(JL,IKL) *PPIZA_DST(JL,IKL)*PCGA_DST(JL,IKL)*&
                 & PCGA_DST(JL,IKL)
-           ELSE
+!           ELSE
            !Ponderation of aerosol optical properties:first step 
            !ti
-             PTAUAZ(JL,JK)=PTAUAZ(JL,JK)+PAER(JL, JAE, IKL)*RTAUA(KNU,JAE)
+!             PTAUAZ(JL,JK)=PTAUAZ(JL,JK)+PAER(JL, JAE, IKL)*RTAUA(KNU,JAE)
            !wi*ti
-             PPIZAZ(JL,JK)=PPIZAZ(JL,JK)+PAER(JL, JAE, IKL)&
-                &* RTAUA(KNU,JAE)*RPIZA(KNU,JAE)
+!             PPIZAZ(JL,JK)=PPIZAZ(JL,JK)+PAER(JL, JAE, IKL)&
+!                &* RTAUA(KNU,JAE)*RPIZA(KNU,JAE)
            !wi*ti*gi
-             PCGAZ(JL,JK) =  PCGAZ(JL,JK) +PAER(JL, JAE, IKL)&
-                &* RTAUA(KNU,JAE)*RPIZA(KNU,JAE)*RCGA(KNU,JAE)
+!             PCGAZ(JL,JK) =  PCGAZ(JL,JK) +PAER(JL, JAE, IKL)&
+!                &* RTAUA(KNU,JAE)*RPIZA(KNU,JAE)*RCGA(KNU,JAE)
            !wi*ti*(gi**2)
-             ZFACOA_NEW(JL,JK)= ZFACOA_NEW(JL,JK)+PAER(JL, JAE, IKL)&
-                &* RTAUA(KNU,JAE)*RPIZA(KNU,JAE)*RCGA(KNU,JAE)*RCGA(KNU,JAE)
-           ENDIF
+!             ZFACOA_NEW(JL,JK)= ZFACOA_NEW(JL,JK)+PAER(JL, JAE, IKL)&
+!                &* RTAUA(KNU,JAE)*RPIZA(KNU,JAE)*RCGA(KNU,JAE)*RCGA(KNU,JAE)
+!           ENDIF
         ENDDO
-     ENDDO
+!     ENDDO
   ENDIF
 !--MODIFCODE  
@@ -217,5 +228,5 @@
 !-- bug-fix: ZRATIO must be defined from the transformed value of optical thickness
 ! MPLFH : ZTRAY N'EST PAS INITIALISE !!!!! A REVOIR (MPL)
-      ZTRAY=0.
+      ZTRAY= PRAYL(JL) * PDSIG(JL,JK)
 !     print *,'>>>>>>> swclr: ZTRAY ',ZTRAY
       ZDENB = ZTRAY + PTAUAZ(JL,JK)*(1.0_JPRB-PPIZAZ(JL,JK)*ZFF)
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/swr.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/swr.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/swr.F90	(revision 2056)
@@ -161,5 +161,5 @@
 !++MODIFCODE
   IF (NOVLP >= 5) THEN !MESONH VERSION
-   stop'provisoire pour verifier option novlp=1'
+   stop 'provisoire pour verifier option novlp=1'
    ZFACOA =PTAUAZ(JL,IKL) 
    ZFACOC = 1.0_JPRB - POMEGA(JL,KNU,IKL) * PCG(JL,KNU,IKL)* PCG(JL,KNU,IKL)
@@ -192,5 +192,5 @@
     ZCLOUD(JL) = ZSS1(JL)
   ELSEIF (NOVLP == 2) THEN
-   stop'provisoire pour verifier option novlp=1b'
+   stop 'provisoire pour verifier option novlp=1b'
 !* maximum
     ZCLOUD(JL) = MAX( ZSS1(JL) , ZCLOUD(JL) )
@@ -198,5 +198,5 @@
 !++MODIFCODE
   ELSEIF ((NOVLP == 3).OR.((NOVLP  >=  5).AND.(NOVLP /= 8))) THEN
-   stop'provisoire pour verifier option novlp=1c'
+   stop 'provisoire pour verifier option novlp=1c'
 !--MODIFCODE
 !* random
@@ -205,5 +205,5 @@
     ZC1I(JL,IKL) = ZCLOUD(JL)
   ELSEIF (NOVLP == 4) THEN
-   stop'provisoire pour verifier option novlp=1d'
+   stop 'provisoire pour verifier option novlp=1d'
 !* Hogan & Illingworth, 2001  
     ZCLEAR(JL)=ZCLEAR(JL)*( &
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_dim.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_dim.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_dim.F90	(revision 2056)
@@ -32,3 +32,7 @@
 TYPE(DIM_TYPE),POINTER     :: R
 
+!$OMP THREADPRIVATE(r)
+!$OMP THREADPRIVATE(dim_resol)
+
+
 END MODULE TPM_DIM
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_distr.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_distr.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_distr.F90	(revision 2056)
@@ -152,4 +152,10 @@
 TYPE(DISTR_TYPE),POINTER     :: D
 
+!$OMP THREADPRIVATE(d,leq_regions,mtagdistgp,mtagdistsp,mtaggl,mtagletr)
+!$OMP THREADPRIVATE(mtaglg,mtaglm,mtagml,mtagpart,myproc,mysetv,mysetw)
+!$OMP THREADPRIVATE(ncombflen,nprgpew,nprgpns,nproc,nprtrns,nprtrv,nprtrw)
+
+!$OMP THREADPRIVATE(distr_resol)
+
 END MODULE TPM_DISTR
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_fft.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_fft.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_fft.F90	(revision 2056)
@@ -14,3 +14,5 @@
 TYPE(FFT_TYPE),POINTER     :: T
 
+!$OMP THREADPRIVATE(t)
+
 END MODULE TPM_FFT
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_gen.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_gen.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_gen.F90	(revision 2056)
@@ -23,3 +23,6 @@
 LOGICAL   :: LMPOFF          ! true: switch off message passing
 
+!$OMP THREADPRIVATE(lalloperm,limp,limp_noolap,lmpoff,msetup0,ncur_resol)
+!$OMP THREADPRIVATE(ndef_resol,nerr,nmax_resol,nout,nprintlev,npromatr)
+
 END MODULE TPM_GEN
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_geometry.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_geometry.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_geometry.F90	(revision 2056)
@@ -19,3 +19,6 @@
 TYPE(GEOM_TYPE),POINTER     :: G
 
+!$OMP THREADPRIVATE(g)
+!$OMP THREADPRIVATE(geom_resol)
+
 END MODULE TPM_GEOMETRY
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_trans.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_trans.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/tpm_trans.F90	(revision 2056)
@@ -42,3 +42,8 @@
 INTEGER(KIND=JPIM) :: NGPBLKS ! Number of NPROMA blocks
 
+!$OMP THREADPRIVATE(ldivgp,lscders,luvder,lvorgp,nf_sc2,nf_sc3a,nf_sc3b,ngpblks,nproma)
+!$OMP THREADPRIVATE(foubuf_in,foubuf)
+
 END MODULE TPM_TRANS
+
+
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoe_mcica.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoe_mcica.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoe_mcica.F90	(revision 2056)
@@ -12,3 +12,6 @@
 
 !------------------------------------------------------------------------------
+
+!$OMP THREADPRIVATE(nmci1,nmci2,xcw)
+
 END MODULE YOE_McICA
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoe_tile_prop.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoe_tile_prop.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoe_tile_prop.F90	(revision 2056)
@@ -19,3 +19,4 @@
 REAL(KIND=JPRB),ALLOCATABLE :: RTSKTI (:,:,:) ! SKIN TEMPERATURE 
 
+!$OMP THREADPRIVATE(rahfsti,revapti,rtskti,rustrti,rvstrti)
 END MODULE YOE_TILE_PROP
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoe_uvrad.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoe_uvrad.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoe_uvrad.F90	(revision 2056)
@@ -22,4 +22,8 @@
 REAL(KIND=JPRB) :: RFCAER, RFCOZO, RMUZUV
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(ipuv,jcop,juvlam,luvdbg,luvproc,luvtdep,nraduv,nuv,nuvtim,rasa,rasb)
+!$OMP THREADPRIVATE(rasc,rasd,rase,rasf,rayuvb,rcguva,rcieas,rfa0,rfa1,rfb0,rfb1,rfb2,rfb3)
+!$OMP THREADPRIVATE(rfc0,rfc1,rfc2,rfc3,rfcaer,rfcozo,rfd0,rfd1,rfd2,rfd3,rk250,rmuzuv,rpiuva)
+!$OMP THREADPRIVATE(rsuvb,rsuvb0,rtauva,rtuv1,rtuv2,ruvlam,rxpl,rxpo)
 END MODULE YOE_UVRAD
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeaeratm.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeaeratm.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeaeratm.F90	(revision 2056)
@@ -45,4 +45,10 @@
 ! LAER6SDIA  : .T. if radiance diagnostics with 6S
 !     ------------------------------------------------------------------
+
+
+!$OMP THREADPRIVATE(indbg,laer6sdia,laerclimg,laerclimz,laerclist,laerdrydp)
+!$OMP THREADPRIVATE(laergbud,laerngat,laerprnt,laerscav,laersedim,laersurf)
+!$OMP THREADPRIVATE(ndd1,nss1,repscaer,rmasse,rmfmin)
+
 END MODULE YOEAERATM
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeaerd.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeaerd.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeaerd.F90	(revision 2056)
@@ -65,3 +65,10 @@
 
 !     ------------------------------------------------------------------
+
+!$OMP THREADPRIVATE(raedc,raeds,raelc,raels,raesc,raess,raeuc,raeus)
+!$OMP THREADPRIVATE(rcaeadk,rcaeadm,rcaeopd,rcaeopl,rcaeops,rcaeopu)
+!$OMP THREADPRIVATE(rcaeros,rcstbga,rctrbga,rctrpt,rcvobga)
+
+!$OMP THREADPRIVATE(cvdaed,cvdael,cvdaes,cvdaeu)
+
 END MODULE YOEAERD
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeaerop.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeaerop.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeaerop.F90	(revision 2056)
@@ -31,4 +31,8 @@
 ! OMG is pizero, the single scattering albedo	     ND
 !     ------------------------------------------------------------------
+
+!$OMP THREADPRIVATE(alf_bc,alf_dd,alf_fa,alf_om,alf_ss,alf_su,asy_bc,asy_dd)
+!$OMP THREADPRIVATE(asy_fa,asy_om,asy_ss,asy_su,omg_bc,omg_dd,omg_fa,omg_om,omg_ss,omg_su)
+
 END MODULE YOEAEROP
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeaersnk.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeaersnk.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeaersnk.F90	(revision 2056)
@@ -58,4 +58,10 @@
 ! RVSEDLIC   :
 !     -----------------------------------------------------------------
+
+!$OMP THREADPRIVATE(nbrh,r_r,r_s,ralphar,ralphas,rfraer,rfrbc,rfrdd,rfrgas)
+!$OMP THREADPRIVATE(rfrif,rfrom,rfrso4,rfrss,rho_ice,rho_wat,rmmd_dd,rmmd_ss)
+!$OMP THREADPRIVATE(rrhmax,rrho_dd,rrho_ss,rrhtab,rssgrow,rvdplic,rvdplnd)
+!$OMP THREADPRIVATE(rvdpoce,rvdpsic,rvsedlic,rvsedlnd,rvsedoce,rvsedsic)
+
 END MODULE YOEAERSNK
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeaersrc.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeaersrc.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeaersrc.F90	(revision 2056)
@@ -44,4 +44,11 @@
 ! JDDUST     : 1 =LSCE, 2 =based on MODIS
 !     ------------------------------------------------------------------
+
+
+
+!$OMP THREADPRIVATE(jkbin,jktyp,laerextr,lepaero,nbinaer,nddust,nindaer)
+!$OMP THREADPRIVATE(nmaxtaer,ntaer,ntypaer,rclonv,rdclonv,rdglav,rdgmuv)
+!$OMP THREADPRIVATE(rdslonv,rgelav,rgemuv,rlatvol,rlonvol,rslonv,rssflx)
+
 END MODULE YOEAERSRC
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoecld.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoecld.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoecld.F90	(revision 2056)
@@ -70,3 +70,10 @@
 !  LOMEGA:  LOGICAL  SWITCH FOR OMEGA-FILTER ON MIDDLE CLOUD
 !     ------------------------------------------------------------------
+
+!$OMP THREADPRIVATE(lomega,ranva,ranvb,ranvh,rcca,rccb,rccc,rcfct)
+!$OMP THREADPRIVATE(rclwmr,rcscal,repscr,repsec,retahb,retamb,rgammas)
+!$OMP THREADPRIVATE(rloia,rloib,rloic,rloid,rlonia,rlonib,rrhh,rrhl,rrhm)
+
+!$OMP THREADPRIVATE(ceta)
+
 END MODULE YOECLD
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeclop.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeclop.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeclop.F90	(revision 2056)
@@ -83,3 +83,10 @@
 ! RRIW   :  REAL   : TRANSITION RANGE
 !     -----------------------------------------------------------------
+
+
+!$OMP THREADPRIVATE(raswca,raswcb,raswcc,raswcd,raswce,raswcf,rebcua)
+!$OMP THREADPRIVATE(rebcub,rebcuc,rebcud,rebcue,rebcuf,rebcug,rebcuh)
+!$OMP THREADPRIVATE(rebcui,rebcuj,reffia,reffib,rriw,rtiw,ryfwca)
+!$OMP THREADPRIVATE(ryfwcb,ryfwcc,ryfwcd,ryfwce,ryfwcf)
+
 END MODULE YOECLOP
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoecnd.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoecnd.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoecnd.F90	(revision 2056)
@@ -23,3 +23,8 @@
 ! REPQMI :  Minimum specific humidity (security within QNEGAT)
 !     -----------------------------------------------------------------
+
+!$OMP THREADPRIVATE(repflm,repfls,repqmi)
+
+!$OMP THREADPRIVATE(cevapcu)
+
 END MODULE YOECND
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoedbug.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoedbug.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoedbug.F90	(revision 2056)
@@ -12,4 +12,7 @@
 INTEGER(KIND=JPIM) :: KSTPDBG(3)
 !     ------------------------------------------------------------------
+
+!$OMP THREADPRIVATE(kstpdbg)
+
 END MODULE YOEDBUG
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoelw.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoelw.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoelw.F90	(revision 2056)
@@ -79,3 +79,8 @@
 !  RVGO3 :  REAL     RESIDUAL PRESSURE FOR O3  VOIGT LINE HALF-WIDTH
 !     ------------------------------------------------------------------
+
+
+!$OMP THREADPRIVATE(alwt,blwt,mxixt,ng1,ng1p1,nipd,nipd2,nsil,ntr,ntra,nua)
+!$OMP THREADPRIVATE(pdga,pdgb,retype,rntnu,ro1h,ro2h,ro3t,rpialf0,rptype,rt1)
+!$OMP THREADPRIVATE(rvgco2,rvgh2o,rvgo3,tintp,tref,tstand,tstp,wg1,xp)
 END MODULE YOELW
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeovlp.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeovlp.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoeovlp.F90	(revision 2056)
@@ -21,3 +21,4 @@
 
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(ra1ovlp)
 END MODULE YOEOVLP
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoephli.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoephli.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoephli.F90	(revision 2056)
@@ -56,3 +56,7 @@
 !                          ACTIVATED
 !     ------------------------------------------------------------------
+
+!$OMP THREADPRIVATE(lenopert,leppcfls,lphylin,lraisanen,rlpal1,rlpal2,rlpbb)
+!$OMP THREADPRIVATE(rlpbeta,rlpcc,rlpdd,rlpdrag,rlpevap,rlpmixl,rlpp00,rlptrc)
+
 END MODULE YOEPHLI
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoephy.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoephy.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoephy.F90	(revision 2056)
@@ -93,3 +93,10 @@
 ! LE4ALB : LOGICAL  : MODIS ALBEDO (UV-Vis+NIR)x(direct+diffuse) 
 !     -----------------------------------------------------------------
+
+!$OMP THREADPRIVATE(lagphy,lbud23,le4alb,leco2diu,lecond,lecumf,lecurr,ledcld)
+!$OMP THREADPRIVATE(leevap,legwdg,lemethox,lemwave,leo3ch,leocco,leocsa,leocwa)
+!$OMP THREADPRIVATE(leozoc,lepcld,lephys,leqngt,lera40,leradi,lerads,lerain)
+!$OMP THREADPRIVATE(leshcv,lesice,lesurf,levdif,lmftrac,lvdftrac,nephys_pcfull)
+!$OMP THREADPRIVATE(nphproma,nphyint,rthrfrti)
+
 END MODULE YOEPHY
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerad.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerad.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerad.F90	(revision 2056)
@@ -170,3 +170,12 @@
 !                     2: McICA w generalized overlap in cloud generator
 !     ------------------------------------------------------------------
+
+!$OMP THREADPRIVATE(crtabledir,crtablefil,lccnl,lccno,ldiffc,leco2var,lecsrad)
+!$OMP THREADPRIVATE(ledbug,lepo3ra,lerad1h,leradhs,lhghg,lhvolca,lnewaer,lnotroaer)
+!$OMP THREADPRIVATE(lonewsw,loptrproma,lradlb,lrayl,lrrtm,lsrtm,naer,ncsradf,nhincsol)
+!$OMP THREADPRIVATE(niceopt,ninhom,nlayinh,nliqopt,nlngr1h,nlw,nmcica,nmode,novlp,nozocl)
+!$OMP THREADPRIVATE(npertaer,npertoz,nradfr,nradint,nradip,nradlp,nradnfr,nradpfr,nradpla)
+!$OMP THREADPRIVATE(nradres,nradsfr,nrint,nrproma,nscen,nswnl,nswtl,ntsw,nuv,raovlp)
+!$OMP THREADPRIVATE(rbovlp,rccnlnd,rccnsea,rlwinhf,rpertoz,rre2de,rswinhf)
+
 END MODULE YOERAD
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerdi.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerdi.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerdi.F90	(revision 2056)
@@ -40,3 +40,8 @@
 !          TO BE MORE THAN THE RESPECTIVE VALUE AT SATURATION.
 !     -----------------------------------------------------------------
+
+!$OMP THREADPRIVATE(rcardi,rccfc11,rccfc12,rcch4,rcco2,rcfc11,rcfc12,rch4)
+!$OMP THREADPRIVATE(rcn2o,repclc,reph2o,rfvar,rhvar,rincsol,rn2o,ro3,rrae)
+!$OMP THREADPRIVATE(rsolinc,rsundur)
+
 END MODULE YOERDI
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerdu.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerdu.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerdu.F90	(revision 2056)
@@ -49,3 +49,7 @@
 
 !     -----------------------------------------------------------------
+
+
+!$OMP THREADPRIVATE(diff,nimp,nout,ntraer,nuaer,r10e,rcday,replog,repsc,repsco,repscq,repsct,repscw)
+
 END MODULE YOERDU
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtab.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtab.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtab.F90	(revision 2056)
@@ -24,4 +24,7 @@
 ! BPADE  :  REAL     
 !     -----------------------------------------------------------------
+
+!$OMP THREADPRIVATE(bpade,trans)
+
 END MODULE YOERRTAB
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtbg2.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtbg2.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtbg2.F90	(revision 2056)
@@ -26,4 +26,6 @@
 ! CORR2  :  REAL   :
 !    -------------------------------------------------------------------
+!$OMP THREADPRIVATE(corr1,corr2)
+
 END MODULE YOERRTBG2
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtftr.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtftr.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtftr.F90	(revision 2056)
@@ -35,4 +35,7 @@
 !  WT    : REAL    :
 !    -------------------------------------------------------------------
+
+!$OMP THREADPRIVATE(ngb,ngc,ngm,ngn,ngs,wt)
+
 END MODULE YOERRTFTR
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto1.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto1.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto1.F90	(revision 2056)
@@ -33,3 +33,4 @@
 ! SELFREFO: REAL     
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(forrefo,fracrefao,fracrefbo,kao,kbo,selfrefo)
 END MODULE YOERRTO1
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto10.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto10.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto10.F90	(revision 2056)
@@ -32,3 +32,6 @@
 ! KB      : REAL     
 !     -----------------------------------------------------------------
+
+!$OMP THREADPRIVATE(fracrefao,fracrefbo,kao,kbo) 
+
 END MODULE YOERRTO10
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto11.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto11.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto11.F90	(revision 2056)
@@ -34,3 +34,5 @@
 ! SELFREF : REAL     
 !     -----------------------------------------------------------------
+
+!$OMP THREADPRIVATE(fracrefao,fracrefbo,kao,kbo,selfrefo)
 END MODULE YOERRTO11
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto12.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto12.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto12.F90	(revision 2056)
@@ -29,3 +29,6 @@
 ! SELFREF : REAL
 !     -----------------------------------------------------------------
+
+!$OMP THREADPRIVATE(fracrefao,kao,selfrefo)
+
 END MODULE YOERRTO12
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto13.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto13.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto13.F90	(revision 2056)
@@ -30,3 +30,4 @@
 ! SELFREF : REAL
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(fracrefao,kao,selfrefo)
 END MODULE YOERRTO13
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto14.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto14.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto14.F90	(revision 2056)
@@ -34,3 +34,4 @@
 ! SELFREF : REAL     
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(fracrefao,fracrefbo,kao,kbo,selfrefo)
 END MODULE YOERRTO14
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto15.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto15.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto15.F90	(revision 2056)
@@ -30,3 +30,4 @@
 ! SELFREF : REAL 
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(fracrefao,kao,selfrefo)
 END MODULE YOERRTO15
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto16.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto16.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto16.F90	(revision 2056)
@@ -30,3 +30,4 @@
 ! SELFREF : REAL     
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(fracrefao,kao,selfrefo)
 END MODULE YOERRTO16
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto2.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto2.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto2.F90	(revision 2056)
@@ -35,3 +35,4 @@
 ! FORREFO : REAL  
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(forrefo,fracrefao,fracrefbo,kao,kbo,selfrefo)
 END MODULE YOERRTO2
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto3.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto3.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto3.F90	(revision 2056)
@@ -39,3 +39,4 @@
 ! SELFREFO: REAL     
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(absn2oao,absn2obo,forrefo,fracrefao,fracrefbo,kao,kbo,selfrefo)
 END MODULE YOERRTO3
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto4.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto4.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto4.F90	(revision 2056)
@@ -32,3 +32,4 @@
 ! SELFREF : REAL     
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(fracrefao,fracrefbo,kao,kbo,selfrefo)
 END MODULE YOERRTO4
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto5.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto5.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto5.F90	(revision 2056)
@@ -35,3 +35,4 @@
 ! SELFREF : REAL     
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(ccl4o,fracrefao,fracrefbo,kao,kbo,selfrefo)
 END MODULE YOERRTO5
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto6.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto6.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto6.F90	(revision 2056)
@@ -34,3 +34,4 @@
 ! SELFREF : REAL     
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(absco2o,cfc11adjo,cfc12o,fracrefao,kao,selfrefo)
 END MODULE YOERRTO6
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto7.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto7.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto7.F90	(revision 2056)
@@ -35,3 +35,4 @@
 ! SELFREF : REAL  
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(absco2o,fracrefao,fracrefbo,kao,kbo,selfrefo)
 END MODULE YOERRTO7
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto8.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto8.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto8.F90	(revision 2056)
@@ -46,3 +46,4 @@
 ! SELFREF : REAL     
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(absco2ao,absco2bo,absn2oao,absn2obo,cfc12o,cfc22adjo,fracrefao,fracrefbo,kao,kbo,selfrefo)
 END MODULE YOERRTO8
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto9.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto9.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrto9.F90	(revision 2056)
@@ -42,3 +42,4 @@
 ! SELFREF : REAL     
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(absn2oo,fracrefao,fracrefbo,kao,kbo,selfrefo)
 END MODULE YOERRTO9
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtrf.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtrf.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtrf.F90	(revision 2056)
@@ -26,3 +26,4 @@
 ! TREF   : REAL
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(pref,preflog,tref)
 END MODULE YOERRTRF
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtrwt.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtrwt.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtrwt.F90	(revision 2056)
@@ -32,3 +32,4 @@
 ! RWT    :  REAL   : 
 !    -------------------------------------------------------------------
+!$OMP THREADPRIVATE(frefa,frefadf,frefb,frefbdf,rwgt)
 END MODULE YOERRTRWT
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtwn.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtwn.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoerrtwn.F90	(revision 2056)
@@ -36,3 +36,4 @@
 ! TOTPLK16: REAL    :
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(delwave,ng,nspa,nspb,totplk16,totplnk,wavenum1,wavenum2)
 END MODULE YOERRTWN
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesat.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesat.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesat.F90	(revision 2056)
@@ -53,3 +53,4 @@
 ! RGEAS : REAL    : LATITUDE OF EAST  LIMIT OF FIELD OF VIEW
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(lgeose,lgeosw,lgms,lindsa,lmto,lnoaa,lnoab,lnoac,lnoad,ngeo,npolo,rgalt,rgeas,rgnad,rgnor,rgsou,rgwst)
 END MODULE YOESAT
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesrtaer.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesrtaer.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesrtaer.F90	(revision 2056)
@@ -32,4 +32,5 @@
 
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(rsrasya,rsrpiza,rsrtaua)
 END MODULE YOESRTAER
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesrtcop.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesrtcop.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesrtcop.F90	(revision 2056)
@@ -127,4 +127,10 @@
 
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(rsaswa,rsaswb,rsaswc,rsaswd,rsaswe,rsaswf,rsecia,rsecib)
+!$OMP THREADPRIVATE(rsecic,rsecid,rsecie,rsecif,rsfla0,rsfla1,rsflb0,rsflb1)
+!$OMP THREADPRIVATE(rsflb2,rsflb3,rsflc0,rsflc1,rsflc2,rsflc3,rsfld0,rsfld1)
+!$OMP THREADPRIVATE(rsfld2,rsfld3,rsfua0,rsfua1,rsfub0,rsfub1,rsfub2,rsfub3)
+!$OMP THREADPRIVATE(rsfuc0,rsfuc1,rsfuc2,rsfuc3,rsssia,rsssie,rsssif,rsssig)
+!$OMP THREADPRIVATE(rsssih,rsssik,rsyfwa,rsyfwb,rsyfwc,rsyfwd,rsyfwe,rsyfwf)
 END MODULE YOESRTCOP
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesrtop.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesrtop.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesrtop.F90	(revision 2056)
@@ -40,4 +40,7 @@
 !                    FU, 1996, J. CLIM., 9, 
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(abscld1,abscoice,abscoliq,asyice2,asyice3,asyliq1,extcoice)
+!$OMP THREADPRIVATE(extcoliq,extice2,extice3,extliq1,fdelta,fdlice3,forwice,forwliq)
+!$OMP THREADPRIVATE(gice,gliq,ssacoice,ssacoliq,ssaice2,ssaice3,ssaliq1)
 END MODULE YOESRTOP
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesrtwn.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesrtwn.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesrtwn.F90	(revision 2056)
@@ -61,4 +61,6 @@
 !  RWGT   : REAL    : 
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(delwave,ng,ngbsw,ngc,ngm,ngn,ngs,nmpsrtm,nspa,nspb)
+!$OMP THREADPRIVATE(pref,preflog,rwgt,tref,wavenum1,wavenum2,wt,wtsm)
 END MODULE YOESRTWN
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesw.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesw.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoesw.F90	(revision 2056)
@@ -264,3 +264,15 @@
 ! NMPSRTM: INTEGER  : Indices for mapping SW[1:6] albedo into SRTM[1:14]  
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(apad,bpad,d,nexpo3,nmpsrtm,ntyps,radjust,raer,raswca)
+!$OMP THREADPRIVATE(raswcb,raswcc,raswcd,raswce,raswcf,rcga,rebcua,rebcub)
+!$OMP THREADPRIVATE(rebcuc,rebcud,rebcue,rebcuf,rebcug,rebcuh,rebcui,rebcuj)
+!$OMP THREADPRIVATE(reffia,reffib,rexpo3,rflaa0,rflaa1,rflbb0,rflbb1,rflbb2)
+!$OMP THREADPRIVATE(rflbb3,rflcc0,rflcc1,rflcc2,rflcc3,rfldd0,rfldd1,rfldd2)
+!$OMP THREADPRIVATE(rfldd3,rfuaa0,rfuaa1,rfubb0,rfubb1,rfubb2,rfubb3,rfucc0)
+!$OMP THREADPRIVATE(rfucc1,rfucc2,rfucc3,rfueta,rfuetb,rfuetc,rfulio,rhsavi)
+!$OMP THREADPRIVATE(rhsra,rhsrb,rhsrc,rhsrd,rhsre,rhsrf,rhsrta,rhsrtb,rlilia)
+!$OMP THREADPRIVATE(rlilib,rpdh1,rpdu1,rpiza,rpnh,rpnu,rrasy,rray,rriw,rroma)
+!$OMP THREADPRIVATE(rromb,rsusha,rsushc,rsushd,rsushe,rsushf,rsushfa,rsushg)
+!$OMP THREADPRIVATE(rsushh,rsushk,rswce,rswcp,rtaua,rtdh2o,rtdumg,rth2o,rtiw)
+!$OMP THREADPRIVATE(rtumg,rtweight,rweight,rweigs,rweigv,ryfwca,ryfwcb,ryfwcc,ryfwcd,ryfwce,ryfwcf)
 END MODULE YOESW
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoethf.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoethf.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoethf.F90	(revision 2056)
@@ -60,3 +60,6 @@
 
 !       ----------------------------------------------------------------
+!$OMP THREADPRIVATE(r2es,r3ies,r3les,r4ies,r4les,r5alscp,r5alvcp,r5ies,r5les)
+!$OMP THREADPRIVATE(ralfdcp,ralsdcp,ralvdcp,rhoh2o,rkoop1,rkoop2,rtber,rtbercu)
+!$OMP THREADPRIVATE(rtice,rticecu,rtwat,rtwat_rtice_r,rtwat_rticecu_r,rvtmp2)
 END MODULE YOETHF
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoevdf.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoevdf.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoevdf.F90	(revision 2056)
@@ -42,3 +42,4 @@
 !     *RPARSRF*   REAL     *DEPTH OF SURFACE LAYER AS FRACTION OF PBL-H 
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(nvtypes,rentr,repdu2,rkap,rlam,rpar,rpar1,rparsrf,rvdifts)
 END MODULE YOEVDF
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yoewcou.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yoewcou.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yoewcou.F90	(revision 2056)
@@ -112,3 +112,5 @@
 
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(cbegdat,lwcou,lwcou2w,lwcounorms,lwvin_mask_not_set,lwvin_uninitialised,mwvin_recvtot)
+!$OMP THREADPRIVATE(mwvin_sendtot,ndurat,nlat1w,nlatw,nlon1w,nlonw,nnorxw,nresum,nstpw,rdegrew,rnortw,rsoutw)
 END MODULE YOEWCOU
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yom_phys_grid.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yom_phys_grid.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yom_phys_grid.F90	(revision 2056)
@@ -110,3 +110,5 @@
 TYPE(TYPE_DYN_POINT),ALLOCATABLE :: YDYNPOI(:)
  
+!$OMP THREADPRIVATE(dyn_grid,dyn_sl,phys_grid,phys_sl)
+!$OMP THREADPRIVATE(ydynpoi,yphypoi)
 END MODULE YOM_PHYS_GRID
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yom_ygfl.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yom_ygfl.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yom_ygfl.F90	(revision 2056)
@@ -121,3 +121,9 @@
 
 !------------------------------------------------------------------
+!$OMP THREADPRIVATE(laerosfc,lghgsfc,lsf6sfc,nactaero,naero,ngfl_ext,ngfl_ezdiag,ngfl_forc,nghg,ngrg)
+!$OMP THREADPRIVATE(ntrac,ya,ya_nl,yaero,yaero_nl,ycpf,ycpf_nl,ycvgq,ycvgq_nl,ycvv,ycvv_nl,ydal,ydal_nl)
+!$OMP THREADPRIVATE(ydom,ydom_nl,yext,yext_nl,yezdiag,yezdiag_nl,yforc,yforc_nl,yg,yg_nl,ygfl,ygflc,yghg)
+!$OMP THREADPRIVATE(yghg_nl,ygrg,ygrg_nl,yi,yi_nl,yl,yl_nl,yo3,yo3_nl,yq,yq_nl,yqva,yqva_nl,yr,yr_nl,ys)
+!$OMP THREADPRIVATE(ys_nl,ysdsat,ysdsat_nl,yspf,yspf_nl,ysrc,ysrc_nl,ytke,ytke_nl,ytrac,ytrac_nl,yual)
+!$OMP THREADPRIVATE(yual_nl,yuen,yuen_nl,yunebh,yunebh_nl,yuom,yuom_nl)
 END MODULE YOM_YGFL
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomaer15.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomaer15.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomaer15.F90	(revision 2056)
@@ -32,3 +32,4 @@
 REAL(KIND=JPRB) :: RAER15 (5,6)
 
+!$OMP THREADPRIVATE(raer15,rcga15,rpiza15,taua15)
 END MODULE YOMAER15
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomaerd15.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomaerd15.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomaerd15.F90	(revision 2056)
@@ -70,3 +70,6 @@
 !     *RCAEROS15*  REAL      *BACKGROUND VALUE IN ABSENCE OF AEROSOLS.
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(raedc15,raeds15,raelc15,raels15,raesc15,raess15,raeuc15,raeus15,rcaeadk15,rcaeadm15)
+!$OMP THREADPRIVATE(rcaeopd15,rcaeopf15,rcaeopl15,rcaeops15,rcaeopu15,rcaeros15,rcstbga15,rctrbga15,rctrpt15,rcvobga15)
+!$OMP THREADPRIVATE(cvdaed15,cvdaef15,cvdael15,cvdaes15,cvdaeu15)
 END MODULE YOMAERD15
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomarar.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomarar.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomarar.F90	(revision 2056)
@@ -98,3 +98,9 @@
 
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(larobu_enable,ldiagwmax,losigmas,losubg_aucv,losubg_cond,lowarm,lsquall)
+!$OMP THREADPRIVATE(macprg,macprr,macprs,malbdir,malbsca,mfrthds,mgz0,mgz0h,minprg,minprr,minprs)
+!$OMP THREADPRIVATE(mpabsm,mpsurf,mqvm,mrain,mrhodref,msfrv,msfsv,msfth,msfu,msfv,msnow,mswdif)
+!$OMP THREADPRIVATE(mswdir,mtm,mum,mvemis,mvm,mvqs,mvts,mzz,ndiagfr,ndiagwmax,ndtchem,ngpar)
+!$OMP THREADPRIVATE(nprintfr,nptp,nrefroi1,nrefroi2,nrr,nrri,nrrl,nsplitr,nsv,nswb_mnh,vsquall)
+!$OMP THREADPRIVATE(nbuproc,njbudg1,njbudg2,xsw_bands)
 END MODULE YOMARAR
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomarphy.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomarphy.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomarphy.F90	(revision 2056)
@@ -41,4 +41,5 @@
 CHARACTER(LEN=1) :: CCOUPLING
 !    -------------------------------------------------------------------
+!$OMP THREADPRIVATE(ccoupling,lbuflux,lkfbconv,lkfbd,lkfbs,lmicro,lmpa,lmse,lorilam,lrdust,lturb,lusechem)
 END MODULE YOMARPHY
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomcape.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomcape.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomcape.F90	(revision 2056)
@@ -44,3 +44,4 @@
 
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(gcapepsd,gcaperet,ncapeiter,netapes)
 END MODULE YOMCAPE
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomcli.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomcli.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomcli.F90	(revision 2056)
@@ -107,3 +107,8 @@
 REAL(KIND=JPRB) :: SZZ0D
 
+!$OMP THREADPRIVATE(edlat,edlon,elatne,elatsw,elonne,elonsw,lglobe,lieee,ndatx,ndaty)
+!$OMP THREADPRIVATE(nglobx,ngloby,npint,nslice,ntpdes,ntpgla,ntplac,ntpmer,salbb,salbd)
+!$OMP THREADPRIVATE(salbg,salbm,salbn,salbx,sargd,sargn,sargx,sdepd,sdepn,sdepx,semib)
+!$OMP THREADPRIVATE(semid,semig,semim,semin,semix,sfcz0,smanq,smask,srsmd,srsmn,srsmx)
+!$OMP THREADPRIVATE(ssabd,ssabn,ssabx,sther,str,sveg,swr,szz0b,szz0d,szz0m,szz0n,szz0u)
 END MODULE YOMCLI
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomclop15.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomclop15.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomclop15.F90	(revision 2056)
@@ -67,3 +67,5 @@
 ! RRIW15   :  REAL   :  TRANSITION RANGE
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(rebcua15,rebcub15,rebcuc15,rebcud15,rebcue15,rebcuf15,rebcug15,rebcuh15)
+!$OMP THREADPRIVATE(reffia15,reffib15,reffwia15,rriw15,rtiw15,ryfwca15,ryfwcb15,ryfwcc15,ryfwcd15,ryfwce15,ryfwcf15)
 END MODULE YOMCLOP15
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomcoaphy.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomcoaphy.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomcoaphy.F90	(revision 2056)
@@ -21,3 +21,4 @@
 CHARACTER (LEN = 256) ::   CPTABLEDIR
 
+!$OMP THREADPRIVATE(cptabledir,cptablefil,nphyint,phys_gppbuf)
 END MODULE YOMCOAPHY
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomcst.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomcst.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomcst.F90	(revision 2056)
@@ -79,3 +79,7 @@
 
 !    ------------------------------------------------------------------
+!$OMP THREADPRIVATE(r,r1sa,ra,ralpd,ralps,ralpw,ratm,rbetd,rbets,rbetw,rclum,rcpd,rcpv,rcs,rcvd,rcvv,rcw)
+!$OMP THREADPRIVATE(rd,rday,rdt,rea,repsm,restt,retv,rg,rgamd,rgams,rgamw,rhpla,ri0,rkappa,rkbol,rlmlt)
+!$OMP THREADPRIVATE(rlstt,rlszer,rlvtt,rlvzer,rmch4,rmco,rmco2,rmd,rmhcho,rmn2o,rmno2,rmo3,rmra,rmsf6)
+!$OMP THREADPRIVATE(rmso2,rmv,rnavo,romega,rpi,rsiday,rsigma,rsiyea,rtt,rv)
 END MODULE YOMCST
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomct0.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomct0.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomct0.F90	(revision 2056)
@@ -467,3 +467,16 @@
 LOGICAL ::  LSFORC
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(cfclass,cfdirlst,cfpncf,cndispp,cnmexp,cnppath,ctype,l_screen_call,l_split_screen,lallopr,lalltc)
+!$OMP THREADPRIVATE(laprxpk,larome,larpegef,larpegef_rdgp_init,larpegef_rdgp_trajbg,larpegef_rdgp_trajhr)
+!$OMP THREADPRIVATE(larpegef_trajbg,larpegef_trajhr,lbackg,lcanari,lcasig,lelam,lfbdap,lfdbop,lfpart2,lfpos)
+!$OMP THREADPRIVATE(lgrbop,lguess,lifsmin,lifstraj,lminim,lmpdiag,lmpoff,lnf,lnhdyn,lnobgon,lobs,lobsc1,lobsref)
+!$OMP THREADPRIVATE(loldpp,lopdis,loutput,lpc_full,lpc_nesc,lpc_old,lrefgen,lrefout,lregeta,lretcfou,lrfoutcnorm)
+!$OMP THREADPRIVATE(lrfric,lrgptcnorm,lrough,lrplane,lrubc,lscmec,lscreen,lscreen_openmp,lsfcflx,lsforc,lsimob)
+!$OMP THREADPRIVATE(lsitric,lslag,lsmssig,lsprt,ltenc,ltwotl,lvercor,lwrtcfou,n2dini,n3dini,n_regions_ew,n_regions_ns)
+!$OMP THREADPRIVATE(ncntvar,nconf,ncycle,ndhfdts,ndhfgts,ndhfzts,ndhpts,nfrco,nfrcorm,nfrdhfd,nfrdhfg,nfrdhfz,nfrdhp)
+!$OMP THREADPRIVATE(nfrgdi,nfrhis,nfrisp,nfrmasscon,nfrpos,nfrsdi,ngdits,nhists,ninterpincr,ninterpincrlimit)
+!$OMP THREADPRIVATE(ninterpincrorder,ninterptraj,ninterptrajlimit,ninterptrajorder,nmasscons,noutput,npisps,nposts)
+!$OMP THREADPRIVATE(nprgpew,nprgpns,nprintlev,nproc,nprtrm,nprtrn,nprtrns,nprtrv,nprtrw,nquad,nsdits,nsppr,nstart)
+!$OMP THREADPRIVATE(nstepini,nstop,ntasks,rextlhf,rextshf,rextz0h,rextz0m,rtenc)
+!$OMP THREADPRIVATE(n_regions)
 END MODULE YOMCT0
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomct0b.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomct0b.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomct0b.F90	(revision 2056)
@@ -16,3 +16,4 @@
 
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(lecmwf)
 END MODULE YOMCT0B
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomct3.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomct3.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomct3.F90	(revision 2056)
@@ -22,3 +22,4 @@
 
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(lgpqinsp,lrecall_suhdf_in_cnt4,lspc_from_di,nstep)
 END MODULE YOMCT3
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomcver.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomcver.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomcver.F90	(revision 2056)
@@ -46,3 +46,5 @@
 ! -----------------------------------------------------------------------------
 
+!$OMP THREADPRIVATE(lsvtsm,lvertfe,lvsplip,nvsch)
+!$OMP THREADPRIVATE(rderi,rfaa,rfbb,rfcc,rfdd,rinte,rvspc,rvsptri,vrdetar)
 END MODULE YOMCVER
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomdim.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomdim.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomdim.F90	(revision 2056)
@@ -228,3 +228,13 @@
 
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(lader,loptproma,lspt,luvder,lvor,ncmax,ncpec,ncpec2,ndgenfph)
+!$OMP THREADPRIVATE(ndgeng,ndgenh,ndgenl,ndglg,ndgll,ndgnh,ndgsafph,ndgsag,ndgsah)
+!$OMP THREADPRIVATE(ndgsal,ndgsur,ndgung,ndgunl,ndguxg,ndguxl,ndlon,ndlsm,ndlsur)
+!$OMP THREADPRIVATE(ndlung,ndluxg,ndsur1,nf3d,nfaux,nfc2d,nfd2d,nfgpnh,nflen,nflevg)
+!$OMP THREADPRIVATE(nflevl,nflevlmx,nflsa,nflsul,nflsur,nfppye,nfppyx,nfther,ngpblks)
+!$OMP THREADPRIVATE(nmsmax,nmtcmax,nppm,nproma,npromb,npromc,nprome,npromm,npromnh)
+!$OMP THREADPRIVATE(npromnh_gwadv,npromp,npromv,npromvc,nrlevx,ns1d,ns2d,ns3d,nsaux)
+!$OMP THREADPRIVATE(nsefre,nsmax,nsmin,nspec,nspec2,nspec2g,nspec2mx,nspecg,ntcmax,ntmax)
+!$OMP THREADPRIVATE(ntpec2,numcp,nump,numtp,numxp,nundefld,nvarmax,nxmax,nxpec,nxpecg)
+!$OMP THREADPRIVATE(ndlunl,ndluxl)
 END MODULE YOMDIM
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomdphy.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomdphy.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomdphy.F90	(revision 2056)
@@ -68,3 +68,5 @@
 LOGICAL            :: LTPROF
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(ltprof,ncextr,nchac,nchin,ncsi,ncsnec,ncxp,nloa,nloe,nsira,ntiles,ntoz1d,ntoz2d,ntoz3d,ntsl,ntssg)
+!$OMP THREADPRIVATE(ntvg,nvclis,nvextr,nvextrdyn,nvtend,nvxp,nvxp2,nvxtr2)
 END MODULE YOMDPHY
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomdyn.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomdyn.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomdyn.F90	(revision 2056)
@@ -563,3 +563,18 @@
 
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(alphint,betadt,flccri,frandh,gammax,gammax0,hdirdiv,hdiro3,hdirpd,hdirq,hdirsp,hdirt)
+!$OMP THREADPRIVATE(hdirvd,hdirvor,hdsrdiv,hdsrvd,hdsrvor,hdtime_strhd,hrdirdiv,hrdiro3,hrdirpd,hrdirq)
+!$OMP THREADPRIVATE(hrdirsp,hrdirt,hrdirvd,hrdirvor,hrdsrdiv,hrdsrvd,hrdsrvor,l2tlff,ladvf,ladvfw,lchdif)
+!$OMP THREADPRIVATE(ldry_ecmwf,leltra,lfrein,lfreinf,limpf,lnewhd,lpc_xidt,lqmhp,lqmhpd,lqmht,lqmhvd,lqmhw)
+!$OMP THREADPRIVATE(lqmp,lqmpd,lqmt,lqmvd,lqmw,lrephd,lrhdi_lastiterpc,lrspline_p,lrspline_spd,lrspline_svd)
+!$OMP THREADPRIVATE(lrspline_t,lrspline_w,lsettls,lsidg,lsl_unlphy_f,lstrhd,lverave_hluv,lverflt,ncomp_cvgq)
+!$OMP THREADPRIVATE(ncurrent_iter,ndlnpr,nitmp,nlevvf,nrubc,nsiter,nspdlag,nsrefdh,nsvdlag,ntlag,nvlag,nwlag)
+!$OMP THREADPRIVATE(rcmslp0,rdampdiv,rdampdivs,rdamphds,rdampo3,rdamppd,rdampq,rdampsp,rdampt,rdampvd,rdampvds)
+!$OMP THREADPRIVATE(rdampvor,rdampvors,refgeo,reps1,reps2,repsm1,repsm2,repsp1,repsvfdi,repsvfvo,rexpdh,rexpdhs)
+!$OMP THREADPRIVATE(rfrein,rhydr0,rrdxtau,rtemrb,rw2tlff,sdred,sipr,siprub,sirprg,sirprn,sitime,sitr,sitra,sitrub)
+!$OMP THREADPRIVATE(slevdh,slevdh2,slevdh3,slevdhs,slevdhs2,slhda0,slhdb,slhdkmax,tdt,tstep,vcak,vcpr,vctr,vesl)
+!$OMP THREADPRIVATE(vetaon,vetaox,vmax1,vmax2,vnorm,xidt)
+!$OMP THREADPRIVATE(gmr,rcordif,rcordih,rcordit,rdhi,rdhs,rdidiv,rdigfl,rdipd,rdisp,rditg,rdivd,rdivor,rdsdiv)
+!$OMP THREADPRIVATE(rdsvd,rdsvor,rkrf,s2eta,scgmap,sialph,sib,sidelp,sidphi,sifac,sifaci,siheg,siheg2,sihegb)
+!$OMP THREADPRIVATE(sihegb2,silnpr,simi,simo,sirdel,sirub,sitlaf,sitlah,sitrica,sitricb,sitricc,sivp,slhda,slhdd0)
 END MODULE YOMDYN
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomfa.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomfa.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomfa.F90	(revision 2056)
@@ -69,3 +69,7 @@
 TYPE(FAD) :: YFAQVA  ! Total humidity amplitude variation of Q+L+I
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(nbitcs,nbitpg,npulap,nstron,nvgrib,yfaclf,yfacpf,yfacvgq,yfacvv,yfadal,yfadom,yfafsp1)
+!$OMP THREADPRIVATE(yfafsp2,yfafsp3,yfafsp4,yfafsp5,yfag,yfai,yfakhi,yfal,yfao3,yfaorog,yfapd,yfapsi,yfaq)
+!$OMP THREADPRIVATE(yfaqva,yfar,yfas,yfasdsat,yfasp,yfaspf,yfasrc,yfat,yfatke,yfaual,yfauen,yfaugeo)
+!$OMP THREADPRIVATE(yfaunebh,yfauom,yfavd,yfavgeo)
 END MODULE YOMFA
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomfpc.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomfpc.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomfpc.F90	(revision 2056)
@@ -244,3 +244,11 @@
 INTEGER(KIND=JPIM) :: NFPMASK
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(c1fp2df,c1fp3df,c1fp3dfh,c1fp3dfp,c1fp3dfs,c1fp3dft,c1fp3dfv,c1fpcfu,c1fpdom,c1fpphy,c1fpxfu)
+!$OMP THREADPRIVATE(cfp2df,cfp3df,cfp3dfh,cfp3dfp,cfp3dfs,cfp3dft,cfp3dfv,cfpcfu,cfpdir,cfpdom,cfpfmt,cfpiden)
+!$OMP THREADPRIVATE(cfpphy,cfpxfu,fpbl,lasq,lfitp,lfitt,lfitv,lfpcnt,lfplosp,lfpmois,lfpnhpd,lfpnhvd,lfpnhvw)
+!$OMP THREADPRIVATE(lfpq,lfprh100,lfpspec,lmoconvar,ltracefp,mfp2df,mfp2dyn,mfp3dfh,mfp3dfp,mfp3dfs,mfp3dft)
+!$OMP THREADPRIVATE(mfp3dfv,mfp3dyn,mfpphy,nfp2df,nfp3df,nfp3dfh,nfp3dfp,nfp3dfs,nfp3dft,nfp3dfv,nfp3h,nfp3p)
+!$OMP THREADPRIVATE(nfp3pv,nfp3s,nfp3th,nfpcape,nfpcfu,nfpcli,nfpdom,nfpdphy,nfpgrib,nfpincr,nfpindyn,nfpinphy)
+!$OMP THREADPRIVATE(nfplake,nfplnpr,nfpmask,nfpphy,nfpsurfex,nfpxfu,nfpxlev,nrfp3s,rfp3h,rfp3p,rfp3pv,rfp3th)
+!$OMP THREADPRIVATE(rfpcd2,rfpcorr,rfpcsab,rfpvcap,wdxi,wdxo,wsxi,wsxo)
 END MODULE YOMFPC
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomgc.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomgc.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomgc.F90	(revision 2056)
@@ -63,3 +63,6 @@
 
 !      ----------------------------------------------------------------
+
+!$OMP THREADPRIVATE(gaw,geclo,gelam,gelat,gemu,geslo,gm,gnordl,gnordlcl,gnordm,gnordmcl,gnordmcm,gomvrl)
+!$OMP THREADPRIVATE(gomvrm,gsqm2,ngplat,nuniquegp,orog,orogl,orogll,oroglm,orogm,orogmm,rcori,rcoric)
 END MODULE YOMGC
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomgem.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomgem.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomgem.F90	(revision 2056)
@@ -187,3 +187,7 @@
 
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(nbeegp,nbnegp,ngptot,ngptot_cap,ngptotg,ngptotmx,nhtyp,nsttyp,r4jp,rc2m1,rc2p1,rcor0)
+!$OMP THREADPRIVATE(rcor1,rcor2,reflcape,reflkuo,reflrhc,rlocen,rmucen,rnlginc,rstret,teqc,teqh,teqk,toppres,vp00,vrlevx)
+!$OMP THREADPRIVATE(ndglu,nestagp,ngptotl,nloen,nloeng,nmen,nmeng,nmentc,nstagp,ntstagp,nvautf,nvauth,ratath,ratatx)
+!$OMP THREADPRIVATE(rcolon,rindx,rindy,rsilon,vaf,vah,valh,vbf,vbh,vc,vcuico,vcuicoh,vdela,vdelb,vetaf,vetah,vrdetah)
 END MODULE YOMGEM
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomgrb.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomgrb.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomgrb.F90	(revision 2056)
@@ -670,3 +670,33 @@
 
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(mbitsgg,mbitssh,mensfnb,mgrbs2,mgrbs3,mjdiag,mjdomai,mjiter,mlocgrb,msec0,msec1,msec2spm,msec2spp)
+!$OMP THREADPRIVATE(msec3,msec4,msmaxnp,mtotens,nbitsgg,nbitssh,ncalval,nconsensus,ndwd,nensfnb,ngrb080,ngrb081)
+!$OMP THREADPRIVATE(ngrb082,ngrb083,ngrb084,ngrb085,ngrb086,ngrb087,ngrb088,ngrb089,ngrb090,ngrb091,ngrb092,ngrb093)
+!$OMP THREADPRIVATE(ngrb094,ngrb095,ngrb096,ngrb097,ngrb098,ngrb099,ngrb100,ngrb101,ngrb102,ngrb103,ngrb104,ngrb105)
+!$OMP THREADPRIVATE(ngrb106,ngrb107,ngrb108,ngrb109,ngrb10fg,ngrb10u,ngrb10v,ngrb110,ngrb111,ngrb112,ngrb113,ngrb114)
+!$OMP THREADPRIVATE(ngrb115,ngrb116,ngrb117,ngrb118,ngrb119,ngrb120,ngrb149,ngrb150,ngrb153,ngrb154,ngrb207,ngrb21)
+!$OMP THREADPRIVATE(ngrb214,ngrb215,ngrb216,ngrb217,ngrb218,ngrb219,ngrb22,ngrb222,ngrb223,ngrb224,ngrb225,ngrb226)
+!$OMP THREADPRIVATE(ngrb227,ngrb23,ngrb241,ngrb242,ngrb249,ngrb250,ngrb251,ngrb252,ngrb253,ngrb254,ngrb255,ngrb2d)
+!$OMP THREADPRIVATE(ngrb2t,ngrbaerdep,ngrbaergn01,ngrbaergn02,ngrbaergn03,ngrbaergn04,ngrbaergn05,ngrbaergn06)
+!$OMP THREADPRIVATE(ngrbaergn07,ngrbaergn08,ngrbaergn09,ngrbaergn10,ngrbaergn11,ngrbaergn12,ngrbaergn13,ngrbaergn14)
+!$OMP THREADPRIVATE(ngrbaergn15,ngrbaerlg,ngrbaerls01,ngrbaerls02,ngrbaerls03,ngrbaerls04,ngrbaerls05,ngrbaerls06)
+!$OMP THREADPRIVATE(ngrbaerls07,ngrbaerls08,ngrbaerls09,ngrbaerls10,ngrbaerls11,ngrbaerls12,ngrbaerls13,ngrbaerls14)
+!$OMP THREADPRIVATE(ngrbaerls15,ngrbaerlts,ngrbaermr01,ngrbaermr02,ngrbaermr03,ngrbaermr04,ngrbaermr05,ngrbaermr06)
+!$OMP THREADPRIVATE(ngrbaermr07,ngrbaermr08,ngrbaermr09,ngrbaermr10,ngrbaermr11,ngrbaermr12,ngrbaermr13,ngrbaermr14)
+!$OMP THREADPRIVATE(ngrbaermr15,ngrbaerpr,ngrbaerscc,ngrbaersm,ngrbal,ngrbalnid,ngrbalnip,ngrbaluvd,ngrbaluvp,ngrbanor)
+!$OMP THREADPRIVATE(ngrbaodlg,ngrbaodpr,ngrbaodsm,ngrbasn,ngrbat,ngrbbld,ngrbblh,ngrbbv,ngrbcape,ngrbcc,ngrbccc)
+!$OMP THREADPRIVATE(ngrbchar,ngrbci,ngrbciwc,ngrbclwc,ngrbco2a,ngrbco2b,ngrbco2o,ngrbcp,ngrbcsf,ngrbcvh,ngrbcvl,ngrbd)
+!$OMP THREADPRIVATE(ngrbe,ngrbemis,ngrbes,ngrbewov,ngrbewss,ngrbfal,ngrbflsr,ngrbfsr,ngrbgh,ngrbghg,ngrbgrg,ngrbgwd)
+!$OMP THREADPRIVATE(ngrbhcc,ngrbie,ngrbiews,ngrbinss,ngrbishf,ngrbisor,ngrbistl1,ngrbistl2,ngrbistl3,ngrbistl4,ngrblcc)
+!$OMP THREADPRIVATE(ngrblgws,ngrblnsp,ngrblsf,ngrblsm,ngrblsp,ngrblspf,ngrblsrh,ngrbmaxxtra,ngrbmcc,ngrbmgws)
+!$OMP THREADPRIVATE(ngrbminxtra,ngrbmn2t,ngrbmont,ngrbmsl,ngrbmx2t,ngrbneov,ngrbnsov,ngrbnsss,ngrbnwov,ngrbo3,ngrbpaw)
+!$OMP THREADPRIVATE(ngrbpthpv,ngrbpv,ngrbq,ngrbr,ngrbro,ngrbrsn,ngrbs2,ngrbs3,ngrbsd,ngrbsdfor,ngrbsdor,ngrbsf,ngrbsf6)
+!$OMP THREADPRIVATE(ngrbskt,ngrbslhf,ngrbslor,ngrbsmlt,ngrbsp,ngrbspar,ngrbsparc,ngrbspd,ngrbsr,ngrbsrc,ngrbsshf,ngrbssr)
+!$OMP THREADPRIVATE(ngrbssrc,ngrbssrd,ngrbsst,ngrbstinc,ngrbstl1,ngrbstl2,ngrbstl3,ngrbstl4,ngrbstr,ngrbstrc,ngrbstrd)
+!$OMP THREADPRIVATE(ngrbsund,ngrbsuvb,ngrbsvd,ngrbswl1,ngrbswl2,ngrbswl3,ngrbswl4,ngrbt,ngrbtbt,ngrbtcc,ngrbtcghg)
+!$OMP THREADPRIVATE(ngrbtcgrg,ngrbtciw,ngrbtclw,ngrbtco3,ngrbtctrac,ngrbtcw,ngrbtcwv,ngrbth,ngrbtp,ngrbtrac,ngrbtsn)
+!$OMP THREADPRIVATE(ngrbtsp,ngrbtsr,ngrbtsrc,ngrbttr,ngrbttrc,ngrbtvh,ngrbtvl,ngrbu,ngrbv,ngrbveg,ngrbvimd,ngrbvo)
+!$OMP THREADPRIVATE(ngrbvso,ngrbw,ngrbz,njdiag,njdomai,njiter,nleg,nlocgrb,nmethod,nmfr,nncep,nreference,nsec0,nsec1)
+!$OMP THREADPRIVATE(nsec2spm,nsec2spp,nsec3,nsec4,nsmaxnp,nsteplpp,nstream,nsystem,ntotens,nukm,rsec3,ssec3)
+!$OMP THREADPRIVATE(msec2gg,ngrbgp2,ngrbgp3,ngrbsp2,ngrbsp3,nsec2gg,rsec2,ssec2)
 END MODULE YOMGRB
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomgstats.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomgstats.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomgstats.F90	(revision 2056)
@@ -98,4 +98,10 @@
 INTEGER(KIND=JPIM) :: NPRNT_STATS=3
 
+!$OMP THREADPRIVATE(ccdesc,cctype,lbarrier_stats,ldetailed_stats,lgstats_label,lstats,lstats_alloc)
+!$OMP THREADPRIVATE(lstats_comms,lstats_mem,lstats_omp,lstatscpu,lsyncstats,ltrace_stats,myproc_stats)
+!$OMP THREADPRIVATE(ncalls,ncalls_total,nprnt_stats,nproc_stats,nstats_mem,ntmem,ntrace_stats,thistcpu)
+!$OMP THREADPRIVATE(thistime,thisvcpu,time_last_call,timelcall,timemax,timesqsum,timesum,timesumb)
+!$OMP THREADPRIVATE(ttcpulcall,ttcpusum,tvcpulcall,tvcpusum)
+!$OMP THREADPRIVATE(ncall_trace,nprcids_stats,time_start,time_trace)
 END MODULE YOMGSTATS
 
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomjfh.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomjfh.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomjfh.F90	(revision 2056)
@@ -13,3 +13,4 @@
 !    -----------------------------------------------------------------
 
+!$OMP THREADPRIVATE(n_vmass)
 END MODULE YOMJFH
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomleg.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomleg.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomleg.F90	(revision 2056)
@@ -38,3 +38,4 @@
 REAL(KIND=JPRB),ALLOCATABLE:: RIPI2(:)
 
+!$OMP THREADPRIVATE(r1mu2,r1mua,r1mui,r1qm2,racthe,ripi0,ripi1,ripi2,rlati,rlatig,rmu,rsqm2,rw)
 END MODULE YOMLEG
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomlun.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomlun.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomlun.F90	(revision 2056)
@@ -138,3 +138,8 @@
 INTEGER(KIND=JPIM) :: NULTRAJBG
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(nbias,ncmafl,nefls,neflss,negash,nfgigg,nfgish,ninigg,ninish,ninmsh,npdirl,npoddh,npossh)
+!$OMP THREADPRIVATE(npppsh,nscasig,nscaspe,nscatab,nscrtch,ntcsr,ntide,ntrjsh,nulase,nulass,nulcl1,nulcl2,nulco)
+!$OMP THREADPRIVATE(nulcont,nuldila,nulfp01,nulfp02,nulfp03,nulfp04,nulfp05,nulfp06,nulfp07,nulfp08,nulfp09)
+!$OMP THREADPRIVATE(nulfp10,nulfp11,nulfp12,nulfp13,nulfp14,nulfp15,nulfpos,nulhwf,nulrad,nulrcf,nulref,nulrotc)
+!$OMP THREADPRIVATE(nulrtl,nulstat,nultmp,nultrajbg,nultrajhr,nulusr1,nulusr2,nulusr3,nulusr4,nulusr5,nuo3ch1,nuo3ch2)
 END MODULE YOMLUN
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomlun_ifsaux.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomlun_ifsaux.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomlun_ifsaux.F90	(revision 2056)
@@ -18,3 +18,4 @@
 
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(nulerr,nulout)
 END MODULE YOMLUN_IFSAUX
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomlw15.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomlw15.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomlw15.F90	(revision 2056)
@@ -77,3 +77,6 @@
 !  RVGO315  :  REAL     RESIDUAL PRESSURE FOR O3  VOIGT LINE HALF-WIDTH
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(at15,bt15,ga15,gb15,mxixt15,ng115,ng1p115,nint15,nipd15,nipd215)
+!$OMP THREADPRIVATE(ntr15,ntra15,nua15,o1h15,o2h15,oct15,rntnu15,rpialf015,rt115,rvgco215)
+!$OMP THREADPRIVATE(rvgh2o15,rvgo315,tintp15,tref15,tstand15,tstp15,wg115,xp15)
 END MODULE YOMLW15
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yommddh.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yommddh.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yommddh.F90	(revision 2056)
@@ -230,3 +230,12 @@
 ! ---- DDH
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(bdeddh,fnoddh,hdsfgl,ndhaend,ndhaenp,ndhahkd,ndhahkp,ndhamcd)
+!$OMP THREADPRIVATE(ndhamcp,ndhavd,ndhavp,ndhbend,ndhbenp,ndhbhkd,ndhbhkp,ndhbmcd)
+!$OMP THREADPRIVATE(ndhbmcp,ndhbpu,ndhbpx,ndhbvd,ndhbvp,ndhcs,ndhcssu,ndhcv,ndhcvsu)
+!$OMP THREADPRIVATE(ndhcvsul,ndhcvsun,ndhddx,ndhfend,ndhfenp,ndhffs,ndhfhkd,ndhfhkp)
+!$OMP THREADPRIVATE(ndhfiis,ndhfmcd,ndhfmcp,ndhfsd,ndhfsp,ndhfsss,ndhftis,ndhftls)
+!$OMP THREADPRIVATE(ndhftss,ndhftts,ndhfvd,ndhfvp,ndhfwls,ndhidh,ndhkd,ndhnom,ndhnpu)
+!$OMP THREADPRIVATE(ndhten,ndhthk,ndhtmc,ndhven,ndhvfs,ndhvhk,ndhviis,ndhvmc,ndhvs)
+!$OMP THREADPRIVATE(ndhvsss,ndhvtis,ndhvtls,ndhvtss,ndhvtts,ndhvv,ndhvwls,ndhzpr)
+!$OMP THREADPRIVATE(hdsf,hdsfdu,hdsfla,nddhi,nddhla,nddhpu,nlrddh,nlxddh,nurddh,nuxddh)
 END MODULE YOMMDDH
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yommp.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yommp.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yommp.F90	(revision 2056)
@@ -466,3 +466,16 @@
 ! ----------------------------------------------------------------------
 
+!$OMP THREADPRIVATE(leq_regions,limp,limp_noolap,lockio,lsplit,lsplitout,mbx_size,mp_type,my_region_ew,my_region_ns)
+!$OMP THREADPRIVATE(myfrstactlat,mylstactlat,myproc,myseta,mysetb,mysetm,mysetn,mysetv,mysetw,nafpb1,napsets,narib1)
+!$OMP THREADPRIVATE(narob1,naslb1,nblkout,nbsetsp,ncombflen,ncpec2v,nfldin,nfldout,nfpmpbufsz,nfpprocs,nfprpt,nfpspt)
+!$OMP THREADPRIVATE(nfrstloff,ngathout,nintype,nouttype,npsp,nptrfloff,nrimpbufsz,nriprocs,nrirpt,nrispt,nrompbufsz)
+!$OMP THREADPRIVATE(nroprocs,nrorpt,nrospt,nslmpbufsz,nslpad,nslprocs,nslrpt,nslspt,nspec2v,nspec2vf,nstrin,nstrout)
+!$OMP THREADPRIVATE(ntpec2v,numxp,nwrtout)
+!$OMP THREADPRIVATE(lsplitlat,mylats,mylevs,nallms,nbsetlev,nfpcomm,nfpcore,nfpext,nfpoff,nfponl,nfprecvpos,nfprecvptr)
+!$OMP THREADPRIVATE(nfpsendpos,nfpsendptr,nfpsta,nfrstlat,nglobalindex,nglobalproc,ngpset2pe,nlocalindex,nlstlat,noboff)
+!$OMP THREADPRIVATE(nobonl,nobsta,nonl,nprcids,nprocm,npsurf,nptrcv,nptrfrstlat,nptrlat,nptrll,nptrls,nptrlstlat,nptrmf)
+!$OMP THREADPRIVATE(nptrms,nptrsv,nptrsvf,nptrtv,nrecvptr,nricomm,nricore,nriext,nrioff,nrionl,nrirecvpos,nrirecvptr)
+!$OMP THREADPRIVATE(nrisendpos,nrisendptr,nrista,nrocomm,nrocore,nroext,nrooff,nroonl,nrorecvpos,nrorecvptr,nrosendpos)
+!$OMP THREADPRIVATE(nrosendptr,nrosta,nsendptr,nslcomm,nslcore,nslext,nsloff,nslonl,nslrecvpos,nslsendpos,nslsta)
+!$OMP THREADPRIVATE(nspstaf,nsta,numll,numpp,numprocfp,numvmo,numvmojb,numxpp,nvmodist)
 END MODULE YOMMP
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomoml.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomoml.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomoml.F90	(revision 2056)
@@ -46,4 +46,5 @@
 
 LOGICAL :: OML_DEBUG = .FALSE.
+!$OMP THREADPRIVATE(OML_DEBUG)
 
 PUBLIC OML_WAIT_EVENT, OML_SET_EVENT, OML_INCR_EVENT, &
@@ -62,7 +63,9 @@
 !-- Note: Still JPIM !!
 INTEGER(KIND=JPIM) :: M_EVENT = 0
+!$OMP THREADPRIVATE(M_EVENT)
 
 !-- Note: OML_LOCK_KIND, not JPIM !!
 INTEGER(KIND=OML_LOCK_KIND) :: M_LOCK(2) = (/-1, -1/)
+!$OMP THREADPRIVATE(M_LOCK)
 
 CONTAINS
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomphy.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomphy.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomphy.F90	(revision 2056)
@@ -412,3 +412,13 @@
 INTEGER(KIND=JPIM), PARAMETER  ::  JPHYARO =   3  ! for AROME physics
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(cgmixlen,l1drhcri,l2phys,l3mt,ladjcld,laerodes,laerolan,laerosea,laerosoo,laerosul)
+!$OMP THREADPRIVATE(laerovol,lajucv,lautoneb,lbccond,lblvar,lcape,lcddpro,lclsatur,lcollec,lcondwt,lcvcas)
+!$OMP THREADPRIVATE(lcvdd,lcvlis,lcvpgy,lcvpp,lcvppkf,lcvpro,lcvra,lcvrav3,ldifcons,lect,lectfl,levapp,lfgel)
+!$OMP THREADPRIVATE(lfgels,lfpcor,lglt,lgwd,lgwdc,lgwrhcri,lhmto,lhucn,lhuneg,lmphys,lnd2diff,lnebco,lnebgr)
+!$OMP THREADPRIVATE(lnebgy,lnebn,lnebnxr,lnebr,lnebt,lneige,lnewd,lnewstat,lnoias,lnsmlis,lo3abc,lozone,lpble)
+!$OMP THREADPRIVATE(lphcdpi,lphspsh,lpil,lprgml,lprocld,lptke,lqxrtgh,lrautoev,lray,lrayfm,lrayfm15,lraylu)
+!$OMP THREADPRIVATE(lraypl,lreasur,lrelaxt,lrelaxw,lrews,lrmix,lrnumx,lrprox,lrrgust,lrrmes,lrstab,lrtdl)
+!$OMP THREADPRIVATE(lrtpp,lscmf,lsfhyd,lslc,lsmnimbt,lsmrot,lsmtps,lsnv,lsolv,lsrcon,lsrcont,lssd,lstra)
+!$OMP THREADPRIVATE(lstrapro,lstras,lthermo,lvdif,lvfull,lvgsn,lvoigt,lz0hsrel,nbiter,ndpsfi,noir,nphy)
+!$OMP THREADPRIVATE(nphyrep,nprac,nprag,nprri,nsmdneb,nsmtbot)
 END MODULE YOMPHY
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomphy0.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomphy0.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomphy0.F90	(revision 2056)
@@ -706,3 +706,21 @@
 
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(a0ml_at,a0ml_au,a0ml_bt,a0ml_bu,acbrphim,acg,adise,adisi,aecls3,aecls4,aercs1,aercs3,aercs5)
+!$OMP THREADPRIVATE(agre1,agre2,agref,agreke,agrericr,ahclpv,aj1meps,aj1peps,ajbumin,akn,ald,alfx,almav,almave)
+!$OMP THREADPRIVATE(alphae,alphat,arsb2,arsc1,arsc2,arsch,arscq,arsct,bedifv,ecmnp,ecmnpi,ectmin,edb,edc,edd,edk)
+!$OMP THREADPRIVATE(eps,etacut,evap,fentrt,fevapc,fnebc,font,fqlic,galp,gamap1,gamtke,gccsv,gcismin,gcomod,gcvachi)
+!$OMP THREADPRIVATE(gcvadmw,gcvads,gcvalfa,gcvalmx,gcvbee,gcvbeta,gcveex,gcvmlt,gcvnu,gcvpsi,gcvpsie,gcvsqdcx)
+!$OMP THREADPRIVATE(gcvsqdn,gcvsqdr,gddbeta,gddeva,gddevf,gddsde,gddwpf,gfric,gpblhk0,gpblhra,grcvpp,grhcmod,grrinte)
+!$OMP THREADPRIVATE(grrmina,gwbfaut,gwdamp,gwdbc,gwdcco,gwdcd,gwdlt,gwdprof,gwdse,gwdvali,hcmin,hobst,hucoe,hucoe2)
+!$OMP THREADPRIVATE(hutil,hutil1,hutil2,najiter,npclo1,npclo2,nrhcri,nsmtpa,nsmtpb,nuptke,qsmin,qsnebc,qsnebs,qssc)
+!$OMP THREADPRIVATE(qssusc,qssuss,qssusv,qsusxc,qsusxs,qxral,qxrdel,qxrhx,qxrr,qxrtgh,raccef,raggef,rauitn,rauitx)
+!$OMP THREADPRIVATE(rauiuste,rautefr,rautefs,rautsbet,rcin,rcoflm,rcoll,rcvevap,rdphic,rdtfac,retamin,revgsl,rfacnsm)
+!$OMP THREADPRIVATE(rfalll,rhcrit1,rhcrit2,rhevap,ricret,ricrlm,rkdn,rnegat,rnintr,rnints,rnlcurv,rphi0,rphir,rqcrns)
+!$OMP THREADPRIVATE(rqicrmax,rqicrmin,rqicrsn,rqicrt1,rqicrt2,rqicvmax,rqicvmin,rqlcr,rqlcv,rrgamma,rrimef,rrscale)
+!$OMP THREADPRIVATE(rsmdnebx,rsmdtx,rtcape,rwbf1,rwbf2,sco,sensl,snnbco,spnbco,sttbmin,sxnbco,tca,tct,tctc,tcw,tddbu)
+!$OMP THREADPRIVATE(tddfr,tddgp,tentr,tentrd,tentrvl,tentrx,tfvr,tfvs,trentrv,tudbu,tudfr,tudgp,turb,tvf,tvfc,tym)
+!$OMP THREADPRIVATE(ucwstar,udect,ueteps,uhdifv,untier,upreclp,upretmax,upretmin,usdmlt,ushearm,usuprc,usuric,usurice)
+!$OMP THREADPRIVATE(usuricl,usurid,usuride,utilgust,vchrnk,vkarmn,vvn,vvx,vz0cm,vziustar0,xblm,xklm,xmaxlm,xminlm)
+!$OMP THREADPRIVATE(xnbmax,xwsalm,xwsblm)
+!$OMP THREADPRIVATE(rhcri)
 END MODULE YOMPHY0
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomphy1.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomphy1.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomphy1.F90	(revision 2056)
@@ -304,3 +304,11 @@
 INTEGER(KIND=JPIM) :: NCHSP
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(alb1,alb2,albgla,albmax,albmed,albmer,albmin,alcrin,alrcn1,alrcn2,ea,ec2ref,emcrin,emmgla)
+!$OMP THREADPRIVATE(emmmer,ewfc,ewwilt,g1b,g1c1sat,g1cgsat,g1p,g1wsat,g2b,g2c1sat,g2cgsat,g2p,g2wsat,g3cgsat)
+!$OMP THREADPRIVATE(ga,gc1,gc1s1,gc1s2,gc1s3,gc1s4,gc1y1,gc2,gc2ref,gc3,gc31,gc32,gcgel,gcgels,gconv,gcz0h,gf1)
+!$OMP THREADPRIVATE(gf3,gf4,glaimx,glaimxs,gneimx,gneimxs,gsnc1,gsnc2,gtsvap,gvegmx,gvegmxs,gwfc,gwlex,gwlmx)
+!$OMP THREADPRIVATE(gwpimx,gwwilt,hsol,hsolit0,hsoliwr,lc1vap,limc,limw,nchsp,ntvgla,ntvmer,omtpro,omwpro,rc1max)
+!$OMP THREADPRIVATE(rcgmax,rctgla,rctveg,rd1,rd2gla,rd2mer,rgl,rhomax,rhomin,rlai,rlaimx,rsmax,rtiner,rz0gla)
+!$OMP THREADPRIVATE(rz0mer,rzhgla,rzhmer,rzhz0g,rzhz0m,sodelx,tmergl,toexp,tolin,tref4,wcrin,wcrinc,wcring)
+!$OMP THREADPRIVATE(wnew,wpmx,wsmx,xcrinr,xcrinv)
 END MODULE YOMPHY1
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomphy2.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomphy2.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomphy2.F90	(revision 2056)
@@ -65,3 +65,5 @@
 LOGICAL :: LMULAF
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(facraf,gz0raf,hclp,htcls,htshm,htsml,hvcls,lmulaf,lraftur,ntshm,ntsml,ripblc,tsphy)
+!$OMP THREADPRIVATE(xdamp,xmucvpp,xmulaf)
 END MODULE YOMPHY2
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomphy3.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomphy3.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomphy3.F90	(revision 2056)
@@ -192,3 +192,8 @@
 REAL(KIND=JPRB) :: REXP_NEB
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(bsfsa,bsfsi,bsfsn,bsfta,bsfti,bsftn,earrt,eoasa,eoasi,eoasn,eoata,eoati,eoatn,eodsa,eodsi)
+!$OMP THREADPRIVATE(eodsn,eodta,eodti,eodtn,eoray,fcm_del_a,fcm_del_d,fcm_mu_a,fcm_mu_d,fcm_n_i,fcm_n_l,fcm_p_ai)
+!$OMP THREADPRIVATE(fcm_p_al,fcm_p_di,fcm_p_dl,fcm_p_gi,fcm_p_gl,fcm_q_ai,fcm_q_al,fcm_q_di,fcm_q_dl,fcm_q_gi)
+!$OMP THREADPRIVATE(fcm_q_gl,gca,gcb,gcc,gcd4,gce4,girec1,girec2,girec3,girec4,qco2,qlimi,qlip0,rexp_neb,rii0)
+!$OMP THREADPRIVATE(usaa,usai,usan,usba,usbi,usbn,vdp,vnp)
 END MODULE YOMPHY3
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yompldsw.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yompldsw.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yompldsw.F90	(revision 2056)
@@ -10,3 +10,4 @@
 LOGICAL :: LOPT_RS6K
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(lopt_rs6k,lopt_scalar)
 END MODULE YOMPLDSW
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomprad.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomprad.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomprad.F90	(revision 2056)
@@ -145,3 +145,8 @@
 INTEGER(KIND=JPIM),ALLOCATABLE:: NRCRCVWO(:,:,:)
 INTEGER(KIND=JPIM),ALLOCATABLE:: NRCRCVEO(:,:,:)
+!$OMP THREADPRIVATE(lodbgradi,lodbgradl,lradondem,lradondem_active,nfixradfld,nrimaxla,nrimaxlb)
+!$OMP THREADPRIVATE(nrimaxln,nrimaxlt,nrimaxt,nrlbchunks,nrlbdata,nrlbpoints,nrlprcs,nrlrchunks)
+!$OMP THREADPRIVATE(nrlrdata,nrlrpoints,radgrid)
+!$OMP THREADPRIVATE(mask_ri1,mask_ri2,mask_ro1,mask_ro2,nrcneede,nrcneedw,nrcrcve,nrcrcveo,nrcrcvt)
+!$OMP THREADPRIVATE(nrcrcvw,nrcrcvwo,nrcsnde,nrcsndt,nrcsndw,nrfrstoff,nrimax,nrirint,nrlastoff)
 END MODULE YOMPRAD
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomrad15.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomrad15.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomrad15.F90	(revision 2056)
@@ -66,3 +66,5 @@
 ! LNEWAER15 :LOGICAL : .TRUE. IF TEGEN AEROSOLS ARE USED
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(lerad6h15,leradhs15,lnewaer15,lradaer15,lradlb15,naer15,nflux15,nmode15,novlp15)
+!$OMP THREADPRIVATE(nrad15,nradc2f15,nradf2c15,nradfr15,nradnfr15,nradpfr15,nradpla15,nradsfr15,nrint15,nrproma15)
 END MODULE YOMRAD15
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomradf.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomradf.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomradf.F90	(revision 2056)
@@ -42,3 +42,6 @@
 REAL(KIND=JPRB),ALLOCATABLE :: RMOON(:,:)
 
+
+!$OMP THREADPRIVATE(edro,emtc,emtd,emtu,rmoon,srlwd,srlwdcs,srswd,srswdcs,srswduv)
+!$OMP THREADPRIVATE(srswdv,srswpar,srswparc,srswtinc,srswuvb,trsc,trsw)
 END MODULE YOMRADF
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomrcoef.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomrcoef.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomrcoef.F90	(revision 2056)
@@ -80,3 +80,6 @@
 
 !   ----------------------------------------------------------------
+!$OMP THREADPRIVATE(lglobrad,lrcoef,ltladdia,nexpbsr,nexpbthr,ng3sr,ngmtr,nlatrd,nlatwr,nlengsrb)
+!$OMP THREADPRIVATE(nlengtrb,npckfsr,npckfthr)
+!$OMP THREADPRIVATE(solrad,therrad,trmatsum,trweight)
 END MODULE YOMRCOEF
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomrdi15.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomrdi15.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomrdi15.F90	(revision 2056)
@@ -59,3 +59,5 @@
 !            TO BE MORE THAN THE RESPECTIVE VALUE AT SATURATION.
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(ralbice15,ralbsea15,ralbsnm15,ralbsno15,rcardi15,rcfc1115,rcfc1215,rch415)
+!$OMP THREADPRIVATE(remiss15,repalb15,repclc15,reph2o15,rmu0015,rn2o15,rrae15,rsdtsn15,rsnowal15,rvlbdc15)
 END MODULE YOMRDI15
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomrdu15.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomrdu15.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomrdu15.F90	(revision 2056)
@@ -52,3 +52,5 @@
 ! REPSCW15  : REAL      SEC. EPSILON FOR CLOUD LIQUID WATER PATH
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(diff15,nimp15,nout15,ntraer15,nuaer15,r10e15,rcday15,reelog15)
+!$OMP THREADPRIVATE(repsc15,repsco15,repscq15,repsct15,repscw15,repsec15)
 END MODULE YOMRDU15
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomrip.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomrip.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomrip.F90	(revision 2056)
@@ -99,3 +99,6 @@
 REAL(KIND=JPRB) :: RSIVSRLU
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(nindat,nsssss,nstadd,nstass,rcodec,rcodeclu,rcovsr,rcovsrlu,rdeaso,rdecli,rdeclu)
+!$OMP THREADPRIVATE(rdts22,rdts62,rdtsa,rdtsa2,reqtim,rhgmt,rip0,rip0lu,rsidec,rsideclu,rsivsr)
+!$OMP THREADPRIVATE(rsivsrlu,rsovr,rstati,rtdt,rtimst,rtimtr,rtmolt,rwsovr)
 END MODULE YOMRIP
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomsc2.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomsc2.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomsc2.F90	(revision 2056)
@@ -49,3 +49,6 @@
 
 !-----------------------------------------------------------------------
+!$OMP THREADPRIVATE(nfldobb1,nfldslb1,nfldslb15,nfldslb2,nobwide,nriwidee,nriwiden,nriwides)
+!$OMP THREADPRIVATE(nriwidew,nrowidee,nrowiden,nrowides,nrowidew,nslwide)
+!$OMP THREADPRIVATE(nciend,ncist,ndiend,ndist)
 END MODULE YOMSC2
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomscm.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomscm.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomscm.F90	(revision 2056)
@@ -51,3 +51,4 @@
 INTEGER(KIND=JPIM) :: NSCM_ADD_SAMPL
 
+!$OMP THREADPRIVATE(gscm_lat1,gscm_lat2,gscm_lon1,gscm_lon2,gscm_radius,lgscm,nfrscm,nscm_add_sampl,nscm_space_s,nscmts)
 END MODULE YOMSCM
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomsimphl.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomsimphl.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomsimphl.F90	(revision 2056)
@@ -51,3 +51,5 @@
 
 !   ----------------------------------------------------------------
+!$OMP THREADPRIVATE(lclouds,lcvrasp,lgwdsp,lraysp,lrrmessp,lsimph,lsmootha,lsmoothb,lsmoothd,lstrasp)
+!$OMP THREADPRIVATE(ltrajps,ltrajpst,lvdifsp)
 END MODULE YOMSIMPHL
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomslphy.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomslphy.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomslphy.F90	(revision 2056)
@@ -26,3 +26,6 @@
 INTEGER(KIND=JPIM) :: MSAVTEND_S
 
+!$OMP THREADPRIVATE(lslphy,msat_savtend,msat_savtend_s,msavtend_s,mt_savtend,mt_savtend_s)
+!$OMP THREADPRIVATE(mu_savtend,mu_savtend_s,mv_savtend,mv_savtend_s,nvtend)
+!$OMP THREADPRIVATE(savtend)
 END MODULE YOMSLPHY
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomsta.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomsta.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomsta.F90	(revision 2056)
@@ -119,3 +119,10 @@
 
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(hextrap,nlextrap,rdtdz1,rdtdz2,rdtdz3,rdtdz4,rdtdz5,rdtdz6,rdtdz7,rdtdz8,rdtdz9)
+!$OMP THREADPRIVATE(rpabov,rpmepo,rpmes2,rpmeso,rpstpo,rpstr2,rpstra,rptrop,rtabov,rtmepo,rtmes2,rtmeso)
+!$OMP THREADPRIVATE(rtstpo,rtstr2,rtstra,rtsur,rttrop,rzabov,rzmepo,rzmes2,rzmeso,rzstpo,rzstr2,rzstra)
+!$OMP THREADPRIVATE(rztrop,vdtdz1,vdtdz2,vdtdz3,vdtdz4,vdtdz5,vdtdz6,vdtdz7,vdtdz8,vdtdz9,vpabov,vpmepo)
+!$OMP THREADPRIVATE(vpmes2,vpmeso,vpstpo,vpstr2,vpstra,vptrop,vtabov,vtmepo,vtmes2,vtmeso,vtstpo,vtstr2)
+!$OMP THREADPRIVATE(vtstra,vtsur,vttrop,vzabov,vzmepo,vzmes2,vzmeso,vzstpo,vzstr2,vzstra,vztrop)
+!$OMP THREADPRIVATE(stden,stphi,stpre,stpreh,sttem,stz)
 END MODULE YOMSTA
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomsw15.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomsw15.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomsw15.F90	(revision 2056)
@@ -51,3 +51,5 @@
 !  RTUMG15 :  REFERENCE TEMPERATURE UNIFORMLY MIXED GASES
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(apad15,bpad15,d15,rpdh115,rpdu115,rpnh15,rpnu15,rray15,rsun15,rswce15,rswcp15)
+!$OMP THREADPRIVATE(rtdh2o15,rtdumg15,rth2o15,rtumg15)
 END MODULE YOMSW15
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomtag.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomtag.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomtag.F90	(revision 2056)
@@ -107,3 +107,8 @@
 INTEGER(KIND=JPIM) :: MTAGDISTFO
 
+!$OMP THREADPRIVATE(mt_distributed_vector,mtagbdy,mtagbrpr,mtagcain,mtagcost,mtagddh1,mtagddh2,mtagddh3,mtagddh4)
+!$OMP THREADPRIVATE(mtagddhres,mtagdistfo,mtagdistgp,mtagdistsp,mtageigmd,mtagfce,mtagfreq,mtaggetv,mtagglobsi)
+!$OMP THREADPRIVATE(mtagglobsr,mtaggom,mtaggpnorm,mtaggsum,mtagke,mtaglcz,mtaglm,mtagmn,mtagms,mtagmv,mtagnm)
+!$OMP THREADPRIVATE(mtagobseq,mtagobseqad,mtagozon,mtagpart,mtagrad,mtagrcbdy,mtagrclb,mtagrclbi,mtagreadvec)
+!$OMP THREADPRIVATE(mtagsig,mtagslag,mtagsm,mtagspno,mtagtide,mtagvh)
 END MODULE YOMTAG
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomtddh.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomtddh.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomtddh.F90	(revision 2056)
@@ -310,4 +310,4 @@
 !       IF LHDMCI
 !       IF LHDENT
-
+!$OMP THREADPRIVATE(hdcs0,hdcs1,hdcvb0,hdcvb1,pddhfsvi)
 END MODULE YOMTDDH
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomtoph.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomtoph.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomtoph.F90	(revision 2056)
@@ -87,3 +87,8 @@
 
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(etajuc,etcoef,etcoefe,etcoet,etcvim,etdifu,etdrag,etdrme,etnebu,etozon,etplui)
+!$OMP THREADPRIVATE(etqsat,etradi,ntajuc,ntcoef,ntcoefe,ntcoet,ntcvim,ntdifu,ntdrag,ntdrme,ntnebu)
+!$OMP THREADPRIVATE(ntozon,ntplui,ntqsat,ntradi,rclx,rfmesoq,tpsclim,xdrmqk,xdrmqp,xdrmtk,xdrmtp)
+!$OMP THREADPRIVATE(xdrmtx,xdrmuk,xdrmup,xdrmux)
+!$OMP THREADPRIVATE(rmesoq,rmesot,rmesou)
 END MODULE YOMTOPH
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yomvdoz.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yomvdoz.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yomvdoz.F90	(revision 2056)
@@ -74,3 +74,5 @@
 LOGICAL :: LRDEPOZ
 !   ---------------------------------------------------------------------
+!$OMP THREADPRIVATE(lrdepoz,lrdifoz,vdajh,vdajs,vdanh,vdans,vdejh,vdejs,vdenh,vdens,vdhjh,vdhjs)
+!$OMP THREADPRIVATE(vdhnh,vdhns,vdnjh,vdnjs,vdnnh,vdnns,vdpjh,vdpjs,vdpnh,vdpns,vozhs,voznj)
 END MODULE YOMVDOZ
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yophlc.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yophlc.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yophlc.F90	(revision 2056)
@@ -53,3 +53,4 @@
 !                        X(T+1)=X(T-1)+2*DX
 !     -----------------------------------------------------------------
+!$OMP THREADPRIVATE(ah0,alandz0,alpha,aseaz0,lczdeb,lkexp,lsdrds,lsdrlc,lsphlc,lvdfds,lvdflc,lzmcon,ustarl,ustars)
 END MODULE YOPHLC
Index: /LMDZ5/branches/testing/libf/phylmd/rrtm/yophnc.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/rrtm/yophnc.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/rrtm/yophnc.F90	(revision 2056)
@@ -50,3 +50,5 @@
 
 !     ------------------------------------------------------------------
+!$OMP THREADPRIVATE(lecond2,lecubm2,lecumf2,ledcld2,legwdg2,lekpert,lencld2,leqngt2,leradfl2,leradi2)
+!$OMP THREADPRIVATE(leradn2,lerads2,leradsw2,lesurf2,letrajp,letrajpt,levapls2,levdif2,ltraclnph)
 END MODULE YOPHNC
Index: /LMDZ5/branches/testing/libf/phylmd/surf_land_orchidee_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/surf_land_orchidee_mod.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/surf_land_orchidee_mod.F90	(revision 2056)
@@ -370,5 +370,6 @@
 
 ! zlev(1:knon) = (100.*plev(1:knon))/((ps(1:knon)/287.05*temp_air(1:knon))*9.80665)
-    zlev(1:knon) = (100.*plev(1:knon))/((ps(1:knon)/RD*temp_air(1:knon))*RG)
+!    zlev(1:knon) = (100.*plev(1:knon))/((ps(1:knon)/RD*temp_air(1:knon))*RG)
+     zlev(1:knon) = plev(1:knon)*RD*temp_air(1:knon)/((ps(1:knon)*100.0)*RG)
 
 
Index: /LMDZ5/branches/testing/libf/phylmd/test_disvert_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/test_disvert_m.F90	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/test_disvert_m.F90	(revision 2056)
@@ -0,0 +1,70 @@
+module test_disvert_m
+
+  implicit none
+
+contains
+
+  subroutine test_disvert
+
+    ! Author: Lionel GUEZ
+
+    ! This procedure tests the order of pressure values at half-levels
+    ! and full levels. We arbitrarily choose to test ngrid values of
+    ! the surface pressure, which sample possible values on Earth.
+
+    use exner_hyb_m, only: exner_hyb
+
+    ! For llm:
+    include "dimensions.h"
+
+    ! For ap, bp, preff:
+    include "comvert.h"
+
+    ! For kappa, cpp:
+    include "comconst.h"
+
+    ! Local:
+    integer l, i
+    integer, parameter:: ngrid = 7
+    real p(ngrid, llm + 1) ! pressure at half-level, in Pa
+    real pks(ngrid) ! exner function at the surface, in J K-1 kg-1 
+    real pk(ngrid, llm) ! exner function at full level, in J K-1 kg-1 
+    real ps(ngrid) ! surface pressure, in Pa
+    real p_lay(ngrid, llm) ! pressure at full level, in Pa
+    real delta_ps ! in Pa
+
+    !---------------------
+
+    print *, "Call sequence information: test_disvert"
+
+    delta_ps = 6e4 / (ngrid - 1)
+    ps = (/(5e4 + delta_ps * i, i = 0, ngrid - 1)/)
+    forall (l = 1: llm + 1) p(:, l) = ap(l) + bp(l) * ps
+    call exner_hyb(ngrid, ps, p, pks, pk)
+    p_lay = preff * (pk / cpp)**(1. / kappa)
+
+    ! Are pressure values in the right order?
+    if (any(p(:, :llm) <= p_lay .or. p_lay <= p(:, 2:))) then
+       ! List details and stop:
+       do l = 1, llm
+          do i = 1, ngrid
+             if (p(i, l) <= p_lay(i, l)) then
+                print 1000, "ps = ", ps(i) / 100., "hPa, p(level ",  l, &
+                     ") = ", p(i, l) / 100., " hPa <= p(layer ", l, ") = ", &
+                     p_lay(i, l) / 100., " hPa"
+             end if
+             if (p_lay(i, l) <= p(i, l + 1)) then
+                print 1000, "ps = ", ps(i) / 100., "hPa, p(layer ", l, ") = ", &
+                     p_lay(i, l) / 100., " hPa <= p(level ", l + 1, ") = ", &
+                     p(i, l + 1) / 100., " hPa"
+             end if
+          end do
+       end do
+       call abort_gcm("test_disvert", "bad order of pressure values", 1)
+    end if
+
+1000 format (3(a, g10.4, a, i0))
+
+  end subroutine test_disvert
+
+end module test_disvert_m
Index: DZ5/branches/testing/libf/phylmd/tetalevel.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/tetalevel.F90	(revision 2055)
+++ 	(revision )
@@ -1,138 +1,0 @@
-
-! $Header$
-
-! ================================================================
-! ================================================================
-SUBROUTINE tetalevel(ilon, ilev, lnew, pgcm, pres, qgcm, qpres)
-  ! ================================================================
-  ! ================================================================
-  USE dimphy
-  IMPLICIT NONE
-
-  ! ym#include "dimensions.h"
-  ! ym#include "dimphy.h"
-
-  ! ================================================================
-
-  ! Interpoler des champs 3-D u, v et g du modele a un niveau de
-  ! pression donnee (pres)
-
-  ! INPUT:  ilon ----- nombre de points
-  ! ilev ----- nombre de couches
-  ! lnew ----- true si on doit reinitialiser les poids
-  ! pgcm ----- pressions modeles
-  ! pres ----- pression vers laquelle on interpolle
-  ! Qgcm ----- champ GCM
-  ! Qpres ---- champ interpolle au niveau pres
-
-  ! ================================================================
-
-  ! arguments :
-  ! -----------
-
-  INTEGER ilon, ilev
-  LOGICAL lnew
-
-  REAL pgcm(ilon, ilev)
-  REAL qgcm(ilon, ilev)
-  REAL pres
-  REAL qpres(ilon)
-
-  ! local :
-  ! -------
-
-  ! ym#include "paramet.h"
-
-  INTEGER, ALLOCATABLE, SAVE :: lt(:), lb(:)
-  REAL, ALLOCATABLE, SAVE :: aist(:), aisb(:)
-  REAL, SAVE :: ptop, pbot
-  LOGICAL, SAVE :: first = .TRUE.
-  !$OMP THREADPRIVATE(lt,lb,aist,aisb,ptop, pbot,first)
-
-  INTEGER i, k
-
-  ! PRINT*,'tetalevel pres=',pres
-  IF (first) THEN
-    ALLOCATE (lt(ilon), lb(ilon))
-    ALLOCATE (aist(ilon), aisb(ilon))
-
-    first = .FALSE.
-  END IF
-  ! =====================================================================
-  IF (lnew) THEN
-    ! on r�nitialise les r�ndicages et les poids
-    ! =====================================================================
-
-
-    ! Chercher les 2 couches les plus proches du niveau a obtenir
-
-    ! Eventuellement, faire l'extrapolation a partir des deux couches
-    ! les plus basses ou les deux couches les plus hautes:
-    DO i = 1, ilon
-      ! IM      IF ( ABS(pres-pgcm(i,ilev) ) .LT.
-      IF (abs(pres-pgcm(i,ilev))>abs(pres-pgcm(i,1))) THEN
-        lt(i) = ilev ! 2
-        lb(i) = ilev - 1 ! 1
-      ELSE
-        lt(i) = 2
-        lb(i) = 1
-      END IF
-      ! IM   PRINT*,'i, ABS(pres-pgcm),ABS(pres-pgcm)',
-      ! IM  .i, ABS(pres-pgcm(i,ilev)),ABS(pres-pgcm(i,1))
-    END DO
-    DO k = 1, ilev - 1
-      DO i = 1, ilon
-        pbot = pgcm(i, k)
-        ptop = pgcm(i, k+1)
-        ! IM         IF (ptop.LE.pres .AND. pbot.GE.pres) THEN
-        IF (ptop>=pres .AND. pbot<=pres) THEN
-          lt(i) = k + 1
-          lb(i) = k
-        END IF
-      END DO
-    END DO
-
-    ! Interpolation lineaire:
-
-    DO i = 1, ilon
-      ! interpolation en logarithme de pression:
-
-      ! ...   Modif . P. Le Van    ( 20/01/98) ....
-      ! Modif Fr��ic Hourdin (3/01/02)
-
-      ! IF(pgcm(i,lb(i)).NE.0.OR.
-      ! $     pgcm(i,lt(i)).NE.0.) THEN
-
-      ! PRINT*,'i,lb,lt,2pgcm,pres',i,lb(i),
-      ! .  lt(i),pgcm(i,lb(i)),pgcm(i,lt(i)),pres
-
-      aist(i) = log(pgcm(i,lb(i))/pres)/log(pgcm(i,lb(i))/pgcm(i,lt(i)))
-      aisb(i) = log(pres/pgcm(i,lt(i)))/log(pgcm(i,lb(i))/pgcm(i,lt(i)))
-    END DO
-
-
-  END IF ! lnew
-
-  ! ======================================================================
-  ! inteprollation
-  ! ======================================================================
-
-  DO i = 1, ilon
-    qpres(i) = qgcm(i, lb(i))*aisb(i) + qgcm(i, lt(i))*aist(i)
-    ! IM      PRINT*,'i,Qgcm,Qpres',i,Qgcm(i,lb(i)),aisb(i),
-    ! IM  $   Qgcm(i,lt(i)),aist(i),Qpres(i)
-  END DO
-
-  ! Je mets les vents a zero quand je rencontre une montagne
-  DO i = 1, ilon
-    ! IM      if (pgcm(i,1).LT.pres) THEN
-    IF (pgcm(i,1)>pres) THEN
-      ! Qpres(i)=1e33
-      qpres(i) = 1E+20
-      ! IM         PRINT*,'i,pgcm(i,1),pres =',i,pgcm(i,1),pres
-    END IF
-  END DO
-
-
-  RETURN
-END SUBROUTINE tetalevel
Index: /LMDZ5/branches/testing/libf/phylmd/thermcell.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/thermcell.h	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/thermcell.h	(revision 2056)
@@ -9,13 +9,13 @@
       real,parameter     :: r_aspect_thermals=2.,l_mix_thermals=30.
       real               :: alp_bl_k
-      real               :: tau_thermals
+      real               :: tau_thermals,fact_thermals_ed_dz
       integer,parameter  :: w2di_thermals=0
       integer            :: isplit
 
       integer            :: iflag_coupl,iflag_clos,iflag_wake
-      integer            :: iflag_thermals_ed,iflag_thermals_optflux
+      integer            :: iflag_thermals_ed,iflag_thermals_optflux,iflag_thermals_closure
 
-      common/ctherm1/iflag_thermals,nsplit_thermals
-      common/ctherm2/tau_thermals,alp_bl_k
+      common/ctherm1/iflag_thermals,nsplit_thermals,iflag_thermals_closure
+      common/ctherm2/tau_thermals,alp_bl_k,fact_thermals_ed_dz
       common/ctherm4/iflag_coupl,iflag_clos,iflag_wake
       common/ctherm5/iflag_thermals_ed,iflag_thermals_optflux
Index: /LMDZ5/branches/testing/libf/phylmd/thermcell_dry.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/thermcell_dry.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/thermcell_dry.F90	(revision 2056)
@@ -122,6 +122,13 @@
                zw2(ig,l+1)=0.
                lmax(ig)=l
+!            endif
+!CR:zmax continu 06/05/12: calcul de linter quand le thermique est stoppe par le detrainement
+            elseif (f_star(ig,l+1).lt.0.) then
+               linter(ig)=(l*(f_star(ig,l+1)-f_star(ig,l))  &
+     &           -f_star(ig,l))/(f_star(ig,l+1)-f_star(ig,l))
+               zw2(ig,l+1)=0.
+               lmax(ig)=l
             endif
-
+!CRfin
                wa_moy(ig,l+1)=sqrt(zw2(ig,l+1))
 
Index: /LMDZ5/branches/testing/libf/phylmd/thermcell_height.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/thermcell_height.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/thermcell_height.F90	(revision 2056)
@@ -84,6 +84,7 @@
       enddo
 
-      if (iflag_thermals_ed.ge.1) then
-
+!     if (iflag_thermals_ed.ge.1) then
+      if (1==0) then
+!CR:date de quand le calcul du zmax continu etait buggue 
          num(:)=0.
          denom(:)=0.
@@ -100,7 +101,7 @@
        endif 
        enddo
-
-       else
-
+ 
+      else
+!CR:Calcul de zmax continu via le linter      
       do  ig=1,ngrid
 ! calcul de zlevinter
Index: /LMDZ5/branches/testing/libf/phylmd/thermcell_main.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/thermcell_main.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/thermcell_main.F90	(revision 2056)
@@ -513,4 +513,5 @@
     &                      lalim,lmin,zmax_sec,wmax_sec,lev_out)
 
+ 
 call test_ltherm(ngrid,nlay,pplev,pplay,lmin,seuil,ztv,po,ztva,zqla,f_star,zw2,'thermcell_dry  lmin  ')
 call test_ltherm(ngrid,nlay,pplev,pplay,lalim,seuil,ztv,po,ztva,zqla,f_star,zw2,'thermcell_dry  lalim ')
@@ -533,6 +534,8 @@
       alim_star_clos(:,:)=alim_star(:,:)
       alim_star_clos(:,:)=entr_star(:,:)+alim_star(:,:)
-
-! Appel avec la version seche
+!
+!CR Appel de la fermeture seche 
+      if (iflag_thermals_closure.eq.1) then
+
       CALL thermcell_closure(ngrid,nlay,r_aspect_thermals,ptimestep,rho,  &
      &   zlev,lalim,alim_star_clos,f_star,zmax_sec,wmax_sec,f,lev_out)
@@ -541,6 +544,11 @@
 ! Appel avec les zmax et wmax tenant compte de la condensation
 ! Semble moins bien marcher
-!     CALL thermcell_closure(ngrid,nlay,r_aspect_thermals,ptimestep,rho,  &
-!    &   zlev,lalim,alim_star,f_star,zmax,wmax,f,lev_out)
+     else if (iflag_thermals_closure.eq.2) then
+
+     CALL thermcell_closure(ngrid,nlay,r_aspect_thermals,ptimestep,rho,  &
+    &   zlev,lalim,alim_star,f_star,zmax,wmax,f,lev_out)
+
+     endif
+
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
@@ -754,7 +762,12 @@
       do ig=1,ngrid
         if (ok_lcl(ig)) then 
-          if ((pplay(ig,l) .ge. pcon(ig)) .and. (pplay(ig,l+1) .le. pcon(ig))) then
+!ATTENTION,zw2 calcule en pplev
+!          if ((pplay(ig,l) .ge. pcon(ig)) .and. (pplay(ig,l+1) .le. pcon(ig))) then
+!          klcl(ig)=l
+!          interp(ig)=(pcon(ig)-pplay(ig,klcl(ig)))/(pplay(ig,klcl(ig)+1)-pplay(ig,klcl(ig)))
+!          endif
+          if ((pplev(ig,l) .ge. pcon(ig)) .and. (pplev(ig,l+1) .le. pcon(ig))) then
           klcl(ig)=l
-          interp(ig)=(pcon(ig)-pplay(ig,klcl(ig)))/(pplay(ig,klcl(ig)+1)-pplay(ig,klcl(ig)))
+          interp(ig)=(pcon(ig)-pplev(ig,klcl(ig)))/(pplev(ig,klcl(ig)+1)-pplev(ig,klcl(ig)))
           endif
         endif
@@ -772,5 +785,6 @@
 !!    enddo
     do ig =1,ngrid
-     zmax(ig)=pphi(ig,lmax(ig))/rg
+!CR:REHABILITATION ZMAX CONTINU
+!     zmax(ig)=pphi(ig,lmax(ig))/rg
      if (ok_lcl(ig)) then 
       rhobarz0(ig)=rhobarz(ig,klcl(ig))+(rhobarz(ig,klcl(ig)+1) &
@@ -915,5 +929,5 @@
 !------------Closure------------------
 
-  IF (iflag_clos_bl.ge.1) THEN 
+  IF (iflag_clos_bl.ge.2) THEN 
 
 !-----Calcul de ALP_BL_STAT
@@ -938,5 +952,5 @@
   enddo
 
-  ENDIF ! (iflag_clos_bl.ge.1)
+  ENDIF ! (iflag_clos_bl.ge.2)
 
 !!! fin nrlmd le 10/04/2012
Index: /LMDZ5/branches/testing/libf/phylmd/thermcell_plume.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/thermcell_plume.F90	(revision 2055)
+++ /LMDZ5/branches/testing/libf/phylmd/thermcell_plume.F90	(revision 2056)
@@ -7,9 +7,6 @@
      &           ztla,zqla,zqta,zha,zw2,w_est,ztva_est,zqsatth,lmix,lmix_bis,linter &
      &           ,lev_out,lunout1,igout)
-
 !--------------------------------------------------------------------------
-! thermcell_plume: calcule les valeurs de qt, thetal et w dans l ascendance
-! Last modified : Arnaud Jam 2014/02/11
-!                 Better representation of stratocumulus
+!thermcell_plume: calcule les valeurs de qt, thetal et w dans l ascendance
 !--------------------------------------------------------------------------
 
@@ -83,4 +80,7 @@
       real zbuoyjam(ngrid,klev)
       real zbuoybis,zdz2,zdz3,lmel,entrbis,zdzbis
+      real fact_shell
+      real ztv1,ztv2,factinv,zinv,zlmel
+      real ztv_est1,ztv_est2
       real zcor,zdelta,zcvm5,qlbef
       real betalpha,zbetalpha
@@ -98,5 +98,6 @@
       fact_epsilon=0.002
       betalpha=0.9 
-      afact=2./3.            
+      afact=2./3.    
+      fact_shell=0.85       
 
       zbetalpha=betalpha/(1.+betalpha)
@@ -164,5 +165,5 @@
                lalim(ig)=l+1
                alim_star_tot(ig)=alim_star_tot(ig)+alim_star(ig,l)
-!              print*,'alim2',l,ztv(ig,l),ztv(ig,l+1),alim_star(ig,l)
+!               print*,'alim2',l,ztv(ig,l),ztv(ig,l+1),alim_star(ig,l)
             endif
          enddo
@@ -234,5 +235,5 @@
    call thermcell_qsat(ngrid,active,pplev(:,l),ztemp,zqta(:,l-1),zqsat(:))
     do ig=1,ngrid 
-!      print*,'active',active(ig),ig,l
+!       print*,'active',active(ig),ig,l
         if(active(ig)) then 
         zqla_est(ig,l)=max(0.,zqta(ig,l-1)-zqsat(ig))
@@ -260,11 +261,46 @@
 !    &                     Max(0.0001,exp(-zw2factbis)*(w_est(ig,l-1)-zdw2bis)+zdw2)
 !              w_est(ig,l+1)=Max(0.0001,(1-exp(-zw2fact))*zdw2+w_est(ig,l)*exp(-zw2fact))
+
+!--------------------------------------------------
+!AJ052014: J'ai remplac? w_est(ig,l) par zw2(ig,l)
+!--------------------------------------------------
+         if (iflag_thermals_ed==8) then
+! Ancienne version
              w_est(ig,l+1)=Max(0.0001,(zdz/zdzbis)*(exp(-zw2fact)* &
     &                     (w_est(ig,l)-zdw2)+zdw2)+(zdzbis-zdz)/zdzbis* &
     &                     (exp(-zw2factbis)*(w_est(ig,l-1)-zdw2bis)+zdw2))
-             if (w_est(ig,l+1).lt.0.) then
+ 
+! Nouvelle version Arnaud
+         else
+              w_est(ig,l+1)=Max(0.0001,(zdz/zdzbis)*(exp(-zw2fact)* &
+    &                     (zw2(ig,l)-zdw2)+zdw2)+(zdzbis-zdz)/zdzbis* &
+    &                     (exp(-zw2factbis)*(zw2(ig,l-1)-zdw2bis)+zdw2))
+         endif
+
+
+         if (iflag_thermals_ed<6) then
+             zalpha=f0(ig)*f_star(ig,l)/sqrt(w_est(ig,l+1))/rhobarz(ig,l)
+!              fact_epsilon=0.0005/(zalpha+0.025)**0.5
+!              fact_epsilon=Min(0.003,0.0004/(zalpha)**0.5)
+              fact_epsilon=0.0002/(zalpha+0.1)
+              zw2fact=fact_epsilon*2.*zdz/(1.+betalpha)
+              zw2factbis=fact_epsilon*2.*zdzbis/(1.+betalpha)
+              zdw2=afact*zbuoy(ig,l)/fact_epsilon
+              zdw2bis=afact*zbuoy(ig,l-1)/fact_epsilon
+              w_est(ig,l+1)=Max(0.0001,(zdz/zdzbis)*(exp(-zw2fact)* &
+    &                     (zw2(ig,l)-zdw2)+zdw2)+(zdzbis-zdz)/zdzbis* &
+    &                     (exp(-zw2factbis)*(zw2(ig,l-1)-zdw2bis)+zdw2))
+
+         endif
+!--------------------------------------------------
+!AJ052014: J'ai comment? ce if plus n?cessaire puisqu'
+!on fait max(0.0001,.....)
+!--------------------------------------------------	 
+
+!             if (w_est(ig,l+1).lt.0.) then
 !               w_est(ig,l+1)=zw2(ig,l)
-                w_est(ig,l+1)=0.0001
-             endif
+!                w_est(ig,l+1)=0.0001
+!             endif
+
        endif
     enddo
@@ -297,13 +333,115 @@
 !Modif AJAM
           
-	lmel=0.1*zlev(ig,l)
+	lmel=fact_thermals_ed_dz*zlev(ig,l)
+        zlmel=zlev(ig,l)+lmel
 !        lmel=2.5*(zlev(ig,l)-zlev(ig,l-1))
         lt=l+1
-         do it=1,klev-(l+1) 
-          zdz2=zlev(ig,lt)-zlev(ig,l)
-          if (zdz2.gt.lmel) then 
-          zdz3=zlev(ig,lt)-zlev(ig,lt-1) 
+        zdz2=zlev(ig,lt)-zlev(ig,l)
+!--------------------------------------------------
+!AJ052014: J'ai remplac? la boucle do par un do while
+! afin de faire moins de calcul dans la boucle
+!--------------------------------------------------
+         do while (zdz2.lt.lmel)
+         lt=lt+1
+         zdz2=zlev(ig,lt)-zlev(ig,l)
+         end do
+
+         zdz3=zlev(ig,lt)-zlev(ig,lt-1) 
+
+!--------------------------------------------------
+!AJ052014: Si iflag_thermals_ed<8 (par ex 6), alors
+! on cherche o? se trouve l'altitude d'inversion 
+! en calculant ztv1 (interpolation de la valeur de 
+! theta au niveau lt en utilisant les niveaux lt-1 et
+! lt-2) et ztv2 (interpolation avec les niveaux lt+1
+! et lt+2). Si theta r?ellement calcul?e au niveau lt
+! comprise entre ztv1 et ztv2, alors il y a inversion
+! et on calcule son altitude zinv en supposant que ztv(lt)
+! est une combinaison lin?aire de ztv1 et ztv2.
+! Ensuite, on calcule la flottabilit? en comparant 
+! la temp?rature de la couche l ? celle de l'air situ? 
+! l+lmel plus haut, ce qui n?cessite de savoir quel fraction 
+! de cet air est au-dessus ou en-dessous de l'inversion   
+!--------------------------------------------------
+
+
+	 if (iflag_thermals_ed.lt.8) then
+
+          ztv1=(ztv(ig,lt-1)-ztv(ig,lt-2))*zlev(ig,lt)/(zlev(ig,lt-1)-zlev(ig,lt-2)) &
+    &          +(ztv(ig,lt-2)*zlev(ig,lt-1)-ztv(ig,lt-1)*zlev(ig,lt-2)) &
+    &          /(zlev(ig,lt-1)-zlev(ig,lt-2))
+
+          ztv2=(ztv(ig,lt+2)-ztv(ig,lt+1))*zlev(ig,lt)/(zlev(ig,lt+2)-zlev(ig,lt+1)) &
+    &          +(ztv(ig,lt+1)*zlev(ig,lt+2)-ztv(ig,lt+2)*zlev(ig,lt+1)) &
+    &          /(zlev(ig,lt+2)-zlev(ig,lt+1))
+
+          if (ztv(ig,lt).gt.ztv1.and.ztv(ig,lt).lt.ztv2) then  
+
+	  factinv=(ztv2-ztv(ig,lt))/(ztv2-ztv1)
+          zinv=zlev(ig,lt-1)+factinv*(zlev(ig,lt)-zlev(ig,lt-1))
+
+	  if (zlmel+0.5*zdz.ge.zinv) then
+           if (zlmel-0.5*zdz.ge.zinv) then
+
+          ztv_est(ig,l)=(ztv(ig,lt+2)-ztv(ig,lt+1))*(zlmel-0.*zdz)/(zlev(ig,lt+2)-zlev(ig,lt+1)) &
+    &          +(ztv(ig,lt+1)*zlev(ig,lt+2)-ztv(ig,lt+2)*zlev(ig,lt+1)) &
+    &          /(zlev(ig,lt+2)-zlev(ig,lt+1))
+
+          zbuoyjam(ig,l)=fact_shell*RG*(ztva_est(ig,l)-ztv_est(ig,l))/ztv_est(ig,l)+(1.-fact_shell)*zbuoy(ig,l)
+
+          else
+
+	  ztv_est1=(ztv(ig,lt+2)-ztv(ig,lt+1))*0.5*(zlmel+zinv+0.5*zdz)/(zlev(ig,lt+2)-zlev(ig,lt+1)) &
+    &          +(ztv(ig,lt+1)*zlev(ig,lt+2)-ztv(ig,lt+2)*zlev(ig,lt+1)) &
+    &          /(zlev(ig,lt+2)-zlev(ig,lt+1))
+          ztv_est2=(ztv(ig,lt-1)-ztv(ig,lt-2))*0.5*(zinv+zlmel-0.5*zdz)/(zlev(ig,lt-1)-zlev(ig,lt-2)) &
+    &          +(ztv(ig,lt-2)*zlev(ig,lt-1)-ztv(ig,lt-1)*zlev(ig,lt-2)) &
+    &          /(zlev(ig,lt-1)-zlev(ig,lt-2))
+          zbuoyjam(ig,l)=fact_shell*RG*(((zlmel+0.5*zdz-zinv)/zdz)*(ztva_est(ig,l)- & 
+    &          ztv_est1)/ztv_est1+((zinv-zlmel+0.5*zdz)/zdz)*(ztva_est(ig,l)- &
+    &          ztv_est2)/ztv_est2)+(1.-fact_shell)*zbuoy(ig,l)
+
+           endif
+
+          else 
+
+          ztv_est(ig,l)=(ztv(ig,lt-1)-ztv(ig,lt-2))*(zlmel-0.*zdz)/(zlev(ig,lt-1)-zlev(ig,lt-2)) &
+    &          +(ztv(ig,lt-2)*zlev(ig,lt-1)-ztv(ig,lt-1)*zlev(ig,lt-2)) &
+    &          /(zlev(ig,lt-1)-zlev(ig,lt-2))
+
+          zbuoyjam(ig,l)=fact_shell*RG*(ztva_est(ig,l)-ztv_est(ig,l))/ztv_est(ig,l)+(1.-fact_shell)*zbuoy(ig,l)
+!	  ztv_est1=(ztv(ig,lt+2)-ztv(ig,lt+1))*0.5*(zlmel+zinv+0.5*zdz)/(zlev(ig,lt+2)-zlev(ig,lt+1)) &
+!    &          +(ztv(ig,lt+1)*zlev(ig,lt+2)-ztv(ig,lt+2)*zlev(ig,lt+1)) &
+!    &          /(zlev(ig,lt+2)-zlev(ig,lt+1))
+!          ztv_est2=(ztv(ig,lt-1)-ztv(ig,lt-2))*0.5*(zinv+zlmel-0.5*zdz)/(zlev(ig,lt-1)-zlev(ig,lt-2)) &
+!    &          +(ztv(ig,lt-2)*zlev(ig,lt-1)-ztv(ig,lt-1)*zlev(ig,lt-2)) &
+!    &          /(zlev(ig,lt-1)-zlev(ig,lt-2))
+!          zbuoyjam(ig,l)=fact_shell*RG*(((zlmel+0.5*zdz-zinv)/zdz)*(ztva_est(ig,l)- & 
+!    &          ztv_est1)/ztv_est1+((zinv-zlmel+0.5*zdz)/zdz)*(ztva_est(ig,l)- &
+!    &          ztv_est2)/ztv_est2)+(1.-fact_shell)*zbuoy(ig,l)
+
+
+
+
+!          print*,'on est pass? par l?',l,lt,zbuoyjam(ig,l),zbuoy(ig,l)
+          endif
+
+
+          else
+          
 !          ztv_est(ig,l)=(lmel/zdz2)*(ztv(ig,lt)-ztv(ig,l))+ztv(ig,l)
 !          zbuoyjam(ig,l)=RG*(ztva_est(ig,l)-ztv_est(ig,l))/ztv_est(ig,l)
+
+         zbuoyjam(ig,l)=fact_shell*RG*(((lmel+zdz3-zdz2)/zdz3)*(ztva_est(ig,l)- & 
+    &          ztv(ig,lt))/ztv(ig,lt)+((zdz2-lmel)/zdz3)*(ztva_est(ig,l)- &
+    &          ztv(ig,lt-1))/ztv(ig,lt-1))+(1.-fact_shell)*zbuoy(ig,l)
+
+!         zdqt(ig,l)=Max(0.,((lmel+zdz3-zdz2)/zdz3)*(zqta(ig,l-1)- & 
+!    &          po(ig,lt))/po(ig,lt)+((zdz2-lmel)/zdz3)*(zqta(ig,l-1)- &
+!     &          po(ig,lt-1))/po(ig,lt-1))
+
+	  endif
+
+          else
 
          zbuoyjam(ig,l)=1.*RG*(((lmel+zdz3-zdz2)/zdz3)*(ztva_est(ig,l)- & 
@@ -311,31 +449,30 @@
     &          ztv(ig,lt-1))/ztv(ig,lt-1))+0.*zbuoy(ig,l)
 
-!         zdqt(ig,l)=Max(0.,((lmel+zdz3-zdz2)/zdz3)*(zqta(ig,l-1)- & 
-!    &          po(ig,lt))/po(ig,lt)+((zdz2-lmel)/zdz3)*(zqta(ig,l-1)- &
-!    &          po(ig,lt-1))/po(ig,lt-1))
+	  endif
           
-          else
-          lt=lt+1
-          endif
-          enddo
 
 !          zbuoyjam(ig,l)=RG*(ztva_est(ig,l)-ztv(ig,l))/ztv(ig,l)
 
+!          entr_star(ig,l)=f_star(ig,l)*zdz*zbetalpha*MAX(0.,  &
+!    &     afact*zbuoyjam(ig,l)/zw2m - fact_epsilon ) 
+
+!          entrbis=entr_star(ig,l)
+
+	  if (iflag_thermals_ed.lt.6) then
+          fact_epsilon=0.0002/(zalpha+0.1)
+	  endif
+
+          detr_star(ig,l)=f_star(ig,l)*zdz             &
+    &     *MAX(1.e-4, -afact*zbetalpha*zbuoyjam(ig,l)/zw2m          &
+    &     + 0.012*(zdqt(ig,l)/zw2m)**0.5)
+
+          zbuoy(ig,l)=RG*(ztva_est(ig,l)-ztv(ig,l))/ztv(ig,l)
+
           entr_star(ig,l)=f_star(ig,l)*zdz*zbetalpha*MAX(0.,  &
-    &     afact*zbuoyjam(ig,l)/zw2m - fact_epsilon ) 
-
-          entrbis=entr_star(ig,l)
-
-
-          detr_star(ig,l)=f_star(ig,l)*zdz                        &
-    &     *MAX(1.e-4, -afact*zbetalpha*zbuoyjam(ig,l)/zw2m          &
-    &     + 0.012*(zdqt(ig,l)/zw2m)**0.5 )
-
-
-!           zbuoy(ig,l)=RG*(ztva_est(ig,l)-ztv(ig,l))/ztv(ig,l)
-!
-!           entr_star(ig,l)=Max(0.,f_star(ig,l)*zdz*zbetalpha*  &     
-!     &     afact*zbuoy(ig,l)/zw2m &
-!     &     - 1.*fact_epsilon)
+    &     afact*zbuoy(ig,l)/zw2m - fact_epsilon)
+
+!          entr_star(ig,l)=Max(0.,f_star(ig,l)*zdz*zbetalpha*  &     
+!    &     afact*zbuoy(ig,l)/zw2m &
+!    &     - 1.*fact_epsilon)
 
           
@@ -350,5 +487,5 @@
 !        endif
 
-!print*,'alim0',l,lalim(ig),alim_star(ig,l),entrbis,f_star(ig,l)
+!	print*,'alim0',zlev(ig,l),entr_star(ig,l),detr_star(ig,l),zw2m,zbuoy(ig,l),f_star(ig,l)
 ! Calcul du flux montant normalise
       f_star(ig,l+1)=f_star(ig,l)+alim_star(ig,l)+entr_star(ig,l)  &
@@ -393,5 +530,5 @@
            zdzbis=zlev(ig,l+1)-zlev(ig,l-1)
            zeps(ig,l)=(entr_star(ig,l)+alim_star(ig,l))/(f_star(ig,l)*zdz)
-
+           fact_epsilon=0.002
             zw2fact=fact_epsilon*2.*zdz/(1.+betalpha)
             zw2factbis=fact_epsilon*2.*zdzbis/(1.+betalpha)
@@ -402,4 +539,22 @@
     &                     (zw2(ig,l)-zdw2)+zdw2)+(zdzbis-zdz)/zdzbis* &
     &                     (exp(-zw2factbis)*(zw2(ig,l-1)-zdw2bis)+zdw2))
+
+	   if (iflag_thermals_ed.lt.6) then
+           zalpha=f0(ig)*f_star(ig,l)/sqrt(zw2(ig,l+1))/rhobarz(ig,l)
+!           fact_epsilon=0.0005/(zalpha+0.025)**0.5
+!           fact_epsilon=Min(0.003,0.0004/(zalpha)**0.5)
+           fact_epsilon=0.0002/(zalpha+0.1)**1
+            zw2fact=fact_epsilon*2.*zdz/(1.+betalpha)
+            zw2factbis=fact_epsilon*2.*zdzbis/(1.+betalpha)
+            zdw2= afact*zbuoy(ig,l)/(fact_epsilon)
+            zdw2bis= afact*zbuoy(ig,l-1)/(fact_epsilon)
+
+            zw2(ig,l+1)=Max(0.0001,(zdz/zdzbis)*(exp(-zw2fact)* &
+    &                     (zw2(ig,l)-zdw2)+zdw2)+(zdzbis-zdz)/zdzbis* &
+    &                     (exp(-zw2factbis)*(zw2(ig,l-1)-zdw2bis)+zdw2))
+
+	   endif
+
+
       endif
    enddo
@@ -425,4 +580,10 @@
      &               -zw2(ig,l))/(zw2(ig,l+1)-zw2(ig,l))
            zw2(ig,l+1)=0.
+!+CR:04/05/12:correction calcul linter pour calcul de zmax continu
+        elseif (f_star(ig,l+1).lt.0.) then
+           linter(ig)=(l*(f_star(ig,l+1)-f_star(ig,l))  &
+     &               -f_star(ig,l))/(f_star(ig,l+1)-f_star(ig,l))
+           zw2(ig,l+1)=0.
+!fin CR:04/05/12
         endif
 
@@ -462,6 +623,51 @@
         if (prt_level.ge.20) print*,'coucou calcul detr 470: ig, l', ig, l
 
+#undef wrgrads_thermcell
+#ifdef wrgrads_thermcell
+         call wrgradsfi(1,klev,entr_star(igout,1:klev),'esta      ','esta      ')
+         call wrgradsfi(1,klev,detr_star(igout,1:klev),'dsta      ','dsta      ')
+         call wrgradsfi(1,klev,zbuoy(igout,1:klev),'buoy      ','buoy      ')
+         call wrgradsfi(1,klev,zdqt(igout,1:klev),'dqt      ','dqt      ')
+         call wrgradsfi(1,klev,w_est(igout,1:klev),'w_est     ','w_est     ')
+         call wrgradsfi(1,klev,w_est(igout,2:klev+1),'w_es2     ','w_es2     ')
+         call wrgradsfi(1,klev,zw2(igout,1:klev),'zw2A      ','zw2A      ')
+#endif
+
+
      return 
      end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 
@@ -536,4 +742,5 @@
       REAL zqsatth(ngrid,klev)
       REAL zta_est(ngrid,klev)
+      REAL zbuoyjam(ngrid,klev)
       REAL ztemp(ngrid),zqsat(ngrid)
       REAL zdw2
@@ -572,5 +779,5 @@
 
 ! Initialisations des variables reeles
-if (1==0) then
+if (1==1) then
       ztva(:,:)=ztv(:,:)
       ztva_est(:,:)=ztva(:,:)
@@ -598,4 +805,5 @@
       zw2(:,:)=0.
       zbuoy(:,:)=0.
+      zbuoyjam(:,:)=0.
       gamma(:,:)=0.
       zeps(:,:)=0.
@@ -862,4 +1070,16 @@
         if (prt_level.ge.20) print*,'coucou calcul detr 470: ig, l', ig, l
 
+#undef wrgrads_thermcell
+#ifdef wrgrads_thermcell
+         call wrgradsfi(1,klev,entr_star(igout,1:klev),'esta      ','esta      ')
+         call wrgradsfi(1,klev,detr_star(igout,1:klev),'dsta      ','dsta      ')
+         call wrgradsfi(1,klev,zbuoy(igout,1:klev),'buoy      ','buoy      ')
+         call wrgradsfi(1,klev,zdqt(igout,1:klev),'dqt      ','dqt      ')
+         call wrgradsfi(1,klev,w_est(igout,1:klev),'w_est     ','w_est     ')
+         call wrgradsfi(1,klev,w_est(igout,2:klev+1),'w_es2     ','w_es2     ')
+         call wrgradsfi(1,klev,zw2(igout,1:klev),'zw2A      ','zw2A      ')
+#endif
+
+
      return 
      end
Index: /LMDZ5/branches/testing/libf/phylmd/tsoilnudge.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/tsoilnudge.h	(revision 2056)
+++ /LMDZ5/branches/testing/libf/phylmd/tsoilnudge.h	(revision 2056)
@@ -0,0 +1,7 @@
+      logical nudge_tsoil
+      integer isoil_nudge
+      real Tsoil_nudge, tau_soil_nudge
+
+      common /tsoilnudge/ nudge_tsoil, isoil_nudge, Tsoil_nudge,        &
+     &                   tau_soil_nudge
+
Index: /LMDZ5/branches/testing/makegcm
===================================================================
--- /LMDZ5/branches/testing/makegcm	(revision 2055)
+++ /LMDZ5/branches/testing/makegcm	(revision 2056)
@@ -7,4 +7,17 @@
 # options par defaut pour la commande make
 ########################################################################
+
+echo ' '
+echo 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
+echo 'Attention makegcm n est plus supporte par l equipe de developpement'
+echo 'Il faut maintenant utiliser ./makelmdz ou ./makelmdz_fcm              '
+echo 'Si vous tenez absolument a utiliser makegcm, editez le script et'
+echo 'retirer ces lignes (a vos risques et perils)'
+echo 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
+echo ' '
+
+exit
+
+
 set dim="96x71x19"
 set physique=lmd
@@ -30,11 +43,11 @@
 set FC_LINUX=gfortran
 
-if ( $FC_LINUX == g95 ) then
-  set OPT_LINUX="-i4 -O3 -r8 -DNC_DOUBLE"
+if ( $FC_LINUX == gfortran ) then
+  set OPT_LINUX="-O3 -fdefault-real-8 -DNC_DOUBLE"
 else if ( $FC_LINUX == gfortran ) then
   set OPT_LINUX="-O3 -fdefault-real-8 -DNC_DOUBLE"
 else
 # pgf90 options
-  set OPT_LINUX="-O3 -i4 -r8 -DNC_DOUBLE"
+  set OPT_LINUX="-O3 -fdefault-real-8 -DNC_DOUBLE"
 endif
 
@@ -51,6 +64,6 @@
 setenv IOIPSLDIR /tmpdir/fairhead/Aqua/LMDZ20120327.trunk/modipsl/lib
 setenv MODIPSLDIR /tmpdir/fairhead/Aqua/LMDZ20120327.trunk/modipsl/lib
-setenv NCDFINC /d1/mpllmd/LMDZtesting/netcdf-4.0.1/include
-setenv NCDFLIB /d1/mpllmd/LMDZtesting/netcdf-4.0.1/lib
+setenv NCDFINC /tmpdir/fairhead/Test_install/LMDZtrunk/netcdf-4.0.1/include
+setenv NCDFLIB /tmpdir/fairhead/Test_install/LMDZtrunk/netcdf-4.0.1/lib
 
 
@@ -104,10 +117,10 @@
   if ( ! $?NCDFLIB ) then
     echo You must initialize the variable NCDFLIB in your environnement
-    echo for instance: "setenv NCDFLIB /d1/mpllmd/LMDZtesting/netcdf-4.0.1/lib
+    echo for instance: "setenv NCDFLIB /tmpdir/fairhead/Test_install/LMDZtrunk/netcdf-4.0.1/lib
     exit
   endif
   if ( ! $?NCDFINC ) then
     echo You must initialize the variable NCDFINC in your environnement
-    echo for instance: "setenv NCDFINC /d1/mpllmd/LMDZtesting/netcdf-4.0.1/include
+    echo for instance: "setenv NCDFINC /tmpdir/fairhead/Test_install/LMDZtrunk/netcdf-4.0.1/include
     exit
   endif
@@ -259,5 +272,5 @@
 else if $LINUX then
 #################
-   if ( $FC_LINUX == pgf90 || $FC_LINUX == g95 || $FC_LINUX == gfortran ) then
+   if ( $FC_LINUX == pgf90 || $FC_LINUX == gfortran || $FC_LINUX == gfortran ) then
      set optim=" $OPT_LINUX "
      set optim90=" $OPT_LINUX "
@@ -519,5 +532,5 @@
              set optim90="$optim90"" -g -ffpe-trap=invalid,zero,overflow -fbounds-check -Wall "
              set optimtru90="$optimtru90"" -ffpe-trap=invalid,zero,overflow -g -fbounds-check -Wall "
-           else if ( $FC_LINUX == 'g95' ) then
+           else if ( $FC_LINUX == 'gfortran' ) then
              set optim="$optim"" -g -fbounds-check -freal=nan -ftrace=full -Wall "
              set optim90="$optim90"" -g -fbounds-check -freal=nan -ftrace=full -Wall "
@@ -585,5 +598,5 @@
    set cppflags="$cppflags -DCPP_VEGET"
 #   set link_veget=" -lsechiba -lparameters -lstomate  "
-   set link_veget=" -lsechiba -lparameters -lstomate -lparallel -lorglob -lorchidee"
+   set link_veget=" -lsechiba -lparameters -lstomate   -lorchidee"
    if ( $XNEC || $X8BRODIE || $X6NEC) then
 #      set link_veget=" -lsxsechiba -lsxparameters -lsxstomate -lsxorglob -lsxparallel"
@@ -845,5 +858,5 @@
        set opt_link="$opt_link  -L$MODIPSLDIR $link_veget -L$NCDFLIB -lnetcdf "
      endif
-   else if ($FC_LINUX == 'g95' || $FC_LINUX == 'gfortran' ) then
+   else if ($FC_LINUX == 'gfortran' || $FC_LINUX == 'gfortran' ) then
      if ( $io == "ioipsl" ) then
        set opt_link="$opt_link -L$MODIPSLDIR $link_veget -lioipsl -L$NCDFLIB  -lnetcdf -lioipsl  -lnetcdf "
@@ -1019,7 +1032,7 @@
    set optimtru90=" $optimtru90 -module $libo "
    set optim90=" $optim90 -module $libo "
-else if ( $FC_LINUX == 'g95' ) then 
-   set optimtru90=" $optimtru90 -fmod=$libo  " 
-   set optim90=" $optim90 -fmod=$libo  "
+else if ( $FC_LINUX == 'gfortran' ) then 
+   set optimtru90=" $optimtru90 -I$libo  " 
+   set optim90=" $optim90 -I$libo  "
 else if ( $FC_LINUX == 'gfortran' ) then
    set optimtru90=" $optimtru90 -M $libo  "
Index: /LMDZ5/branches/testing/makelmdz
===================================================================
--- /LMDZ5/branches/testing/makelmdz	(revision 2055)
+++ /LMDZ5/branches/testing/makelmdz	(revision 2056)
@@ -32,15 +32,7 @@
 ## try to recognise machine and infer arch from it
 machine=`hostname`
-if [[ "$machine" == "brodie" ]]
-then
-  arch="SX8_BRODIE"
-fi
 if [[ "${machine:0:3}" == "ada" ]]
 then
   arch="X64_ADA"
-fi
-if [[ "${machine:0:6}" == "ciclad" ]]
-then
-  arch="AMD64_CICLAD"
 fi
 if [[ "${machine:0:7}" == "platine" ]]
@@ -84,5 +76,5 @@
 
 CPP_KEY="" 
-INCLUDE='-I$(LIBF)/grid -I$(LIBF)/bibio -I$(LIBF)/dyn3d_common -I$(LIBF)/filtrez -I. '
+INCLUDE='-I$(LIBF)/grid -I$(LIBF)/bibio -I$(LIBF)/filtrez -I. '
 LIB=""
 adjnt=""
@@ -167,9 +159,4 @@
 	  CPP_KEY="$CPP_KEY $2" ; shift ; shift ;;
 
-      "-adjnt")
-	  echo "not operational ... work to be done here ";exit
-	  opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d "
-	  optim="$optim -Dadj" ; shift ;;
-
       "-cosp")
           cosp="$2" ; shift ; shift ;;
@@ -487,49 +474,16 @@
    cp -p fxy_${grille}.h fxyprim.h
    filtre="FILTRE=$filtre"
-   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} '
+   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} -I$(LIBF)/dyn3d_common '
 elif (( $dimc == 2 )) ; then
    filtre="FILTRE= L_FILTRE= "
    INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d'
 elif (( $dimc == 1 )) ; then
+   CPP_KEY="$CPP_KEY CPP_1D"
    filtre="L_DYN= DYN= FILTRE= L_FILTRE= DIRMAIN=phy$physique "
-   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d' # Pas tres propre
+   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d -I$(LIBF)/dyn3d_common ' # Pas tres propre
 else
    echo Dimension dimc=$dimc pas prevu ; exit
 fi
 
-######################################################################
-# Creation du suffixe de la configuration
-######################################################################
-
-SUFF_NAME=_${dim_full}
-SUFF_NAME=${SUFF_NAME}_phy${physique}
-
-if [[ "$parallel" != "none" ]]
-then
-  SUFF_NAME=${SUFF_NAME}_para
-  DYN=dyn${dimc}d${paramem}
-  if [[ "$paramem" == "mem" ]]
-  then
-   SUFF_NAME=${SUFF_NAME}_${paramem}
-  fi
-else
-  SUFF_NAME=${SUFF_NAME}_seq
-  DYN=dyn${dimc}d
-fi
-
-if [[ $veget != "false" ]]
-then
-  SUFF_NAME=${SUFF_NAME}_orch
-fi
-
-if [[ $couple != "false" ]]
-then
-  SUFF_NAME=${SUFF_NAME}_couple
-fi
-
-if [[ $chimie == "INCA" ]]
-then
-  SUFF_NAME=${SUFF_NAME}_inca
-fi
 
 cd $LMDGCM
@@ -574,4 +528,6 @@
 if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]]
 then
+  source_code=${code}.F90
+elif [[ -r $LMDGCM/libf/phy$physique/${code}.F90 ]] ; then
   source_code=${code}.F90
 fi
