Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/comgeomphy.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/comgeomphy.F90	(revision 245)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/comgeomphy.F90	(revision 253)
@@ -1,7 +1,10 @@
 module comgeomphy
+   integer,save             :: nvertex=0
    real,save,allocatable :: airephy(:)
    real,save,allocatable :: rlatd(:)
    real,save,allocatable :: rlond(:)
-!$OMP THREADPRIVATE(airephy,cuphy,cvphy,rlatd,rlond)
+   real,save,allocatable :: rbounds_lon(:,:)
+   real,save,allocatable :: rbounds_lat(:,:)
+!$OMP THREADPRIVATE(airephy,cuphy,cvphy,rlatd,rlond,rbounds_lon,rbounds_lat)
 contains
   
@@ -14,4 +17,6 @@
     allocate(rlatd(klon_omp))
     allocate(rlond(klon_omp))
+    allocate(rbounds_lon(klon_omp,nvertex))
+    allocate(rbounds_lat(klon_omp,nvertex))
 
   end subroutine initcomgeomphy
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/physiq.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/physiq.F90	(revision 245)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/physiq.F90	(revision 253)
@@ -35,4 +35,5 @@
                             obliquit, nres, z0
 
+      use xios_output_mod 
       implicit none
 
@@ -471,4 +472,8 @@
 
 
+
+      CALL update_xios_timestep
+
+
 !=======================================================================
 
@@ -2219,4 +2224,17 @@
       icount=icount+1
 
+!!!!!!!!!!!!!!!! section for XIOS output !!!!!!!!!!!!!!!      
+      CALL write_xios_field("tsurf",tsurf)
+      CALL write_xios_field("ps",ps)
+      CALL write_xios_field("phisinit",phisfi)
+      CALL write_xios_field("aire",area)
+      CALL write_xios_field("temp",zt)
+      CALL write_xios_field("u",zu)
+      CALL write_xios_field("v",zv)
+      CALL write_xios_field("p",pplay)
+      CALL write_xios_field("ISR",fluxtop_dn)
+      CALL write_xios_field("ASR",fluxabs_sw)
+      CALL write_xios_field("OLR",fluxtop_lw)
+
       if (lastcall) then
 
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/writediagfi.F
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/writediagfi.F	(revision 245)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/writediagfi.F	(revision 253)
@@ -115,5 +115,6 @@
       real phisfi_glo(ngrid) ! surface geopotential on global physics grid
 #endif
-
+     
+      RETURN
 !***************************************************************
 !Sortie des variables au rythme voulu
Index: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/xios_output.F90
===================================================================
--- codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/xios_output.F90	(revision 253)
+++ codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/xios_output.F90	(revision 253)
@@ -0,0 +1,125 @@
+MODULE xios_output_mod
+
+
+ INTEGER :: time_it
+ CHARACTER(LEN=*), PARAMETER :: context_id= "lmdz_physics"
+ 
+ PRIVATE :: time_it
+
+ INTERFACE write_xios_field
+    MODULE PROCEDURE write_xios_field_2d,write_xios_field_3d
+  END INTERFACE
+ 
+
+CONTAINS
+
+  SUBROUTINE initialize_xios_output
+  USE comgeomphy
+  USE xios
+  USE dimphy
+  USE mod_phys_lmdz_para
+  USE mod_grid_phy_lmdz
+  
+  IMPLICIT NONE
+    INCLUDE "comcstfi.h" 
+      
+    TYPE(xios_context) :: ctx_hdl
+    TYPE(xios_time)      :: dtime
+    REAL :: lev_value(klev)
+
+    REAL :: lon_mpi(klon_mpi)
+    REAL :: lat_mpi(klon_mpi)
+    REAL :: bounds_lon_mpi(klon_mpi,nvertex)
+    REAL :: bounds_lat_mpi(klon_mpi,nvertex)
+    INTEGER :: l
+
+    CALL gather_omp(rlond,lon_mpi)
+    CALL gather_omp(rlatd,lat_mpi)
+    CALL gather_omp(rbounds_lon,bounds_lon_mpi)
+    CALL gather_omp(rbounds_lat,bounds_lat_mpi)
+    
+!$OMP BARRIER    
+!$OMP MASTER
+    CALL xios_context_initialize(context_id,comm_lmdz_phy)
+    CALL xios_get_handle(context_id, ctx_hdl)
+    CALL xios_set_current_context(ctx_hdl)
+   
+    lev_value(:) = (/ (l,l=1,klev) /)     
+    
+    CALL xios_set_axis_attr("altitude",size=klev ,value=lev_value)
+    
+  
+    CALL xios_set_domain_attr("horiz_domain",ni_glo=klon_glo, ibegin=klon_mpi_begin, ni=klon_mpi)
+    CALL xios_set_domain_attr("horiz_domain", data_dim=1, type='unstructured' , nvertex=6)
+    CALL xios_set_domain_attr("horiz_domain", lonvalue=lon_mpi*180/Pi, latvalue=lat_mpi*180/Pi)
+    CALL xios_set_domain_attr("horiz_domain", bounds_lon=reshape(bounds_lon_mpi,(/nvertex,klon_mpi/),order=(/2,1/))*180./Pi )
+    CALL xios_set_domain_attr("horiz_domain", bounds_lat=reshape(bounds_lat_mpi,(/nvertex,klon_mpi/),order=(/2,1/))*180./Pi )
+  
+    dtime%second=dtphys
+    CALL xios_set_timestep(dtime)
+    time_it = 0  
+    CALL xios_close_context_definition()
+!$OMP END MASTER    
+!$OMP BARRIER    
+    
+  END SUBROUTINE initialize_xios_output
+
+  SUBROUTINE update_xios_timestep
+  USE xios
+  IMPLICIT NONE
+    CALL set_xios_context
+!$OMP MASTER
+    time_it=time_it+1
+    CALL xios_update_calendar(time_it)
+!$OMP END MASTER    
+  END SUBROUTINE update_xios_timestep
+
+
+  SUBROUTINE set_xios_context
+  USE XIOS
+  IMPLICIT NONE
+    TYPE(xios_context) :: ctx_hdl
+
+!$OMP MASTER
+    CALL xios_get_handle(context_id,ctx_hdl)
+    CALL xios_set_current_context(ctx_hdl)
+!$OMP END MASTER    
+  END SUBROUTINE set_xios_context
+
+
+  
+  SUBROUTINE write_xios_field_2d(field_id,field)
+  USE xios
+  USE mod_phys_lmdz_para
+  IMPLICIT NONE
+    CHARACTER(LEN=*) :: field_id
+    REAL,INTENT(IN)  :: field(:)
+    REAL             :: field_mpi(klon_mpi)
+  
+    CALL gather_omp(field,field_mpi)
+
+!$OMP MASTER
+    CALL xios_send_field(field_id,field_mpi)
+!$OMP END MASTER   
+    
+  END SUBROUTINE write_xios_field_2d
+
+  SUBROUTINE write_xios_field_3d(field_id,field)
+  USE xios
+  USE mod_phys_lmdz_para
+  IMPLICIT NONE
+    CHARACTER(LEN=*) :: field_id
+    REAL,INTENT(IN)  :: field(:,:)
+    REAL             :: field_mpi(klon_mpi,SIZE(field,2))
+  
+    CALL gather_omp(field,field_mpi)
+
+!$OMP MASTER
+    CALL xios_send_field(field_id,field_mpi)
+!$OMP END MASTER   
+    
+  END SUBROUTINE write_xios_field_3d
+  
+END MODULE xios_output_mod
+  
+  
