Index: CONFIG/IPSLCM/IPSLCM5A/Chistorical/COMP/lmdz.card
===================================================================
--- CONFIG/IPSLCM/IPSLCM5A/Chistorical/COMP/lmdz.card	(revision 1236)
+++ CONFIG/IPSLCM/IPSLCM5A/Chistorical/COMP/lmdz.card	(revision 1237)
@@ -27,4 +27,6 @@
 LMDZ_NMC_daily=y
 LMDZ_NMC_hf=y
+
+co2_init=284.725
 
 [InitialStateFiles]
Index: CONFIG/IPSLCM/IPSLCM5A/Chistorical/COMP/lmdz.driver
===================================================================
--- CONFIG/IPSLCM/IPSLCM5A/Chistorical/COMP/lmdz.driver	(revision 1236)
+++ CONFIG/IPSLCM/IPSLCM5A/Chistorical/COMP/lmdz.driver	(revision 1237)
@@ -91,4 +91,8 @@
 {
     IGCM_debug_PushStack "ATM_Update"
+
+    typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff
+    typeset PreviousLinelog LastPeriodDateBegin LastPeriodDateEnd LastDatesPeriod LastPREFIX
+    typeset PathCO2log Date_r OUT_OCE OUT_SRF
 
     case ${config_UserChoices_PeriodLength} in
@@ -151,9 +155,113 @@
     ##-- GHG forcing for the current year
     IPCC_SOLAR=`grep Annee_${year} SOLARANDVOLCANOES_1610_2008.txt | awk -F= '{print $2}'`
-    IPCC_CO2=`grep Annee_${year} CO2_1765_2005.txt | awk -F= '{print $2}'`
+#    IPCC_CO2=`grep Annee_${year} CO2_1765_2005.txt | awk -F= '{print $2}'`
     IPCC_CH4=`grep Annee_${year} CH4_1765_2005.txt | awk -F= '{print $2}'`
     IPCC_N2O=`grep Annee_${year} N2O_1765_2005.txt | awk -F= '{print $2}'`
     IPCC_CFC11=`grep Annee_${year} CFC11_1765_2005.txt | awk -F= '{print $2}'`
     IPCC_CFC12=`grep Annee_${year} CFC12_1765_2005.txt | awk -F= '{print $2}'`
+
+    if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"n" ]) ; then
+	
+	fCO2_ff=0
+	CO2SRF=0
+	CO2LU=0
+	CO2MBG=0
+	CO2_ppm=${lmdz_UserChoices_co2_init}
+	CO2_ppm_prec=${lmdz_UserChoices_co2_init}
+	
+	IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log
+	IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log
+
+	echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SRF} ${CO2LU}" |   \
+	     gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \
+                              $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log
+    else
+#       get the fossile fuel file :
+	fCO2_ff=$( gawk "{if (match(\$0,\"${year}\ *${month}\")) {print \$5}}" ${SUBMIT_DIR}/PARAM/CMIP5_gridcar_CO2_emissions_fossil_fuel_Andres_1751-2007_monthly_SC_grid1x1.txt )
+	fCO2_ff=$( echo "${fCO2_ff} / 1000." | bc -l  )
+	echo "Fossil Fuel for historical run  :" ${fCO2_ff}
+
+	# Get restart line in co2.log
+
+	# NEW parameter in config.card (even for Overule all restarts, you must modify the line after this comment ):
+        # !! NEW for Carbone cycle !! Path where to find old co2.log file for restart CO2.
+	#SubmitRestartPath=
+	if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ]) ; then
+	    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ATM SubmitRestartPath
+	    PathCO2log=${config_ATM_SubmitRestartPath}
+	    Date_r=$( IGCM_date_ConvertFormatToGregorian ${config_ATM_RestartDate} )
+	    PreviousLinelog=$( grep ${Date_r} ${PathCO2log}/co2.log )
+	    OUT_OCE=${config_OCE_RestartPath}/${config_OCE_RestartJobName}/OCE
+	    OUT_SRF=${config_SRF_RestartPath}/${config_SRF_RestartJobName}/SRF
+
+	    IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log
+	    IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log
+
+	    # Save Last Line of control in new co2.log file
+	    echo ${PreviousLinelog} >> ${SUBMIT_DIR}/co2.log
+	else
+	    PathCO2log=${SUBMIT_DIR}
+	    PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log )
+	    OUT_OCE=${R_OUT_OCE}
+	    OUT_SRF=${R_OUT_SRF}
+	fi
+
+	# Get Previous period output PREFIX
+	LastPeriodDateBegin=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $2}' )
+	LastPeriodDateEnd=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $3}' )
+	eval LastDatesPeriod=${LastPeriodDateBegin}_${LastPeriodDateEnd} > /dev/null 2>&1
+        # Prefix for save files of this period
+	if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ]) ; then
+	    eval LastPREFIX=${config_ATM_RestartJobName}_${LastDatesPeriod}  > /dev/null 2>&1
+	else
+	    eval LastPREFIX=${config_UserChoices_JobName}_${LastDatesPeriod}  > /dev/null 2>&1
+	fi
+
+	# Ocean	
+	IGCM_sys_TestFileArchive ${OUT_OCE}/Debug/${LastPREFIX}_ocean.output
+	if [ $? = 0 ] ; then
+
+	    if [ $DRYRUN -gt 1 ]; then
+		IGCM_sys_Cp ${OUT_OCE}/Debug/${LastPREFIX}_ocean.output ./
+	    else
+		IGCM_sys_Get ${OUT_OCE}/Debug/${LastPREFIX}_ocean.output ./
+	    fi
+	    IGCM_comp_PrepareDeletedFiles ./${LastPREFIX}_ocean.output
+	    CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ${LastPREFIX}_ocean.output )
+	    CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" )
+	else
+	    echo "Error : file ${OUT_OCE}/Debug/${LastPREFIX}_ocean.output not found."
+	    exit 1
+	fi
+
+	# Surface
+	IGCM_sys_TestFileArchive ${OUT_SRF}/Debug/${LastPREFIX}_out_orchidee_0000
+	if [ $? = 0 ] ; then
+	    if [ $DRYRUN -gt 1 ]; then
+		IGCM_sys_Cp ${OUT_SRF}/Debug/${LastPREFIX}_out_orchidee_0000 ./
+	    else
+		IGCM_sys_Get ${OUT_SRF}/Debug/${LastPREFIX}_out_orchidee_0000 ./
+	    fi
+	    IGCM_comp_PrepareDeletedFiles ./${LastPREFIX}_out_orchidee_0000
+            set +A CO2SBG -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk ${LastPREFIX}_out_orchidee_0000 )
+	else
+	    echo "Error : file ${OUT_SRF}/Debug/${LastPREFIX}_ocean.output not found."
+	    exit 1
+	fi
+	CO2SRF=$( echo ${CO2SBG[0]} | sed -e "s/ *//" )
+	CO2LU=$( echo ${CO2SBG[1]} | sed -e "s/ *//" )
+
+	# Previous CO2
+	CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' )
+
+	# Formula
+	CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SRF} + ${CO2LU}) / 2.12" | bc -l )
+
+	# Save CO2 values in ExeCpuLog variable contents 5 fields
+	echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SRF} ${CO2LU}" |   \
+	     gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \
+                              $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log
+
+    fi
 
     ##-- For historical daily cosp must be output during 1979-2005 period
@@ -174,5 +282,6 @@
     LMDZ_sed physiq.def ok_histNMC  "${LMDZ_NMC_monthly}, ${LMDZ_NMC_daily}, ${LMDZ_NMC_hf}"
     LMDZ_sed physiq.def solaire     ${IPCC_SOLAR}
-    LMDZ_sed physiq.def co2_ppm     ${IPCC_CO2}
+#    LMDZ_sed physiq.def co2_ppm     ${IPCC_CO2}
+    LMDZ_sed physiq.def co2_ppm     ${CO2_ppm}
     LMDZ_sed physiq.def CH4_ppb     ${IPCC_CH4}
     LMDZ_sed physiq.def N2O_ppb     ${IPCC_N2O}
Index: CONFIG/IPSLCM/IPSLCM5A/Chistorical/COMP/lmdz_analyse_pisces_out.awk
===================================================================
--- CONFIG/IPSLCM/IPSLCM5A/Chistorical/COMP/lmdz_analyse_pisces_out.awk	(revision 1237)
+++ CONFIG/IPSLCM/IPSLCM5A/Chistorical/COMP/lmdz_analyse_pisces_out.awk	(revision 1237)
@@ -0,0 +1,104 @@
+#!/usr/bin/awk -f 
+# lmdz_analyse_opa_out - filter NEMO/PISCES output :
+# command :
+# lmdz_analyse_opa_out.awk [-d] ocean.output
+
+#**************************************************************
+# Author: Martial.Mancip
+# Contact: Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision:: 373                                      $ Revision of last commit
+# $Author:: sdipsl                                     $ Author of last commit
+# $Date:: 2010-10-29 12:37:36 +0200 (Fri, 29 Oct 2010) $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#==========================
+function myprint(str) {
+  if (debug) {
+     print str
+  }
+}
+
+
+#==========================
+BEGIN {
+#  print "traitement de " ARGV[1]
+
+  nbarg=ARGC
+
+  if (ARGV[1] == "-d") {
+    debug=1
+    file=ARGV[2]
+    delete ARGV[1] 
+    nbarg--
+  } else {
+    debug=0
+    file=ARGV[1]
+  }
+
+  exit_value=0
+  if (nbarg != 2) {
+        print "Usage: lmdz_analyse_opa_out.awk [-d] file"
+        exit_value=-1
+        exit
+  }
+
+  line=0
+
+  fluxCarbon_found=0
+  counter=0
+
+  CO2file[1]=""
+  errcounter=0
+}
+
+#==========================
+{
+
+#  myprint($0) 
+
+  line=line+1
+  
+  if (match($0, ".*Cumulative total Flux of Carbon out of the ocean.*")) {
+    fluxCarbon_found=1
+    myprint("fluxCarbon_found=1")
+
+    nb=split($0,felts, ":")
+    myprint("nb  :" nb)
+    for (elt in felts) {
+	myprint(elt "- elt  :" felts[elt])
+    }
+    myprint("elts_co2  :" felts[2])
+
+    counter=counter+1
+    CO2file[counter]=felts[2]
+  }
+}
+
+#==========================
+END {
+  if ( exit_value != -1 ) {
+
+    if ( fluxCarbon_found == 1 ) {
+	myprint("CO2 value for " file)
+	myprint("counter  :" counter)
+	for (i=1; i<=counter; i++) {  
+	    print CO2file[i]
+	    myprint("value  :" CO2file[i])
+	}
+	
+	exit_value=0
+	exit 0
+    }
+    else {
+	myprint("ERROR : NO CO2 value for " file)
+	print "0001"
+    }
+    
+  }
+  else {
+      print "0000"
+  }
+}
Index: CONFIG/IPSLCM/IPSLCM5A/Chistorical/COMP/lmdz_analyse_stomate_out.awk
===================================================================
--- CONFIG/IPSLCM/IPSLCM5A/Chistorical/COMP/lmdz_analyse_stomate_out.awk	(revision 1237)
+++ CONFIG/IPSLCM/IPSLCM5A/Chistorical/COMP/lmdz_analyse_stomate_out.awk	(revision 1237)
@@ -0,0 +1,141 @@
+#!/usr/bin/awk -f 
+# lmdz_analyse_stomate_out - filter ORCHIDEE node output :
+# command :
+# lmdz_analyse_stomate_out.awk [-d] out_orchidee[_0000]
+
+#**************************************************************
+# Author: Martial.Mancip
+# Contact: Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision:: 373                                      $ Revision of last commit
+# $Author:: sdipsl                                     $ Author of last commit
+# $Date:: 2010-10-29 12:37:36 +0200 (Fri, 29 Oct 2010) $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#==========================
+function myprint(str) {
+  if (debug) {
+     print str
+  }
+}
+
+
+#==========================
+BEGIN {
+#  print "traitement de " ARGV[1]
+
+  nbarg=ARGC
+
+  if (ARGV[1] == "-d") {
+    debug=1
+    file=ARGV[2]
+    delete ARGV[1] 
+    nbarg--
+  } else {
+    debug=0
+    file=ARGV[1]
+  }
+
+  exit_value=0
+  if (nbarg != 2) {
+        print "Usage: lmdz_analyse_stomate_out.awk [-d] file"
+        exit_value=-1
+        exit
+  }
+
+  line=0
+
+  fluxCarbon_found=0
+  counterCO2=0
+
+  fluxLU_found=0
+  counterLU=0
+
+  CO2file[1]=""
+  LUfile[1]=""
+}
+
+#==========================
+{
+
+#  myprint($0) 
+
+  line=line+1
+
+  if (match($0, ".*GLOBAL net_co2_flux_monthly.*")) {
+    myprint("fluxCarbon_found = 1")
+    fluxCarbon_found=1
+    counterCO2=counterCO2+1
+
+    nb=split($0,felts, "=")
+    myprint("nb  :" nb)
+    for (elt in felts) {
+	myprint(elt "- elt  :" felts[elt])
+    }
+    myprint("elts_co2  :" felts[2])
+
+    CO2file[counterCO2]=felts[2]
+  }
+  else if (match($0, ".*GLOBAL net cflux_prod_total_sum.*")) {
+    myprint("fluxLU_found = 1")
+    fluxLU_found=1
+    counterLU=counterLU+1
+
+    nb=split($0,felts, "=")
+    myprint("nb  :" nb)
+    for (elt in felts) {
+	myprint(elt "- elt  :" felts[elt])
+    }
+    myprint("elts_lu  :" felts[2])
+
+    LUfile[counterLU]=felts[2]
+  }
+}
+
+#==========================
+END {
+  if ( exit_value != -1 ) {
+
+    if ( fluxCarbon_found == 1 ) {
+	myprint("CO2 value for " file)
+	myprint("counterCO2  :" counterCO2)
+	for (i=1; i<=counterCO2; i++) {  
+	    print CO2file[i]
+	    myprint("value  :" CO2file[i])
+	}
+	
+	if ( fluxLU_found == 1 ) {
+	    myprint("LU value for " file)
+	    myprint("counterLU  :" counterLU)
+	    for (i=1; i<=counterLU; i++) {  
+		print LUfile[i]
+		myprint("value  :" LUfile[i])
+	    }
+	    
+	    exit_value=0
+	    exit 0
+	}
+	else {
+	    myprint("ERROR : NO LU value for " file)
+	    print "0002"
+	    exit 1
+	}
+
+	exit_value=0
+	exit 0
+    }
+    else {
+	myprint("ERROR : NO CO2 value for " file)
+	print "0001"
+	print "0002"
+	exit 1
+    }
+    
+  }
+  else {
+      print "0000"
+      exit 1
+  }
+}
Index: CONFIG/IPSLCM/IPSLCM5A/Chistorical/co2.log.init
===================================================================
--- CONFIG/IPSLCM/IPSLCM5A/Chistorical/co2.log.init	(revision 1237)
+++ CONFIG/IPSLCM/IPSLCM5A/Chistorical/co2.log.init	(revision 1237)
@@ -0,0 +1,1 @@
+  CumulPeriod | PeriodDateBegin |   PeriodDateEnd | Monthly CO2 for Period | Previous Monthly CO2 | fossil flux | PISCES flux | ORCHIDEE NEP | ORCHIDEE LUC 
Index: CONFIG/IPSLCM/IPSLCM5A/Chistorical/config.card
===================================================================
--- CONFIG/IPSLCM/IPSLCM5A/Chistorical/config.card	(revision 1236)
+++ CONFIG/IPSLCM/IPSLCM5A/Chistorical/config.card	(revision 1237)
@@ -75,4 +75,6 @@
 RestartJobName=EXP00
 RestartPath=${ARCHIVE}/IGCM_OUT/IPSLCM5A/DEVT/piControl
+# !! NEW for Carbone cycle !! Path where to find old co2.log file for restart CO2.
+SubmitRestartPath=${SUBMIT_DIR}/../CpiControl
 # Old component name for restart (if empty, use new name)
 OldName=
