Index: CONFIG/UNIFORM/v6/LMDZORINCA_v6/GENERAL/DRIVER/lmdz.driver
===================================================================
--- CONFIG/UNIFORM/v6/LMDZORINCA_v6/GENERAL/DRIVER/lmdz.driver	(revision 2547)
+++ CONFIG/UNIFORM/v6/LMDZORINCA_v6/GENERAL/DRIVER/lmdz.driver	(revision 2694)
@@ -13,20 +13,4 @@
     RESOL_ATM_Y=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $2}' )
     RESOL_ATM_XY="${RESOL_ATM_X}x${RESOL_ATM_Y}"
-
-    ##-- Calendar type for LMDZ and create_etat0_limit
-    case ${config_UserChoices_CalendarType} in
-        leap|gregorian)
-            CalendarTypeForLmdz=earth_366d
-	    CalendarTypeForCreate=gregorian;;
-        noleap)
-            CalendarTypeForLmdz=earth_365d
-            CalendarTypeForCreate=${CalendarTypeForLmdz};;
-        360d)
-            CalendarTypeForLmdz=earth_360d
-            CalendarTypeForCreate=${CalendarTypeForLmdz};;
-        *)
-            CalendarTypeForLmdz=earth_360d
-            CalendarTypeForCreate=${CalendarTypeForLmdz}
-    esac
 
     ##- LMDZ physics version
@@ -63,34 +47,34 @@
     ##-- Output frequency purpose ....
     ##--  Initialisation  ....
-    ok_mensuel=n
-    ok_journe=n
-    ok_hf=n
-    ok_hf3h=n
-    ok_hf3hm=n
-    ok_stn=n
+    ok_mensuel=.FALSE.
+    ok_journe=.FALSE.
+    ok_hf=.FALSE.
+    ok_hf3h=.FALSE.
+    ok_hf3hm=.FALSE.
+    ok_stn=.FALSE.
 
     case ${config_UserChoices_PeriodLength} in
-	1Y|1y|1M|1m) ok_mensuel=y ;;
-	5D|5d|1D|1d) ok_journe=y ;;
+	1Y|1y|1M|1m) ok_mensuel=.TRUE. ;;
+	5D|5d|1D|1d) ok_journe=.TRUE. ;;
     esac
 
     for frequency in ${config_ATM_WriteFrequency} ; do
 	case ${frequency} in
-	    1M|1m) ok_mensuel=y ;;
+	    1M|1m) ok_mensuel=.TRUE. ;;
 	esac
 	case ${frequency} in
-	    5D|5d|1D|1d) ok_journe=y ;;
+	    5D|5d|1D|1d) ok_journe=.TRUE. ;;
 	esac
 	case ${frequency} in
-	    HF|hf) ok_hf=y ;;
+	    HF|hf) ok_hf=.TRUE. ;;
 	esac
 	case ${frequency} in 
-	    HF3h|hf3h) ok_hf3h=y ;;
+	    HF3h|hf3h) ok_hf3h=.TRUE. ;;
 	esac
 	case ${frequency} in 
-	    HF3hm|hf3hm) ok_hf3hm=y ;;
+	    HF3hm|hf3hm) ok_hf3hm=.TRUE. ;;
 	esac
 	case ${frequency} in
-	    STN|stn) ok_stn=y ;;
+	    STN|stn) ok_stn=.TRUE. ;;
 	esac
     done
@@ -110,49 +94,52 @@
 
     ##  Read LMDZ_COSP_OK in lmdz.card
-    if [ ! X${lmdz_UserChoices_LMDZ_COSP_OK} = X ] ; then
-	LMDZ_COSP_OK=${lmdz_UserChoices_LMDZ_COSP_OK}
-    else
-	LMDZ_COSP_OK=n
-    fi
-    ##  Read LMDZ_COSP_monthly in lmdz.card
-    if [ ! X${lmdz_UserChoices_LMDZ_COSP_monthly} = X ] ; then
-	LMDZ_COSP_monthly=${lmdz_UserChoices_LMDZ_COSP_monthly}
-    else
-	LMDZ_COSP_monthly=n
-    fi
-    ##  Read LMDZ_COSP_daily in lmdz.card
-    if [ ! X${lmdz_UserChoices_LMDZ_COSP_daily} = X ] ; then
-	LMDZ_COSP_daily=${lmdz_UserChoices_LMDZ_COSP_daily}
-    else
-	LMDZ_COSP_daily=n
-    fi
-    ##  Read LMDZ_COSP_hf in lmdz.card
-    if [ ! X${lmdz_UserChoices_LMDZ_COSP_hf} = X ] ; then
-	LMDZ_COSP_hf=${lmdz_UserChoices_LMDZ_COSP_hf}
-    else
-	LMDZ_COSP_hf=n
-    fi
+    if [ X${lmdz_UserChoices_LMDZ_COSP_OK} = Xy ] ; then
+	##  LMDZ_COSP_OK=y, now read all other COSP variables
+	##  Read LMDZ_COSP_monthly in lmdz.card
+	if [ X${lmdz_UserChoices_LMDZ_COSP_monthly} = Xy ] ; then
+	    LMDZ_COSP_monthly=.TRUE.
+	else
+	    LMDZ_COSP_monthly=.FALSE.
+	fi
+        ##  Read LMDZ_COSP_daily in lmdz.card
+	if [ X${lmdz_UserChoices_LMDZ_COSP_daily} = Xy ] ; then
+	    LMDZ_COSP_daily=.TRUE.
+	else
+	    LMDZ_COSP_daily=.FALSE.
+	fi
+        ##  Read LMDZ_COSP_hf in lmdz.card
+	if [ X${lmdz_UserChoices_LMDZ_COSP_hf} = Xy ] ; then
+	    LMDZ_COSP_hf=.TRUE.
+	else
+	    LMDZ_COSP_hf=.FALSE.
+	fi
+    else
+	# LMDZ_COSP_OK=n : All cosp output are deactivated
+	LMDZ_COSP_monthly=.FALSE.
+	LMDZ_COSP_daily=.FALSE.
+	LMDZ_COSP_hf=.FALSE.
+    fi	
 
     ##  Read LMDZ_NMC_monthly in lmdz.card
-    if [ ! X${lmdz_UserChoices_LMDZ_NMC_monthly} = X ] ; then
-	LMDZ_NMC_monthly=${lmdz_UserChoices_LMDZ_NMC_monthly}
-    else
-	LMDZ_NMC_monthly=n
-    fi
-
+    if [ X${lmdz_UserChoices_LMDZ_NMC_monthly} = Xy ] ; then
+	LMDZ_NMC_monthly=.TRUE.
+    else
+	LMDZ_NMC_monthly=.FALSE.
+    fi
+    
     ## Read LMDZ_NMC_daily in lmdz.card
-    if [ ! X${lmdz_UserChoices_LMDZ_NMC_daily} = X ] ; then
-	LMDZ_NMC_daily=${lmdz_UserChoices_LMDZ_NMC_daily}
-    else
-	LMDZ_NMC_daily=n
+    if [ X${lmdz_UserChoices_LMDZ_NMC_daily} = Xy ] ; then
+	LMDZ_NMC_daily=.TRUE.
+    else
+	LMDZ_NMC_daily=.FALSE.
     fi
     
     ## Read LMDZ_NMC_hf in lmdz.card
-    if [ ! X${lmdz_UserChoices_LMDZ_NMC_hf} = X ] ; then
-	LMDZ_NMC_hf=${lmdz_UserChoices_LMDZ_NMC_hf}
-    else
-	LMDZ_NMC_hf=n
-    fi
-
+    if [ X${lmdz_UserChoices_LMDZ_NMC_hf} = Xy ] ; then
+	LMDZ_NMC_hf=.TRUE.
+    else
+	LMDZ_NMC_hf=.FALSE.
+    fi
+    
 
     IGCM_debug_PopStack "ATM_Initialize"
@@ -164,26 +151,4 @@
     IGCM_debug_PushStack "ATM_Update"
 
-
-    case ${config_UserChoices_PeriodLength} in
-        *Y|*y) 
-               LMDZ_ecrit_ISCCP=30.
-               LMDZ_periodav=30.
-               if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then
-                  echo Do not consider following warning if your running create_etat0_limit :
-                  echo WARNING !!! For lmdz : calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d 
-	       fi
-               ;;
-        *)
-               LMDZ_ecrit_ISCCP=${PeriodLengthInDays}.
-               LMDZ_periodav=${PeriodLengthInDays}.
-               ;;
-    esac
-  
-    ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def
-    if [ ${CumulPeriod} -eq 1 ] ; then
-	RAZ_DATE=1
-    else
-	RAZ_DATE=0
-    fi
 
     ## Algorithme for special treatment for Bands_xxx file
@@ -322,120 +287,46 @@
     ##   COSP daily output for years 1979 and later (mandatory for historical CMIP5 run).
     if ([ X"${lmdz_UserChoices_LMDZ_COSP_daily1979}" = X"y" ] &&  [ ${year} -ge 1979 ]) ; then
-	LMDZ_COSP_daily=y
-    fi
-
-
-    ## output.def parameters
-    #  columns in phys_output_filekeys refer to the filenames given in phys_out_filenames in output.def :  
-    #                                            histmth       histday        histhf    histhf3h   histhf3hm   histstn
-    IGCM_comp_modifyDefFile nonblocker output.def phys_out_filekeys "${ok_mensuel} ${ok_journe}   ${ok_hf}  ${ok_hf3h} ${ok_hf3hm} ${ok_stn}"
-    IGCM_comp_modifyDefFile nonblocker output.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP}
-    IGCM_comp_modifyDefFile nonblocker output.def ok_cosp     ${LMDZ_COSP_OK}
-    IGCM_comp_modifyDefFile nonblocker output.def ok_mensuelCOSP  ${LMDZ_COSP_monthly}
-    IGCM_comp_modifyDefFile nonblocker output.def ok_journeCOSP   ${LMDZ_COSP_daily}
-    IGCM_comp_modifyDefFile nonblocker output.def ok_hfCOSP   ${LMDZ_COSP_hf}
-    IGCM_comp_modifyDefFile nonblocker 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
-	IGCM_comp_modifyXmlFile force file_def_histmth_lmdz.xml histmth enabled .FALSE. 
-	IGCM_comp_modifyXmlFile force file_def_histday_lmdz.xml histday enabled .FALSE. 
-	IGCM_comp_modifyXmlFile force file_def_histhf_lmdz.xml histhf enabled .FALSE.
-#	IGCM_comp_modifyXmlFile force file_def_histhf3h_lmdz.xml histhf3h enabled .FALSE.
-#	IGCM_comp_modifyXmlFile force file_def_histhf3hm_lmdz.xml histhf3hm enabled .FALSE.
-	IGCM_comp_modifyXmlFile force file_def_histstn_lmdz.xml histstn enabled .FALSE.
-	IGCM_comp_modifyXmlFile force file_def_histmthNMC_lmdz.xml histmthNMC enabled .FALSE.
-	IGCM_comp_modifyXmlFile force file_def_histdayNMC_lmdz.xml histdayNMC enabled .FALSE.
-	IGCM_comp_modifyXmlFile force file_def_histhfNMC_lmdz.xml histhfNMC enabled .FALSE.
-	IGCM_comp_modifyXmlFile force file_def_histmthCOSP_lmdz.xml histmthCOSP enabled .FALSE.
-	IGCM_comp_modifyXmlFile force file_def_histdayCOSP_lmdz.xml histdayCOSP enabled .FALSE.
-	IGCM_comp_modifyXmlFile force file_def_histhfCOSP_lmdz.xml histhfCOSP enabled .FALSE.
-
-    # Default output level : 5
-	IGCM_comp_modifyXmlFile force file_def_histmth_lmdz.xml histmth output_level 5 
-	IGCM_comp_modifyXmlFile force file_def_histday_lmdz.xml histday output_level 5 
-	IGCM_comp_modifyXmlFile force file_def_histhf_lmdz.xml histhf output_level 5
-#	IGCM_comp_modifyXmlFile force file_def_histhf3h_lmdz.xml histhf3h output_level 5
-#	IGCM_comp_modifyXmlFile force file_def_histhf3hm_lmdz.xml histhf3hm output_level 5
-	IGCM_comp_modifyXmlFile force file_def_histstn_lmdz.xml histstn output_level 5
-	IGCM_comp_modifyXmlFile force file_def_histmthNMC_lmdz.xml histmthNMC output_level 5
-	IGCM_comp_modifyXmlFile force file_def_histdayNMC_lmdz.xml histdayNMC output_level 5
-	IGCM_comp_modifyXmlFile force file_def_histhfNMC_lmdz.xml histhfNMC output_level 5
-        IGCM_comp_modifyXmlFile force file_def_histmthCOSP_lmdz.xml histmthCOSP output_level 5
-        IGCM_comp_modifyXmlFile force file_def_histdayCOSP_lmdz.xml histdayCOSP output_level 5
-        IGCM_comp_modifyXmlFile force file_def_histhfCOSP_lmdz.xml histhfCOSP output_level 5
-     # Filling of XML files 
-	if [ X${ok_mensuel} = Xy ] ; then
-	    IGCM_comp_modifyXmlFile force file_def_histmth_lmdz.xml histmth enabled .TRUE. 
-	    IGCM_comp_modifyXmlFile force file_def_histmth_lmdz.xml histmth output_freq 1mo
-	    IGCM_comp_modifyXmlFile force file_def_histmth_lmdz.xml histmth name histmth
-	fi
-	if [ X${ok_journe} = Xy ] ; then	
-	    IGCM_comp_modifyXmlFile force file_def_histday_lmdz.xml histday enabled .TRUE. 
-	    IGCM_comp_modifyXmlFile force file_def_histday_lmdz.xml histday output_freq 1d
-	    IGCM_comp_modifyXmlFile force file_def_histday_lmdz.xml histday name histday
-	    if [ X${OutLevel} = Xlow ] || [ X${OutLevel} = Xmedium ] ; then
-		IGCM_comp_modifyXmlFile force file_def_histday_lmdz.xml histday output_level 2
-	    fi
-	fi
-	if [ X${ok_hf} = Xy ] ; then
-	    IGCM_comp_modifyXmlFile force file_def_histhf_lmdz.xml histhf enabled .TRUE. 
-	    IGCM_comp_modifyXmlFile force file_def_histhf_lmdz.xml histhf output_freq 6h
-	    IGCM_comp_modifyXmlFile force file_def_histhf_lmdz.xml histhf name histhf
-	    if [ X${OutLevel} = Xlow ] ; then
-		IGCM_comp_modifyXmlFile force file_def_histhf_lmdz.xml histhf output_level 2
-	    fi
-	fi	
-#	if [ X${ok_hf3h} = Xy ] ; then
-#	    IGCM_comp_modifyXmlFile force file_def_histhf3h_lmdz.xml histhf3h enabled .TRUE. 
-#	    IGCM_comp_modifyXmlFile force file_def_histhf3h_lmdz.xml histhf3h output_freq 3h
-#	    IGCM_comp_modifyXmlFile force file_def_histhf3h_lmdz.xml histhf3h name histhf3h
-#	fi	
-#	if [ X${ok_hf3hm} = Xy ] ; then
-#	    IGCM_comp_modifyXmlFile force file_def_histhf3hm_lmdz.xml histhf3hm enabled .TRUE. 
-#	    IGCM_comp_modifyXmlFile force file_def_histhf3hm_lmdz.xml histhf3hm output_freq 3h
-#	    IGCM_comp_modifyXmlFile force file_def_histhf3hm_lmdz.xml histhf3hm name histhf3hm
-#	fi
-	if [ X${ok_stn} = Xy ] ; then
-	    IGCM_comp_modifyXmlFile force file_def_histstn_lmdz.xml histstn enabled .TRUE. 
-	    IGCM_comp_modifyXmlFile force file_def_histstn_lmdz.xml histstn output_freq 1800s
-	    IGCM_comp_modifyXmlFile force file_def_histstn_lmdz.xml histstn name histstn
-	fi
-	if [ X${LMDZ_NMC_monthly} = Xy ] ; then
-	    IGCM_comp_modifyXmlFile force file_def_histmthNMC_lmdz.xml histmthNMC enabled .TRUE. 
-	    IGCM_comp_modifyXmlFile force file_def_histmthNMC_lmdz.xml histmthNMC output_freq 1mo
-	    IGCM_comp_modifyXmlFile force file_def_histmthNMC_lmdz.xml histmthNMC name histmthNMC
-	fi
-	if [ X${LMDZ_NMC_daily} = Xy ] ; then
-	    IGCM_comp_modifyXmlFile force file_def_histdayNMC_lmdz.xml histdayNMC enabled .TRUE. 
-	    IGCM_comp_modifyXmlFile force file_def_histdayNMC_lmdz.xml histdayNMC output_freq 1d
-	    IGCM_comp_modifyXmlFile force file_def_histdayNMC_lmdz.xml histdayNMC name histdayNMC
-	fi
-	if [ X${LMDZ_NMC_hf} = Xy ] ; then
-	    IGCM_comp_modifyXmlFile force file_def_histhfNMC_lmdz.xml histhfNMC enabled .TRUE. 
-	    IGCM_comp_modifyXmlFile force file_def_histhfNMC_lmdz.xml histhfNMC output_freq 6h
-	    IGCM_comp_modifyXmlFile force file_def_histhfNMC_lmdz.xml histhfNMC name histhfNMC
-	fi
-
-	if [  X${LMDZ_COSP_OK} = Xy ] ; then
-            if [ X${LMDZ_COSP_monthly} = Xy ] ; then
-		IGCM_comp_modifyXmlFile force file_def_histmthCOSP_lmdz.xml histmthCOSP enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_histmthCOSP_lmdz.xml histmthCOSP output_freq 1mo
-		IGCM_comp_modifyXmlFile force file_def_histmthCOSP_lmdz.xml histmthCOSP name histmthCOSP
-	    fi
-	    if [ X${LMDZ_COSP_daily} = Xy ] ; then
-		IGCM_comp_modifyXmlFile force file_def_histdayCOSP_lmdz.xml histdayCOSP enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_histdayCOSP_lmdz.xml histdayCOSP output_freq 1d
-		IGCM_comp_modifyXmlFile force file_def_histdayCOSP_lmdz.xml histdayCOSP name histdayCOSP
-	    fi
-	    if [ X${LMDZ_COSP_hf} = Xy ] ; then
-		IGCM_comp_modifyXmlFile force file_def_histhfCOSP_lmdz.xml histhfCOSP enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_histhfCOSP_lmdz.xml histhfCOSP output_freq 6h
-		IGCM_comp_modifyXmlFile force file_def_histhfCOSP_lmdz.xml histhfCOSP name histhfCOSP
-	    fi
-	fi
-
-    fi
+	LMDZ_COSP_daily=.TRUE.
+    fi
+
+    ## Modifiy 
+    IGCM_comp_modifyXmlFile nonblocker file_def_histmth_lmdz.xml histmth enabled ${ok_mensuel}
+    
+    IGCM_comp_modifyXmlFile nonblocker file_def_histday_lmdz.xml histday enabled ${ok_journe}
+    
+    if [ X${OutLevel} = Xlow ] || [ X${OutLevel} = Xmedium ] ; then
+	IGCM_comp_modifyXmlFile nonblocker file_def_histday_lmdz.xml histday output_level 2
+    else
+	IGCM_comp_modifyXmlFile nonblocker file_def_histday_lmdz.xml histday output_level 5
+    fi
+    
+    IGCM_comp_modifyXmlFile nonblocker file_def_histhf_lmdz.xml histhf enabled ${ok_hf}
+    
+    if [ X${OutLevel} = Xlow ] ; then
+	IGCM_comp_modifyXmlFile nonblocker file_def_histhf_lmdz.xml histhf output_level 5
+    elif [ X${OutLevel} = Xmedium ] ; then
+	IGCM_comp_modifyXmlFile nonblocker file_def_histhf_lmdz.xml histhf output_level 6
+    elif [ X${OutLevel} = Xhigh ] ; then
+	IGCM_comp_modifyXmlFile nonblocker file_def_histhf_lmdz.xml histhf output_level 7
+    fi
+    	
+#       IGCM_comp_modifyXmlFile force file_def_histhf3h_lmdz.xml histhf3h enabled ${ok_hf3h}
+#	IGCM_comp_modifyXmlFile force file_def_histhf3h_lmdz.xml histhf3h output_freq 3h
+#	IGCM_comp_modifyXmlFile force file_def_histhf3h_lmdz.xml histhf3h name histhf3h
+
+#       IGCM_comp_modifyXmlFile force file_def_histhf3hm_lmdz.xml histhf3hm enabled ${ok_hf3hm}
+#	IGCM_comp_modifyXmlFile force file_def_histhf3hm_lmdz.xml histhf3hm output_freq 3h
+#	IGCM_comp_modifyXmlFile force file_def_histhf3hm_lmdz.xml histhf3hm name histhf3hm
+
+    IGCM_comp_modifyXmlFile nonblocker file_def_histstn_lmdz.xml histstn enabled ${ok_stn}
+
+    IGCM_comp_modifyXmlFile nonblocker file_def_histmthNMC_lmdz.xml histmthNMC enabled ${LMDZ_NMC_monthly}
+    IGCM_comp_modifyXmlFile nonblocker file_def_histdayNMC_lmdz.xml histdayNMC enabled ${LMDZ_NMC_daily}
+    IGCM_comp_modifyXmlFile nonblocker file_def_histhfNMC_lmdz.xml histhfNMC enabled ${LMDZ_NMC_hf}
+    
+    IGCM_comp_modifyXmlFile nonblocker file_def_histmthCOSP_lmdz.xml histmthCOSP enabled ${LMDZ_COSP_monthly}
+    IGCM_comp_modifyXmlFile nonblocker file_def_histdayCOSP_lmdz.xml histdayCOSP enabled ${LMDZ_COSP_daily}
+    IGCM_comp_modifyXmlFile nonblocker file_def_histhfCOSP_lmdz.xml histhfCOSP enabled ${LMDZ_COSP_hf}
+        
 
     ## gcm.def parameters : 
@@ -481,17 +372,34 @@
 
     ## run.def parameters
-    IGCM_comp_modifyDefFile blocker run.def dayref   ${InitDay}
-    IGCM_comp_modifyDefFile blocker run.def nday     ${PeriodLengthInDays}
-    IGCM_comp_modifyDefFile blocker run.def raz_date ${RAZ_DATE}
-    IGCM_comp_modifyDefFile blocker run.def periodav ${LMDZ_periodav}
-    IGCM_comp_modifyDefFile nonblocker run.def adjust   ${LMDZ_adjust}
+
+
+    ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def
+    if [ ${CumulPeriod} -eq 1 ] ; then
+	IGCM_comp_modifyDefFile blocker run.def raz_date  1
+    else
+	IGCM_comp_modifyDefFile blocker run.def raz_date  0
+    fi
+
+    ##-- Calendar type for LMDZ and create_etat0_limit
+    case ${config_UserChoices_CalendarType} in
+        leap|gregorian)
+	    IGCM_comp_modifyDefFile blocker run.def calend  gregorian ;;
+        noleap)
+	    IGCM_comp_modifyDefFile blocker run.def calend  earth_365d ;;
+        360d)
+	    IGCM_comp_modifyDefFile blocker run.def calend  earth_360d ;;
+        *)
+	    IGCM_comp_modifyDefFile blocker run.def calend  earth_360d ;;
+    esac
+
+    IGCM_comp_modifyDefFile blocker run.def dayref    ${InitDay}
+    IGCM_comp_modifyDefFile blocker run.def nday      ${PeriodLengthInDays}
+    IGCM_comp_modifyDefFile nonblocker run.def adjust ${LMDZ_adjust}
 
     # Set anneeref different for gcm and ce0l
-    # Variable calend is different for a run with create_etat0_limit and the gcm
     # Test if executable create_etat0_limit is present and lmdz.x is not present
     if [ -f create_etat0_limit* ] || [ -f ce0l* ] && [ ! -f lmdz.x ] ; then
 	# for case ce0l : always take current year
 	IGCM_comp_modifyDefFile blocker run.def anneeref ${year}
-	IGCM_comp_modifyDefFile blocker run.def calend   ${CalendarTypeForCreate}
 
         # Temporary, set use_filtre_fft=n because we now use dyn3d for ce0l version where fft is not implemented. 
@@ -501,12 +409,4 @@
 	# for case gcm : take first year of simulation
 	IGCM_comp_modifyDefFile blocker run.def anneeref ${InitYear}
-	IGCM_comp_modifyDefFile blocker run.def calend   ${CalendarTypeForLmdz}
-    fi
-
-    # Activate creation of file grilles_gcm.nc only at first period
-    if [ ${CumulPeriod} -eq 1 ] ; then
-	IGCM_comp_modifyDefFile nonblocker run.def grilles_gcm_netcdf y
-    else
-	IGCM_comp_modifyDefFile nonblocker run.def grilles_gcm_netcdf n
     fi
 
@@ -623,18 +523,17 @@
 
     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
+        # 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
 
         # Set ok_all_xml=y in run.def
-	IGCM_comp_modifyDefFile nonblocker run.def ok_all_xml y
-    else
-	# Deactivate ok_all_xml in run.def
-	IGCM_comp_modifyDefFile nonblocker run.def ok_all_xml n
+        IGCM_comp_modifyDefFile nonblocker run.def ok_all_xml y
+    else
+        # Deactivate ok_all_xml in run.def
+        IGCM_comp_modifyDefFile nonblocker run.def ok_all_xml n
     fi
     
Index: CONFIG/UNIFORM/v6/LMDZORINCA_v6/GENERAL/DRIVER/orchidee.driver
===================================================================
--- CONFIG/UNIFORM/v6/LMDZORINCA_v6/GENERAL/DRIVER/orchidee.driver	(revision 2547)
+++ CONFIG/UNIFORM/v6/LMDZORINCA_v6/GENERAL/DRIVER/orchidee.driver	(revision 2694)
@@ -6,19 +6,11 @@
     IGCM_debug_PushStack "SRF_Initialize"
 
-    RESOL_SRF=ALL
-
-    for frequency in ${config_SRF_WriteFrequency} ; do
-        case ${frequency} in
-            HF|hf) SRF_ok_hf=y ;;
-        esac
-    done
-
     ##- Define variable DefSuffix set in orchidee.card
-    ##  This variable is used in orchidee.card to choose 
-    ##  parameter file(orchidee.def_DefSuffix). 
+    ##  This variable is used in orchidee.card to choose
+    ##  parameter file(orchidee.def_DefSuffix).
     if [ ! X${orchidee_UserChoices_DefSuffix} = X ] ; then
-	DefSuffix=${orchidee_UserChoices_DefSuffix}
+        DefSuffix=${orchidee_UserChoices_DefSuffix}
     else
-	DefSuffix=Choi
+        DefSuffix=Choi
     fi
 
@@ -31,162 +23,93 @@
     IGCM_debug_PushStack "SRF_Update"
 
+    ## 1. Modifications in orchidee.def parameter file
+
     # Activate STOMATE if the compontent SBG=stomate is set in config.card
     if [ X${config_ListOfComponents_SBG} = Xstomate ] ; then
-	IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE y
+	# Activate stomate in orchidee.def
+        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE y
     else
-	IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE n
+	# Deactivate stomate in orchidee.def
+        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE n
+	# Deactivate output files for stomate
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled .FALSE.
+        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE.
     fi
 
-    typeset SECHIBA_WRITE_STEP
-
-    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-	IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 enabled .FALSE. 
-	IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba2 enabled .FALSE. 
-	IGCM_comp_modifyDefFile nonblocker orchidee.def XIOS_ORCHIDEE_OK y
+    # Define in orchidee.def if restart file should be used
+    if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then
+        IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in sechiba_rest_in.nc
     else
-	IGCM_comp_modifyDefFile nonblocker orchidee.def XIOS_ORCHIDEE_OK n
-    fi    
-
-    SRF_WriteFrequency=$( echo ${config_SRF_WriteFrequency} | sed -e 's/\([0-9]*[yYmMdDs]\).*/\1/' ) 
-    case ${SRF_WriteFrequency} in
-	*Y|*y) 
-	    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 )) 
-	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 output_freq ${WriteInYears}y
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 name sechiba_history 
-	    fi
-	    ;;
-	1M)
-	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 output_freq 1mo
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 name sechiba_history 
-	    fi
-	    case ${config_UserChoices_PeriodLength} in
-	    *Y|*y)
-		SECHIBA_WRITE_STEP=-1.
-		;;
-	    *M|*m)
-		SECHIBA_WRITE_STEP=-1.
-		;;
-	    *)
-		(( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 ))
-		;;
-	    esac
-	    ;;
-	*M|*m) 
-	    WriteInMonths=$( echo ${SRF_WriteFrequency} | awk -F '[mM]' '{print $1}' )
-	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 output_freq ${WriteInMonths}mo
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 name sechiba_history 
-	    fi
-	    case ${config_UserChoices_PeriodLength} in
-	    *Y|*y)
-		PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
-		(( SECHIBA_WRITE_STEP = PeriodLengthInDays * 86400 / PeriodLengthInYears / 12  ))
-		;;
-	    *M|*m)
-		PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' )
-		(( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInMonths  * 86400 / PeriodLengthInMonths  ))
-		;;
-	    *)
-		(( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 ))
-		if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-		    IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 enabled .TRUE. 
-		    IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 output_freq ${SECHIBA_WRITE_STEP}s
-		    IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 name sechiba_history
-		fi
-		;;
-	    esac
-	    ;;
-	5D|5d) 
-	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 output_freq 5d
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 name sechiba_history 
-	    fi
-	    (( SECHIBA_WRITE_STEP = 5 * 86400 )) 
-	    ;;
-	1D|1d) 
-	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 output_freq 1d
-		IGCM_comp_modifyXmlFile force 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
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 output_freq ${WriteInSeconds}s
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 name sechiba_history 
-	    fi
-	    (( SECHIBA_WRITE_STEP = WriteInSeconds )) ;;
-	*) 
-	    IGCM_debug_Exit "SRF_Update " ${SRF_WriteFrequency} " invalid WriteFrequency : choose in 1Y, 1M, 5D, 1D." 
-	    IGCM_debug_Verif_Exit ;;
-    esac
-
-#Use of XIOS ouputs only
-
-    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-	(( SECHIBA_WRITE_STEP = 0 ))
-    fi
-    IGCM_comp_modifyDefFile nonblocker orchidee.def WRITE_STEP ${SECHIBA_WRITE_STEP}
-    IGCM_comp_modifyDefFile nonblocker orchidee.def SECHIBA_HISTLEVEL ${orchidee_UserChoices_sechiba_LEVEL}
-
-    # Outputs HF in HISTFILE2 if required
-    if [ X${SRF_ok_hf} = Xy ] ; then
-	IGCM_comp_modifyDefFile nonblocker orchidee.def SECHIBA_HISTFILE2 y
-	if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-	    IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba2 enabled .TRUE. 
-	    IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba2 output_freq 10800s
-	    IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba2 name sechiba_out_2
-	fi
-    else
-	IGCM_comp_modifyDefFile nonblocker orchidee.def SECHIBA_HISTFILE2 n
-    fi
-    IGCM_comp_modifyDefFile nonblocker orchidee.def SECHIBA_HISTLEVEL2 1
-    IGCM_comp_modifyDefFile nonblocker orchidee.def WRITE_STEP2 10800.0
-
-    if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then
-	IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in sechiba_rest_in.nc
-    else
-	IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in NONE
+        IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in NONE
     fi
 
-# Modify in orchidee.def VEGET_UPDATE and LAND_COVER_CHANGE if they are set in orchidee.card section UserChoices
+    # Modify in orchidee.def VEGET_UPDATE and LAND_COVER_CHANGE if they are set in orchidee.card section UserChoices
     if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then
-	IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE   ${orchidee_UserChoices_VEGET_UPDATE}
+        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE   ${orchidee_UserChoices_VEGET_UPDATE}
     else
-	IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 0Y
+        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 0Y
     fi
     if [ ! X${orchidee_UserChoices_LAND_COVER_CHANGE} = X ] ; then
-	IGCM_comp_modifyDefFile nonblocker orchidee.def LAND_COVER_CHANGE ${orchidee_UserChoices_LAND_COVER_CHANGE}
+        IGCM_comp_modifyDefFile nonblocker orchidee.def LAND_COVER_CHANGE ${orchidee_UserChoices_LAND_COVER_CHANGE}
     else
-	IGCM_comp_modifyDefFile nonblocker orchidee.def LAND_COVER_CHANGE n
+        IGCM_comp_modifyDefFile nonblocker orchidee.def LAND_COVER_CHANGE n
     fi
 
-    #IGCM_sys_Cp ${RUN_DIR}/orchidee.def ${RUN_DIR}/run.def
-    #IGCM_sys_Put_Out ${RUN_DIR}/run.def ${R_SAVE}/${PREFIX}_run.def
+    # Activate creation of river description file only for the first period
+    if [ ${CumulPeriod} -eq 1 ] ; then
+        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC y
+    else
+        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC n
+    fi
 
-#Temporary way to fix bug on cimean variable
-    IGCM_comp_modifyXmlFile force field_def_orchidee.xml cimean enabled .FALSE. 
 
-    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+    ## 2. Mangement of output and modifications of related xml files
+
+    # Set default values for sechiba1_enabled, sechiba1_freq and sechiba2_enabled.
+    sechiba1_enabled=.FALSE.
+    sechiba2_enabled=.FALSE.
+    sechiba1_freq=0s
+
+    # Get WriteFrenquecies from config.card for SECHIBA
+    # Note that it is only possible to have one HF and one other option. 
+    # If more options are set in config.card only the latest will be used.
+    for frequency in ${config_SRF_WriteFrequency} ; do
+	case ${frequency} in
+	    *Y|*y) 
+		NbYears=$( echo ${frequency} | awk -F '[yY]' '{print $1}' )
+		NbDaysYear=$( IGCM_date_DaysInYear ${year} )
+		sechiba1_enabled=.TRUE.
+		sechiba1_freq=${NbYears}y ;;
+	    *M|*m)
+		NbMonths=$( echo ${frequency} | awk -F '[mM]' '{print $1}' )
+		sechiba1_enabled=.TRUE.
+		sechiba1_freq=${NbMonths}mo ;;
+	    *D|*d)
+		NbDays=$( echo ${frequency} | awk -F '[dD]' '{print $1}' )
+		sechiba1_enabled=.TRUE.
+		sechiba1_freq=${NbDays}d ;;
+	    *s)
+		WriteInSeconds=$( echo ${frequency} | awk -F '[s]' '{print $1}' )
+		sechiba1_enabled=.TRUE.
+		sechiba1_freq=${WriteInSeconds}s ;;
+            HF|hf) 
+		sechiba2_enabled=.TRUE. ;;
+	    *) 
+		IGCM_debug_Exit "SRF WriteFrequency=${frequency} is invalid. Choose between xY, xM, xD, xs and HF for Sechiba." ;;
+	esac
+    done
+
+    # Do the modifications in file_def_orchidee.xml
+    IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled ${sechiba1_enabled}
+    IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq ${sechiba1_freq}
+    IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled ${sechiba2_enabled}
+
     # 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
+    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
 
     IGCM_debug_PopStack "SRF_Update"
@@ -198,8 +121,4 @@
     IGCM_debug_PushStack "SRF_Finalize"
 
-    #IGCM_sys_Put_Out ${RUN_DIR}/used_run.def ${R_SAVE}/${PREFIX}_used_run.def
-
-    echo FINALIZE SRF !!!
-
     IGCM_debug_PopStack "SRF_Finalize"
 }
Index: CONFIG/UNIFORM/v6/LMDZORINCA_v6/GENERAL/DRIVER/stomate.driver
===================================================================
--- CONFIG/UNIFORM/v6/LMDZORINCA_v6/GENERAL/DRIVER/stomate.driver	(revision 2547)
+++ CONFIG/UNIFORM/v6/LMDZORINCA_v6/GENERAL/DRIVER/stomate.driver	(revision 2694)
@@ -1,5 +1,5 @@
 #!/bin/ksh
 
-#D- Driver du script pour ORCHIDEE
+#D- Driver pour ORCHIDEE stomate component
 
 #-----------------------------------------------------------------
@@ -8,6 +8,4 @@
     IGCM_debug_PushStack "SBG_Initialize"
 
-    RESOL_SBG=ALL
-    
     IGCM_debug_PopStack "SBG_Initialize"
 }
@@ -17,131 +15,47 @@
 {
     IGCM_debug_PushStack "SBG_Update"
+    
+    # Output management
 
-    typeset STOMATE_WRITE_STEP
+    # Set default values for stomate output files.
+    stomate_enabled=.FALSE.
+    stomate_freq=0s
 
-    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-	IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 enabled .FALSE. 
-	IGCM_comp_modifyXmlFile force 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 )) 
-	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 output_freq ${WriteInYears}y
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 name stomate_history 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 output_freq ${WriteInYears}y
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 name stomate_ipcc_history 
+    # Read WriteFrequency set in config.card section SBG. 
+    # Only one choice can be set as WriteFrequency. The same choice will be used for 
+    # both stomate_history and stomate_ipcc_history files. 
+    for frequency in ${config_SBG_WriteFrequency} ; do
+	case ${frequency} in
+	    *Y|*y) 
+		NbYears=$( echo ${frequency} | awk -F '[yY]' '{print $1}' )
+		NbDaysYear=$( IGCM_date_DaysInYear ${year} )
+		stomate_enabled=.TRUE.
+		stomate_freq=${NbYears}y ;;
+	    *M|*m) 
+		NbMonths=$( echo ${frequency} | awk -F '[mM]' '{print $1}' )
+		stomate_enabled=.TRUE.
+		stomate_freq=${NbMonths}mo ;;
+	    *D|*d)
+		NbDays=$( echo ${frequency} | awk -F '[dD]' '{print $1}' )
+		stomate_enabled=.TRUE.
+		stomate_freq=${NbDays}d ;;
+	    *) 
+		IGCM_debug_Exit "SBG WriteFrequency=${frequency} is invalid. Choose between xY, xM and xD for Stomate." ;;
+	esac
+    done
 
-	    fi
-	    ;;
-	1M|1m) 
-	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 output_freq 1mo
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 name stomate_history 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 output_freq 1mo
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 name stomate_ipcc_history 
-	    fi
-	    case ${config_UserChoices_PeriodLength} in
-	    *Y|*y)
-		STOMATE_WRITE_STEP=-1.
-		;;
-	    *M|*m)
-		STOMATE_WRITE_STEP=-1.
-		;;
-	    *)
-		(( STOMATE_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) )) ;;
-	    esac
-	    ;;
-	*M|*m) 
-	    WriteInMonths=$( echo ${config_SBG_WriteFrequency} | awk -F '[mM]' '{print $1}' )
-	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 output_freq ${WriteInMonths}mo
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 name stomate_history 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 output_freq ${WriteInMonths}mo
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 name stomate_ipcc_history 
-	    fi
-	    case ${config_UserChoices_PeriodLength} in
-	    *Y|*y)
-		PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
-		(( STOMATE_WRITE_STEP = 30 ))
-		;;
-	    *M|*m)
-		PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' )
-		(( STOMATE_WRITE_STEP = PeriodLengthInDays * WriteInMonths / PeriodLengthInMonths ))
-		;;
-	    *)
-		(( STOMATE_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) )) 
-		if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-		    IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 enabled .TRUE. 
-		    IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 output_freq ${STOMATE_WRITE_STEP}s
-		    IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 name stomate_history
-		    IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 enabled .TRUE. 
-		    IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 output_freq ${STOMATE_WRITE_STEP}s
-		    IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 name stomate_ipcc_history
-		fi
-		;;
-	    esac
-	    ;;
-	5D|5d) 
-	    (( STOMATE_WRITE_STEP = 5 ))
-	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 output_freq 5d
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 name stomate_history 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 output_freq 5d
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 name stomate_ipcc_history 
-	    fi
-	    ;;
-	1D|1d) 
-	    (( STOMATE_WRITE_STEP = 1 )) 
-	    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 output_freq 1d
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate1 name stomate_history 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 output_freq 1d
-		IGCM_comp_modifyXmlFile force 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
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 output_freq ${WriteInSeconds}s
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 name sechiba_history 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 enabled .TRUE. 
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 output_freq ${WriteInSeconds}s
-		IGCM_comp_modifyXmlFile force file_def_orchidee.xml stomate2 name stomate_ipcc_history 
-	    fi
-	    (( STOMATE_WRITE_STEP = 1 )) ;;
-	*) 
-	    IGCM_debug_Exit "SBG_Update " ${config_SBG_WriteFrequency} " invalid WriteFrequency : choose in 1Y, 1M, 5D, 1D." 
-	    IGCM_debug_Verif_Exit ;;
-    esac
+    # Modify file_def_orchidee.xml
+    IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled ${stomate_enabled}
+    IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq ${stomate_freq}
+    IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled ${stomate_enabled}
+    IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq ${stomate_freq}
+    
 
-
-#Use of XIOS library only
-
-    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-	(( STOMATE_WRITE_STEP = 0 ))
-    fi
-
-    IGCM_comp_modifyDefFile nonblocker orchidee.def STOMATE_HIST_DT ${STOMATE_WRITE_STEP}
-    IGCM_comp_modifyDefFile nonblocker orchidee.def STOMATE_HISTLEVEL ${stomate_UserChoices_stomate_LEVEL}
-
+    # Define in orchidee.def if restart file should be used
     if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SBG_Restart}" = "n" ] ) ; then
-	echo "STOMATE : without restart"
-	IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_RESTART_FILEIN NONE
+        echo "STOMATE : without restart"
+        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_RESTART_FILEIN NONE
     else
-	IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_RESTART_FILEIN stomate_rest_in.nc
+        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_RESTART_FILEIN stomate_rest_in.nc
     fi
 
@@ -152,14 +66,6 @@
 function SBG_Finalize
 {
-#set -vx
     IGCM_debug_PushStack "SBG_Finalize"
-
-    if [ $( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${year}1230 ) -ge 0 ] ; then
-	IGCM_sys_Put_Out stomate_Cforcing.nc ${R_OUT_SBG_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_stomate_Cforcing.nc
-	IGCM_sys_Put_Out stomate_forcing.nc  ${R_OUT_SBG_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_stomate_forcing.nc
-# 	rm -f stomate_Cforcing.nc
-# 	rm -f stomate_forcing.nc
-    fi
-
+    
     IGCM_debug_PopStack "SBG_Finalize"
 }
Index: CONFIG/UNIFORM/v6/LMDZORINCA_v6/GENERAL/DRIVER/xios.driver
===================================================================
--- CONFIG/UNIFORM/v6/LMDZORINCA_v6/GENERAL/DRIVER/xios.driver	(revision 2547)
+++ CONFIG/UNIFORM/v6/LMDZORINCA_v6/GENERAL/DRIVER/xios.driver	(revision 2694)
@@ -18,8 +18,5 @@
 # Activate server mode
     IGCM_comp_modifyXmlFile force iodef.xml using_server NONE true
-# If lmdz_UserChoices_XIOS=y add LMDZ as component id :
-    if [ X${lmdz_UserChoices_XIOS}  = Xy ] ; then
-	IGCM_comp_modifyXmlFile force iodef.xml oasis_codes_id NONE LMDZ,oceanx
-    fi 
+
     if [ -f namcouple ] ; then
 	sed -e "s/2  LMDZ oceanx/3 LMDZ oceanx ${config_Executable_IOS[1]}/" namcouple > namcouple.tmp 
