Index: /LMDZ5/trunk/libf/misc/wxios.F90
===================================================================
--- /LMDZ5/trunk/libf/misc/wxios.F90	(revision 2270)
+++ /LMDZ5/trunk/libf/misc/wxios.F90	(revision 2271)
@@ -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/trunk/libf/phylmd/calcul_STDlev.h
===================================================================
--- /LMDZ5/trunk/libf/phylmd/calcul_STDlev.h	(revision 2270)
+++ /LMDZ5/trunk/libf/phylmd/calcul_STDlev.h	(revision 2271)
@@ -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/trunk/libf/phylmd/declare_STDlev.h
===================================================================
--- /LMDZ5/trunk/libf/phylmd/declare_STDlev.h	(revision 2270)
+++ /LMDZ5/trunk/libf/phylmd/declare_STDlev.h	(revision 2271)
@@ -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/trunk/libf/phylmd/moy_undefSTD.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/moy_undefSTD.F90	(revision 2270)
+++ /LMDZ5/trunk/libf/phylmd/moy_undefSTD.F90	(revision 2271)
@@ -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/trunk/libf/phylmd/phys_output_ctrlout_mod.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 2270)
+++ /LMDZ5/trunk/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 2271)
@@ -604,5 +604,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", &
@@ -620,5 +620,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",      &
@@ -636,5 +636,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", &
@@ -652,5 +652,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/trunk/libf/phylmd/phys_output_write_mod.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/phys_output_write_mod.F90	(revision 2270)
+++ /LMDZ5/trunk/libf/phylmd/phys_output_write_mod.F90	(revision 2271)
@@ -174,5 +174,7 @@
          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, &
+         missing_val_nf90
 
     USE phys_local_var_mod, only: zxfluxlat, slp, zxtsol, zt2m, &
@@ -244,5 +246,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
@@ -290,5 +292,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.
 
@@ -658,6 +663,10 @@
        !       ENDIF
 
+  IF (.NOT.ok_all_xml) THEN
        ! ATTENTION, LES ANCIENS HISTWRITE ONT ETES CONSERVES EN ATTENDANT MIEUX:
        ! Champs interpolles sur des niveaux de pression
+#ifndef CPP_XIOS
+       missing_val=missing_val_nf90
+#endif
        DO iff=1, nfiles
           ll=0
@@ -681,5 +690,26 @@
           ENDDO
        ENDDO
-
+  ELSE
+!XIOS  CALL xios_get_field_attr("u850",default_value=missing_val)
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+       DO iff=1, nfiles
+          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), iff)
+                CALL histwrite_phy(o_vSTDlevs(ll),vlevSTD(:,k), iff)
+                CALL histwrite_phy(o_wSTDlevs(ll),wlevSTD(:,k), iff)
+                CALL histwrite_phy(o_zSTDlevs(ll),philevSTD(:,k), iff)
+                CALL histwrite_phy(o_qSTDlevs(ll),qlevSTD(:,k), iff)
+                CALL histwrite_phy(o_tSTDlevs(ll),tlevSTD(:,k), iff)
+             ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
+          ENDDO
+       ENDDO
+  ENDIF
        IF (vars_defined) THEN
           DO i=1, klon
Index: /LMDZ5/trunk/libf/phylmd/phys_state_var_mod.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/phys_state_var_mod.F90	(revision 2270)
+++ /LMDZ5/trunk/libf/phylmd/phys_state_var_mod.F90	(revision 2271)
@@ -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/trunk/libf/phylmd/physiq.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/physiq.F90	(revision 2270)
+++ /LMDZ5/trunk/libf/phylmd/physiq.F90	(revision 2271)
@@ -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 >>> 
@@ -3962,4 +3969,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/trunk/libf/phylmd/plevel.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/plevel.F90	(revision 2270)
+++ /LMDZ5/trunk/libf/phylmd/plevel.F90	(revision 2271)
@@ -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/trunk/libf/phylmd/plevel_new.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/plevel_new.F90	(revision 2270)
+++ /LMDZ5/trunk/libf/phylmd/plevel_new.F90	(revision 2271)
@@ -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/trunk/libf/phylmd/undefSTD.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/undefSTD.F90	(revision 2270)
+++ /LMDZ5/trunk/libf/phylmd/undefSTD.F90	(revision 2271)
@@ -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
