Index: trunk/NEMO/TOP_SRC/PISCES/p4zflx.F90
===================================================================
--- trunk/NEMO/TOP_SRC/PISCES/p4zflx.F90	(revision 1457)
+++ trunk/NEMO/TOP_SRC/PISCES/p4zflx.F90	(revision 1534)
@@ -24,5 +24,7 @@
    USE p4zche
    USE iom
-
+#if defined key_cpl_carbon_cycle
+   USE sbc_oce , ONLY :  atm_co2
+#endif
    USE lib_mpp
 
@@ -35,8 +37,15 @@
       atcox  = 0.20946 ,    &  !:
       atcco2 = 278.            !:
- 
-   REAL(wp) :: &          
-      xconv  = 0.01/3600.,  &  ! coefficients for conversion       
-      tco2flx                 !: Total flux of carbon per year
+
+   REAL(wp) :: &
+      xconv  = 0.01/3600     !: coefficients for conversion 
+
+#if defined key_cpl_carbon_cycle
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::  &
+      oce_co2            !: ocean carbon flux
+   REAL(wp) :: &
+      t_atm_co2_flx,  &  !: Total atmospheric carbon flux per year
+      t_oce_co2_flx      !: Total ocean carbon flux per year
+#endif
 
    !!* Substitution
@@ -63,5 +72,5 @@
       REAL(wp) ::   zfld, zflu, zfld16, zflu16, zfact
       REAL(wp) ::   zph, zah2, zbot, zdic, zalk, zsch_o2, zalka, zsch_co2
-      REAL(wp), DIMENSION(jpi,jpj) ::   zkgco2, zkgo2, zh2co3, ztco2flx
+      REAL(wp), DIMENSION(jpi,jpj) ::   zkgco2, zkgo2, zh2co3
 #if defined key_trc_diaadd && defined key_iomput
       REAL(wp), DIMENSION(jpi,jpj) ::  zcflx, zoflx, zkg, zdelc
@@ -146,16 +155,18 @@
       END DO
 
-#if ! defined key_iomput
       DO jj = 1, jpj
          DO ji = 1, jpi
-
             ! Compute CO2 flux for the sea and air
+#if ! defined key_cpl_carbon_cycle
             zfld = atcco2 * tmask(ji,jj,1) * chemc(ji,jj,1) * zkgco2(ji,jj)
             zflu = zh2co3(ji,jj) * tmask(ji,jj,1) * zkgco2(ji,jj)
+#else
+            zfld = atm_co2(ji,jj) * tmask(ji,jj,1) * chemc(ji,jj,1) * zkgco2(ji,jj)
+            zflu = zh2co3(ji,jj) * tmask(ji,jj,1) * zkgco2(ji,jj)
+            ! compute flux of carbon
+            oce_co2(ji,jj) = ( zfld - zflu ) * rfact &
+               &             * e1t(ji,jj) * e2t(ji,jj) * tmask(ji,jj,1) * 1000.
+#endif
             tra(ji,jj,1,jpdic) = tra(ji,jj,1,jpdic) + ( zfld - zflu ) / fse3t(ji,jj,1)
-
-            ! compute flux of carbon
-            ztco2flx(ji,jj) = ( zfld - zflu ) * rfact &
-               &             * e1t(ji,jj) * e2t(ji,jj) * tmask(ji,jj,1) * 1000.
 
             ! Compute O2 flux 
@@ -164,59 +175,45 @@
             tra(ji,jj,1,jpoxy) = tra(ji,jj,1,jpoxy) + ( zfld16 - zflu16 ) / fse3t(ji,jj,1)
 
-# if defined key_trc_diaadd 
+#if defined key_trc_diaadd 
             ! Save diagnostics
-            trc2d(ji,jj,jp_pcs0_2d    ) = ( zfld - zflu ) * 1000.  * tmask(ji,jj,1)
+#  if ! defined key_iomput
+            trc2d(ji,jj,jp_pcs0_2d    ) = ( zfld - zflu )     * 1000. * tmask(ji,jj,1)
             trc2d(ji,jj,jp_pcs0_2d + 1) = ( zfld16 - zflu16 ) * 1000. * tmask(ji,jj,1)
             trc2d(ji,jj,jp_pcs0_2d + 2) = zkgco2(ji,jj) * tmask(ji,jj,1)
             trc2d(ji,jj,jp_pcs0_2d + 3) = atcco2 - zh2co3(ji,jj) / ( chemc(ji,jj,1) + rtrn ) * tmask(ji,jj,1)
-# endif
-         END DO
-      END DO
-      !
-#else
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            ! Compute CO2 flux for the sea and air
-            zfld = atcco2 * tmask(ji,jj,1) * chemc(ji,jj,1) * zkgco2(ji,jj)
-            zflu = zh2co3(ji,jj) * tmask(ji,jj,1) * zkgco2(ji,jj)
-            tra(ji,jj,1,jpdic) = tra(ji,jj,1,jpdic) + ( zfld - zflu ) / fse3t(ji,jj,1)
-
-            ! compute flux of carbon
-            ztco2flx(ji,jj) = ( zfld - zflu ) * rfact &
-               &             * e1t(ji,jj) * e2t(ji,jj) * tmask(ji,jj,1) * 1000.
-
-            ! Compute O2 flux 
-            zfld16 = atcox * chemc(ji,jj,2) *tmask(ji,jj,1) * zkgo2(ji,jj)
-            zflu16 = trn(ji,jj,1,jpoxy) * tmask(ji,jj,1) * zkgo2(ji,jj)
-            tra(ji,jj,1,jpoxy) = tra(ji,jj,1,jpoxy) + ( zfld16 - zflu16 ) / fse3t(ji,jj,1)
-# if defined key_trc_diaadd 
-            ! Save diagnostics
+#  else
             zcflx(ji,jj) = ( zfld - zflu ) * 1000.  * tmask(ji,jj,1)
             zoflx(ji,jj) = ( zfld16 - zflu16 ) * 1000. * tmask(ji,jj,1)
             zkg  (ji,jj) = zkgco2(ji,jj) * tmask(ji,jj,1)
             zdelc(ji,jj) = atcco2 - zh2co3(ji,jj) / ( chemc(ji,jj,1) + rtrn ) * tmask(ji,jj,1)
-# endif
+#  endif
+#endif
          END DO
       END DO
-#endif
-
+
+#if defined key_cpl_carbon_cycle
       ! Total Flux of Carbon
-      DO jj = 1, jpj
+      DO jj = 1, jpj 
         DO ji = 1, jpi
-           tco2flx = tco2flx + ztco2flx(ji,jj) * tmask_i(ji,jj)
+           t_atm_co2_flx = t_atm_co2_flx + atm_co2(ji,jj) * tmask_i(ji,jj)
+           t_oce_co2_flx = t_oce_co2_flx + oce_co2(ji,jj) * tmask_i(ji,jj)
         END DO
       END DO
 
       IF( MOD( kt, nspyr ) == 0 ) THEN
-        IF( lk_mpp ) CALL mpp_sum( tco2flx )   ! sum over the global domain
-
+        IF( lk_mpp ) THEN
+          CALL mpp_sum( t_atm_co2_flx )   ! sum over the global domain
+          CALL mpp_sum( t_oce_co2_flx )   ! sum over the global domain
+        ENDIF
         WRITE(numout,*) ' Atmospheric pCO2    :'
-        WRITE(numout,*) '-------------------- : ',kt,'  ',atcco2
+        WRITE(numout,*) '-------------------- : ',kt,'  ',t_atm_co2_flx
         WRITE(numout,*) '(ppm)'
         WRITE(numout,*) 'Total Flux of Carbon :'
-        WRITE(numout,*) '-------------------- : ',tco2flx * 12. / 1e15
+        WRITE(numout,*) '-------------------- : ',t_oce_co2_flx * 12. / 1e15
         WRITE(numout,*) '(GtC/an)'
-        tco2flx = 0.
+        t_atm_co2_flx = 0.
+        t_oce_co2_flx = 0.
       ENDIF
+#endif
 
       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
@@ -260,6 +257,10 @@
       ENDIF
 
-      ! Initialization of total Flux of Carbon
-      tco2flx = 0.
+#if defined key_cpl_carbon_cycle
+      ! Initialization of Flux of Carbon
+      oce_co2(:,:) = 0.
+      t_atm_co2_flx = 0.
+      t_oce_co2_flx = 0.
+#endif
 
    END SUBROUTINE p4z_flx_init
