Index: CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/inca.driver
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/inca.driver	(revision 2841)
+++ CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/inca.driver	(revision 3688)
@@ -30,4 +30,27 @@
     echo "INCA Tag : LMDZ-INCA" ${config_UserChoices_TagName}
 
+    ##- LMDZ physics version
+    ##  Read LMDZ_Physics option in lmdz.card, if not present take default value AP (old physics) 
+    if [ ! X${lmdz_UserChoices_LMDZ_Physics} = X ] ; then
+	LMDZ_Physics=${lmdz_UserChoices_LMDZ_Physics}
+    else
+	LMDZ_Physics=AP
+    fi
+    echo LMDZ physics version : ${LMDZ_Physics}
+
+    enable1=.FALSE.
+    enable2=.FALSE.
+
+    for frequency in ${config_CHM_WriteFrequency} ; do
+	case ${frequency} in 
+	    1D|1d) enable1=.TRUE. ;;
+	esac
+	case ${frequency} in
+	    1M|1m) enable2=.TRUE. ;;
+	esac
+    done
+
+
+
     IGCM_debug_PopStack "CHM_Initialize"
 }
@@ -40,24 +63,132 @@
     case ${CHEM} in 
 	AER)
-	IGCM_comp_modifyDefFile nonblocker run.def config_inca aero
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   forcage1     enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml forcage2     enabled ${enable2}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   aero1        enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml aero2        enabled ${enable2}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   chemistry1   enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml chemistry2   enabled ${enable2}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   emissions1   enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml emissions2   enabled ${enable2}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   species1     enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml species2     enabled ${enable2}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   dvel1        enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml dvel2        enabled ${enable2}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   washout1     enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml washout2     enabled ${enable2}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   reacflux1    enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml reacflux2    enabled ${enable2}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   invariants1  enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml invariants2  enabled ${enable2}
+
+	    if [ X${LMDZ_Physics} = X"AP" ] ; then
+		IGCM_comp_modifyDefFile nonblocker run.def config_inca aero
+	    else
+		IGCM_comp_modifyDefFile nonblocker run.def config_inca aeNP
+	    fi
 	;;
-	DUST)
-	IGCM_comp_modifyDefFile nonblocker run.def config_inca aero
+	DUSS)
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml forcage1     enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml aero1        enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml emissions1   enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml species1     enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml vegetation1  enabled ${enable1}
+
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml forcage2     enabled ${enable2}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml aero2        enabled ${enable2}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml emissions2   enabled ${enable2}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml species2     enabled ${enable2}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml vegetation2  enabled ${enable2}
+
+	    if [ X${LMDZ_Physics} = X"AP" ] ; then
+		IGCM_comp_modifyDefFile nonblocker run.def config_inca aero
+	    else
+		IGCM_comp_modifyDefFile nonblocker run.def config_inca aeNP
+	    fi
 	;;
 	NMHC) 
-	IGCM_comp_modifyDefFile nonblocker run.def config_inca chem
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml reacflux1    enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml emissions1   enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml species1     enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml chemistry1   enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml dvel1        enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml washout1     enabled ${enable1}
+
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml reacflux2  enabled ${enable2}  
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml emissions2 enabled ${enable2}  
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml species2   enabled ${enable2}  
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml chemistry2 enabled ${enable2}  
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml dvel2      enabled ${enable2}  
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml washout2   enabled ${enable2}  
+
+	    IGCM_comp_modifyDefFile nonblocker run.def config_inca chem
+	    ;;
+	NMHC_AER)
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml forcage1     enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml aero1        enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml species1     enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml chemistry1   enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml emissions1   enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml dvel1        enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml phtrate1     enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml washout1     enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml reacflux1    enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml vegetation1  enabled ${enable1}
+
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml forcage2    enabled ${enable2}  
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml aero2       enabled ${enable2} 
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml species2    enabled ${enable2} 
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml chemistry2  enabled ${enable2} 
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml emissions2  enabled ${enable2} 
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml dvel2       enabled ${enable2} 
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml phtrate2    enabled ${enable2} 
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml washout2    enabled ${enable2} 
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml reacflux2   enabled ${enable2} 
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml vegetation2 enabled ${enable2} 
+
+	    if [ X${LMDZ_Physics} = X"AP" ] ; then
+		IGCM_comp_modifyDefFile nonblocker run.def config_inca aero
+	    else
+		IGCM_comp_modifyDefFile nonblocker run.def config_inca aeNP
+	    fi
 	;;
-	NMHC_AER)
-	IGCM_comp_modifyDefFile nonblocker run.def config_inca aero
-	;;
-	CH4)
-	IGCM_comp_modifyDefFile nonblocker run.def config_inca chem
-	;;
-	CH4_AER)
-	IGCM_comp_modifyDefFile nonblocker run.def config_inca aero
+
+	NMHC_AER_S)
+ 	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml forcage1     enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml aero1        enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml species1     enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml chemistry1   enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml emissions1   enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml dvel1        enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml phtrate1     enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml washout1     enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml reacflux1    enabled ${enable1}
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml vegetation1  enabled ${enable1}
+
+ 	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml forcage2    enabled ${enable2} 
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml aero2       enabled ${enable2} 
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml species2    enabled ${enable2} 
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml chemistry2  enabled ${enable2} 
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml emissions2  enabled ${enable2} 
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml phtrate2    enabled ${enable2} 
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml dvel2       enabled ${enable2} 
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml washout2    enabled ${enable2} 
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml reacflux2   enabled ${enable2} 
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml vegetation2 enabled ${enable2}  
+
+	    if [ X${LMDZ_Physics} = X"AP" ] ; then
+		IGCM_comp_modifyDefFile nonblocker run.def config_inca aero
+	    else
+		IGCM_comp_modifyDefFile nonblocker run.def config_inca aeNP
+	    fi
 	;;
 	GES)
-	IGCM_comp_modifyDefFile nonblocker run.def config_inca chem
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml emissions1    enabled ${enable1}
+
+	    IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml emissions2    enabled ${enable2}
+
+	    IGCM_comp_modifyDefFile nonblocker run.def config_inca chem
 	esac
+
 
     # inca.def : Activate reading of 10m wind in files if LMDZ_10m_winds=n in inca.card
@@ -68,4 +199,32 @@
     fi
 
+    if [  X${inca_UserChoices_10m_winds_method} = X ] ; then
+    IGCM_comp_modifyDefFile nonblocker inca.def  10m_winds_method  threshold
+    else
+    IGCM_comp_modifyDefFile nonblocker inca.def  10m_winds_method ${inca_UserChoices_10m_winds_method}
+    fi
+
+
+    if [ ! X${inca_UserChoices_wind_parameter} = X ] ; then 
+	if [  X${inca_UserChoices_10m_winds_method} = Xthreshold ] ; then 
+	    IGCM_comp_modifyDefFile nonblocker inca.def  tref ${inca_UserChoices_wind_parameter}
+	    IGCM_comp_modifyDefFile nonblocker inca.def  kref DEFAULT
+	else
+	    IGCM_comp_modifyDefFile nonblocker inca.def  kref ${inca_UserChoices_wind_parameter}
+	    IGCM_comp_modifyDefFile nonblocker inca.def  tref DEFAULT
+	fi
+    else
+	    IGCM_comp_modifyDefFile nonblocker inca.def  kref DEFAULT
+	    IGCM_comp_modifyDefFile nonblocker inca.def  tref DEFAULT
+    fi
+
+    if [  X${inca_UserChoices_seasalt_corr} = X ] ; then
+    IGCM_comp_modifyDefFile nonblocker inca.def  ss_corr  DEFAULT
+    else
+    IGCM_comp_modifyDefFile nonblocker inca.def  ss_corr ${inca_UserChoices_seasalt_corr}
+    fi
+
+
+
     # inca.def : choose write frequency for inca_avgr in inca.card
     if [ ! X${inca_UserChoices_freq_write_chem} = X ] ; then
@@ -82,4 +241,39 @@
     fi
     
+    #inca.def : choose coupled model with orchidee  
+    if [ ! X${inca_UserChoices_CoupOrchInca} = X ]; then 
+	IGCM_comp_modifyDefFile nonblocker inca.def CoupOrchInca ${inca_UserChoices_CoupOrchInca}
+    else
+	IGCM_comp_modifyDefFile nonblocker inca.def CoupOrchInca n
+    fi
+
+    #inca.def : choose sedimentation schema 
+    if [ ! X${inca_UserChoices_multilayer_sedim} = X ]; then 
+	IGCM_comp_modifyDefFile nonblocker inca.def multilayer_sediment ${inca_UserChoices_multilayer_sedim}
+    else
+	IGCM_comp_modifyDefFile nonblocker inca.def multilayer_sediment y
+    fi
+
+    #inca.def : choose calcul interactif des diagnostiques flux chimique ou non  
+    if [ ! X${inca_UserChoices_calcul_flux} = X ]; then 
+	IGCM_comp_modifyDefFile nonblocker inca.def calcul_flux ${inca_UserChoices_calcul_flux}
+    else
+	IGCM_comp_modifyDefFile nonblocker inca.def calcul_flux n
+    fi
+
+    #inca.def : choose aircraft emission 
+    if [ ! X${inca_UserChoices_flag_plane} = X ]; then 
+	IGCM_comp_modifyDefFile nonblocker inca.def flag_plane ${inca_UserChoices_flag_plane}
+    else
+	IGCM_comp_modifyDefFile nonblocker inca.def flag_plane 0
+    fi
+    
+    #inca.def : choose time interpolation for sflx.nc
+    if [ ! X${inca_UserChoices_emi_interp_time} = X ]; then 
+	IGCM_comp_modifyDefFile nonblocker inca.def emi_interp_time ${inca_UserChoices_emi_interp_time}
+    else
+	IGCM_comp_modifyDefFile nonblocker inca.def emi_interp_time 1
+    fi
+
     #inca.def : choose output library 
     if [  X${inca_UserChoices_XIOS} = Xy ] ; then
@@ -95,10 +289,4 @@
     fi
 
-
-    if [  X${inca_UserChoices_10m_winds_method} = X ] ; then
-    IGCM_comp_modifyDefFile nonblocker inca.def  10m_winds_method  threshold
-    else
-    IGCM_comp_modifyDefFile nonblocker inca.def  10m_winds_method ${inca_UserChoices_10m_winds_method}
-    fi
 
 
@@ -115,4 +303,18 @@
     fi
 
+    # Add LongName as global attribute in XIOS output files (if LongName is not empty)
+    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
+	listfile=$(ls file_def*inca.xml)
+	echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
+	for file in ${listfile}
+	do
+	    cp ${file} ${file}.tmp
+	    sed -e "/<file id/r add.tmp" \
+		${file}.tmp > ${file}
+	    rm ${file}.tmp 
+	done
+	rm add.tmp
+    fi
+
     IGCM_debug_PopStack "CHM_Update"
 }
Index: CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/lim2.driver
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/lim2.driver	(revision 2841)
+++ CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/lim2.driver	(revision 3688)
@@ -16,4 +16,32 @@
     IGCM_debug_PushStack "ICE_Update"
 
+    ##--Write Frequency for iomput
+    ## Differents frequencies are allowed for ICE files
+
+    VI1D_ENABLE=".FALSE."
+    VI5D_ENABLE=".FALSE."
+    VI1M_ENABLE=".FALSE."
+    VI1Y_ENABLE=".FALSE."
+
+    for frequency in ${config_ICE_WriteFrequency} ; do
+        case ${frequency} in
+            ( 1D|1d ) VI1D_ENABLE=".TRUE." ;;
+            ( 5D|5d ) VI5D_ENABLE=".TRUE." ;;
+            ( 1M|1m ) VI1M_ENABLE=".TRUE." ;;
+            ( *[yY] ) VI1Y_ENABLE=".TRUE." ;;
+        esac
+    done
+
+
+  # Update iodef.xml
+
+    IGCM_debug_Print 1 'Informations into iodef.xml : VI1D_ENABLE VI5D_ENABLE VI1M_ENABLE VI1Y_ENABLE '
+    IGCM_debug_Print 1 ${VI1D_ENABLE}  ${VI5D_ENABLE} ${VI1M_ENABLE} ${VI1Y_ENABLE}
+
+    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-lim.xml 1d_lim enabled ${VI1D_ENABLE}
+    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-lim.xml 5d_lim enabled ${VI5D_ENABLE}
+    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-lim.xml 1m_lim enabled ${VI1M_ENABLE}
+    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-lim.xml 1y_lim enabled ${VI1Y_ENABLE}
+
     echo UPDATE ICE !!!
 
Index: CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/lim3.driver
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/lim3.driver	(revision 2841)
+++ CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/lim3.driver	(revision 3688)
@@ -16,4 +16,39 @@
     IGCM_debug_PushStack "ICE_Update"
 
+    ##--Write Frequency for iomput
+    ## Differents frequencies are allowed for ICE files
+
+    VI1D_ENABLE=".FALSE."
+    VI5D_ENABLE=".FALSE."
+    VI1M_ENABLE=".FALSE."
+    VI1Y_ENABLE=".FALSE."
+
+    for frequency in ${config_ICE_WriteFrequency} ; do
+        case ${frequency} in
+            ( 1D|1d ) VI1D_ENABLE=".TRUE." ;;
+            ( 5D|5d ) VI5D_ENABLE=".TRUE." ;;
+            ( 1M|1m ) VI1M_ENABLE=".TRUE." ;;
+            ( *[yY] ) VI1Y_ENABLE=".TRUE." ;;
+        esac
+    done
+
+
+  # Update iodef.xml
+
+    if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then       
+	VI1D_ENABLE=".FALSE."
+	VI5D_ENABLE=".FALSE."
+	VI1M_ENABLE=".FALSE."
+	VI1Y_ENABLE=".FALSE."
+    fi
+
+    IGCM_debug_Print 1 'Informations into iodef.xml : VI1D_ENABLE VI5D_ENABLE VI1M_ENABLE VI1Y_ENABLE '
+    IGCM_debug_Print 1 ${VI1D_ENABLE}  ${VI5D_ENABLE} ${VI1M_ENABLE} ${VI1Y_ENABLE}
+
+    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-lim.xml 1d_lim enabled ${VI1D_ENABLE}
+    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-lim.xml 5d_lim enabled ${VI5D_ENABLE}
+    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-lim.xml 1m_lim enabled ${VI1M_ENABLE}
+    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-lim.xml 1y_lim enabled ${VI1Y_ENABLE}
+
     echo UPDATE ICE !!!
 
Index: CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/lmdz.driver
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/lmdz.driver	(revision 2841)
+++ CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/lmdz.driver	(revision 3688)
@@ -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,96 +47,96 @@
     ##-- 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
 
-    ## Read LMDZ_NbPeriod_adjust option in lmdz.card 
-    if [ X"${lmdz_UserChoices_LMDZ_NbPeriod_adjust}" = X"" ] ; then
-	# The variable is not in lmdz.card, set default value
-	LMDZ_NbPeriod_adjust=0
-    else	
-	LMDZ_NbPeriod_adjust=${lmdz_UserChoices_LMDZ_NbPeriod_adjust}
-    fi
-
-    if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
-	LMDZ_Bands_file_name=${lmdz_UserChoices_LMDZ_Bands_file_name}
-    fi
-
-
-    ##  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"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then
+        ok_mensuel=.FALSE.
+        ok_journe=.FALSE.
+        ok_hf=.FALSE.
+        ok_hf3h=.FALSE.
+        ok_hf3hm=.FALSE.
+        ok_stn=.FALSE.
+    fi
+
+##  Read LMDZ_COSP_OK in lmdz.card
+    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,61 +148,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
-    ## For CumulPeriod=1 ; 
-    ##        IF NbPeriod_Adjust = 0 ; set LMDZ_adjust=n
-    ##                                IF LMDZ_Bands_file_name was given in lmdz.card THEN Get Bands file directly from server. Store it later with _0 suffix.
-    ##                                IF no LMDZ_Bands_file_name was given, start without Bands file. Store it later with _0 suffix.
-    ##        ELSE set LMDZ_adjust=y ; start without Bands file ; Store it later in PARAM/ directory in submit directory with suffix _1 ;
-    ##
-    ## For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; 
-    ##       Get Bands file from PARAM/ in submit directory (CumulPeriod-1) ; set LMDZ_adjust=y ; Store Bands file in PARAM/ ;
-    ##
-    ## For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from PARAM/ ; Do not store ;
-
-    if [ ${CumulPeriod} -eq 1 ] ; then
-        if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
-	    if [ ! X${LMDZ_Bands_file_name} = X ] ; then
-		IGCM_sys_Get ${LMDZ_Bands_file_name} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat 
-		IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat
-		IGCM_debug_Print 1 "Bands file forced to ${LMDZ_Bands_file_name} and stored in ${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_0"
-	    fi
-        fi
-    fi
-
-    LMDZ_adjust=n
-    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y
-
-    RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart
-    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) 
-
-    # Get Bands file from PARAM directory if file exist
-    if ( [ ${CumulPeriod} -gt 1 ] && [ -f ${SUBMIT_DIR}/PARAM/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${RefPeriod} ] ) ; then
-        IGCM_sys_Cp ${SUBMIT_DIR}/PARAM/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${RefPeriod} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat
-        IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat
-    fi
-
     ##-- GHG forcing :
     ##   If forcing file exist in run directory, read values for the current year 
@@ -226,4 +153,6 @@
 
     # Read value for solaire from file SOLARANDVOLCANOES.txt. If file not existing, take DEFAULT value from file. 
+    IGCM_debug_Print 1 "Note that the solaire parameter is here below changed but it is only used by LMDZ for old physics(AP and NPv3.2)"
+    IGCM_debug_Print 1 "For newer physics with iflag_rrtm=1 and ok_suntime_rrtm=y, the solar constant is instead taken from solarforcing.nc file"
     if [ -f SOLARANDVOLCANOES.txt ] ; then
 	value=`grep Annee_${year} SOLARANDVOLCANOES.txt | awk -F= '{print $2}'`
@@ -240,4 +169,5 @@
 
     # Read value for co2_ppm from file CO2.txt. If file not existing, take DEFAULT value from file. 
+    # Calculate co2_ppm_per as co2_ppm*4.
     if [ -f CO2.txt ] ; then
        	value=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'`
@@ -247,8 +177,11 @@
 	    IGCM_debug_Verif_Exit
 	fi
+	value4=`grep Annee_${year} CO2.txt | awk -F= '{print $2 * 4}'`
     else
 	value=DEFAULT
+	value4=DEFAULT
     fi
     IGCM_comp_modifyDefFile nonblocker config.def co2_ppm $value
+    IGCM_comp_modifyDefFile nonblocker config.def co2_ppm_per $value4
 
 
@@ -322,176 +255,80 @@
     ##   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
-
-    ## gcm.def parameters : 
-    # Modification of variable iphysiq depending on the physics
-    if [ X${LMDZ_Physics} = X"AP" ] ; then
-	if [ ${RESOL_ATM_3D} = 96x95x39 ]; then
-	    value=10
-	elif [ ${RESOL_ATM_3D} = 144x142x39 ]; then
-	    value=15
-	else
-	    IGCM_debug_Print 1 "LMDZ_Physics=${LMDZ_Physics} has not been tested for the current resolution RESOL_ATM_3D=${RESOL_ATM_3D}. "
-	    IGCM_debug_Print 1 "iphysiq must be defined for the current combination of resolution and phyiscs package"
-	    IGCM_debug_Exit "You need to add a special case in lmdz.driver to handle the above combination."
-	fi
-    elif [ X${LMDZ_Physics} = X"NPv3.1" ] ; then
-	if  [ ${RESOL_ATM_3D} = 96x95x39 ] ; then
-	    value=5
-	elif [ ${RESOL_ATM_3D} = 144x142x39 ] ; then
-	    value=5
-	else
-	    IGCM_debug_Print 1 "LMDZ_Physics=${LMDZ_Physics} has not been tested for the current resolution RESOL_ATM_3D=${RESOL_ATM_3D}. "
-	    IGCM_debug_Print 1 "iphysiq must be defined for the current combination of resolution and phyiscs package"
-	    IGCM_debug_Exit "You need to add a special case in lmdz.driver to handle the above combination."
-	fi
-    elif [ X${LMDZ_Physics} = X"NPv3.2" ] ; then
-	if [ ${RESOL_ATM_3D} = 96x95x39 ] ; then
-	    value=5
-	elif [ ${RESOL_ATM_3D} = 144x142x39 ] ; then
-	    value=5
-	elif [ ${RESOL_ATM_3D} = 128x118x39 ] ; then
-	    value=15
-	else
-	    IGCM_debug_Print 1 "LMDZ_Physics=${LMDZ_Physics} has not been tested for the current resolution RESOL_ATM_3D=${RESOL_ATM_3D}. "
-	    IGCM_debug_Print 1 "iphysiq must be defined for the current combination of resolution and phyiscs package"
-	    IGCM_debug_Exit "You need to add a special case in lmdz.driver to handle the above combination."
-	fi
-    else
-	# Take default value set in gcm.def
-	value=DEFAULT
-    fi
-    IGCM_comp_modifyDefFile nonblocker gcm.def iphysiq $value
-    
+	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 nonblocker file_def_histhf3h_lmdz.xml histhf3h enabled ${ok_hf3h}
+    IGCM_comp_modifyXmlFile nonblocker file_def_histhf3hm_lmdz.xml histhf3hm enabled ${ok_hf3hm}
+
+    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}
+
+    # Activate the histstrataer output file only for configuration with interactive stratospheric aersols 
+    # done by setting the key word LMDZ_strataero=y in lmdz.card
+    if [ X${lmdz_UserChoices_LMDZ_strataero} = Xy ] ; then
+	IGCM_comp_modifyXmlFile nonblocker file_def_histstrataer_lmdz.xml histstrataer enabled .TRUE.
+    else
+	IGCM_comp_modifyXmlFile nonblocker file_def_histstrataer_lmdz.xml histstrataer enabled .FALSE.
+    fi
+
 
     ## 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}
 
     # 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 +338,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
 
@@ -587,4 +416,19 @@
     else
 	IGCM_comp_modifyDefFile nonblocker config.def ok_cdnc n	
+    fi 
+
+    # config.def : Activate COSP
+    if [ ! X${lmdz_UserChoices_LMDZ_COSP_OK} = X ]; then 
+	IGCM_comp_modifyDefFile nonblocker config.def ok_cosp ${lmdz_UserChoices_LMDZ_COSP_OK}
+    else
+	IGCM_comp_modifyDefFile nonblocker config.def ok_cosp n	
+    fi 
+
+    # config.def : Modify parameter pmagic if it is set in lmdz.card
+    if [ ! X${lmdz_UserChoices_pmagic} = X ]; then 
+	IGCM_comp_modifyDefFile nonblocker config.def pmagic ${lmdz_UserChoices_pmagic}
+    else
+	# Take default value set in config.def
+	IGCM_comp_modifyDefFile nonblocker config.def pmagic DEFAULT
     fi 
 
@@ -622,21 +466,30 @@
     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
-
-        # 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
-    fi
-    
+    echo '<context id="LMDZ" src="./context_lmdz.xml"/>' > add.tmp
+    if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then
+	echo '<context id="LMDZ" src="./ping_lmdz.xml"/>' >> add.tmp
+	echo '<context id="LMDZ" src="./dr2xml_lmdz.xml"/>' >> add.tmp
+    fi
+    cp iodef.xml iodef.xml.tmp
+    sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml
+    rm iodef.xml.tmp add.tmp
+
+    #Long Name as global attribute (if LongName is not empty)
+    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
+	listfile=$(ls file_def*lmdz.xml)
+	echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
+	for file in ${listfile}
+	do
+	    cp ${file} ${file}.tmp
+	    sed -e "/<file id/r add.tmp" \
+		${file}.tmp > ${file}
+	    rm ${file}.tmp 
+	done
+	rm add.tmp
+    fi
+            
     IGCM_debug_PopStack "ATM_Update"
 }
@@ -646,17 +499,4 @@
 {
     IGCM_debug_PushStack "ATM_Finalize"
-
-    # If the file exist, copy Bands_ file to PARAM/ in submit directory. This file will be used for the simulation.
-    # Copy also the same file into ATM/Restart at ARCHIVE directory for backup.
-    if [ -f Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ] ; then 
-      if [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] ; then
-        IGCM_sys_Cp Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${SUBMIT_DIR}/PARAM/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${CumulPeriod}
-        IGCM_sys_Put_Out Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_R}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${CumulPeriod}
-      elif [ ${CumulPeriod} -eq 1 ] && [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
-        # Special case : first period and no adjust => Save bands file with suffix _0
-        IGCM_sys_Cp Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${SUBMIT_DIR}/PARAM/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_0
-        IGCM_sys_Put_Out Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_R}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_0
-      fi
-    fi
 
     # Add special treatement for CARBON CYCLE
Index: CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/oasis.driver
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/oasis.driver	(revision 2841)
+++ CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/oasis.driver	(revision 3688)
@@ -51,4 +51,5 @@
 
     FreqCoupling=${oasis_UserChoices_FreqCoupling:-86400}
+    FreqCouplingRoffCalv=${oasis_UserChoices_FreqCouplingRoffCalv:-86400}
 
     ## Calculate lag for transfer of fields from atmosphere -> ocean.
@@ -65,7 +66,12 @@
     IGCM_debug_Print 3 "Parametre de calcul Lag LMDZ mis a jour " ${day_step} ${iphysiq} ${nsplit_phys}
                                                               
-    (( LagAtm = 86400 / day_step * iphysiq / nsplit_phys ))
+    (( LagAtm = 86400 * iphysiq / day_step / nsplit_phys ))
+    (( LagAtmRoffCalv = $FreqCoupling + $LagAtm ))
+    (( LagOce = 86400 / OPA_NPDT_DAY ))
 
-    (( LagOce = 86400 / ORCA_NPDT_JOUR ))
+    IGCM_debug_Print 1 "OPA_NPDT_DAY : ${OPA_NPDT_DAY}"
+    IGCM_debug_Print 1 "LagAtm        : ${LagAtm}"
+    IGCM_debug_Print 1 "LagAtmRoffCalv : ${LagAtmRoffCalv}"
+    IGCM_debug_Print 1 "LagOce        : ${LagOce}"
 
     ## Use of Lucia ##
@@ -80,5 +86,7 @@
 	-e "s/<output_mode>/${CPL_OutputVar}/g" \
 	-e "s/<freq_coupling>/${FreqCoupling}/g" \
+	-e "s/<freq_coupling_roff_calv>/${FreqCouplingRoffCalv}/g" \
 	-e "s/<lag_atm>/${LagAtm}/g" \
+	-e "s/<lag_atm_roff_calv>/${LagAtmRoffCalv}/g" \
 	-e "s/<lag_oce>/${LagOce}/g" \
 	namcouple > namcouple.tmp
Index: CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/opa9.driver
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/opa9.driver	(revision 2841)
+++ CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/opa9.driver	(revision 3688)
@@ -9,15 +9,8 @@
     RESOL_OCE_ICE=$( echo ${RESOL} | awk "-Fx" '{print $1}' )
     case ${RESOL_OCE_ICE} in
-	( *LIM2* )
-	SEAICE_MODEL=LIM2 
-	LIM_VERSION=2
-	;;
-
-	( *LIM3* )
-	SEAICE_MODEL=LIM3
-	LIM_VERSION=3
-	;;
-	( *CICE*) SEAICE_MODEL=CICE ;;
-	( *     ) SEAICE_MODEL=UNKNOWN ;;
+	( *LIM2* ) SEAICE_MODEL=LIM2 ; 	LIM_VERSION=2 ;;
+	( *LIM3* ) SEAICE_MODEL=LIM3 ; 	LIM_VERSION=3 ;;
+	( *CICE* ) SEAICE_MODEL=CICE                  ;;
+	( *      ) SEAICE_MODEL=UNKNOWN               ;;
     esac
     RESOL_OCE=$( echo ${RESOL_OCE_ICE} | sed "s/${SEAICE_MODEL}//" )
@@ -30,91 +23,49 @@
 
     # Local function to find namelists parameters
-    supergrep () {
- 	grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
-    }
-
+    #supergrep () { grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%" ; }
+    supergrep () { grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%" -e "s%^ *$1 *=%%" ; }
     ##--Variables used by OPA --
-
-    # cn_exp    experience name
-    # nn_it000  number of the first time step
-    # nn_itend  number of the last time step
-    # nn_date0  initial calendar date yymmdd (used if  nn_rstctl=1)
-    # nn_leapy  Leap year calendar (1) or not (0), or 360 days calendar (30)
-    # nn_stock  frequency of creation of a restart file (modulo referenced to 1)
-    # nn_write  frequency of write in the output file   (modulo referenced to nn_it000)
-    # ln_rstart start from rest (F) or from a restart file (T)
-    # nn_rstctl restart control = 0 nn_it000 is not compared to the restart file value
-    #                           = 1 use nn_date0 in namelist_cfg (not the value in the restart file)
-    #                           = 2 calendar parameters read in the restart file
-    # nn_msh    =1 create a mesh file (coordinates, scale factors, masks)
-    # rn_rdt    time step in seconds for the dynamics (and tracer if nacc=0)   ==> 5760 (coming from namelist)
-    # nn_prg    time-step frequency of gap print in model output
-    # nn_fwri   frequency of zonal means and transport output
-
     NAMELIST_OPA_CFG=${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE}_cfg
-    NAMELIST_OPA_REF=${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE}_ref
-    IGCM_debug_Print 1 "namelist_ref : ${NAMELIST_OPA_REF}"
-    if [ ! -r ${NAMELIST_OPA_REF} ] ; then
-	echo "${NAMELIST_OPA_REF} non trouve"
-    fi
     IGCM_debug_Print 1 "namelist_cfg : ${NAMELIST_OPA_CFG}"
     if [ ! -r ${NAMELIST_OPA_CFG} ] ; then
-	echo "${NAMELIST_OPA_CFG} non trouve"
-    fi
-
-    PAT_CEXPER=$(   supergrep cn_exp      ${NAMELIST_OPA_CFG} )
-    PAT_NIT000=$(   supergrep nn_it000    ${NAMELIST_OPA_CFG} )
-    PAT_NITEND=$(   supergrep nn_itend    ${NAMELIST_OPA_CFG} )
-    PAT_NDATE0=$(   supergrep nn_date0    ${NAMELIST_OPA_CFG} )
-    PAT_NLEAPY=$(   supergrep nn_leapy    ${NAMELIST_OPA_CFG} )
-    PAT_NSTOCK=$(   supergrep nn_stock    ${NAMELIST_OPA_CFG} )
-    PAT_NWRITE=$(   supergrep nn_write    ${NAMELIST_OPA_CFG} )
-    PAT_RESTAR=$(   supergrep ln_rstart   ${NAMELIST_OPA_CFG} )
-    PAT_NRSTAR=$(   supergrep nn_rstctl   ${NAMELIST_OPA_CFG} )
-    PAT_NMSH=$(     supergrep nn_msh      ${NAMELIST_OPA_CFG} )
-    PAT_NN_WRITE=$( supergrep nn_write    ${NAMELIST_OPA_CFG} )
-    PAT_NN_FWRI=$(  supergrep nn_fwri     ${NAMELIST_OPA_CFG} )
-    PAT_ICE_EMBD=$( supergrep nn_ice_embd ${NAMELIST_OPA_CFG} )
-    PAT_ICEFLX=$(   supergrep cn_iceflx   ${NAMELIST_OPA_CFG} )
-    PAT_JPNI=$(     supergrep jpni        ${NAMELIST_OPA_CFG} )
-    PAT_JPNJ=$(     supergrep jpnj        ${NAMELIST_OPA_CFG} )
-    PAT_JPNIJ=$(    supergrep jpnij       ${NAMELIST_OPA_CFG} )
-    PAT_NN_FSBC=$(  supergrep nn_fsbc     ${NAMELIST_OPA_CFG} ) 
-
-    ORCA_RDT=$(       supergrep rn_rdt        ${NAMELIST_OPA_CFG} | sed 's/ *rn_rdt *=//'  | sed 's/\. *//' )
-    ORCA_NN_FSBC=$(   supergrep nn_fsbc       ${NAMELIST_OPA_CFG} | sed 's/ *nn_fsbc *=//' | sed 's/\. *//' )
-    (( ORCA_NPDT_JOUR  = 86400 / ORCA_RDT     ))
-    #(( ORCA_NPDT_SBC   = ORCA_NPDT_JOUR / ORCA_NN_FSBC ))
-    (( ORCA_RDT_SBC =  ORCA_RDT * ORCA_NN_FSBC ))
+        IGCM_debug_Exit "${NAMELIST_OPA_CFG} not found"
+	IGCM_debug_Verif_Exit
+    fi
+    OPA_RDT=$(       supergrep rn_rdt        ${NAMELIST_OPA_CFG} )
+    OPA_NN_FSBC=$(   supergrep nn_fsbc       ${NAMELIST_OPA_CFG} )
+    #
+    # OPA_RDT=$(       supergrep rn_rdt        namelist_cfg )
+    # OPA_NN_FSBC=$(   supergrep nn_fsbc       namelist_cfg )
+    (( OPA_NPDT_DAY   =  86400 / OPA_RDT        ))
+    (( OPA_NPDT_YEAR  =  OPA_NPDT_DAY * 365     ))
+    (( OPA_RDT_SBC    =  OPA_RDT * OPA_NN_FSBC ))
  
-
     # Period Length In Days between DateBegin and first day of calendar 0001 01 01
     # /!\ Needed by OPA namelist to compute file names /!\
     (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 ))
 
-    IGCM_debug_Print 1 "PAT_CEXPER   $PAT_CEXPER "
-    IGCM_debug_Print 1 "PAT_NIT000   $PAT_NIT000"
-    IGCM_debug_Print 1 "PAT_NITEND   $PAT_NITEND"
-    IGCM_debug_Print 1 "PAT_NDATE0   $PAT_NDATE0"
-    IGCM_debug_Print 1 "PAT_NLEAPY   $PAT_NLEAPY"
-    IGCM_debug_Print 1 "PAT_NSTOCK   $PAT_NSTOCK"
-    IGCM_debug_Print 1 "PAT_NWRITE   $PAT_NWRITE"
-    IGCM_debug_Print 1 "PAT_RESTAR   $PAT_RESTAR"
-    IGCM_debug_Print 1 "PAT_NRSTAR   $PAT_NRSTAR"
-    IGCM_debug_Print 1 "PAT_NMSH     $PAT_NMSH"
-    IGCM_debug_Print 1 "PAT_NN_WRITE $PAT_NN_WRITE"
-    IGCM_debug_Print 1 "PAT_NN_FWRI  $PAT_NN_FWRI"
-    IGCM_debug_Print 1 "PAT_ICE_EMBD $PAT_ICE_EMBD"
-    IGCM_debug_Print 1 "PAT_ICEFLX   $PAT_ICEFLX"
-    IGCM_debug_Print 1 "PAT_JPNI     $PAT_JPNI"
-    IGCM_debug_Print 1 "PAT_JPNJ     $PAT_JPNJ"
-    IGCM_debug_Print 1 "PAT_JPNIJ    $PAT_JPNIJ"
-    IGCM_debug_Print 1 "PAT_NN_FSBC  $PAT_NN_FSBC"
     IGCM_debug_Print 1 " "
-    IGCM_debug_Print 1 "ORCA_RDT        $ORCA_RDT"
-    IGCM_debug_Print 1 "ORCA_NN_FSBC    $ORCA_NN_FSBC"
-    IGCM_debug_Print 1 "ORCA_RDT_SBC    $ORCA_RDT_SBC"
-    IGCM_debug_Print 1 "ORCA_NPDT_JOUR  $ORCA_NPDT_JOUR"
-    IGCM_debug_Print 1 "DaysSinceJC     $DaysSinceJC"
+    IGCM_debug_Print 1 "OPA_RDT        ${OPA_RDT}"
+    IGCM_debug_Print 1 "OPA_NN_FSBC    ${OPA_NN_FSBC}"
+    IGCM_debug_Print 1 "OPA_RDT_SBC    ${OPA_RDT_SBC}"
+    IGCM_debug_Print 1 "OPA_NPDT_DAY   ${OPA_NPDT_DAY}"
+    IGCM_debug_Print 1 "OPA_NPDT_YEAR  ${OPA_NPDT_YEAR}"
+    IGCM_debug_Print 1 "DaysSinceJC    ${DaysSinceJC}"
+
+    ## Check that nn_fsbc is correct compare to coupling frequency
+    FreqCoupling=${oasis_UserChoices_FreqCoupling:-86400}
+    
+    ## This informations are used for diaptr, trends and diagap files
+    ## only the first frequency is used for this files
+    
+    IGCM_debug_Print 1 "FreqCoupling    ${FreqCoupling}"
+    IGCM_debug_Print 1 "OPA_NN_FSBC    ${OPA_NN_FSBC}"
+    IGCM_debug_Print 1 "OPA_RDT        ${OPA_RDT}"
+    IGCM_debug_Print 1 "OPA_RDT_SBC    ${OPA_RDT_SBC}"
+    
+    if [[ ${OPA_RDT_SBC} -gt ${FreqCoupling} ]] ; then
+	IGCM_debug_Exit "OPA_RDT_SBC=${OPA_RDT_SBC} is greater than FreqCoupling=${FreqCoupling}"
+     	IGCM_debug_Verif_Exit
+    fi
     
     IGCM_debug_PopStack "OCE_Initialize"
@@ -126,49 +77,10 @@
 {
     IGCM_debug_PushStack "OCE_Update"
-
-    ## Check that nn_fsbc is correct compare to coupling frequency
-
-    FreqCoupling=${oasis_UserChoices_FreqCoupling:-86400}
-
-    ## This informations are used for diaptr, trends and diagap files
-    ## only the first frequency is used for this files
-   
-    IGCM_debug_Print 1 "FreqCoupling    $FreqCoupling"
-    IGCM_debug_Print 1 "ORCA_NN_FSBC    $ORCA_NN_FSBC"
-    IGCM_debug_Print 1 "ORCA_RDT        $ORCA_RDT"
-    IGCM_debug_Print 1 "ORCA_RDT_SBC    $ORCA_RDT_SBC"
-
-    if [[ ${ORCA_RDT_SBC} -gt ${FreqCoupling} ]] ; then
-	IGCM_debug_Exit "ORCA_RDT_SBC=${ORCA_RDT_SBC} is greater than FreqCoupling=${FreqCoupling}"
-     	IGCM_debug_Verif_Exit
-    fi
-    
-    ##--Write Frequency Purpose ....
-    frequency=$( echo ${config_OCE_WriteFrequency} | awk "-F " '{print $1}' )
-    factor=$( echo ${frequency} | sed -e "s/[yYmMdD]//" )
-    case ${frequency} in
-	1Y|1y)
-	    (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInYear  ${year} ) ))          ;
-	    PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}y ;
-	    R_OUT_OCE_NWRITE=${R_OUT_OCE_O_Y} ;
-	    WF1=${factor}Y ;;
-	1M|1m)
-	    (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInMonth ${year} ${month} ) )) ;
-	    PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}m ;
-	    R_OUT_OCE_NWRITE=${R_OUT_OCE_O_M} ;
-	    WF1=${factor}M ;;
-	*D|*d)
-	    (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor  ))  ;
-	    PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}d ;
-	    R_OUT_OCE_NWRITE=${R_OUT_OCE_O_D} ;
-	    WF1=${factor}D ;;
-	*)
-	    (( ORCA_NWRITE = 0 ))                                                            ;;
-    esac
-
+  
     ##--Write Frequency for iomput
-    ## Differents frequencies are allowed for grid_[TUVW] and icemod files
+    ## Differents frequencies are allowed for OCE files
 
     V1D_ENABLE=".FALSE."
+    V5D_ENABLE=".FALSE."
     V1M_ENABLE=".FALSE."
     V1Y_ENABLE=".FALSE."
@@ -176,19 +88,10 @@
     for frequency in ${config_OCE_WriteFrequency} ; do
         case ${frequency} in
-            1D|1d) V1D_ENABLE=".TRUE." ;;
-        esac
-        case ${frequency} in
-            1M|1m) V1M_ENABLE=".TRUE." ;;
-        esac
-        case ${frequency} in
-            *[yY]) V1Y_ENABLE=".TRUE." ;;
+            ( 1D|1d ) V1D_ENABLE=".TRUE." ;;
+            ( 5D|5d ) V5D_ENABLE=".TRUE." ;;
+            ( 1M|1m ) V1M_ENABLE=".TRUE." ;;
+            ( *[yY] ) V1Y_ENABLE=".TRUE." ;;
         esac
     done
-
-
-    ##-- Output level : 3 for more 1D variables
-    eval opa9_OUTPUT_LEVEL=\${opa9_UserChoices_OUTPUT_LEVEL} > /dev/null 2>&1
-    OUTPUT_LEVEL=${opa9_OUTPUT_LEVEL}
-
 
     # Period Length In Days between DateBegin and first day of calendar 0001 01 01
@@ -197,35 +100,50 @@
 
     ##-- Number of time steps updated : the first, the last and the number of time steps
-    (( ORCA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * ORCA_NPDT_JOUR + 1 ))
-    (( ORCA_NPDT   = PeriodLengthInDays * ORCA_NPDT_JOUR ))
-    (( ORCA_NITEND = ORCA_NIT000 + ORCA_NPDT - 1))
+    (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NPDT_DAY + 1 ))
+    (( OPA_NPDT   = PeriodLengthInDays * OPA_NPDT_DAY ))
+    (( OPA_NITEND = OPA_NIT000 + OPA_NPDT - 1))
 
     ##-- We force one restart file at the end of the trunk
-    ORCA_NSTOCK="${ORCA_NITEND}"
-
-    ##-- Restart configuration
-    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then
-	ORCA_LRSTAR=.FALSE.
-	ORCA_NRSTDT=0
-        # Put ORCA_NMSH=0 when OPA running in parallel mode
-	ORCA_NMSH=1
-	#echo "NO OPA RESTART"
+    OPA_NSTOCK="${OPA_NITEND}"
+
+
+    ##-- Additionnal Restart Option to force reproducibility ; force kt to kt red in restart file
+    ## ${opa9_UserChoices_Reproducibility_after_restart}
+
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/opa9.card UserChoices Reproducibility_after_restart
+
+   ##-- Restart configuration
+    if ( [ "${opa9_UserChoices_Reproducibility_after_restart}" = "y" ] ) ; then
+      OPA_LRSTAR=.TRUE.
+      OPA_NRSTDT=2
+      #echo "OPA RESTART"
+      IGCM_debug_Print 1 'WARNING : dangerous option'
+      IGCM_debug_Print 1 'Reproducibility_after_Restart forced ie kt forced to kt red in restart file : ' ${opa9_UserChoices_Reproducibility_after_restart}
+    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then
+      OPA_LRSTAR=.FALSE.
+      OPA_NRSTDT=0
+      #echo "NO OPA RESTART"
     elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then
-	ORCA_LRSTAR=.TRUE.
-	ORCA_NRSTDT=0
-	ORCA_NMSH=1
-	#echo "OPA RESTART"
+      OPA_LRSTAR=.TRUE.
+      OPA_NRSTDT=0
+      #echo "OPA RESTART"
     else
-	ORCA_LRSTAR=.TRUE.
-	ORCA_NRSTDT=2
-	ORCA_NMSH=0
-	#echo "OPA RESTART"
-    fi
-
-    ##-- Meshmask option
+      OPA_LRSTAR=.TRUE.
+      OPA_NRSTDT=2
+      #echo "OPA RESTART"
+    fi
+
+    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${opa9_UserChoices_Restart_TS_only}" = "y" ] ) ; then
+      OPA_LRSTAR_TS=.TRUE.
+    else
+      OPA_LRSTAR_TS=.FALSE.
+    fi
+
+    ##-- Meshmask option. Forced only once.
     IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/opa9.card UserChoices mesh_mask
 
+    OPA_NMSH=0
     if [ "${opa9_UserChoices_mesh_mask}" = "y" ]; then
-        ORCA_NMSH=1
+        OPA_NMSH=1
         IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/opa9.card UserChoices mesh_mask "n"
     fi
@@ -233,69 +151,57 @@
     # nleapy configuration
     case ${config_UserChoices_CalendarType} in
-        leap|gregorian)
-            ORCA_NLEAPY=1;;
-        noleap)
-            ORCA_NLEAPY=0;;
-        360d)
-            ORCA_NLEAPY=30;;
-        *)
-            ORCA_NLEAPY=30
+        ( leap|gregorian) OPA_NLEAPY=1  ;;
+        ( noleap        ) OPA_NLEAPY=0  ;;
+        ( 360d          ) OPA_NLEAPY=30 ;;
+        ( *             ) OPA_NLEAPY=30 ;;
     esac
 
+    if ( [ "${opa9_UserChoices_Reproducibility_after_restart}" = "y" ] ) ; then
+      NEMO_KT_FROM_RESTART=$(ncdump -v kt restartopa_0000.nc|grep 'kt ='|awk '{print $3}' )
+      (( NEMO_NIT000 = NEMO_KT_FROM_RESTART + 1 ))
+      (( NEMO_NITEND = NEMO_KT_FROM_RESTART + OPA_NITEND - OPA_NIT000 + 1 ))
+      IGCM_debug_Print 1 "NEMO_NIT000 (from Restart)        : ${NEMO_NIT000}"
+      IGCM_debug_Print 1 "NEMO_NITEND (from Restart + ... ) : ${NEMO_NITEND}"
+      ##-- We force one restart file at the end of the trunk
+      OPA_NSTOCK="${NEMO_NITEND}"
+      OPA_NIT000="${NEMO_NIT000}"
+      OPA_NITEND="${NEMO_NITEND}"
+    fi
+
     typeset -r PRECIS=8
-    NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${ORCA_NITEND} }" ) ) 
-
-
-    case ${SEAICE_MODEL} in
-	( LIM2 ) 
-	NN_ICE_EMBD=0
-	ICEFLX=none
-	;;
-	( LIM3 ) 
-	NN_ICE_EMBD=2
-	ICEFLX=${opa9_UserChoices_iceflx:-linear}
-	;;
-    esac
-
-    IGCM_debug_Print 1 "NUM_PROC_OCE : " ${NUM_PROC_OCE}
-
-    sed -e "s/${PAT_CEXPER}/       cn_exp=\"${config_UserChoices_JobName}\"/"   \
-	-e "s/${PAT_NIT000}/       nn_it000=${ORCA_NIT000}/"                    \
-	-e "s/${PAT_NITEND}/       nn_itend=${ORCA_NITEND}/"                    \
-	-e "s/${PAT_NDATE0}/       nn_date0=${PeriodDateBegin}/"                \
-        -e "s%${PAT_NLEAPY}%       nn_leapy=${ORCA_NLEAPY}%"                    \
-	-e "s/${PAT_NSTOCK}/       nn_stock=${ORCA_NSTOCK}/"                    \
-	-e "s/${PAT_NWRITE}/       nn_write=${ORCA_NWRITE}/"                    \
-	-e "s/${PAT_RESTAR}/       ln_rstart=${ORCA_LRSTAR}/"                   \
-	-e "s/${PAT_NRSTAR}/       nn_rstctl=${ORCA_NRSTDT}/"                   \
-	-e "s/${PAT_NMSH}/         nn_msh=${ORCA_NMSH}/"                        \
-	-e "s/${PAT_NN_WRITE}/     nn_prg=${ORCA_NWRITE}/"                      \
-	-e "s/${PAT_NN_FWRI}/      nn_fwri=${ORCA_NWRITE}/"                     \
-	-e "s/${PAT_NN_FSBC}/      nn_fsbc=${ORCA_NN_FSBC}/"                    \
-	-e "s/${PAT_ICE_EMBD}/     nn_ice_embd=${NN_ICE_EMBD}/"                 \
-	-e "s/${PAT_ICEFLX}/       cn_iceflx=\'${ICEFLX}'/"                     \
-	-e "s/${PAT_JPNI}/         jpni=1/"                                     \
-	-e "s/${PAT_JPNJ}/         jpnj=${NUM_PROC_OCE}/"                       \
-	-e "s/${PAT_JPNIJ}/        jpnij=${NUM_PROC_OCE}/"                      \
-	namelist_cfg > namelist_cfg.tmp
-
-    IGCM_sys_Mv namelist_cfg.tmp namelist_cfg
-
-    IGCM_debug_Print 1 'Variables automatically updated in ORCA namelist_cfg'
-    grep AUTO namelist_cfg
-
-    # update iodef.xml
-
-    IGCM_debug_Print 1 'Informations into iodef.xml : V1D_ENABLE V1M_ENABLE V1Y_ENABLE OUTPUT_LEVEL'
-    IGCM_debug_Print 1 ${V1D_ENABLE} ${V1M_ENABLE} ${V1Y_ENABLE} ${OUTPUT_LEVEL}
-
-    sed -e "s/_1D_ENABLE_/${V1D_ENABLE}/" \
-        -e "s/_1M_ENABLE_/${V1M_ENABLE}/" \
-        -e "s/_1Y_ENABLE_/${V1Y_ENABLE}/" \
-        -e "s/_OUTPUT_LEVEL_/${OUTPUT_LEVEL}/" \
-        context_nemo.xml > context_nemo.xml.tmp
-
-    IGCM_sys_Mv context_nemo.xml.tmp context_nemo.xml
-
+    NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) ) 
+
+    IGCM_comp_modifyNamelist blocker    namelist_cfg cn_exp       ${config_UserChoices_JobName}
+    IGCM_comp_modifyNamelist blocker    namelist_cfg nn_it000     ${OPA_NIT000}
+    IGCM_comp_modifyNamelist blocker    namelist_cfg nn_itend     ${OPA_NITEND}
+    IGCM_comp_modifyNamelist blocker    namelist_cfg ln_rstart    ${OPA_LRSTAR}
+    IGCM_comp_modifyNamelist blocker    namelist_cfg ln_rstart_ts ${OPA_LRSTAR_TS}
+    IGCM_comp_modifyNamelist blocker    namelist_cfg nn_stock     ${OPA_NSTOCK}
+    IGCM_comp_modifyNamelist blocker    namelist_cfg nn_rstctl    ${OPA_NRSTDT}
+    IGCM_comp_modifyNamelist blocker    namelist_cfg nn_date0     ${PeriodDateBegin}
+    IGCM_comp_modifyNamelist nonblocker namelist_cfg nn_msh       ${OPA_NMSH}
+    IGCM_comp_modifyNamelist nonblocker namelist_cfg nn_rnf_depth_file  ${OPA_NMSH}
+    IGCM_comp_modifyNamelist blocker    namelist_cfg nn_leapy     ${OPA_NLEAPY}
+    
+    # Update iodef.xml
+
+    if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then       
+	V1D_ENABLE=".FALSE."
+	V5D_ENABLE=".FALSE."
+	V1M_ENABLE=".FALSE."
+	V1Y_ENABLE=".FALSE."
+    fi
+
+    IGCM_debug_Print 1 'Informations into iodef.xml : V1D_ENABLE V5D_ENABLE V1M_ENABLE V1Y_ENABLE '
+    IGCM_debug_Print 1 ${V1D_ENABLE}  ${V5D_ENABLE} ${V1M_ENABLE} ${V1Y_ENABLE}
+
+    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 1d_opa enabled ${V1D_ENABLE}
+    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 5d_opa enabled ${V5D_ENABLE}
+    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 1m_opa enabled ${V1M_ENABLE}
+    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 1y_opa enabled ${V1Y_ENABLE}
+
+    IGCM_comp_modifyXmlFile force context_nemo.xml ref_year NONE ${opa9_UserChoices_TimeOrigin}
+	
+ 
     # vargas/titane/MPP and switch from 1 proc to 5 procs. We need to suppres restartopa the second month, if restartopa_0000 exist
     # same thing for restart_trc and restart_ice_in
@@ -309,4 +215,8 @@
     #  <context id="nemo" src="./context_nemo.xml"/>
     echo '<context id="nemo" src="./context_nemo.xml"/>' > add.tmp
+    if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then
+	echo '<context id="nemo" src="./ping_nemo.xml"/>' >> add.tmp
+	echo '<context id="nemo" src="./dr2xml_opa9.xml"/>' >> add.tmp
+    fi
     cp iodef.xml iodef.xml.tmp
     sed -e "/COMPONENT CONTEXT/r add.tmp" \
@@ -314,4 +224,17 @@
     rm iodef.xml.tmp add.tmp
 
+    #Long Name as global attribute (if LongName is not empty)
+    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
+	listfile=$(ls file_def_nemo*.xml)
+	echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
+	for file in ${listfile}
+	do
+	    cp ${file} ${file}.tmp
+	    sed -e "/<file id/r add.tmp" \
+		${file}.tmp > ${file}
+	    rm ${file}.tmp 
+	done 
+	rm add.tmp
+    fi
 
     IGCM_debug_PopStack "OCE_Update"
@@ -323,12 +246,4 @@
     IGCM_debug_PushStack "OCE_Finalize"
 
-    if [ -f date.file ] ; then
-        # Prefix use in opa9.card AND in lim2.card :
-	DATE_OPA=$( cat date.file | \
-	    sed "s/\ ${config_UserChoices_JobName}_[0-9]*[a-z]_\([0-9]*_[0-9]*\)_\ */\1/g" )
-	MainPrefix=${config_UserChoices_JobName}_1d_${DATE_OPA}
-	SecondPrefix=${config_UserChoices_JobName}_1m_${DATE_OPA}
-    fi
-
     IGCM_debug_Print 1 FINALIZE OCE !!!
 
Index: CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/orchidee.driver
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/orchidee.driver	(revision 2841)
+++ CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/orchidee.driver	(revision 3688)
@@ -1,4 +1,4 @@
 #!/bin/ksh
-#D- Driver du script pour ORCHIDEE
+## Driver for the component SRF corresponding to the sechiba part of ORCHIDEE
 #-----------------------------------------------------------------
 function SRF_Initialize
@@ -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,120 @@
     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 stomate1 output_level 0
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq 1mo
+        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE.
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_level 0
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq 1mo
     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
-    if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then
-	IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE   ${orchidee_UserChoices_VEGET_UPDATE}
-    else
-	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}
-    else
-	IGCM_comp_modifyDefFile nonblocker orchidee.def LAND_COVER_CHANGE n
+    # Set VEGET_UPDATE=1Y in orchidee.def if VEGET_UPDATE_at_start=y in orchidee.card and if it is the first cumul periond (start of new simulation)
+    if [ X${orchidee_UserChoices_VEGET_UPDATE_at_start} = Xy ] && [ ${CumulPeriod} -eq 1 ] ; then
+        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE   1Y
     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
+    # Modify in orchidee.def VEGET_UPDATE if it is set in orchidee.card section UserChoices
+    # Note: if the variable has been set by VEGET_UPDATE_at_start, this section will not overwrite it.
+    if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then
+        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE   ${orchidee_UserChoices_VEGET_UPDATE}
+    else
+        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 0Y
+    fi
 
-#Temporary way to fix bug on cimean variable
-    IGCM_comp_modifyXmlFile force field_def_orchidee.xml cimean enabled .FALSE. 
+    # 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
 
-    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
+
+    ## 2. Mangement of output and modifications of related xml files
+    # Modify file_def_orchidee.xml file using settings from orchidee.card
+    # We here suppose that for each file, in orchidee.card UserChoices section, if the parameter 
+    # output_level_filename is set, then also output_freq_filename must be set. The existance of output_freq_filename will not be checked. 
+    # If output_level_filename=NONE or if it is not set, the corresponding file will be deactivated.
+    # Settings in config.card WriteFrequency are not used any more.
+    
+    if [ X${orchidee_UserChoices_output_level_sechiba_history} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history} = XNONE ] ; then
+	# output_level_sechiba_history is not set in orchidee.card or it is set to NONE.
+	# Deactivate the file.
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled .FALSE.
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level 0
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq 1mo
+    else
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled      .TRUE.
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level ${orchidee_UserChoices_output_level_sechiba_history}
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq  ${orchidee_UserChoices_output_freq_sechiba_history}
+    fi
+    
+    if [ X${orchidee_UserChoices_output_level_sechiba_out_2} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_out_2} = XNONE ] ; then
+	# output_level_sechiba_out_2 is not set in orchidee.card or it is set to NONE.
+	# Deactivate the file.
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled .FALSE.
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level 0
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq 1mo
+    else
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled      .TRUE.
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level ${orchidee_UserChoices_output_level_sechiba_out_2}
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq  ${orchidee_UserChoices_output_freq_sechiba_out_2}
+    fi
+    
+    if [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = XNONE ] ; then
+	# output_level_sechiba_history_4dim is not set in orchidee.card or it is set to NONE.
+	# Deactivate the file.
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled .FALSE.
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level 0
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq 1mo
+    else
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled      .TRUE.
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level ${orchidee_UserChoices_output_level_sechiba_history_4dim}
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq  ${orchidee_UserChoices_output_freq_sechiba_history_4dim}
+    fi
+        
+
     # 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
+    echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
+    if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then
+	echo '<context id="orchidee" src="./ping_orchidee.xml"/>' >> add.tmp
+	echo '<context id="orchidee" src="./dr2xml_orchidee.xml"/>' >> add.tmp
     fi
+    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 LongName as global attribute in XIOS output files (if LongName is not empty)
+    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
+	listfile=$(ls file_def*orchidee.xml)
+	echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
+	for file in ${listfile}
+	do
+	    cp ${file} ${file}.tmp
+	    sed -e "/<file id/r add.tmp" \
+		${file}.tmp > ${file}
+	    rm ${file}.tmp 
+	done 
+	rm add.tmp
+    fi
+
 
     IGCM_debug_PopStack "SRF_Update"
@@ -198,8 +148,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/IPSLCM6CHT/GENERAL/DRIVER/pisces.driver
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/pisces.driver	(revision 2841)
+++ CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/pisces.driver	(revision 3688)
@@ -6,13 +6,8 @@
     IGCM_debug_PushStack "MBG_Initialize"
 
-# Local function to find namelists parameters
-supergrep () {
-    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
-}
+    # Local function to find parameters in LMDZ .def files
 
-# Local function to find parameters in LMDZ .def files
-
-lmdzgrep () {
-    grep $1 $2 |grep -v "#" | awk "-F=" '{print $2}'
+lmdzgrep2 () {
+     grep -w ${1} ${2} | grep -v "#"  | sed -e 's/=//g' -e 's/://g' -e 's/_AUTO_//' -e 's/DEFAULT//' | sed -e "s/${1}//" 
 }
 
@@ -22,14 +17,4 @@
     # nrsttr    control of the time step (0, 1 or 2)
     
-    ##--Variables used by PISCES --
- 
-    NAMELIST_TOP_CFG=${SUBMIT_DIR}/PARAM/namelist_top_${RESOL_OCE}_cfg
-    NAMELIST_PISCES_CFG=${SUBMIT_DIR}/PARAM/namelist_pisces_${RESOL_OCE}_cfg
-
-    PAT_TOP_LRSTTR=$( supergrep ln_rsttr          ${NAMELIST_TOP_CFG} )
-    PAT_TOP_NRSTTR=$( supergrep nn_rsttr          ${NAMELIST_TOP_CFG} )
-    PAT_PIS_ATCCO2=$( supergrep atcco2            ${NAMELIST_PISCES_CFG} )
-    PAT_PIS_LRIVER=$( supergrep ln_river          ${NAMELIST_PISCES_CFG} )
-
     IGCM_debug_PopStack "MBG_Initialize"
 }
@@ -40,20 +25,33 @@
     IGCM_debug_PushStack "MBG_Update"
 
+    ##--Write Frequency for iomput
+    ## Differents frequencies are allowed for MBG files
+
+    VT1D_ENABLE=".FALSE."
+    VT5D_ENABLE=".FALSE."
+    VT1M_ENABLE=".FALSE."
+    VT1Y_ENABLE=".FALSE."
+
+    for frequency in ${config_MBG_WriteFrequency} ; do
+        case ${frequency} in
+            ( 1D|1d ) VT1D_ENABLE=".TRUE." ;;
+            ( 5D|5d ) VT5D_ENABLE=".TRUE." ;;
+            ( 1M|1m ) VT1M_ENABLE=".TRUE." ;;
+            ( *[yY] ) VT1Y_ENABLE=".TRUE." ;;
+        esac
+    done
+
     ##-- Restart configuration
     if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "n" ] ) ; then
 
         #echo "NO RESTART FOR TOP"
-        TOP_LRSTTR=.FALSE.
-        TOP_NRSTTR=0
-
-        PISCES_LRIVER=.FALSE.
+        TOP_LN_RSTR=.FALSE.
+        TOP_NN_RSTR=0
 
     elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "y" ] ) ; then
 
         #echo "RESTART TOP"
-        TOP_LRSTTR=.TRUE.
-        TOP_NRSTTR=0
-
-        PISCES_LRIVER=.TRUE.
+        TOP_LN_RSTR=.TRUE.
+        TOP_NN_RSTR=0
 
         # If we start from IPSLCM5* restart files.
@@ -65,8 +63,6 @@
 
         #echo "RESTART TOP"
-        TOP_LRSTTR=.TRUE.
-        TOP_NRSTTR=2
-
-        PISCES_LRIVER=.FALSE.
+        TOP_LN_RSTR=.TRUE.
+        TOP_NN_RSTR=2
 
     fi
@@ -81,6 +77,5 @@
     # update iodef.xml
 
-    echo 'Informations into iodef.xml : DBIO_ENABLE'
-    echo ${DBIO_ENABLE}
+    IGCM_debug_Print 1 " 'Informations into iodef.xml : DBIO_ENABLE : ${DBIO_ENABLE}"
 
     sed -e "s/<DBIO_ENABLE>/${DBIO_ENABLE}/" \
@@ -91,37 +86,43 @@
     ##-- CO2 forcing : update atcco2 value in namelist_pisces_cfg
     if [ "${pisces_UserChoices_CARBON_CYCLE}" = "y" ]; then
-       	# Special case for carbon cycle
+       	IGCM_debug_Print 1 "Special case for carbon cycle"
 	# Activate this case by putting CARBON_CYCLE=y in pisces.card section UserChoices
-	echo 'Update atcco2 in namelist_pisces_cfg with value from file co2.log'
+	IGCM_debug_Print 1  'Update atcco2 in namelist_pisces_cfg with value from file co2.log'
 	PathCO2log=${SUBMIT_DIR}
 	PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log )
 	IPCC_PIS_CO2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' )
-	sed -e "s%${PAT_PIS_ATCCO2}%          atcco2=${IPCC_PIS_CO2}%"             \
-	    namelist_pisces_cfg > namelist_pisces_cfg.tmp
-	IGCM_sys_Mv namelist_pisces_cfg.tmp namelist_pisces_cfg
+	IGCM_debug_Print 1 "IPCC_PIS_CO2 : ${IPCC_PIS_CO2} "
+	IGCM_comp_modifyNamelist force  namelist_pisces_cfg atcco2 ${IPCC_PIS_CO2}
     else
-	# Take same CO2 as for LMDZ, in parameter file config.def.
-	# ATM_Update is done before MBG_Update and therefor config.def file contains the correct value for CO2.
-	echo 'Update atcco2 in namelist_pisces_cfg with same value as for LMDZ'
-	LMDZ_CO2=$( lmdzgrep co2_ppm config.def )
-	sed -e "s%${PAT_PIS_ATCCO2}%          atcco2=${LMDZ_CO2}%"             \
-	    namelist_pisces_cfg > namelist_pisces_cfg.tmp
-	IGCM_sys_Mv namelist_pisces_cfg.tmp namelist_pisces_cfg
+	IGCM_debug_Print 1 "Take same CO2 as for LMDZ, in parameter file config.def."
+	# ATM_Update is done before MBG_Update and therefore config.def file contains the correct value for CO2.
+	IGCM_debug_Print 1 'Update atcco2 in namelist_pisces_cfg with same value as for LMDZ'
+	LMDZ_CO2=$( lmdzgrep2 co2_ppm config.def )
+	IGCM_debug_Print 1 "LMDZ_CO2 : ${LMDZ_CO2} "
+	IGCM_comp_modifyNamelist force  namelist_pisces_cfg atcco2 ${LMDZ_CO2}
     fi
 
     ##-- Update namelist_top_cfg and namelist_pisces_cfg
+    IGCM_comp_modifyNamelist blocker  namelist_top_cfg     ln_rsttr   ${TOP_LN_RSTR}
+    IGCM_comp_modifyNamelist blocker  namelist_top_cfg     nn_rsttr   ${TOP_NN_RSTR}
+    IGCM_comp_modifyNamelist blocker  namelist_pisces_cfg  nn_pisdmp  ${OPA_NPDT_YEAR}
+ 
+    # Update iodef.xml
 
-    sed -e "s%${PAT_TOP_LRSTTR}%          ln_rsttr=${TOP_LRSTTR}%"                   \
-        -e "s%${PAT_TOP_NRSTTR}%          nn_rsttr=${TOP_NRSTTR}%"                   \
-        namelist_top_cfg > namelist_top_cfg.tmp
+    if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then       
+	VT1D_ENABLE=".FALSE."
+	VT5D_ENABLE=".FALSE."
+	VT1M_ENABLE=".FALSE."
+	VT1Y_ENABLE=".FALSE."
+    fi
 
-    IGCM_sys_Mv namelist_top_cfg.tmp namelist_top_cfg
+    IGCM_debug_Print 1 'Informations into iodef.xml : VT1D_ENABLE VT5D_ENABLE VT1M_ENABLE VT1Y_ENABLE '
+    IGCM_debug_Print 1 ${VT1D_ENABLE}  ${VT5D_ENABLE} ${VT1M_ENABLE} ${VT1Y_ENABLE}
 
-    sed -e "s%${PAT_PIS_LRIVER}%          ln_river=${PISCES_LRIVER}%"                \
-        namelist_pisces_cfg > namelist_pisces_cfg.tmp
-
-    IGCM_sys_Mv namelist_pisces_cfg.tmp namelist_pisces_cfg
-
-
+    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1d_pis enabled ${VT1D_ENABLE}
+    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 5d_pis enabled ${VT5D_ENABLE}
+    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1m_pis enabled ${VT1M_ENABLE}
+    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1y_pis enabled ${VT1Y_ENABLE}
+   
     IGCM_debug_PopStack "MBG_Update"
 }
Index: CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/stomate.driver
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/stomate.driver	(revision 2841)
+++ CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/stomate.driver	(revision 3688)
@@ -1,5 +1,5 @@
 #!/bin/ksh
 
-#D- Driver du script pour ORCHIDEE
+#D- Driver for ORCHIDEE stomate component (SBG)
 
 #-----------------------------------------------------------------
@@ -8,6 +8,4 @@
     IGCM_debug_PushStack "SBG_Initialize"
 
-    RESOL_SBG=ALL
-    
     IGCM_debug_PopStack "SBG_Initialize"
 }
@@ -17,131 +15,43 @@
 {
     IGCM_debug_PushStack "SBG_Update"
-
-    typeset STOMATE_WRITE_STEP
-
-    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 
-
-	    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
-
-
-#Use of XIOS library only
-
-    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
-	(( STOMATE_WRITE_STEP = 0 ))
+    
+    # Output management
+    # Modify file_def_orchidee.xml file using settings from stomate.card
+    # We here suppose that for each file, in stomate.card UserChoices section, if the parameter 
+    # output_level_filename is set, then also output_freq_filename must be set. The existance of output_freq_filename will not be checked. 
+    # If output_level_filename=NONE or if it is not set, the corresponding file will be deactivated.
+    
+    if [ X${stomate_UserChoices_output_level_stomate_history} = X ] || [ X${stomate_UserChoices_output_level_stomate_history} = XNONE ] ; then
+	# output_level_stomate_history is not set in stomate.card or it is set to NONE.
+	# Deactivate the file.
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled .FALSE.
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_level 0
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq 1mo
+    else
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled      .TRUE.
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_level ${stomate_UserChoices_output_level_stomate_history}
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq  ${stomate_UserChoices_output_freq_stomate_history}
+    fi
+    
+    if [ X${stomate_UserChoices_output_level_stomate_ipcc_history} = X ] || [ X${stomate_UserChoices_output_level_stomate_ipcc_history} = XNONE ] ; then
+	# output_level_stomate_ipcc_history is not set in stomate.card or it is set to NONE.
+	# Deactivate the file.
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE.
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_level 0
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq 1mo
+    else
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled      .TRUE.
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_level ${stomate_UserChoices_output_level_stomate_ipcc_history}
+	IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq  ${stomate_UserChoices_output_freq_stomate_ipcc_history}
     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 +62,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/IPSLCM6CHT/GENERAL/DRIVER/xios.driver
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/xios.driver	(revision 2841)
+++ CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/xios.driver	(revision 3688)
@@ -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 
