Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/cpl_mod.F90
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/cpl_mod.F90	(revision 1152)
+++ 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"
