Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/carbon_cycle_mod.F90
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/carbon_cycle_mod.F90	(revision 1227)
+++ LMDZ4/branches/LMDZ4-dev/libf/phylmd/carbon_cycle_mod.F90	(revision 1227)
@@ -0,0 +1,390 @@
+MODULE carbon_cycle_mod
+
+! Author : Josefine GHATTAS, Patricia CADULE
+
+  IMPLICIT NONE
+  SAVE
+  PRIVATE
+  PUBLIC :: carbon_cycle_init, carbon_cycle
+
+! Variables read from parmeter file physiq.def
+  LOGICAL, PUBLIC :: carbon_cycle_tr        ! 3D transport of CO2 in the atmosphere, parameter read in conf_phys
+  LOGICAL, PUBLIC :: carbon_cycle_cpl       ! Coupling of CO2 fluxes between LMDZ/ORCHIDEE and LMDZ/OCEAN(PISCES) 
+  LOGICAL :: carbon_cycle_emis_comp=.FALSE. ! Calculation of emission compatible
+
+! Scalare values when no transport, from physiq.def
+  REAL :: fos_fuel_s  ! carbon_cycle_fos_fuel dans physiq.def
+  REAL :: emis_land_s ! not yet implemented
+
+  INTEGER :: ntr_co2                ! Number of tracers concerning the carbon cycle
+  INTEGER :: id_fco2_tot            ! Tracer index
+  INTEGER :: id_fco2_ocn            !  - " -
+  INTEGER :: id_fco2_land           !  - " -
+  INTEGER :: id_fco2_land_use       !  - " -
+  INTEGER :: id_fco2_fos_fuel       !  - " -
+  
+  REAL, DIMENSION(:), ALLOCATABLE :: fos_fuel        ! CO2 fossil fuel emission from file [gC/m2/d]
+  REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_ocn_day ! flux CO2 from ocean for 1 day (cumulated) [gC/m2/d]
+  REAL, DIMENSION(:), ALLOCATABLE :: fco2_land_day   ! flux CO2 from land for 1 day (cumulated)  [gC/m2/d]
+  REAL, DIMENSION(:), ALLOCATABLE :: fco2_lu_day     ! Emission from land use change for 1 day (cumulated) [gC/m2/d]
+
+! Following 2 fields will be initialized in surf_land_orchidee at each time step
+  REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_land_inst  ! flux CO2 from land at one time step
+  REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_lu_inst    ! Emission from land use change at one time step
+
+! Calculated co2 field to be send to the ocean via the coupler and to ORCHIDEE 
+  REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: co2_send 
+
+
+CONTAINS
+  
+  SUBROUTINE carbon_cycle_init(tr_seri, aerosol, radio)
+    USE dimphy
+    USE infotrac
+    USE IOIPSL
+    USE surface_data, ONLY : ok_veget, type_ocean
+
+    IMPLICIT NONE
+    INCLUDE "clesphys.h"
+    INCLUDE "iniprint.h"
+ 
+! Input argument
+    REAL,DIMENSION(klon,klev,nbtr),INTENT(IN) :: tr_seri ! Concentration Traceur [U/KgA]  
+
+! InOutput arguments
+    LOGICAL,DIMENSION(nbtr), INTENT(INOUT) :: aerosol
+    LOGICAL,DIMENSION(nbtr), INTENT(INOUT) :: radio
+
+! Local variables
+    INTEGER               :: ierr, it, iiq
+    REAL, DIMENSION(klon) :: tr_seri_sum
+
+
+! 0) Test for compatibility
+    IF (carbon_cycle_cpl .AND. type_ocean/='couple') &
+         CALL abort_gcm('carbon_cycle_init', 'Coupling with ocean model is needed for carbon_cycle_cpl',1)
+    IF (carbon_cycle_cpl .AND..NOT. ok_veget) &
+         CALL abort_gcm('carbon_cycle_init', 'Coupling with surface land model ORCHDIEE is needed for carbon_cycle_cpl',1)
+
+
+! 1) Check if transport of one tracer flux CO2 or 4 separated tracers
+    IF (carbon_cycle_tr) THEN
+       id_fco2_tot=0
+       id_fco2_ocn=0
+       id_fco2_land=0
+       id_fco2_land_use=0
+       id_fco2_fos_fuel=0
+       
+       ! Search in tracer list
+       DO it=1,nbtr
+          iiq=niadv(it+2)
+          IF (tname(iiq) == "fCO2" ) THEN
+             id_fco2_tot=it
+          ELSE IF (tname(iiq) == "fCO2_ocn" ) THEN
+             id_fco2_ocn=it
+          ELSE IF (tname(iiq) == "fCO2_land" ) THEN
+             id_fco2_land=it
+          ELSE IF (tname(iiq) == "fCO2_land_use" ) THEN
+             id_fco2_land_use=it
+          ELSE IF (tname(iiq) == "fCO2_fos_fuel" ) THEN
+             id_fco2_fos_fuel=it
+          END IF
+       END DO
+
+       ! Count tracers found
+       IF (id_fco2_tot /= 0 .AND. &
+            id_fco2_ocn==0 .AND. id_fco2_land==0 .AND. id_fco2_land_use==0 .AND. id_fco2_fos_fuel==0) THEN
+          
+          ! transport  1 tracer flux CO2
+          ntr_co2 = 1
+          
+       ELSE IF (id_fco2_tot==0 .AND. &
+            id_fco2_ocn /=0 .AND. id_fco2_land/=0 .AND. id_fco2_land_use/=0 .AND. id_fco2_fos_fuel/=0) THEN
+          
+          ! transport 4 tracers seperatively
+          ntr_co2 = 4
+          
+       ELSE
+          CALL abort_gcm('carbon_cycle_init', 'error in coherence between traceur.def and gcm.def',1)
+       END IF
+
+       ! Definition of control varaiables for the tracers
+       DO it=1,nbtr
+          IF (it==id_fco2_tot .OR. it==id_fco2_ocn .OR. it==id_fco2_land .OR. &
+               it==id_fco2_land_use .OR. it==id_fco2_fos_fuel) THEN
+             aerosol(it) = .FALSE.
+             radio(it)   = .FALSE.
+          END IF
+       END DO
+
+    ELSE 
+       ! No transport of CO2
+       ntr_co2 = 0
+    END IF ! carbon_cycle_tr
+
+
+! 2) Allocate variable for CO2 fossil fuel emission
+    IF (carbon_cycle_tr) THEN
+       ! Allocate 2D variable
+       ALLOCATE(fos_fuel(klon), stat=ierr)
+       IF (ierr /= 0) CALL abort_gcm('carbon_cycle_init', 'pb in allocation 1',1)
+    ELSE
+       ! No transport : read value from .def
+       fos_fuel_s = 0.
+       CALL getin ('carbon_cycle_fos_fuel',fos_fuel_s)
+       WRITE(lunout,*) 'carbon_cycle_fos_fuel = ', fos_fuel_s 
+    END IF
+
+
+! 3) Allocate and initialize fluxes
+    IF (carbon_cycle_cpl) THEN
+       IF (ierr /= 0) CALL abort_gcm('carbon_cycle_init', 'pb in allocation 2',1)
+       ALLOCATE(fco2_land_day(klon), stat=ierr)
+       IF (ierr /= 0) CALL abort_gcm('carbon_cycle_init', 'pb in allocation 3',1)
+       ALLOCATE(fco2_lu_day(klon), stat=ierr)
+       IF (ierr /= 0) CALL abort_gcm('carbon_cycle_init', 'pb in allocation 4',1)
+
+       fco2_land_day(:) = 0.  ! JG : Doit prend valeur de restart
+       fco2_lu_day(:)   = 0.  ! JG : Doit prend valeur de restart
+
+       ! fco2_ocn_day is allocated in cpl_mod
+       ! fco2_land_inst and fco2_lu_inst are allocated in surf_land_orchidee
+       
+       ALLOCATE(co2_send(klon), stat=ierr)
+       IF (ierr /= 0) CALL abort_gcm('carbon_cycle_init', 'pb in allocation 7',1)
+       
+       ! Calculate using restart tracer values
+       IF (carbon_cycle_tr) THEN
+          IF (ntr_co2==1) THEN
+             co2_send(:) = tr_seri(:,1,id_fco2_tot) + co2_ppm0
+          ELSE ! ntr_co2==4
+             ! Calculate the delta CO2 flux
+             tr_seri_sum(:) = tr_seri(:,1,id_fco2_fos_fuel) + tr_seri(:,1,id_fco2_land_use) + &
+                  tr_seri(:,1,id_fco2_land) + tr_seri(:,1,id_fco2_ocn)
+             co2_send(:) = tr_seri_sum(:) + co2_ppm0
+          END IF
+       ELSE
+          ! Send a scalare value in 2D variable to ocean and land model (PISCES and ORCHIDEE)
+          co2_send(:) = co2_ppm
+       END IF
+
+
+    ELSE 
+       IF (carbon_cycle_tr) THEN
+          ! No coupling of CO2 fields : 
+          ! corresponding fields will instead be read from files
+          ALLOCATE(fco2_ocn_day(klon), stat=ierr)
+          IF (ierr /= 0) CALL abort_gcm('carbon_cycle_init', 'pb in allocation 8',1)
+          ALLOCATE(fco2_land_day(klon), stat=ierr)
+          IF (ierr /= 0) CALL abort_gcm('carbon_cycle_init', 'pb in allocation 9',1)
+          ALLOCATE(fco2_lu_day(klon), stat=ierr)
+          IF (ierr /= 0) CALL abort_gcm('carbon_cycle_init', 'pb in allocation 10',1)       
+       END IF
+    END IF
+
+! 4) Read parmeter for calculation of emission compatible
+    IF (.NOT. carbon_cycle_tr) THEN
+       carbon_cycle_emis_comp=.FALSE.
+       CALL getin('carbon_cycle_emis_comp',carbon_cycle_emis_comp)
+       WRITE(lunout,*) 'carbon_cycle_emis_comp = ',carbon_cycle_emis_comp
+    END IF
+
+  END SUBROUTINE carbon_cycle_init
+
+!
+!
+!
+
+  SUBROUTINE carbon_cycle(nstep, pdtphys, pctsrf, tr_seri)
+    
+    USE infotrac
+    USE dimphy
+    USE mod_phys_lmdz_transfert_para, ONLY : reduce_sum
+    USE phys_cal_mod, ONLY : mth_cur, mth_len
+    USE phys_cal_mod, ONLY : day_cur
+    USE comgeomphy
+
+    IMPLICIT NONE
+
+    INCLUDE "clesphys.h"
+    INCLUDE "indicesol.h"
+
+! In/Output arguments
+    INTEGER,INTENT(IN) :: nstep      ! time step in physiq
+    REAL,INTENT(IN)    :: pdtphys    ! length of time step in physiq (sec)
+    REAL,DIMENSION(klon,nbsrf),INTENT(IN) :: pctsrf ! Pourcentage de sol f(nature du sol)
+    REAL, DIMENSION(klon,klev,nbtr), INTENT(INOUT)  :: tr_seri
+
+! Local variables
+    LOGICAL :: newmonth ! indicates if a new month just started
+    LOGICAL :: newday   ! indicates if a new day just started
+    LOGICAL :: endday   ! indicated if last time step in a day
+
+    REAL, PARAMETER :: fact=1.E-15/2.12  ! transformation factor from gC/m2/day => ppm/m2/day
+    REAL, DIMENSION(klon) :: fco2_tmp, tr_seri_sum
+    REAL :: sumtmp
+    REAL :: airetot     ! Total area the earth
+    REAL :: delta_co2_ppm
+    
+! -) Calculate logicals indicating if it is a new month, new day or the last time step in a day (end day)
+
+    newday = .FALSE.; endday = .FALSE.; newmonth = .FALSE.
+
+    IF (MOD(nstep,INT(86400./pdtphys))==1) newday=.TRUE.
+    IF (MOD(nstep,INT(86400./pdtphys))==0) endday=.TRUE.
+    IF (newday .AND. day_cur==1) newmonth=.TRUE.
+    
+! -) Read new maps if new month started
+    IF (newmonth .AND. carbon_cycle_tr) THEN
+       CALL read_map2D('fossil_fuel.nc','fos_fuel', mth_cur, .FALSE., fos_fuel)
+       
+       ! division by month lenght to get dayly value
+       fos_fuel(:) = fos_fuel(:)/mth_len
+       
+       IF (.NOT. carbon_cycle_cpl) THEN
+          ! Get dayly values from monthly fluxes
+          CALL read_map2D('fl_co2_ocean.nc','CO2_OCN',mth_cur,.FALSE.,fco2_ocn_day)
+          CALL read_map2D('fl_co2_land.nc','CO2_LAND', mth_cur,.FALSE.,fco2_land_day)
+          CALL read_map2D('fl_co2_land_use.nc','CO2_LAND_USE',mth_cur,.FALSE.,fco2_lu_day)
+       END IF
+    END IF
+    
+
+
+! -) Update tracers at beginning of a new day. Beginning of a new day correspond to a new coupling period in cpl_mod.
+    IF (newday) THEN
+
+       IF (carbon_cycle_tr) THEN
+
+          ! Update tracers
+          IF (ntr_co2 == 1) THEN
+             ! Calculate the new flux CO2
+             tr_seri(:,1,id_fco2_tot) = tr_seri(:,1,id_fco2_tot) + &
+                  (fos_fuel(:) + &
+                  fco2_lu_day(:)  * pctsrf(:,is_ter) + &
+                  fco2_land_day(:)* pctsrf(:,is_ter) + &
+                  fco2_ocn_day(:) * pctsrf(:,is_oce)) * fact
+
+          ELSE ! ntr_co2 == 4
+             tr_seri(:,1,id_fco2_fos_fuel)  = tr_seri(:,1,id_fco2_fos_fuel) + fos_fuel(:) * fact ! [ppm/m2/day]
+
+             tr_seri(:,1,id_fco2_land_use)  = tr_seri(:,1,id_fco2_land_use) + &
+                  fco2_lu_day(:)  *pctsrf(:,is_ter)*fact ! [ppm/m2/day]
+
+             tr_seri(:,1,id_fco2_land)      = tr_seri(:,1,id_fco2_land)     + &
+                  fco2_land_day(:)*pctsrf(:,is_ter)*fact ! [ppm/m2/day]
+
+             tr_seri(:,1,id_fco2_ocn)       = tr_seri(:,1,id_fco2_ocn)      + &
+                  fco2_ocn_day(:) *pctsrf(:,is_oce)*fact ! [ppm/m2/day]
+
+          END IF
+
+       ELSE ! no transport
+          IF (carbon_cycle_cpl) THEN
+             IF (carbon_cycle_emis_comp) THEN
+                ! Calcul emission compatible a partir des champs 2D et co2_ppm
+                !!! TO DO!!
+                CALL abort_gcm('carbon_cycle', ' Option carbon_cycle_emis_comp not yet implemented',1)
+             END IF
+          END IF
+
+       END IF ! carbon_cycle_tr
+    
+       ! Reset cumluative variables
+       IF (carbon_cycle_cpl) THEN
+          fco2_land_day(:) = 0.
+          fco2_lu_day(:)   = 0.
+       END IF
+    
+    END IF ! newday
+       
+
+
+! -) Cumulate fluxes from ORCHIDEE at each timestep
+    IF (carbon_cycle_cpl) THEN
+       fco2_land_day(:) = fco2_land_day(:) + fco2_land_inst(:)
+       fco2_lu_day(:)   = fco2_lu_day(:)   + fco2_lu_inst(:)
+    END IF
+
+
+
+! -)  At the end of a new day, calculate a mean scalare value of CO2 to be used by 
+!     the radiation scheme (instead of reading value from .def)
+
+! JG : Ici on utilise uniquement le traceur du premier couche du modele. Est-ce que c'est correcte ? 
+    IF (endday) THEN 
+       ! Calculte total area of the earth surface
+       CALL reduce_sum(SUM(airephy),airetot)
+       
+
+       IF (carbon_cycle_tr) THEN
+          IF (ntr_co2 == 1) THEN
+          
+             ! Calculate mean value of tracer CO2 to get an scalare value to be used in the 
+             ! radiation scheme (instead of reading value from .def)
+             ! Mean value weighted with the grid cell area
+             
+             ! Calculate mean value
+             fco2_tmp(:) = tr_seri(:,1,id_fco2_tot) * airephy(:) 
+             CALL reduce_sum(SUM(fco2_tmp),sumtmp)
+             co2_ppm = sumtmp/airetot + co2_ppm0
+             
+          ELSE ! ntr_co2 == 4
+             
+             ! Calculate the delta CO2 flux
+             tr_seri_sum(:) = tr_seri(:,1,id_fco2_fos_fuel) + tr_seri(:,1,id_fco2_land_use) + &
+                  tr_seri(:,1,id_fco2_land) + tr_seri(:,1,id_fco2_ocn)
+             
+             ! Calculate mean value of delta CO2 flux
+             fco2_tmp(:) = tr_seri_sum(:) * airephy(:)
+             CALL reduce_sum(SUM(fco2_tmp),sumtmp)
+             delta_co2_ppm = sumtmp/airetot
+             
+             ! Add initial value for co2_ppm to delta value
+             co2_ppm = delta_co2_ppm + co2_ppm0
+          END IF
+
+       ELSE IF (carbon_cycle_cpl) THEN ! no carbon_cycle_tr
+
+          ! Calculate the total CO2 flux and integrate to get scalare value for the radiation scheme
+          fco2_tmp(:) = (fos_fuel(:) + (fco2_lu_day(:) + fco2_land_day(:))*pctsrf(:,is_ter) &
+               + fco2_ocn_day(:)*pctsrf(:,is_oce)) * fact
+          
+          ! Calculate mean value
+          fco2_tmp(:) = fco2_tmp(:) * airephy(:)
+          CALL reduce_sum(SUM(fco2_tmp),sumtmp)
+          delta_co2_ppm = sumtmp/airetot
+
+          ! Update current value of the atmospheric co2_ppm
+          co2_ppm = co2_ppm + delta_co2_ppm
+          
+       END IF ! carbon_cycle_tr
+
+       ! transformation of the atmospheric CO2 concentration for the radiation code
+       RCO2 = co2_ppm * 1.0e-06  * 44.011/28.97 
+
+    END IF
+
+    ! Calculate CO2 flux to send to ocean and land models : PISCES and ORCHIDEE         
+    IF (endday .AND. carbon_cycle_cpl) THEN
+       
+       IF (carbon_cycle_tr) THEN
+          IF (ntr_co2==1) THEN
+
+             co2_send(:) = tr_seri(:,1,id_fco2_tot) + co2_ppm0
+
+          ELSE ! ntr_co2 == 4
+
+             co2_send(:) = tr_seri_sum(:) + co2_ppm0
+
+          END IF
+       ELSE
+          ! Send a scalare value in 2D variable to ocean and land model (PISCES and ORCHIDEE)
+          co2_send(:) = co2_ppm
+       END IF
+
+    END IF
+
+  END SUBROUTINE carbon_cycle
+  
+END MODULE carbon_cycle_mod
Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/clesphys.h
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/clesphys.h	(revision 1226)
+++ LMDZ4/branches/LMDZ4-dev/libf/phylmd/clesphys.h	(revision 1227)
@@ -12,5 +12,5 @@
        LOGICAL ok_limitvrai
        INTEGER nbapp_rad, iflag_con
-       REAL co2_ppm, solaire
+       REAL co2_ppm, co2_ppm0, solaire
        REAL(kind=8) RCO2, RCH4, RN2O, RCFC11, RCFC12  
        REAL(kind=8) CH4_ppb, N2O_ppb, CFC11_ppt, CFC12_ppt
@@ -71,5 +71,6 @@
      &     , freq_ISCCP, ecrit_ISCCP, ip_ebil_phy                       &
      &     , ok_lic_melt, cvl_corr, aer_type                            &
-     &     , qsol0, iflag_rrtm, ok_strato,ok_hines,ecrit_LES
+     &     , qsol0, iflag_rrtm, ok_strato,ok_hines,ecrit_LES            &
+     &     , co2_ppm0
      
 !$OMP THREADPRIVATE(/clesphys/)
Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/conf_phys.F90
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/conf_phys.F90	(revision 1226)
+++ LMDZ4/branches/LMDZ4-dev/libf/phylmd/conf_phys.F90	(revision 1227)
@@ -21,4 +21,5 @@
    use IOIPSL
    USE surface_data
+   USE carbon_cycle_mod, ONLY : carbon_cycle_tr, carbon_cycle_cpl
 
    implicit none
@@ -144,4 +145,7 @@
   LOGICAL,SAVE :: ok_strato_omp
   LOGICAL,SAVE :: ok_hines_omp
+  LOGICAL      :: read_climoz_omp
+  LOGICAL      :: carbon_cycle_tr_omp
+  LOGICAL      :: carbon_cycle_cpl_omp
 
   logical, intent(out):: read_climoz ! read ozone climatology, OpenMP shared
@@ -1262,6 +1266,12 @@
   call getin('ecrit_LES', ecrit_LES_omp)
 !
-  read_climoz = .false. ! default value
-  call getin('read_climoz', read_climoz)
+  read_climoz_omp = .false. ! default value
+  call getin('read_climoz', read_climoz_omp)
+
+  carbon_cycle_tr_omp=.FALSE.
+  CALL getin('carbon_cycle_tr',carbon_cycle_tr_omp)
+
+  carbon_cycle_cpl_omp=.FALSE.
+  CALL getin('carbon_cycle_cpl',carbon_cycle_cpl_omp)
 
 !$OMP END MASTER
@@ -1393,5 +1403,8 @@
     ok_LES = ok_LES_omp
     ecrit_LES = ecrit_LES_omp
-    
+    read_climoz = read_climoz_omp
+    carbon_cycle_tr = carbon_cycle_tr_omp
+    carbon_cycle_cpl = carbon_cycle_cpl_omp
+
 ! Test of coherence between type_ocean and version_ocean
     IF (type_ocean=='couple' .AND. (version_ocean/='opa8' .AND. version_ocean/='nemo') ) THEN
@@ -1524,4 +1537,6 @@
   write(numout,*) 'ok_hines = ',  ok_hines
   write(numout,*) 'read_climoz = ', read_climoz
+  write(numout,*) 'carbon_cycle_tr = ', carbon_cycle_tr
+  write(numout,*) 'carbon_cycle_cpl = ', carbon_cycle_cpl
   
 !$OMP END MASTER
Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/cpl_mod.F90
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/cpl_mod.F90	(revision 1226)
+++ LMDZ4/branches/LMDZ4-dev/libf/phylmd/cpl_mod.F90	(revision 1227)
@@ -39,5 +39,5 @@
 !*************************************************************************************
 ! variable for coupling period
-  INTEGER, SAVE                             :: nexca
+  INTEGER, SAVE :: nexca
   !$OMP THREADPRIVATE(nexca)
 
@@ -95,4 +95,5 @@
 !
   SUBROUTINE cpl_init(dtime, rlon, rlat)
+    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, fco2_ocn_day
 
     INCLUDE "dimensions.h"
@@ -183,8 +184,12 @@
     sum_error = sum_error + error
 
-    IF (cpl_carbon_cycle) THEN
+    IF (carbon_cycle_cpl) THEN
        ALLOCATE(read_co2(iim, jj_nb), stat = error)
        sum_error = sum_error + error
        ALLOCATE(cpl_atm_co2(klon,2), stat = error)
+       sum_error = sum_error + error
+
+! Allocate variable in carbon_cycle_mod
+       ALLOCATE(fco2_ocn_day(klon), stat = error)
        sum_error = sum_error + error
     END IF
@@ -275,5 +280,6 @@
     USE surface_data
     USE phys_state_var_mod, ONLY : rlon, rlat
-
+    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl
+    
     INCLUDE "indicesol.h"
     INCLUDE "temps.h"
@@ -364,5 +370,5 @@
       ENDIF
 
-       IF (cpl_carbon_cycle) THEN
+       IF (carbon_cycle_cpl) THEN
 !$OMP MASTER
            read_co2(:,:) = tab_read_flds(:,:,idr_oceco2) ! CO2 flux
@@ -403,4 +409,5 @@
 ! The temperature is transformed into 1D array with valid points from index 1 to knon.
 !
+    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, fco2_ocn_day
     INCLUDE "indicesol.h"
 
@@ -418,6 +425,7 @@
 ! Local variables
 !*************************************************************************************
-    INTEGER               :: i
-    REAL, DIMENSION(klon) :: sic_new
+    INTEGER                  :: i
+    INTEGER, DIMENSION(klon) :: index
+    REAL, DIMENSION(klon)    :: sic_new
 
 !*************************************************************************************
@@ -430,9 +438,16 @@
     CALL cpl2gath(read_v0, v0_new, knon, knindex)
 
-    IF (cpl_carbon_cycle) THEN
-       WRITE(*,*) 'cpl_carbon_cycle TO BE DONE!!'
-       !!    var_co2 will be a intent(out) argument
-       !!    CALL cpl2gath(read_co2, var_co2, knon, knindex)
+!*************************************************************************************
+! Transform read_co2 into uncompressed 1D variable fco2_ocn_day added directly in 
+! the module carbon_cycle_mod
+!
+!*************************************************************************************
+    IF (carbon_cycle_cpl) THEN
+       DO i=1,klon
+          index(i)=i
+       END DO
+       CALL cpl2gath(read_co2, fco2_ocn_day, klon, index)
     END IF
+
 !*************************************************************************************
 ! The fields received from the coupler have to be weighted with the fraction of ocean 
@@ -511,4 +526,5 @@
 ! (it is done in cpl_send_seaice_fields).
 !
+    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, co2_send
     INCLUDE "indicesol.h"
     INCLUDE "dimensions.h"
@@ -531,5 +547,4 @@
     CHARACTER(len = 25)                     :: modname = 'cpl_send_ocean_fields'
     CHARACTER(len = 80)                     :: abort_message
-    REAL, DIMENSION(klon)                   :: atm_co2    ! JG: to be an INTENT(IN) if cpl_carbon_cycle
 
 !*************************************************************************************
@@ -556,5 +571,5 @@
        cpl_tauy(1:knon,cpl_index) = 0.0
        cpl_windsp(1:knon,cpl_index) = 0.0
-       IF (cpl_carbon_cycle) cpl_atm_co2(1:knon,cpl_index) = 0.0
+       IF (carbon_cycle_cpl) cpl_atm_co2(1:knon,cpl_index) = 0.0
     ENDIF
        
@@ -587,8 +602,7 @@
             windsp(ig)      / FLOAT(nexca) 
 
-       IF (cpl_carbon_cycle) THEN
-          atm_co2=286.
+       IF (carbon_cycle_cpl) THEN
           cpl_atm_co2(ig,cpl_index) = cpl_atm_co2(ig,cpl_index) + &
-               atm_co2(ig)/ FLOAT(nexca) 
+               co2_send(knindex(ig))/ FLOAT(nexca) 
        END IF
      ENDDO
@@ -627,5 +641,5 @@
           sum_error = sum_error + error
           
-          IF (cpl_carbon_cycle) THEN
+          IF (carbon_cycle_cpl) THEN
              ALLOCATE(cpl_atm_co22D(iim,jj_nb), stat=error)
              sum_error = sum_error + error
@@ -675,5 +689,5 @@
             knon, knindex)
 
-       IF (cpl_carbon_cycle) &
+       IF (carbon_cycle_cpl) &
             CALL gath2cpl(cpl_atm_co2(:,cpl_index), cpl_atm_co22D(:,:), knon, knindex)
    ENDIF
@@ -695,4 +709,5 @@
 ! the coupler.
 !
+    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl
     INCLUDE "indicesol.h"
     INCLUDE "dimensions.h"
@@ -803,5 +818,5 @@
           sum_error = sum_error + error
 
-          IF (cpl_carbon_cycle) THEN
+          IF (carbon_cycle_cpl) THEN
              ALLOCATE(cpl_atm_co22D(iim,jj_nb), stat=error)
              sum_error = sum_error + error
@@ -926,4 +941,5 @@
 ! will be done in cpl_send_seaice_fields.
 !
+
     INCLUDE "dimensions.h"
 
@@ -979,4 +995,5 @@
 !    
     USE surface_data
+    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl
 ! Some includes
 !*************************************************************************************
@@ -1037,5 +1054,5 @@
     IF (version_ocean=='nemo') THEN
        tab_flds(:,:,ids_liqrun) = cpl_rriv2D(:,:) + cpl_rcoa2D(:,:)
-       IF (cpl_carbon_cycle) tab_flds(:,:,ids_atmco2)=cpl_atm_co22D(:,:)
+       IF (carbon_cycle_cpl) tab_flds(:,:,ids_atmco2)=cpl_atm_co22D(:,:)
     ELSE IF (version_ocean=='opa8') THEN
        tab_flds(:,:,ids_shfoce) = cpl_sols2D(:,:,1)
@@ -1232,5 +1249,5 @@
     sum_error = sum_error + error
     
-    IF (cpl_carbon_cycle) THEN
+    IF (carbon_cycle_cpl) THEN
        DEALLOCATE(cpl_atm_co22D, stat=error )
        sum_error = sum_error + error
@@ -1248,15 +1265,15 @@
   SUBROUTINE cpl2gath(champ_in, champ_out, knon, knindex)
   USE mod_phys_lmdz_para
-! Cette routine ecrit un champ 'gathered' sur la grille 2D pour le passer
-! au coupleur.
+! Cette routine transforme un champs de la grille 2D recu du coupleur sur la grille 
+! 'gathered' (la grille physiq comprime).
 !
 ! 
 ! input:         
-!   champ_in     champ sur la grille gathere        
+!   champ_in     champ sur la grille 2D
 !   knon         nombre de points dans le domaine a traiter
 !   knindex      index des points de la surface a traiter
 !
 ! output:
-!   champ_out    champ sur la grille 2D
+!   champ_out    champ sur la grille 'gatherd'
 !
     INCLUDE "dimensions.h"
Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/oasis.F90
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/oasis.F90	(revision 1226)
+++ LMDZ4/branches/LMDZ4-dev/libf/phylmd/oasis.F90	(revision 1227)
@@ -72,5 +72,4 @@
   
   LOGICAL :: cpl_current
-  LOGICAL :: cpl_carbon_cycle
 
 #ifdef CPP_COUPLE
@@ -88,4 +87,6 @@
     USE IOIPSL
     USE surface_data, ONLY : version_ocean
+    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl
+
     INCLUDE "dimensions.h"
     INCLUDE "iniprint.h"
@@ -105,5 +106,4 @@
     CHARACTER (len = 80)               :: abort_message 
     LOGICAL                            :: cpl_current_omp
-    LOGICAL                            :: cpl_carbon_cycle_omp
 
 !*    1. Initializations
@@ -133,15 +133,4 @@
     cpl_current = cpl_current_omp
     WRITE(lunout,*) 'Couple ocean currents, cpl_current = ',cpl_current 
-
-!************************************************************************************
-! Define if coupling carbon cycle or not
-!************************************************************************************
-!$OMP MASTER
-    cpl_carbon_cycle_omp = .FALSE.
-    CALL getin('cpl_carbon_cycle', cpl_carbon_cycle_omp)
-!$OMP END MASTER
-!$OMP BARRIER
-    cpl_carbon_cycle=cpl_carbon_cycle_omp
-    WRITE(lunout,*) 'Couple carbon cycle , cpl_carbon_cycle = ',cpl_carbon_cycle
 
 !************************************************************************************
@@ -174,5 +163,5 @@
         infosend(ids_icevap)%action = .TRUE. ; infosend(ids_icevap)%name = 'COICEVAP'
         infosend(ids_liqrun)%action = .TRUE. ; infosend(ids_liqrun)%name = 'COLIQRUN'
-        IF (cpl_carbon_cycle) THEN
+        IF (carbon_cycle_cpl) THEN
             infosend(ids_atmco2)%action = .TRUE. ; infosend(ids_atmco2)%name = 'COATMCO2'
         ENDIF
@@ -204,5 +193,5 @@
    ENDIF
 
-   IF (cpl_carbon_cycle ) THEN
+   IF (carbon_cycle_cpl ) THEN
        inforecv(idr_oceco2)%action = .TRUE. ; inforecv(idr_oceco2)%name = 'SICO2FLX'
    ENDIF
Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/pbl_surface_mod.F90
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/pbl_surface_mod.F90	(revision 1226)
+++ LMDZ4/branches/LMDZ4-dev/libf/phylmd/pbl_surface_mod.F90	(revision 1227)
@@ -242,4 +242,7 @@
 ! pblT-----output-R- T au nveau HCL
 !
+    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, co2_send
+    IMPLICIT NONE
+
     INCLUDE "indicesol.h"
     INCLUDE "dimsoil.h"
@@ -762,7 +765,13 @@
        ypsref(:) = ypaprs(:,1)  
 
-! - Constant CO2 is copied to global grid
-       r_co2_ppm(:) = co2_ppm
-
+! - CO2 field on 2D grid to be sent to ORCHIDEE
+!   Transform to compressed field
+       IF (carbon_cycle_cpl) THEN
+          DO i=1,knon
+             r_co2_ppm(i) = co2_send(ni(i))
+          END DO
+       ELSE
+          r_co2_ppm(:) = co2_ppm     ! Constant field
+       END IF
 
 !****************************************************************************************
Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/phyetat0.F
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/phyetat0.F	(revision 1226)
+++ LMDZ4/branches/LMDZ4-dev/libf/phylmd/phyetat0.F	(revision 1227)
@@ -21,4 +21,5 @@
       USE infotrac
       USE traclmdz_mod,    ONLY : traclmdz_from_restart
+      USE carbon_cycle_mod,ONLY : carbon_cycle_tr, carbon_cycle_cpl
 
       IMPLICIT none
@@ -106,5 +107,15 @@
          tab_cntrl(1)=dtime
          tab_cntrl(2)=radpas
-         co2_ppm_etat0      = tab_cntrl(3)
+
+c co2_ppm : value from the previous time step
+         IF (carbon_cycle_tr .OR. carbon_cycle_cpl) THEN
+            co2_ppm = tab_cntrl(3)
+            RCO2    = co2_ppm * 1.0e-06  * 44.011/28.97 
+c ELSE : keep value from .def
+         END IF
+
+c co2_ppm0 : initial value of atmospheric CO2 (from create_etat0_limit.e .def)
+         co2_ppm0   = tab_cntrl(16)
+
          solaire_etat0      = tab_cntrl(4)
          tab_cntrl(5)=iflag_con
Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/phyredem.F
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/phyredem.F	(revision 1226)
+++ LMDZ4/branches/LMDZ4-dev/libf/phylmd/phyredem.F	(revision 1227)
@@ -76,4 +76,5 @@
 CC      tab_cntrl(1) = dtime
       tab_cntrl(2) = radpas
+c co2_ppm : current value of atmospheric CO2
       tab_cntrl(3) = co2_ppm
       tab_cntrl(4) = solaire
@@ -90,4 +91,7 @@
       tab_cntrl(14) = annee_ref
       tab_cntrl(15) = itau_phy
+
+c co2_ppm0 : initial value of atmospheric CO2
+      tab_cntrl(16) = co2_ppm0
 c
       CALL put_var("controle","Parametres de controle",tab_cntrl)
Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/phys_cal_mod.F90
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/phys_cal_mod.F90	(revision 1227)
+++ LMDZ4/branches/LMDZ4-dev/libf/phylmd/phys_cal_mod.F90	(revision 1227)
@@ -0,0 +1,41 @@
+! $Id:$
+MODULE phys_cal_mod
+! This module contains information on the calendar at the actual time step
+
+  SAVE
+
+  INTEGER :: year_cur      ! current year
+  INTEGER :: mth_cur       ! current month
+  INTEGER :: day_cur       ! current day
+  INTEGER :: days_elapsed  ! number of whole days since start of the simulation 
+  INTEGER :: mth_len       ! number of days in the current month
+  REAL    :: hour
+  REAL    :: jD_1jan
+  REAL    :: jH_1jan
+  REAL    :: xjour
+
+
+CONTAINS
+  
+  SUBROUTINE phys_cal_update(jD_cur, jH_cur)
+    ! This subroutine updates the module saved variables.
+
+    USE IOIPSL
+    
+    REAL, INTENT(IN) :: jD_cur ! jour courant a l'appel de la physique (jour julien)
+    REAL, INTENT(IN) :: jH_cur ! heure courante a l'appel de la physique (jour julien)
+    
+    CALL ju2ymds(jD_cur+jH_cur, year_cur, mth_cur, day_cur, hour)
+    CALL ymds2ju(year_cur, 1, 1, 0., jD_1jan)
+    
+    jH_1jan = jD_1jan - int (jD_1jan)
+    jD_1jan = int (jD_1jan) 
+    xjour = jD_cur - jD_1jan
+    days_elapsed = jD_cur - jD_1jan
+
+    ! Get lenght of acutual month
+    mth_len = ioget_mon_len(year_cur,mth_cur)
+
+  END SUBROUTINE phys_cal_update
+
+END MODULE phys_cal_mod
Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/phys_state_var_mod.F90
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/phys_state_var_mod.F90	(revision 1226)
+++ LMDZ4/branches/LMDZ4-dev/libf/phylmd/phys_state_var_mod.F90	(revision 1227)
@@ -11,7 +11,7 @@
       INTEGER, PARAMETER :: napisccp=1
       INTEGER, SAVE :: radpas
-      REAL, SAVE :: dtime, co2_ppm_etat0, solaire_etat0
+      REAL, SAVE :: dtime, solaire_etat0
 !$OMP THREADPRIVATE(radpas)
-!$OMP THREADPRIVATE(dtime, co2_ppm_etat0, solaire_etat0)
+!$OMP THREADPRIVATE(dtime, solaire_etat0)
 
       REAL, ALLOCATABLE, SAVE :: rlat(:), rlon(:), pctsrf(:,:)
Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/physiq.F
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/physiq.F	(revision 1226)
+++ LMDZ4/branches/LMDZ4-dev/libf/phylmd/physiq.F	(revision 1227)
@@ -16,4 +16,5 @@
 !JG     $     histwrite, ju2ymds, ymds2ju, ioget_year_len
       USE comgeomphy
+      USE phys_cal_mod
       USE write_field_phy
       USE dimphy
@@ -529,11 +530,4 @@
       REAL clesphy0( longcles      )
 c
-c Variables quasi-arguments
-c
-      REAL xjour
-      SAVE xjour
-c$OMP THREADPRIVATE(xjour)
-c
-c
 c Variables propres a la physique
       INTEGER itap
@@ -705,9 +699,5 @@
 c
 !
-! Gestion calendrier
-!
-      REAL :: jD_1jan, jH_1jan
-      INTEGER :: year_cur, mth_cur, day_cur, days_elapsed
-      REAL :: hour, day_since_equinox
+      REAL :: day_since_equinox
 ! Date de l'equinoxe de printemps
       INTEGER, parameter :: mth_eq=3, day_eq=21
@@ -1204,12 +1194,7 @@
 
 c======================================================================
-! Gestion calendrier
+! Gestion calendrier : mise a jour du module phys_cal_mod
 !
-      call ju2ymds(jD_cur+jH_cur, year_cur, mth_cur, day_cur, hour)
-      call ymds2ju(year_cur, 1, 1, 0., jD_1jan)
-      jH_1jan = jD_1jan - int (jD_1jan)
-      jD_1jan = int (jD_1jan) 
-      xjour = jD_cur - jD_1jan
-      days_elapsed = jD_cur - jD_1jan
+      CALL phys_cal_update(jD_cur,jH_cur)
 
 c
Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/phytrac.F90
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/phytrac.F90	(revision 1226)
+++ LMDZ4/branches/LMDZ4-dev/libf/phylmd/phytrac.F90	(revision 1227)
@@ -212,5 +212,5 @@
      SELECT CASE(type_trac)
      CASE('lmdz')
-        CALL traclmdz_init(pctsrf, ftsol, aerosol, lessivage)
+        CALL traclmdz_init(pctsrf, ftsol, tr_seri, aerosol, lessivage)
      CASE('inca')
         source(:,:)=0.
Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/read_map2D.F90
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/read_map2D.F90	(revision 1227)
+++ LMDZ4/branches/LMDZ4-dev/libf/phylmd/read_map2D.F90	(revision 1227)
@@ -0,0 +1,60 @@
+SUBROUTINE read_map2D(filename, varname, timestep, inverse, varout)
+! Open file and read one variable for one timestep.
+! Return variable for the given timestep. 
+  USE dimphy
+  USE netcdf
+  USE mod_grid_phy_lmdz
+  USE mod_phys_lmdz_para
+
+
+  IMPLICIT NONE
+
+! Input arguments
+  CHARACTER(len=20), INTENT(IN) :: filename     ! name of file to read
+  CHARACTER(len=20), INTENT(IN) :: varname      ! name of variable in file
+  INTEGER, INTENT(IN)           :: timestep     ! actual timestep
+  LOGICAL, INTENT(IN)           :: inverse      ! TRUE if latitude needs to be inversed
+! Output argument
+  REAL, DIMENSION(klon), INTENT(OUT) :: varout  ! The variable read from file for the given timestep
+
+! Local variables
+  INTEGER :: j
+  INTEGER :: nid, nvarid, ierr
+  INTEGER, DIMENSION(3) :: start, count
+  CHARACTER(len=20)     :: modname='read_map2D'
+
+  REAL, DIMENSION(nbp_lon,nbp_lat) :: var_glo2D     ! 2D global 
+  REAL, DIMENSION(nbp_lon,nbp_lat) :: var_glo2D_tmp ! 2D global
+  REAL, DIMENSION(klon_glo)        :: var_glo1D     ! 1D global
+
+
+! Read variable from file. Done by master process MPI and master thread OpenMP
+  IF (is_mpi_root .AND. is_omp_root) THEN
+     ierr = NF90_OPEN (filename, NF90_NOWRITE, nid)
+     IF (ierr /= NF90_NOERR) CALL abort_gcm(modname,'Problem in opening file '//filename,1)
+
+     ierr = NF90_INQ_VARID(nid, varname, nvarid)
+     IF (ierr /= NF90_NOERR) CALL abort_gcm(modname, 'The variable '//varname//' is absent in file',1)
+     
+     start=(/1,1,timestep/)
+     count=(/nbp_lon,nbp_lat,1/)
+     ierr = NF90_GET_VAR(nid, nvarid, var_glo2D,start,count)
+     IF (ierr /= NF90_NOERR) CALL abort_gcm(modname, 'Problem in reading varaiable '//varname,1)
+
+     ! Inverse latitude order
+     IF (inverse) THEN
+        var_glo2D_tmp(:,:) = var_glo2D(:,:)
+        DO j=1, nbp_lat
+           var_glo2D(:,j) = var_glo2D_tmp(:,nbp_lat-j+1)
+        END DO
+     END IF
+
+     ! Transform the global field from 2D to 1D
+     CALL grid2Dto1D_glo(var_glo2D,var_glo1D)
+
+  ENDIF
+
+! Scatter gloabl 1D variable to all processes
+  CALL scatter(var_glo1D, varout)
+
+END SUBROUTINE read_map2D
Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/surf_land_orchidee_mod.F90
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/surf_land_orchidee_mod.F90	(revision 1226)
+++ LMDZ4/branches/LMDZ4-dev/libf/phylmd/surf_land_orchidee_mod.F90	(revision 1227)
@@ -40,7 +40,10 @@
        tsol_rad, tsurf_new, alb1_new, alb2_new, &
        emis_new, z0_new, qsurf)
-   USE mod_surf_para
-   USE mod_synchro_omp
+
+    USE mod_surf_para
+    USE mod_synchro_omp
    
+USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, fco2_land_inst, fco2_lu_inst
+
 !    
 ! Cette routine sert d'interface entre le modele atmospherique et le 
@@ -67,5 +70,6 @@
 !   spechum      humidite specifique 1ere couche
 !   epot_air     temp pot de l'air
-!   ccanopy      concentration CO2 canopee
+!   ccanopy      concentration CO2 canopee, correspond au co2_send de 
+!                carbon_cycle_mod ou valeur constant co2_ppm
 !   tq_cdrag     cdrag
 !   petAcoef     coeff. A de la resolution de la CL pour t
@@ -134,4 +138,6 @@
     INTEGER                                   :: error
     REAL, DIMENSION(klon)                     :: swdown_vrai
+    REAL, DIMENSION(klon)                     :: fco2_land_comp  ! sur grille compresse
+    REAL, DIMENSION(klon)                     :: fco2_lu_comp    ! sur grille compresse
     CHARACTER (len = 20)                      :: modname = 'surf_land_orchidee'
     CHARACTER (len = 80)                      :: abort_message
@@ -341,6 +347,19 @@
           CALL abort_gcm(modname,abort_message,1)
        ENDIF
-
+!
+! Allocate variables needed for carbon_cycle_mod
+!
+       IF (carbon_cycle_cpl) THEN
+          IF (.NOT. ALLOCATED(fco2_land_inst)) THEN
+             ALLOCATE(fco2_land_inst(klon),stat=error)
+             IF (error /= 0)  CALL abort_gcm(modname,'Pb in allocation fco2_land_inst',1)
+             
+             ALLOCATE(fco2_lu_inst(klon),stat=error)
+             IF(error /=0) CALL abort_gcm(modname,'Pb in allocation fco2_lu_inst',1)
+          END IF
+       END IF
+       
     ENDIF                          ! (fin debut) 
+ 
 
 ! 
@@ -443,5 +462,24 @@
     
     IF (debut) CALL Finalize_surf_para
-    
+
+    
+! JG : TEMPORAIRE!!!! Les variables fco2_land_comp et fco2_lu_comp seront plus tard en sortie d'ORCHIDEE
+!      ici mis a valeur quelquonque pour test. Ces variables sont sur la grille compresse avec uniquement des points de terres
+
+    fco2_land_comp(:) = 1.
+    fco2_lu_comp(:)   = 10.
+
+! Decompress variables for the module carbon_cycle_mod
+    IF (carbon_cycle_cpl) THEN
+       fco2_land_inst(:)=0.
+       fco2_lu_inst(:)=0.
+       
+       DO igrid = 1, knon
+          ireal = knindex(igrid)
+          fco2_land_inst(ireal) = fco2_land_comp(igrid)
+          fco2_lu_inst(ireal)   = fco2_lu_comp(igrid)
+       END DO
+    END IF
+
   END SUBROUTINE surf_land_orchidee
 !
Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/surf_land_orchidee_noopenmp_mod.F90
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/surf_land_orchidee_noopenmp_mod.F90	(revision 1226)
+++ LMDZ4/branches/LMDZ4-dev/libf/phylmd/surf_land_orchidee_noopenmp_mod.F90	(revision 1227)
@@ -68,5 +68,6 @@
 !   spechum      humidite specifique 1ere couche
 !   epot_air     temp pot de l'air
-!   ccanopy      concentration CO2 canopee
+!   ccanopy      concentration CO2 canopee, correspond au co2_send de 
+!                carbon_cycle_mod ou valeur constant co2_ppm
 !   tq_cdrag     cdrag
 !   petAcoef     coeff. A de la resolution de la CL pour t
@@ -95,4 +96,7 @@
 !   qsurf        air moisture at surface
 !
+    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, fco2_land_inst, fco2_lu_inst
+    IMPLICIT NONE
+
     INCLUDE "indicesol.h"
     INCLUDE "temps.h"
@@ -135,4 +139,6 @@
     INTEGER                                   :: error
     REAL, DIMENSION(klon)                     :: swdown_vrai
+    REAL, DIMENSION(klon)                     :: fco2_land_comp  ! sur grille compresse
+    REAL, DIMENSION(klon)                     :: fco2_lu_comp    ! sur grille compresse
     CHARACTER (len = 20)                      :: modname = 'surf_land_orchidee'
     CHARACTER (len = 80)                      :: abort_message
@@ -334,4 +340,17 @@
        ENDIF
 
+!
+! Allocate variables needed for carbon_cycle_mod
+!
+       IF (carbon_cycle_cpl) THEN
+          IF (.NOT. ALLOCATED(fco2_land_inst)) THEN
+             ALLOCATE(fco2_land_inst(klon),stat=error)
+             IF (error /= 0)  CALL abort_gcm(modname,'Pb in allocation fco2_land_inst',1)
+             
+             ALLOCATE(fco2_lu_inst(klon),stat=error)
+             IF(error /=0) CALL abort_gcm(modname,'Pb in allocation fco2_lu_inst',1)
+          END IF
+       END IF
+
     ENDIF                          ! (fin debut) 
 
@@ -378,8 +397,4 @@
 
 #ifndef CPP_MPI
-#define ORC_PREPAR
-#endif
-
-#ifdef ORC_PREPAR
           ! Interface for ORCHIDEE compiled in sequential mode(without preprocessing flag CPP_MPI)
           CALL intersurf_main (itime+itau_phy-1, iim, jjm+1, knon, ktindex, dtime, &
@@ -394,5 +409,5 @@
 
 #else          
-          ! Interface for ORCHIDEE version 1.9 or later compiled in parallel mode(with preprocessing flag CPP_MPI)
+          ! Interface for ORCHIDEE version 1.9 or later(1.9.2, 1.9.3, 1.9.4) compiled in parallel mode(with preprocessing flag CPP_MPI)
           CALL intersurf_main (itime+itau_phy-1, iim, jjm+1, offset, knon, ktindex, & 
                orch_comm, dtime, lrestart_read, lrestart_write, lalo, &
@@ -417,5 +432,5 @@
     IF (knon /=0) THEN
     
-#ifdef ORC_PREPAR
+#ifndef CPP_MPI
        ! Interface for ORCHIDEE compiled in sequential mode(without preprocessing flag CPP_MPI)
        CALL intersurf_main (itime+itau_phy, iim, jjm+1, knon, ktindex, dtime, &
@@ -463,4 +478,24 @@
 
     IF (debut) lrestart_read = .FALSE.
+
+
+! JG : TEMPORAIRE!!!! Les variables fco2_land_comp et fco2_lu_comp seront plus tard en sortie d'ORCHIDEE
+!      ici mis a valeur quelquonque pour test. Ces variables sont sur la grille compresse avec uniquement des points de terres
+
+    fco2_land_comp(:) = 1.
+    fco2_lu_comp(:)   = 10.
+
+! Decompress variables for the module carbon_cycle_mod
+    IF (carbon_cycle_cpl) THEN
+       fco2_land_inst(:)=0.
+       fco2_lu_inst(:)=0.
+       
+       DO igrid = 1, knon
+          ireal = knindex(igrid)
+          fco2_land_inst(ireal) = fco2_land_comp(igrid)
+          fco2_lu_inst(ireal)   = fco2_lu_comp(igrid)
+       END DO
+    END IF
+
 #endif    
   END SUBROUTINE surf_land_orchidee
Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/traclmdz_mod.F90
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/traclmdz_mod.F90	(revision 1226)
+++ LMDZ4/branches/LMDZ4-dev/libf/phylmd/traclmdz_mod.F90	(revision 1227)
@@ -65,8 +65,9 @@
 
 
-  SUBROUTINE traclmdz_init(pctsrf, ftsol, aerosol, lessivage)
+  SUBROUTINE traclmdz_init(pctsrf, ftsol, tr_seri, aerosol, lessivage)
     ! This subroutine allocates and initialize module variables and control variables.
     USE dimphy
     USE infotrac
+    USE carbon_cycle_mod, ONLY : carbon_cycle_init, carbon_cycle_tr, carbon_cycle_cpl
 
     IMPLICIT NONE
@@ -75,7 +76,8 @@
 
 ! Input variables
-    REAL,DIMENSION(klon,nbsrf),INTENT(IN) :: pctsrf ! Pourcentage de sol f(nature du sol)
-    REAL,DIMENSION(klon,nbsrf),INTENT(IN) :: ftsol  ! Temperature du sol (surf)(Kelvin)
-    
+    REAL,DIMENSION(klon,nbsrf),INTENT(IN)     :: pctsrf ! Pourcentage de sol f(nature du sol)
+    REAL,DIMENSION(klon,nbsrf),INTENT(IN)     :: ftsol  ! Temperature du sol (surf)(Kelvin)
+    REAL,DIMENSION(klon,klev,nbtr),INTENT(IN) :: tr_seri! Concentration Traceur [U/KgA]  
+
 ! Output variables
     LOGICAL,DIMENSION(nbtr), INTENT(OUT) :: aerosol
@@ -150,4 +152,11 @@
     END IF
 
+!
+! Initialisation de module carbon_cycle_mod
+! ----------------------------------------------
+    IF (carbon_cycle_tr .OR. carbon_cycle_cpl) THEN
+       CALL carbon_cycle_init(tr_seri, aerosol, radio)
+    END IF
+
   END SUBROUTINE traclmdz_init
 
@@ -161,4 +170,5 @@
     USE dimphy
     USE infotrac
+    USE carbon_cycle_mod, ONLY : carbon_cycle, carbon_cycle_tr, carbon_cycle_cpl
     
     IMPLICIT NONE
@@ -199,4 +209,5 @@
     REAL,DIMENSION(klon,nbsrf),INTENT(IN) :: pctsrf ! Pourcentage de sol f(nature du sol)
 
+
 ! InOutput argument
     REAL,DIMENSION(klon,klev,nbtr),INTENT(INOUT)  :: tr_seri ! Concentration Traceur [U/KgA]  
@@ -206,5 +217,4 @@
     REAL,DIMENSION(klon,nbtr), INTENT(OUT)        :: source  ! a voir lorsque le flux de surface est prescrit 
     REAL,DIMENSION(klon,klev,nbtr), INTENT(OUT)   :: d_tr_cl ! Td couche limite/traceur
-
 
 !=======================================================================================
@@ -301,4 +311,11 @@
     END DO
 
+!======================================================================
+!   Calcul de cycle de carbon
+!======================================================================
+    IF (carbon_cycle_tr .OR. carbon_cycle_cpl) THEN
+       CALL carbon_cycle(nstep, pdtphys, pctsrf, tr_seri)
+    END IF
+
   END SUBROUTINE traclmdz
 
