Index: /LMDZ6/trunk/libf/phylmd/tracco2i_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/tracco2i_mod.F90	(revision 3365)
+++ /LMDZ6/trunk/libf/phylmd/tracco2i_mod.F90	(revision 3366)
@@ -82,10 +82,9 @@
 !--co2bb is zero for now
     CALL co2_emissions(debutphy,co2ff,co2bb)
+    PRINT *,'co2 emissions i'
 
 !--preparing the net anthropogenic flux at the surface for mixing layer 
 !--unit kg CO2 / m2 / s
-    DO i=1, klon
-      source(i,id_CO2)=co2ff(i)+co2bb(i)
-    ENDDO
+    source(:,id_CO2)=co2ff(:)+co2bb(:)
 
 !--computing global mean CO2 for radiation
@@ -111,5 +110,5 @@
     USE geometry_mod, ONLY : cell_area
     USE mod_grid_phy_lmdz
-    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    USE mod_phys_lmdz_mpi_data, ONLY: is_mpi_root
     USE mod_phys_lmdz_para, ONLY: gather, scatter
     USE phys_cal_mod
@@ -126,55 +125,104 @@
 
 ! For NetCDF:
-    integer ncid_in  ! IDs for input files
-    integer varid, ncerr
+    INTEGER ncid_in  ! IDs for input files
+    INTEGER varid, ncerr
 
     INTEGER :: n_glo, n_month
     REAL, POINTER:: vector(:), time(:)
-    REAL,ALLOCATABLE       :: flx_co2_glo(:,:) !  fossil-fuel CO2 
-    REAL,ALLOCATABLE, SAVE :: flx_co2(:,:)     !  fossil-fuel CO2 
-!$OMP THREADPRIVATE(flx_co2)
-
-  IF (debutphy) THEN 
-
-  ALLOCATE(flx_co2(klon,12))
+    REAL,ALLOCATABLE       :: flx_co2ff_glo(:,:) !  fossil-fuel CO2 
+    REAL,ALLOCATABLE, SAVE :: flx_co2ff(:,:)     !  fossil-fuel CO2 
+    REAL,ALLOCATABLE       :: flx_co2bb_glo(:,:) !  biomass-burning CO2 
+    REAL,ALLOCATABLE, SAVE :: flx_co2bb(:,:)     !  biomass-burning CO2 
+!$OMP THREADPRIVATE(flx_co2ff, flx_co2bb)
+
+    LOGICAL, PARAMETER :: readco2ff=.TRUE., readco2bb=.FALSE. !!may be controlled via the .def later on
+
+    IF (debutphy) THEN 
+
+    ALLOCATE(flx_co2ff(klon,12))
+    ALLOCATE(flx_co2bb(klon,12))
 
 !$OMP MASTER
-  IF (is_mpi_root) THEN
-    ! ... Open the file
-    CALL nf95_open("sflx_lmdz_co2.nc", nf90_nowrite, ncid_in)
-
-    CALL nf95_inq_varid(ncid_in, "vector", varid)
-    CALL nf95_gw_var(ncid_in, varid, vector)
-    n_glo = size(vector)
-    IF (n_glo.NE.klon_glo) THEN
-       print *,'Le nombre de points n est pas egal a klon_glo'
-       STOP
-    ENDIF
-
-    CALL nf95_inq_varid(ncid_in, "time", varid)
-    CALL nf95_gw_var(ncid_in, varid, time)
-    n_month = size(time)
-    IF (n_month.NE.12) THEN
-       print *,'Le nombre de month n est pas egal a 12'
-       STOP
-    ENDIF
-
-    IF (.NOT.ALLOCATED(flx_co2_glo)) ALLOCATE(flx_co2_glo(n_glo,n_month))
-
-!--reading flx_co2
-    CALL nf95_inq_varid(ncid_in, "flx_co2", varid)
-    ncerr = nf90_get_var(ncid_in, varid, flx_co2_glo)
-
-    CALL nf95_close(ncid_in)
-  ENDIF
+    IF (is_mpi_root) THEN
+    
+      IF (.NOT.ALLOCATED(flx_co2ff_glo)) ALLOCATE(flx_co2ff_glo(n_glo,n_month))
+      IF (.NOT.ALLOCATED(flx_co2bb_glo)) ALLOCATE(flx_co2bb_glo(n_glo,n_month))
+
+!--reading CO2 fossil fuel emissions
+      IF (readco2ff) THEN 
+
+        ! ... Open the COZff file
+        CALL nf95_open("sflx_lmdz_co2_ff.nc", nf90_nowrite, ncid_in)
+
+        CALL nf95_inq_varid(ncid_in, "vector", varid)
+        CALL nf95_gw_var(ncid_in, varid, vector)
+        n_glo = size(vector)
+        IF (n_glo.NE.klon_glo) THEN
+           PRINT *,'sflx_lmdz_co2_ff: le nombre de points n est pas egal a klon_glo'
+           STOP
+        ENDIF
+
+        CALL nf95_inq_varid(ncid_in, "time", varid)
+        CALL nf95_gw_var(ncid_in, varid, time)
+        n_month = size(time)
+        IF (n_month.NE.12) THEN
+           PRINT *,'sflx_lmdz_co2_ff: le nombre de month n est pas egal a 12'
+           STOP
+        ENDIF
+
+!--reading flx_co2 for fossil fuel
+        CALL nf95_inq_varid(ncid_in, "flx_co2", varid)
+        ncerr = nf90_get_var(ncid_in, varid, flx_co2ff_glo)
+
+        CALL nf95_close(ncid_in)
+    
+      ELSE  !--co2ff not to be read
+        flx_co2ff_glo(:,:)=0.0
+      ENDIF
+
+!--reading CO2 biomass burning emissions
+      IF (readco2bb) THEN 
+
+      ! ... Open the CO2bb file
+      CALL nf95_open("sflx_lmdz_co2_bb.nc", nf90_nowrite, ncid_in)
+
+      CALL nf95_inq_varid(ncid_in, "vector", varid)
+      CALL nf95_gw_var(ncid_in, varid, vector)
+      n_glo = size(vector)
+      IF (n_glo.NE.klon_glo) THEN
+         PRINT *,'sflx_lmdz_co2_bb: le nombre de points n est pas egal a klon_glo'
+         STOP
+      ENDIF
+
+      CALL nf95_inq_varid(ncid_in, "time", varid)
+      CALL nf95_gw_var(ncid_in, varid, time)
+      n_month = size(time)
+      IF (n_month.NE.12) THEN
+         PRINT *,'sflx_lmdz_co2_bb: le nombre de month n est pas egal a 12'
+         STOP
+      ENDIF
+
+!--reading flx_co2 for biomass burning
+      CALL nf95_inq_varid(ncid_in, "flx_co2", varid)
+      ncerr = nf90_get_var(ncid_in, varid, flx_co2bb_glo)
+
+      CALL nf95_close(ncid_in)
+    
+      ELSE  !--co2bb not to be read
+        flx_co2bb_glo(:,:)=0.0
+      ENDIF
+
+    ENDIF
 !$OMP END MASTER
 
 !--scatter on all proc
-  CALL scatter(flx_co2_glo,flx_co2)
+    CALL scatter(flx_co2ff_glo,flx_co2ff)
+    CALL scatter(flx_co2bb_glo,flx_co2bb)
 
 !$OMP MASTER
-  IF (is_mpi_root) THEN
-     DEALLOCATE(flx_co2_glo)
-  ENDIF
+    IF (is_mpi_root) THEN
+       DEALLOCATE(flx_co2ff_glo)
+       DEALLOCATE(flx_co2bb_glo)
+    ENDIF
 !$OMP END MASTER
 
@@ -183,8 +231,8 @@
 !---select the correct month
   IF (mth_cur.LT.1.OR.mth_cur.GT.12) THEN
-    print *,'probleme avec le mois dans co2_ini =', mth_cur
+    PRINT *,'probleme avec le mois dans co2_ini =', mth_cur
   ENDIF
-  co2ff(:) = flx_co2(:,mth_cur)
-  co2bb(:) = 0.0
+  co2ff(:) = flx_co2ff(:,mth_cur)
+  co2bb(:) = flx_co2bb(:,mth_cur)
 
   END SUBROUTINE co2_emissions
