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
