Index: CONFIG/UNIFORM/v6/IPSLCM6/AA_make
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6/AA_make	(revision 2297)
+++ CONFIG/UNIFORM/v6/IPSLCM6/AA_make	(revision 2300)
@@ -11,15 +11,15 @@
 	if [ -s ./.resol ] ; then $(M_K) `head -1 .resol` ; else $(M_K) ORCA2LIM2xLMD9695-L39 ; fi
 
-ORCA2LIM2xLMD9695-L39 : libioipsl oasis3-mct liborchidee xios orca2lim2 lmdz96x95x39 verif
+ORCA2LIM2xLMD9695-L39 : libioipsl oasis3-mct xios liborchidee orca2lim2 lmdz96x95x39 verif
 	echo "ORCA2LIM2xLMD9695-L39" >.resol
 	echo "RESOL_ATM_3D=96x95x39" >>.resol
 	echo "$(LIB_MPI)" >.libmpi
 
-ORCA2LIM3xLMD9695-L39 : libioipsl oasis3-mct liborchidee xios orca2lim3 lmdz96x95x39 verif
+ORCA2LIM3xLMD9695-L39 : libioipsl oasis3-mct xios liborchidee orca2lim3 lmdz96x95x39 verif
 	echo "ORCA2LIM3xLMD9695-L39" >.resol
 	echo "RESOL_ATM_3D=96x95x39" >>.resol
 	echo "$(LIB_MPI)" >.libmpi
 
-ORCA2LIM2xLMD9695-L39-NOPISCES : libioipsl oasis3-mct liborchidee xios orca2lim2nopisces lmdz96x95x39 verif
+ORCA2LIM2xLMD9695-L39-NOPISCES : libioipsl oasis3-mct xios liborchidee orca2lim2nopisces lmdz96x95x39 verif
 	echo "ORCA2LIM2xLMD9695-L39" >.resol
 	echo "RESOL_ATM_3D=96x95x39" >>.resol
@@ -27,60 +27,60 @@
 	echo "$(LIB_MPI)" >.libmpi
 
-ORCA2LIM2xLMD144142-L39 : libioipsl oasis3-mct liborchidee xios orca2lim2 lmdz144x142x39 verif
+ORCA2LIM2xLMD144142-L39 : libioipsl oasis3-mct xios liborchidee orca2lim2 lmdz144x142x39 verif
 	echo "ORCA2LIM2xLMD144142-L39" >.resol
 	echo "RESOL_ATM_3D=144x142x39" >>.resol
 	echo "$(LIB_MPI)" >.libmpi
 
-ORCA2LIM2xLMD144142-L59 : libioipsl oasis3-mct liborchidee xios orca2lim2 lmdz144x142x59 verif
+ORCA2LIM2xLMD144142-L59 : libioipsl oasis3-mct xios liborchidee orca2lim2 lmdz144x142x59 verif
 	echo "ORCA2LIM2xLMD144142-L59" >.resol
 	echo "RESOL_ATM_3D=144x142x59" >>.resol
 	echo "$(LIB_MPI)" >.libmpi
 
-ORCA2LIM3xLMD144142-L39 : libioipsl oasis3-mct liborchidee xios orca2lim3 lmdz144x142x39 verif
+ORCA2LIM3xLMD144142-L39 : libioipsl oasis3-mct xios liborchidee orca2lim3 lmdz144x142x39 verif
 	echo "ORCA2LIM3xLMD144142-L39" >.resol
 	echo "RESOL_ATM_3D=144x142x39" >>.resol
 	echo "$(LIB_MPI)" >.libmpi
 
-ORCA2LIM3xLMD144142-L59 : libioipsl oasis3-mct liborchidee xios orca2lim3 lmdz144x142x59 verif
+ORCA2LIM3xLMD144142-L59 : libioipsl oasis3-mct xios liborchidee orca2lim3 lmdz144x142x59 verif
 	echo "ORCA2LIM3xLMD144142-L59" >.resol
 	echo "RESOL_ATM_3D=144x142x59" >>.resol
 	echo "$(LIB_MPI)" >.libmpi
 
-ORCA1LIM2xLMD9695-L39 : libioipsl oasis3-mct liborchidee xios orca1lim2 lmdz96x95x39 verif
+ORCA1LIM2xLMD9695-L39 : libioipsl oasis3-mct xios liborchidee orca1lim2 lmdz96x95x39 verif
 	echo "ORCA1LIM2xLMD9695-L39" >.resol
 	echo "RESOL_ATM_3D=96x95x39" >>.resol
 	echo "$(LIB_MPI)" >.libmpi
 
-ORCA1LIM2xLMD144142-L39 : libioipsl oasis3-mct liborchidee xios orca1lim2 lmdz144x142x39 verif
+ORCA1LIM2xLMD144142-L39 : libioipsl oasis3-mct xios liborchidee orca1lim2 lmdz144x142x39 verif
 	echo "ORCA1LIM2xLMD144142-L39" >.resol
 	echo "RESOL_ATM_3D=144x142x39" >>.resol
 	echo "$(LIB_MPI)" >.libmpii
 
-ORCA1LIM2xLMD144142-L59 : libioipsl oasis3-mct liborchidee xios orca1lim2 lmdz144x142x59 verif
+ORCA1LIM2xLMD144142-L59 : libioipsl oasis3-mct xios liborchidee orca1lim2 lmdz144x142x59 verif
 	echo "ORCA1LIM2xLMD144142-L59" >.resol
 	echo "RESOL_ATM_3D=144x142x59" >>.resol
 	echo "$(LIB_MPI)" >.libmpii
 
-ORCA1LIM2xLMD144142-L79 : libioipsl oasis3-mct liborchidee xios orca1lim2 lmdz144x142x79 verif
+ORCA1LIM2xLMD144142-L79 : libioipsl oasis3-mct xios liborchidee orca1lim2 lmdz144x142x79 verif
 	echo "ORCA1LIM2xLMD144142-L79" >.resol
 	echo "RESOL_ATM_3D=144x142x79" >>.resol
 	echo "$(LIB_MPI)" >.libmpii
 
-ORCA1LIM3xLMD9695-L39 : libioipsl oasis3-mct liborchidee xios orca1lim3 lmdz96x95x39 verif
+ORCA1LIM3xLMD9695-L39 : libioipsl oasis3-mct xios liborchidee orca1lim3 lmdz96x95x39 verif
 	echo "ORCA1LIM3xLMD9695-L39" >.resol
 	echo "RESOL_ATM_3D=96x95x39" >>.resol
 	echo "$(LIB_MPI)" >.libmpi
 
-ORCA1LIM3xLMD144142-L39 : libioipsl oasis3-mct liborchidee xios orca1lim3 lmdz144x142x39 verif
+ORCA1LIM3xLMD144142-L39 : libioipsl oasis3-mct xios liborchidee orca1lim3 lmdz144x142x39 verif
 	echo "ORCA1LIM3xLMD144142-L39" >.resol
 	echo "RESOL_ATM_3D=144x142x39" >>.resol
 	echo "$(LIB_MPI)" >.libmpi
 
-ORCA1LIM3xLMD144142-L59 : libioipsl oasis3-mct liborchidee xios orca1lim3 lmdz144x142x59 verif
+ORCA1LIM3xLMD144142-L59 : libioipsl oasis3-mct xios liborchidee orca1lim3 lmdz144x142x59 verif
 	echo "ORCA1LIM3xLMD144142-L59" >.resol
 	echo "RESOL_ATM_3D=144x142x59" >>.resol
 	echo "$(LIB_MPI)" >.libmpi
 
-ORCA1LIM3xLMD144142-L79 : libioipsl oasis3-mct liborchidee xios orca1lim3 lmdz144x142x79 verif
+ORCA1LIM3xLMD144142-L79 : libioipsl oasis3-mct xios liborchidee orca1lim3 lmdz144x142x79 verif
 	echo "ORCA1LIM3xLMD144142-L79" >.resol
 	echo "RESOL_ATM_3D=144x142x79" >>.resol
@@ -94,5 +94,5 @@
 
 liborchidee : ../../modeles/ORCHIDEE/
-	(cd ../../modeles/ORCHIDEE/ ; ./makeorchidee_fcm -parallel mpi -arch $(FCM_ARCH) -j 8 -driver)
+	(cd ../../modeles/ORCHIDEE/ ; ./makeorchidee_fcm -parallel mpi -arch $(FCM_ARCH) -j 8 -xios -driver)
 
 lmdz96x95x39:
Index: CONFIG/UNIFORM/v6/IPSLCM6/EXPERIMENTS/IPSLCM/piControl/COMP/lmdz.card
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6/EXPERIMENTS/IPSLCM/piControl/COMP/lmdz.card	(revision 2297)
+++ CONFIG/UNIFORM/v6/IPSLCM6/EXPERIMENTS/IPSLCM/piControl/COMP/lmdz.card	(revision 2300)
@@ -49,5 +49,8 @@
 LMDZ_NMC_monthly=y
 LMDZ_NMC_daily=y
-LMDZ_NMC_hf=y
+LMDZ_NMC_hf=n
+
+# Use XIOS as output library
+XIOS=n
 
 [InitialStateFiles]
@@ -73,5 +76,17 @@
 	(${SUBMIT_DIR}/PARAM/config.def_${ConfType},  config.def),    \
 	(${SUBMIT_DIR}/PARAM/run.def, .), \
-	(${SUBMIT_DIR}/PARAM/traceur.def, .)
+	(${SUBMIT_DIR}/PARAM/traceur.def, .), \
+	(${SUBMIT_DIR}/PARAM/iodef.xml, . ),\
+	(${MODIPSL}/modeles/LMDZ/DefLists/context_lmdz.xml, . )            ,\
+	(${MODIPSL}/modeles/LMDZ/DefLists/field_def_lmdz.xml, . )          ,\
+	(${MODIPSL}/modeles/LMDZ/DefLists/file_def_histday_lmdz.xml, . )   ,\
+	(${MODIPSL}/modeles/LMDZ/DefLists/file_def_histhf_lmdz.xml, . )    ,\
+	(${MODIPSL}/modeles/LMDZ/DefLists/file_def_histins_lmdz.xml, . )   ,\
+	(${MODIPSL}/modeles/LMDZ/DefLists/file_def_histLES_lmdz.xml, . )   ,\
+	(${MODIPSL}/modeles/LMDZ/DefLists/file_def_histmth_lmdz.xml, . )   ,\
+	(${MODIPSL}/modeles/LMDZ/DefLists/file_def_histstn_lmdz.xml, . )   ,\
+	(${MODIPSL}/modeles/LMDZ/DefLists/file_def_histmthNMC_lmdz.xml, . ),\
+	(${MODIPSL}/modeles/LMDZ/DefLists/file_def_histdayNMC_lmdz.xml, . ),\
+	(${MODIPSL}/modeles/LMDZ/DefLists/file_def_histhfNMC_lmdz.xml, . )
 
 [RestartFiles]
@@ -80,5 +95,6 @@
 
 [OutputText]
-List=   (physiq.def, gcm.def, run.def, traceur.def, guide.def, config.def, used_run.def, debug.01)
+List=   (physiq.def, gcm.def, run.def, traceur.def, guide.def, config.def, used_run.def, iodef.xml, context_lmdz.xml,field_def_lmdz.xml,debug.01)
+#List=   (lmdz.x.prt)
 
 [OutputFiles]
Index: CONFIG/UNIFORM/v6/IPSLCM6/EXPERIMENTS/IPSLCM/piControl/COMP/opa9.card
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6/EXPERIMENTS/IPSLCM/piControl/COMP/opa9.card	(revision 2297)
+++ CONFIG/UNIFORM/v6/IPSLCM6/EXPERIMENTS/IPSLCM/piControl/COMP/opa9.card	(revision 2300)
@@ -35,6 +35,5 @@
 List=	(${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE}_ref, namelist_ref),      \
         (${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE}_cfg, namelist_cfg),      \
-        (${SUBMIT_DIR}/PARAM/iodef.xml,                    iodef.xml),      \
-        (${SUBMIT_DIR}/PARAM/context_nemo.xml,      context_nemo.xml),      \
+        (${SUBMIT_DIR}/PARAM/context_nemo.xml,   context_nemo.xml),         \
         (${SUBMIT_DIR}/PARAM/field_def_nemo.xml,   field_def_nemo.xml),     \
         (${SUBMIT_DIR}/PARAM/domain_def_nemo.xml,  domain_def_nemo.xml)
Index: CONFIG/UNIFORM/v6/IPSLCM6/EXPERIMENTS/IPSLCM/piControl/COMP/orchidee.card
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6/EXPERIMENTS/IPSLCM/piControl/COMP/orchidee.card	(revision 2297)
+++ CONFIG/UNIFORM/v6/IPSLCM6/EXPERIMENTS/IPSLCM/piControl/COMP/orchidee.card	(revision 2300)
@@ -10,4 +10,7 @@
 
 sechiba_LEVEL=11
+
+# Use XIOS as output library
+XIOS=n
 
 [InitialStateFiles]
@@ -24,5 +27,8 @@
 
 [ParametersFiles]
-List=	(${SUBMIT_DIR}/PARAM/orchidee.def_${DefSuffix}, orchidee.def)
+List=	(${SUBMIT_DIR}/PARAM/orchidee.def_${DefSuffix}, orchidee.def)   ,\
+	(${MODIPSL}/modeles/ORCHIDEE/src_xml/context_orchidee.xml, .)   ,\
+	(${MODIPSL}/modeles/ORCHIDEE/src_xml/field_def_orchidee.xml, .) ,\
+	(${MODIPSL}/modeles/ORCHIDEE/src_xml/file_def_orchidee.xml, .)
 
 [RestartFiles]
@@ -31,5 +37,5 @@
 
 [OutputText]
-List=   (out_orchidee, orchidee.def)
+List=   (out_orchidee, orchidee.def, context_orchidee.xml, field_def_orchidee.xml, file_def_orchidee.xml)
 
 [OutputFiles]
Index: CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/DRIVER/lmdz.driver
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/DRIVER/lmdz.driver	(revision 2297)
+++ CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/DRIVER/lmdz.driver	(revision 2300)
@@ -34,4 +34,23 @@
     LMDZ_sed  ${1} ${2} $DefValue
     IGCM_debug_PopStack "LMDZ_sed_default"
+    return $RET
+}
+
+function LMDZ_sed_xml
+{
+# Usage : LMDZ_sed_xml xml_file output_file attribute value 
+#         In file xml_file modify at the line containing id="output_file" the attribute "attribute=xxx" into "attribute=value"
+    
+    # Test if the fichier exist
+    if [ ! -f ${1} ] ; then
+	echo "WARNING : ${1} file does not exist. Following will not be done : LMDZ_sed : ${1} ${2} ${3} ${4}"
+        IGCM_debug_PopStack "LMDZ_sed"
+	return
+    fi
+    sed -e "/id=\"${2}\"/s/\(${3}=\"\)[^\"]*\(\"\)/\1${4}\2/" ${1} > ${1}.tmp
+    RET=$?
+    echo "LMDZ_sed : ${1} ${2} ${3} ${4}"
+    \mv ${1}.tmp ${1}
+
     return $RET
 }
@@ -327,4 +346,80 @@
     LMDZ_sed output.def ok_hfCOSP   ${LMDZ_COSP_hf}
     LMDZ_sed output.def ok_histNMC  "${LMDZ_NMC_monthly} ${LMDZ_NMC_daily} ${LMDZ_NMC_hf}"
+
+    # XIOS XML definition
+    if [ X${lmdz_UserChoices_XIOS}  = Xy ] ; then
+    # Default init : files are desactivated
+	LMDZ_sed_xml file_def_histmth_lmdz.xml histmth enabled .FALSE. 
+	LMDZ_sed_xml file_def_histday_lmdz.xml histday enabled .FALSE. 
+	LMDZ_sed_xml file_def_histhf_lmdz.xml histhf enabled .FALSE.
+	LMDZ_sed_xml file_def_histfh3h_lmdz.xml histfh3h enabled .FALSE.
+	LMDZ_sed_xml file_def_histhf3hm_lmdz.xml histfh3hm enabled .FALSE.
+	LMDZ_sed_xml file_def_histstn_lmdz.xml histstn enabled .FALSE.
+	LMDZ_sed_xml file_def_histmthNMC_lmdz.xml histmthNMC enabled .FALSE.
+	LMDZ_sed_xml file_def_histdayNMC_lmdz.xml histdayNMC enabled .FALSE.
+	LMDZ_sed_xml file_def_histhfNMC_lmdz.xml histhfNMC enabled .FALSE.
+    # Default output level : 5
+	LMDZ_sed_xml file_def_histmth_lmdz.xml histmth output_level 5 
+	LMDZ_sed_xml file_def_histday_lmdz.xml histday output_level 5 
+	LMDZ_sed_xml file_def_histhf_lmdz.xml histhf output_level 5
+	LMDZ_sed_xml file_def_histfh3h_lmdz.xml histfh3h output_level 5
+	LMDZ_sed_xml file_def_histhf3hm_lmdz.xml histfh3hm output_level 5
+	LMDZ_sed_xml file_def_histstn_lmdz.xml histstn output_level 5
+	LMDZ_sed_xml file_def_histmthNMC_lmdz.xml histmthNMC output_level 5
+	LMDZ_sed_xml file_def_histdayNMC_lmdz.xml histdayNMC output_level 5
+	LMDZ_sed_xml file_def_histhfNMC_lmdz.xml histhfNMC output_level 5
+     # Filling of XML files 
+	if [ X${ok_mensuel} = Xy ] ; then
+	    LMDZ_sed_xml file_def_histmth_lmdz.xml histmth enabled .TRUE. 
+	    LMDZ_sed_xml file_def_histmth_lmdz.xml histmth output_freq 1mo
+	    LMDZ_sed_xml file_def_histmth_lmdz.xml histmth name histmth
+	fi
+	if [ X${ok_journe} = Xy ] ; then	
+	    LMDZ_sed_xml file_def_histday_lmdz.xml histday enabled .TRUE. 
+	    LMDZ_sed_xml file_def_histday_lmdz.xml histday output_freq 1d
+	    LMDZ_sed_xml file_def_histday_lmdz.xml histday name histday
+	    if [ X${OutLevel} = Xlow ] || [ X${OutLevel} = Xmedium ] ; then
+		LMDZ_sed_xml file_def_histday_lmdz.xml histday output_level 2
+	    fi
+	fi
+	if [ X${ok_hf} = Xy ] ; then
+	    LMDZ_sed_xml file_def_histhf_lmdz.xml histhf enabled .TRUE. 
+	    LMDZ_sed_xml file_def_histhf_lmdz.xml histhf output_freq 6h
+	    LMDZ_sed_xml file_def_histhf_lmdz.xml histhf name histhf
+	    if [ X${OutLevel} = Xlow ] ; then
+		LMDZ_sed_xml file_def_histhf_lmdz.xml histhf output_level 2
+	    fi
+	fi	
+	if [ X${ok_hf3h} = Xy ] ; then
+	    LMDZ_sed_xml file_def_histhf3h_lmdz.xml histhf3h enabled .TRUE. 
+	    LMDZ_sed_xml file_def_histhf3h_lmdz.xml histhf3h output_freq 3h
+	    LMDZ_sed_xml file_def_histhf3h_lmdz.xml histhf3h name histhf3h
+	fi	
+	if [ X${ok_hf3hm} = Xy ] ; then
+	    LMDZ_sed_xml file_def_histhf3hm_lmdz.xml histhf3hm enabled .TRUE. 
+	    LMDZ_sed_xml file_def_histhf3hm_lmdz.xml histhf3hm output_freq 3h
+	    LMDZ_sed_xml file_def_histhf3hm_lmdz.xml histhf3hm name histhf3hm
+	fi
+	if [ X${ok_stn} = Xy ] ; then
+	    LMDZ_sed_xml file_def_histstn_lmdz.xml histstn enabled .TRUE. 
+	    LMDZ_sed_xml file_def_histstn_lmdz.xml histstn output_freq 1800s
+	    LMDZ_sed_xml file_def_histstn_lmdz.xml histstn name histstn
+	fi
+	if [ X${LMDZ_NMC_monthly} = Xy ] ; then
+	    LMDZ_sed_xml file_def_histmthNMC_lmdz.xml histmthNMC enabled .TRUE. 
+	    LMDZ_sed_xml file_def_histmthNMC_lmdz.xml histmthNMC output_freq 1mo
+	    LMDZ_sed_xml file_def_histmthNMC_lmdz.xml histmthNMC name histmthNMC
+	fi
+	if [ X${LMDZ_NMC_daily} = Xy ] ; then
+	    LMDZ_sed_xml file_def_histdayNMC_lmdz.xml histdayNMC enabled .TRUE. 
+	    LMDZ_sed_xml file_def_histdayNMC_lmdz.xml histdayNMC output_freq 1d
+	    LMDZ_sed_xml file_def_histdayNMC_lmdz.xml histdayNMC name histdayNMC
+	fi
+	if [ X${LMDZ_NMC_hf} = Xy ] ; then
+	    LMDZ_sed_xml file_def_histhfNMC_lmdz.xml histhfNMC enabled .TRUE. 
+	    LMDZ_sed_xml file_def_histhfNMC_lmdz.xml histhfNMC output_freq 6h
+	    LMDZ_sed_xml file_def_histhfNMC_lmdz.xml histhfNMC name histhfNMC
+	fi
+    fi
 
     ## gcm.def parameters : 
@@ -503,4 +598,15 @@
     fi
 
+    if [ X${lmdz_UserChoices_XIOS}  = Xy ] ; then
+    # Add include of LMDZ context in iodef.xml
+    # In iodef.xml add on next line after "COMPONENT CONTEXT"
+    #  <context id="LMDZ" src="./context_lmdz.xml"/>
+	echo '<context id="LMDZ" src="./context_lmdz.xml"/>' > add.tmp
+	cp iodef.xml iodef.xml.tmp
+	sed -e "/COMPONENT CONTEXT/r add.tmp" \
+	    iodef.xml.tmp > iodef.xml
+	rm iodef.xml.tmp add.tmp
+    fi
+    
     IGCM_debug_PopStack "ATM_Update"
 }
Index: CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/DRIVER/orchidee.driver
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/DRIVER/orchidee.driver	(revision 2297)
+++ CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/DRIVER/orchidee.driver	(revision 2300)
@@ -17,4 +17,23 @@
 }
 
+function ORCHIDEE_sed_xml
+{
+# Usage : ORCHIDEE_sed_xml xml_file output_file attribute value 
+#         In file xml_file modify at the line containing id="output_file" the attribute "attribute=xxx" into "attribute=value"
+    
+    # Test if the fichier exist
+    if [ ! -f ${1} ] ; then
+	echo "WARNING : ${1} file does not exist. Following will not be done : ORCHIDEE_sed : ${1} ${2} ${3} ${4}"
+        IGCM_debug_PopStack "LMDZ_sed"
+	return
+    fi
+    sed -e "/id=\"${2}\"/s/\(${3}=\"\)[^\"]*\(\"\)/\1${4}\2/" ${1} > ${1}.tmp
+    RET=$?
+    echo "ORCHIDEE_sed : ${1} ${2} ${3} ${4}"
+    \mv ${1}.tmp ${1}
+
+    return $RET
+}
+
 #-----------------------------------------------------------------
 function SRF_Initialize
@@ -49,4 +68,10 @@
     typeset SECHIBA_WRITE_STEP
 
+    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+	ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 enabled .FALSE. 
+	ORCHIDEE_sed_xml file_def_orchidee.xml sechiba2 enabled .FALSE. 
+	ORCHIDEE_sed XIOS_ORCHIDEE_OK y
+    fi    
+
     SRF_WriteFrequency=$( echo ${config_SRF_WriteFrequency} | sed -e 's/\([0-9]*[yYmMdDs]\).*/\1/' ) 
     case ${SRF_WriteFrequency} in
@@ -54,6 +79,17 @@
 	    WriteInYears=$( echo ${SRF_WriteFrequency} | awk -F '[yY]' '{print $1}' )
 	    PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
-	    (( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInYears / PeriodLengthInYears * 86400 )) ;;
+	    (( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInYears / PeriodLengthInYears * 86400 )) 
+	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 output_freq ${WriteInYears}y
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 name sechiba_history 
+	    fi
+	    ;;
 	1M)
+	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 output_freq 1mo
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 name sechiba_history 
+	    fi
 	    case ${config_UserChoices_PeriodLength} in
 	    *Y|*y)
@@ -70,4 +106,9 @@
 	*M|*m) 
 	    WriteInMonths=$( echo ${SRF_WriteFrequency} | awk -F '[mM]' '{print $1}' )
+	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 output_freq ${WriteInMonths}mo
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 name sechiba_history 
+	    fi
 	    case ${config_UserChoices_PeriodLength} in
 	    *Y|*y)
@@ -81,13 +122,35 @@
 	    *)
 		(( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 ))
+		if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+		    ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 enabled .TRUE. 
+		    ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 output_freq ${SECHIBA_WRITE_STEP}s
+		    ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 name sechiba_history
+		fi
 		;;
 	    esac
 	    ;;
 	5D|5d) 
-	    (( SECHIBA_WRITE_STEP = 5 * 86400 )) ;;
+	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 output_freq 5d
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 name sechiba_history 
+	    fi
+	    (( SECHIBA_WRITE_STEP = 5 * 86400 )) 
+	    ;;
 	1D|1d) 
-	    (( SECHIBA_WRITE_STEP = 86400 )) ;;
+	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 output_freq 1d
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 name sechiba_history 
+	    fi
+	    (( SECHIBA_WRITE_STEP = 86400 )) 
+	    ;;
 	*s)
 	    WriteInSeconds=$( echo ${SRF_WriteFrequency} | awk -F '[s]' '{print $1}' )
+	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 output_freq ${WriteInSeconds}s
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 name sechiba_history 
+	    fi
 	    (( SECHIBA_WRITE_STEP = WriteInSeconds )) ;;
 	*) 
@@ -96,4 +159,10 @@
     esac
 
+#Use of XIOS ouputs only
+
+    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+	(( SECHIBA_WRITE_STEP = 0 ))
+    fi
+
     ORCHIDEE_sed WRITE_STEP ${SECHIBA_WRITE_STEP}
     ORCHIDEE_sed SECHIBA_HISTLEVEL ${orchidee_UserChoices_sechiba_LEVEL}
@@ -102,4 +171,9 @@
     if [ X${SRF_ok_hf} = Xy ] ; then
 	ORCHIDEE_sed SECHIBA_HISTFILE2 y
+	if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+	    ORCHIDEE_sed_xml file_def_orchidee.xml sechiba2 enabled .TRUE. 
+	    ORCHIDEE_sed_xml file_def_orchidee.xml sechiba2 output_freq 10800s
+	    ORCHIDEE_sed_xml file_def_orchidee.xml sechiba2 name sechiba_out_2
+	fi
     else
 	ORCHIDEE_sed SECHIBA_HISTFILE2 n
@@ -130,4 +204,15 @@
 
 
+    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+    # Add include of orchidee context in iodef.xml
+    # In iodef.xml add on next line after "COMPONENT CONTEXT"
+    #  <context id="orchidee" src="./context_orchidee.xml"/>
+	echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
+	cp iodef.xml iodef.xml.tmp
+	sed -e "/COMPONENT CONTEXT/r add.tmp" \
+	    iodef.xml.tmp > iodef.xml
+	rm iodef.xml.tmp add.tmp
+    fi
+
     IGCM_debug_PopStack "SRF_Update"
 }
Index: CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/DRIVER/stomate.driver
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/DRIVER/stomate.driver	(revision 2297)
+++ CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/DRIVER/stomate.driver	(revision 2300)
@@ -20,10 +20,32 @@
     typeset STOMATE_WRITE_STEP
 
+    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+	ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 enabled .FALSE. 
+	ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 enabled .FALSE. 
+    fi   
     case ${config_SBG_WriteFrequency} in
 	*Y|*y) 
 	    WriteInYears=$( echo ${config_SBG_WriteFrequency} | awk -F '[yY]' '{print $1}' )
 	    PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
-	    (( STOMATE_WRITE_STEP = PeriodLengthInDays * WriteInYears / PeriodLengthInYears )) ;;
+	    (( STOMATE_WRITE_STEP = PeriodLengthInDays * WriteInYears / PeriodLengthInYears )) 
+	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 output_freq ${WriteInYears}y
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 name stomate_history 
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 output_freq ${WriteInYears}y
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 name stomate_ipcc_history 
+
+	    fi
+	    ;;
 	1M|1m) 
+	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 output_freq 1mo
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 name stomate_history 
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 output_freq 1mo
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 name stomate_ipcc_history 
+	    fi
 	    case ${config_UserChoices_PeriodLength} in
 	    *Y|*y)
@@ -39,4 +61,12 @@
 	*M|*m) 
 	    WriteInMonths=$( echo ${config_SBG_WriteFrequency} | awk -F '[mM]' '{print $1}' )
+	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 output_freq ${WriteInMonths}mo
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 name stomate_history 
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 output_freq ${WriteInMonths}mo
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 name stomate_ipcc_history 
+	    fi
 	    case ${config_UserChoices_PeriodLength} in
 	    *Y|*y)
@@ -49,13 +79,48 @@
 		;;
 	    *)
-		(( STOMATE_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) )) ;;
+		(( STOMATE_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) )) 
+		if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+		    ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 enabled .TRUE. 
+		    ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 output_freq ${STOMATE_WRITE_STEP}s
+		    ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 name stomate_history
+		    ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 enabled .TRUE. 
+		    ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 output_freq ${STOMATE_WRITE_STEP}s
+		    ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 name stomate_ipcc_history
+		fi
+		;;
 	    esac
 	    ;;
 	5D|5d) 
-	    (( STOMATE_WRITE_STEP = 5 )) ;;
+	    (( STOMATE_WRITE_STEP = 5 ))
+	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 output_freq 5d
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 name stomate_history 
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 output_freq 5d
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 name stomate_ipcc_history 
+	    fi
+	    ;;
 	1D|1d) 
-	    (( STOMATE_WRITE_STEP = 1 )) ;;
+	    (( STOMATE_WRITE_STEP = 1 )) 
+	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 output_freq 1d
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate1 name stomate_history 
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 output_freq 1d
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 name stomate_ipcc_history 
+	    fi
+	    ;;
 	*s)
 	    WriteInSeconds=$( echo ${config_SBG_WriteFrequency} | awk -F '[s]' '{print $1}' )
+	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 output_freq ${WriteInSeconds}s
+		ORCHIDEE_sed_xml file_def_orchidee.xml sechiba1 name sechiba_history 
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 enabled .TRUE. 
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 output_freq ${WriteInSeconds}s
+		ORCHIDEE_sed_xml file_def_orchidee.xml stomate2 name stomate_ipcc_history 
+	    fi
 	    (( STOMATE_WRITE_STEP = 1 )) ;;
 	*) 
@@ -65,4 +130,10 @@
 
     ORCHIDEE_sed STOMATE_OK_STOMATE y
+
+#Use of XIOS library only
+
+    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+	(( STOMATE_WRITE_STEP = 0 ))
+    fi
 
     ORCHIDEE_sed STOMATE_HIST_DT ${STOMATE_WRITE_STEP}
Index: CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/DRIVER/xios.driver
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/DRIVER/xios.driver	(revision 2297)
+++ CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/DRIVER/xios.driver	(revision 2300)
@@ -1,3 +1,22 @@
 #!/bin/ksh
+
+function XIOS_sed_xml
+{
+# Usage : XIOS_sed_xml xml_file attribute value 
+#         In file xml_file modify at the line containing id="attribute" the attribute value ">value<" 
+    
+    # Test if the fichier exist
+    if [ ! -f ${1} ] ; then
+	echo "WARNING : ${1} file does not exist. Following will not be done : XIOS_sed_xml : ${1} ${2} ${3}"
+        IGCM_debug_PopStack "XIOS_sed_xml"
+	return
+    fi
+    sed -e "s/\(<[^\"]*\"${2}\".*>\)\([^<]*\)\(<[^>]*\)/\1${3}\3/" ${1} > ${1}.tmp
+    RET=$?
+    echo "XIOS_sed_xml" : ${1} ${2} ${3}
+    \mv ${1}.tmp ${1}
+
+    return $RET
+}
 
 #-----------------------------------
@@ -17,7 +36,10 @@
 
     echo UPDATE IOS !!!
-
-    sed -e 's/<variable id="using_server"              type="boolean">false/<variable id="using_server" type="boolean">true/' iodef.xml > iodef.xml.tmp
-    IGCM_sys_Mv iodef.xml.tmp iodef.xml
+# Activate server mode
+    XIOS_sed_xml iodef.xml using_server true
+# If lmdz_UserChoices_XIOS=y add LMDZ as component id :
+    if [ X${lmdz_UserChoices_XIOS}  = Xy ] ; then
+	XIOS_sed_xml iodef.xml oasis_codes_id LMDZ,oceanx
+    fi 
     if [ -f namcouple ] ; then
 	sed -e "s/2  LMDZ oceanx/3 LMDZ oceanx ${config_Executable_IOS[1]}/" namcouple > namcouple.tmp 
Index: CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/PARAM/orchidee.def_CWRR
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/PARAM/orchidee.def_CWRR	(revision 2297)
+++ CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/PARAM/orchidee.def_CWRR	(revision 2300)
@@ -891,3 +891,6 @@
 # default = n
 
-#**************************************************************************
+# Flag to activate XIOS as output library
+XIOS_ORCHIDEE_OK = n
+
+#**************************************************************************
Index: CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/PARAM/orchidee.def_Choi
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/PARAM/orchidee.def_Choi	(revision 2297)
+++ CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/PARAM/orchidee.def_Choi	(revision 2300)
@@ -891,3 +891,6 @@
 # default = n
 
-#**************************************************************************
+# Flag to activate XIOS as output library
+XIOS_ORCHIDEE_OK = n
+
+#**************************************************************************
