Index: /LMDZ5/branches/LMDZ6_rc0/DefLists/field_def_lmdz.xml
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/DefLists/field_def_lmdz.xml	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/DefLists/field_def_lmdz.xml	(revision 2283)
@@ -207,46 +207,46 @@
         <field id="alp_bl_conv"    long_name="ALP_BL_CONV"    unit="W/m2" />
         <field id="alp_bl_stat"    long_name="ALP_BL_STAT"    unit="W/m2" />
-        <field id="u850"    long_name="Zonal wind 1hPa"    unit="m/s" />
-        <field id="u700"    long_name="Zonal wind 2hPa"    unit="m/s" />
-        <field id="u500"    long_name="Zonal wind 3hPa"    unit="m/s" />
-        <field id="u200"    long_name="Zonal wind 4hPa"    unit="m/s" />
-        <field id="u100"    long_name="Zonal wind 5hPa"    unit="m/s" />
-        <field id="u50"     long_name="Zonal wind 6hPa"    unit="m/s" />
-        <field id="u10"     long_name="Zonal wind 7hPa"    unit="m/s" />
-        <field id="v850"    long_name="Meridional wind 1hPa"    unit="m/s" />
-        <field id="v700"    long_name="Meridional wind 2hPa"    unit="m/s" />
-        <field id="v500"    long_name="Meridional wind 3hPa"    unit="m/s" />
-        <field id="v200"    long_name="Meridional wind 4hPa"    unit="m/s" />
-        <field id="v100"    long_name="Meridional wind 5hPa"    unit="m/s" />
-        <field id="v50"     long_name="Meridional wind 6hPa"    unit="m/s" />
-        <field id="v10"    long_name="Meridional wind 7hPa"    unit="m/s" />
-        <field id="w850"    long_name="Vertical wind 1hPa"    unit="Pa/s" />
-        <field id="w700"    long_name="Vertical wind 2hPa"    unit="Pa/s" />
-        <field id="w500"    long_name="Vertical wind 3hPa"    unit="Pa/s" />
-        <field id="w200"    long_name="Vertical wind 4hPa"    unit="Pa/s" />
-        <field id="w100"    long_name="Vertical wind 5hPa"    unit="Pa/s" />
-        <field id="w50"    long_name="Vertical wind 6hPa"    unit="Pa/s" />
-        <field id="w10"    long_name="Vertical wind 7hPa"    unit="Pa/s" />
-        <field id="t850"    long_name="Temperature 1hPa"    unit="K" />
-        <field id="t700"    long_name="Temperature 2hPa"    unit="K" />
-        <field id="t500"    long_name="Temperature 3hPa"    unit="K" />
-        <field id="t200"    long_name="Temperature 4hPa"    unit="K" />
-        <field id="t100"    long_name="Temperature 5hPa"    unit="K" />
-        <field id="t50"    long_name="Temperature 6hPa"    unit="K" />
-        <field id="t10"    long_name="Temperature 7hPa"    unit="K" />
-        <field id="q850"    long_name="Specific humidity 1hPa"    unit="kg/kg" />
-        <field id="q700"    long_name="Specific humidity 2hPa"    unit="kg/kg" />
-        <field id="q500"    long_name="Specific humidity 3hPa"    unit="kg/kg" />
-        <field id="q200"    long_name="Specific humidity 4hPa"    unit="kg/kg" />
-        <field id="q100"    long_name="Specific humidity 5hPa"    unit="kg/kg" />
-        <field id="q50"    long_name="Specific humidity 6hPa"    unit="kg/kg" />
-        <field id="q10"    long_name="Specific humidity 7hPa"    unit="kg/kg" />
-        <field id="z850"    long_name="Geopotential height 1hPa"    unit="m" />
-        <field id="z700"    long_name="Geopotential height 2hPa"    unit="m" />
-        <field id="z500"    long_name="Geopotential height 3hPa"    unit="m" />
-        <field id="z200"    long_name="Geopotential height 4hPa"    unit="m" />
-        <field id="z100"    long_name="Geopotential height 5hPa"    unit="m" />
-        <field id="z50"    long_name="Geopotential height 6hPa"    unit="m" />
-        <field id="z10"    long_name="Geopotential height 7hPa"    unit="m" />
+        <field id="u850"    long_name="Zonal wind 850hPa"    unit="m/s" />
+        <field id="u700"    long_name="Zonal wind 700hPa"    unit="m/s" />
+        <field id="u500"    long_name="Zonal wind 500hPa"    unit="m/s" />
+        <field id="u200"    long_name="Zonal wind 200hPa"    unit="m/s" />
+        <field id="u100"    long_name="Zonal wind 100hPa"    unit="m/s" />
+        <field id="u50"     long_name="Zonal wind 50hPa"    unit="m/s" />
+        <field id="u10"     long_name="Zonal wind 10hPa"    unit="m/s" />
+        <field id="v850"    long_name="Meridional wind 850hPa"    unit="m/s" />
+        <field id="v700"    long_name="Meridional wind 700hPa"    unit="m/s" />
+        <field id="v500"    long_name="Meridional wind 500hPa"    unit="m/s" />
+        <field id="v200"    long_name="Meridional wind 200hPa"    unit="m/s" />
+        <field id="v100"    long_name="Meridional wind 100hPa"    unit="m/s" />
+        <field id="v50"     long_name="Meridional wind 50hPa"    unit="m/s" />
+        <field id="v10"    long_name="Meridional wind 10hPa"    unit="m/s" />
+        <field id="w850"    long_name="Vertical wind 850hPa"    unit="Pa/s" />
+        <field id="w700"    long_name="Vertical wind 700hPa"    unit="Pa/s" />
+        <field id="w500"    long_name="Vertical wind 500hPa"    unit="Pa/s" />
+        <field id="w200"    long_name="Vertical wind 200hPa"    unit="Pa/s" />
+        <field id="w100"    long_name="Vertical wind 100hPa"    unit="Pa/s" />
+        <field id="w50"    long_name="Vertical wind 50hPa"    unit="Pa/s" />
+        <field id="w10"    long_name="Vertical wind 10hPa"    unit="Pa/s" />
+        <field id="t850"    long_name="Temperature 850hPa"    unit="K" />
+        <field id="t700"    long_name="Temperature 700hPa"    unit="K" />
+        <field id="t500"    long_name="Temperature 500hPa"    unit="K" />
+        <field id="t200"    long_name="Temperature 200hPa"    unit="K" />
+        <field id="t100"    long_name="Temperature 100hPa"    unit="K" />
+        <field id="t50"    long_name="Temperature 50hPa"    unit="K" />
+        <field id="t10"    long_name="Temperature 10hPa"    unit="K" />
+        <field id="q850"    long_name="Specific humidity 850hPa"    unit="kg/kg" />
+        <field id="q700"    long_name="Specific humidity 700hPa"    unit="kg/kg" />
+        <field id="q500"    long_name="Specific humidity 500hPa"    unit="kg/kg" />
+        <field id="q200"    long_name="Specific humidity 200hPa"    unit="kg/kg" />
+        <field id="q100"    long_name="Specific humidity 100hPa"    unit="kg/kg" />
+        <field id="q50"    long_name="Specific humidity 50hPa"    unit="kg/kg" />
+        <field id="q10"    long_name="Specific humidity 10hPa"    unit="kg/kg" />
+        <field id="z850"    long_name="Geopotential height 850hPa"    unit="m" />
+        <field id="z700"    long_name="Geopotential height 700hPa"    unit="m" />
+        <field id="z500"    long_name="Geopotential height 500hPa"    unit="m" />
+        <field id="z200"    long_name="Geopotential height 200hPa"    unit="m" />
+        <field id="z100"    long_name="Geopotential height 100hPa"    unit="m" />
+        <field id="z50"    long_name="Geopotential height 50hPa"    unit="m" />
+        <field id="z10"    long_name="Geopotential height 10hPa"    unit="m" />
         <field id="t_oce_sic"    long_name="Temp mixte oce-sic"    unit="K" />
         <field id="weakinv"    long_name="Weak inversion"    unit="-" />
@@ -524,5 +524,5 @@
     
     <field_group  id="fields_NMC" domain_ref="dom_glo" axis_ref="plev">
-      <field id="tnondef" long_name="Undefined value of T" unit="K" />
+<!--  <field id="tnondef" long_name="Undefined value of T" unit="K" /> -->
       <field id="ta" long_name="Air temperature" unit="K" />
       <field id="zg" long_name="Geopotential height" unit="m" />
@@ -532,5 +532,5 @@
       <field id="va" long_name="Northward wind" unit="m s-1" />
       <field id="wap" long_name="Lagrangian tendency of air pressure" unit="Pa s-1" />
-      <field id="psbg" long_name="Pressure sfce below ground" unit="%" />
+<!--  <field id="psbg" long_name="Pressure sfce below ground" unit="%" /> -->
       <field id="tro3" long_name="Ozone mole fraction" unit="1e-9" />
       <field id="tro3_daylight" long_name="Daylight ozone mole fraction" unit="1e-9" />
Index: /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histLES_lmdz.xml
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histLES_lmdz.xml	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histLES_lmdz.xml	(revision 2283)
@@ -204,5 +204,5 @@
                 <field field_ref="alp_bl_stat" level="10" />
 
-                <field_group operation="instant">
+                <field_group operation="average" freq_op="1ts" detect_missing_value=".true.">
                     <field field_ref="u850" level="10" />
                     <field field_ref="u700" level="10" />
Index: /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histdayNMC_lmdz.xml
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histdayNMC_lmdz.xml	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histdayNMC_lmdz.xml	(revision 2283)
@@ -5,5 +5,5 @@
             <!-- VARS 3D -->
             <field_group operation="instant" freq_op="1ts" >
-                <field field_ref="tnondef" level="5" />
+<!--            <field field_ref="tnondef" level="5" /> -->
                 <field field_ref="ta" level="1" />
                 <field field_ref="zg" level="5" />
@@ -13,5 +13,5 @@
                 <field field_ref="va" level="5" />
                 <field field_ref="wap" level="5" />
-                <field field_ref="psbg" level="5" />
+<!--            <field field_ref="psbg" level="5" /> -->
                 <field field_ref="tro3" level="5" />
                 <field field_ref="tro3_daylight" level="5" />
Index: /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histday_lmdz.xml
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histday_lmdz.xml	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histday_lmdz.xml	(revision 2283)
@@ -204,5 +204,5 @@
                 <field field_ref="alp_bl_stat" level="1" />
 
-                <field_group operation="instant">
+                <field_group operation="average" freq_op="1ts" detect_missing_value=".true.">
                     <field field_ref="u850" level="7" />
                     <field field_ref="u700" level="7" />
Index: /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histhfNMC_lmdz.xml
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histhfNMC_lmdz.xml	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histhfNMC_lmdz.xml	(revision 2283)
@@ -5,5 +5,5 @@
             <!-- VARS 3D -->
             <field_group operation="instant" freq_op="1ts" >
-                <field field_ref="tnondef" level="5" />
+<!--            <field field_ref="tnondef" level="5" />  -->
                 <field field_ref="ta" level="1" />
                 <field field_ref="zg" level="5" />
@@ -13,5 +13,5 @@
                 <field field_ref="va" level="5" />
                 <field field_ref="wap" level="5" />
-                <field field_ref="psbg" level="5" />
+<!--            <field field_ref="psbg" level="5" /> -->
                 <field field_ref="tro3" level="5" />
                 <field field_ref="tro3_daylight" level="5" />
Index: /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histhf_lmdz.xml
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histhf_lmdz.xml	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histhf_lmdz.xml	(revision 2283)
@@ -1,5 +1,5 @@
 <file_definition>
     <file_group id="defile">
-        <file id="histhf" name="Xhisthf" output_freq="1h" output_level="5" enabled=".FALSE.">
+        <file id="histhf" name="histhf" output_freq="6h" output_level="5" enabled=".FALSE.">
             
             <!-- VARS 1D -->
@@ -204,5 +204,5 @@
                 <field field_ref="alp_bl_stat" level="10" />
 
-                <field_group operation="instant">
+                <field_group operation="average" freq_op="1ts" detect_missing_value=".true.">
                     <field field_ref="u850" level="10" />
                     <field field_ref="u700" level="10" />
Index: /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histins_lmdz.xml
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histins_lmdz.xml	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histins_lmdz.xml	(revision 2283)
@@ -1,5 +1,5 @@
 <file_definition>
     <file_group id="defile">
-        <file id="histins" name="Xhistins" output_freq="6h" output_level="4" enabled=".FALSE.">
+        <file id="histins" name="Xhistins" output_freq="1ts" output_level="4" enabled=".FALSE.">
             
             <!-- VARS 1D -->
@@ -204,5 +204,5 @@
                 <field field_ref="alp_bl_stat" level="1" />
 
-                <field_group operation="instant">
+                <field_group operation="instant" freq_op="1ts" detect_missing_value=".true.">
                     <field field_ref="u850" level="7" />
                     <field field_ref="u700" level="7" />
Index: /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histmthNMC_lmdz.xml
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histmthNMC_lmdz.xml	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histmthNMC_lmdz.xml	(revision 2283)
@@ -5,5 +5,5 @@
             <!-- VARS 3D -->
             <field_group operation="instant" freq_op="1ts" >
-                <field field_ref="tnondef" level="5" />
+<!--            <field field_ref="tnondef" level="5" />  -->
                 <field field_ref="ta" level="1" />
                 <field field_ref="zg" level="5" />
@@ -13,5 +13,5 @@
                 <field field_ref="va" level="5" />
                 <field field_ref="wap" level="5" />
-                <field field_ref="psbg" level="5" />
+<!--            <field field_ref="psbg" level="5" />  -->
                 <field field_ref="tro3" level="5" />
                 <field field_ref="tro3_daylight" level="5" />
Index: /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histmth_lmdz.xml
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histmth_lmdz.xml	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histmth_lmdz.xml	(revision 2283)
@@ -204,5 +204,5 @@
                 <field field_ref="alp_bl_stat" level="1" />
 
-                <field_group operation="instant">
+                <field_group operation="average" freq_op="1ts" detect_missing_value=".true.">
                     <field field_ref="u850" level="1" />
                     <field field_ref="u700" level="1" />
Index: /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histstn_lmdz.xml
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histstn_lmdz.xml	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/DefLists/file_def_histstn_lmdz.xml	(revision 2283)
@@ -204,5 +204,5 @@
                 <field field_ref="alp_bl_stat" level="10" />
 
-                <field_group operation="instant">
+                <field_group operation="average" freq_op="1ts" detect_missing_value=".true.">
                     <field field_ref="u850" level="10" />
                     <field field_ref="u700" level="10" />
Index: /LMDZ5/branches/LMDZ6_rc0/libf/bibio/wxios.F90
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/libf/bibio/wxios.F90	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/libf/bibio/wxios.F90	(revision 2283)
@@ -21,5 +21,7 @@
     CHARACTER(len=100) :: g_field_name = "nofield"
 !$OMP THREADPRIVATE(g_flag_xml,g_field_name)
-
+    REAL :: missing_val_omp
+    REAL :: missing_val
+!$OMP THREADPRIVATE(missing_val)
 
     CONTAINS
Index: /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/calcul_STDlev.h
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/calcul_STDlev.h	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/calcul_STDlev.h	(revision 2283)
@@ -4,5 +4,5 @@
 !IM on initialise les variables 
 !
-        missing_val=nf90_fill_real
+!       missing_val=nf90_fill_real
 !
         CALL ini_undefSTD(itap,itapm1)
Index: /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/declare_STDlev.h
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/declare_STDlev.h	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/declare_STDlev.h	(revision 2283)
@@ -57,5 +57,5 @@
       REAL zx_tmp_fiNC(klon,nlevSTD)
 
-      REAL missing_val
+!     REAL missing_val
       REAL, SAVE :: freq_moyNMC(nout)
 !$OMP THREADPRIVATE(freq_moyNMC)
Index: /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/moy_undefSTD.F90
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/moy_undefSTD.F90	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/moy_undefSTD.F90	(revision 2283)
@@ -5,8 +5,14 @@
   USE netcdf
   USE dimphy
+#ifdef CPP_IOIPSL 
   USE phys_state_var_mod
+#endif
+
   USE phys_cal_mod, ONLY: mth_len
   IMPLICIT NONE
   include "clesphys.h"
+#ifdef CPP_IOIPSL 
+  REAL :: missing_val
+#endif
 
   ! ====================================================================
@@ -51,7 +57,10 @@
   REAL un_jour
   PARAMETER (un_jour=86400.)
-  REAL missing_val
+! REAL missing_val
 
-  missing_val = nf90_fill_real
+! missing_val = nf90_fill_real
+#ifndef CPP_XIOS
+      missing_val=missing_val_nf90
+#endif
 
   DO n = 1, nout
Index: /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/phys_output_ctrlout_mod.F90
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 2283)
@@ -557,5 +557,5 @@
 
   TYPE(ctrl_out), SAVE, DIMENSION(7) :: o_wSTDlevs     = (/                    &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'w850', "Vertical wind 1hPa", "Pa/s", &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'w850', "Vertical wind 850hPa", "Pa/s", &
       (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
       ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'w700', "Vertical wind 700hPa", "Pa/s", &
@@ -573,5 +573,5 @@
 
   TYPE(ctrl_out), SAVE, DIMENSION(7) :: o_tSTDlevs     = (/                    &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'t850', "Temperature 1hPa", "K",      &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'t850', "Temperature 850hPa", "K",      &
       (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
       ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'t700', "Temperature 700hPa", "K",      &
@@ -589,5 +589,5 @@
 
   TYPE(ctrl_out), SAVE, DIMENSION(7) :: o_qSTDlevs     = (/                             &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'q850', "Specific humidity 1hPa", &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'q850', "Specific humidity 850hPa", &
       "kg/kg", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
       ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'q700', "Specific humidity 700hPa", &
@@ -605,5 +605,5 @@
 
   TYPE(ctrl_out), SAVE, DIMENSION(7) :: o_zSTDlevs   = (/                           &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'z850', "Geopotential height 1hPa",        &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'z850', "Geopotential height 850hPa",        &
       "m", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
       ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'z700', "Geopotential height 700hPa",        &
Index: /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/phys_output_write_mod.F90
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/phys_output_write_mod.F90	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/phys_output_write_mod.F90	(revision 2283)
@@ -171,5 +171,8 @@
          vqsumSTD, vTsumSTD, O3daysumSTD, wqsumSTD, &
          vphisumSTD, wTsumSTD, u2sumSTD, v2sumSTD, &
-         T2sumSTD, nlevSTD, du_gwd_rando, dv_gwd_rando
+         T2sumSTD, nlevSTD, du_gwd_rando, dv_gwd_rando, &
+         ulevSTD, vlevSTD, wlevSTD, philevSTD, qlevSTD, tlevSTD, &
+         rhlevSTD, O3STD, O3daySTD, uvSTD, vqSTD, vTSTD, wqSTD, &
+         vphiSTD, wTSTD, u2STD, v2STD, T2STD, missing_val_nf90
 
     USE phys_local_var_mod, only: zxfluxlat, slp, zxtsol, zt2m, &
@@ -239,5 +242,5 @@
     ! ug Pour les sorties XIOS
     USE xios, ONLY: xios_update_calendar
-    USE wxios, only: wxios_closedef
+    USE wxios, only: wxios_closedef, missing_val
 #endif
     USE phys_cal_mod, only : mth_len
@@ -285,5 +288,8 @@
     INTEGER, DIMENSION(iim*jjmp1*klev) :: ndex3d
     REAL, PARAMETER :: dobson_u = 2.1415e-05 ! Dobson unit, in kg m-2
-    REAL, PARAMETER :: missing_val=nf90_fill_real
+!   REAL, PARAMETER :: missing_val=nf90_fill_real
+#ifndef CPP_XIOS
+    REAL :: missing_val
+#endif
     REAL, PARAMETER :: un_jour=86400.
 
@@ -646,6 +652,10 @@
        !       ENDIF
 
+#ifdef CPP_IOIPSL
+#ifndef CPP_XIOS
+  IF (.NOT.ok_all_xml) THEN
        ! ATTENTION, LES ANCIENS HISTWRITE ONT ETES CONSERVES EN ATTENDANT MIEUX:
        ! Champs interpolles sur des niveaux de pression
+       missing_val=missing_val_nf90
        DO iff=1, nfiles
           ll=0
@@ -669,5 +679,29 @@
           ENDDO
        ENDDO
-
+  ENDIF
+#endif
+#endif
+#ifdef CPP_XIOS
+  IF(ok_all_xml) THEN
+!XIOS  CALL xios_get_field_attr("u850",default_value=missing_val)
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+          ll=0
+          DO k=1, nlevSTD
+             bb2=clevSTD(k) 
+             IF(bb2.EQ."850".OR.bb2.EQ."700".OR. &
+                bb2.EQ."500".OR.bb2.EQ."200".OR. &
+                bb2.EQ."100".OR. &
+                bb2.EQ."50".OR.bb2.EQ."10") THEN
+                ll=ll+1
+                CALL histwrite_phy(o_uSTDlevs(ll),ulevSTD(:,k))
+                CALL histwrite_phy(o_vSTDlevs(ll),vlevSTD(:,k))
+                CALL histwrite_phy(o_wSTDlevs(ll),wlevSTD(:,k))
+                CALL histwrite_phy(o_zSTDlevs(ll),philevSTD(:,k))
+                CALL histwrite_phy(o_qSTDlevs(ll),qlevSTD(:,k))
+                CALL histwrite_phy(o_tSTDlevs(ll),tlevSTD(:,k))
+             ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
+          ENDDO
+  ENDIF
+#endif
        IF (vars_defined) THEN
           DO i=1, klon
@@ -1251,4 +1285,10 @@
        ENDIF
 !!!!!!!!!!!! Sorties niveaux de pression NMC !!!!!!!!!!!!!!!!!!!!
+#ifdef CPP_IOIPSL
+#ifndef CPP_XIOS
+  IF (.NOT.ok_all_xml) THEN 
+       ! ATTENTION, LES ANCIENS HISTWRITE ONT ETES CONSERVES EN ATTENDANT MIEUX:
+       ! Champs interpolles sur des niveaux de pression
+       missing_val=missing_val_nf90
        DO iff=7, nfiles
 
@@ -1314,4 +1354,74 @@
           CALL histwrite_phy(o_TxT,T2sumSTD(:,:,iff-6),iff)
        ENDDO !nfiles
+  ENDIF
+#endif
+#endif
+#ifdef CPP_XIOS
+  IF(ok_all_xml) THEN 
+!      DO iff=7, nfiles
+
+!         CALL histwrite_phy(o_tnondef,tnondef(:,:,3))
+          CALL histwrite_phy(o_ta,tlevSTD(:,:))
+          CALL histwrite_phy(o_zg,philevSTD(:,:))
+          CALL histwrite_phy(o_hus,qlevSTD(:,:))
+          CALL histwrite_phy(o_hur,rhlevSTD(:,:))
+          CALL histwrite_phy(o_ua,ulevSTD(:,:))
+          CALL histwrite_phy(o_va,vlevSTD(:,:))
+          CALL histwrite_phy(o_wap,wlevSTD(:,:))
+!         IF(vars_defined) THEN
+!            DO k=1, nlevSTD
+!               DO i=1, klon
+!                  IF(tnondef(i,k,3).NE.missing_val) THEN
+!                     IF(freq_outNMC(iff-6).LT.0) THEN
+!                        freq_moyNMC(iff-6)=(mth_len*un_jour)/freq_calNMC(iff-6)
+!                     ELSE
+!                        freq_moyNMC(iff-6)=freq_outNMC(iff-6)/freq_calNMC(iff-6)
+!                     ENDIF
+!                     zx_tmp_fi3d_STD(i,k) = (100.*tnondef(i,k,3))/freq_moyNMC(iff-6)
+!                  ELSE
+!                     zx_tmp_fi3d_STD(i,k) = missing_val
+!                  ENDIF
+!               ENDDO
+!            ENDDO
+!         ENDIF
+!         CALL histwrite_phy(o_psbg,zx_tmp_fi3d_STD)
+          IF(vars_defined) THEN
+             DO k=1, nlevSTD
+                DO i=1, klon
+                   IF(O3STD(i,k).NE.missing_val) THEN
+                      zx_tmp_fi3d_STD(i,k) = O3STD(i,k) * 1.e+9
+                   ELSE
+                      zx_tmp_fi3d_STD(i,k) = missing_val
+                   ENDIF
+                ENDDO
+             ENDDO !k=1, nlevSTD
+          ENDIF
+          CALL histwrite_phy(o_tro3,zx_tmp_fi3d_STD)
+          if (read_climoz == 2) THEN
+             IF(vars_defined) THEN
+                DO k=1, nlevSTD
+                   DO i=1, klon
+                      IF(O3daySTD(i,k).NE.missing_val) THEN
+                         zx_tmp_fi3d_STD(i,k) = O3daySTD(i,k) * 1.e+9
+                      ELSE
+                         zx_tmp_fi3d_STD(i,k) = missing_val
+                      ENDIF
+                   ENDDO
+                ENDDO !k=1, nlevSTD
+             ENDIF
+             CALL histwrite_phy(o_tro3_daylight,zx_tmp_fi3d_STD)
+          endif
+          CALL histwrite_phy(o_uxv,uvSTD(:,:))
+          CALL histwrite_phy(o_vxq,vqSTD(:,:))
+          CALL histwrite_phy(o_vxT,vTSTD(:,:))
+          CALL histwrite_phy(o_wxq,wqSTD(:,:))
+          CALL histwrite_phy(o_vxphi,vphiSTD(:,:))
+          CALL histwrite_phy(o_wxT,wTSTD(:,:))
+          CALL histwrite_phy(o_uxu,u2STD(:,:))
+          CALL histwrite_phy(o_vxv,v2STD(:,:))
+          CALL histwrite_phy(o_TxT,T2STD(:,:))
+!      ENDDO !nfiles
+  ENDIF
+#endif
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
         IF (nqtot.GE.nqo+1) THEN
Index: /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/phys_state_var_mod.F90
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/phys_state_var_mod.F90	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/phys_state_var_mod.F90	(revision 2283)
@@ -10,4 +10,5 @@
 ! Declaration des variables
       USE dimphy
+      USE netcdf, only: nf90_fill_real
       INTEGER, PARAMETER :: nlevSTD=17
       INTEGER, PARAMETER :: nlevSTD8=8
@@ -16,4 +17,5 @@
       INTEGER, PARAMETER :: napisccp=1
       INTEGER, SAVE :: radpas
+      REAL, PARAMETER :: missing_val_nf90=nf90_fill_real
 !$OMP THREADPRIVATE(radpas)
       REAL, SAVE :: dtime, solaire_etat0
Index: /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/physiq.F90
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/physiq.F90	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/physiq.F90	(revision 2283)
@@ -47,4 +47,8 @@
   use phyaqua_mod, only: zenang_an
   USE control_mod
+#ifdef CPP_XIOS
+  USE wxios, ONLY: missing_val, missing_val_omp
+  USE xios, ONLY: xios_get_field_attr
+#endif
 #ifdef REPROBUS
   USE CHEM_REP, ONLY : Init_chem_rep_xjour
@@ -240,4 +244,7 @@
   real da(klon,klev),phi(klon,klev,klev),mp(klon,klev)
   real wght_cvfd(klon,klev)
+#ifndef CPP_XIOS
+  REAL, SAVE :: missing_val
+#endif
   ! Variables pour le lessivage convectif
   ! RomP >>> 
@@ -3674,4 +3681,16 @@
   !IM Interpolation sur les niveaux de pression du NMC
   !   -------------------------------------------------
+#ifdef CPP_XIOS
+          !$OMP MASTER
+          !On recupere la valeur de la missing value donnee dans le xml
+          CALL xios_get_field_attr("t850",default_value=missing_val_omp)
+!         PRINT *,"ARNAUD value missing ",missing_val_omp
+          !$OMP END MASTER
+          !$OMP BARRIER
+          missing_val=missing_val_omp
+#endif
+#ifndef CPP_XIOS
+          missing_val=missing_val_nf90
+#endif
   !
   include "calcul_STDlev.h"
Index: /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/plevel.F90
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/plevel.F90	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/plevel.F90	(revision 2283)
@@ -9,4 +9,10 @@
   USE netcdf
   USE dimphy
+#ifdef CPP_IOIPSL 
+  USE phys_state_var_mod, ONLY: missing_val_nf90 
+#endif
+#ifdef CPP_XIOS
+  USE wxios, ONLY: missing_val
+#endif
   IMPLICIT NONE
 
@@ -56,7 +62,14 @@
   INTEGER i, k
 
-  REAL missing_val
+! REAL missing_val
+#ifndef CPP_XIOS
+  REAL :: missing_val
+#endif
 
-  missing_val = nf90_fill_real
+! missing_val = nf90_fill_real
+
+#ifndef CPP_XIOS
+      missing_val=missing_val_nf90
+#endif
 
   IF (first) THEN
Index: /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/plevel_new.F90
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/plevel_new.F90	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/plevel_new.F90	(revision 2283)
@@ -10,4 +10,11 @@
   USE netcdf
   USE dimphy
+#ifdef CPP_IOIPSL 
+  USE phys_state_var_mod, ONLY: missing_val_nf90
+#endif
+#ifdef CPP_XIOS
+  USE wxios, ONLY: missing_val
+#endif
+
   IMPLICIT NONE
 
@@ -58,7 +65,14 @@
   INTEGER i, k
 
-  REAL missing_val
+! REAL missing_val
+#ifndef CPP_XIOS
+  REAL :: missing_val
+#endif
 
-  missing_val = nf90_fill_real
+! missing_val = nf90_fill_real
+
+#ifndef CPP_XIOS
+      missing_val=missing_val_nf90
+#endif
 
   IF (first) THEN
Index: /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/undefSTD.F90
===================================================================
--- /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/undefSTD.F90	(revision 2282)
+++ /LMDZ5/branches/LMDZ6_rc0/libf/phylmd/undefSTD.F90	(revision 2283)
@@ -5,7 +5,13 @@
   USE netcdf
   USE dimphy
-  USE phys_state_var_mod ! Variables sauvegardees de la physique
+#ifdef CPP_IOIPSL 
+  USE phys_state_var_mod
+#endif
+
   IMPLICIT NONE
   include "clesphys.h"
+#ifdef CPP_IOIPSL 
+  REAL :: missing_val
+#endif
 
   ! ====================================================================
@@ -51,7 +57,10 @@
   ! REAL tnondef(klon,klevSTD,nout)
 
-  REAL missing_val
+! REAL missing_val
 
-  missing_val = nf90_fill_real
+! missing_val = nf90_fill_real
+#ifndef CPP_XIOS
+      missing_val=missing_val_nf90
+#endif
 
   DO n = 1, nout
