Index: trunk/LMDZ.PLUTO/libf/phypluto/phyetat0_mod.F90
===================================================================
--- trunk/LMDZ.PLUTO/libf/phypluto/phyetat0_mod.F90	(revision 3504)
+++ trunk/LMDZ.PLUTO/libf/phypluto/phyetat0_mod.F90	(revision 3506)
@@ -2,4 +2,9 @@
 
 implicit none
+
+real, save :: tab_cntrl_mod(100)
+
+!$OMP THREADPRIVATE(tab_cntrl_mod)
+
 
 contains
@@ -282,3 +287,39 @@
 end subroutine phyetat0
 
+
+!======================================================================
+subroutine ini_tab_controle_dyn_xios(idayref)
+
+use comcstfi_mod,        only: g, mugaz, omeg, rad, rcp
+use time_phylmdz_mod,  only: daysec, dtphys
+use mod_grid_phy_lmdz, only: nbp_lon, nbp_lat, nbp_lev
+
+implicit none
+
+integer*4, intent(in) :: idayref ! date (initial date for this run)
+
+integer :: length, l
+parameter (length = 100)
+real    :: tab_cntrl(length) ! run parameters are stored in this array
+
+do l = 1,length
+    tab_cntrl(l) = 0.
+enddo
+tab_cntrl(1)  = real(nbp_lon)
+tab_cntrl(2)  = real(nbp_lat-1)
+tab_cntrl(3)  = real(nbp_lev)
+tab_cntrl(4)  = real(idayref)
+tab_cntrl(5)  = rad
+tab_cntrl(6)  = omeg
+tab_cntrl(7)  = g
+tab_cntrl(8)  = mugaz
+tab_cntrl(9)  = rcp
+tab_cntrl(10) = daysec
+tab_cntrl(11) = dtphys
+
+tab_cntrl_mod = tab_cntrl
+
+end subroutine ini_tab_controle_dyn_xios
+
+
 end module phyetat0_mod
Index: trunk/LMDZ.PLUTO/libf/phypluto/physiq_mod.F90
===================================================================
--- trunk/LMDZ.PLUTO/libf/phypluto/physiq_mod.F90	(revision 3504)
+++ trunk/LMDZ.PLUTO/libf/phypluto/physiq_mod.F90	(revision 3506)
@@ -37,5 +37,5 @@
                           nesp, is_chim, is_condensable,constants_epsi_generic
       use time_phylmdz_mod, only: ecritphy, iphysiq, nday
-      use phyetat0_mod, only: phyetat0
+      use phyetat0_mod, only: phyetat0,tab_cntrl_mod
       use wstats_mod, only: callstats, wstats, mkstats
       use phyredem, only: physdem0, physdem1
@@ -79,5 +79,5 @@
       use datafile_mod, only: datadir
 #ifndef MESOSCALE
-      use vertical_layers_mod, only: presnivs, pseudoalt
+      USE vertical_layers_mod, ONLY: ap,bp,aps,bps,presnivs,pseudoalt
       use mod_phys_lmdz_omp_data, ONLY: is_omp_master
 #else
@@ -745,7 +745,7 @@
 #ifdef CPP_XIOS
 
-         write(*,*) "physiq: call initialize_xios_output"
-         call initialize_xios_output(pday,ptime,ptimestep,daysec, &
-                                     year_day,presnivs,pseudoalt,WNOI,WNOV)
+         if (is_master) write(*,*) "physiq: call initialize_xios_output"
+         call initialize_xios_output(pday,ptime,ptimestep,daysec,year_day, &
+                                     presnivs,pseudoalt,mlayer,WNOI,WNOV)
 #endif
 
@@ -2637,25 +2637,10 @@
       ! Send fields to XIOS: (NB these fields must also be defined as
       ! <field id="..." /> in context_lmdz_physics.xml to be correctly used)
-      CALL send_xios_field("ls",zls)
-
-      CALL send_xios_field("ps",ps)
-      CALL send_xios_field("area",cell_area)
-      CALL send_xios_field("p",pplay)
-      CALL send_xios_field("temperature",zt)
-      CALL send_xios_field("u",zu)
-      CALL send_xios_field("v",zv)
-      call send_xios_field("w",pw)
-
-      CALL send_xios_field("ISR",fluxtop_dn)
-      CALL send_xios_field("OLR",fluxtop_lw)
-      CALL send_xios_field("ASR",fluxabs_sw)
-
-      if (specOLR .and. corrk) then
-         call send_xios_field("OLR3D",OLR_nu)
-         call send_xios_field("IR_Bandwidth",DWNI)
-         call send_xios_field("VI_Bandwidth",DWNV)
-         call send_xios_field("OSR3D",OSR_nu)
-         call send_xios_field("GSR3D",GSR_nu)
-      endif
+      CALL send_xios_field("controle",tab_cntrl_mod,1)
+
+      CALL send_xios_field("ap",ap,1)
+      CALL send_xios_field("bp",bp,1)
+      CALL send_xios_field("aps",aps,1)
+      CALL send_xios_field("bps",bps,1)
 
       if (lastcall.and.is_omp_master) then
Index: trunk/LMDZ.PLUTO/libf/phypluto/write_output_mod.F90
===================================================================
--- trunk/LMDZ.PLUTO/libf/phypluto/write_output_mod.F90	(revision 3506)
+++ trunk/LMDZ.PLUTO/libf/phypluto/write_output_mod.F90	(revision 3506)
@@ -0,0 +1,343 @@
+MODULE write_output_mod
+
+implicit none
+
+private
+
+INTERFACE write_output
+    MODULE PROCEDURE write_output_d0, write_output_d1, write_output_d2, &
+                     write_output_i0, write_output_i1, write_output_i2, &
+                     write_output_l0, write_output_l1, write_output_l2
+END INTERFACE write_output
+
+public write_output
+
+!-----------------------------------------------------------------------
+contains
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_d0(field_name,title,units,field)
+! For a scalar
+
+#ifdef CPP_XIOS
+    use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*), intent(in) :: field_name
+character(*), intent(in) :: title
+character(*), intent(in) :: units
+real,         intent(in) :: field
+
+logical :: is_active ! For XIOS, should this field be sent or not
+
+call writediagfi(ngrid,field_name,title,units,0,(/field/))
+#ifdef CPP_XIOS
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field)
+#endif
+
+END SUBROUTINE write_output_d0
+
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_d1(field_name,title,units,field)
+! For a surface field
+
+#ifdef CPP_XIOS
+    use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*),       intent(in) :: field_name
+character(*),       intent(in) :: title
+character(*),       intent(in) :: units
+real, dimension(:), intent(in) :: field
+
+logical :: is_active ! For XIOS, should this field be sent or not
+
+call writediagfi(ngrid,field_name,title,units,2,field)
+#ifdef CPP_XIOS
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field)
+#endif
+
+END SUBROUTINE write_output_d1
+
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_d2(field_name,title,units,field)
+! For a "3D" horizontal-vertical field
+
+#ifdef CPP_XIOS
+    use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+use comsoil_h,         only: nsoilmx
+use writediagsoil_mod, only: writediagsoil
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*),         intent(in) :: field_name
+character(*),         intent(in) :: title
+character(*),         intent(in) :: units
+real, dimension(:,:), intent(in) :: field
+
+logical :: is_active ! For XIOS, should this field be sent or not
+
+if (size(field,2) == nsoilmx) then
+    call writediagsoil(ngrid,field_name,title,units,3,field)
+else
+    call writediagfi(ngrid,field_name,title,units,3,field)
+endif
+
+#ifdef CPP_XIOS
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field)
+#endif
+
+END SUBROUTINE write_output_d2
+
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_i0(field_name,title,units,field)
+! For a scalar
+
+#ifdef CPP_XIOS
+    use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*), intent(in) :: field_name
+character(*), intent(in) :: title
+character(*), intent(in) :: units
+integer,      intent(in) :: field
+
+logical :: is_active ! For XIOS, should this field be sent or not
+
+call writediagfi(ngrid,field_name,title,units,0,(/real(field)/))
+#ifdef CPP_XIOS
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,(/real(field)/))
+#endif
+
+END SUBROUTINE write_output_i0
+
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_i1(field_name,title,units,field)
+! For a surface field
+
+#ifdef CPP_XIOS
+    use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*),          intent(in) :: field_name
+character(*),          intent(in) :: title
+character(*),          intent(in) :: units
+integer, dimension(:), intent(in) :: field
+
+logical :: is_active ! For XIOS, should this field be sent or not
+
+call writediagfi(ngrid,field_name,title,units,2,real(field))
+#ifdef CPP_XIOS
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,real(field))
+#endif
+
+END SUBROUTINE write_output_i1
+
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_i2(field_name,title,units,field)
+! For a "3D" horizontal-vertical field
+
+#ifdef CPP_XIOS
+    use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+use comsoil_h,         only: nsoilmx
+use writediagsoil_mod, only: writediagsoil
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*),            intent(in) :: field_name
+character(*),            intent(in) :: title
+character(*),            intent(in) :: units
+integer, dimension(:,:), intent(in) :: field
+
+logical :: is_active ! For XIOS, should this field be sent or not
+
+if (size(field,2) == nsoilmx) then
+    call writediagsoil(ngrid,field_name,title,units,3,real(field))
+else
+    call writediagfi(ngrid,field_name,title,units,3,real(field))
+endif
+#ifdef CPP_XIOS
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,real(field))
+#endif
+
+END SUBROUTINE write_output_i2
+
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_l0(field_name,title,units,field)
+! For a scalar
+
+#ifdef CPP_XIOS
+    use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*), intent(in) :: field_name
+character(*), intent(in) :: title
+character(*), intent(in) :: units
+logical,      intent(in) :: field
+! Local argument used to convert logical to real array
+real, dimension(1) :: field_real
+logical :: is_active ! For XIOS, should this field be sent or not
+
+field_real = 0.
+if (field) field_real = 1.
+
+call writediagfi(ngrid,field_name,title,units,0,field_real)
+#ifdef CPP_XIOS
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field_real)
+#endif
+
+END SUBROUTINE write_output_l0
+
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_l1(field_name,title,units,field)
+! For a surface field
+
+#ifdef CPP_XIOS
+    use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*),          intent(in) :: field_name
+character(*),          intent(in) :: title
+character(*),          intent(in) :: units
+logical, dimension(:), intent(in) :: field
+! Local argument used to convert logical to real
+real, dimension(ngrid) :: field_real
+logical :: is_active ! For XIOS, should this field be sent or not
+
+field_real = 0.
+where (field) field_real = 1.
+
+call writediagfi(ngrid,field_name,title,units,2,field_real)
+#ifdef CPP_XIOS
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field_real)
+#endif
+
+END SUBROUTINE write_output_l1
+
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_l2(field_name,title,units,field)
+! For a "3D" horizontal-vertical field
+
+#ifdef CPP_XIOS
+    use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+use comsoil_h,         only: nsoilmx
+use writediagsoil_mod, only: writediagsoil
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*),            intent(in) :: field_name
+character(*),            intent(in) :: title
+character(*),            intent(in) :: units
+logical, dimension(:,:), intent(in) :: field
+! Local argument used to convert logical to real
+real, allocatable, dimension(:,:) :: field_real
+logical :: is_active ! For XIOS, should this field be sent or not
+
+allocate(field_real(size(field,1),size(field,2)))
+field_real = 0.
+where (field) field_real = 1.
+
+if (size(field,2) == nsoilmx) then
+    call writediagsoil(ngrid,field_name,title,units,3,field_real)
+else
+    call writediagfi(ngrid,field_name,title,units,3,field_real)
+endif
+
+#ifdef CPP_XIOS
+! is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field_real)
+#endif
+
+deallocate(field_real)
+
+END SUBROUTINE write_output_l2
+
+END MODULE write_output_mod
Index: trunk/LMDZ.PLUTO/libf/phypluto/writediagsoil.F90
===================================================================
--- trunk/LMDZ.PLUTO/libf/phypluto/writediagsoil.F90	(revision 3504)
+++ trunk/LMDZ.PLUTO/libf/phypluto/writediagsoil.F90	(revision 3506)
@@ -1,2 +1,8 @@
+module writediagsoil_mod
+
+implicit none
+
+contains
+
 subroutine writediagsoil(ngrid,name,title,units,dimpx,px)
 
@@ -86,9 +92,9 @@
     stop
   endif
-  
+
   ! Set output sample rate
   isample=int(ecritphy) ! same as for diagfi outputs
   ! Note ecritphy is known from control.h
-  
+
   ! Create output NetCDF file
   if (is_master) then
@@ -129,5 +135,5 @@
     enddo
    endif
-   
+
    ! write "header" of file (longitudes, latitudes, geopotential, ...)
    if (klon_glo>1) then ! general 3D case
@@ -138,8 +144,8 @@
 
   endif ! of if (is_master)
-  
+
   ! set zitau to -1 to be compatible with zitau incrementation step below
   zitau=-1
-  
+
 else
   ! If not an initialization call, simply open the NetCDF file
@@ -164,5 +170,5 @@
     date=float(zitau+1)/float(day_step)
     ! Note: day_step is known from control.h
-    
+
     if (is_master) then
      ! Get NetCDF ID for "time"
@@ -176,5 +182,5 @@
      if (ierr.ne.NF_NOERR) then
       write(*,*)"writediagsoil: Failed writing date to time variable"
-      stop 
+      stop
      endif
     endif ! of if (is_master)
@@ -217,5 +223,5 @@
   endif
 #endif
-  
+
   ! B. Write (append) the variable to the NetCDF file
   if (is_master) then
@@ -235,5 +241,5 @@
     call def_var(nid,name,title,units,4,id,varid,ierr)
   endif ! of if (ierr.ne.NF_NOERR)
-  
+
   ! B.2. Prepare things to be able to write/append the variable
   corners(1)=1
@@ -241,5 +247,5 @@
   corners(3)=1
   corners(4)=ntime
-  
+
   if (klon_glo==1) then
     edges(1)=1
@@ -250,5 +256,5 @@
   edges(3)=nsoilmx
   edges(4)=1
-  
+
   ! B.3. Write the slab of data
 !#ifdef NC_DOUBLE
@@ -324,5 +330,5 @@
   corners(2)=1
   corners(3)=ntime
-  
+
   if (klon_glo==1) then
     edges(1)=1
@@ -332,5 +338,5 @@
   edges(2)=nbp_lat
   edges(3)=1
-  
+
   ! B.3. Write the slab of data
 !#ifdef NC_DOUBLE
@@ -373,5 +379,5 @@
   ! B.2. Prepare things to be able to write/append the variable
   corners(1)=ntime
-  
+
   edges(1)=1
 
@@ -396,2 +402,4 @@
 
 end subroutine writediagsoil
+
+end module writediagsoil_mod
Index: trunk/LMDZ.PLUTO/libf/phypluto/xios_output_mod.F90
===================================================================
--- trunk/LMDZ.PLUTO/libf/phypluto/xios_output_mod.F90	(revision 3504)
+++ trunk/LMDZ.PLUTO/libf/phypluto/xios_output_mod.F90	(revision 3506)
@@ -11,5 +11,5 @@
 
  INTERFACE send_xios_field
-    MODULE PROCEDURE histwrite0d_xios,histwrite2d_xios,histwrite3d_xios!,histwrite1d_xios
+    MODULE PROCEDURE histwrite0d_xios,histwrite1d_xios,histwrite2d_xios,histwrite3d_xios
  END INTERFACE
 
@@ -17,10 +17,6 @@
 CONTAINS
 
-  SUBROUTINE initialize_xios_output(day,timeofday,dtphys,daysec,&
-                                    yearday,presnivs,pseudoalt,wnoi,wnov)
-!  USE mod_phys_lmdz_para, only: gather, bcast, &
-!                                jj_nb, jj_begin, jj_end, ii_begin, ii_end, &
-!                                mpi_size, mpi_rank, klon_mpi, &
-!                                is_sequential, is_south_pole_dyn
+  SUBROUTINE initialize_xios_output(day,timeofday,dtphys,daysec,yearday,   &
+                                    presnivs,pseudoalt,mlayer,wnoi,wnov)
   USE mod_phys_lmdz_para, ONLY: jj_nb, jj_begin, jj_end, ii_begin, ii_end, &
                                 mpi_size, mpi_rank, klon_mpi, &
@@ -44,6 +40,8 @@
   REAL,INTENT(IN) :: presnivs(:) ! vertical grid approximate pressure (Pa)
   REAL,INTENT(IN) :: pseudoalt(:) ! vertical grid approximate altitude (km)
+  REAL,INTENT(IN) :: mlayer(:) ! soil layer depth at intermediate level (m)
   REAL,INTENT(IN) :: wnoi(:) ! Array of wavenumbers at the spectral interval centers for the infrared.
   real,intent(in) :: wnov (:) !Array of wavenumbers at the spectral interval centers for the visible.
+
 
   INTEGER :: data_ibegin, data_iend
@@ -62,4 +60,9 @@
     CALL xios_set_axis_attr("altitude", n_glo=size(pseudoalt), value=pseudoalt,&
                             unit="km",positive="up")
+    CALL xios_set_axis_attr("interlayer", n_glo=size(pseudoalt)+1,&
+                            unit="km",positive="up")
+    IF (prt_level>=10) WRITE(lunout,*) "initialize_xios_output: call xios_set_axis_attr for soil"
+    CALL xios_set_axis_attr("soil_layers", n_glo=size(mlayer), value=mlayer,&
+                            unit="m",positive="down")
     if (prt_level >=10) write(lunout,*) "initialize_xios_output: call xios_set_axis_attr for IR_Wavenumber"
     write(lunout,*) "writing IR_Wavenumber now in initialize_xios_output"
@@ -139,5 +142,5 @@
     ! Now define the start time of this simulation
     ! NB: we substract dtphys because we want to set the origin of the time axis
-    start_date=time_origin+xios_duration(0,0,day,0,0,timeofday*daysec-dtphys)
+    start_date=time_origin
     call xios_set_start_date(start_date=start_date)
     if (prt_level>=10) then
@@ -148,4 +151,5 @@
     if (prt_level>=10) write(*,*) "initialize_xios_output: call wxios_closedef"
     CALL wxios_closedef()
+    if (prt_level>=10) write(*,*) "initialize_xios_output: after call wxios_closedef"
 
 !$OMP END MASTER
@@ -211,4 +215,23 @@
 
   END SUBROUTINE histwrite0d_xios
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE histwrite1d_xios(field_name,field,dimens)
+  USE xios, ONLY: xios_send_field
+  USE print_control_mod, ONLY: prt_level, lunout
+  IMPLICIT NONE
+
+    CHARACTER(LEN=*), INTENT(IN) :: field_name
+    REAL, DIMENSION(:), INTENT(IN) :: field
+    INTEGER, INTENT(IN) :: dimens
+    IF (prt_level >= 10) WRITE(lunout,*)'Begin histrwrite1d_xios ',trim(field_name)
+!$OMP MASTER
+    CALL xios_send_field(field_name,field)
+!$OMP END MASTER
+
+    IF (prt_level >= 10) WRITE(lunout,*)'End histrwrite1d_xios ',trim(field_name)
+
+  END SUBROUTINE histwrite1d_xios
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -221,5 +244,4 @@
   USE print_control_mod, ONLY: prt_level, lunout
   USE mod_grid_phy_lmdz, ONLY: nbp_lon
-  USE radinc_h ,only: L_NSPECTI,L_NSPECTV
   IMPLICIT NONE
 
@@ -230,14 +252,12 @@
     REAL :: Field2d(nbp_lon,jj_nb)
 
+    CHARACTER(len=128) :: msg
+
     IF (prt_level >= 10) WRITE(lunout,*)'Begin histrwrite2d_xios ',trim(field_name)
-    if ((size(field) .eq. L_NSPECTI) .or. (size(field) .eq. L_NSPECTV)) then
-!$OMP MASTER
-      ! only for spectral stuff: IR_Bandwidth and VI_Bandwidth
-      call xios_send_field(field_name,field)
-!$OMP END MASTER
-      return
-    endif
-    IF (SIZE(field)/=klon) CALL abort_physic('iophy::histwrite2d_xios','Field first DIMENSION not equal to klon',1)
-
+    IF (SIZE(field)/=klon) THEN
+      WRITE(msg,*) "Pb with field "//trim(field_name)//&
+                   " : Field first DIMENSION not equal to klon"
+      CALL abort_physic('iophy::histwrite2d_xios',trim(msg),1)
+    ENDIF
     CALL Gather_omp(field,buffer_omp)
 !$OMP MASTER
@@ -269,8 +289,15 @@
     INTEGER :: ip, n, nlev
 
+    CHARACTER(len=128) :: msg
+
   IF (prt_level >= 10) write(lunout,*)'Begin histrwrite3d_xios ',trim(field_name)
 
-    !Et on.... écrit
-    IF (SIZE(field,1)/=klon) CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)
+    !And we write...
+    IF (SIZE(field,1)/=klon) THEN
+      WRITE(msg,*) "Pb with field "//trim(field_name)//&
+                   " : Field first DIMENSION not equal to klon"
+      CALL abort_physic('iophy::histwrite3d',trim(msg),1)
+    ENDIF
+
     nlev=SIZE(field,2)
 
@@ -286,4 +313,23 @@
   END SUBROUTINE histwrite3d_xios
 
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+ FUNCTION xios_is_active_field(field_id)
+ USE xios, only: xios_field_is_active
+ USE mod_phys_lmdz_omp_transfert, only: bcast_omp
+ IMPLICIT NONE
+   LOGICAL ::  xios_is_active_field
+   CHARACTER(LEN=*) :: field_id
+
+ ! check with XIOS if "field_id" is requested by the user
+ ! to be in the output file(s)
+
+!$OMP BARRIER
+!$OMP MASTER
+   xios_is_active_field = xios_field_is_active(field_id)
+!$OMP END MASTER
+   CALL bcast_omp(xios_is_active_field)
+ END FUNCTION xios_is_active_field
+
 #endif
 
