Index: trunk/LMDZ.MARS/libf/phymars/co2cloud.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/co2cloud.F	(revision 1921)
+++ trunk/LMDZ.MARS/libf/phymars/co2cloud.F	(revision 1922)
@@ -1,2 +1,12 @@
+      MODULE co2cloud_mod
+
+      IMPLICIT NONE 
+
+      DOUBLE PRECISION,allocatable,save :: mem_Mccn_co2(:,:) ! Memory of CCN mass of H2O and dust used by CO2
+      DOUBLE PRECISION,allocatable,save :: mem_Mh2o_co2(:,:) ! Memory of H2O mass integred into CO2 crystal
+      DOUBLE PRECISION,allocatable,save :: mem_Nccn_co2(:,:) ! Memory of CCN number of H2O and dust used by CO2
+
+      CONTAINS
+
       SUBROUTINE co2cloud(ngrid,nlay,ptimestep, 
      &                pplev,pplay,pdpsrf,pzlay,pt,pdt,
@@ -20,4 +30,5 @@
       USE newsedim_mod, ONLY: newsedim
       USE datafile_mod, ONLY: datadir
+      USE improvedCO2clouds_mod, ONLY: improvedCO2clouds
 
       IMPLICIT NONE
@@ -137,8 +148,4 @@
       real subpdqsed(ngrid,nlay,nq)
       real sum_subpdqs_sedco2(ngrid) ! CO2 flux at the surface
-
-      DOUBLE PRECISION,allocatable,save :: memdMMccn(:,:) !memory of h2o particles 
-      DOUBLE PRECISION,allocatable,save :: memdMMh2o(:,:) !only if co2useh2o=.true.
-      DOUBLE PRECISION,allocatable,save :: memdNNccn(:,:) !Nb particules H2O intégré 
      
 !     What we need for Qext reading and tau computation : size distribution
@@ -207,13 +214,4 @@
         write(*,*)"Physical timestep is",ptimestep 
         write(*,*)"CO2 Microphysics timestep is",microtimestep 
-      
-   
-        if (.not. allocated(memdMMccn)) allocate(memdMMccn(ngrid,nlay))
-        if (.not. allocated(memdNNccn)) allocate(memdNNccn(ngrid,nlay))
-        if (.not. allocated(memdMMh2o)) allocate(memdMMh2o(ngrid,nlay))
-        
-        memdMMccn(:,:)=0.
-        memdMMh2o(:,:)=0.
-        memdNNccn(:,:)=0.
 
 c     Compute the size bins of the distribution of CO2 ice particles
@@ -610,5 +608,5 @@
      &     pplay,pplev,pteff,sum_subpdt,
      &     pqeff,sum_subpdq,subpdqcloudco2,subpdtcloudco2,
-     &     nq,tauscaling,memdMMccn,memdMMh2o,memdNNccn)
+     &     nq,tauscaling,mem_Mccn_co2,mem_Mh2o_co2,mem_Nccn_co2)
 c ==============================================================================
 c      3.  Updating tendencies after cloud scheme:
@@ -960,9 +958,35 @@
       call WRITEdiagfi(ngrid,"tau1mic","co2 ice opacity 1 micron"
      &        ," ",2,tau1mic)
-      call WRITEDIAGFI(ngrid,"memdNNccn","Nombre de CCN de glace d eau"
-     &        ,"kg/kg ",3,memdNNccn) 
-      call WRITEDIAGFI(ngrid,"memdMMccn","Masse de CCN de glace d eau"
-     &        ,"kg/kg ",3,memdMMccn) 
-      call WRITEDIAGFI(ngrid,"memdMMh2o","Masse de CCN de glace d eau"
-     &        ,"kg/kg ",3,memdMMh2o)         
-      END
+      call WRITEDIAGFI(ngrid,"mem_Nccn_co2","CCN number used by CO2"
+     &        ,"kg/kg ",3,mem_Nccn_co2) 
+      call WRITEDIAGFI(ngrid,"mem_Mccn_co2","CCN mass used by CO2"
+     &        ,"kg/kg ",3,mem_Mccn_co2) 
+      call WRITEDIAGFI(ngrid,"mem_Mh2o_co2","H2O mass in CO2 crystal"
+     &        ,"kg/kg ",3,mem_Mh2o_co2)         
+
+      END SUBROUTINE co2cloud
+c Subroutines used to write variables of memory in start files       
+      SUBROUTINE ini_co2cloud(ngrid,nlayer)
+  
+      IMPLICIT NONE
+
+      INTEGER, INTENT (in) :: ngrid  ! number of atmospheric columns
+      INTEGER, INTENT (in) :: nlayer ! number of atmospheric layers
+
+         allocate(mem_Nccn_co2(ngrid,nlayer))
+         allocate(mem_Mccn_co2(ngrid,nlayer))
+         allocate(mem_Mh2o_co2(ngrid,nlayer))
+
+      END SUBROUTINE ini_co2cloud
+
+      SUBROUTINE end_co2cloud
+
+      IMPLICIT NONE
+
+         if (allocated(mem_Nccn_co2)) deallocate(mem_Nccn_co2)
+         if (allocated(mem_Mccn_co2)) deallocate(mem_Mccn_co2)
+         if (allocated(mem_Mh2o_co2)) deallocate(mem_Mh2o_co2)
+
+      END SUBROUTINE end_co2cloud
+
+      END MODULE co2cloud_mod
Index: trunk/LMDZ.MARS/libf/phymars/improvedCO2clouds.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/improvedCO2clouds.F	(revision 1921)
+++ trunk/LMDZ.MARS/libf/phymars/improvedCO2clouds.F	(revision 1922)
@@ -1,7 +1,13 @@
+      MODULE improvedCO2clouds_mod
+      
+      IMPLICIT NONE
+
+      CONTAINS
+ 
       subroutine improvedCO2clouds(ngrid,nlay,microtimestep,
      &             pplay,pplev,pteff,sum_subpdt,
      &             pqeff,sum_subpdq,subpdqcloudco2,subpdtcloudco2,
      &             nq,tauscaling,
-     &             memdMMccn,memdMMh2o,memdNNccn)
+     &             mem_Mccn_co2,mem_Mh2o_co2,mem_Nccn_co2)
       USE comcstfi_h, only: pi, g, cpp
       USE updaterad, only: updaterice_micro, updaterice_microco2
@@ -36,5 +42,5 @@
 c Memory of the origin of the co2 particles is kept and thus the 
 c water cycle shouldn't be modified by this.
-cWARNING: no sedimentation of the water ice origin is performed
+c WARNING: no sedimentation of the water ice origin is performed
 c in the microphysical timestep in co2cloud.F. 
 
@@ -104,7 +110,7 @@
       DOUBLE PRECISION Mo,No,No_dust,Mo_dust
       DOUBLE PRECISION  Rn, Rm, dev2,dev3, n_derf, m_derf
-      DOUBLE PRECISION memdMMccn(ngrid,nlay)
-      DOUBLE PRECISION memdMMh2o(ngrid,nlay)
-      DOUBLE PRECISION memdNNccn(ngrid,nlay)
+      DOUBLE PRECISION mem_Mccn_co2(ngrid,nlay) ! Memory of CCN mass of H2O and dust used by CO2
+      DOUBLE PRECISION mem_Mh2o_co2(ngrid,nlay) ! Memory of H2O mass integred into CO2 crystal
+      DOUBLE PRECISION mem_Nccn_co2(ngrid,nlay) ! Memory of CCN number of H2O and dust used by CO2
       
 !     Radius used by the microphysical scheme (m)
@@ -506,7 +512,7 @@
                 zq(ig,l,igcm_h2o_ice) = zq(ig,l,igcm_h2o_ice)-dMh2o_ice
                 zq(ig,l,igcm_ccn_mass)= zq(ig,l,igcm_ccn_mass)-dMh2o_ccn
-                memdMMh2o(ig,l)=memdMMh2o(ig,l)+dMh2o_ice
-                memdMMccn(ig,l)=memdMMccn(ig,l)+dMh2o_ccn
-                memdNNccn(ig,l)=memdNNccn(ig,l)+dNNh2o
+                mem_Mh2o_co2(ig,l)=mem_Mh2o_co2(ig,l)+dMh2o_ice
+                mem_Mccn_co2(ig,l)=mem_Mccn_co2(ig,l)+dMh2o_ccn
+                mem_Nccn_co2(ig,l)=mem_Nccn_co2(ig,l)+dNNh2o
              endif ! of if co2useh2o
            ENDIF   ! of is satu >1
@@ -566,16 +572,16 @@
 ! On sublime tout
                  if (co2useh2o) then
-                   if (memdMMccn(ig,l) .gt. 0) then
+                   if (mem_Mccn_co2(ig,l) .gt. 0) then
                     zq(ig,l,igcm_ccn_mass)=zq(ig,l,igcm_ccn_mass)
-     &                   +memdMMccn(ig,l)
+     &                   +mem_Mccn_co2(ig,l)
                    endif
-                   if (memdMMh2o(ig,l) .gt. 0) then
+                   if (mem_Mh2o_co2(ig,l) .gt. 0) then
                     zq(ig,l,igcm_h2o_ice)=zq(ig,l,igcm_h2o_ice)
-     &                   +memdMMh2o(ig,l)
+     &                   +mem_Mh2o_co2(ig,l)
                    endif
                  
-                   if (memdNNccn(ig,l) .gt. 0) then
+                   if (mem_Nccn_co2(ig,l) .gt. 0) then
                     zq(ig,l,igcm_ccn_number)=zq(ig,l,igcm_ccn_number)
-     &                   +memdNNccn(ig,l)
+     &                   +mem_Nccn_co2(ig,l)
                    endif
                  endif
@@ -583,8 +589,9 @@
      &                   zq(ig,l,igcm_dust_mass)
      &                   + zq(ig,l,igcm_ccnco2_mass)-
-     &                   (memdMMh2o(ig,l)+memdMMccn(ig,l))
+     &                   (mem_Mh2o_co2(ig,l)+mem_Mccn_co2(ig,l))
                     zq(ig,l,igcm_dust_number) = 
      &                   zq(ig,l,igcm_dust_number)
-     &                   + zq(ig,l,igcm_ccnco2_number)-memdNNccn(ig,l)
+     &                   + zq(ig,l,igcm_ccnco2_number)
+     &                   -mem_Nccn_co2(ig,l)
                  
                     zq(ig,l,igcm_co2) = zq(ig,l,igcm_co2) 
@@ -594,7 +601,7 @@
                  zq(ig,l,igcm_co2_ice)=0.
                  zq(ig,l,igcm_ccnco2_number)=0.
-                 memdNNccn(ig,l)=0.
-                 memdMMh2o(ig,l)=0.
-                 memdMMccn(ig,l)=0.
+                 mem_Nccn_co2(ig,l)=0.
+                 mem_Mh2o_co2(ig,l)=0.
+                 mem_Mccn_co2(ig,l)=0.
                  riceco2(ig,l)=0.
 
@@ -643,6 +650,14 @@
 
 
-        end
-      
-      
-      
+c     TEST D.BARDET 
+      call WRITEDIAGFI(ngrid,"No_dust","Nombre particules de poussière"
+     &        ,"part/kg",3,No_dust)
+      call WRITEDIAGFI(ngrid,"Mo_dust","Masse particules de poussière"
+     &        ,"kg/kg ",3,Mo_dust)      
+
+        END SUBROUTINE improvedCO2clouds
+
+        END MODULE improvedCO2clouds_mod
+      
+      
+      
Index: trunk/LMDZ.MARS/libf/phymars/phyetat0.F90
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/phyetat0.F90	(revision 1921)
+++ trunk/LMDZ.MARS/libf/phymars/phyetat0.F90	(revision 1922)
@@ -1,6 +1,7 @@
 subroutine phyetat0 (fichnom,tab0,Lmodif,nsoil,ngrid,nlay,nq, &
                      day_ini,time0,tsurf,tsoil,emis,q2,qsurf,co2ice, &
-                     tauscaling,totcloudfrac)
-!  use netcdf
+                     tauscaling,totcloudfrac,mem_Mccn_co2,mem_Nccn_co2,&
+                     mem_Mh2o_co2)
+
   use tracer_mod, only: noms ! tracer names
   use surfdat_h, only: phisfi, albedodat, z0, z0_default,&
@@ -47,4 +48,7 @@
   real,intent(out) :: tauscaling(ngrid) ! dust conversion factor
   real,intent(out) :: totcloudfrac(ngrid) ! total cloud fraction
+  real,intent(out) :: mem_Mccn_co2(ngrid,nlay) ! Memory of CCN mass of H2O and dust used by CO2
+  real,intent(out) :: mem_Nccn_co2(ngrid,nlay) ! Memory of CCN number of H2O and dust used by CO2
+  real,intent(out) :: mem_Mh2o_co2(ngrid,nlay) ! Memory of H2O mass integred into CO2 crystal
 !======================================================================
 !  Local variables:
@@ -230,4 +234,34 @@
 endif
 
+! Memory of the origin of the co2 particles
+call get_field("mem_Mccn_co2",mem_Mccn_co2,found,indextime)
+if (.not.found) then
+  write(*,*) "phyetat0: <mem_Mccn_co2> not in file"
+  mem_Mccn_co2(:,:)=0
+else
+  write(*,*) "phyetat0: Memory of CCN mass of H2O and dust used by CO2"
+  write(*,*) " <mem_Mccn_co2> range:", &
+             minval(mem_Mccn_co2), maxval(mem_Mccn_co2)
+endif
+
+call get_field("mem_Nccn_co2",mem_Nccn_co2,found,indextime)
+if (.not.found) then
+  write(*,*) "phyetat0: <mem_Nccn_co2> not in file"
+  mem_Nccn_co2(:,:)=0
+else
+  write(*,*) "phyetat0: Memory of CCN number of H2O and dust used by CO2"
+  write(*,*) " <mem_Nccn_co2> range:", &
+             minval(mem_Nccn_co2), maxval(mem_Nccn_co2)
+endif
+
+call get_field("mem_Mh2o_co2",mem_Mh2o_co2,found,indextime)
+if (.not.found) then
+  write(*,*) "phyetat0: <mem_Mh2o_co2> not in file"
+  mem_Mh2o_co2(:,:)=0
+else
+  write(*,*) "phyetat0: Memory of H2O mass integred into CO2 crystal"
+  write(*,*) " <mem_Mh2o_co2> range:", &
+             minval(mem_Mh2o_co2), maxval(mem_Mh2o_co2)
+endif
 
 ! Dust conversion factor
Index: trunk/LMDZ.MARS/libf/phymars/phyredem.F90
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/phyredem.F90	(revision 1921)
+++ trunk/LMDZ.MARS/libf/phymars/phyredem.F90	(revision 1922)
@@ -145,10 +145,15 @@
 subroutine physdem1(filename,nsoil,ngrid,nlay,nq, &
                     phystep,time,tsurf,tsoil,co2ice,emis,q2,qsurf,&
-                    tauscaling,totcloudfrac)
+                    tauscaling,totcloudfrac,mem_Mccn_co2,mem_Nccn_co2,&
+                    mem_Mh2o_co2)
   ! write time-dependent variable to restart file
   use iostart, only : open_restartphy, close_restartphy, & 
                       put_var, put_field
   use tracer_mod, only: noms ! tracer names
+
   implicit none
+  
+  include "callkeys.h"
+  
   character(len=*),intent(in) :: filename
   integer,intent(in) :: nsoil
@@ -165,5 +170,8 @@
   real,intent(in) :: qsurf(ngrid,nq)
   real,intent(in) :: tauscaling(ngrid)
-  real, intent(in) :: totcloudfrac(ngrid)
+  real,intent(in) :: totcloudfrac(ngrid)
+  real,intent(in) :: mem_Mccn_co2(ngrid,nlay) ! CCN mass of H2O and dust used by CO2
+  real,intent(in) :: mem_Nccn_co2(ngrid,nlay) ! CCN number of H2O and dust used by CO2
+  real,intent(in) :: mem_Mh2o_co2(ngrid,nlay) ! H2O mass integred into CO2 crystal
   
   integer :: iq
@@ -235,4 +243,10 @@
     enddo
   endif
+  ! Memory of the origin of the co2 particles
+  if (co2useh2o) then
+     call put_field("mem_Mccn_co2","CCN mass of H2O and dust used by CO2",mem_Mccn_co2,time)
+     call put_field("mem_Nccn_co2","CCN number of H2O and dust used by CO2",mem_Nccn_co2,time)
+     call put_field("mem_Mh2o_co2","H2O mass integred into CO2 crystal",mem_Mh2o_co2,time)
+  endif
   
   ! Close file
Index: trunk/LMDZ.MARS/libf/phymars/phys_state_var_init_mod.F90
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/phys_state_var_init_mod.F90	(revision 1921)
+++ trunk/LMDZ.MARS/libf/phymars/phys_state_var_init_mod.F90	(revision 1922)
@@ -46,4 +46,5 @@
       use tracer_mod, only: ini_tracer_mod,end_tracer_mod
       use time_phylmdz_mod, only: init_time
+      use co2cloud_mod, only: ini_co2cloud,end_co2cloud
 
       IMPLICIT NONE
@@ -105,5 +106,10 @@
       call end_turb_mod
       call ini_turb_mod(ngrid,nlayer)
-
+      
+      ! allocate arrays in "co2cloud" : 
+      ! Memory of the origin of the co2 particles      
+      call end_co2cloud
+      call ini_co2cloud(ngrid,nlayer)
+      
       END SUBROUTINE phys_state_var_init
 
Index: trunk/LMDZ.MARS/libf/phymars/physiq_mod.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/physiq_mod.F	(revision 1921)
+++ trunk/LMDZ.MARS/libf/phymars/physiq_mod.F	(revision 1922)
@@ -15,4 +15,6 @@
 
       use watercloud_mod
+      use co2cloud_mod, only: co2cloud, mem_Mccn_co2, mem_Mh2o_co2,
+     &                        mem_Nccn_co2
       use aeropacity_mod
       use callradite_mod 
@@ -60,4 +62,6 @@
       USE vertical_layers_mod, ONLY: ap,bp,aps,bps
 #endif
+
+
 
       IMPLICIT NONE
@@ -162,9 +166,9 @@
 c    ------------------
 
-#include "callkeys.h"
-#include "comg1d.h"
-#include "nlteparams.h"
-#include "chimiedata.h"
-#include "netcdf.inc"
+      include "callkeys.h"
+      include "comg1d.h"
+      include "nlteparams.h"
+      include "chimiedata.h"
+      include "netcdf.inc"
 
 c Arguments :
@@ -432,5 +436,6 @@
      &         day_ini,time_phys,
      &         tsurf,tsoil,emis,q2,qsurf,co2ice,tauscaling,
-     &         totcloudfrac)
+     &         totcloudfrac,mem_Mccn_co2,mem_Nccn_co2,
+     &         mem_Mh2o_co2)
 
          if (pday.ne.day_ini) then
@@ -1231,5 +1236,6 @@
          
          IF (co2clouds ) THEN
-            
+
+
             call co2cloud(ngrid,nlayer,ptimestep,
      &           zplev,zplay,pdpsrf,zzlay,pt,pdt,
@@ -1239,5 +1245,5 @@
      &           rsedcloud,rhocloud,zzlev,zdqssed_co2,
      &           pdu,pu)
-                
+
 
 c Temperature variation due to latent heat release
@@ -1301,14 +1307,14 @@
              where (pq(:,:,igcm_ccnco2_mass) + 
      &              ptimestep*pdq(:,:,igcm_ccnco2_mass) < 0.)
-                pdq(:,:,igcm_ccnco2_mass) = 
+               pdq(:,:,igcm_ccnco2_mass) = 
      &            - pq(:,:,igcm_ccnco2_mass)/ptimestep + 1.e-30
-                pdq(:,:,igcm_ccnco2_number) = 
+               pdq(:,:,igcm_ccnco2_number) = 
      &            - pq(:,:,igcm_ccnco2_number)/ptimestep + 1.e-30
              end where
              where (pq(:,:,igcm_ccnco2_number) + 
      &              ptimestep*pdq(:,:,igcm_ccnco2_number) < 0.)
-                pdq(:,:,igcm_ccnco2_mass) = 
+               pdq(:,:,igcm_ccnco2_mass) = 
      &            - pq(:,:,igcm_ccnco2_mass)/ptimestep + 1.e-30
-                pdq(:,:,igcm_ccnco2_number) = 
+               pdq(:,:,igcm_ccnco2_number) = 
      &            - pq(:,:,igcm_ccnco2_number)/ptimestep + 1.e-30
              end where
@@ -1317,15 +1323,15 @@
              where (pq(:,:,igcm_dust_mass) + 
      &              ptimestep*pdq(:,:,igcm_dust_mass) < 0.)
-                pdq(:,:,igcm_dust_mass) = 
-     &            - pq(:,:,igcm_dust_mass)/ptimestep + 1.e-30
-                pdq(:,:,igcm_dust_number) = 
-     &            - pq(:,:,igcm_dust_number)/ptimestep + 1.e-30
+               pdq(:,:,igcm_dust_mass) = 
+     &           - pq(:,:,igcm_dust_mass)/ptimestep + 1.e-30
+               pdq(:,:,igcm_dust_number) = 
+     &           - pq(:,:,igcm_dust_number)/ptimestep + 1.e-30
              end where
              where (pq(:,:,igcm_dust_number) + 
      &              ptimestep*pdq(:,:,igcm_dust_number) < 0.)
-                pdq(:,:,igcm_dust_mass) = 
-     &            - pq(:,:,igcm_dust_mass)/ptimestep + 1.e-30
-                pdq(:,:,igcm_dust_number) = 
-     &            - pq(:,:,igcm_dust_number)/ptimestep + 1.e-30
+               pdq(:,:,igcm_dust_mass) = 
+     &           - pq(:,:,igcm_dust_mass)/ptimestep + 1.e-30
+               pdq(:,:,igcm_dust_number) = 
+     &           - pq(:,:,igcm_dust_number)/ptimestep + 1.e-30
              end where
       
@@ -1839,5 +1845,6 @@
      .                ptimestep,ztime_fin,
      .                tsurf,tsoil,co2ice,emis,q2,qsurf,tauscaling,
-     .               totcloudfrac)
+     .                totcloudfrac,mem_Mccn_co2,mem_Nccn_co2,
+     .                mem_Mh2o_co2)
           
          ENDIF
@@ -1895,5 +1902,4 @@
                enddo
               enddo
-              
            endif ! of if (co2clouds)
            
@@ -2369,5 +2375,5 @@
 c        Outputs of the CO2 cycle
 c        ----------------------------------------------------------
-
+            
          if (tracer.and.(igcm_co2.ne.0)) then
 !          call WRITEDIAGFI(ngrid,"co2_l1","co2 mix. ratio in 1st layer",
@@ -2386,5 +2392,5 @@
      &                       'total mass of CO2 ice',
      &                       'kg/m2',2,icetotco2)
-
+ 
             call WRITEDIAGFI(ngrid,'ccnqco2','CCNco2 mass mr',
      &                       'kg/kg',3,qccnco2)
@@ -2395,6 +2401,4 @@
           endif ! of if (co2clouds)
          endif ! of if (tracer.and.(igcm_co2.ne.0))
-
-
         ! Output He tracer, if there is one
         if (tracer.and.(igcm_he.ne.0)) then
@@ -2445,8 +2449,10 @@
      &                       'Mean reff',
      &                       'm',2,rave)
+
             call WRITEDIAGFI(ngrid,'h2o_ice','h2o_ice','kg/kg',
      &             3,zq(:,:,igcm_h2o_ice))
             call WRITEDIAGFI(ngrid,'h2o_vap','h2o_vap','kg/kg',
      &             3,zq(:,:,igcm_h2o_vap))
+
 
 !A. Pottier
