Index: /LMDZ6/trunk/libf/phylmd/carbon_cycle_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/carbon_cycle_mod.F90	(revision 3383)
+++ /LMDZ6/trunk/libf/phylmd/carbon_cycle_mod.F90	(revision 3384)
@@ -1,3 +1,13 @@
 MODULE carbon_cycle_mod
+
+!=======================================================================
+!
+!   Authors: Patricia Cadule and Laurent Fairhead
+!            base sur un travail anterieur mene par Patricia Cadule et Josefine
+!            Ghattas
+!   -------
+!
+!  Purpose and description:
+!  -----------------------
 ! Controle module for the carbon CO2 tracers :
 !   - Identification
@@ -6,5 +16,37 @@
 !   - Calculate new carbon flux for sending to coupled models (PISCES and ORCHIDEE)
 !
-! Author : Josefine GHATTAS, Patricia CADULE
+! Module permettant de mettre a jour les champs (puits et sources) pour le transport de CO2 en
+! online (IPSL-CM et LMDZOR) et offline (lecture de carte)
+!   
+! Le cas online/offline est defini par le flag carbon_cycle_cpl (y/n)
+! Le transport du traceur CO2 est defini par le flag carbon_cycle_tr (y/n)
+! la provenance des champs (termes de puits) est denini par le flag  level_coupling_esm
+
+! level_coupling_esm : level of coupling of the biogeochemical fields between
+! LMDZ, ORCHIDEE and NEMO
+! Definitions of level_coupling_esm in physiq.def
+! level_coupling_esm = 0  ! No field exchange between LMDZ and ORCHIDEE models
+!                         ! No field exchange between LMDZ and NEMO
+! level_coupling_esm = 1  ! Field exchange between LMDZ and ORCHIDEE models
+!                         ! No field exchange between LMDZ and NEMO models
+! level_coupling_esm = 2  ! No field exchange between LMDZ and ORCHIDEE models
+!                         ! Field exchange between LMDZ and NEMO models
+! level_coupling_esm = 3  ! Field exchange between LMDZ and ORCHIDEE models
+!                         ! Field exchange between LMDZ and NEMO models
+!
+! si carbon_cycle_cpl=y alors les termes de puits et sources sont mis a jour 
+! en focntion de la valeur de level_coupling_esm
+! dans tous les cas  (si carbon_cycle_cpl=y) les valeurs des emissions anthropiques de CO2 (fossil
+! fuel+cement) sont lues,
+! - soit via des cartes 2D mensuelles (fichiers netcdf contenant 12 valeurs par
+! annee): fCO2_fco2fos
+! - soit via des fichier txt contenant une valeur globale mensuelle/annuelle: fCO2_fco2fos_1D
+!
+! Ce module permet de transport des champs de carbone dans LMDz
+
+! Declaration des differents champs 
+! LAND: fCO2_nep, fCO2_fLuc, fCO2_fFire,
+! OCEAN: fCO2_fgco2
+! FOS:fCO2_fco2fos
 
   IMPLICIT NONE
@@ -18,4 +60,6 @@
   LOGICAL, PUBLIC :: carbon_cycle_cpl       ! Coupling of CO2 fluxes between LMDZ/ORCHIDEE and LMDZ/OCEAN(PISCES) 
 !$OMP THREADPRIVATE(carbon_cycle_cpl)
+  INTEGER, SAVE, PUBLIC :: level_coupling_esm
+!$OMP THREADPRIVATE(level_coupling_esm)
 
   LOGICAL :: carbon_cycle_emis_comp_omp=.FALSE.
@@ -27,8 +71,9 @@
 !$OMP THREADPRIVATE(RCO2_inter)
 
-! Scalare values when no transport, from physiq.def
-  REAL :: fos_fuel_s_omp
-  REAL :: fos_fuel_s  ! carbon_cycle_fos_fuel dans physiq.def
-!$OMP THREADPRIVATE(fos_fuel_s)
+! Scalar values when no transport, from physiq.def
+  REAL :: fCO2_fco2fos_1D_omp
+!$OMP THREADPRIVATE(fCO2_fco2fos_1D_omp)
+  REAL :: fCO2_fco2fos_1D  ! carbon_cycle_fco2fos dans physiq.def
+!$OMP THREADPRIVATE(fCO2_fco2fos_1D)
   REAL :: emis_land_s ! not yet implemented
 !$OMP THREADPRIVATE(emis_land_s)
@@ -37,32 +82,53 @@
 !$OMP THREADPRIVATE(airetot)
 
-  INTEGER :: ntr_co2  ! Number of tracers concerning the carbon cycle
+  INTEGER :: ntr_co2  ! Number of fields concerning the carbon cycle
 !$OMP THREADPRIVATE(ntr_co2)
 
-! fco2_ocn_day : flux CO2 from ocean for 1 day (cumulated) [gC/m2/d]. Allocation and initalization done in cpl_mod
-  REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_ocn_day 
-!$OMP THREADPRIVATE(fco2_ocn_day)
-
-  REAL, DIMENSION(:), ALLOCATABLE :: fco2_land_day   ! flux CO2 from land for 1 day (cumulated)  [gC/m2/d]
-!$OMP THREADPRIVATE(fco2_land_day)
-  REAL, DIMENSION(:), ALLOCATABLE :: fco2_lu_day     ! Emission from land use change for 1 day (cumulated) [gC/m2/d]
-!$OMP THREADPRIVATE(fco2_lu_day)
+! fCO2_fgco2 : carbon flux from ocean cumulated between 2 ATM-OCN coupling timestep [gC/m2/Dt]. 
+! fCO2_fgco2 :  flux de carbone venant de l ocean. Ce flux est cumule entre
+! deux pas de temps du couplage ATM-OCN [gC/m2/Dt]. 
+! Allocation and initalization done in cpl_mod
+
+! OCEAN
+! fkux echange a la frequence de couplage entre NEMO et LMDZ
+  REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fCO2_fgco2 
+!$OMP THREADPRIVATE(fCO2_fgco2)
+
+! LAND
+  REAL, DIMENSION(:), ALLOCATABLE :: fCO2_nbp        ! carbon flux from land at each time step  [kgC/m2/s]
+!$OMP THREADPRIVATE(fCO2_nbp)
+  REAL, DIMENSION(:), ALLOCATABLE :: fCO2_nep        ! carbon flux from land at each time step  [kgC/m2/s]
+!$OMP THREADPRIVATE(fCO2_nep)
+  REAL, DIMENSION(:), ALLOCATABLE :: fCO2_fLuc     ! Emission from land use change  [gC/m2/s]
+!$OMP THREADPRIVATE(fCO2_fLuc)
+  REAL, DIMENSION(:), ALLOCATABLE :: fCO2_fFire
+!$OMP THREADPRIVATE(fCO2_fFire)
+
+! SOURCES: FOSSIL FUEL emissions
+  REAL, DIMENSION(:), ALLOCATABLE :: fCO2_fco2fos 
+!$OMP THREADPRIVATE(fCO2_fco2fos)
 
   REAL, DIMENSION(:,:), ALLOCATABLE :: dtr_add       ! Tracer concentration to be injected 
 !$OMP THREADPRIVATE(dtr_add)
-
-! Following 2 fields will be allocated and initialized in surf_land_orchidee
-  REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_land_inst  ! flux CO2 from land at one time step
-!$OMP THREADPRIVATE(fco2_land_inst)
-  REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_lu_inst    ! Emission from land use change at one time step
-!$OMP THREADPRIVATE(fco2_lu_inst)
-
-! Calculated co2 field to be send to the ocean via the coupler and to ORCHIDEE 
+  REAL, DIMENSION(:), ALLOCATABLE :: dtr_add_sum       ! Tracer concentration to be injected
+!$OMP THREADPRIVATE(dtr_add_sum)
+
+! Following 4 fields will be allocated and initialized in surf_land_orchidee
+  REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fCO2_nbp_inst  ! flux CO2 from land at one time step
+!$OMP THREADPRIVATE(fCO2_nbp_inst)
+  REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fCO2_nep_inst  ! flux CO2 from land at one time step
+!$OMP THREADPRIVATE(fCO2_nep_inst)
+  REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fCO2_fLuc_inst    ! Emission from land use change at one time step
+!$OMP THREADPRIVATE(fCO2_fLuc_inst)
+  REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fCO2_fFire_inst  ! flux CO2 from land at one time step
+!$OMP THREADPRIVATE(fCO2_fFire_inst)
+
+! Calculated co2 field to be send to the ocean model (NEMO) via the coupler and to the land surface model (ORCHIDEE) 
   REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: co2_send ! Field allocated in phyetat0
 !$OMP THREADPRIVATE(co2_send)
 
 
-  TYPE, PUBLIC ::   co2_trac_type
-     CHARACTER(len = 8) :: name       ! Tracer name in tracer.def
+  TYPE, PUBLIC ::   co2_fields_type
+     CHARACTER(len = 20) :: name       ! Fields 
      INTEGER            :: id         ! Index in total tracer list, tr_seri
      CHARACTER(len=30)  :: file       ! File name
@@ -72,7 +138,24 @@
      INTEGER            :: readstep   ! Actual time step to read in file
      LOGICAL            :: updatenow  ! True if this tracer should be updated this time step
+  END TYPE co2_fields_type
+  INTEGER,PARAMETER :: maxco2fields=5  ! Maximum number of different CO2 fluxes
+  TYPE(co2_fields_type), DIMENSION(maxco2fields) :: co2fields
+!$OMP THREADPRIVATE(co2fields)
+
+
+  TYPE, PUBLIC ::   co2_trac_type
+     CHARACTER(len = 8) :: name       ! Tracer name in tracer.def
+     INTEGER            :: id         ! Index in total tracer list, tr_seri
+     CHARACTER(len=30)  :: file       ! File name
+     LOGICAL            :: cpl        ! True if this tracers is coupled from ORCHIDEE or PISCES.
+                                      ! False if read from file.
+     INTEGER            :: updatefreq ! Frequence to inject in second
+     INTEGER            :: readstep   ! Actual time step to read in file
+     LOGICAL            :: updatenow  ! True if this tracer should be updated this time step
   END TYPE co2_trac_type
   INTEGER,PARAMETER :: maxco2trac=5  ! Maximum number of different CO2 fluxes
   TYPE(co2_trac_type), DIMENSION(maxco2trac) :: co2trac
+
+
 
 CONTAINS
@@ -93,4 +176,5 @@
     USE phys_cal_mod, ONLY : mth_len
     USE print_control_mod, ONLY: lunout
+    USE infocfields_mod
 
     IMPLICIT NONE
@@ -116,10 +200,11 @@
     IF (.NOT. carbon_cycle_tr) THEN
 !$OMP MASTER
-       fos_fuel_s_omp = 0.
-       CALL getin ('carbon_cycle_fos_fuel',fos_fuel_s_omp)
+       fCO2_fco2fos_1D_omp = 0.
+       CALL getin ('carbon_cycle_fco2fos_1D',fCO2_fco2fos_1D_omp)
 !$OMP END MASTER
 !$OMP BARRIER
-       fos_fuel_s=fos_fuel_s_omp
-       WRITE(lunout,*) 'carbon_cycle_fos_fuel = ', fos_fuel_s 
+       fCO2_fco2fos_1D=fCO2_fco2fos_1D_omp
+       CALL bcast(fCO2_fco2fos_1D)
+       WRITE(lunout,*) 'carbon_cycle_fco2fos_1D = ', fCO2_fco2fos_1D
     END IF
 
@@ -153,76 +238,111 @@
 
 
-! 2) Search for carbon tracers and set default values
+! 2) Search for carbon fields and set default values
 ! ---------------------------------------------------
     itc=0
-    DO it=1,nbtr
-!!       iiq=niadv(it+2)                                                            ! jyg
-       iiq=niadv(it+nqo)                                                            ! jyg
-       
-       SELECT CASE(tname(iiq))
-       CASE("fCO2_ocn")
+    DO it=1,nbcf_in  ! bien remplir le fichier pour avoir un champ fos et un champs ocean
+
+!fCO2_nbp, fCO2_nep, fCO2_fLuc, fCO2_fFire, fCO2_fco2fos, fCO2_fgco2       
+
+       SELECT CASE(cfname_in(it))
+       !SELECT CASE(co2fields(it)%name)
+       CASE("fCO2_fgco2")
           itc = itc + 1
-          co2trac(itc)%name='fCO2_ocn'
-          co2trac(itc)%id=it
-          co2trac(itc)%file='fl_co2_ocean.nc'
-          IF (carbon_cycle_cpl .AND. type_ocean=='couple') THEN 
-             co2trac(itc)%cpl=.TRUE.
-             co2trac(itc)%updatefreq = 86400 ! Once a day as the coupling with OASIS/PISCES
+          co2fields(it)%name=TRIM(cfname_in(it))
+          co2fields(it)%id=it
+          co2fields(it)%file='flx_fgco2_ocean.nc'
+          IF (carbon_cycle_cpl .AND. (type_ocean=='couple') .AND. (level_coupling_esm.GE.2))  THEN 
+             WRITE(lunout,*) 'carbon_cycle_mod (ESM) --- fCO2_fgco2'
+             co2fields(it)%cpl=.TRUE.
+! >> PC
+! on va injecter a tous les pas de temps de couplage (2700x2)
+! recuperer proprement la frequence de couplage
+! << PC
+!!!! METTRE la vraie frequence de couplage !!! PAS en dur
+             co2fields(it)%updatefreq = 5400 !  OASIS/NEMO-PISCES
+! << PC
+          ELSE IF (carbon_cycle_cpl .AND.  (level_coupling_esm.LE.2))  THEN 
+             co2fields(it)%cpl=.FALSE.
+             co2fields(it)%updatefreq = 86400*mth_len ! Once a month
+          END IF
+       CASE("fCO2_nbp")
+          itc = itc + 1
+          co2fields(it)%name=TRIM(cfname_in(it))
+          co2fields(it)%id=it
+          co2fields(it)%file='flx_nbp_land.nc'
+          IF (carbon_cycle_cpl .AND. ((level_coupling_esm.EQ.1) .OR. level_coupling_esm.EQ.3)) THEN
+             WRITE(lunout,*) 'carbon_cycle_mod (ESM) --- fCO2_nbp'
+             co2fields(it)%cpl=.TRUE.
+             co2fields(it)%updatefreq = INT(pdtphys) ! Each timestep as the coupling with ORCHIDEE
+          ELSE IF (carbon_cycle_cpl .AND. ((level_coupling_esm.EQ.0) .OR.  level_coupling_esm.EQ.2)) THEN
+             co2fields(it)%cpl=.FALSE.
+!             co2fields(itc)%updatefreq = 10800   ! 10800sec = 3H
+             co2fields(it)%updatefreq = 86400*mth_len ! Once a month
+          END IF
+!!!! Si le test est ok pour nbp dupliquer sur les autres champs LAND
+       CASE("fCO2_nep")
+          itc = itc + 1
+          co2fields(it)%name=TRIM(cfname_in(it))
+          co2fields(it)%id=it
+          co2fields(it)%file='flx_nep_land.nc'
+          IF (carbon_cycle_cpl .AND. ok_veget) THEN 
+             WRITE(lunout,*) 'carbon_cycle_mod (ESM) --- fCO2_nep'
+             co2fields(it)%cpl=.TRUE.
+             co2fields(it)%updatefreq = INT(pdtphys) ! Each timestep as the coupling with ORCHIDEE
           ELSE
-             co2trac(itc)%cpl=.FALSE.
-             co2trac(itc)%updatefreq = 86400*mth_len ! Once a month
+             co2fields(it)%cpl=.FALSE.
+!             co2fields(itc)%updatefreq = 10800   ! 10800sec = 3H
+             co2fields(it)%updatefreq = 86400*mth_len ! Once a month
           END IF
-       CASE("fCO2_land")
+       CASE("fCO2_fLuc")
           itc = itc + 1
-          co2trac(itc)%name='fCO2_land'
-          co2trac(itc)%id=it
-          co2trac(itc)%file='fl_co2_land.nc'
+          co2fields(it)%name=TRIM(cfname_in(it))
+          co2fields(it)%id=it
+          co2fields(it)%file='flx_fLuc_land.nc'
           IF (carbon_cycle_cpl .AND. ok_veget) THEN 
-             co2trac(itc)%cpl=.TRUE.
-             co2trac(itc)%updatefreq = INT(pdtphys) ! Each timestep as the coupling with ORCHIDEE
+             WRITE(lunout,*) 'carbon_cycle_mod (ESM) --- fCO2_nbp'
+             co2fields(it)%cpl=.TRUE.
+             co2fields(it)%updatefreq = INT(pdtphys) ! Each timestep as the coupling with ORCHIDEE
           ELSE
-             co2trac(itc)%cpl=.FALSE.
-!             co2trac(itc)%updatefreq = 10800   ! 10800sec = 3H
-             co2trac(itc)%updatefreq = 86400*mth_len ! Once a month
+             co2fields(it)%cpl=.FALSE.
+             co2fields(it)%updatefreq = 10800   ! 10800sec = 3H
           END IF
-       CASE("fCO2_land_use")
+       CASE("fCO2_fco2fos")
           itc = itc + 1
-          co2trac(itc)%name='fCO2_land_use'
-          co2trac(itc)%id=it
-          co2trac(itc)%file='fl_co2_land_use.nc'
-          IF (carbon_cycle_cpl .AND. ok_veget) THEN 
-             co2trac(it)%cpl=.TRUE.
-             co2trac(itc)%updatefreq = INT(pdtphys) ! Each timestep as the coupling with ORCHIDEE
-          ELSE
-             co2trac(itc)%cpl=.FALSE.
-             co2trac(itc)%updatefreq = 10800   ! 10800sec = 3H
-          END IF
-       CASE("fCO2_fos_fuel")
+          !co2fields(it)%name='fCO2_fco2fos'
+          co2fields(it)%name=TRIM(cfname_in(it))
+          co2fields(it)%id=it
+          co2fields(it)%file='fco2fos.nc' 
+! >> PC
+         IF ( carbon_cycle_cpl .AND. carbon_cycle_tr) THEN 
+          WRITE(lunout,*) 'carbon_cycle_mod (ESM) --- fCO2_fco2fos'
+          co2fields(it)%cpl=.TRUE.
+          co2fields(it)%updatefreq = 86400*mth_len ! Once a month
+         ELSE IF ( carbon_cycle_cpl .AND. (.NOT. carbon_cycle_tr)) THEN 
+          co2fields(it)%cpl=.TRUE.
+          co2fields(it)%updatefreq = 86400*mth_len ! Once a month
+            WRITE(*,*) "lecture du champs scalaire"
+         END IF
+! << PC
+       CASE("fCO2_fFire")
           itc = itc + 1
-          co2trac(itc)%name='fCO2_fos_fuel'
-          co2trac(itc)%id=it
-          co2trac(itc)%file='fossil_fuel.nc'
-          co2trac(itc)%cpl=.FALSE.       ! This tracer always read from file
-!         co2trac(itc)%updatefreq = 86400  ! 86400sec = 24H Cadule case
-          co2trac(itc)%updatefreq = 86400*mth_len ! Once a month
-       CASE("fCO2_bbg")
-          itc = itc + 1
-          co2trac(itc)%name='fCO2_bbg'
-          co2trac(itc)%id=it
-          co2trac(itc)%file='fl_co2_bbg.nc'
-          co2trac(itc)%cpl=.FALSE.       ! This tracer always read from file
-          co2trac(itc)%updatefreq = 86400*mth_len ! Once a month
+          co2fields(it)%name=TRIM(cfname_in(it))
+          co2fields(it)%id=it
+          co2fields(it)%file='flx_fFire_land.nc'
+          co2fields(it)%cpl=.FALSE.       ! This tracer always read from file
+          co2fields(it)%updatefreq = 86400*mth_len ! Once a month
        CASE("fCO2")
           ! fCO2 : One tracer transporting the total CO2 flux
           itc = itc + 1
-          co2trac(itc)%name='fCO2'
-          co2trac(itc)%id=it
-          co2trac(itc)%file='fl_co2.nc'
+          co2fields(it)%name='fCO2'
+          co2fields(it)%id=it
+          co2fields(it)%file='flx_fCO2.nc'
           IF (carbon_cycle_cpl) THEN 
-             co2trac(itc)%cpl=.TRUE.
+             WRITE(lunout,*) 'carbon_cycle_mod (ESM) --- fCO2'
+             co2fields(it)%cpl=.TRUE.
           ELSE
-             co2trac(itc)%cpl=.FALSE.
+             co2fields(it)%cpl=.FALSE.
           END IF
-          co2trac(itc)%updatefreq = 86400
+          co2fields(it)%updatefreq = 86400*mth_len
           ! DOES THIS WORK ???? Problematic due to implementation of the coupled fluxes...
           CALL abort_physic('carbon_cycle_init','transport of total CO2 has to be implemented and tested',1)
@@ -230,7 +350,30 @@
     END DO
 
-    ! Total number of carbon CO2 tracers
-    ntr_co2 = itc 
-    
+    ! CO2 tracer
+
+IF ( carbon_cycle_cpl .AND. carbon_cycle_tr) THEN
+    itc=0
+
+    DO it=1,nbtr
+       iiq=niadv(it+nqo)
+
+       SELECT CASE(tname(iiq))
+       CASE("fCO2")
+          itc = itc + 1
+          co2fields(it)%name='fCO2'
+          IF (carbon_cycle_cpl .AND. type_ocean=='couple') THEN
+             co2fields(it)%cpl=.TRUE.
+          END IF
+        END SELECT
+     END DO
+END IF
+
+!!!!! BIEN FAIRE LA DIFFERENCE ENTRE tracer.def et coupling_fields.def
+! cela conditionne la valeur de ntr_co2 
+!    ntr_co2 = itc 
+
+    ntr_co2=0
+    IF (carbon_cycle_tr .AND. (nbcf .GT. 0)) ntr_co2=1    
+
     ! Definition of control varaiables for the tracers
     DO it=1,ntr_co2
@@ -247,19 +390,35 @@
 ! ---------------------
     ! Allocate vector for storing fluxes to inject
-    ALLOCATE(dtr_add(klon,maxco2trac), stat=ierr)
+!fCO2_nbp, fCO2_nep, fCO2_fLuc, fCO2_fFire, fCO2_fco2fos, fCO2_fgco2
+    ALLOCATE(dtr_add(klon,maxco2fields), stat=ierr)
     IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation 11',1)       
-    
+
+    ALLOCATE(dtr_add_sum(klon), stat=ierr)
+    IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation 12',1)   
+
+ 
     ! Allocate variables for cumulating fluxes from ORCHIDEE
-    IF (RCO2_inter) THEN
-       IF (.NOT. carbon_cycle_tr .AND. carbon_cycle_cpl) THEN
-          ALLOCATE(fco2_land_day(klon), stat=ierr)
+!    IF (RCO2_inter) THEN
+       !IF ((.NOT. carbon_cycle_tr) .AND. carbon_cycle_cpl) THEN
+       IF (carbon_cycle_tr .OR. carbon_cycle_cpl) THEN
+
+          ALLOCATE(fCO2_nbp(klon), stat=ierr)
           IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation 2',1)
-          fco2_land_day(1:klon) = 0.
+          fCO2_nbp(1:klon) = 0.
+
+          ALLOCATE(fCO2_nep(klon), stat=ierr)
+          IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation 2',1)
+          fCO2_nep(1:klon) = 0.
           
-          ALLOCATE(fco2_lu_day(klon), stat=ierr)
+          ALLOCATE(fCO2_fLuc(klon), stat=ierr)
           IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation 3',1)
-          fco2_lu_day(1:klon)   = 0.
+          fCO2_fLuc(1:klon)   = 0.
+
+          ALLOCATE(fCO2_fFire(klon), stat=ierr)
+          IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation 2',1)
+          fCO2_fFire(1:klon) = 0.
+
        END IF
-    END IF
+!    END IF
 
 
@@ -282,7 +441,10 @@
     END DO
 
-    IF (ntr_co2==0) THEN
+
+    IF (ntr_co2==0 .AND. carbon_cycle_tr) THEN
        ! No carbon tracers found in tracer.def. It is not possible to do carbon cycle 
-       WRITE(lunout,*) 'No carbon tracers found in tracer.def. Not ok with carbon_cycle_tr and/or carbon_cycle_cp'
+! >> PC
+       WRITE(lunout,*) 'No carbon tracers found in tracer.def. Not ok with carbon_cycle_tr and/or carbon_cycle_cpl'
+! << PC
        CALL abort_physic('carbon_cycle_init', 'No carbon tracers found in tracer.def',1)
     END IF
@@ -312,4 +474,10 @@
     USE print_control_mod, ONLY: lunout
     USE geometry_mod, ONLY : cell_area
+    USE infocfields_mod
+
+! >> PC
+! ne pas le mettre en argument de la subrourine
+!    USE time_phylmdz_mod, ONLY: pdtphys
+! << PC
 
     IMPLICIT NONE
@@ -326,10 +494,15 @@
 
 ! Local variables
-    INTEGER :: it
+    INTEGER :: it,itc
+! >> PC
+    LOGICAL :: newyear ! indicates if a new month just started
+! << PC
     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
+! >> PC
+    REAL, PARAMETER :: fact=1.0e06  * 28.97/44.011  ! transformation factor kg CO2/kg air => ppm
+! << PC
     REAL, DIMENSION(klon) :: fco2_tmp
     REAL :: sumtmp
@@ -340,57 +513,99 @@
 ! -------------------------------------------------------------------------------------------------------
 
-    newday = .FALSE.; endday = .FALSE.; newmonth = .FALSE.
+! >> PC 
+! Mise a jour mensuelle des emissions fossiles 
+    !newday = .FALSE.; endday = .FALSE.; newmonth = .FALSE.
+    newday = .FALSE.; endday = .FALSE.; newmonth = .FALSE. ; newyear = .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.
+! mettre la duree de l annee au propre len_year ???
+    IF (newday .AND. (MOD(nstep,INT(86400.*365/pdtphys))==1)) newyear=.TRUE.
+! << PC
 
 ! 2)  For each carbon tracer find out if it is time to inject (update)
 ! --------------------------------------------------------------------
-    DO it = 1, ntr_co2
-       IF ( MOD(nstep,INT(co2trac(it)%updatefreq/pdtphys)) == 1 ) THEN
-          co2trac(it)%updatenow = .TRUE.
+    !DO it = 1, nbcf_in+2 
+    DO it = 1, nbcf_in
+       WRITE(lunout,*) 'nstep ',nstep
+       WRITE(lunout,*) 'co2fields(it)%updatefreq ',co2fields(it)%name,' ', co2fields(it)%updatefreq
+       WRITE(lunout,*) 'co2fields(it)%name ',co2fields(it)%name
+       WRITE(lunout,*) 'INT(pdtphys) ',INT(pdtphys)
+       WRITE(lunout,*) '(INT(co2fields(it)%updatefreq)/INT(pdtphys))', (INT(co2fields(it)%updatefreq)/INT(pdtphys))
+       WRITE(lunout,*) 'MOD(nstep,(INT(co2fields(it)%updatefreq)/INT(pdtphys))) ',MOD(nstep,(INT(co2fields(it)%updatefreq)/INT(pdtphys)))
+       IF ( MOD(nstep,(INT(co2fields(it)%updatefreq)/INT(pdtphys))) == 0 ) THEN
+         co2fields(it)%updatenow = .TRUE.
        ELSE
-          co2trac(it)%updatenow = .FALSE.
+         co2fields(it)%updatenow = .FALSE.
        END IF
+       WRITE(lunout,*) 'co2fields(it)%updatenow ',co2fields(it)%updatenow
     END DO
 
 ! 3) Get tracer update
 ! --------------------------------------
-    DO it = 1, ntr_co2
-       IF ( co2trac(it)%updatenow ) THEN
-          IF ( co2trac(it)%cpl ) THEN
+! >> PC
+       IF (newyear) THEN
+         co2fields(:)%readstep = 0
+       END IF
+! << PC
+
+    DO it = 1, nbcf_in 
+       IF ( co2fields(it)%updatenow ) THEN
+          IF ( co2fields(it)%cpl ) THEN
              ! Get tracer from coupled model
-             SELECT CASE(co2trac(it)%name)
-             CASE('fCO2_land')     ! from ORCHIDEE
-                dtr_add(:,it) = fco2_land_inst(:)*pctsrf(:,is_ter)*fact ! [ppm/m2/day]
-             CASE('fCO2_land_use') ! from ORCHIDEE
-                dtr_add(:,it) = fco2_lu_inst(:)  *pctsrf(:,is_ter)*fact ! [ppm/m2/day]
-             CASE('fCO2_ocn')      ! from PISCES
-                dtr_add(:,it) = fco2_ocn_day(:)  *pctsrf(:,is_oce)*fact ! [ppm/m2/day]
+             SELECT CASE(TRIM(co2fields(it)%name))
+             CASE('fCO2_nbp')     ! from ORCHIDEE
+                dtr_add(:,it) = fCO2_nbp_inst(:)*pctsrf(:,is_ter)*((co2fields(it)%updatefreq)/INT(pdtphys))*fact !  [ppm/m2/s]
+             CASE('fCO2_nep')     ! from ORCHIDEE
+                dtr_add(:,it) = fCO2_nep_inst(:)*pctsrf(:,is_ter)*((co2fields(it)%updatefreq)/INT(pdtphys))*fact ! [ppm/m2/s]
+             CASE('fCO2_fLuc') ! from ORCHIDEE
+                dtr_add(:,it) = fCO2_fLuc_inst(:)  *pctsrf(:,is_ter)*((co2fields(it)%updatefreq)/INT(pdtphys))*fact ! [ppm/m2/s]
+             CASE('fCO2_fFire')     ! from ORCHIDEE
+                dtr_add(:,it) = fCO2_fFire_inst(:)*pctsrf(:,is_ter)*((co2fields(it)%updatefreq)/INT(pdtphys))*fact !  [ppm/m2/s]
+             CASE('fCO2_fgco2')      ! from PISCES
+                dtr_add(:,it) = fCO2_fgco2(:)  *pctsrf(:,is_oce)*((co2fields(it)%updatefreq)/INT(pdtphys))*fact ! [ppm/m2/s]
+! >> PC
+             CASE("fCO2_fco2fos")
+               WRITE(lunout,*) 'carbon cycle --- fossil fuel emissions'
+                 IF (newmonth) THEN
+                   co2fields(it)%readstep = co2fields(it)%readstep + 1
+! ne pas faire la lecture du fichier a chaque pas de temps
+                   CALL read_map2D(co2fields(it)%file,'CO2_em_anthro',co2fields(it)%readstep,.TRUE.,source(1:klon,co2fields(it)%id))
+                   dtr_add(:,it) = source(1:klon,co2fields(it)%id)*pctsrf(:,is_ter)*(co2fields(it)%updatefreq/INT(pdtphys))*fact ! [ppm/m2/s]
+                 END IF
+! << PC             
              CASE DEFAULT
-                WRITE(lunout,*) 'Error with tracer ',co2trac(it)%name
+                WRITE(lunout,*) 'Error with field ',co2fields(it)%name
                 CALL abort_physic('carbon_cycle', 'No coupling implemented for this tracer',1)
              END SELECT
           ELSE
              ! Read tracer from file
-             co2trac(it)%readstep = co2trac(it)%readstep + 1 ! increment time step in file
-! Patricia   CALL read_map2D(co2trac(it)%file,'fco2',co2trac(it)%readstep,.FALSE.,dtr_add(:,it))
-             CALL read_map2D(co2trac(it)%file,'fco2',co2trac(it)%readstep,.TRUE.,dtr_add(:,it))
-
-             ! Converte from kgC/m2/h to kgC/m2/s
-             dtr_add(:,it) = dtr_add(:,it)/3600
+             co2fields(it)%readstep = co2fields(it)%readstep + 1 ! increment time step in file
+! Patricia   CALL read_map2D(co2fields(it)%file,'fco2',co2fields(it)%readstep,.FALSE.,dtr_add(:,it))
+             CALL read_map2D(co2fields(it)%file,'fco2',co2fields(it)%readstep,.TRUE.,dtr_add(:,it))
+
+! >> PC
+             !! Converte from kgC/m2/h to kgC/m2/s
+             !dtr_add(:,it) = dtr_add(:,it)/3600
+! << PC
              ! Add individual treatment of values read from file
-             SELECT CASE(co2trac(it)%name)
-             CASE('fCO2_land')
+             SELECT CASE(co2fields(it)%name)
+             CASE('fCO2_nbp')
                 dtr_add(:,it) = dtr_add(:,it) *pctsrf(:,is_ter)
-             CASE('fCO2_land_use')
+             CASE('fCO2_nep')
                 dtr_add(:,it) = dtr_add(:,it) *pctsrf(:,is_ter)
-             CASE('fCO2_ocn')
+             CASE('fCO2_fLuc')
+                dtr_add(:,it) = dtr_add(:,it) *pctsrf(:,is_ter)
+             CASE('fCO2_fFire')
+                dtr_add(:,it) = dtr_add(:,it) *pctsrf(:,is_ter)
+             CASE('fCO2_fgco2')
                 dtr_add(:,it) = dtr_add(:,it) *pctsrf(:,is_oce)
+             CASE('fCO2_fco2fos')
+                dtr_add(:,it) = dtr_add(:,it) *pctsrf(:,is_ter)
 ! Patricia :
 !             CASE('fCO2_fos_fuel')
 !                dtr_add(:,it) = dtr_add(:,it)/mth_len
-!                co2trac(it)%readstep = 0 ! Always read same value for fossil fuel(Cadule case)
+!                co2fields(it)%readstep = 0 ! Always read same value for fossil fuel(Cadule case)
              END SELECT
           END IF
@@ -402,11 +617,12 @@
 ! ------------------------------------------------------------------
     IF (carbon_cycle_tr) THEN
+ 
+      dtr_add_sum(1:klon)=0.
+      DO it=1,nbcf_in
+         dtr_add_sum(1:klon)=dtr_add_sum(1:klon)+dtr_add(1:klon,it)
+      END DO
+ 
        DO it = 1, ntr_co2
-          IF (.FALSE.) THEN
-             tr_seri(1:klon,1,co2trac(it)%id) = tr_seri(1:klon,1,co2trac(it)%id) + dtr_add(1:klon,it)
-             source(1:klon,co2trac(it)%id) = 0.
-          ELSE
-             source(1:klon,co2trac(it)%id) = dtr_add(1:klon,it)
-          END IF
+                 tr_seri(1:klon,1,co2trac(it)%id) = tr_seri(1:klon,1,co2trac(it)%id) + dtr_add_sum(1:klon)
        END DO
     END IF
@@ -415,20 +631,28 @@
 ! 5) Calculations for new CO2 value for the radiation scheme(instead of reading value from .def)
 ! ----------------------------------------------------------------------------------------------
-    IF (RCO2_inter) THEN
-       ! Cumulate fluxes from ORCHIDEE at each timestep
-       IF (.NOT. carbon_cycle_tr .AND. carbon_cycle_cpl) THEN
-          IF (newday) THEN ! Reset cumulative variables once a day 
-             fco2_land_day(1:klon) = 0.
-             fco2_lu_day(1:klon)   = 0.
-          END IF
-          fco2_land_day(1:klon) = fco2_land_day(1:klon) + fco2_land_inst(1:klon) ![gC/m2/day]
-          fco2_lu_day(1:klon)   = fco2_lu_day(1:klon)   + fco2_lu_inst(1:klon)   ![gC/m2/day]
-       END IF
-
-       ! At the end of a new day, calculate a mean scalare value of CO2
-       ! JG : Ici on utilise uniquement le traceur du premier couche du modele. Est-ce que c'est correcte ? 
-       IF (endday) THEN
+    !IF (RCO2_inter) THEN
+! >> PC
+!       IF (.NOT. carbon_cycle_tr .AND. carbon_cycle_cpl) THEN
+!!          IF (newday) THEN ! Reset cumulative variables once a day 
+!!             fCO2_nep(1:klon) = 0.
+!!             fCO2_fLuc(1:klon)   = 0.
+!!          END IF
+!! >> PC
+!          fCO2_nep(1:klon) =  fCO2_nep_inst(1:klon) ![gC/m2/s]
+!          fCO2_fLuc(1:klon)   =  fCO2_fLuc_inst(1:klon)   ![gC/m2/s]
+!       END IF
+!! << PC
+
+! >> PC
+    !   IF (endday) THEN
+! << PC
+
+! >> PC
+! modifier le test (carbon_cycle_tr) ligne 492 pour prendre en compte que les cas
+! ou carbon_cycle_cpl = 1 ou 2 .AND. carbon_cycle_tr=y
+! bien declarer la variable fco2_tmp (pour un seul traceur)
 
           IF (carbon_cycle_tr) THEN
+          WRITE(lunout,*) 'fco2_tmp --- carbon_cycle_tr case'
              ! Sum all co2 tracers to get the total delta CO2 flux
              fco2_tmp(:) = 0.
@@ -436,46 +660,86 @@
                 fco2_tmp(1:klon) = fco2_tmp(1:klon) + tr_seri(1:klon,1,co2trac(it)%id)
              END DO
-             
-          ELSE IF (carbon_cycle_cpl) THEN ! no carbon_cycle_tr
+! << PC             
+          ELSE IF (carbon_cycle_cpl .AND. (.NOT. carbon_cycle_tr)) THEN ! no carbon_cycle_tr
+          WRITE(lunout,*) 'fco2_tmp --- carbon_cycle_cpl case'
              ! Sum co2 fluxes comming from coupled models and parameter for fossil fuel
-             fco2_tmp(1:klon) = fos_fuel_s + ((fco2_lu_day(1:klon) + fco2_land_day(1:klon))*pctsrf(1:klon,is_ter) &
-                  + fco2_ocn_day(:)*pctsrf(:,is_oce)) * fact
+! >> PC
+             !fco2_tmp(1:klon) = (fCO2_fco2fos*pctsrf(1:klon,is_ter) + (fCO2_fLuc(1:klon) + fCO2_nep(1:klon))*pctsrf(1:klon,is_ter) &
+
+!             fco2_tmp(1:klon) = (fCO2_fco2fos(1:klon)*pctsrf(1:klon,is_ter) + fCO2_nbp(1:klon)*pctsrf(1:klon,is_ter) &
+!                  + fCO2_fgco2(1:klon)*pctsrf(1:klon,is_oce)) * fact
+! fCO2_fco2fos_1D
+             fco2_tmp(:) = 0. 
+             fco2_tmp(:) =  ( fCO2_fco2fos_1D + fCO2_nbp_inst(:)*pctsrf(:,is_ter) + fCO2_fgco2(:)*pctsrf(:,is_oce))/2.12 
+             WRITE(lunout,*) 'fco2_tmp(:) ',fco2_tmp(:)
+! << PC
           END IF
 
           ! Calculate a global mean value of delta CO2 flux
-          fco2_tmp(1:klon) = fco2_tmp(1:klon) * cell_area(1:klon)
+          fco2_tmp(:) = fco2_tmp(:) * cell_area(:)
           CALL reduce_sum(SUM(fco2_tmp),sumtmp)
           CALL bcast(sumtmp)
           delta_co2_ppm = sumtmp/airetot
+          WRITE(lunout,*) 'delta_co2_ppm: ',delta_co2_ppm
           
           ! Add initial value for co2_ppm and delta value
+           WRITE(lunout,*)'carbon_cycle_mod --- co2_ppm0 ',co2_ppm0
           co2_ppm = co2_ppm0 + delta_co2_ppm
-          
+          CALL bcast(co2_ppm)
+          WRITE(lunout,*)'carbon_cycle_mod --- co2_ppm ',co2_ppm
+IF (RCO2_inter) THEN          
           ! Transformation of atmospheric CO2 concentration for the radiation code
           RCO2 = co2_ppm * 1.0e-06  * 44.011/28.97 
           
-          WRITE(lunout,*) 'RCO2 is now updated! RCO2 = ', RCO2
-       END IF ! endday
-
-    END IF ! RCO2_inter
+          WRITE(lunout,*) 'RCO2 is now updated (in carbon_cycle_mod) ! RCO2 = ', RCO2
+
+! >> PC
+    !   END IF ! endday
+! << PC
+
+END IF ! RCO2_inter
 
 
 ! 6) Calculate CO2 flux to send to ocean and land models : PISCES and ORCHIDEE         
 ! ----------------------------------------------------------------------------
-    IF (carbon_cycle_cpl) THEN
-
-       IF (carbon_cycle_tr) THEN
-          ! Sum all co2 tracers to get the total delta CO2 flux at first model layer
-          fco2_tmp(:) = 0.
+!    IF (carbon_cycle_cpl) THEN
+!
+!       IF (carbon_cycle_tr) THEN
+!          ! Sum all co2 tracers to get the total delta CO2 flux at first model layer
+!          fco2_tmp(:) = 0.
+!          DO it = 1, ntr_co2
+!             fco2_tmp(1:klon) = fco2_tmp(1:klon) + tr_seri(1:klon,1,co2fields(it)%id)          
+!          END DO
+!          co2_send(1:klon) = fco2_tmp(1:klon) + co2_ppm0
+!       ELSE
+!          ! Send a scalare value in 2D variable to ocean and land model (PISCES and ORCHIDEE)
+!          co2_send(1:klon) = co2_ppm
+!       END IF
+!
+!    END IF
+
+
+! << PC
+! co2_ppm0 au premier pas de temps
+! prendre le co2 du restart
+
+       IF (carbon_cycle_cpl .AND. carbon_cycle_tr) THEN
+          ! Sum all co2 tracers to get the total delta CO2 flux at first model
+          ! layer
+          !fco2_tmp(:) = 0.
           DO it = 1, ntr_co2
-             fco2_tmp(1:klon) = fco2_tmp(1:klon) + tr_seri(1:klon,1,co2trac(it)%id)
+             fco2_tmp(1:klon) = fco2_tmp(1:klon) + tr_seri(1:klon,1,co2fields(it)%id)
           END DO
           co2_send(1:klon) = fco2_tmp(1:klon) + co2_ppm0
+       ELSE IF (carbon_cycle_cpl .AND. (.NOT. carbon_cycle_tr)) THEN
+          WRITE(lunout,*) 'carbon_cycle_mod --- co2_send(1:klon)', co2_send(1:klon)
+          co2_send(1:klon) = co2_ppm 
        ELSE
-          ! Send a scalare value in 2D variable to ocean and land model (PISCES and ORCHIDEE)
+          ! Send a scalare value in 2D variable to ocean and land model (PISCES
+          ! and ORCHIDEE)
           co2_send(1:klon) = co2_ppm
        END IF
 
-    END IF
+
 
   END SUBROUTINE carbon_cycle
Index: /LMDZ6/trunk/libf/phylmd/conf_phys_m.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/conf_phys_m.F90	(revision 3383)
+++ /LMDZ6/trunk/libf/phylmd/conf_phys_m.F90	(revision 3384)
@@ -26,22 +26,20 @@
     USE surface_data
     USE phys_cal_mod
-    USE carbon_cycle_mod,  ONLY: carbon_cycle_tr, carbon_cycle_cpl
+    USE carbon_cycle_mod,  ONLY: carbon_cycle_tr, carbon_cycle_cpl, level_coupling_esm
     USE mod_grid_phy_lmdz, ONLY: klon_glo
     USE print_control_mod, ONLY: lunout
 
-    include "conema3.h"
-    include "fisrtilp.h"
-    include "nuage.h"
-    include "YOMCST.h"
-    include "YOMCST2.h"
-
-    include "thermcell.h"
-
+    INCLUDE "conema3.h"
+    INCLUDE "fisrtilp.h"
+    INCLUDE "nuage.h"
+    INCLUDE "YOMCST.h"
+    INCLUDE "YOMCST2.h"
+    INCLUDE "thermcell.h"
 
     !IM : on inclut/initialise les taux de CH4, N2O, CFC11 et CFC12
-    include "clesphys.h"
-    include "compbl.h"
-    include "comsoil.h"
-    include "YOEGWD.h"
+    INCLUDE "clesphys.h"
+    INCLUDE "compbl.h"
+    INCLUDE "comsoil.h"
+    INCLUDE "YOEGWD.h"
     !
     ! Configuration de la "physique" de LMDZ a l'aide de la fonction
@@ -49,6 +47,4 @@
     !
     ! LF 05/2001
-    !
-
     !
     ! type_ocean:      type d'ocean (force, slab, couple)
@@ -67,5 +63,4 @@
     ! bl95_b*: parameters in the formula to link CDNC to aerosol mass conc 
     !
-
 
     ! Sortie:
@@ -108,5 +103,4 @@
     REAL,SAVE           :: tau_cld_cv_omp, coefw_cld_cv_omp
     INTEGER, SAVE       :: iflag_cld_cv_omp
-
 
     REAL, SAVE          :: ratqshaut_omp
@@ -201,22 +195,22 @@
     INTEGER, SAVE :: levout_histNMC_omp(3)
     LOGICAL, SAVE :: ok_histNMC_omp(3)
-    REAL, SAVE :: freq_outNMC_omp(3), freq_calNMC_omp(3)
+    REAL, SAVE    :: freq_outNMC_omp(3), freq_calNMC_omp(3)
     CHARACTER*4, SAVE :: type_run_omp
-    LOGICAL,SAVE :: ok_cosp_omp, ok_airs_omp
-    LOGICAL,SAVE :: ok_mensuelCOSP_omp,ok_journeCOSP_omp,ok_hfCOSP_omp
-    REAL,SAVE :: lonmin_ins_omp, lonmax_ins_omp, latmin_ins_omp, latmax_ins_omp
-    REAL,SAVE :: ecrit_hf_omp, ecrit_day_omp, ecrit_mth_omp, ecrit_reg_omp
-    REAL,SAVE :: ecrit_ins_omp
-    REAL,SAVE :: ecrit_LES_omp
-    REAL,SAVE :: ecrit_tra_omp
-    REAL,SAVE :: cvl_comp_threshold_omp
-    REAL,SAVE :: cvl_sig2feed_omp
-    REAL,SAVE :: cvl_corr_omp
-    LOGICAL,SAVE :: ok_lic_melt_omp
-    LOGICAL,SAVE :: ok_lic_cond_omp
-    !
-    INTEGER,SAVE  :: iflag_cycle_diurne_omp
-    LOGICAL,SAVE  :: soil_model_omp,new_oliq_omp
-    LOGICAL,SAVE  :: ok_orodr_omp, ok_orolf_omp, ok_limitvrai_omp
+    LOGICAL, SAVE :: ok_cosp_omp, ok_airs_omp
+    LOGICAL, SAVE :: ok_mensuelCOSP_omp,ok_journeCOSP_omp,ok_hfCOSP_omp
+    REAL, SAVE    :: lonmin_ins_omp, lonmax_ins_omp, latmin_ins_omp, latmax_ins_omp
+    REAL, SAVE    :: ecrit_hf_omp, ecrit_day_omp, ecrit_mth_omp, ecrit_reg_omp
+    REAL, SAVE    :: ecrit_ins_omp
+    REAL, SAVE    :: ecrit_LES_omp
+    REAL, SAVE    :: ecrit_tra_omp
+    REAL, SAVE    :: cvl_comp_threshold_omp
+    REAL, SAVE    :: cvl_sig2feed_omp
+    REAL, SAVE    :: cvl_corr_omp
+    LOGICAL, SAVE :: ok_lic_melt_omp
+    LOGICAL, SAVE :: ok_lic_cond_omp
+    !
+    INTEGER, SAVE :: iflag_cycle_diurne_omp
+    LOGICAL, SAVE :: soil_model_omp,new_oliq_omp
+    LOGICAL, SAVE :: ok_orodr_omp, ok_orolf_omp, ok_limitvrai_omp
     INTEGER, SAVE :: nbapp_rad_omp, iflag_con_omp
     INTEGER, SAVE :: nbapp_cv_omp, nbapp_wk_omp
@@ -231,9 +225,10 @@
     REAL, SAVE    :: sso_gkdrag_omp,sso_grahil_omp,sso_grcrit_omp
     REAL, SAVE    :: sso_gfrcri_omp,sso_gkwake_omp,sso_gklift_omp
-    LOGICAL,SAVE  :: ok_qch4_omp
-    LOGICAL,SAVE  :: carbon_cycle_tr_omp
-    LOGICAL,SAVE  :: carbon_cycle_cpl_omp
-    LOGICAL,SAVE  :: adjust_tropopause_omp
-    LOGICAL,SAVE  :: ok_daily_climoz_omp
+    LOGICAL, SAVE :: ok_qch4_omp
+    LOGICAL, SAVE :: carbon_cycle_tr_omp
+    LOGICAL, SAVE :: carbon_cycle_cpl_omp
+    INTEGER, SAVE :: level_coupling_esm_omp
+    LOGICAL, SAVE :: adjust_tropopause_omp
+    LOGICAL, SAVE :: ok_daily_climoz_omp
 
     INTEGER, INTENT(OUT):: read_climoz ! read ozone climatology, OpenMP shared
@@ -2148,4 +2143,19 @@
     carbon_cycle_cpl_omp=.FALSE.
     CALL getin('carbon_cycle_cpl',carbon_cycle_cpl_omp)
+
+    ! >> PC
+    ! level_coupling_esm : level of coupling of the biogeochemical fields between LMDZ, ORCHIDEE and NEMO
+    ! Definitions of level_coupling_esm in physiq.def
+    ! level_coupling_esm = 0  ! No field exchange between LMDZ and ORCHIDEE models
+    !                         ! No field exchange between LMDZ and NEMO
+    ! level_coupling_esm = 1  ! Field exchange between LMDZ and ORCHIDEE models
+    !                         ! No field exchange between LMDZ and NEMO models
+    ! level_coupling_esm = 2  ! No field exchange between LMDZ and ORCHIDEE models
+    !                         ! Field exchange between LMDZ and NEMO models
+    ! level_coupling_esm = 3  ! Field exchange between LMDZ and ORCHIDEE models
+    !                         ! Field exchange between LMDZ and NEMO models
+    level_coupling_esm_omp=0 ! default value
+    CALL getin('level_coupling_esm',level_coupling_esm_omp)
+    ! << PC
 
     !$OMP END MASTER
@@ -2404,4 +2414,5 @@
     carbon_cycle_tr = carbon_cycle_tr_omp
     carbon_cycle_cpl = carbon_cycle_cpl_omp
+    level_coupling_esm = level_coupling_esm_omp
 
     ! Test of coherence between type_ocean and version_ocean
@@ -2511,209 +2522,210 @@
        WRITE(lunout,*)'ifl_pbltree is now changed to zero'
        ifl_pbltree=0
-    END IF
+    ENDIF
 
     !$OMP MASTER
 
-    write(lunout,*)' ##############################################'
-    write(lunout,*)' Configuration des parametres de la physique: '
-    write(lunout,*)' Type ocean = ', type_ocean
-    write(lunout,*)' Version ocean = ', version_ocean
-    write(lunout,*)' Config veget = ', ok_veget,type_veget
-    write(lunout,*)' Snow model SISVAT : ok_snow = ', ok_snow
-    write(lunout,*)' Config xml pour XIOS : ok_all_xml = ', ok_all_xml
-    write(lunout,*)' Sortie journaliere = ', ok_journe
-    write(lunout,*)' Sortie haute frequence = ', ok_hf
-    write(lunout,*)' Sortie mensuelle = ', ok_mensuel
-    write(lunout,*)' Sortie instantanee = ', ok_instan
-    write(lunout,*)' Frequence appel simulateur ISCCP, freq_ISCCP =', freq_ISCCP
-    write(lunout,*)' Frequence appel simulateur ISCCP, ecrit_ISCCP =', ecrit_ISCCP
-    write(lunout,*)' Frequence appel simulateur COSP, freq_COSP =', freq_COSP
-    write(lunout,*)' Frequence appel simulateur AIRS, freq_AIRS =', freq_AIRS
-    write(lunout,*)' Sortie bilan d''energie, ip_ebil_phy =', ip_ebil_phy
-    write(lunout,*)' Excentricite = ',R_ecc
-    write(lunout,*)' Equinoxe = ',R_peri
-    write(lunout,*)' Inclinaison =',R_incl
-    write(lunout,*)' Constante solaire =',solaire
-    write(lunout,*)' ok_suntime_rrtm =',ok_suntime_rrtm
-    write(lunout,*)' co2_ppm =',co2_ppm
-    write(lunout,*)' RCO2_act = ',RCO2_act
-    write(lunout,*)' CH4_ppb =',CH4_ppb,' RCH4_act = ',RCH4_act
-    write(lunout,*)' N2O_ppb =',N2O_ppb,' RN2O_act=  ',RN2O_act
-    write(lunout,*)' CFC11_ppt=',CFC11_ppt,' RCFC11_act=  ',RCFC11_act
-    write(lunout,*)' CFC12_ppt=',CFC12_ppt,' RCFC12_act=  ',RCFC12_act
-    write(lunout,*)' RCO2_per = ',RCO2_per,' RCH4_per = ', RCH4_per
-    write(lunout,*)' RN2O_per = ',RN2O_per,' RCFC11_per = ', RCFC11_per
-    write(lunout,*)' RCFC12_per = ',RCFC12_per
-    write(lunout,*)' cvl_comp_threshold=', cvl_comp_threshold
-    write(lunout,*)' cvl_sig2feed=', cvl_sig2feed
-    write(lunout,*)' cvl_corr=', cvl_corr
-    write(lunout,*)'ok_lic_melt=', ok_lic_melt
-    write(lunout,*)'ok_lic_cond=', ok_lic_cond
-    write(lunout,*)'iflag_cycle_diurne=',iflag_cycle_diurne
-    write(lunout,*)'soil_model=',soil_model
-    write(lunout,*)'new_oliq=',new_oliq
-    write(lunout,*)'ok_orodr=',ok_orodr
-    write(lunout,*)'ok_orolf=',ok_orolf
-    write(lunout,*)'ok_limitvrai=',ok_limitvrai
-    write(lunout,*)'nbapp_rad=',nbapp_rad
-    write(lunout,*)'iflag_con=',iflag_con
-    write(lunout,*)'nbapp_cv=',nbapp_cv
-    write(lunout,*)'nbapp_wk=',nbapp_wk
-    write(lunout,*)'iflag_ener_conserv=',iflag_ener_conserv
-    write(lunout,*)'ok_conserv_q=',ok_conserv_q
-    write(lunout,*)'iflag_fisrtilp_qsat=',iflag_fisrtilp_qsat
-    write(lunout,*)'iflag_bergeron=',iflag_bergeron
-    write(lunout,*)' epmax = ', epmax
-    write(lunout,*)' coef_epmax_cape = ', coef_epmax_cape
-    write(lunout,*)' ok_adj_ema = ', ok_adj_ema
-    write(lunout,*)' iflag_clw = ', iflag_clw
-    write(lunout,*)' cld_lc_lsc = ', cld_lc_lsc
-    write(lunout,*)' cld_lc_con = ', cld_lc_con
-    write(lunout,*)' cld_tau_lsc = ', cld_tau_lsc
-    write(lunout,*)' cld_tau_con = ', cld_tau_con
-    write(lunout,*)' ffallv_lsc = ', ffallv_lsc
-    write(lunout,*)' ffallv_con = ', ffallv_con
-    write(lunout,*)' coef_eva = ', coef_eva
-    write(lunout,*)' reevap_ice = ', reevap_ice
-    write(lunout,*)' iflag_pdf = ', iflag_pdf
-    write(lunout,*)' iflag_cld_th = ', iflag_cld_th
-    write(lunout,*)' iflag_cld_cv = ', iflag_cld_cv
-    write(lunout,*)' tau_cld_cv = ', tau_cld_cv
-    write(lunout,*)' coefw_cld_cv = ', coefw_cld_cv
-    write(lunout,*)' iflag_radia = ', iflag_radia
-    write(lunout,*)' iflag_rrtm = ', iflag_rrtm
-    write(lunout,*)' NSW = ', NSW
-    write(lunout,*)' iflag_albedo = ', iflag_albedo !albedo SB
-    write(lunout,*)' ok_chlorophyll =',ok_chlorophyll ! albedo SB
-    write(lunout,*)' iflag_ratqs = ', iflag_ratqs
-    write(lunout,*)' seuil_inversion = ', seuil_inversion
-    write(lunout,*)' fact_cldcon = ', fact_cldcon
-    write(lunout,*)' facttemps = ', facttemps
-    write(lunout,*)' ok_newmicro = ',ok_newmicro 
-    write(lunout,*)' ratqsbas = ',ratqsbas 
-    write(lunout,*)' ratqshaut = ',ratqshaut 
-    write(lunout,*)' tau_ratqs = ',tau_ratqs 
-    write(lunout,*)' top_height = ',top_height 
-    write(lunout,*)' rad_froid = ',rad_froid
-    write(lunout,*)' rad_chau1 = ',rad_chau1
-    write(lunout,*)' rad_chau2 = ',rad_chau2
-    write(lunout,*)' t_glace_min = ',t_glace_min
-    write(lunout,*)' t_glace_max = ',t_glace_max
-    write(lunout,*)' exposant_glace = ',exposant_glace
-    write(lunout,*)' iflag_t_glace = ',iflag_t_glace
-    write(lunout,*)' iflag_cloudth_vert = ',iflag_cloudth_vert
-    write(lunout,*)' iflag_rain_incloud_vol = ',iflag_rain_incloud_vol
-    write(lunout,*)' iflag_ice_thermo = ',iflag_ice_thermo
-    write(lunout,*)' rei_min = ',rei_min
-    write(lunout,*)' rei_max = ',rei_max
-    write(lunout,*)' overlap = ',overlap 
-    write(lunout,*)' cdmmax = ',cdmmax 
-    write(lunout,*)' cdhmax = ',cdhmax 
-    write(lunout,*)' ksta = ',ksta 
-    write(lunout,*)' ksta_ter = ',ksta_ter 
-    write(lunout,*)' f_ri_cd_min = ',f_ri_cd_min 
-    write(lunout,*)' ok_kzmin = ',ok_kzmin 
-    write(lunout,*)' pbl_lmixmin_alpha = ',pbl_lmixmin_alpha
-    write(lunout,*)' fmagic = ',fmagic
-    write(lunout,*)' pmagic = ',pmagic
-    write(lunout,*)' ok_ade = ',ok_ade
-    write(lunout,*)' ok_aie = ',ok_aie
-    write(lunout,*)' ok_alw = ',ok_alw
-    write(lunout,*)' aerosol_couple = ', aerosol_couple
-    write(lunout,*)' chemistry_couple = ', chemistry_couple
-    write(lunout,*)' flag_aerosol = ', flag_aerosol
-    write(lunout,*)' flag_aerosol_strat= ', flag_aerosol_strat
-    write(lunout,*)' new_aod = ', new_aod
-    write(lunout,*)' aer_type = ',aer_type
-    write(lunout,*)' bl95_b0 = ',bl95_b0
-    write(lunout,*)' bl95_b1 = ',bl95_b1
-    write(lunout,*)' lev_histhf = ',lev_histhf 
-    write(lunout,*)' lev_histday = ',lev_histday 
-    write(lunout,*)' lev_histmth = ',lev_histmth 
-    write(lunout,*)' lev_histins = ',lev_histins
-    write(lunout,*)' lev_histLES = ',lev_histLES
-    write(lunout,*)' lev_histdayNMC = ',lev_histdayNMC
-    write(lunout,*)' levout_histNMC = ',levout_histNMC
-    write(lunout,*)' ok_histNMC = ',ok_histNMC
-    write(lunout,*)' freq_outNMC = ',freq_outNMC
-    write(lunout,*)' freq_calNMC = ',freq_calNMC
-    write(lunout,*)' iflag_pbl = ', iflag_pbl
+    WRITE(lunout,*) ' ##############################################'
+    WRITE(lunout,*) ' Configuration des parametres de la physique: '
+    WRITE(lunout,*) ' Type ocean = ', type_ocean
+    WRITE(lunout,*) ' Version ocean = ', version_ocean
+    WRITE(lunout,*) ' Config veget = ', ok_veget,type_veget
+    WRITE(lunout,*) ' Snow model SISVAT : ok_snow = ', ok_snow
+    WRITE(lunout,*) ' Config xml pour XIOS : ok_all_xml = ', ok_all_xml
+    WRITE(lunout,*) ' Sortie journaliere = ', ok_journe
+    WRITE(lunout,*) ' Sortie haute frequence = ', ok_hf
+    WRITE(lunout,*) ' Sortie mensuelle = ', ok_mensuel
+    WRITE(lunout,*) ' Sortie instantanee = ', ok_instan
+    WRITE(lunout,*) ' Frequence appel simulateur ISCCP, freq_ISCCP =', freq_ISCCP
+    WRITE(lunout,*) ' Frequence appel simulateur ISCCP, ecrit_ISCCP =', ecrit_ISCCP
+    WRITE(lunout,*) ' Frequence appel simulateur COSP, freq_COSP =', freq_COSP
+    WRITE(lunout,*) ' Frequence appel simulateur AIRS, freq_AIRS =', freq_AIRS
+    WRITE(lunout,*) ' Sortie bilan d''energie, ip_ebil_phy =', ip_ebil_phy
+    WRITE(lunout,*) ' Excentricite = ',R_ecc
+    WRITE(lunout,*) ' Equinoxe = ',R_peri
+    WRITE(lunout,*) ' Inclinaison =',R_incl
+    WRITE(lunout,*) ' Constante solaire =',solaire
+    WRITE(lunout,*) ' ok_suntime_rrtm =',ok_suntime_rrtm
+    WRITE(lunout,*) ' co2_ppm =',co2_ppm
+    WRITE(lunout,*) ' RCO2_act = ',RCO2_act
+    WRITE(lunout,*) ' CH4_ppb =',CH4_ppb,' RCH4_act = ',RCH4_act
+    WRITE(lunout,*) ' N2O_ppb =',N2O_ppb,' RN2O_act=  ',RN2O_act
+    WRITE(lunout,*) ' CFC11_ppt=',CFC11_ppt,' RCFC11_act=  ',RCFC11_act
+    WRITE(lunout,*) ' CFC12_ppt=',CFC12_ppt,' RCFC12_act=  ',RCFC12_act
+    WRITE(lunout,*) ' RCO2_per = ',RCO2_per,' RCH4_per = ', RCH4_per
+    WRITE(lunout,*) ' RN2O_per = ',RN2O_per,' RCFC11_per = ', RCFC11_per
+    WRITE(lunout,*) ' RCFC12_per = ',RCFC12_per
+    WRITE(lunout,*) ' cvl_comp_threshold=', cvl_comp_threshold
+    WRITE(lunout,*) ' cvl_sig2feed=', cvl_sig2feed
+    WRITE(lunout,*) ' cvl_corr=', cvl_corr
+    WRITE(lunout,*) ' ok_lic_melt=', ok_lic_melt
+    WRITE(lunout,*) ' ok_lic_cond=', ok_lic_cond
+    WRITE(lunout,*) ' iflag_cycle_diurne=',iflag_cycle_diurne
+    WRITE(lunout,*) ' soil_model=',soil_model
+    WRITE(lunout,*) ' new_oliq=',new_oliq
+    WRITE(lunout,*) ' ok_orodr=',ok_orodr
+    WRITE(lunout,*) ' ok_orolf=',ok_orolf
+    WRITE(lunout,*) ' ok_limitvrai=',ok_limitvrai
+    WRITE(lunout,*) ' nbapp_rad=',nbapp_rad
+    WRITE(lunout,*) ' iflag_con=',iflag_con
+    WRITE(lunout,*) ' nbapp_cv=',nbapp_cv
+    WRITE(lunout,*) ' nbapp_wk=',nbapp_wk
+    WRITE(lunout,*) ' iflag_ener_conserv=',iflag_ener_conserv
+    WRITE(lunout,*) ' ok_conserv_q=',ok_conserv_q
+    WRITE(lunout,*) ' iflag_fisrtilp_qsat=',iflag_fisrtilp_qsat
+    WRITE(lunout,*) ' iflag_bergeron=',iflag_bergeron
+    WRITE(lunout,*) ' epmax = ', epmax
+    WRITE(lunout,*) ' coef_epmax_cape = ', coef_epmax_cape
+    WRITE(lunout,*) ' ok_adj_ema = ', ok_adj_ema
+    WRITE(lunout,*) ' iflag_clw = ', iflag_clw
+    WRITE(lunout,*) ' cld_lc_lsc = ', cld_lc_lsc
+    WRITE(lunout,*) ' cld_lc_con = ', cld_lc_con
+    WRITE(lunout,*) ' cld_tau_lsc = ', cld_tau_lsc
+    WRITE(lunout,*) ' cld_tau_con = ', cld_tau_con
+    WRITE(lunout,*) ' ffallv_lsc = ', ffallv_lsc
+    WRITE(lunout,*) ' ffallv_con = ', ffallv_con
+    WRITE(lunout,*) ' coef_eva = ', coef_eva
+    WRITE(lunout,*) ' reevap_ice = ', reevap_ice
+    WRITE(lunout,*) ' iflag_pdf = ', iflag_pdf
+    WRITE(lunout,*) ' iflag_cld_th = ', iflag_cld_th
+    WRITE(lunout,*) ' iflag_cld_cv = ', iflag_cld_cv
+    WRITE(lunout,*) ' tau_cld_cv = ', tau_cld_cv
+    WRITE(lunout,*) ' coefw_cld_cv = ', coefw_cld_cv
+    WRITE(lunout,*) ' iflag_radia = ', iflag_radia
+    WRITE(lunout,*) ' iflag_rrtm = ', iflag_rrtm
+    WRITE(lunout,*) ' NSW = ', NSW
+    WRITE(lunout,*) ' iflag_albedo = ', iflag_albedo !albedo SB
+    WRITE(lunout,*) ' ok_chlorophyll =',ok_chlorophyll ! albedo SB
+    WRITE(lunout,*) ' iflag_ratqs = ', iflag_ratqs
+    WRITE(lunout,*) ' seuil_inversion = ', seuil_inversion
+    WRITE(lunout,*) ' fact_cldcon = ', fact_cldcon
+    WRITE(lunout,*) ' facttemps = ', facttemps
+    WRITE(lunout,*) ' ok_newmicro = ',ok_newmicro 
+    WRITE(lunout,*) ' ratqsbas = ',ratqsbas 
+    WRITE(lunout,*) ' ratqshaut = ',ratqshaut 
+    WRITE(lunout,*) ' tau_ratqs = ',tau_ratqs 
+    WRITE(lunout,*) ' top_height = ',top_height 
+    WRITE(lunout,*) ' rad_froid = ',rad_froid
+    WRITE(lunout,*) ' rad_chau1 = ',rad_chau1
+    WRITE(lunout,*) ' rad_chau2 = ',rad_chau2
+    WRITE(lunout,*) ' t_glace_min = ',t_glace_min
+    WRITE(lunout,*) ' t_glace_max = ',t_glace_max
+    WRITE(lunout,*) ' exposant_glace = ',exposant_glace
+    WRITE(lunout,*) ' iflag_t_glace = ',iflag_t_glace
+    WRITE(lunout,*) ' iflag_cloudth_vert = ',iflag_cloudth_vert
+    WRITE(lunout,*) ' iflag_rain_incloud_vol = ',iflag_rain_incloud_vol
+    WRITE(lunout,*) ' iflag_ice_thermo = ',iflag_ice_thermo
+    WRITE(lunout,*) ' rei_min = ',rei_min
+    WRITE(lunout,*) ' rei_max = ',rei_max
+    WRITE(lunout,*) ' overlap = ',overlap 
+    WRITE(lunout,*) ' cdmmax = ',cdmmax 
+    WRITE(lunout,*) ' cdhmax = ',cdhmax 
+    WRITE(lunout,*) ' ksta = ',ksta 
+    WRITE(lunout,*) ' ksta_ter = ',ksta_ter 
+    WRITE(lunout,*) ' f_ri_cd_min = ',f_ri_cd_min 
+    WRITE(lunout,*) ' ok_kzmin = ',ok_kzmin 
+    WRITE(lunout,*) ' pbl_lmixmin_alpha = ',pbl_lmixmin_alpha
+    WRITE(lunout,*) ' fmagic = ',fmagic
+    WRITE(lunout,*) ' pmagic = ',pmagic
+    WRITE(lunout,*) ' ok_ade = ',ok_ade
+    WRITE(lunout,*) ' ok_aie = ',ok_aie
+    WRITE(lunout,*) ' ok_alw = ',ok_alw
+    WRITE(lunout,*) ' aerosol_couple = ', aerosol_couple
+    WRITE(lunout,*) ' chemistry_couple = ', chemistry_couple
+    WRITE(lunout,*) ' flag_aerosol = ', flag_aerosol
+    WRITE(lunout,*) ' flag_aerosol_strat= ', flag_aerosol_strat
+    WRITE(lunout,*) ' new_aod = ', new_aod
+    WRITE(lunout,*) ' aer_type = ',aer_type
+    WRITE(lunout,*) ' bl95_b0 = ',bl95_b0
+    WRITE(lunout,*) ' bl95_b1 = ',bl95_b1
+    WRITE(lunout,*) ' lev_histhf = ',lev_histhf 
+    WRITE(lunout,*) ' lev_histday = ',lev_histday 
+    WRITE(lunout,*) ' lev_histmth = ',lev_histmth 
+    WRITE(lunout,*) ' lev_histins = ',lev_histins
+    WRITE(lunout,*) ' lev_histLES = ',lev_histLES
+    WRITE(lunout,*) ' lev_histdayNMC = ',lev_histdayNMC
+    WRITE(lunout,*) ' levout_histNMC = ',levout_histNMC
+    WRITE(lunout,*) ' ok_histNMC = ',ok_histNMC
+    WRITE(lunout,*) ' freq_outNMC = ',freq_outNMC
+    WRITE(lunout,*) ' freq_calNMC = ',freq_calNMC
+    WRITE(lunout,*) ' iflag_pbl = ', iflag_pbl
 !FC
-    write(lunout,*)' ifl_pbltree = ', ifl_pbltree
-    write(lunout,*)' Cd_frein = ', Cd_frein
-    write(lunout,*)' iflag_pbl_split = ', iflag_pbl_split
-    write(lunout,*)' iflag_order2_sollw = ', iflag_order2_sollw
-    write(lunout,*)' iflag_thermals = ', iflag_thermals
-    write(lunout,*)' iflag_thermals_ed = ', iflag_thermals_ed
-    write(lunout,*)' fact_thermals_ed_dz = ', fact_thermals_ed_dz
-    write(lunout,*)' iflag_thermals_optflux = ', iflag_thermals_optflux
-    write(lunout,*)' iflag_thermals_closure = ', iflag_thermals_closure
-    write(lunout,*)' iflag_clos = ', iflag_clos
-    write(lunout,*)' coef_clos_ls = ', coef_clos_ls
-    write(lunout,*)' type_run = ',type_run 
-    write(lunout,*)' ok_cosp = ',ok_cosp
-    write(lunout,*)' ok_airs = ',ok_airs
-
-    write(lunout,*)' ok_mensuelCOSP = ',ok_mensuelCOSP
-    write(lunout,*)' ok_journeCOSP = ',ok_journeCOSP
-    write(lunout,*)' ok_hfCOSP =',ok_hfCOSP
-    write(lunout,*)' solarlong0 = ', solarlong0
-    write(lunout,*)' qsol0 = ', qsol0
-    write(lunout,*)' evap0 = ', evap0
-    write(lunout,*)' albsno0 = ', albsno0
-    write(lunout,*)' iflag_sic = ', iflag_sic
-    write(lunout,*)' inertie_sol = ', inertie_sol
-    write(lunout,*)' inertie_sic = ', inertie_sic
-    write(lunout,*)' inertie_lic = ', inertie_lic
-    write(lunout,*)' inertie_sno = ', inertie_sno
-    write(lunout,*)' f_cdrag_ter = ',f_cdrag_ter
-    write(lunout,*)' f_cdrag_oce = ',f_cdrag_oce
-    write(lunout,*)' f_rugoro = ',f_rugoro
-    write(lunout,*)' z0min = ',z0min
-    write(lunout,*)' supcrit1 = ', supcrit1
-    write(lunout,*)' supcrit2 = ', supcrit2
-    write(lunout,*)' iflag_mix = ', iflag_mix
-    write(lunout,*)' iflag_mix_adiab = ', iflag_mix_adiab
-    write(lunout,*)' scut = ', scut
-    write(lunout,*)' qqa1 = ', qqa1
-    write(lunout,*)' qqa2 = ', qqa2
-    write(lunout,*)' gammas = ', gammas
-    write(lunout,*)' Fmax = ', Fmax
-    write(lunout,*)' tmax_fonte_cv = ', tmax_fonte_cv
-    write(lunout,*)' alphas = ', alphas
-    write(lunout,*)' iflag_wake = ', iflag_wake
-    write(lunout,*)' alp_offset = ', alp_offset
+    WRITE(lunout,*) ' ifl_pbltree = ', ifl_pbltree
+    WRITE(lunout,*) ' Cd_frein = ', Cd_frein
+    WRITE(lunout,*) ' iflag_pbl_split = ', iflag_pbl_split
+    WRITE(lunout,*) ' iflag_order2_sollw = ', iflag_order2_sollw
+    WRITE(lunout,*) ' iflag_thermals = ', iflag_thermals
+    WRITE(lunout,*) ' iflag_thermals_ed = ', iflag_thermals_ed
+    WRITE(lunout,*) ' fact_thermals_ed_dz = ', fact_thermals_ed_dz
+    WRITE(lunout,*) ' iflag_thermals_optflux = ', iflag_thermals_optflux
+    WRITE(lunout,*) ' iflag_thermals_closure = ', iflag_thermals_closure
+    WRITE(lunout,*) ' iflag_clos = ', iflag_clos
+    WRITE(lunout,*) ' coef_clos_ls = ', coef_clos_ls
+    WRITE(lunout,*) ' type_run = ',type_run 
+    WRITE(lunout,*) ' ok_cosp = ',ok_cosp
+    WRITE(lunout,*) ' ok_airs = ',ok_airs
+
+    WRITE(lunout,*) ' ok_mensuelCOSP = ',ok_mensuelCOSP
+    WRITE(lunout,*) ' ok_journeCOSP = ',ok_journeCOSP
+    WRITE(lunout,*) ' ok_hfCOSP =',ok_hfCOSP
+    WRITE(lunout,*) ' solarlong0 = ', solarlong0
+    WRITE(lunout,*) ' qsol0 = ', qsol0
+    WRITE(lunout,*) ' evap0 = ', evap0
+    WRITE(lunout,*) ' albsno0 = ', albsno0
+    WRITE(lunout,*) ' iflag_sic = ', iflag_sic
+    WRITE(lunout,*) ' inertie_sol = ', inertie_sol
+    WRITE(lunout,*) ' inertie_sic = ', inertie_sic
+    WRITE(lunout,*) ' inertie_lic = ', inertie_lic
+    WRITE(lunout,*) ' inertie_sno = ', inertie_sno
+    WRITE(lunout,*) ' f_cdrag_ter = ',f_cdrag_ter
+    WRITE(lunout,*) ' f_cdrag_oce = ',f_cdrag_oce
+    WRITE(lunout,*) ' f_rugoro = ',f_rugoro
+    WRITE(lunout,*) ' z0min = ',z0min
+    WRITE(lunout,*) ' supcrit1 = ', supcrit1
+    WRITE(lunout,*) ' supcrit2 = ', supcrit2
+    WRITE(lunout,*) ' iflag_mix = ', iflag_mix
+    WRITE(lunout,*) ' iflag_mix_adiab = ', iflag_mix_adiab
+    WRITE(lunout,*) ' scut = ', scut
+    WRITE(lunout,*) ' qqa1 = ', qqa1
+    WRITE(lunout,*) ' qqa2 = ', qqa2
+    WRITE(lunout,*) ' gammas = ', gammas
+    WRITE(lunout,*) ' Fmax = ', Fmax
+    WRITE(lunout,*) ' tmax_fonte_cv = ', tmax_fonte_cv
+    WRITE(lunout,*) ' alphas = ', alphas
+    WRITE(lunout,*) ' iflag_wake = ', iflag_wake
+    WRITE(lunout,*) ' alp_offset = ', alp_offset
     ! nrlmd le 10/04/2012
-    write(lunout,*)' iflag_trig_bl = ', iflag_trig_bl
-    write(lunout,*)' s_trig = ', s_trig
-    write(lunout,*)' tau_trig_shallow = ', tau_trig_shallow
-    write(lunout,*)' tau_trig_deep = ', tau_trig_deep
-    write(lunout,*)' iflag_clos_bl = ', iflag_clos_bl
+    WRITE(lunout,*) ' iflag_trig_bl = ', iflag_trig_bl
+    WRITE(lunout,*) ' s_trig = ', s_trig
+    WRITE(lunout,*) ' tau_trig_shallow = ', tau_trig_shallow
+    WRITE(lunout,*) ' tau_trig_deep = ', tau_trig_deep
+    WRITE(lunout,*) ' iflag_clos_bl = ', iflag_clos_bl
     ! fin nrlmd le 10/04/2012
 
-    write(lunout,*)' lonmin lonmax latmin latmax bilKP_ins =',&
+    WRITE(lunout,*) ' lonmin lonmax latmin latmax bilKP_ins =',&
          lonmin_ins, lonmax_ins, latmin_ins, latmax_ins
-    write(lunout,*)' ecrit_ hf, ins, day, mth, reg, tra, ISCCP, LES',&
+    WRITE(lunout,*) ' ecrit_ hf, ins, day, mth, reg, tra, ISCCP, LES',&
          ecrit_hf, ecrit_ins, ecrit_day, ecrit_mth, ecrit_reg, ecrit_tra, ecrit_ISCCP, ecrit_LES
 
-    write(lunout,*) 'ok_strato = ', ok_strato
-    write(lunout,*) 'ok_hines = ',  ok_hines
-    write(lunout,*) 'ok_gwd_rando = ',  ok_gwd_rando
-    write(lunout,*) 'ok_qch4 = ',  ok_qch4
-    write(lunout,*) 'gwd_rando_ruwmax = ', gwd_rando_ruwmax
-    write(lunout,*) 'gwd_rando_sat = ', gwd_rando_sat
-    write(lunout,*) 'gwd_front_ruwmax = ', gwd_front_ruwmax
-    write(lunout,*) 'gwd_front_sat = ', gwd_front_sat
-    write(lunout,*) 'SSO gkdrag =',gkdrag
-    write(lunout,*) 'SSO grahilo=',grahilo
-    write(lunout,*) 'SSO grcrit=',grcrit
-    write(lunout,*) 'SSO gfrcrit=',gfrcrit
-    write(lunout,*) 'SSO gkwake=',gkwake
-    write(lunout,*) 'SSO gklift=',gklift
-    write(lunout,*) 'adjust_tropopause = ', adjust_tropopause
-    write(lunout,*) 'ok_daily_climoz = ',ok_daily_climoz
-    write(lunout,*) 'read_climoz = ', read_climoz
-    write(lunout,*) 'carbon_cycle_tr = ', carbon_cycle_tr
-    write(lunout,*) 'carbon_cycle_cpl = ', carbon_cycle_cpl
+    WRITE(lunout,*) ' ok_strato = ', ok_strato
+    WRITE(lunout,*) ' ok_hines = ',  ok_hines
+    WRITE(lunout,*) ' ok_gwd_rando = ',  ok_gwd_rando
+    WRITE(lunout,*) ' ok_qch4 = ',  ok_qch4
+    WRITE(lunout,*) ' gwd_rando_ruwmax = ', gwd_rando_ruwmax
+    WRITE(lunout,*) ' gwd_rando_sat = ', gwd_rando_sat
+    WRITE(lunout,*) ' gwd_front_ruwmax = ', gwd_front_ruwmax
+    WRITE(lunout,*) ' gwd_front_sat = ', gwd_front_sat
+    WRITE(lunout,*) ' SSO gkdrag =',gkdrag
+    WRITE(lunout,*) ' SSO grahilo=',grahilo
+    WRITE(lunout,*) ' SSO grcrit=',grcrit
+    WRITE(lunout,*) ' SSO gfrcrit=',gfrcrit
+    WRITE(lunout,*) ' SSO gkwake=',gkwake
+    WRITE(lunout,*) ' SSO gklift=',gklift
+    WRITE(lunout,*) ' adjust_tropopause = ', adjust_tropopause
+    WRITE(lunout,*) ' ok_daily_climoz = ',ok_daily_climoz
+    WRITE(lunout,*) ' read_climoz = ', read_climoz
+    WRITE(lunout,*) ' carbon_cycle_tr = ', carbon_cycle_tr
+    WRITE(lunout,*) ' carbon_cycle_cpl = ', carbon_cycle_cpl
+    WRITE(lunout,*) ' level_coupling_esm = ', level_coupling_esm
 
     !$OMP END MASTER
@@ -2736,8 +2748,7 @@
   !
   ! tau_calv:    temps de relaxation pour la fonte des glaciers
-
+  !
   REAL          :: tau_calv
-  REAL,SAVE     :: tau_calv_omp
-
+  REAL, SAVE    :: tau_calv_omp
   !
   !Config Key  = tau_calv
@@ -2751,13 +2762,13 @@
   !$OMP END MASTER
   !$OMP BARRIER
-
+  !
   tau_calv=tau_calv_omp
-
+  !
   !$OMP MASTER
-  write(lunout,*)' ##############################################'
+  WRITE(lunout,*)' ##############################################'
   WRITE(lunout,*)' Configuration de l''interface atm/surfaces  : '
   WRITE(lunout,*)' tau_calv = ',tau_calv
   !$OMP END MASTER
-
+  !
   RETURN
 
