Index: /LMDZ5/branches/testing/DefLists/field_def_lmdz.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/field_def_lmdz.xml	(revision 2470)
+++ /LMDZ5/branches/testing/DefLists/field_def_lmdz.xml	(revision 2471)
@@ -656,9 +656,4 @@
       <field id="c14_cfad_lidarsr532" long_name="Lidar Scattering Ratio CFAD (532 nm)" unit="1" axis_ref="height" />
       <field id="c15_cfad_lidarsr532" long_name="Lidar Scattering Ratio CFAD (532 nm)" unit="1" axis_ref="height" />
-      <field id="c16_cfad_lidarsr532" long_name="Lidar Scattering Ratio CFAD (532 nm)" unit="1" axis_ref="height" />
-      <field id="c17_cfad_lidarsr532" long_name="Lidar Scattering Ratio CFAD (532 nm)" unit="1" axis_ref="height" />
-      <field id="c18_cfad_lidarsr532" long_name="Lidar Scattering Ratio CFAD (532 nm)" unit="1" axis_ref="height" />
-      <field id="c19_cfad_lidarsr532" long_name="Lidar Scattering Ratio CFAD (532 nm)" unit="1" axis_ref="height" />
-      <field id="c20_cfad_lidarsr532" long_name="Lidar Scattering Ratio CFAD (532 nm)" unit="1" axis_ref="height" />
       <field id="c01_atb532" long_name="Lidar Attenuated Total Backscatter (532 nm)" unit="1" axis_ref="height_mlev" />
       <field id="c02_atb532" long_name="Lidar Attenuated Total Backscatter (532 nm)" unit="1" axis_ref="height_mlev" />
@@ -703,4 +698,44 @@
     </field_group>  
 
+    <field_group id="fields_COSP_CLOUDSAT" domain_ref="dom_glo" freq_op="3h">
+      <field id="cltlidarradar" long_name="Lidar and Radar Total Cloud Fraction" unit="%" />
+      <field id="clcalipso2"  long_name="CALIPSO Cloud Fraction Undetected by CloudSat" unit="%" axis_ref="height" />
+      <field id="c01_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c02_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c03_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c04_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c05_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c06_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c07_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c08_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c09_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c10_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c11_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c12_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c13_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c14_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c15_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c16_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c17_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c18_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c19_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c20_dbze94" long_name="CloudSat Radar Reflectivity" unit="1" axis_ref="height_mlev" />
+      <field id="c01_cfadDbze94" long_name="CloudSat Radar Reflectivity CFAD" unit="1" axis_ref="height" />
+      <field id="c02_cfadDbze94" long_name="CloudSat Radar Reflectivity CFAD" unit="1" axis_ref="height" />
+      <field id="c03_cfadDbze94" long_name="CloudSat Radar Reflectivity CFAD" unit="1" axis_ref="height" />
+      <field id="c04_cfadDbze94" long_name="CloudSat Radar Reflectivity CFAD" unit="1" axis_ref="height" />
+      <field id="c05_cfadDbze94" long_name="CloudSat Radar Reflectivity CFAD" unit="1" axis_ref="height" />
+      <field id="c06_cfadDbze94" long_name="CloudSat Radar Reflectivity CFAD" unit="1" axis_ref="height" />
+      <field id="c07_cfadDbze94" long_name="CloudSat Radar Reflectivity CFAD" unit="1" axis_ref="height" />
+      <field id="c08_cfadDbze94" long_name="CloudSat Radar Reflectivity CFAD" unit="1" axis_ref="height" />
+      <field id="c09_cfadDbze94" long_name="CloudSat Radar Reflectivity CFAD" unit="1" axis_ref="height" />
+      <field id="c10_cfadDbze94" long_name="CloudSat Radar Reflectivity CFAD" unit="1" axis_ref="height" />
+      <field id="c11_cfadDbze94" long_name="CloudSat Radar Reflectivity CFAD" unit="1" axis_ref="height" />
+      <field id="c12_cfadDbze94" long_name="CloudSat Radar Reflectivity CFAD" unit="1" axis_ref="height" />
+      <field id="c13_cfadDbze94" long_name="CloudSat Radar Reflectivity CFAD" unit="1" axis_ref="height" />
+      <field id="c14_cfadDbze94" long_name="CloudSat Radar Reflectivity CFAD" unit="1" axis_ref="height" />
+      <field id="c15_cfadDbze94" long_name="CloudSat Radar Reflectivity CFAD" unit="1" axis_ref="height" />
+    </field_group>
+
     <field_group id="fields_COSP_ISCCP" domain_ref="dom_glo" freq_op="3h">
       <field id="sunlit" long_name="1 for day points, 0 for nightime" unit="1" />
@@ -722,4 +757,14 @@
     </field_group>
 
+    <field_group id="fields_COSP_MISR" domain_ref="dom_glo" freq_op="3h">
+      <field id="c01_clMISR" long_name="Cloud Fraction as Calculated by the MISR Simulator" unit="1" axis_ref="cth16" />
+      <field id="c02_clMISR" long_name="Cloud Fraction as Calculated by the MISR Simulator" unit="1" axis_ref="cth16" />
+      <field id="c03_clMISR" long_name="Cloud Fraction as Calculated by the MISR Simulator" unit="1" axis_ref="cth16" />
+      <field id="c04_clMISR" long_name="Cloud Fraction as Calculated by the MISR Simulator" unit="1" axis_ref="cth16" />
+      <field id="c05_clMISR" long_name="Cloud Fraction as Calculated by the MISR Simulator" unit="1" axis_ref="cth16" />
+      <field id="c06_clMISR" long_name="Cloud Fraction as Calculated by the MISR Simulator" unit="1" axis_ref="cth16" />
+      <field id="c07_clMISR" long_name="Cloud Fraction as Calculated by the MISR Simulator" unit="1" axis_ref="cth16" />
+    </field_group>
+
 </field_definition>
 
Index: /LMDZ5/branches/testing/DefLists/file_def_histdayCOSP_lmdz.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/file_def_histdayCOSP_lmdz.xml	(revision 2470)
+++ /LMDZ5/branches/testing/DefLists/file_def_histdayCOSP_lmdz.xml	(revision 2471)
@@ -3,5 +3,5 @@
         <file id="histdayCOSP" name="histdayCOSP" output_freq="1d" output_level="1"  enabled=".TRUE.">
 
-            <!-- VARS 2D -->
+            <!-- VARS Calipso and PARASOL -->
             <field_group operation="average" freq_op="3h" detect_missing_value=".true.">
                 <field field_ref="cllcalipso"         level="1" />
@@ -32,24 +32,19 @@
                 <field field_ref="parasol_crefl"  level="1" axis_ref="sza" />
                 <field field_ref="Ncrefl"  level="1" axis_ref="sza" />
-		<field field_ref="c01_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c02_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c03_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c04_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c05_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c06_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c07_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c08_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c09_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c10_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c11_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c12_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c13_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c14_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c15_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c16_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c17_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c18_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c19_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c20_cfad_lidarsr532"  level="10" axis_ref="height" />
+       		    <field field_ref="c01_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c02_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c03_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c04_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c05_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c06_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c07_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c08_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c09_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c10_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c11_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c12_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c13_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c14_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c15_cfad_lidarsr532"  level="10" axis_ref="height" />
                 <field field_ref="c01_atb532" level="10" axis_ref="height_mlev" />
                 <field field_ref="c02_atb532" level="10" axis_ref="height_mlev" />
@@ -73,4 +68,47 @@
                 <field field_ref="c20_atb532" level="10" axis_ref="height_mlev" />
                 <field field_ref="beta_mol532" level="10" axis_ref="height_mlev" />
+              </field_group>
+             <!-- VARS CLOUDSAT et/ou Calipso -->
+            <field_group operation="average" freq_op="3h" detect_missing_value=".true."> 
+               <field field_ref="cltlidarradar"  level="1"/>
+               <field field_ref="clcalipso2"  level="1" axis_ref="height" />
+               <field field_ref="c01_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c02_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c03_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c04_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c05_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c06_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c07_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c08_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c09_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c10_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c11_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c12_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c13_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c14_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c15_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c01_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c02_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c03_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c04_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c05_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c06_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c07_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c08_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c09_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c10_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c11_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c12_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c13_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c14_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c15_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c16_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c17_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c18_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c19_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c20_dbze94" level="10" axis_ref="height_mlev" />
+              </field_group>
+             <!-- VARS ISCCP -->
+            <field_group operation="average" freq_op="3h" detect_missing_value=".true.">
                 <field field_ref="sunlit" level="1" />
                 <field field_ref="c01_clisccp2" level="1" axis_ref="pressure2" />
@@ -89,4 +127,14 @@
                 <field field_ref="meantbisccp" level="10" />
                 <field field_ref="meantbclrisccp" level="10" />
+             </field_group>
+             <!-- VARS MISR -->
+            <field_group operation="average" freq_op="3h" detect_missing_value=".true.">
+                <field field_ref="c01_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c02_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c03_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c04_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c05_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c06_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c07_clMISR" level="1" axis_ref="cth16" />
             </field_group>
 
Index: /LMDZ5/branches/testing/DefLists/file_def_histhfCOSP_lmdz.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/file_def_histhfCOSP_lmdz.xml	(revision 2470)
+++ /LMDZ5/branches/testing/DefLists/file_def_histhfCOSP_lmdz.xml	(revision 2471)
@@ -3,6 +3,6 @@
         <file id="histhfCOSP" name="XhisthfCOSP" output_freq="3h" output_level="1"  enabled=".TRUE.">
 
-            <!-- VARS 2D -->
-            <field_group operation="instant" freq_op="1ts">
+            <!-- VARS Calipso and PARASOL -->
+            <field_group operation="average" freq_op="3h" detect_missing_value=".true.">
                 <field field_ref="cllcalipso"         level="1" />
                 <field field_ref="clmcalipso"         level="1" />
@@ -32,24 +32,19 @@
                 <field field_ref="parasol_crefl"  level="1" axis_ref="sza" />
                 <field field_ref="Ncrefl"  level="1" axis_ref="sza" />
-		<field field_ref="c01_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c02_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c03_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c04_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c05_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c06_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c07_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c08_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c09_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c10_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c11_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c12_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c13_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c14_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c15_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c16_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c17_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c18_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c19_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c20_cfad_lidarsr532"  level="10" axis_ref="height" />
+       		    <field field_ref="c01_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c02_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c03_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c04_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c05_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c06_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c07_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c08_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c09_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c10_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c11_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c12_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c13_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c14_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c15_cfad_lidarsr532"  level="10" axis_ref="height" />
                 <field field_ref="c01_atb532" level="10" axis_ref="height_mlev" />
                 <field field_ref="c02_atb532" level="10" axis_ref="height_mlev" />
@@ -73,4 +68,47 @@
                 <field field_ref="c20_atb532" level="10" axis_ref="height_mlev" />
                 <field field_ref="beta_mol532" level="10" axis_ref="height_mlev" />
+              </field_group>
+             <!-- VARS CLOUDSAT et/ou Calipso -->
+            <field_group operation="average" freq_op="3h" detect_missing_value=".true."> 
+               <field field_ref="cltlidarradar"  level="1"/>
+               <field field_ref="clcalipso2"  level="1" axis_ref="height" />
+               <field field_ref="c01_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c02_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c03_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c04_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c05_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c06_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c07_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c08_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c09_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c10_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c11_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c12_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c13_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c14_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c15_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c01_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c02_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c03_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c04_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c05_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c06_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c07_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c08_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c09_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c10_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c11_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c12_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c13_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c14_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c15_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c16_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c17_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c18_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c19_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c20_dbze94" level="10" axis_ref="height_mlev" />
+              </field_group>
+             <!-- VARS ISCCP -->
+            <field_group operation="average" freq_op="3h" detect_missing_value=".true.">
                 <field field_ref="sunlit" level="1" />
                 <field field_ref="c01_clisccp2" level="1" axis_ref="pressure2" />
@@ -84,9 +122,19 @@
                 <field field_ref="boxptopisccp" level="10" axis_ref="column" />
                 <field field_ref="tclisccp" level="1" />
-                <field field_ref="ctpisccp" level="10" />
-                <field field_ref="tauisccp" level="10" /> 
-                <field field_ref="albisccp" level="10" />
+                <field field_ref="ctpisccp" level="1" />
+                <field field_ref="tauisccp" level="1" /> 
+                <field field_ref="albisccp" level="1" />
                 <field field_ref="meantbisccp" level="10" />
                 <field field_ref="meantbclrisccp" level="10" />
+             </field_group>
+             <!-- VARS MISR -->
+            <field_group operation="average" freq_op="3h" detect_missing_value=".true.">
+                <field field_ref="c01_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c02_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c03_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c04_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c05_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c06_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c07_clMISR" level="1" axis_ref="cth16" />
             </field_group>
 
Index: /LMDZ5/branches/testing/DefLists/file_def_histmthCOSP_lmdz.xml
===================================================================
--- /LMDZ5/branches/testing/DefLists/file_def_histmthCOSP_lmdz.xml	(revision 2470)
+++ /LMDZ5/branches/testing/DefLists/file_def_histmthCOSP_lmdz.xml	(revision 2471)
@@ -3,5 +3,5 @@
         <file id="histmthCOSP" name="histmthCOSP" output_freq="30d" output_level="1"  enabled=".TRUE.">
 
-            <!-- VARS 2D -->
+            <!-- VARS Calipso and PARASOL -->
             <field_group operation="average" freq_op="3h" detect_missing_value=".true.">
                 <field field_ref="cllcalipso"         level="1" />
@@ -32,24 +32,19 @@
                 <field field_ref="parasol_crefl"  level="1" axis_ref="sza" />
                 <field field_ref="Ncrefl"  level="1" axis_ref="sza" />
-		<field field_ref="c01_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c02_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c03_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c04_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c05_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c06_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c07_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c08_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c09_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c10_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c11_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c12_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c13_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c14_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c15_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c16_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c17_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c18_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c19_cfad_lidarsr532"  level="10" axis_ref="height" />
-		<field field_ref="c20_cfad_lidarsr532"  level="10" axis_ref="height" />
+       		    <field field_ref="c01_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c02_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c03_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c04_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c05_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c06_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c07_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c08_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c09_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c10_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c11_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c12_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c13_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c14_cfad_lidarsr532"  level="10" axis_ref="height" />
+		        <field field_ref="c15_cfad_lidarsr532"  level="10" axis_ref="height" />
                 <field field_ref="c01_atb532" level="10" axis_ref="height_mlev" />
                 <field field_ref="c02_atb532" level="10" axis_ref="height_mlev" />
@@ -73,4 +68,47 @@
                 <field field_ref="c20_atb532" level="10" axis_ref="height_mlev" />
                 <field field_ref="beta_mol532" level="10" axis_ref="height_mlev" />
+              </field_group>
+             <!-- VARS CLOUDSAT et/ou Calipso -->
+            <field_group operation="average" freq_op="3h" detect_missing_value=".true."> 
+               <field field_ref="cltlidarradar"  level="1"/>
+               <field field_ref="clcalipso2"  level="1" axis_ref="height" />
+               <field field_ref="c01_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c02_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c03_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c04_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c05_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c06_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c07_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c08_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c09_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c10_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c11_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c12_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c13_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c14_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c15_cfadDbze94"  level="10" axis_ref="height" />
+               <field field_ref="c01_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c02_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c03_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c04_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c05_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c06_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c07_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c08_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c09_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c10_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c11_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c12_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c13_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c14_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c15_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c16_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c17_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c18_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c19_dbze94" level="10" axis_ref="height_mlev" />
+               <field field_ref="c20_dbze94" level="10" axis_ref="height_mlev" />
+              </field_group>
+             <!-- VARS ISCCP -->
+            <field_group operation="average" freq_op="3h" detect_missing_value=".true.">
                 <field field_ref="sunlit" level="1" />
                 <field field_ref="c01_clisccp2" level="1" axis_ref="pressure2" />
@@ -89,4 +127,14 @@
                 <field field_ref="meantbisccp" level="10" />
                 <field field_ref="meantbclrisccp" level="10" />
+             </field_group>
+             <!-- VARS MISR -->
+            <field_group operation="average" freq_op="3h" detect_missing_value=".true.">
+                <field field_ref="c01_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c02_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c03_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c04_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c05_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c06_clMISR" level="1" axis_ref="cth16" />
+                <field field_ref="c07_clMISR" level="1" axis_ref="cth16" />
             </field_group>
 
Index: /LMDZ5/branches/testing/DefLists/gcm.def_144x142
===================================================================
--- /LMDZ5/branches/testing/DefLists/gcm.def_144x142	(revision 2471)
+++ /LMDZ5/branches/testing/DefLists/gcm.def_144x142	(revision 2471)
@@ -0,0 +1,58 @@
+## $Id: gcm.def 1403 2010-07-01 09:02:53Z fairhead $
+## nombre de pas par jour (multiple de iperiod) ( ici pour  dt = 1 min )      
+day_step=960
+## periode pour le pas Matsuno (en pas)
+iperiod=5
+## choix de l'operateur de dissipation (star ou  non star )
+lstardis=y
+## nombre d'iterations de l'operateur de dissipation   gradiv
+nitergdiv=1
+## nombre d'iterations de l'operateur de dissipation  nxgradrot
+nitergrot=2
+## nombre d'iterations de l'operateur de dissipation  divgrad            
+niterh=2
+## temps de dissipation des plus petites long.d ondes pour u,v (gradiv)  
+tetagdiv=1800.
+## temps de dissipation des plus petites long.d ondes pour u,v(nxgradrot)
+#tetagrot=5400.
+tetagrot=7200.
+## temps de dissipation des plus petites long.d ondes pour  h ( divgrad) 
+tetatemp=5400.
+## coefficient pour gamdissip                                            
+coefdis=0.
+## choix du shema d'integration temporelle (Matsuno:y ou Matsuno-leapfrog:n) 
+purmats=n
+## avec ou sans physique
+## 0: pas de physique (e.g. en mode Shallow Water)
+## 1: avec physique (e.g. physique phylmd)
+## 2: avec rappel newtonien dans la dynamique                                         
+iflag_phys=1
+## avec ou sans fichiers de demarrage (start.nc, startphy.nc) ?
+## (sans fichiers de demarrage, initialisation des champs par iniacademic
+##  dans la dynamique)
+read_start=y
+## periode de la physique (en pas dynamiques, n'a de sens que si iflag_phys=1)                                       
+iphysiq=_AUTO_ : DEFAULT = 5
+#
+#
+### Parametres du zoom
+## longitude en degres du centre du zoom                                 
+clon=0.
+## latitude en degres du centre du zoom                                  
+clat=0.
+## facteur de grossissement du zoom,selon longitude                      
+grossismx=1.0
+## facteur de grossissement du zoom ,selon latitude                      
+grossismy=1.0
+##  Fonction  f(y)  hyperbolique  si = .true.  , sinon  sinusoidale         
+fxyhypb=y
+## extension en longitude  de la zone du zoom  ( fraction de la zone totale)
+dzoomx=0.0
+## extension en latitude de la zone  du zoom  ( fraction de la zone totale)
+dzoomy=0.0
+##raideur du zoom en  X
+taux=3.
+##raideur du zoom en  Y
+tauy=3.
+##  Fonction  f(y) avec y = Sin(latit.) si = .true. , sinon y = latit.         
+ysinus=y
Index: /LMDZ5/branches/testing/DefLists/physiq.def_L79_NPv5.4
===================================================================
--- /LMDZ5/branches/testing/DefLists/physiq.def_L79_NPv5.4	(revision 2471)
+++ /LMDZ5/branches/testing/DefLists/physiq.def_L79_NPv5.4	(revision 2471)
@@ -0,0 +1,186 @@
+##############################################################################RAMETRES ET CLES DE LA PHYSIQUE LMDZ
+###############################################################################
+## D: Valeur par default
+##
+##Parametres Orographiques et cdrags
+##**********************************
+###   Si=.T. ,  lecture du fichier limit avec la bonne annee 
+ok_limitvrai=n
+iflag_albedo=1
+#Cdrags 
+f_cdrag_stable=1.
+f_cdrag_ter=1.
+f_cdrag_oce=0.7
+f_ri_cd_min=0.6
+#cdmmax
+cdmmax=2.5E-3
+#cdhmax
+cdhmax=2.0E-3
+##  Orodr  ou  non   pour l orographie
+ok_orodr=y
+##  Orolf  ou  non   pour l orographie              
+ok_orolf=y
+#Rugoro
+f_rugoro=0.
+#
+### Random gravity waves
+#Activitate the stochastic parameterization of convective GWs (should be equal to ok_strato)
+ok_gwd_rando=y
+# Scale the momentum fluxes due to convective GWs
+gwd_rando_ruwmax=2.5
+#Scale the saturated momentum flux of  convective GWs 
+gwd_rando_sat=0.2
+
+ok_strato=y
+ok_hines=n
+sso_gkdrag=0.2
+sso_gfrcri=0.70
+sso_gkwake=0.40
+#
+# Rayonnement
+#*********************
+# activation du nouveau code de rayonnement RRTM
+# 0 : Ancien code et 1 : RRTM (D=0)
+iflag_rrtm=0
+#NSW=2
+#
+# Parametres nuages
+#******************
+#seuils de la precipitation des nuages strateformes (D: 2.6e-4 2.6e-4)
+cld_lc_lsc=0.0001
+cld_lc_con=0.0001
+#constante de temps pour eleminer eau lsc et convective (D: 3600. 3600.)
+cld_tau_lsc=900.
+cld_tau_con=900.
+#facteurs correctifs sur la vitesse de chute des cristaux de glace (D: 1 1)
+ffallv_lsc=1.
+ffallv_con=1.
+#coefficient sur la reevaporation de la pluie (D: 2.e-5 n)
+coef_eva=2e-5
+reevap_ice=y
+#calcul des proprietes des nuages convectifs (D:1 0.375 1.e-4) 
+iflag_cldcon=6
+fact_cldcon=1.
+facttemps=0.
+#calcul eau condensee et fraction nuageuse a partir des PDF (D:0, 0:version avec ratqs sinon nouvelles PDFs)  
+iflag_pdf=1
+#calcul epaisseur optique et emmissivite des nuages (D: y 1 0.01 0.3)
+ok_newmicro=y
+iflag_ratqs=4
+ratqsbas=0.002
+ratqshaut=0.312
+#rayon effectif pour les nuages de glace (D:35)
+rad_froid=35
+#rayons effectifs pour les nuages eau liq (tailles des gouttes d eau nuageuse, D: 13 9)
+rad_chau1=12
+rad_chau2=11
+##  Choix ou non  de  New oliq               
+new_oliq=y
+#Rayons min et max effectifs des particules des nuages
+rei_min=16.
+rei_max=61.29
+#
+# Flags Convection 
+#*****************
+#Convection scheme switch (D:2, 1:LMD, 2:Tiedtke, 3:KE New Physics, 30:KE AR4)
+iflag_con=3
+#output level of energy conservation diagnostics
+if_ebil=0
+#maximum efficiency of cld water->precipitation conversion (D: 0.993)
+epmax=0.9995
+#dry convective adjustment at beginning of Emanuel convective scheme (D: n 0)
+ok_adj_ema=n
+iflag_clw=0
+#Convective closure (D:1, 0:AR4, 2:ALE and ALP)
+iflag_clos=2
+#Convective entrainment mixing law (D:1, 0:AR4=flat PDF, 1=PDF)
+iflag_mix=1
+#weights of the bell shaped and flat PDF (used only if iflag_mix=1) (D: 1 0)
+qqa1=1.
+qqa2=0.
+#Parameters of the bell shaped PDF; Fmax=center (D= 0.65), Gammas=width (D=0.05)
+cvl_corr=1.0
+#Multiplicative factor of Emanuel convective scheme precipitation (D: 1.)
+Fmax=0.65
+#
+# Flags Couche limite
+#********************
+#shema de CL des thermiques (D:0, 0:ajustement sec,=>1:versions thermiques) 
+iflag_thermals=18
+#pas de temps du spliting pour les thermiques
+nsplit_thermals=1
+tau_thermals=0.
+iflag_thermals_ed=8
+fact_thermals_ed_dz=0.1
+iflag_thermals_optflux=0
+#shema de la couche de surface (D:1, 1:LMD, 8:Mellor-Yamada) 
+iflag_pbl=11
+#diffusion turbulente
+ksta_ter=1.e-7
+ksta=1.e-10
+#ok_kzmin : calcul Kzmin dans la CL de surface
+ok_kzmin=y
+#couplage ou non avec la convection
+iflag_coupl=5 (0:AR4 et 1:nouvelle physique)
+seuil_inversion=-0.08
+#rendement sur la puissance fournie par les thermiques a la convection
+alp_bl_k=0.5
+#
+## temperature dependency of qsat for iterative procedure
+## temporary flag to switch between the old (CMIP5, D=0) and new versions (=1) versions 
+iflag_fisrtilp_qsat=4 
+## Reactivation du calcul d'un zmax continu pour les thermiques
+## reactivation d'une fermeture humide des thermiques  iflag_thermals_closure=2 (D=1)
+iflag_thermals_closure=1
+#
+# Flags wakes
+#************
+#Wake scheme switch (D:0, 0:AR4, 1:New Physics)
+iflag_wake=1
+#Constant value to be added to Alp (D: 0.)
+alp_offset=0.
+
+### nrlmd le 10/04/2012: Declenchement ###
+#Déclelenchement par couche-limite (0: deterministe, 1: stochastique)
+iflag_trig_bl=1
+#Surface critique au LCL
+s_trig=1.2e7
+#Temps de decorrelation entre scenes de cumulus
+tau_trig_shallow=1200
+#Temps de decorrelation entre scenes de cumulonimbus
+tau_trig_deep=1200
+# Pour la stabilisation
+random_notrig_max=0.99
+ok_adjwk=y
+tmax_fonte_cv=288.15
+
+
+### nrlmd le 10/04/2012: Fermeture ###
+#Fermeture par couche-limite (0: deterministe, 1: statistique, 2: statistique+convergence grande échelle)
+iflag_clos_bl=1
+### fin nrlmd le 10/04/2012
+
+## Modification de la plage de temperature pour la phase mixte liquide/glace des nuages
+## Controle par les t_glace_min/max, exposant_glace, iflag_t_glace (D=0)
+t_glace_min=233.13
+t_glace_max=273.13
+exposant_glace=1.
+iflag_t_glace=1
+iflag_ice_thermo=1
+
+#
+## The source terms of the TKE prognostic equation are diagnosed from tendencies (du, dv, dT) 
+## associated with subrgrid scaleamotions and treated as an additional heat source.
+## Controled by a key, iflag_ener_conserv (D=-1):
+## 0 : no conservation, -1 : old adhoc correction for kinetic E only (used for CMIP5) 
+## 1 : conservation, 101 : conversion from kinetic to heat only, 110 conversion from potential to heat only
+iflag_ener_conserv=1
+
+#Activation of corrections for water conservation (D: n). 
+##The default is n for compatibility with earlier versions.
+##generally it should be y.
+ok_conserv_q=y 
+
+### distribution sous-maille sur la verticale 
+iflag_cloudth_vert=1
+
Index: /LMDZ5/branches/testing/DefLists/physiq.def_NPv5.4
===================================================================
--- /LMDZ5/branches/testing/DefLists/physiq.def_NPv5.4	(revision 2471)
+++ /LMDZ5/branches/testing/DefLists/physiq.def_NPv5.4	(revision 2471)
@@ -0,0 +1,186 @@
+#
+# $Id$
+#
+#PARAMETRES ET CLES DE LA PHYSIQUE LMDZ
+###############################################################################
+## D: Valeur par default
+##
+##Parametres Orographiques et cdrags
+##**********************************
+###   Si=.T. ,  lecture du fichier limit avec la bonne annee 
+ok_limitvrai=n
+iflag_albedo=1
+#Cdrags 
+f_cdrag_stable=1.
+f_cdrag_ter=1.
+f_cdrag_oce=0.7
+f_ri_cd_min=0.6
+#cdmmax
+cdmmax=2.5E-3
+#cdhmax
+cdhmax=2.0E-3
+##  Orodr  ou  non   pour l orographie
+ok_orodr=y
+##  Orolf  ou  non   pour l orographie              
+ok_orolf=y
+#Rugoro
+f_rugoro=0.
+#
+### Random gravity waves
+#Activitate the stochastic parameterization of convective GWs (should be equal to ok_strato)
+ok_gwd_rando=y
+# Scale the momentum fluxes due to convective GWs
+gwd_rando_ruwmax=2.5
+#Scale the saturated momentum flux of  convective GWs 
+gwd_rando_sat=0.2
+sso_gkdrag=0.2
+sso_gfrcri=0.70
+sso_gkwake=0.40
+#
+# Rayonnement
+#*********************
+# activation du nouveau code de rayonnement RRTM
+# 0 : Ancien code et 1 : RRTM (D=0)
+iflag_rrtm=0
+#NSW=2
+#
+# Parametres nuages
+#******************
+#seuils de la precipitation des nuages strateformes (D: 2.6e-4 2.6e-4)
+cld_lc_lsc=0.0001
+cld_lc_con=0.0001
+#constante de temps pour eleminer eau lsc et convective (D: 3600. 3600.)
+cld_tau_lsc=900.
+cld_tau_con=900.
+#facteurs correctifs sur la vitesse de chute des cristaux de glace (D: 1 1)
+ffallv_lsc=1.
+ffallv_con=1.
+#coefficient sur la reevaporation de la pluie (D: 2.e-5 n)
+coef_eva=2e-5
+reevap_ice=y
+#calcul des proprietes des nuages convectifs (D:1 0.375 1.e-4) 
+iflag_cldcon=6
+fact_cldcon=1.
+facttemps=0.
+#calcul eau condensee et fraction nuageuse a partir des PDF (D:0, 0:version avec ratqs sinon nouvelles PDFs)  
+iflag_pdf=1
+#calcul epaisseur optique et emmissivite des nuages (D: y 1 0.01 0.3)
+ok_newmicro=y
+iflag_ratqs=4
+ratqsbas=0.002
+ratqshaut=0.312
+#rayon effectif pour les nuages de glace (D:35)
+rad_froid=35
+#rayons effectifs pour les nuages eau liq (tailles des gouttes d eau nuageuse, D: 13 9)
+rad_chau1=12
+rad_chau2=11
+##  Choix ou non  de  New oliq               
+new_oliq=y
+#Rayons min et max effectifs des particules des nuages
+rei_min=16.
+rei_max=61.29
+#
+# Flags Convection 
+#*****************
+#Convection scheme switch (D:2, 1:LMD, 2:Tiedtke, 3:KE New Physics, 30:KE AR4)
+iflag_con=3
+#output level of energy conservation diagnostics
+if_ebil=0
+#maximum efficiency of cld water->precipitation conversion (D: 0.993)
+epmax=0.9995
+#dry convective adjustment at beginning of Emanuel convective scheme (D: n 0)
+ok_adj_ema=n
+iflag_clw=0
+#Convective closure (D:1, 0:AR4, 2:ALE and ALP)
+iflag_clos=2
+#Convective entrainment mixing law (D:1, 0:AR4=flat PDF, 1=PDF)
+iflag_mix=1
+#weights of the bell shaped and flat PDF (used only if iflag_mix=1) (D: 1 0)
+qqa1=1.
+qqa2=0.
+#Parameters of the bell shaped PDF; Fmax=center (D= 0.65), Gammas=width (D=0.05)
+cvl_corr=1.0
+#Multiplicative factor of Emanuel convective scheme precipitation (D: 1.)
+Fmax=0.65
+#
+# Flags Couche limite
+#********************
+#shema de CL des thermiques (D:0, 0:ajustement sec,=>1:versions thermiques) 
+iflag_thermals=18
+#pas de temps du spliting pour les thermiques
+nsplit_thermals=1
+tau_thermals=0.
+iflag_thermals_ed=8
+fact_thermals_ed_dz=0.1
+iflag_thermals_optflux=0
+#shema de la couche de surface (D:1, 1:LMD, 8:Mellor-Yamada) 
+iflag_pbl=11
+#diffusion turbulente
+ksta_ter=1.e-7
+ksta=1.e-10
+#ok_kzmin : calcul Kzmin dans la CL de surface
+ok_kzmin=y
+#couplage ou non avec la convection
+iflag_coupl=5 (0:AR4 et 1:nouvelle physique)
+seuil_inversion=-0.08
+#rendement sur la puissance fournie par les thermiques a la convection
+alp_bl_k=0.5
+#
+## temperature dependency of qsat for iterative procedure
+## temporary flag to switch between the old (CMIP5, D=0) and new versions (=1) versions 
+iflag_fisrtilp_qsat=4 
+## Reactivation du calcul d'un zmax continu pour les thermiques
+## reactivation d'une fermeture humide des thermiques  iflag_thermals_closure=2 (D=1)
+iflag_thermals_closure=1
+#
+# Flags wakes
+#************
+#Wake scheme switch (D:0, 0:AR4, 1:New Physics)
+iflag_wake=1
+#Constant value to be added to Alp (D: 0.)
+alp_offset=0.
+
+### nrlmd le 10/04/2012: Declenchement ###
+#Déclelenchement par couche-limite (0: deterministe, 1: stochastique)
+iflag_trig_bl=1
+#Surface critique au LCL
+s_trig=1.2e7
+#Temps de decorrelation entre scenes de cumulus
+tau_trig_shallow=1200
+#Temps de decorrelation entre scenes de cumulonimbus
+tau_trig_deep=1200
+# Pour la stabilisation
+random_notrig_max=0.99
+ok_adjwk=y
+tmax_fonte_cv=288.15
+
+
+### nrlmd le 10/04/2012: Fermeture ###
+#Fermeture par couche-limite (0: deterministe, 1: statistique, 2: statistique+convergence grande échelle)
+iflag_clos_bl=1
+### fin nrlmd le 10/04/2012
+
+## Modification de la plage de temperature pour la phase mixte liquide/glace des nuages
+## Controle par les t_glace_min/max, exposant_glace, iflag_t_glace (D=0)
+t_glace_min=233.13
+t_glace_max=273.13
+exposant_glace=1.
+iflag_t_glace=1
+iflag_ice_thermo=1
+
+#
+## The source terms of the TKE prognostic equation are diagnosed from tendencies (du, dv, dT) 
+## associated with subrgrid scaleamotions and treated as an additional heat source.
+## Controled by a key, iflag_ener_conserv (D=-1):
+## 0 : no conservation, -1 : old adhoc correction for kinetic E only (used for CMIP5) 
+## 1 : conservation, 101 : conversion from kinetic to heat only, 110 conversion from potential to heat only
+iflag_ener_conserv=1
+
+#Activation of corrections for water conservation (D: n). 
+##The default is n for compatibility with earlier versions.
+##generally it should be y.
+ok_conserv_q=y 
+
+### distribution sous-maille sur la verticale 
+iflag_cloudth_vert=1
+
Index: /LMDZ5/branches/testing/DefLists/vert_L79.def
===================================================================
--- /LMDZ5/branches/testing/DefLists/vert_L79.def	(revision 2471)
+++ /LMDZ5/branches/testing/DefLists/vert_L79.def	(revision 2471)
@@ -0,0 +1,40 @@
+#
+# $Id$
+#
+#### Verticale discretisation
+## Modified verticale discretisation for stratospheric versions.
+## The new version can be controled by following parameters
+## Al the parameters are given in km assuming a given scalehigh
+vert_sampling=strato_custom
+## scale hight
+vert_scale=7.
+## width of first layer
+vert_dzmin=0.017
+## dz in the low atmosphere
+vert_dzlow=1.
+## height at which resolution recches dzlow
+vert_z0low=8.7
+## dz in the mid atmsophere
+vert_dzmid=2.
+## height at which resolution recches dzmid
+vert_z0mid=70.
+## width of the transition
+vert_h_mid=20.
+## dz in the high atmsophere
+vert_dzhig=11.
+## height at which resolution recches dz
+vert_z0hig=75.
+## width of the transition
+vert_h_hig=20.
+## vert_prof_dissip used to choose the vertical profile
+## of horizontal dissipation (values are 0 and 1)
+vert_prof_dissip = 1
+dissip_zref = 50
+##  Avec ou sans strato
+ok_strato=y
+ok_hines=y
+#  Couche eponge dans les couches de pression plus faible que 100 fois la pression de la derniere couche
+iflag_top_bound=2
+#  Coefficient pour la couche eponge (valeur derniere couche)
+tau_top_bound=5.e-4
+#
Index: /LMDZ5/branches/testing/arch/arch-X64_ADA.fcm
===================================================================
--- /LMDZ5/branches/testing/arch/arch-X64_ADA.fcm	(revision 2470)
+++ /LMDZ5/branches/testing/arch/arch-X64_ADA.fcm	(revision 2471)
@@ -8,5 +8,5 @@
 %PROD_FFLAGS         -O2 -ip -fp-model strict -axAVX,SSE4.2
 %DEV_FFLAGS          -p -g -O0 -fpe0 -traceback
-%DEBUG_FFLAGS        -p -g -O0 -fpe-all=0 -traceback -ftrapuv -fp-stack-check -check all -debug
+%DEBUG_FFLAGS        -p -g -O0 -fpe-all=0 -traceback -ftrapuv -fp-stack-check -check bounds,format,output_conversion,pointers,uninit -debug
 #%DEBUG_FFLAGS        -p -g -O0 -fpe-all=0 -traceback -ftrapuv -fp-stack-check -debug
 %MPI_FFLAGS
Index: /LMDZ5/branches/testing/arch/arch-X64_OCCIGEN.fcm
===================================================================
--- /LMDZ5/branches/testing/arch/arch-X64_OCCIGEN.fcm	(revision 2470)
+++ /LMDZ5/branches/testing/arch/arch-X64_OCCIGEN.fcm	(revision 2471)
@@ -8,5 +8,5 @@
 %PROD_FFLAGS         -O2 -ip
 %DEV_FFLAGS          -p -g -O1 -fpe0 -traceback
-%DEBUG_FFLAGS        -p -g -O0 -fpe-all=0 -ftz -ftrapuv -fp-stack-check -check all -debug -traceback
+%DEBUG_FFLAGS        -p -g -O0 -fpe-all=0 -ftz -ftrapuv -fp-stack-check -check bounds,format,output_conversion,pointers,uninit -debug -traceback
 %MPI_FFLAGS
 %OMP_FFLAGS          -openmp -openmp-threadprivate compat
Index: /LMDZ5/branches/testing/arch/arch-gfortran_CICLAD.path
===================================================================
--- /LMDZ5/branches/testing/arch/arch-gfortran_CICLAD.path	(revision 2470)
+++ /LMDZ5/branches/testing/arch/arch-gfortran_CICLAD.path	(revision 2471)
@@ -7,4 +7,6 @@
 OASIS_INCDIR=$LMDGCM/../../prism/SX/build/lib/psmile.$couple
 OASIS_LIBDIR=$LMDGCM/../../prism/SX/lib
-INCA_LIBDIR=$LMDGCM/../INCA3/config/lib
-INCA_INCDIR=$LMDGCM/../INCA3/config/lib
+INCA_LIBDIR=$LMDGCM/../INCA/config/lib
+INCA_INCDIR=$LMDGCM/../INCA/config/lib
+XIOS_INCDIR=$LMDGCM/../XIOS/inc
+XIOS_LIBDIR=$LMDGCM/../XIOS/lib
Index: /LMDZ5/branches/testing/arch/arch-ifort_CICLAD.fcm
===================================================================
--- /LMDZ5/branches/testing/arch/arch-ifort_CICLAD.fcm	(revision 2470)
+++ /LMDZ5/branches/testing/arch/arch-ifort_CICLAD.fcm	(revision 2471)
@@ -8,5 +8,5 @@
 %PROD_FFLAGS         -O2 -ip
 %DEV_FFLAGS          -p -g -O1 -fpe0 -traceback
-%DEBUG_FFLAGS        -p -g -O0 -fpe-all=0 -traceback -ftrapuv -fp-stack-check -check all -debug
+%DEBUG_FFLAGS        -p -g -O0 -fpe-all=0 -traceback -ftrapuv -fp-stack-check -check bounds,format,output_conversion,pointers,uninit -debug
 %MPI_FFLAGS          -I/usr/lib64/openmpi/1.4.5-ifort/include
 %OMP_FFLAGS          -openmp
Index: /LMDZ5/branches/testing/arch/arch-ifort_CICLAD.path
===================================================================
--- /LMDZ5/branches/testing/arch/arch-ifort_CICLAD.path	(revision 2470)
+++ /LMDZ5/branches/testing/arch/arch-ifort_CICLAD.path	(revision 2471)
@@ -7,4 +7,6 @@
 OASIS_INCDIR=$LMDGCM/../../prism/SX/build/lib/psmile.$couple
 OASIS_LIBDIR=$LMDGCM/../../prism/SX/lib
-INCA_LIBDIR=$LMDGCM/../INCA3/config/lib
-INCA_INCDIR=$LMDGCM/../INCA3/config/lib
+INCA_LIBDIR=$LMDGCM/../INCA/config/lib
+INCA_INCDIR=$LMDGCM/../INCA/config/lib
+XIOS_INCDIR=$LMDGCM/../XIOS/inc
+XIOS_LIBDIR=$LMDGCM/../XIOS/lib
Index: /LMDZ5/branches/testing/libf/dyn3d/conf_gcm.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d/conf_gcm.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/dyn3d/conf_gcm.F90	(revision 2471)
@@ -297,4 +297,9 @@
   CALL getin('dissip_deltaz',dissip_deltaz )
   CALL getin('dissip_zref',dissip_zref )
+
+  ! ngroup
+  ngroup=3
+  CALL getin('ngroup',ngroup)
+
 
   ! top_bound sponge: only active if ok_strato=.true. and iflag_top_bound!=0
Index: /LMDZ5/branches/testing/libf/dyn3d/gcm.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d/gcm.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/dyn3d/gcm.F90	(revision 2471)
@@ -157,6 +157,6 @@
   use_filtre_fft=.FALSE.
   CALL getin('use_filtre_fft',use_filtre_fft)
-  IF (use_filtre_fft) call abort_gcm('FFT filter is not available in the ' &
-          // 'sequential version of the dynamics.', 1)
+  IF (use_filtre_fft) call abort_gcm("gcm", 'FFT filter is not available in ' &
+          // 'the sequential version of the dynamics.', 1)
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Index: /LMDZ5/branches/testing/libf/dyn3d/groupe.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d/groupe.F	(revision 2470)
+++ /LMDZ5/branches/testing/libf/dyn3d/groupe.F	(revision 2471)
@@ -22,6 +22,6 @@
 #include "comvert.h"
 
-      integer ngroup
-      parameter (ngroup=3)
+!     integer ngroup
+!     parameter (ngroup=3)
 
 
Index: /LMDZ5/branches/testing/libf/dyn3d/groupeun.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d/groupeun.F	(revision 2470)
+++ /LMDZ5/branches/testing/libf/dyn3d/groupeun.F	(revision 2471)
@@ -13,6 +13,6 @@
       REAL q(iip1,jjmax,llmax)
 
-      INTEGER ngroup
-      PARAMETER (ngroup=3)
+!     INTEGER ngroup
+!     PARAMETER (ngroup=3)
 
       REAL airecn,qn
@@ -37,7 +37,7 @@
 
       LOGICAL, SAVE :: first = .TRUE.
-      INTEGER,SAVE :: i_index(iim,ngroup)
+!     INTEGER,SAVE :: i_index(iim,ngroup)
       INTEGER      :: offset
-      REAL         :: qsum(iim/ngroup)
+!     REAL         :: qsum(iim/ngroup)
 
       IF (first) THEN
@@ -142,6 +142,6 @@
 #include "comgeom2.h"
 
-      INTEGER ngroup
-      PARAMETER (ngroup=3)
+!     INTEGER ngroup
+!     PARAMETER (ngroup=3)
 
       REAL airen,airecn
Index: /LMDZ5/branches/testing/libf/dyn3d_common/comconst.h
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3d_common/comconst.h	(revision 2470)
+++ /LMDZ5/branches/testing/libf/dyn3d_common/comconst.h	(revision 2471)
@@ -6,5 +6,5 @@
 
       COMMON/comconsti/im,jm,lllm,imp1,jmp1,lllmm1,lllmp1,lcl,          &
-     &                 iflag_top_bound,mode_top_bound
+     &                 iflag_top_bound,mode_top_bound,ngroup
       COMMON/comconstr/dtvr,daysec,                                     &
      & pi,dtphys,dtdiss,rad,r,cpp,kappa,cotot,unsim,g,omeg              &
@@ -32,4 +32,5 @@
 ! top_bound sponge:
       INTEGER iflag_top_bound ! sponge type
+      INTEGER ngroup
       INTEGER mode_top_bound  ! sponge mode
       REAL tau_top_bound ! inverse of sponge characteristic time scale (Hz)
Index: /LMDZ5/branches/testing/libf/dyn3dmem/conf_gcm.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dmem/conf_gcm.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/dyn3dmem/conf_gcm.F90	(revision 2471)
@@ -326,4 +326,9 @@
   CALL getin('dissip_zref',dissip_zref )
 
+  ! ngroup
+  ngroup=3
+  CALL getin('ngroup',ngroup)
+
+  ! mode_top_bound : fields towards which sponge relaxation will be done:
   ! top_bound sponge: only active if ok_strato=.true. and iflag_top_bound!=0
   !                   iflag_top_bound=0 for no sponge
@@ -857,19 +862,18 @@
 
      !Config  Key  = use_filtre_fft
-     !Config  Desc = flag d'activation des FFT pour le filtre
+     !Config  Desc = flag to activate FFTs for the filter
      !Config  Def  = false
-     !Config  Help = permet d'activer l'utilisation des FFT pour effectuer
-     !Config         le filtrage aux poles.
+     !Config  Help = enables to use FFts to do the longitudinal polar 
+     !Config         filtering around the poles.
      use_filtre_fft=.FALSE.
      CALL getin('use_filtre_fft',use_filtre_fft)
-     use_filtre_fft_loc=use_filtre_fft
-
      IF (use_filtre_fft .AND. grossismx /= 1.0) THEN
         write(lunout,*)'WARNING !!! '
-        write(lunout,*)"Le zoom en longitude est incompatible", &
-             " avec l'utilisation du filtre FFT ", &
-             "---> FFT filter not active"
+        write(lunout,*)"A zoom in longitude is not compatible", &
+             " with the FFT filter ", &
+             "---> FFT filter deactivated"
         use_filtre_fft=.FALSE.
      ENDIF
+     use_filtre_fft_loc=use_filtre_fft
 
      !Config  Key  = use_mpi_alloc
Index: /LMDZ5/branches/testing/libf/dyn3dmem/groupe_loc.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dmem/groupe_loc.F	(revision 2470)
+++ /LMDZ5/branches/testing/libf/dyn3dmem/groupe_loc.F	(revision 2471)
@@ -22,6 +22,6 @@
 #include "comvert.h"
 
-      integer ngroup
-      parameter (ngroup=3)
+!     integer ngroup
+!     parameter (ngroup=3)
 
 
Index: /LMDZ5/branches/testing/libf/dyn3dmem/groupeun_loc.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dmem/groupeun_loc.F	(revision 2470)
+++ /LMDZ5/branches/testing/libf/dyn3dmem/groupeun_loc.F	(revision 2471)
@@ -12,6 +12,6 @@
       REAL q(iip1,sb:se,llmax)
 
-      INTEGER ngroup
-      PARAMETER (ngroup=3)
+!     INTEGER ngroup
+!     PARAMETER (ngroup=3)
 
       REAL airecn,qn
@@ -38,7 +38,7 @@
       LOGICAL, SAVE :: first = .TRUE.
 !$OMP THREADPRIVATE(first)
-      INTEGER,SAVE :: i_index(iim,ngroup)
+!     INTEGER,SAVE :: i_index(iim,ngroup)
       INTEGER      :: offset
-      REAL         :: qsum(iim/ngroup)
+!     REAL         :: qsum(iim/ngroup)
 
       IF (first) THEN
@@ -143,6 +143,6 @@
 #include "comgeom2.h"
 
-      INTEGER ngroup
-      PARAMETER (ngroup=3)
+!     INTEGER ngroup
+!     PARAMETER (ngroup=3)
 
       REAL airen,airecn
Index: /LMDZ5/branches/testing/libf/dyn3dmem/mod_hallo.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dmem/mod_hallo.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/dyn3dmem/mod_hallo.F90	(revision 2471)
@@ -46,17 +46,21 @@
 
   INTERFACE Register_SwapField_u
-    MODULE PROCEDURE Register_SwapField1d_u,Register_SwapField2d_u1d,Register_SwapField3d_u
+    MODULE PROCEDURE Register_SwapField1d_u,Register_SwapField2d_u1d,Register_SwapField3d_u, &
+                     Register_SwapField1d_u_bis,Register_SwapField2d_u1d_bis,Register_SwapField3d_u_bis
   END INTERFACE Register_SwapField_u
 
   INTERFACE Register_SwapField_v
-    MODULE PROCEDURE Register_SwapField1d_v,Register_SwapField2d_v1d,Register_SwapField3d_v
+    MODULE PROCEDURE Register_SwapField1d_v,Register_SwapField2d_v1d,Register_SwapField3d_v,&
+                     Register_SwapField1d_v_bis,Register_SwapField2d_v1d_bis,Register_SwapField3d_v_bis
   END INTERFACE Register_SwapField_v
 
   INTERFACE Register_SwapField2d_u
-    MODULE PROCEDURE Register_SwapField1d_u2d,Register_SwapField2d_u2d,Register_SwapField3d_u2d
+    MODULE PROCEDURE Register_SwapField1d_u2d,Register_SwapField2d_u2d,Register_SwapField3d_u2d, &
+                     Register_SwapField1d_u2d_bis,Register_SwapField2d_u2d_bis,Register_SwapField3d_u2d_bis
   END INTERFACE Register_SwapField2d_u
 
   INTERFACE Register_SwapField2d_v
-    MODULE PROCEDURE Register_SwapField1d_v2d,Register_SwapField2d_v2d,Register_SwapField3d_v2d
+    MODULE PROCEDURE Register_SwapField1d_v2d,Register_SwapField2d_v2d,Register_SwapField3d_v2d, &
+                     Register_SwapField1d_v2d_bis,Register_SwapField2d_v2d_bis,Register_SwapField3d_v2d_bis
   END INTERFACE Register_SwapField2d_v
 
@@ -352,44 +356,64 @@
 
 
-  SUBROUTINE Register_SwapField1d_u(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
-  USE parallel_lmdz
-  USE dimensions_mod
-      IMPLICIT NONE
-    
-    REAL, DIMENSION(:),INTENT(IN)     :: FieldS
-    REAL, DIMENSION(:),INTENT(OUT)    :: FieldR
-    TYPE(distrib),OPTIONAL,INTENT(IN) :: old_dist
+  SUBROUTINE Register_SwapField1d_u(FieldS,FieldR,new_dist,a_request,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+    
     TYPE(distrib),INTENT(IN)          :: new_dist
-    INTEGER,OPTIONAL,INTENT(IN)       :: up
-    INTEGER,OPTIONAL,INTENT(IN)       :: down      
-    TYPE(request),INTENT(INOUT)         :: a_request
-
-    INTEGER                           :: halo_up
-    INTEGER                           :: halo_down
-    
-    
-    halo_up=0
-    halo_down=0
-    IF (PRESENT(up))   halo_up=up
-    IF (PRESENT(down)) halo_down=down
-
-    IF (PRESENT(old_dist)) THEN
-      CALL  Register_SwapField_gen_u(FieldS,FieldR,1,old_dist,new_dist,halo_up,halo_down,a_request)
-    ELSE
-      CALL  Register_SwapField_gen_u(FieldS,FieldR,1,current_dist,new_dist,halo_up,halo_down,a_request)
-    ENDIF
+    REAL, DIMENSION(current_dist%ijb_u:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%ijb_u:),INTENT(OUT)    :: FieldR
+    INTEGER,OPTIONAL,INTENT(IN)       :: up
+    INTEGER,OPTIONAL,INTENT(IN)       :: down      
+    TYPE(request),INTENT(INOUT)         :: a_request
+
+    INTEGER                           :: halo_up
+    INTEGER                           :: halo_down
+    
+    
+    halo_up=0
+    halo_down=0
+    IF (PRESENT(up))   halo_up=up
+    IF (PRESENT(down)) halo_down=down
+
+    CALL  Register_SwapField_gen_u(FieldS,FieldR,1,current_dist,new_dist,halo_up,halo_down,a_request)
         
   END SUBROUTINE  Register_SwapField1d_u 
 
-
-  SUBROUTINE Register_SwapField2d_u1d(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
+  SUBROUTINE Register_SwapField1d_u_bis(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+    
+    TYPE(distrib),INTENT(IN)          :: new_dist
+    TYPE(distrib),INTENT(IN)          :: old_dist
+    REAL, DIMENSION(old_dist%ijb_u:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%ijb_u:),INTENT(OUT)    :: FieldR
+    INTEGER,OPTIONAL,INTENT(IN)       :: up
+    INTEGER,OPTIONAL,INTENT(IN)       :: down      
+    TYPE(request),INTENT(INOUT)         :: a_request
+
+    INTEGER                           :: halo_up
+    INTEGER                           :: halo_down
+    
+    
+    halo_up=0
+    halo_down=0
+    IF (PRESENT(up))   halo_up=up
+    IF (PRESENT(down)) halo_down=down
+
+    CALL  Register_SwapField_gen_u(FieldS,FieldR,1,old_dist,new_dist,halo_up,halo_down,a_request)
+        
+  END SUBROUTINE  Register_SwapField1d_u_bis 
+
+
+  SUBROUTINE Register_SwapField2d_u1d(FieldS,FieldR,new_dist,a_request,up,down)
   USE parallel_lmdz
   USE dimensions_mod
     IMPLICIT NONE
     
-    REAL, DIMENSION(:,:),INTENT(IN)     :: FieldS
-    REAL, DIMENSION(:,:),INTENT(OUT)    :: FieldR
-    TYPE(distrib),OPTIONAL,INTENT(IN) :: old_dist
     TYPE(distrib),INTENT(IN)          :: new_dist
+    REAL, DIMENSION(current_dist%ijb_u:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%ijb_u:,:),INTENT(OUT)    :: FieldR
     INTEGER,OPTIONAL,INTENT(IN)       :: up
     INTEGER,OPTIONAL,INTENT(IN)       :: down      
@@ -408,22 +432,17 @@
     ll=size(FieldS,2)
     
-    IF (PRESENT(old_dist)) THEN
-      CALL  Register_SwapField_gen_u(FieldS,FieldR,ll,old_dist,new_dist,halo_up,halo_down,a_request)
-    ELSE
-      CALL  Register_SwapField_gen_u(FieldS,FieldR,ll,current_dist,new_dist,halo_up,halo_down,a_request)
-    ENDIF
+    CALL  Register_SwapField_gen_u(FieldS,FieldR,ll,current_dist,new_dist,halo_up,halo_down,a_request)
     
   END SUBROUTINE  Register_SwapField2d_u1d
-   
-
-  SUBROUTINE Register_SwapField3d_u(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
-  USE parallel_lmdz
-  USE dimensions_mod
-      IMPLICIT NONE
-    
-    REAL, DIMENSION(:,:,:),INTENT(IN)     :: FieldS
-    REAL, DIMENSION(:,:,:),INTENT(OUT)    :: FieldR
-    TYPE(distrib),OPTIONAL,INTENT(IN) :: old_dist
+
+  SUBROUTINE Register_SwapField2d_u1d_bis(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+    IMPLICIT NONE
+    
     TYPE(distrib),INTENT(IN)          :: new_dist
+    TYPE(distrib),INTENT(IN) :: old_dist
+    REAL, DIMENSION(old_dist%ijb_u:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%ijb_u:,:),INTENT(OUT)    :: FieldR
     INTEGER,OPTIONAL,INTENT(IN)       :: up
     INTEGER,OPTIONAL,INTENT(IN)       :: down      
@@ -440,58 +459,133 @@
     IF (PRESENT(down)) halo_down=down
     
+    ll=size(FieldS,2)
+    
+    CALL  Register_SwapField_gen_u(FieldS,FieldR,ll,old_dist,new_dist,halo_up,halo_down,a_request)
+    
+  END SUBROUTINE  Register_SwapField2d_u1d_bis
+   
+
+  SUBROUTINE Register_SwapField3d_u(FieldS,FieldR,new_dist,a_request,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+    
+    TYPE(distrib),INTENT(IN)          :: new_dist
+    REAL, DIMENSION(current_dist%ijb_u:,:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%ijb_u:,:,:),INTENT(OUT)    :: FieldR
+    INTEGER,OPTIONAL,INTENT(IN)       :: up
+    INTEGER,OPTIONAL,INTENT(IN)       :: down      
+    TYPE(request),INTENT(INOUT)         :: a_request
+
+    INTEGER                           :: halo_up
+    INTEGER                           :: halo_down
+    INTEGER                           :: ll
+        
+    
+    halo_up=0
+    halo_down=0
+    IF (PRESENT(up))   halo_up=up
+    IF (PRESENT(down)) halo_down=down
+    
     ll=size(FieldS,2)*size(FieldS,3)
     
-    IF (PRESENT(old_dist)) THEN
-      CALL  Register_SwapField_gen_u(FieldS,FieldR,ll,old_dist,new_dist,halo_up,halo_down,a_request)
-    ELSE
-      CALL  Register_SwapField_gen_u(FieldS,FieldR,ll,current_dist,new_dist,halo_up,halo_down,a_request)
-    ENDIF
+    CALL  Register_SwapField_gen_u(FieldS,FieldR,ll,current_dist,new_dist,halo_up,halo_down,a_request)
     
   END SUBROUTINE  Register_SwapField3d_u 
-  
-
-
- SUBROUTINE Register_SwapField1d_u2d(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
-  USE parallel_lmdz
-  USE dimensions_mod
-
-      IMPLICIT NONE
-    
-    REAL, DIMENSION(:,:),INTENT(IN)     :: FieldS
-    REAL, DIMENSION(:,:),INTENT(OUT)    :: FieldR
-    TYPE(distrib),OPTIONAL,INTENT(IN) :: old_dist
-    TYPE(distrib),OPTIONAL,INTENT(IN)          :: new_dist !LF
-    INTEGER,OPTIONAL,INTENT(IN)       :: up
-    INTEGER,OPTIONAL,INTENT(IN)       :: down      
-    TYPE(request),INTENT(INOUT)         :: a_request
-
-    INTEGER                           :: halo_up
-    INTEGER                           :: halo_down
-    
-    
-    halo_up=0
-    halo_down=0
-    IF (PRESENT(up))   halo_up=up
-    IF (PRESENT(down)) halo_down=down
-
-    IF (PRESENT(old_dist)) THEN
-      CALL  Register_SwapField_gen_u(FieldS,FieldR,1,old_dist,new_dist,halo_up,halo_down,a_request)
-    ELSE
-      CALL  Register_SwapField_gen_u(FieldS,FieldR,1,current_dist,new_dist,halo_up,halo_down,a_request)
-    ENDIF
+
+  SUBROUTINE Register_SwapField3d_u_bis(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+    
+    TYPE(distrib),INTENT(IN)          :: new_dist
+    TYPE(distrib),INTENT(IN) :: old_dist
+    REAL, DIMENSION(old_dist%ijb_u:,:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%ijb_u:,:,:),INTENT(OUT)    :: FieldR
+    INTEGER,OPTIONAL,INTENT(IN)       :: up
+    INTEGER,OPTIONAL,INTENT(IN)       :: down      
+    TYPE(request),INTENT(INOUT)         :: a_request
+
+    INTEGER                           :: halo_up
+    INTEGER                           :: halo_down
+    INTEGER                           :: ll
+        
+    
+    halo_up=0
+    halo_down=0
+    IF (PRESENT(up))   halo_up=up
+    IF (PRESENT(down)) halo_down=down
+    
+    ll=size(FieldS,2)*size(FieldS,3)
+    
+    CALL  Register_SwapField_gen_u(FieldS,FieldR,ll,old_dist,new_dist,halo_up,halo_down,a_request)
+    
+  END SUBROUTINE  Register_SwapField3d_u_bis 
+  
+
+
+ SUBROUTINE Register_SwapField1d_u2d(FieldS,FieldR,new_dist,a_request,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+
+      IMPLICIT NONE
+
+    TYPE(distrib),INTENT(IN)          :: new_dist !LF
+    REAL, DIMENSION(current_dist%jjb_u:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%jjb_u:,:),INTENT(OUT)    :: FieldR
+    INTEGER,OPTIONAL,INTENT(IN)       :: up
+    INTEGER,OPTIONAL,INTENT(IN)       :: down      
+    TYPE(request),INTENT(INOUT)         :: a_request
+
+    INTEGER                           :: halo_up
+    INTEGER                           :: halo_down
+    
+    
+    halo_up=0
+    halo_down=0
+    IF (PRESENT(up))   halo_up=up
+    IF (PRESENT(down)) halo_down=down
+
+    CALL  Register_SwapField_gen_u(FieldS,FieldR,1,current_dist,new_dist,halo_up,halo_down,a_request)
         
   END SUBROUTINE  Register_SwapField1d_u2d 
 
-
-  SUBROUTINE Register_SwapField2d_u2d(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
-  USE parallel_lmdz
-  USE dimensions_mod
-
-      IMPLICIT NONE
-    
-    REAL, DIMENSION(:,:,:),INTENT(IN)     :: FieldS
-    REAL, DIMENSION(:,:,:),INTENT(OUT)    :: FieldR
-    TYPE(distrib),OPTIONAL,INTENT(IN) :: old_dist
+ SUBROUTINE Register_SwapField1d_u2d_bis(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+
+      IMPLICIT NONE
+
+    TYPE(distrib),INTENT(IN)          :: new_dist !LF
+    TYPE(distrib),INTENT(IN)          :: old_dist
+    REAL, DIMENSION(old_dist%jjb_u:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%jjb_u:,:),INTENT(OUT)    :: FieldR
+    INTEGER,OPTIONAL,INTENT(IN)       :: up
+    INTEGER,OPTIONAL,INTENT(IN)       :: down      
+    TYPE(request),INTENT(INOUT)         :: a_request
+
+    INTEGER                           :: halo_up
+    INTEGER                           :: halo_down
+    
+    
+    halo_up=0
+    halo_down=0
+    IF (PRESENT(up))   halo_up=up
+    IF (PRESENT(down)) halo_down=down
+
+    CALL  Register_SwapField_gen_u(FieldS,FieldR,1,old_dist,new_dist,halo_up,halo_down,a_request)
+        
+  END SUBROUTINE  Register_SwapField1d_u2d_bis 
+
+
+  SUBROUTINE Register_SwapField2d_u2d(FieldS,FieldR,new_dist,a_request,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+
+      IMPLICIT NONE
+    
     TYPE(distrib),INTENT(IN)          :: new_dist
+    REAL, DIMENSION(current_dist%jjb_u:,:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%jjb_u:,:,:),INTENT(OUT)    :: FieldR
     INTEGER,OPTIONAL,INTENT(IN)       :: up
     INTEGER,OPTIONAL,INTENT(IN)       :: down      
@@ -510,22 +604,18 @@
     ll=size(FieldS,3)
     
-    IF (PRESENT(old_dist)) THEN
-      CALL  Register_SwapField_gen_u(FieldS,FieldR,ll,old_dist,new_dist,halo_up,halo_down,a_request)
-    ELSE
-      CALL  Register_SwapField_gen_u(FieldS,FieldR,ll,current_dist,new_dist,halo_up,halo_down,a_request)
-    ENDIF
+    CALL  Register_SwapField_gen_u(FieldS,FieldR,ll,current_dist,new_dist,halo_up,halo_down,a_request)
     
   END SUBROUTINE  Register_SwapField2d_u2d
-   
-
-  SUBROUTINE Register_SwapField3d_u2d(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
-  USE parallel_lmdz
-  USE dimensions_mod
-      IMPLICIT NONE
-    
-    REAL, DIMENSION(:,:,:,:),INTENT(IN)     :: FieldS
-    REAL, DIMENSION(:,:,:,:),INTENT(OUT)    :: FieldR
-    TYPE(distrib),OPTIONAL,INTENT(IN) :: old_dist
+
+  SUBROUTINE Register_SwapField2d_u2d_bis(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+
+      IMPLICIT NONE
+    
     TYPE(distrib),INTENT(IN)          :: new_dist
+    TYPE(distrib),INTENT(IN) :: old_dist
+    REAL, DIMENSION(old_dist%jjb_u:,:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%jjb_u:,:,:),INTENT(OUT)    :: FieldR
     INTEGER,OPTIONAL,INTENT(IN)       :: up
     INTEGER,OPTIONAL,INTENT(IN)       :: down      
@@ -542,60 +632,134 @@
     IF (PRESENT(down)) halo_down=down
     
+    ll=size(FieldS,3)
+    
+    CALL  Register_SwapField_gen_u(FieldS,FieldR,ll,old_dist,new_dist,halo_up,halo_down,a_request)
+    
+  END SUBROUTINE  Register_SwapField2d_u2d_bis
+   
+
+  SUBROUTINE Register_SwapField3d_u2d(FieldS,FieldR,new_dist,a_request,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+    
+    TYPE(distrib),INTENT(IN)          :: new_dist
+    REAL, DIMENSION(current_dist%jjb_u:,:,:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%jjb_u:,:,:,:),INTENT(OUT)    :: FieldR
+    INTEGER,OPTIONAL,INTENT(IN)       :: up
+    INTEGER,OPTIONAL,INTENT(IN)       :: down      
+    TYPE(request),INTENT(INOUT)         :: a_request
+
+    INTEGER                           :: halo_up
+    INTEGER                           :: halo_down
+    INTEGER                           :: ll
+        
+    
+    halo_up=0
+    halo_down=0
+    IF (PRESENT(up))   halo_up=up
+    IF (PRESENT(down)) halo_down=down
+    
     ll=size(FieldS,3)*size(FieldS,4)
     
-    IF (PRESENT(old_dist)) THEN
-      CALL  Register_SwapField_gen_u(FieldS,FieldR,ll,old_dist,new_dist,halo_up,halo_down,a_request)
-    ELSE
-      CALL  Register_SwapField_gen_u(FieldS,FieldR,ll,current_dist,new_dist,halo_up,halo_down,a_request)
-    ENDIF
+    CALL  Register_SwapField_gen_u(FieldS,FieldR,ll,current_dist,new_dist,halo_up,halo_down,a_request)
     
   END SUBROUTINE  Register_SwapField3d_u2d 
 
-
-
-
-
-
-
-  SUBROUTINE Register_SwapField1d_v(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
-  USE parallel_lmdz
-  USE dimensions_mod
-      IMPLICIT NONE
-    
-    REAL, DIMENSION(:),INTENT(IN)     :: FieldS
-    REAL, DIMENSION(:),INTENT(OUT)    :: FieldR
-    TYPE(distrib),OPTIONAL,INTENT(IN) :: old_dist
+  SUBROUTINE Register_SwapField3d_u2d_bis(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+    
     TYPE(distrib),INTENT(IN)          :: new_dist
-    INTEGER,OPTIONAL,INTENT(IN)       :: up
-    INTEGER,OPTIONAL,INTENT(IN)       :: down      
-    TYPE(request),INTENT(INOUT)         :: a_request
-
-    INTEGER                           :: halo_up
-    INTEGER                           :: halo_down
-    
-    
-    halo_up=0
-    halo_down=0
-    IF (PRESENT(up))   halo_up=up
-    IF (PRESENT(down)) halo_down=down
-
-    IF (PRESENT(old_dist)) THEN
-      CALL  Register_SwapField_gen_v(FieldS,FieldR,1,old_dist,new_dist,halo_up,halo_down,a_request)
-    ELSE
-      CALL  Register_SwapField_gen_v(FieldS,FieldR,1,current_dist,new_dist,halo_up,halo_down,a_request)
-    ENDIF
+    TYPE(distrib),INTENT(IN) :: old_dist
+    REAL, DIMENSION(old_dist%jjb_u:,:,:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%jjb_u:,:,:,:),INTENT(OUT)    :: FieldR
+    INTEGER,OPTIONAL,INTENT(IN)       :: up
+    INTEGER,OPTIONAL,INTENT(IN)       :: down      
+    TYPE(request),INTENT(INOUT)         :: a_request
+
+    INTEGER                           :: halo_up
+    INTEGER                           :: halo_down
+    INTEGER                           :: ll
+        
+    
+    halo_up=0
+    halo_down=0
+    IF (PRESENT(up))   halo_up=up
+    IF (PRESENT(down)) halo_down=down
+    
+    ll=size(FieldS,3)*size(FieldS,4)
+    
+    CALL  Register_SwapField_gen_u(FieldS,FieldR,ll,old_dist,new_dist,halo_up,halo_down,a_request)
+    
+  END SUBROUTINE  Register_SwapField3d_u2d_bis 
+
+
+
+
+
+
+
+  SUBROUTINE Register_SwapField1d_v(FieldS,FieldR,new_dist,a_request,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+    
+    TYPE(distrib),INTENT(IN)          :: new_dist
+    REAL, DIMENSION(current_dist%ijb_v:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%ijb_v:),INTENT(OUT)    :: FieldR
+    INTEGER,OPTIONAL,INTENT(IN)       :: up
+    INTEGER,OPTIONAL,INTENT(IN)       :: down      
+    TYPE(request),INTENT(INOUT)         :: a_request
+
+    INTEGER                           :: halo_up
+    INTEGER                           :: halo_down
+    
+    
+    halo_up=0
+    halo_down=0
+    IF (PRESENT(up))   halo_up=up
+    IF (PRESENT(down)) halo_down=down
+
+    CALL  Register_SwapField_gen_v(FieldS,FieldR,1,current_dist,new_dist,halo_up,halo_down,a_request)
         
   END SUBROUTINE  Register_SwapField1d_v 
 
-
-  SUBROUTINE Register_SwapField2d_v1d(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
-  USE parallel_lmdz
-  USE dimensions_mod
-      IMPLICIT NONE
-   
-    REAL, DIMENSION(:,:),INTENT(IN)     :: FieldS
-    REAL, DIMENSION(:,:),INTENT(OUT)    :: FieldR
-    TYPE(distrib),OPTIONAL,INTENT(IN) :: old_dist
+  SUBROUTINE Register_SwapField1d_v_bis(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+    
     TYPE(distrib),INTENT(IN)          :: new_dist
+    TYPE(distrib),INTENT(IN) :: old_dist
+    REAL, DIMENSION(old_dist%ijb_v:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%ijb_v:),INTENT(OUT)    :: FieldR
+    INTEGER,OPTIONAL,INTENT(IN)       :: up
+    INTEGER,OPTIONAL,INTENT(IN)       :: down      
+    TYPE(request),INTENT(INOUT)         :: a_request
+
+    INTEGER                           :: halo_up
+    INTEGER                           :: halo_down
+    
+    
+    halo_up=0
+    halo_down=0
+    IF (PRESENT(up))   halo_up=up
+    IF (PRESENT(down)) halo_down=down
+
+    CALL  Register_SwapField_gen_v(FieldS,FieldR,1,old_dist,new_dist,halo_up,halo_down,a_request)
+        
+  END SUBROUTINE  Register_SwapField1d_v_bis 
+
+
+  SUBROUTINE Register_SwapField2d_v1d(FieldS,FieldR,new_dist,a_request,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+   
+    TYPE(distrib),INTENT(IN)          :: new_dist
+    REAL, DIMENSION(current_dist%ijb_v:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%ijb_v:,:),INTENT(OUT)    :: FieldR
     INTEGER,OPTIONAL,INTENT(IN)       :: up
     INTEGER,OPTIONAL,INTENT(IN)       :: down      
@@ -614,22 +778,17 @@
     ll=size(FieldS,2)
     
-    IF (PRESENT(old_dist)) THEN
-      CALL  Register_SwapField_gen_v(FieldS,FieldR,ll,old_dist,new_dist,halo_up,halo_down,a_request)
-    ELSE
-      CALL  Register_SwapField_gen_v(FieldS,FieldR,ll,current_dist,new_dist,halo_up,halo_down,a_request)
-    ENDIF
+    CALL  Register_SwapField_gen_v(FieldS,FieldR,ll,current_dist,new_dist,halo_up,halo_down,a_request)
     
   END SUBROUTINE  Register_SwapField2d_v1d
-   
-
-  SUBROUTINE Register_SwapField3d_v(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
-  USE parallel_lmdz
-  USE dimensions_mod
-      IMPLICIT NONE
-    
-    REAL, DIMENSION(:,:,:),INTENT(IN)     :: FieldS
-    REAL, DIMENSION(:,:,:),INTENT(OUT)    :: FieldR
-    TYPE(distrib),OPTIONAL,INTENT(IN) :: old_dist
+  
+  SUBROUTINE Register_SwapField2d_v1d_bis(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+   
     TYPE(distrib),INTENT(IN)          :: new_dist
+    TYPE(distrib),INTENT(IN)          :: old_dist
+    REAL, DIMENSION(old_dist%ijb_v:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%ijb_v:,:),INTENT(OUT)    :: FieldR
     INTEGER,OPTIONAL,INTENT(IN)       :: up
     INTEGER,OPTIONAL,INTENT(IN)       :: down      
@@ -646,57 +805,132 @@
     IF (PRESENT(down)) halo_down=down
     
+    ll=size(FieldS,2)
+    
+    CALL  Register_SwapField_gen_v(FieldS,FieldR,ll,old_dist,new_dist,halo_up,halo_down,a_request)
+    
+  END SUBROUTINE  Register_SwapField2d_v1d_bis
+  
+   
+
+  SUBROUTINE Register_SwapField3d_v(FieldS,FieldR,new_dist,a_request,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+    
+    TYPE(distrib),INTENT(IN)          :: new_dist
+    REAL, DIMENSION(current_dist%ijb_v:,:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%ijb_v:,:,:),INTENT(OUT)    :: FieldR
+    INTEGER,OPTIONAL,INTENT(IN)       :: up
+    INTEGER,OPTIONAL,INTENT(IN)       :: down      
+    TYPE(request),INTENT(INOUT)         :: a_request
+
+    INTEGER                           :: halo_up
+    INTEGER                           :: halo_down
+    INTEGER                           :: ll
+        
+    
+    halo_up=0
+    halo_down=0
+    IF (PRESENT(up))   halo_up=up
+    IF (PRESENT(down)) halo_down=down
+    
     ll=size(FieldS,2)*size(FieldS,3)
     
-    IF (PRESENT(old_dist)) THEN
-      CALL  Register_SwapField_gen_v(FieldS,FieldR,ll,old_dist,new_dist,halo_up,halo_down,a_request)
-    ELSE
-      CALL  Register_SwapField_gen_v(FieldS,FieldR,ll,current_dist,new_dist,halo_up,halo_down,a_request)
-    ENDIF
+    CALL  Register_SwapField_gen_v(FieldS,FieldR,ll,current_dist,new_dist,halo_up,halo_down,a_request)
     
   END SUBROUTINE  Register_SwapField3d_v 
 
-
-
-
-  SUBROUTINE Register_SwapField1d_v2d(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
-  USE parallel_lmdz
-  USE dimensions_mod
-      IMPLICIT NONE
-    
-    REAL, DIMENSION(:,:),INTENT(IN)     :: FieldS
-    REAL, DIMENSION(:,:),INTENT(OUT)    :: FieldR
-    TYPE(distrib),OPTIONAL,INTENT(IN) :: old_dist
-    TYPE(distrib),OPTIONAL,INTENT(IN)          :: new_dist !LF
-    INTEGER,OPTIONAL,INTENT(IN)       :: up
-    INTEGER,OPTIONAL,INTENT(IN)       :: down      
-    TYPE(request),INTENT(INOUT)         :: a_request
-
-    INTEGER                           :: halo_up
-    INTEGER                           :: halo_down
-    
-    
-    halo_up=0
-    halo_down=0
-    IF (PRESENT(up))   halo_up=up
-    IF (PRESENT(down)) halo_down=down
-
-    IF (PRESENT(old_dist)) THEN
-      CALL  Register_SwapField_gen_v(FieldS,FieldR,1,old_dist,new_dist,halo_up,halo_down,a_request)
-    ELSE
-      CALL  Register_SwapField_gen_v(FieldS,FieldR,1,current_dist,new_dist,halo_up,halo_down,a_request)
-    ENDIF
+  SUBROUTINE Register_SwapField3d_v_bis(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+    
+    TYPE(distrib),INTENT(IN)          :: new_dist
+    TYPE(distrib),INTENT(IN) :: old_dist
+    REAL, DIMENSION(old_dist%ijb_v:,:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%ijb_v:,:,:),INTENT(OUT)    :: FieldR
+    INTEGER,OPTIONAL,INTENT(IN)       :: up
+    INTEGER,OPTIONAL,INTENT(IN)       :: down      
+    TYPE(request),INTENT(INOUT)         :: a_request
+
+    INTEGER                           :: halo_up
+    INTEGER                           :: halo_down
+    INTEGER                           :: ll
+        
+    
+    halo_up=0
+    halo_down=0
+    IF (PRESENT(up))   halo_up=up
+    IF (PRESENT(down)) halo_down=down
+    
+    ll=size(FieldS,2)*size(FieldS,3)
+    
+    CALL  Register_SwapField_gen_v(FieldS,FieldR,ll,old_dist,new_dist,halo_up,halo_down,a_request)
+    
+  END SUBROUTINE  Register_SwapField3d_v_bis 
+
+
+
+
+  SUBROUTINE Register_SwapField1d_v2d(FieldS,FieldR,new_dist,a_request,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+    
+    TYPE(distrib),INTENT(IN)          :: new_dist !LF
+    REAL, DIMENSION(current_dist%jjb_v:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%jjb_v:,:),INTENT(OUT)    :: FieldR
+    INTEGER,OPTIONAL,INTENT(IN)       :: up
+    INTEGER,OPTIONAL,INTENT(IN)       :: down      
+    TYPE(request),INTENT(INOUT)         :: a_request
+
+    INTEGER                           :: halo_up
+    INTEGER                           :: halo_down
+    
+    
+    halo_up=0
+    halo_down=0
+    IF (PRESENT(up))   halo_up=up
+    IF (PRESENT(down)) halo_down=down
+
+    CALL  Register_SwapField_gen_v(FieldS,FieldR,1,current_dist,new_dist,halo_up,halo_down,a_request)
         
   END SUBROUTINE  Register_SwapField1d_v2d
 
-
-  SUBROUTINE Register_SwapField2d_v2d(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
-  USE parallel_lmdz
-  USE dimensions_mod
-      IMPLICIT NONE
-    
-    REAL, DIMENSION(:,:,:),INTENT(IN)     :: FieldS
-    REAL, DIMENSION(:,:,:),INTENT(OUT)    :: FieldR
-    TYPE(distrib),OPTIONAL,INTENT(IN) :: old_dist
+  SUBROUTINE Register_SwapField1d_v2d_bis(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+    
+    TYPE(distrib),INTENT(IN)          :: new_dist !LF
+    TYPE(distrib),INTENT(IN) :: old_dist
+    REAL, DIMENSION(old_dist%jjb_v:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%jjb_v:,:),INTENT(OUT)    :: FieldR
+    INTEGER,OPTIONAL,INTENT(IN)       :: up
+    INTEGER,OPTIONAL,INTENT(IN)       :: down      
+    TYPE(request),INTENT(INOUT)         :: a_request
+
+    INTEGER                           :: halo_up
+    INTEGER                           :: halo_down
+    
+    
+    halo_up=0
+    halo_down=0
+    IF (PRESENT(up))   halo_up=up
+    IF (PRESENT(down)) halo_down=down
+
+    CALL  Register_SwapField_gen_v(FieldS,FieldR,1,old_dist,new_dist,halo_up,halo_down,a_request)
+        
+  END SUBROUTINE  Register_SwapField1d_v2d_bis
+
+
+  SUBROUTINE Register_SwapField2d_v2d(FieldS,FieldR,new_dist,a_request,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+    
     TYPE(distrib),INTENT(IN)          :: new_dist
+    REAL, DIMENSION(current_dist%jjb_v:,:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%jjb_v:,:,:),INTENT(OUT)    :: FieldR
     INTEGER,OPTIONAL,INTENT(IN)       :: up
     INTEGER,OPTIONAL,INTENT(IN)       :: down      
@@ -715,22 +949,17 @@
     ll=size(FieldS,3)
     
-    IF (PRESENT(old_dist)) THEN
-      CALL  Register_SwapField_gen_v(FieldS,FieldR,ll,old_dist,new_dist,halo_up,halo_down,a_request)
-    ELSE
-      CALL  Register_SwapField_gen_v(FieldS,FieldR,ll,current_dist,new_dist,halo_up,halo_down,a_request)
-    ENDIF
+    CALL  Register_SwapField_gen_v(FieldS,FieldR,ll,current_dist,new_dist,halo_up,halo_down,a_request)
     
   END SUBROUTINE  Register_SwapField2d_v2d
    
-
-  SUBROUTINE Register_SwapField3d_v2d(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
-  USE parallel_lmdz
-  USE dimensions_mod
-      IMPLICIT NONE
-    
-    REAL, DIMENSION(:,:,:,:),INTENT(IN)     :: FieldS
-    REAL, DIMENSION(:,:,:,:),INTENT(OUT)    :: FieldR
-    TYPE(distrib),OPTIONAL,INTENT(IN) :: old_dist
+  SUBROUTINE Register_SwapField2d_v2d_bis(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+    
     TYPE(distrib),INTENT(IN)          :: new_dist
+    TYPE(distrib),INTENT(IN) :: old_dist
+    REAL, DIMENSION(old_dist%jjb_v:,:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%jjb_v:,:,:),INTENT(OUT)    :: FieldR
     INTEGER,OPTIONAL,INTENT(IN)       :: up
     INTEGER,OPTIONAL,INTENT(IN)       :: down      
@@ -747,13 +976,67 @@
     IF (PRESENT(down)) halo_down=down
     
+    ll=size(FieldS,3)
+    
+    CALL  Register_SwapField_gen_v(FieldS,FieldR,ll,old_dist,new_dist,halo_up,halo_down,a_request)
+    
+  END SUBROUTINE  Register_SwapField2d_v2d_bis
+   
+
+  SUBROUTINE Register_SwapField3d_v2d(FieldS,FieldR,new_dist,a_request,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+    
+    TYPE(distrib),INTENT(IN)          :: new_dist
+    REAL, DIMENSION(current_dist%jjb_v:,:,:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%jjb_v:,:,:,:),INTENT(OUT)    :: FieldR
+    INTEGER,OPTIONAL,INTENT(IN)       :: up
+    INTEGER,OPTIONAL,INTENT(IN)       :: down      
+    TYPE(request),INTENT(INOUT)         :: a_request
+
+    INTEGER                           :: halo_up
+    INTEGER                           :: halo_down
+    INTEGER                           :: ll
+        
+    
+    halo_up=0
+    halo_down=0
+    IF (PRESENT(up))   halo_up=up
+    IF (PRESENT(down)) halo_down=down
+    
     ll=size(FieldS,3)*size(FieldS,4)
     
-    IF (PRESENT(old_dist)) THEN
-      CALL  Register_SwapField_gen_v(FieldS,FieldR,ll,old_dist,new_dist,halo_up,halo_down,a_request)
-    ELSE
-      CALL  Register_SwapField_gen_v(FieldS,FieldR,ll,current_dist,new_dist,halo_up,halo_down,a_request)
-    ENDIF
+    CALL  Register_SwapField_gen_v(FieldS,FieldR,ll,current_dist,new_dist,halo_up,halo_down,a_request)
     
   END SUBROUTINE  Register_SwapField3d_v2d 
+  
+  SUBROUTINE Register_SwapField3d_v2d_bis(FieldS,FieldR,new_dist,a_request,old_dist,up,down)
+  USE parallel_lmdz
+  USE dimensions_mod
+      IMPLICIT NONE
+    
+    TYPE(distrib),INTENT(IN)          :: new_dist
+    TYPE(distrib),INTENT(IN) :: old_dist
+    REAL, DIMENSION(old_dist%jjb_v:,:,:,:),INTENT(IN)     :: FieldS
+    REAL, DIMENSION(new_dist%jjb_v:,:,:,:),INTENT(OUT)    :: FieldR
+    INTEGER,OPTIONAL,INTENT(IN)       :: up
+    INTEGER,OPTIONAL,INTENT(IN)       :: down      
+    TYPE(request),INTENT(INOUT)         :: a_request
+
+    INTEGER                           :: halo_up
+    INTEGER                           :: halo_down
+    INTEGER                           :: ll
+        
+    
+    halo_up=0
+    halo_down=0
+    IF (PRESENT(up))   halo_up=up
+    IF (PRESENT(down)) halo_down=down
+    
+    ll=size(FieldS,3)*size(FieldS,4)
+    
+    CALL  Register_SwapField_gen_v(FieldS,FieldR,ll,old_dist,new_dist,halo_up,halo_down,a_request)
+    
+  END SUBROUTINE  Register_SwapField3d_v2d_bis 
   
   
Index: /LMDZ5/branches/testing/libf/dyn3dpar/conf_gcm.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dpar/conf_gcm.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/dyn3dpar/conf_gcm.F90	(revision 2471)
@@ -324,4 +324,8 @@
   CALL getin('dissip_deltaz',dissip_deltaz )
   CALL getin('dissip_zref',dissip_zref )
+
+  ! ngroup
+  ngroup=3
+  CALL getin('ngroup',ngroup)
 
   ! top_bound sponge: only active if ok_strato=.true. and iflag_top_bound!=0
Index: /LMDZ5/branches/testing/libf/dyn3dpar/groupe_p.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dpar/groupe_p.F	(revision 2470)
+++ /LMDZ5/branches/testing/libf/dyn3dpar/groupe_p.F	(revision 2471)
@@ -20,6 +20,6 @@
 #include "comvert.h"
 
-      integer ngroup
-      parameter (ngroup=3)
+!     integer ngroup
+!     parameter (ngroup=3)
 
 
Index: /LMDZ5/branches/testing/libf/dyn3dpar/groupeun_p.F
===================================================================
--- /LMDZ5/branches/testing/libf/dyn3dpar/groupeun_p.F	(revision 2470)
+++ /LMDZ5/branches/testing/libf/dyn3dpar/groupeun_p.F	(revision 2471)
@@ -12,6 +12,6 @@
       REAL q(iip1,jjmax,llmax)
 
-      INTEGER ngroup
-      PARAMETER (ngroup=3)
+!     INTEGER ngroup
+!     PARAMETER (ngroup=3)
 
       REAL airecn,qn
@@ -38,7 +38,7 @@
       LOGICAL, SAVE :: first = .TRUE.
 !$OMP THREADPRIVATE(first)
-      INTEGER,SAVE :: i_index(iim,ngroup)
+!     INTEGER,SAVE :: i_index(iim,ngroup)
       INTEGER      :: offset
-      REAL         :: qsum(iim/ngroup)
+!     REAL         :: qsum(iim/ngroup)
 
       IF (first) THEN
@@ -143,6 +143,6 @@
 #include "comgeom2.h"
 
-      INTEGER ngroup
-      PARAMETER (ngroup=3)
+!     INTEGER ngroup
+!     PARAMETER (ngroup=3)
 
       REAL airen,airecn
Index: /LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/ce0l.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/ce0l.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/ce0l.F90	(revision 2471)
@@ -27,10 +27,7 @@
   USE iniphysiq_mod,  ONLY: iniphysiq
   USE mod_const_mpi,  ONLY: comm_lmdz
-#ifdef inca
-  USE indice_sol_mod, ONLY: nbsrf, is_oce, is_sic, is_ter, is_lic
-#endif
 #ifdef CPP_PARA
   USE mod_const_mpi,  ONLY: init_const_mpi
-  USE parallel_lmdz,  ONLY: init_parallel, mpi_rank, omp_rank, mpi_size
+  USE parallel_lmdz,  ONLY: init_parallel, mpi_rank, omp_rank
   USE bands,          ONLY: read_distrib, distrib_phys
   USE mod_hallo,      ONLY: init_mod_hallo
@@ -116,13 +113,4 @@
 
 !--- Tracers initializations
-  IF (type_trac == 'inca') THEN
-#ifdef INCA
-    CALL init_const_lmdz(nbtr,anneeref,dayref,iphysiq,day_step,nday,&
-                         nbsrf,is_oce,is_sic,is_ter,is_lic,calend)
-    CALL init_inca_para(iim,jjp1,llm,klon_glo,mpi_size,distrib_phys,&
-                        COMM_LMDZ)
-    WRITE(lunout,*)'nbtr =' , nbtr 
-#endif
-  END IF
   CALL infotrac_init()
 
Index: /LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/etat0phys_netcdf.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/etat0phys_netcdf.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/etat0phys_netcdf.F90	(revision 2471)
@@ -86,4 +86,5 @@
   USE conf_phys_m, ONLY: conf_phys
   USE init_ssrf_m, ONLY: start_init_subsurf
+  !use ioipsl_getincom
   IMPLICIT NONE
 !-------------------------------------------------------------------------------
@@ -97,5 +98,5 @@
   LOGICAL            :: read_mask
   REAL               :: phystep, dummy
-  REAL, DIMENSION(SIZE(masque,1),SIZE(masque,2)) :: masque_tmp
+  REAL, DIMENSION(SIZE(masque,1),SIZE(masque,2)) :: masque_tmp,phiso
   REAL, DIMENSION(klon)               :: sn, rugmer, run_off_lic_0, fder
   REAL, DIMENSION(klon,nbsrf)         :: qsolsrf, snsrf
@@ -115,4 +116,5 @@
   INTEGER :: read_climoz                        !--- Read ozone climatology
   REAL    :: alp_offset
+  LOGICAL :: filtre_oro=.false.
 
   deg2rad= pi/180.0
@@ -142,4 +144,8 @@
   read_mask=ANY(masque/=-99999.); masque_tmp=masque
   CALL start_init_orog(rlonv, rlatu, phis, masque_tmp)
+
+  CALL getin('filtre_oro',filtre_oro)
+  IF (filtre_oro) CALL filtreoro(size(phis,1),size(phis,2),phis,masque_tmp,rlatu)
+
   WRITE(fmt,"(i4,'i1)')")iml ; fmt='('//ADJUSTL(fmt)
   IF(.NOT.read_mask) THEN                       !--- Keep mask form orography
@@ -447,8 +453,54 @@
 !
 !-------------------------------------------------------------------------------
+!
+!*******************************************************************************
+
+SUBROUTINE filtreoro(imp1,jmp1,phis,masque,rlatu)
+
+IMPLICIT NONE
+
+  INTEGER imp1,jmp1
+  REAL, DIMENSION(imp1,jmp1) :: phis,masque
+  REAL, DIMENSION(jmp1) :: rlatu
+  REAL, DIMENSION(imp1) :: wwf
+  REAL, DIMENSION(imp1,jmp1) :: phiso
+  INTEGER :: ifiltre,ifi,ii,i,j
+  REAL :: coslat0,ssz
+
+  coslat0=0.5
+  phiso=phis
+  do j=2,jmp1-1
+     print*,'avant if ',cos(rlatu(j)),coslat0
+     if (cos(rlatu(j))<coslat0) then
+         ! nb de pts affectes par le filtrage de part et d'autre du pt
+         ifiltre=(coslat0/cos(rlatu(j))-1.)/2.
+         wwf=0.
+         do i=1,ifiltre
+            wwf(i)=1.
+         enddo
+         wwf(ifiltre+1)=(coslat0/cos(rlatu(j))-1.)/2.-ifiltre
+         do i=1,imp1-1
+            if (masque(i,j)>0.9) then
+               ssz=phis(i,j)
+               do ifi=1,ifiltre+1
+                  ii=i+ifi
+                  if (ii>imp1-1) ii=ii-imp1+1
+                  ssz=ssz+wwf(ifi)*phis(ii,j)
+                  ii=i-ifi
+                  if (ii<1) ii=ii+imp1-1
+                  ssz=ssz+wwf(ifi)*phis(ii,j)
+               enddo
+               phis(i,j)=ssz*cos(rlatu(j))/coslat0
+            endif
+         enddo
+         print*,'j=',j,coslat0/cos(rlatu(j)), (1.+2.*sum(wwf))*cos(rlatu(j))/coslat0
+     endif
+  enddo
+  call dump2d(imp1,jmp1,phis,'phis ')
+  call dump2d(imp1,jmp1,masque,'masque ')
+  call dump2d(imp1,jmp1,phis-phiso,'dphis ')
+
+END SUBROUTINE filtreoro
 
 
 END MODULE etat0phys
-!
-!*******************************************************************************
-
Index: /LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/iniphysiq_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/iniphysiq_mod.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/iniphysiq_mod.F90	(revision 2471)
@@ -47,7 +47,8 @@
 #ifdef INCA
   USE indice_sol_mod, ONLY: nbsrf, is_oce, is_sic, is_ter, is_lic
-  USE parallel_lmdz, ONLY : mpi_size
-  USE mod_const_mpi, ONLY : COMM_LMDZ
+#ifdef CPP_PARA
+  USE parallel_lmdz, ONLY : mpi_size, mpi_rank
   USE bands, ONLY : distrib_phys
+#endif
   USE mod_phys_lmdz_omp_data, ONLY: klon_omp 
 #endif
@@ -115,4 +116,10 @@
   REAL,ALLOCATABLE,SAVE :: boundslatfi(:,:)
 !$OMP THREADPRIVATE (latfi,lonfi,cufi,cvfi,airefi,boundslonfi,boundslatfi)
+
+#ifndef CPP_PARA
+  INTEGER,PARAMETER :: mpi_rank=0
+  INTEGER, PARAMETER :: mpi_size = 1 
+  INTEGER :: distrib_phys(mpi_rank:mpi_rank)=(jjm-1)*iim+2
+#endif
 
   ! Initialize Physics distibution and parameters and interface with dynamics
@@ -295,11 +302,9 @@
 #ifdef INCA
      call init_const_lmdz( &
-          anneeref,dayref, &
-          iphysiq,day_step,nday,  &
-          nbsrf, is_oce,is_sic, &
-          is_ter,is_lic, calend)
+          anneeref,dayref, iphysiq,day_step,nday,  &
+          nbsrf, is_oce,is_sic, is_ter,is_lic, calend)
      call init_inca_para( &
           nbp_lon,nbp_lat,nbp_lev,klon_glo,mpi_size, &
-          distrib_phys,COMM_LMDZ)
+          distrib_phys,communicator)
 #endif
   END IF
Index: /LMDZ5/branches/testing/libf/misc/regr1_conserv_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/misc/regr1_conserv_m.F90	(revision 2471)
+++ /LMDZ5/branches/testing/libf/misc/regr1_conserv_m.F90	(revision 2471)
@@ -0,0 +1,358 @@
+module regr1_conserv_m
+
+  ! Author: Lionel GUEZ
+
+  use assert_eq_m, only: assert_eq
+  use assert_m, only: assert
+  use interpolation, only: locate
+
+  implicit none
+
+  interface regr1_conserv
+
+     ! This generic procedure regrids a piecewise linear function (not
+     ! necessarily continuous) by averaging it. This is a conservative
+     ! regridding. The regridding operation is done on the first
+     ! dimension of the input array. Input are positions of cell
+     ! edges. The target grid should be included in the source grid:
+     ! no extrapolation is allowed.
+
+     ! The only difference between the procedures is the rank of the
+     ! first argument.
+
+     ! real, intent(in), rank >= 1:: vs ! (ns, ...)
+     ! averages of cells of the source grid
+     ! vs(is, ...) for [xs(is), xs(is + 1)]
+
+     ! real, intent(in):: xs(:) ! (ns + 1)
+     ! edges of cells of the source grid, in strictly ascending order
+
+     ! real, intent(in):: xt(:) ! (nt + 1)
+     ! edges of cells of the target grid, in strictly ascending order
+
+     ! real, intent(in), optional, rank >= 1:: slope ! (ns, ...)
+     ! same rank as vs
+     ! slopes inside cells of the source grid
+     ! slope(is, ...) for [xs(is), xs(is + 1)]
+     ! If not present, slopes are taken equal to 0. The regridding is
+     ! then first order.
+
+     ! real, intent(out), rank >= 1:: vt(nt, ...) 
+     ! has the same rank as vs and slope
+     ! averages of cells of the target grid
+     ! vt(it, ...) for  [xt(it), xt(it + 1)]
+
+     ! ns and nt must be >= 1.
+
+     ! See notes for explanations on the algorithm and justification
+     ! of algorithmic choices.
+
+     module procedure regr11_conserv, regr12_conserv, regr13_conserv, &
+          regr14_conserv
+  end interface regr1_conserv
+
+  private
+  public regr1_conserv
+
+contains
+
+  subroutine regr11_conserv(vs, xs, xt, vt, slope)
+
+    ! vs and slope have rank 1.
+
+    real, intent(in):: vs(:)
+    real, intent(in):: xs(:)
+    real, intent(in):: xt(:)
+    real, intent(out):: vt(:)
+    real, intent(in), optional:: slope(:)
+
+    ! Local:
+    integer is, it, ns, nt
+    logical slope_present
+
+    !---------------------------------------------
+
+    ns = assert_eq(size(vs), size(xs) - 1, "regr11_conserv ns")
+    nt = assert_eq(size(xt) - 1, size(vt), "regr11_conserv nt")
+
+    ! Quick check on sort order:
+    call assert(xs(1) < xs(2), "regr11_conserv xs bad order")
+    call assert(xt(1) < xt(2), "regr11_conserv xt bad order")
+
+    call assert(xs(1) <= xt(1) .and. xt(nt + 1) <= xs(ns + 1), &
+         "regr11_conserv extrapolation")
+    slope_present = present(slope)
+
+    is = locate(xs, xt(1)) ! 1 <= is <= ns, because we forbid extrapolation
+    do it = 1, nt
+       ! 1 <= is <= ns
+       ! xs(is) <= xt(it) < xs(is + 1)
+       if (xt(it + 1) <= xs(is + 1)) then
+          vt(it) = mean_lin(xt(it), xt(it + 1))
+       else
+          vt(it) = mean_lin(xt(it), xs(is + 1)) * (xs(is + 1) - xt(it))
+          is = is + 1
+          do while (xs(is + 1) < xt(it + 1))
+             ! 1 <= is <= ns - 1
+             vt(it) = vt(it) + (xs(is + 1) - xs(is)) * vs(is)
+             is = is + 1
+          end do
+          ! 1 <= is <= ns
+          vt(it) = (vt(it) + mean_lin(xs(is), xt(it + 1)) * (xt(it + 1) &
+               - xs(is))) / (xt(it + 1) - xt(it))
+       end if
+
+       if (xs(is + 1) == xt(it + 1)) is = is + 1
+       ! 1 <= is <= ns .or. it == nt
+    end do
+
+  contains
+
+    real function mean_lin(a, b)
+
+      ! mean in [a, b] of the linear function in [xs(is), xs(is + 1)]
+
+      real, intent(in):: a, b
+
+      !---------------------------------------------
+
+      if (slope_present) then
+         mean_lin = slope(is) / 2. * (a + b - xs(is) - xs(is + 1)) + vs(is)
+      else
+         mean_lin = vs(is)
+      end if
+
+    end function mean_lin
+
+  end subroutine regr11_conserv
+
+  !********************************************
+
+  subroutine regr12_conserv(vs, xs, xt, vt, slope)
+
+    ! vs and slope have rank 2.
+
+    real, intent(in):: vs(:, :)
+    real, intent(in):: xs(:)
+    real, intent(in):: xt(:)
+    real, intent(out):: vt(:, :)
+    real, intent(in), optional:: slope(:, :)
+
+    ! Local:
+    integer is, it, ns, nt, n2
+    logical slope_present
+
+    !---------------------------------------------
+
+    ns = assert_eq(size(vs, 1), size(xs) - 1, "regr12_conserv ns")
+    nt = assert_eq(size(xt) - 1, size(vt, 1), "regr12_conserv nt")
+    n2 = assert_eq(size(vs, 2), size(vt, 2), "regr12_conserv n2")
+
+    ! Quick check on sort order:
+    call assert(xs(1) < xs(2), "regr12_conserv xs bad order")
+    call assert(xt(1) < xt(2), "regr12_conserv xt bad order")
+
+    call assert(xs(1) <= xt(1) .and. xt(nt + 1) <= xs(ns + 1), &
+         "regr12_conserv extrapolation")
+    slope_present = present(slope)
+
+    is = locate(xs, xt(1)) ! 1 <= is <= ns, because we forbid extrapolation
+    do it = 1, nt
+       ! 1 <= is <= ns
+       ! xs(is) <= xt(it) < xs(is + 1)
+       if (xt(it + 1) <= xs(is + 1)) then
+          vt(it, :) = mean_lin(xt(it), xt(it + 1))
+       else
+          vt(it, :) = mean_lin(xt(it), xs(is + 1)) * (xs(is + 1) - xt(it))
+          is = is + 1
+          do while (xs(is + 1) < xt(it + 1))
+             ! 1 <= is <= ns - 1
+             vt(it, :) = vt(it, :) + (xs(is + 1) - xs(is)) * vs(is, :)
+             is = is + 1
+          end do
+          ! 1 <= is <= ns
+          vt(it, :) = (vt(it, :) + mean_lin(xs(is), xt(it + 1)) * (xt(it + 1) &
+               - xs(is))) / (xt(it + 1) - xt(it))
+       end if
+
+       if (xs(is + 1) == xt(it + 1)) is = is + 1
+       ! 1 <= is <= ns .or. it == nt
+    end do
+
+  contains
+
+    function mean_lin(a, b)
+
+      ! mean in [a, b] of the linear function in [xs(is), xs(is + 1)]
+
+      real, intent(in):: a, b
+      real mean_lin(n2)
+
+      !---------------------------------------------
+
+      if (slope_present) then
+         mean_lin = slope(is, :) / 2. * (a + b - xs(is) - xs(is + 1)) &
+              + vs(is, :)
+      else
+         mean_lin = vs(is, :)
+      end if
+
+    end function mean_lin
+
+  end subroutine regr12_conserv
+
+  !********************************************
+
+  subroutine regr13_conserv(vs, xs, xt, vt, slope)
+
+    ! vs and slope have rank 3.
+
+    real, intent(in):: vs(:, :, :)
+    real, intent(in):: xs(:)
+    real, intent(in):: xt(:)
+    real, intent(out):: vt(:, :, :)
+    real, intent(in), optional:: slope(:, :, :)
+
+    ! Local:
+    integer is, it, ns, nt, n2, n3
+    logical slope_present
+
+    !---------------------------------------------
+
+    ns = assert_eq(size(vs, 1), size(xs) - 1, "regr13_conserv ns")
+    nt = assert_eq(size(xt) - 1, size(vt, 1), "regr13_conserv nt")
+    n2 = assert_eq(size(vs, 2), size(vt, 2), "regr13_conserv n2")
+    n3 = assert_eq(size(vs, 3), size(vt, 3), "regr13_conserv n3")
+
+    ! Quick check on sort order:
+    call assert(xs(1) < xs(2), "regr13_conserv xs bad order")
+    call assert(xt(1) < xt(2), "regr13_conserv xt bad order")
+
+    call assert(xs(1) <= xt(1) .and. xt(nt + 1) <= xs(ns + 1), &
+         "regr13_conserv extrapolation")
+    slope_present = present(slope)
+
+    is = locate(xs, xt(1)) ! 1 <= is <= ns, because we forbid extrapolation
+    do it = 1, nt
+       ! 1 <= is <= ns
+       ! xs(is) <= xt(it) < xs(is + 1)
+       if (xt(it + 1) <= xs(is + 1)) then
+          vt(it, :, :) = mean_lin(xt(it), xt(it + 1))
+       else
+          vt(it, :, :) = mean_lin(xt(it), xs(is + 1)) * (xs(is + 1) - xt(it))
+          is = is + 1
+          do while (xs(is + 1) < xt(it + 1))
+             ! 1 <= is <= ns - 1
+             vt(it, :, :) = vt(it, :, :) + (xs(is + 1) - xs(is)) * vs(is, :, :)
+             is = is + 1
+          end do
+          ! 1 <= is <= ns
+          vt(it, :, :) = (vt(it, :, :) + mean_lin(xs(is), xt(it + 1)) &
+               * (xt(it + 1) - xs(is))) / (xt(it + 1) - xt(it))
+       end if
+
+       if (xs(is + 1) == xt(it + 1)) is = is + 1
+       ! 1 <= is <= ns .or. it == nt
+    end do
+
+  contains
+
+    function mean_lin(a, b)
+
+      ! mean in [a, b] of the linear function in [xs(is), xs(is + 1)]
+
+      real, intent(in):: a, b
+      real mean_lin(n2, n3)
+
+      !---------------------------------------------
+
+      if (slope_present) then
+         mean_lin = slope(is, :, :) / 2. * (a + b - xs(is) - xs(is + 1)) &
+              + vs(is, :, :)
+      else
+         mean_lin = vs(is, :, :)
+      end if
+
+    end function mean_lin
+
+  end subroutine regr13_conserv
+
+  !********************************************
+
+  subroutine regr14_conserv(vs, xs, xt, vt, slope)
+
+    ! vs and slope have rank 4.
+
+    real, intent(in):: vs(:, :, :, :)
+    real, intent(in):: xs(:)
+    real, intent(in):: xt(:)
+    real, intent(out):: vt(:, :, :, :)
+    real, intent(in), optional:: slope(:, :, :, :)
+
+    ! Local:
+    integer is, it, ns, nt, n2, n3, n4
+    logical slope_present
+
+    !---------------------------------------------
+
+    ns = assert_eq(size(vs, 1), size(xs) - 1, "regr14_conserv ns")
+    nt = assert_eq(size(xt) - 1, size(vt, 1), "regr14_conserv nt")
+    n2 = assert_eq(size(vs, 2), size(vt, 2), "regr14_conserv n2")
+    n3 = assert_eq(size(vs, 3), size(vt, 3), "regr14_conserv n3")
+    n4 = assert_eq(size(vs, 4), size(vt, 4), "regr14_conserv n4")
+
+    ! Quick check on sort order:
+    call assert(xs(1) < xs(2), "regr14_conserv xs bad order")
+    call assert(xt(1) < xt(2), "regr14_conserv xt bad order")
+
+    call assert(xs(1) <= xt(1) .and. xt(nt + 1) <= xs(ns + 1), &
+         "regr14_conserv extrapolation")
+    slope_present = present(slope)
+
+    is = locate(xs, xt(1)) ! 1 <= is <= ns, because we forbid extrapolation
+    do it = 1, nt
+       ! 1 <= is <= ns
+       ! xs(is) <= xt(it) < xs(is + 1)
+       if (xt(it + 1) <= xs(is + 1)) then
+          vt(it, :, :, :) = mean_lin(xt(it), xt(it + 1))
+       else
+          vt(it, :, :, :) = mean_lin(xt(it), xs(is + 1)) * (xs(is + 1) - xt(it))
+          is = is + 1
+          do while (xs(is + 1) < xt(it + 1))
+             ! 1 <= is <= ns - 1
+             vt(it, :, :, :) = vt(it, :, :, :) + (xs(is + 1) - xs(is)) &
+                  * vs(is, :, :, :)
+             is = is + 1
+          end do
+          ! 1 <= is <= ns
+          vt(it, :, :, :) = (vt(it, :, :, :) + mean_lin(xs(is), xt(it + 1)) &
+               * (xt(it + 1) - xs(is))) / (xt(it + 1) - xt(it))
+       end if
+
+       if (xs(is + 1) == xt(it + 1)) is = is + 1
+       ! 1 <= is <= ns .or. it == nt
+    end do
+
+  contains
+
+    function mean_lin(a, b)
+
+      ! mean in [a, b] of the linear function in [xs(is), xs(is + 1)]
+
+      real, intent(in):: a, b
+      real mean_lin(n2, n3, n4)
+
+      !---------------------------------------------
+
+      if (slope_present) then
+         mean_lin = slope(is, :, :, :) / 2. * (a + b - xs(is) - xs(is + 1)) &
+              + vs(is, :, :, :)
+      else
+         mean_lin = vs(is, :, :, :)
+      end if
+
+    end function mean_lin
+
+  end subroutine regr14_conserv
+
+end module regr1_conserv_m
Index: DZ5/branches/testing/libf/misc/regr1_step_av_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/misc/regr1_step_av_m.F90	(revision 2470)
+++ 	(revision )
@@ -1,268 +1,0 @@
-! $Id$
-module regr1_step_av_m
-
-  ! Author: Lionel GUEZ
-
-  implicit none
-
-  interface regr1_step_av
-
-     ! Each procedure regrids a step function by averaging it.
-     ! The regridding operation is done on the first dimension of the
-     ! input array.
-     ! Source grid contains edges of steps.
-     ! Target grid contains positions of cell edges.
-     ! The target grid should be included in the source grid: no
-     ! extrapolation is allowed.
-     ! The difference between the procedures is the rank of the first argument.
-
-     module procedure regr11_step_av, regr12_step_av, regr13_step_av, &
-          regr14_step_av
-  end interface
-
-  private
-  public regr1_step_av
-
-contains
-
-  function regr11_step_av(vs, xs, xt) result(vt)
-
-    ! "vs" has rank 1.
-
-    use assert_eq_m, only: assert_eq
-    use assert_m, only: assert
-    use interpolation, only: locate
-
-    real, intent(in):: vs(:) ! values of steps on the source grid
-    ! (Step "is" is between "xs(is)" and "xs(is + 1)".)
-
-    real, intent(in):: xs(:)
-    ! (edges of of steps on the source grid, in strictly increasing order)
-
-    real, intent(in):: xt(:)
-    ! (edges of cells of the target grid, in strictly increasing order)
-
-    real vt(size(xt) - 1) ! average values on the target grid
-    ! (Cell "it" is between "xt(it)" and "xt(it + 1)".)
-
-    ! Variables local to the procedure:
-    integer is, it, ns, nt
-    real left_edge
-
-    !---------------------------------------------
-
-    ns = assert_eq(size(vs), size(xs) - 1, "regr11_step_av ns")
-    nt = size(xt) - 1
-    ! Quick check on sort order:
-    call assert(xs(1) < xs(2), "regr11_step_av xs bad order")
-    call assert(xt(1) < xt(2), "regr11_step_av xt bad order")
-
-    call assert(xs(1) <= xt(1) .and. xt(nt + 1) <= xs(ns + 1), &
-         "regr11_step_av extrapolation")
-
-    is = locate(xs, xt(1)) ! 1 <= is <= ns, because we forbid extrapolation
-    do it = 1, nt
-       ! 1 <= is <= ns
-       ! xs(is) <= xt(it) < xs(is + 1)
-       ! Compute "vt(it)":
-       left_edge = xt(it)
-       vt(it) = 0.
-       do while (xs(is + 1) < xt(it + 1))
-          ! 1 <= is <= ns - 1
-          vt(it) = vt(it) + (xs(is + 1) - left_edge) * vs(is)
-          is = is + 1
-          left_edge = xs(is)
-       end do
-       ! 1 <= is <= ns
-       vt(it) = (vt(it) + (xt(it + 1) - left_edge) * vs(is)) &
-            / (xt(it + 1) - xt(it))
-       if (xs(is + 1) == xt(it + 1)) is = is + 1
-       ! 1 <= is <= ns .or. it == nt
-    end do
-
-  end function regr11_step_av
-
-  !********************************************
-
-  function regr12_step_av(vs, xs, xt) result(vt)
-
-    ! "vs" has rank 2.
-
-    use assert_eq_m, only: assert_eq
-    use assert_m, only: assert
-    use interpolation, only: locate
-
-    real, intent(in):: vs(:, :) ! values of steps on the source grid
-    ! (Step "is" is between "xs(is)" and "xs(is + 1)".)
-
-    real, intent(in):: xs(:)
-    ! (edges of steps on the source grid, in strictly increasing order)
-
-    real, intent(in):: xt(:)
-    ! (edges of cells of the target grid, in strictly increasing order)
-
-    real vt(size(xt) - 1, size(vs, 2)) ! average values on the target grid
-    ! (Cell "it" is between "xt(it)" and "xt(it + 1)".)
-
-    ! Variables local to the procedure:
-    integer is, it, ns, nt
-    real left_edge
-
-    !---------------------------------------------
-
-    ns = assert_eq(size(vs, 1), size(xs) - 1, "regr12_step_av ns")
-    nt = size(xt) - 1
-
-    ! Quick check on sort order:
-    call assert(xs(1) < xs(2), "regr12_step_av xs bad order")
-    call assert(xt(1) < xt(2), "regr12_step_av xt bad order")
-
-    call assert(xs(1) <= xt(1) .and. xt(nt + 1) <= xs(ns + 1), &
-         "regr12_step_av extrapolation")
-
-    is = locate(xs, xt(1)) ! 1 <= is <= ns, because we forbid extrapolation
-    do it = 1, nt
-       ! 1 <= is <= ns
-       ! xs(is) <= xt(it) < xs(is + 1)
-       ! Compute "vt(it, :)":
-       left_edge = xt(it)
-       vt(it, :) = 0.
-       do while (xs(is + 1) < xt(it + 1))
-          ! 1 <= is <= ns - 1
-          vt(it, :) = vt(it, :) + (xs(is + 1) - left_edge) * vs(is, :)
-          is = is + 1
-          left_edge = xs(is)
-       end do
-       ! 1 <= is <= ns
-       vt(it, :) = (vt(it, :) + (xt(it + 1) - left_edge) * vs(is, :)) &
-            / (xt(it + 1) - xt(it))
-       if (xs(is + 1) == xt(it + 1)) is = is + 1
-       ! 1 <= is <= ns .or. it == nt
-    end do
-
-  end function regr12_step_av
-
-  !********************************************
-
-  function regr13_step_av(vs, xs, xt) result(vt)
-
-    ! "vs" has rank 3.
-
-    use assert_eq_m, only: assert_eq
-    use assert_m, only: assert
-    use interpolation, only: locate
-
-    real, intent(in):: vs(:, :, :) ! values of steps on the source grid
-    ! (Step "is" is between "xs(is)" and "xs(is + 1)".)
-
-    real, intent(in):: xs(:)
-    ! (edges of steps on the source grid, in strictly increasing order)
-
-    real, intent(in):: xt(:)
-    ! (edges of cells of the target grid, in strictly increasing order)
-
-    real vt(size(xt) - 1, size(vs, 2), size(vs, 3)) 
-    ! (average values on the target grid)
-    ! (Cell "it" is between "xt(it)" and "xt(it + 1)".)
-
-    ! Variables local to the procedure:
-    integer is, it, ns, nt
-    real left_edge
-
-    !---------------------------------------------
-
-    ns = assert_eq(size(vs, 1), size(xs) - 1, "regr13_step_av ns")
-    nt = size(xt) - 1
-
-    ! Quick check on sort order:
-    call assert(xs(1) < xs(2), "regr13_step_av xs bad order")
-    call assert(xt(1) < xt(2), "regr13_step_av xt bad order")
-
-    call assert(xs(1) <= xt(1) .and. xt(nt + 1) <= xs(ns + 1), &
-         "regr13_step_av extrapolation")
-
-    is = locate(xs, xt(1)) ! 1 <= is <= ns, because we forbid extrapolation
-    do it = 1, nt
-       ! 1 <= is <= ns
-       ! xs(is) <= xt(it) < xs(is + 1)
-       ! Compute "vt(it, :, :)":
-       left_edge = xt(it)
-       vt(it, :, :) = 0.
-       do while (xs(is + 1) < xt(it + 1))
-          ! 1 <= is <= ns - 1
-          vt(it, :, :) = vt(it, :, :) + (xs(is + 1) - left_edge) * vs(is, :, :)
-          is = is + 1
-          left_edge = xs(is)
-       end do
-       ! 1 <= is <= ns
-       vt(it, :, :) = (vt(it, :, :) &
-            + (xt(it + 1) - left_edge) * vs(is, :, :)) / (xt(it + 1) - xt(it))
-       if (xs(is + 1) == xt(it + 1)) is = is + 1
-       ! 1 <= is <= ns .or. it == nt
-    end do
-
-  end function regr13_step_av
-
-  !********************************************
-
-  function regr14_step_av(vs, xs, xt) result(vt)
-
-    ! "vs" has rank 4.
-
-    use assert_eq_m, only: assert_eq
-    use assert_m, only: assert
-    use interpolation, only: locate
-
-    real, intent(in):: vs(:, :, :, :) ! values of steps on the source grid
-    ! (Step "is" is between "xs(is)" and "xs(is + 1)".)
-
-    real, intent(in):: xs(:)
-    ! (edges of steps on the source grid, in strictly increasing order)
-
-    real, intent(in):: xt(:)
-    ! (edges of cells of the target grid, in strictly increasing order)
-
-    real vt(size(xt) - 1, size(vs, 2), size(vs, 3), size(vs, 4))
-    ! (average values on the target grid)
-    ! (Cell "it" is between "xt(it)" and "xt(it + 1)".)
-
-    ! Variables local to the procedure:
-    integer is, it, ns, nt
-    real left_edge
-
-    !---------------------------------------------
-
-    ns = assert_eq(size(vs, 1), size(xs) - 1, "regr14_step_av ns")
-    nt = size(xt) - 1
-
-    ! Quick check on sort order:
-    call assert(xs(1) < xs(2), "regr14_step_av xs bad order")
-    call assert(xt(1) < xt(2), "regr14_step_av xt bad order")
-
-    call assert(xs(1) <= xt(1) .and. xt(nt + 1) <= xs(ns + 1), &
-         "regr14_step_av extrapolation")
-
-    is = locate(xs, xt(1)) ! 1 <= is <= ns, because we forbid extrapolation
-    do it = 1, nt
-       ! 1 <= is <= ns
-       ! xs(is) <= xt(it) < xs(is + 1)
-       ! Compute "vt(it, :, :, :)":
-       left_edge = xt(it)
-       vt(it, :, :, :) = 0.
-       do while (xs(is + 1) < xt(it + 1))
-          ! 1 <= is <= ns - 1
-          vt(it, :, :, :) = vt(it, :, :, :) + (xs(is + 1) - left_edge) &
-               * vs(is, :, :, :)
-          is = is + 1
-          left_edge = xs(is)
-       end do
-       ! 1 <= is <= ns
-       vt(it, :, :, :) = (vt(it, :, :, :) + (xt(it + 1) - left_edge) &
-            * vs(is, :, :, :)) / (xt(it + 1) - xt(it))
-       if (xs(is + 1) == xt(it + 1)) is = is + 1
-       ! 1 <= is <= ns .or. it == nt
-    end do
-
-  end function regr14_step_av
-
-end module regr1_step_av_m
Index: /LMDZ5/branches/testing/libf/misc/slopes_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/misc/slopes_m.F90	(revision 2471)
+++ /LMDZ5/branches/testing/libf/misc/slopes_m.F90	(revision 2471)
@@ -0,0 +1,226 @@
+module slopes_m
+
+  ! Author: Lionel GUEZ
+
+  implicit none
+
+  interface slopes
+     ! This generic function computes second order slopes with Van
+     ! Leer slope-limiting, given cell averages. Reference: Dukowicz,
+     ! 1987, SIAM Journal on Scientific and Statistical Computing, 8,
+     ! 305.
+
+     ! The only difference between the specific functions is the rank
+     ! of the first argument and the equal rank of the result.
+
+     ! real, intent(in), rank >= 1:: f ! (n, ...) cell averages, n must be >= 1
+     ! real, intent(in):: x(:) ! (n + 1) cell edges
+     ! real slopes, same shape as f ! (n, ...)
+
+     module procedure slopes1, slopes2, slopes3, slopes4
+  end interface
+
+  private
+  public slopes
+
+contains
+
+  pure function slopes1(f, x)
+
+    real, intent(in):: f(:)
+    real, intent(in):: x(:)
+    real slopes1(size(f))
+
+    ! Local:
+    integer n, i
+    real xc(size(f)) ! (n) cell centers
+    real h
+
+    !------------------------------------------------------
+
+    n = size(f)
+    forall (i = 1:n) xc(i) = (x(i) + x(i + 1)) / 2.
+    slopes1(1) = 0.
+    slopes1(n) = 0.
+
+    do i = 2, n - 1
+       if (f(i) >= max(f(i - 1), f(i + 1)) .or. f(i) &
+            <= min(f(i - 1), f(i + 1))) then
+          ! Local extremum
+          slopes1(i) = 0.
+       else
+          ! (f(i - 1), f(i), f(i + 1)) strictly monotonous
+
+          ! Second order slope:
+          slopes1(i) = (f(i + 1) - f(i - 1)) / (xc(i + 1) - xc(i - 1))
+
+          ! Slope limitation:
+          h = abs(x(i + 1) - xc(i))
+          slopes1(i) = sign(min(abs(slopes1(i)), abs(f(i + 1) - f(i)) / h, &
+               abs(f(i) - f(i - 1)) / h), slopes1(i))
+       end if
+    end do
+
+  end function slopes1
+
+  !*************************************************************
+
+  pure function slopes2(f, x)
+
+    real, intent(in):: f(:, :)
+    real, intent(in):: x(:)
+    real slopes2(size(f, 1), size(f, 2))
+
+    ! Local:
+    integer n, i, j
+    real xc(size(f, 1)) ! (n) cell centers
+    real h(2:size(f, 1) - 1), delta_xc(2:size(f, 1) - 1) ! (2:n - 1)
+
+    !------------------------------------------------------
+
+    n = size(f, 1)
+    forall (i = 1:n) xc(i) = (x(i) + x(i + 1)) / 2.
+
+    forall (i = 2:n - 1) 
+       h(i) = abs(x(i + 1) - xc(i))
+       delta_xc(i) = xc(i + 1) - xc(i - 1)
+    end forall
+
+    do j = 1, size(f, 2)
+       slopes2(1, j) = 0.
+
+       do i = 2, n - 1
+          if (f(i, j) >= max(f(i - 1, j), f(i + 1, j)) .or. &
+               f(i, j) <= min(f(i - 1, j), f(i + 1, j))) then
+             ! Local extremum
+             slopes2(i, j) = 0.
+          else
+             ! (f(i - 1, j), f(i, j), f(i + 1, j))
+             ! strictly monotonous
+
+             ! Second order slope:
+             slopes2(i, j) = (f(i + 1, j) - f(i - 1, j)) / delta_xc(i)
+
+             ! Slope limitation:
+             slopes2(i, j) = sign(min(abs(slopes2(i, j)), &
+                  abs(f(i + 1, j) - f(i, j)) / h(i), &
+                  abs(f(i, j) - f(i - 1, j)) / h(i)), slopes2(i, j))
+          end if
+       end do
+
+       slopes2(n, j) = 0.
+    end do
+
+  end function slopes2
+
+  !*************************************************************
+
+  pure function slopes3(f, x)
+
+    real, intent(in):: f(:, :, :)
+    real, intent(in):: x(:)
+    real slopes3(size(f, 1), size(f, 2), size(f, 3))
+
+    ! Local:
+    integer n, i, j, k
+    real xc(size(f, 1)) ! (n) cell centers
+    real h(2:size(f, 1) - 1), delta_xc(2:size(f, 1) - 1) ! (2:n - 1)
+
+    !------------------------------------------------------
+
+    n = size(f, 1)
+    forall (i = 1:n) xc(i) = (x(i) + x(i + 1)) / 2.
+
+    forall (i = 2:n - 1) 
+       h(i) = abs(x(i + 1) - xc(i))
+       delta_xc(i) = xc(i + 1) - xc(i - 1)
+    end forall
+
+    do k = 1, size(f, 3)
+       do j = 1, size(f, 2)
+          slopes3(1, j, k) = 0.
+
+          do i = 2, n - 1
+             if (f(i, j, k) >= max(f(i - 1, j, k), f(i + 1, j, k)) .or. &
+                  f(i, j, k) <= min(f(i - 1, j, k), f(i + 1, j, k))) then
+                ! Local extremum
+                slopes3(i, j, k) = 0.
+             else
+                ! (f(i - 1, j, k), f(i, j, k), f(i + 1, j, k))
+                ! strictly monotonous
+
+                ! Second order slope:
+                slopes3(i, j, k) = (f(i + 1, j, k) - f(i - 1, j, k)) &
+                     / delta_xc(i)
+
+                ! Slope limitation:
+                slopes3(i, j, k) = sign(min(abs(slopes3(i, j, k)), &
+                     abs(f(i + 1, j, k) - f(i, j, k)) / h(i), &
+                     abs(f(i, j, k) - f(i - 1, j, k)) / h(i)), slopes3(i, j, k))
+             end if
+          end do
+
+          slopes3(n, j, k) = 0.
+       end do
+    end do
+
+  end function slopes3
+
+  !*************************************************************
+
+  pure function slopes4(f, x)
+
+    real, intent(in):: f(:, :, :, :)
+    real, intent(in):: x(:)
+    real slopes4(size(f, 1), size(f, 2), size(f, 3), size(f, 4))
+
+    ! Local:
+    integer n, i, j, k, l
+    real xc(size(f, 1)) ! (n) cell centers
+    real h(2:size(f, 1) - 1), delta_xc(2:size(f, 1) - 1) ! (2:n - 1)
+
+    !------------------------------------------------------
+
+    n = size(f, 1)
+    forall (i = 1:n) xc(i) = (x(i) + x(i + 1)) / 2.
+
+    forall (i = 2:n - 1) 
+       h(i) = abs(x(i + 1) - xc(i))
+       delta_xc(i) = xc(i + 1) - xc(i - 1)
+    end forall
+
+    do l = 1, size(f, 4)
+       do k = 1, size(f, 3)
+          do j = 1, size(f, 2)
+             slopes4(1, j, k, l) = 0.
+
+             do i = 2, n - 1
+                if (f(i, j, k, l) >= max(f(i - 1, j, k, l), f(i + 1, j, k, l)) &
+                     .or. f(i, j, k, l) &
+                     <= min(f(i - 1, j, k, l), f(i + 1, j, k, l))) then
+                   ! Local extremum
+                   slopes4(i, j, k, l) = 0.
+                else
+                   ! (f(i - 1, j, k, l), f(i, j, k, l), f(i + 1, j, k, l))
+                   ! strictly monotonous
+
+                   ! Second order slope:
+                   slopes4(i, j, k, l) = (f(i + 1, j, k, l) &
+                        - f(i - 1, j, k, l)) / delta_xc(i)
+
+                   ! Slope limitation:
+                   slopes4(i, j, k, l) = sign(min(abs(slopes4(i, j, k, l)), &
+                        abs(f(i + 1, j, k, l) - f(i, j, k, l)) / h(i), &
+                        abs(f(i, j, k, l) - f(i - 1, j, k, l)) / h(i)), &
+                        slopes4(i, j, k, l))
+                end if
+             end do
+
+             slopes4(n, j, k, l) = 0.
+          end do
+       end do
+    end do
+
+  end function slopes4
+
+end module slopes_m
Index: /LMDZ5/branches/testing/libf/obsolete/LIST.txt
===================================================================
--- /LMDZ5/branches/testing/libf/obsolete/LIST.txt	(revision 2470)
+++ /LMDZ5/branches/testing/libf/obsolete/LIST.txt	(revision 2471)
@@ -6,2 +6,3 @@
 phylmd/mkstat.F90             2320
 phylmd/inistats.F90           2320
+misc/regr1_step_av_m.F90      2439
Index: /LMDZ5/branches/testing/libf/obsolete/regr1_step_av_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/obsolete/regr1_step_av_m.F90	(revision 2471)
+++ /LMDZ5/branches/testing/libf/obsolete/regr1_step_av_m.F90	(revision 2471)
@@ -0,0 +1,268 @@
+! $Id$
+module regr1_step_av_m
+
+  ! Author: Lionel GUEZ
+
+  implicit none
+
+  interface regr1_step_av
+
+     ! Each procedure regrids a step function by averaging it.
+     ! The regridding operation is done on the first dimension of the
+     ! input array.
+     ! Source grid contains edges of steps.
+     ! Target grid contains positions of cell edges.
+     ! The target grid should be included in the source grid: no
+     ! extrapolation is allowed.
+     ! The difference between the procedures is the rank of the first argument.
+
+     module procedure regr11_step_av, regr12_step_av, regr13_step_av, &
+          regr14_step_av
+  end interface
+
+  private
+  public regr1_step_av
+
+contains
+
+  function regr11_step_av(vs, xs, xt) result(vt)
+
+    ! "vs" has rank 1.
+
+    use assert_eq_m, only: assert_eq
+    use assert_m, only: assert
+    use interpolation, only: locate
+
+    real, intent(in):: vs(:) ! values of steps on the source grid
+    ! (Step "is" is between "xs(is)" and "xs(is + 1)".)
+
+    real, intent(in):: xs(:)
+    ! (edges of of steps on the source grid, in strictly increasing order)
+
+    real, intent(in):: xt(:)
+    ! (edges of cells of the target grid, in strictly increasing order)
+
+    real vt(size(xt) - 1) ! average values on the target grid
+    ! (Cell "it" is between "xt(it)" and "xt(it + 1)".)
+
+    ! Variables local to the procedure:
+    integer is, it, ns, nt
+    real left_edge
+
+    !---------------------------------------------
+
+    ns = assert_eq(size(vs), size(xs) - 1, "regr11_step_av ns")
+    nt = size(xt) - 1
+    ! Quick check on sort order:
+    call assert(xs(1) < xs(2), "regr11_step_av xs bad order")
+    call assert(xt(1) < xt(2), "regr11_step_av xt bad order")
+
+    call assert(xs(1) <= xt(1) .and. xt(nt + 1) <= xs(ns + 1), &
+         "regr11_step_av extrapolation")
+
+    is = locate(xs, xt(1)) ! 1 <= is <= ns, because we forbid extrapolation
+    do it = 1, nt
+       ! 1 <= is <= ns
+       ! xs(is) <= xt(it) < xs(is + 1)
+       ! Compute "vt(it)":
+       left_edge = xt(it)
+       vt(it) = 0.
+       do while (xs(is + 1) < xt(it + 1))
+          ! 1 <= is <= ns - 1
+          vt(it) = vt(it) + (xs(is + 1) - left_edge) * vs(is)
+          is = is + 1
+          left_edge = xs(is)
+       end do
+       ! 1 <= is <= ns
+       vt(it) = (vt(it) + (xt(it + 1) - left_edge) * vs(is)) &
+            / (xt(it + 1) - xt(it))
+       if (xs(is + 1) == xt(it + 1)) is = is + 1
+       ! 1 <= is <= ns .or. it == nt
+    end do
+
+  end function regr11_step_av
+
+  !********************************************
+
+  function regr12_step_av(vs, xs, xt) result(vt)
+
+    ! "vs" has rank 2.
+
+    use assert_eq_m, only: assert_eq
+    use assert_m, only: assert
+    use interpolation, only: locate
+
+    real, intent(in):: vs(:, :) ! values of steps on the source grid
+    ! (Step "is" is between "xs(is)" and "xs(is + 1)".)
+
+    real, intent(in):: xs(:)
+    ! (edges of steps on the source grid, in strictly increasing order)
+
+    real, intent(in):: xt(:)
+    ! (edges of cells of the target grid, in strictly increasing order)
+
+    real vt(size(xt) - 1, size(vs, 2)) ! average values on the target grid
+    ! (Cell "it" is between "xt(it)" and "xt(it + 1)".)
+
+    ! Variables local to the procedure:
+    integer is, it, ns, nt
+    real left_edge
+
+    !---------------------------------------------
+
+    ns = assert_eq(size(vs, 1), size(xs) - 1, "regr12_step_av ns")
+    nt = size(xt) - 1
+
+    ! Quick check on sort order:
+    call assert(xs(1) < xs(2), "regr12_step_av xs bad order")
+    call assert(xt(1) < xt(2), "regr12_step_av xt bad order")
+
+    call assert(xs(1) <= xt(1) .and. xt(nt + 1) <= xs(ns + 1), &
+         "regr12_step_av extrapolation")
+
+    is = locate(xs, xt(1)) ! 1 <= is <= ns, because we forbid extrapolation
+    do it = 1, nt
+       ! 1 <= is <= ns
+       ! xs(is) <= xt(it) < xs(is + 1)
+       ! Compute "vt(it, :)":
+       left_edge = xt(it)
+       vt(it, :) = 0.
+       do while (xs(is + 1) < xt(it + 1))
+          ! 1 <= is <= ns - 1
+          vt(it, :) = vt(it, :) + (xs(is + 1) - left_edge) * vs(is, :)
+          is = is + 1
+          left_edge = xs(is)
+       end do
+       ! 1 <= is <= ns
+       vt(it, :) = (vt(it, :) + (xt(it + 1) - left_edge) * vs(is, :)) &
+            / (xt(it + 1) - xt(it))
+       if (xs(is + 1) == xt(it + 1)) is = is + 1
+       ! 1 <= is <= ns .or. it == nt
+    end do
+
+  end function regr12_step_av
+
+  !********************************************
+
+  function regr13_step_av(vs, xs, xt) result(vt)
+
+    ! "vs" has rank 3.
+
+    use assert_eq_m, only: assert_eq
+    use assert_m, only: assert
+    use interpolation, only: locate
+
+    real, intent(in):: vs(:, :, :) ! values of steps on the source grid
+    ! (Step "is" is between "xs(is)" and "xs(is + 1)".)
+
+    real, intent(in):: xs(:)
+    ! (edges of steps on the source grid, in strictly increasing order)
+
+    real, intent(in):: xt(:)
+    ! (edges of cells of the target grid, in strictly increasing order)
+
+    real vt(size(xt) - 1, size(vs, 2), size(vs, 3)) 
+    ! (average values on the target grid)
+    ! (Cell "it" is between "xt(it)" and "xt(it + 1)".)
+
+    ! Variables local to the procedure:
+    integer is, it, ns, nt
+    real left_edge
+
+    !---------------------------------------------
+
+    ns = assert_eq(size(vs, 1), size(xs) - 1, "regr13_step_av ns")
+    nt = size(xt) - 1
+
+    ! Quick check on sort order:
+    call assert(xs(1) < xs(2), "regr13_step_av xs bad order")
+    call assert(xt(1) < xt(2), "regr13_step_av xt bad order")
+
+    call assert(xs(1) <= xt(1) .and. xt(nt + 1) <= xs(ns + 1), &
+         "regr13_step_av extrapolation")
+
+    is = locate(xs, xt(1)) ! 1 <= is <= ns, because we forbid extrapolation
+    do it = 1, nt
+       ! 1 <= is <= ns
+       ! xs(is) <= xt(it) < xs(is + 1)
+       ! Compute "vt(it, :, :)":
+       left_edge = xt(it)
+       vt(it, :, :) = 0.
+       do while (xs(is + 1) < xt(it + 1))
+          ! 1 <= is <= ns - 1
+          vt(it, :, :) = vt(it, :, :) + (xs(is + 1) - left_edge) * vs(is, :, :)
+          is = is + 1
+          left_edge = xs(is)
+       end do
+       ! 1 <= is <= ns
+       vt(it, :, :) = (vt(it, :, :) &
+            + (xt(it + 1) - left_edge) * vs(is, :, :)) / (xt(it + 1) - xt(it))
+       if (xs(is + 1) == xt(it + 1)) is = is + 1
+       ! 1 <= is <= ns .or. it == nt
+    end do
+
+  end function regr13_step_av
+
+  !********************************************
+
+  function regr14_step_av(vs, xs, xt) result(vt)
+
+    ! "vs" has rank 4.
+
+    use assert_eq_m, only: assert_eq
+    use assert_m, only: assert
+    use interpolation, only: locate
+
+    real, intent(in):: vs(:, :, :, :) ! values of steps on the source grid
+    ! (Step "is" is between "xs(is)" and "xs(is + 1)".)
+
+    real, intent(in):: xs(:)
+    ! (edges of steps on the source grid, in strictly increasing order)
+
+    real, intent(in):: xt(:)
+    ! (edges of cells of the target grid, in strictly increasing order)
+
+    real vt(size(xt) - 1, size(vs, 2), size(vs, 3), size(vs, 4))
+    ! (average values on the target grid)
+    ! (Cell "it" is between "xt(it)" and "xt(it + 1)".)
+
+    ! Variables local to the procedure:
+    integer is, it, ns, nt
+    real left_edge
+
+    !---------------------------------------------
+
+    ns = assert_eq(size(vs, 1), size(xs) - 1, "regr14_step_av ns")
+    nt = size(xt) - 1
+
+    ! Quick check on sort order:
+    call assert(xs(1) < xs(2), "regr14_step_av xs bad order")
+    call assert(xt(1) < xt(2), "regr14_step_av xt bad order")
+
+    call assert(xs(1) <= xt(1) .and. xt(nt + 1) <= xs(ns + 1), &
+         "regr14_step_av extrapolation")
+
+    is = locate(xs, xt(1)) ! 1 <= is <= ns, because we forbid extrapolation
+    do it = 1, nt
+       ! 1 <= is <= ns
+       ! xs(is) <= xt(it) < xs(is + 1)
+       ! Compute "vt(it, :, :, :)":
+       left_edge = xt(it)
+       vt(it, :, :, :) = 0.
+       do while (xs(is + 1) < xt(it + 1))
+          ! 1 <= is <= ns - 1
+          vt(it, :, :, :) = vt(it, :, :, :) + (xs(is + 1) - left_edge) &
+               * vs(is, :, :, :)
+          is = is + 1
+          left_edge = xs(is)
+       end do
+       ! 1 <= is <= ns
+       vt(it, :, :, :) = (vt(it, :, :, :) + (xt(it + 1) - left_edge) &
+            * vs(is, :, :, :)) / (xt(it + 1) - xt(it))
+       if (xs(is + 1) == xt(it + 1)) is = is + 1
+       ! 1 <= is <= ns .or. it == nt
+    end do
+
+  end function regr14_step_av
+
+end module regr1_step_av_m
Index: /LMDZ5/branches/testing/libf/phylmd/cdrag.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/cdrag.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/cdrag.F90	(revision 2471)
@@ -114,4 +114,5 @@
   LOGICAL, PARAMETER    :: zxli=.FALSE. ! calcul des cdrags selon Laurent Li
   REAL, DIMENSION(klon) :: zcdn_m, zcdn_h         ! Drag coefficient in neutral conditions
+  REAL zzzcd
 !
 ! Fonctions thermodynamiques et fonctions d'instabilite
@@ -176,7 +177,8 @@
 
 
-! Coefficients CD neutres pour m et h
-     zcdn_m(i) = (CKAP/LOG(1.+zgeop1(i)/(RG*z0m(i))))**2
-     zcdn_h(i) = (CKAP/LOG(1.+zgeop1(i)/(RG*z0h(i))))**2
+! Coefficients CD neutres pour m et h : k^2/ln(z/z0) et k^2/(ln(z/z0)*ln(z/z0h))
+     zzzcd=CKAP/LOG(1.+zgeop1(i)/(RG*z0m(i)))
+     zcdn_m(i) = zzzcd*zzzcd
+     zcdn_h(i) = zzzcd*(CKAP/LOG(1.+zgeop1(i)/(RG*z0m(i))))
 
      IF (zri(i) .GT. 0.) THEN      ! situation stable
Index: /LMDZ5/branches/testing/libf/phylmd/compbl.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/compbl.h	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/compbl.h	(revision 2471)
@@ -2,9 +2,9 @@
       ! $Header$
       !
-!jyg+nrlmd<
-!!!      integer iflag_pbl
-!!!      common/compbl/iflag_pbl
-      integer iflag_pbl,iflag_pbl_split
-      common/compbl/iflag_pbl,iflag_pbl_split
-!>jyg+nrlmd
+!jyg+al1<
+!!      integer iflag_pbl,iflag_pbl_split
+!!      common/compbl/iflag_pbl,iflag_pbl_split
+      integer iflag_pbl, iflag_pbl_split, iflag_order2_sollw
+      common/compbl/iflag_pbl, iflag_pbl_split, iflag_order2_sollw
+!>jyg+al1
 !$OMP THREADPRIVATE(/compbl/)
Index: /LMDZ5/branches/testing/libf/phylmd/conf_phys_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/conf_phys_m.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/conf_phys_m.F90	(revision 2471)
@@ -179,4 +179,5 @@
     INTEGER,SAVE :: iflag_pbl_omp,lev_histhf_omp,lev_histday_omp,lev_histmth_omp
     INTEGER,SAVE :: iflag_pbl_split_omp
+    INTEGER,SAVE :: iflag_order2_sollw_omp
     Integer, save :: lev_histins_omp, lev_histLES_omp 
     INTEGER, SAVE :: lev_histdayNMC_omp
@@ -1287,4 +1288,12 @@
     call getin('iflag_pbl_split',iflag_pbl_split_omp)
     !
+    !Config Key  = iflag_order2_sollw
+    !Config Desc =
+    !Config Def  = 0
+    !Config Help =
+    !
+    iflag_order2_sollw_omp = 0
+    call getin('iflag_order2_sollw',iflag_order2_sollw_omp)
+    !
     !Config Key  = iflag_thermals
     !Config Desc =
@@ -1703,4 +1712,9 @@
     f_gust_wk_omp = 0.
     call getin('f_gust_wk',f_gust_wk_omp)
+    !
+    !Config Key  = iflag_z0_oce
+    !Config Desc = 0 (z0h=z0m), 1 (diff. equ. for z0h and z0m), -1 (z0m=z0h=z0min)
+    !Config Def  = 0   ! z0h = z0m
+    !Config Help =
     !
     iflag_z0_oce_omp=0
@@ -2025,4 +2039,5 @@
     iflag_pbl = iflag_pbl_omp
     iflag_pbl_split = iflag_pbl_split_omp
+    iflag_order2_sollw = iflag_order2_sollw_omp
     lev_histhf = lev_histhf_omp
     lev_histday = lev_histday_omp
@@ -2224,4 +2239,14 @@
        END IF
     END IF
+
+    ! Flag_aerosol cannot be to zero if we are in coupled mode for aerosol
+    IF (aerosol_couple .AND. flag_aerosol .eq. 0 ) THEN
+       CALL abort_physic('conf_phys', 'flag_aerosol cannot be to zero if aerosol_couple=y ', 1)
+    ENDIF
+
+    ! flag_aerosol need to be different to zero if ok_cdnc is activated
+    IF (ok_cdnc .AND. flag_aerosol .eq. 0) THEN
+       CALL abort_physic('conf_phys', 'flag_aerosol cannot be to zero if ok_cdnc is activated ', 1)
+    ENDIF
 
     ! ok_cdnc must be set to y if ok_aie is activated
@@ -2347,4 +2372,5 @@
     write(lunout,*)' iflag_pbl = ', iflag_pbl
     write(lunout,*)' iflag_pbl_split = ', iflag_pbl_split
+    write(lunout,*)' iflag_order2_sollw = ', iflag_order2_sollw
     write(lunout,*)' iflag_thermals = ', iflag_thermals
     write(lunout,*)' iflag_thermals_ed = ', iflag_thermals_ed
Index: /LMDZ5/branches/testing/libf/phylmd/cosp/cosp_output_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/cosp/cosp_output_mod.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/cosp/cosp_output_mod.F90	(revision 2471)
@@ -16,7 +16,8 @@
       INTEGER, DIMENSION(3), SAVE  :: cosp_nidfiles
 !$OMP THREADPRIVATE(cosp_outfilekeys, cosp_nidfiles)
-      INTEGER, DIMENSION(3), SAVE  :: nhoricosp,nvert,nvertmcosp,nvertcol,nvertisccp,nvertp,nverttemp,nvertmisr
+      INTEGER, DIMENSION(3), SAVE  :: nhoricosp,nvert,nvertmcosp,nvertcol,nvertbze, &
+                                      nvertsratio,nvertisccp,nvertp,nverttemp,nvertmisr
       REAL, DIMENSION(3), SAVE                :: zoutm_cosp
-!$OMP THREADPRIVATE(nhoricosp, nvert, nvertmcosp, nvertcol, nvertisccp, nvertp, zoutm_cosp, nverttemp, nvertmisr)
+!$OMP THREADPRIVATE(nhoricosp, nvert,nvertmcosp,nvertcol,nvertsratio,nvertbze,nvertisccp,nvertp,zoutm_cosp,nverttemp,nvertmisr)
       REAL, SAVE                   :: zdtimemoy_cosp
 !$OMP THREADPRIVATE(zdtimemoy_cosp) 
@@ -107,5 +108,7 @@
   TYPE(ctrl_outcosp), SAVE :: o_clcalipso2 = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), &
          "clcalipso2", "CALIPSO Cloud Fraction Undetected by CloudSat", "1", (/ ('', i=1, 3) /))
-
+  TYPE(ctrl_outcosp), SAVE :: o_cltlidarradar = ctrl_outcosp((/ .TRUE., .TRUE.,.TRUE. /), &          
+         "cltlidarradar", "Lidar and Radar Total Cloud Fraction", "%", (/ ('', i=1, 3) /))
+     
 ! ISCCP vars
   TYPE(ctrl_outcosp), SAVE :: o_sunlit = ctrl_outcosp((/ .TRUE., .TRUE., .TRUE. /), &
@@ -220,7 +223,9 @@
 
 !!! Variables locales
-  integer                  :: idayref, iff, ii
-  real                     :: zjulian,zjulian_start
-  real,dimension(Ncolumns) :: column_ax
+  integer                   :: idayref, iff, ii
+  real                      :: zjulian,zjulian_start
+  real,dimension(Ncolumns)  :: column_ax
+  real,dimension(2,SR_BINS) :: sratio_bounds
+  real,dimension(SR_BINS)   ::  sratio_ax
   CHARACTER(LEN=20), DIMENSION(3)  :: chfreq = (/ '1day', '1d', '3h' /)            
 
@@ -239,8 +244,23 @@
     ! Initialisations (Valeurs par defaut)
 
+!! Definition valeurs axes
     do ii=1,Ncolumns
       column_ax(ii) = real(ii)
     enddo
 
+!    do ii=1,DBZE_BINS
+!     dbze_ax(i) = CFAD_ZE_MIN + CFAD_ZE_WIDTH*(ii - 0.5)
+!    enddo
+
+!   sratio_bounds(2,:)=stlidar%srbval(:) ! srbval contains the upper
+!                                         limits from lmd_ipsl_stats.f90
+!   sratio_bounds(1,2:SR_BINS) = stlidar%srbval(1:SR_BINS-1)
+!   sratio_bounds(1,1)         = 0.0
+!   sratio_bounds(2,SR_BINS)   = 1.e5 ! This matches with Chepfer et al., JGR,
+!                                    ! 2009. However, it is not consistent 
+                                     ! with the upper limit in
+                                     ! lmd_ipsl_stats.f90, which is
+                                     ! LIDAR_UNDEF-1=998.999
+!    sratio_ax(:) = (sratio_bounds(1,:)+sratio_bounds(2,:))/2.0 
 
     cosp_outfilenames(1) = 'histmthCOSP'
@@ -303,4 +323,6 @@
    CALL wxios_add_vaxis("temp", LIDAR_NTEMP, LIDAR_PHASE_TEMP)
    CALL wxios_add_vaxis("cth16", MISR_N_CTH, MISR_CTH)
+!   CALL wxios_add_vaxis("dbze", DBZE_BINS, dbze_ax) 
+!   CALL wxios_add_vaxis("scatratio", SR_BINS, sratio_ax)
 #endif
    
@@ -343,4 +365,8 @@
       CALL histvert(cosp_nidfiles(iff),"temp","temperature","C",LIDAR_NTEMP,LIDAR_PHASE_TEMP,nverttemp(iff))                                       
       CALL histvert(cosp_nidfiles(iff),"cth16","altitude","m",MISR_N_CTH,MISR_CTH,nvertmisr(iff))                                                                                                  
+!      CALL histvert(cosp_nidfiles(iff),"dbze","equivalent_reflectivity_factor","dBZ",DBZE_BINS,dbze_ax,nvertbze(iff))
+     
+!      CALL histvert(cosp_nidfiles(iff),"scatratio","backscattering_ratio","1",SR_BINS,sratio_ax,nvertsratio(iff))
+     
 !!! Valeur indefinie en cas IOIPSL
      Cosp_fill_value=0.
Index: /LMDZ5/branches/testing/libf/phylmd/cosp/cosp_output_write_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/cosp/cosp_output_write_mod.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/cosp/cosp_output_write_mod.F90	(revision 2471)
@@ -209,4 +209,7 @@
                            stradar%lidar_only_freq_cloud = 0.0
    CALL histwrite3d_cosp(o_clcalipso2,stradar%lidar_only_freq_cloud,nvert)
+   where(stradar%radar_lidar_tcc == R_UNDEF) &
+                           stradar%radar_lidar_tcc = 0.0 
+   CALL histwrite2d_cosp(o_cltlidarradar,stradar%radar_lidar_tcc)
  endif
 
Index: /LMDZ5/branches/testing/libf/phylmd/dyn1d/1DUTILS.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/dyn1d/1DUTILS.h	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/dyn1d/1DUTILS.h	(revision 2471)
@@ -4344,5 +4344,5 @@
 !
    INTEGER k,i
-   REAL zx_qs, rh, tnew, d_rh
+   REAL zx_qs, rh, tnew, d_rh, rhnew
 
 ! Declaration des constantes et des fonctions thermodynamiques
@@ -4361,7 +4361,8 @@
         print *,'temp ',t
         print *,'hum ',q
+!
         DO k = 1,klev
          DO i = 1,klon
-!!           IF (paprs(i,1)-pplay(i,k) .GT. 10000.) THEN
+           IF (paprs(i,1)-pplay(i,k) .GT. 10000.) THEN
             IF (t(i,k).LT.RTT) THEN
                zx_qs = qsats(t(i,k))/(pplay(i,k))
@@ -4374,5 +4375,12 @@
             d_rh = 1./tau*(rh_targ(i,k)-rh)
 !
-            tnew = t(i,k)+d_t(i,k)
+            tnew = t(i,k)+d_t(i,k)*dtime
+!jyg<
+!   Formule pour q :
+!                         d_q = (1/tau) [rh_targ*qsat(T_new) - q] 
+!
+!  Cette formule remplace d_q = (1/tau) [rh_targ - rh] qsat(T_new)
+!   qui n'était pas correcte.
+!
             IF (tnew.LT.RTT) THEN
                zx_qs = qsats(tnew)/(pplay(i,k))
@@ -4380,9 +4388,11 @@
                zx_qs = qsatl(tnew)/(pplay(i,k))
             ENDIF
-            d_q(i,k) = d_q(i,k) + d_rh*zx_qs
-!
-            print *,' k,d_t,rh,d_rh,d_q ',    &
-                      k,d_t(i,k),rh,d_rh,d_q(i,k)
-!!           ENDIF
+!!            d_q(i,k) = d_q(i,k) + d_rh*zx_qs
+            d_q(i,k) = d_q(i,k) + (1./tau)*(rh_targ(i,k)*zx_qs - q(i,k))
+            rhnew = (q(i,k)+d_q(i,k)*dtime)/zx_qs
+!
+            print *,' k,d_t,rh,d_rh,rhnew,d_q ',    &
+                      k,d_t(i,k),rh,d_rh,rhnew,d_q(i,k)
+           ENDIF
 !
          ENDDO
Index: /LMDZ5/branches/testing/libf/phylmd/dyn1d/lmdz1d.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/dyn1d/lmdz1d.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/dyn1d/lmdz1d.F90	(revision 2471)
@@ -932,11 +932,10 @@
 !   Call physiq :
 !---------------------------------------------------------------------
-
        call physiq(ngrid,llm, &
-            firstcall,lastcall,timestep, &
-            plev,play,phi,phis,presnivs, &
-            u,v, rot, temp,q,omega2, &
-            du_phys,dv_phys,dt_phys,dq,dpsrf)
-        firstcall=.false.
+	            firstcall,lastcall,timestep, &
+	            plev,play,phi,phis,presnivs, &
+	            u,v, rot, temp,q,omega2, &
+	            du_phys,dv_phys,dt_phys,dq,dpsrf)
+	        firstcall=.false.
 
 !---------------------------------------------------------------------
Index: /LMDZ5/branches/testing/libf/phylmd/ini_paramLMDZ_phy.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/ini_paramLMDZ_phy.h	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/ini_paramLMDZ_phy.h	(revision 2471)
@@ -10,5 +10,5 @@
 !
        zstophy = pdtphys
-       zout = mth_len*un_jour
+       zout = -1
 !
        idayref = day_ref
@@ -33,20 +33,20 @@
                       "Excentricite","-", &
                       1,1,nhori, 1,1,1, -99, 32, &
-                      "ave", zstophy,zout)
+                      "ave(X)", zstophy,zout)
 !
        CALL histdef(nid_ctesGCM, "R_peri",  &
                       "Equinoxe","-", &
                       1,1,nhori, 1,1,1, -99, 32, &
-                      "ave", zstophy,zout)
+                      "ave(X)", zstophy,zout)
 !
        CALL histdef(nid_ctesGCM, "R_incl",  &
                       "Inclinaison","deg", &
                       1,1,nhori, 1,1,1, -99, 32, &
-                      "ave", zstophy,zout)
+                      "ave(X)", zstophy,zout)
 !
        CALL histdef(nid_ctesGCM, "solaire",  &
                       "Constante solaire","W/m2", &
                       1,1,nhori, 1,1,1, -99, 32, &
-                      "ave", zstophy,zout)
+                      "ave(X)", zstophy,zout)
 !
        CALL histdef(nid_ctesGCM, "co2_ppm",  &
@@ -75,54 +75,4 @@
                       "ave(X)", zstophy,zout)
 !
-       CALL histdef(nid_ctesGCM, "bils", &
-                      "Surface total heat flux", "W m-2", &
-                      1,1,nhori, 1,1,1, -99, 32, &
-                      "ave", zstophy,zout)
-!
-       CALL histdef(nid_ctesGCM, "evap", &
-                      "Evaporation", "kg m-2 s-1", &
-                      1,1,nhori, 1,1,1, -99, 32, &
-                      "ave", zstophy,zout)
-!
-       CALL histdef(nid_ctesGCM, "evap_land", &
-                      "Land evaporation", "kg m-2 s-1", &
-                      1,1,nhori, 1,1,1, -99, 32, &
-                      "ave", zstophy,zout)
-!
-       CALL histdef(nid_ctesGCM, "flat", &
-                      "Latent heat flux", "W m-2", &
-                      1,1,nhori, 1,1,1, -99, 32, &
-                      "ave", zstophy,zout)
-!
-       CALL histdef(nid_ctesGCM, "nettop0", &
-                      "Clear sky net downward radiatif flux at TOA",  &
-                      "W m-2", &
-                      1,1,nhori, 1,1,1, -99, 32, &
-                      "ave", zstophy,zout)
-!
-       CALL histdef(nid_ctesGCM, "nettop", &
-                      "Net downward radiatif flux at TOA", "W m-2", &
-                      1,1,nhori, 1,1,1, -99, 32, &
-                      "ave", zstophy,zout)
-!
-       CALL histdef(nid_ctesGCM, "precip", &
-                      "Total precipitation (liq+sol)", "kg m-2 s-1", &
-                      1,1,nhori, 1,1,1, -99, 32, &
-                      "ave", zstophy,zout)
-!
-       CALL histdef(nid_ctesGCM, "tsol", &
-                      "Surface temperature", "K", &
-                      1,1,nhori, 1,1,1, -99, 32, &
-                      "ave", zstophy,zout)
-!
-       CALL histdef(nid_ctesGCM, "t2m", &
-                      "Temperature at 2m", "K", &
-                      1,1,nhori, 1,1,1, -99, 32, &
-                      "ave", zstophy,zout)
-!
-       CALL histdef(nid_ctesGCM, "prw", &
-                      "Precipitable water", "kg m-2", &
-                      1,1,nhori, 1,1,1, -99, 32, &
-                      "ave", zstophy,zout) 
 !=================================================================
 !
Index: /LMDZ5/branches/testing/libf/phylmd/pbl_surface_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/pbl_surface_mod.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/pbl_surface_mod.F90	(revision 2471)
@@ -305,8 +305,8 @@
 
 !!! nrlmd+jyg le 02/05/2011 et le 20/02/2012
-!!    REAL, DIMENSION(klon,klev),   INTENT(IN)        :: t_x       ! Température hors poche froide
-!!    REAL, DIMENSION(klon,klev),   INTENT(IN)        :: t_w       ! Température dans la poches froide
+!!    REAL, DIMENSION(klon,klev),   INTENT(IN)        :: t_x       ! Temp\'erature hors poche froide
+!!    REAL, DIMENSION(klon,klev),   INTENT(IN)        :: t_w       ! Temp\'erature dans la poches froide
 !!    REAL, DIMENSION(klon,klev),   INTENT(IN)        :: q_x       ! 
-!!    REAL, DIMENSION(klon,klev),   INTENT(IN)        :: q_w       ! Pareil pour l'humidité
+!!    REAL, DIMENSION(klon,klev),   INTENT(IN)        :: q_w       ! Pareil pour l'humidit\'e
     REAL, DIMENSION(klon,klev),   INTENT(IN)        :: wake_dlt  !temperature difference between (w) and (x) (K)
     REAL, DIMENSION(klon,klev),   INTENT(IN)        :: wake_dlq  !humidity difference between (w) and (x) (K)
@@ -522,4 +522,5 @@
 !albedo SB <<<
     REAL, DIMENSION(klon)              :: ztsol
+    REAL, DIMENSION(klon)              :: meansqT ! mean square deviation of subsurface temperatures
     REAL, DIMENSION(klon)              :: alb_m  ! mean albedo for whole SW interval
     REAL, DIMENSION(klon,klev)         :: y_d_t, y_d_q, y_d_t_diss
@@ -679,5 +680,5 @@
 
 !!! jyg le 25/03/2013
-!!    Variables intermediaires pour le raccord des deux colonnes à la surface
+!!    Variables intermediaires pour le raccord des deux colonnes \`a la surface
     REAL   ::   dd_Ch
     REAL   ::   dd_Cm
@@ -1106,4 +1107,22 @@
        ENDDO
     ENDDO
+!
+!<al1: second order corrections
+!- net = dwn -up; up=sig( T4 + 4sum%T3T' + 6sum%T2T'2 +...)
+   IF (iflag_order2_sollw == 1) THEN
+    meansqT(:) = 0. ! as working buffer
+    DO nsrf = 1, nbsrf
+     DO i = 1, klon
+      meansqT(i) = meansqT(i)+(ts(i,nsrf)-ztsol(i))**2 *pctsrf(i,nsrf)
+     END DO
+    END DO
+    DO nsrf = 1, nbsrf
+     DO i = 1, klon
+      sollw(i,nsrf) = sollw(i,nsrf) &
+                + 6.0*RSIGMA*ztsol(i)**2 *(meansqT(i)-(ztsol(i)-ts(i,nsrf))**2)
+     ENDDO
+    ENDDO
+   ENDIF   ! iflag_order2_sollw == 1
+!>al1
 
 !****************************************************************************************
@@ -1572,5 +1591,5 @@
 
 !!! nrlmd le 13/06/2011
-!----- On finit le calcul des coefficients d'échange:on multiplie le cdrag par le module du vent et la densité dans la première couche 
+!----- On finit le calcul des coefficients d'\'echange:on multiplie le cdrag par le module du vent et la densit\'e dans la premi\`ere couche 
 !          Kech_h_x(j) = ycdragh_x(j) * &
 !             (1.0+SQRT(yu_x(j,1)**2+yv_x(j,1)**2)) * &
@@ -1664,5 +1683,5 @@
        ENDIF
 !
-! Calcul des coef A, B équivalents dans la couche 1
+! Calcul des coef A, B \'equivalents dans la couche 1
 !
        AcoefH(j) = AcoefH_x(j) + ywake_s(j)*(Kech_H_wp(j)/Kech_Hp(j))*dd_AH
@@ -1684,10 +1703,10 @@
 
 !
-! Calcul des cdrag équivalents dans la couche 
+! Calcul des cdrag \'equivalents dans la couche 
 !
        ycdragm(j) = ycdragm_x(j) + ywake_s(j)*dd_CM
        ycdragh(j) = ycdragh_x(j) + ywake_s(j)*dd_CH
 !
-! Calcul de T, q, u et v équivalents dans la couche 1
+! Calcul de T, q, u et v \'equivalents dans la couche 1
        yt(j,1) = yt_x(j,1) + ywake_s(j)*(Kech_h_w(j)/Kech_h(j))*dd_t
        yq(j,1) = yq_x(j,1) + ywake_s(j)*(Kech_h_w(j)/Kech_h(j))*dd_q
@@ -1915,6 +1934,6 @@
 
           DO j = 1, knon
-            yt1_new=(1./RCPD)*(AcoefH(j)+BcoefH(j)*yfluxsens(j)*dtime)
-            ytsurf_new(j)=yt1_new-yfluxsens(j)/(Kech_h(j)*RCPD)
+            yt1_new=(1./RCPD)*(AcoefH(j)+BcoefH(j)*y_flux_t1(j)*dtime)
+            ytsurf_new(j)=yt1_new-y_flux_t1(j)/(Kech_h(j)*RCPD)
           ENDDO
 
@@ -1993,5 +2012,5 @@
 !!jyg!!         ENDIF
 !!jyg!!
-!!jyg!!!-----Calcul de ybeta (evap_réelle/evap_potentielle)
+!!jyg!!!-----Calcul de ybeta (evap_r\'eelle/evap_potentielle)
 !!jyg!!!!!!! jyg le 23/02/2012
 !!jyg!!!!!!!
@@ -2811,4 +2830,16 @@
        END DO
     END DO
+!
+!<al1 order 2 correction to zxtsol, for radiation computations (main atm effect of Ts)
+   IF (iflag_order2_sollw == 1) THEN
+    meansqT(:) = 0. ! as working buffer
+    DO nsrf = 1, nbsrf
+     DO i = 1, klon
+      meansqT(i) = meansqT(i)+(ts(i,nsrf)-zxtsol(i))**2 *pctsrf(i,nsrf)
+     END DO
+    END DO
+    zxtsol(:) = zxtsol(:)+1.5*meansqT(:)/zxtsol(:)
+   ENDIF   ! iflag_order2_sollw == 1
+!>al1
           
 !!! jyg le 07/02/2012
Index: /LMDZ5/branches/testing/libf/phylmd/physiq_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/physiq_mod.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/physiq_mod.F90	(revision 2471)
@@ -451,5 +451,5 @@
   real w0(klon)                                          ! Vitesse des thermiques au LCL
   real w_conv(klon)                                      ! Vitesse verticale de grande \'echelle au LCL
-  real tke0(klon,klev+1)                                 ! TKE au dÃ©but du pas de temps
+  real tke0(klon,klev+1)                                 ! TKE au d\'ebut du pas de temps
   real therm_tke_max0(klon)                              ! TKE dans les thermiques au LCL 
   real env_tke_max0(klon)                                ! TKE dans l'environnement au LCL 
@@ -1063,5 +1063,14 @@
         CALL getin_p('config_inca',config_inca)
 
+     ELSE 
+        config_inca='none' ! default
      END IF
+     
+     IF (aerosol_couple .AND. (config_inca /= "aero" .AND. config_inca /= "aeNP ")) THEN
+        abort_message = 'if aerosol_couple is activated, config_inca need to be aero or aeNP'
+        CALL abort_physic (modname,abort_message,1)
+     ENDIF
+
+
 
      rnebcon0(:,:) = 0.0
@@ -1366,5 +1375,5 @@
              cell_area, &
              latitude_deg, &
-             longitude_de, &
+             longitude_deg, &
              presnivs, &
              calday, &
@@ -1759,5 +1768,5 @@
         else
 
-!CR: on rÃ©-Ã©vapore eau liquide et glace
+!CR: on r\'e-\'evapore eau liquide et glace
 
 !        zdelta = MAX(0.,SIGN(1.,RTT-t_seri(i,k)))
@@ -1771,5 +1780,5 @@
         q_seri(i,k) = q_seri(i,k) + zb
         ql_seri(i,k) = 0.0
-!on Ã©vapore la glace
+!on \'evapore la glace
         qs_seri(i,k) = 0.0
         d_t_eva(i,k) = za
@@ -2094,5 +2103,6 @@
            zx_qs  = zx_qs*zcor
         ELSE
-           IF (zx_t.LT.t_coup) THEN
+!!           IF (zx_t.LT.t_coup) THEN             !jyg
+           IF (zx_t.LT.rtt) THEN                  !jyg
               zx_qs = qsats(zx_t)/pplay(i,k)
            ELSE
@@ -2581,5 +2591,5 @@
   !
   !!! nrlmd le 22/03/2011---Si on met les poches hors des thermiques il faut rajouter cette
-  !------------------------- tendance calculée hors des poches froides
+  !------------------------- tendance calcul\'ee hors des poches froides
   !
   if (iflag_wake>=1) then
@@ -2645,5 +2655,5 @@
            DO i=1,klon
               IF (rneb(i,k)==0.) THEN
-! On ne tient compte des tendances qu'en dehors des nuages (c'est ï¿½|  dire
+! On ne tient compte des tendances qu'en dehors des nuages (c'est-\`a-dire
 ! a priri dans une region ou l'eau se reevapore).
                 dt_dwn(i,k)= dt_dwn(i,k)+ &
@@ -2796,5 +2806,5 @@
          IF (mod(iflag_pbl_split/2,2) .EQ. 1) THEN
 !  Si les thermiques ne sont presents que hors des poches, la tendance moyenne
-!  associée doit etre multipliee par la fraction surfacique qu'ils couvrent.
+!  associ\'ee doit etre multipliee par la fraction surfacique qu'ils couvrent.
           DO k=1,klev
            DO i=1,klon
@@ -3362,9 +3372,9 @@
         zx_t = t_seri(i,k)
         IF (thermcep) THEN
-           if (iflag_ice_thermo.eq.0) then 
+!!           if (iflag_ice_thermo.eq.0) then                 !jyg
            zdelta = MAX(0.,SIGN(1.,rtt-zx_t))
-           else
-           zdelta = MAX(0.,SIGN(1.,t_glace_min-zx_t))
-           endif
+!!           else                                            !jyg
+!!           zdelta = MAX(0.,SIGN(1.,t_glace_min-zx_t))      !jyg
+!!           endif                                           !jyg
            zx_qs  = r2es * FOEEW(zx_t,zdelta)/pplay(i,k)
            zx_qs  = MIN(0.5,zx_qs)
@@ -3372,5 +3382,6 @@
            zx_qs  = zx_qs*zcor
         ELSE
-           IF (zx_t.LT.t_coup) THEN
+!!           IF (zx_t.LT.t_coup) THEN             !jyg
+           IF (zx_t.LT.rtt) THEN                  !jyg
               zx_qs = qsats(zx_t)/pplay(i,k)
            ELSE
Index: /LMDZ5/branches/testing/libf/phylmd/regr_lat_time_climoz_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/regr_lat_time_climoz_m.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/regr_lat_time_climoz_m.F90	(revision 2471)
@@ -67,5 +67,5 @@
 
     use mod_grid_phy_lmdz, ONLY : nbp_lat
-    use regr1_step_av_m, only: regr1_step_av
+    use regr1_conserv_m, only: regr1_conserv
     use regr3_lint_m, only: regr3_lint
     use netcdf95, only: handle_err, nf95_close, nf95_get_att, nf95_gw_var, &
@@ -76,4 +76,5 @@
     use regular_lonlat_mod, only : boundslat_reg, south
     use nrtype, only: pi
+    use slopes_m, only: slopes
 
     integer, intent(in):: read_climoz ! read ozone climatology
@@ -92,6 +93,6 @@
     ! (of input data, converted to rad, sorted in strictly ascending order)
 
-    real, allocatable:: lat_in_edg(:)
-    ! (edges of latitude intervals for input data, in rad, in strictly
+    real, allocatable:: sin_lat_in_edg(:)
+    ! (sine of edges of latitude intervals for input data, in rad, in strictly
     ! ascending order)
 
@@ -115,14 +116,14 @@
 
     real, allocatable:: o3_regr_lat(:, :, :, :)
-    ! (jjm + 1, n_plev, 0:13, read_climoz)
+    ! (nbp_lat, n_plev, 0:13, read_climoz)
     ! mean of "o3_in" over a latitude interval of LMDZ
     ! First dimension is latitude interval.
     ! The latitude interval for "o3_regr_lat(j,:, :, :)" contains "rlatu(j)".
-    ! If "j" is between 2 and "jjm" then the interval is:
+    ! If "j" is between 2 and "nbp_lat - 1" then the interval is:
     ! [rlatv(j), rlatv(j-1)]
-    ! If "j" is 1 or "jjm + 1" then the interval is:
+    ! If "j" is 1 or "nbp_lat" then the interval is:
     ! [rlatv(1), pi / 2]
     ! or:
-    ! [- pi / 2, rlatv(jjm)]
+    ! [- pi / 2, rlatv(nbp_lat - 1)]
     ! respectively.
     ! "o3_regr_lat(:, k, :, :)" is for pressure level "plev(k)".
@@ -132,5 +133,5 @@
 
     real, allocatable:: o3_out(:, :, :, :)
-    ! (jjm + 1, n_plev, 360, read_climoz)
+    ! (nbp_lat, n_plev, 360, read_climoz)
     ! regridded ozone climatology
     ! "o3_out(j, k, l, :)" is at latitude "rlatu(j)", pressure
@@ -175,5 +176,5 @@
     latitude = latitude / 180. * pi
     n_lat = size(latitude)
-    ! We need to supply the latitudes to "regr1_step_av" in
+    ! We need to supply the latitudes to "regr1_conserv" in
     ! ascending order, so invert order if necessary:
     desc_lat = latitude(1) > latitude(n_lat)
@@ -181,8 +182,9 @@
 
     ! Compute edges of latitude intervals:
-    allocate(lat_in_edg(n_lat + 1))
-    lat_in_edg(1) = - pi / 2
-    forall (j = 2:n_lat) lat_in_edg(j) = (latitude(j - 1) + latitude(j)) / 2
-    lat_in_edg(n_lat + 1) = pi / 2
+    allocate(sin_lat_in_edg(n_lat + 1))
+    sin_lat_in_edg(1) = - 1.
+    forall (j = 2:n_lat) sin_lat_in_edg(j) = sin((latitude(j - 1) &
+         + latitude(j)) / 2.)
+    sin_lat_in_edg(n_lat + 1) = 1.
     deallocate(latitude) ! pointer
 
@@ -292,6 +294,8 @@
        print *, &
             "Found 12 months in ozone climatologies, assuming periodicity..."
-       o3_regr_lat(nbp_lat:1:-1, :, 1:12, :) = regr1_step_av(o3_in, &
-            xs=sin(lat_in_edg), xt=sin((/- pi / 2, boundslat_reg(nbp_lat-1:1:-1,south), pi / 2/)))
+       call regr1_conserv(o3_in, xs = sin_lat_in_edg, &
+            xt = (/- 1., sin(boundslat_reg(nbp_lat - 1:1:- 1, south)), 1./), &
+            vt = o3_regr_lat(nbp_lat:1:- 1, :, 1:12, :), &
+            slope = slopes(o3_in, sin_lat_in_edg))
        ! (invert order of indices in "o3_regr_lat" because "rlatu" is
        ! in descending order)
@@ -303,6 +307,8 @@
     else
        print *, "Using 14 months in ozone climatologies..."
-       o3_regr_lat(nbp_lat:1:-1, :, :, :) = regr1_step_av(o3_in, &
-            xs=sin(lat_in_edg), xt=sin((/- pi / 2, boundslat_reg(nbp_lat-1:1:-1,south), pi / 2/)))
+       call regr1_conserv(o3_in, xs = sin_lat_in_edg, &
+            xt = (/- 1., sin(boundslat_reg(nbp_lat - 1:1:- 1, south)), 1./), &
+            vt = o3_regr_lat(nbp_lat:1:- 1, :, :, :), &
+            slope = slopes(o3_in, sin_lat_in_edg))
        ! (invert order of indices in "o3_regr_lat" because "rlatu" is
        ! in descending order)
Index: /LMDZ5/branches/testing/libf/phylmd/regr_lat_time_coefoz_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/regr_lat_time_coefoz_m.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/regr_lat_time_coefoz_m.F90	(revision 2471)
@@ -41,5 +41,5 @@
 
     use mod_grid_phy_lmdz, ONLY : nbp_lat
-    use regr1_step_av_m, only: regr1_step_av
+    use regr1_conserv_m, only: regr1_conserv
     use regr3_lint_m, only: regr3_lint
     use netcdf95, only: nf95_open, nf95_close, nf95_inq_varid, handle_err, &
@@ -162,5 +162,5 @@
     latitude = latitude / 180. * pi
     n_lat = size(latitude)
-    ! We need to supply the latitudes to "regr1_step_av" in
+    ! We need to supply the latitudes to "regr1_conserv" in
     ! ascending order, so invert order if necessary:
     desc_lat = latitude(1) > latitude(n_lat)
@@ -209,6 +209,7 @@
        ! We average with respect to sine of latitude, which is
        ! equivalent to weighting by cosine of latitude:
-       v_regr_lat(nbp_lat:1:-1, :, 1:12) = regr1_step_av(o3_par_in, &
-            xs=sin(lat_in_edg), xt=sin((/- pi / 2, boundslat_reg(nbp_lat-1:1:-1,south), pi / 2/)))
+       call regr1_conserv(o3_par_in, xs = sin(lat_in_edg), &
+            xt = (/-1., sin((/boundslat_reg(nbp_lat-1:1:-1,south)/)), 1./), &
+            vt = v_regr_lat(nbp_lat:1:-1, :, 1:12))
        ! (invert order of indices in "v_regr_lat" because "rlatu" is
        ! in descending order)
Index: /LMDZ5/branches/testing/libf/phylmd/regr_pr_av_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/regr_pr_av_m.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/regr_pr_av_m.F90	(revision 2471)
@@ -26,5 +26,5 @@
 
     ! The target vertical LMDZ grid is the grid of layer boundaries.
-    ! Regridding in pressure is done by averaging a step function of pressure.
+    ! Regridding in pressure is conservative, second order.
 
     ! All the fields are regridded as a single multi-dimensional array
@@ -38,5 +38,6 @@
     use assert_m, only: assert
     use assert_eq_m, only: assert_eq
-    use regr1_step_av_m, only: regr1_step_av
+    use regr1_conserv_m, only: regr1_conserv
+    use slopes_m, only: slopes
     use mod_phys_lmdz_mpi_data, only: is_mpi_root
     use mod_grid_phy_lmdz, only: nbp_lon, nbp_lat, nbp_lev
@@ -83,5 +84,6 @@
     !--------------------------------------------
 
-    call assert(size(v3, 1) == klon, size(v3, 2) == nbp_lev, "regr_pr_av v3 klon")
+    call assert(size(v3, 1) == klon, size(v3, 2) == nbp_lev, &
+         "regr_pr_av v3 klon")
     n_var = assert_eq(size(name), size(v3, 3), "regr_pr_av v3 n_var")
     call assert(shape(paprs) == (/klon, nbp_lev+1/), "regr_pr_av paprs")
@@ -112,6 +114,7 @@
     ! Regrid in pressure at each horizontal position:
     do i = 1, klon
-       v3(i, nbp_lev:1:-1, :) = regr1_step_av(v2(i, :, :), press_in_edg, &
-            paprs(i, nbp_lev+1:1:-1))
+       call regr1_conserv(v2(i, :, :), press_in_edg, &
+            paprs(i, nbp_lev + 1:1:-1), v3(i, nbp_lev:1:-1, :), &
+            slopes(v2(i, :, :), press_in_edg))
        ! (invert order of indices because "paprs" is in descending order)
     end do
Index: /LMDZ5/branches/testing/libf/phylmd/regr_pr_o3_m.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/regr_pr_o3_m.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/regr_pr_o3_m.F90	(revision 2471)
@@ -28,5 +28,5 @@
     use netcdf, only:  nf90_nowrite, nf90_get_var
     use assert_m, only: assert
-    use regr1_step_av_m, only: regr1_step_av
+    use regr1_conserv_m, only: regr1_conserv
     use press_coefoz_m, only: press_in_edg
     use time_phylmdz_mod, only: day_ref
@@ -75,6 +75,6 @@
     ! Poles:
     do j = 1, nbp_lat, nbp_lat-1
-       o3_mob_regr(1, j, nbp_lev:1:-1) &
-            = regr1_step_av(r_mob(j, :), press_in_edg, p3d(1, j, nbp_lev+1:1:-1))
+       call regr1_conserv(r_mob(j, :), press_in_edg, &
+            p3d(1, j, nbp_lev + 1:1:-1), o3_mob_regr(1, j, nbp_lev:1:-1))
        ! (invert order of indices because "p3d" is in descending order)
     end do
@@ -83,8 +83,7 @@
     do j = 2, nbp_lat-1
        do i = 1, nbp_lon
-          o3_mob_regr(i, j, nbp_lev:1:-1) &
-               = regr1_step_av(r_mob(j, :), press_in_edg, &
-               p3d(i, j, nbp_lev+1:1:-1))
-             ! (invert order of indices because "p3d" is in descending order)
+          call regr1_conserv(r_mob(j, :), press_in_edg, &
+               p3d(i, j, nbp_lev + 1:1:-1), o3_mob_regr(i, j, nbp_lev:1:-1))
+          ! (invert order of indices because "p3d" is in descending order)
        end do
     end do
Index: /LMDZ5/branches/testing/libf/phylmd/screenc.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/screenc.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/screenc.F90	(revision 2471)
@@ -54,8 +54,9 @@
 !-----------------------------------------------------------------------
       include "YOMCST.h"
+      include "flux_arp.h"
 !
 ! Variables locales  
       INTEGER :: i 
-      REAL, dimension(klon) :: cdram, cdrah, cdran, zri1, gref
+      REAL, dimension(klon) :: cdram, cdrah, cdran, zri1, gref,ycdragm
 !
 !------------------------------------------------------------------------- 
@@ -78,5 +79,12 @@
                     cdram, cdrah, zri1, pref)
       DO i = 1, knon
+        IF(ok_prescr_ust) THEN
+! La aussi il faut forcer avec ust (FC + MPL 20160210)
+        ycdragm(i) = ust*ust/(1.+speed(i))/speed(i)
+        cdram=ycdragm
+        delu(i) = ust/sqrt(cdram(i))
+        ELSE
         delu(i) = ustar(i)/sqrt(cdram(i))
+        ENDIF
         delte(i)= (testar(i)* sqrt(cdram(i)))/ &
                    cdrah(i)
Index: /LMDZ5/branches/testing/libf/phylmd/surf_ocean_mod.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/surf_ocean_mod.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/surf_ocean_mod.F90	(revision 2471)
@@ -36,5 +36,5 @@
 
     include "clesphys.h"
-    ! for cycle_diurne
+    ! for cycle_diurne and for iflag_z0_oce==-1 (prescribed z0)
 
 ! Input variables
@@ -244,4 +244,9 @@
        z0h(i)=0.4*14e-6 / SQRT(cdragm(i) * tmp)
     ENDDO
+ELSE IF (iflag_z0_oce==-1) THEN
+    DO i = 1, knon
+       z0m(i) = z0min
+       z0h(i) = z0min
+    ENDDO
 ELSE
        CALL abort_physic(modname,'version non prevue',1)
Index: /LMDZ5/branches/testing/libf/phylmd/write_paramLMDZ_phy.h
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/write_paramLMDZ_phy.h	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/write_paramLMDZ_phy.h	(revision 2471)
@@ -1,25 +1,2 @@
-!
-! calcul moyennes globales
-!
-       zx_tmp_fi2d=bils*cell_area
-       CALL global_mean(zx_tmp_fi2d,cell_area,.TRUE.,gbils)
-       zx_tmp_fi2d=evap*cell_area
-       CALL global_mean(zx_tmp_fi2d,cell_area,.TRUE.,gevap)
-       zx_tmp_fi2d(:)=fevap(:, is_ter)*cell_area(:)
-       CALL global_mean(zx_tmp_fi2d,cell_area,.TRUE.,gevapt)
-       zx_tmp_fi2d=zxfluxlat*cell_area
-       CALL global_mean(zx_tmp_fi2d,cell_area,.TRUE.,glat)
-       zx_tmp_fi2d=(topsw0-toplw0)*cell_area
-       CALL global_mean(zx_tmp_fi2d,cell_area,.TRUE.,gnet0)
-       zx_tmp_fi2d=(topsw-toplw)*cell_area
-       CALL global_mean(zx_tmp_fi2d,cell_area,.TRUE.,gnet)
-       zx_tmp_fi2d=(rain_fall+snow_fall)*cell_area
-       CALL global_mean(zx_tmp_fi2d,cell_area,.TRUE.,grain)
-       zx_tmp_fi2d=zxtsol*cell_area
-       CALL global_mean(zx_tmp_fi2d,cell_area,.TRUE.,gtsol)
-       zx_tmp_fi2d=zt2m*cell_area
-       CALL global_mean(zx_tmp_fi2d,cell_area,.TRUE.,gt2m)
-       zx_tmp_fi2d=prw*cell_area
-       CALL global_mean(zx_tmp_fi2d,cell_area,.TRUE.,gprw)
 !
 !$OMP MASTER
@@ -68,27 +45,4 @@
 !
 !=================================================================
-! moyennes globales
-!
-      CALL histwrite(nid_ctesGCM,"bils",itau_w, &
-                     gbils,np,ndex2d)
-      CALL histwrite(nid_ctesGCM,"evap",itau_w, &
-                     gevap,np,ndex2d)
-      CALL histwrite(nid_ctesGCM,"evap_land",itau_w, &
-                     gevapt,np,ndex2d)
-      CALL histwrite(nid_ctesGCM,"flat",itau_w, &
-                     glat,np,ndex2d)
-      CALL histwrite(nid_ctesGCM,"nettop0",itau_w, &
-                     gnet0,np,ndex2d)
-      CALL histwrite(nid_ctesGCM,"nettop",itau_w, &
-                     gnet,np,ndex2d)
-      CALL histwrite(nid_ctesGCM,"precip",itau_w, &
-                     grain,np,ndex2d)
-      CALL histwrite(nid_ctesGCM,"tsol",itau_w, &
-                     gtsol,np,ndex2d)
-      CALL histwrite(nid_ctesGCM,"t2m",itau_w, &
-                     gt2m,np,ndex2d)
-      CALL histwrite(nid_ctesGCM,"prw",itau_w, &
-                     gprw,np,ndex2d)
-!=================================================================
 !
       if (ok_sync) then
Index: /LMDZ5/branches/testing/libf/phylmd/yamada4.F90
===================================================================
--- /LMDZ5/branches/testing/libf/phylmd/yamada4.F90	(revision 2470)
+++ /LMDZ5/branches/testing/libf/phylmd/yamada4.F90	(revision 2471)
@@ -6,4 +6,6 @@
   USE dimphy
   USE print_control_mod, ONLY: prt_level
+  USE ioipsl_getin_p_mod, ONLY : getin_p
+
   IMPLICIT NONE
 
@@ -75,4 +77,7 @@
   DATA first, ipas/.FALSE., 0/
   !$OMP THREADPRIVATE( first,ipas)
+  REAL,SAVE :: lmixmin=1.
+  !$OMP THREADPRIVATE(lmixmin) 
+
 
   INTEGER ig, k
@@ -107,5 +112,5 @@
   fl(zzz, zl0, zq2, zn2) = max(min(l0(ig)*kap*zlev(ig, &
     k)/(kap*zlev(ig,k)+l0(ig)),0.5*sqrt(q2(ig,k))/sqrt( &
-    max(n2(ig,k),1.E-10))), 1.)
+    max(n2(ig,k),1.E-10))), lmixmin)
 
 
@@ -116,4 +121,5 @@
     ALLOCATE (l0(klon))
     firstcall = .FALSE.
+    CALL getin_p('lmixmin',lmixmin)
   END IF
 
@@ -341,5 +347,5 @@
     DO k = 2, klev - 1
       DO ig = 1, ngrid
-        l(ig, k) = max(l(ig,k), 1.)
+        l(ig, k) = max(l(ig,k), lmixmin)
         km(ig, k) = l(ig, k)*sqrt(q2(ig,k))*sm(ig, k)
         q2(ig, k) = q2(ig, k) + dt*km(ig, k)*m2(ig, k)*(1.-rif(ig,k))
