Index: trunk/LMDZ.MARS/libf/phymars/co2cloud.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/co2cloud.F	(revision 1985)
+++ trunk/LMDZ.MARS/libf/phymars/co2cloud.F	(revision 1996)
@@ -15,5 +15,5 @@
      &                rsedcloudco2,rhocloudco2,
      &                rsedcloud,rhocloud,pzlev,pdqs_sedco2,
-     &                pdu,pu)
+     &                pdu,pu,pcondicea)
       USE ioipsl_getincom, only: getin
       use dimradmars_mod, only: naerkind
@@ -94,4 +94,5 @@
       real, INTENT(IN) :: pdq(ngrid,nlay,nq)    ! tendencies before condensation  (kg/kg.s-1)
       real, intent(OUT) :: pdqcloudco2(ngrid,nlay,nq) ! tendency due to CO2 condensation (kg/kg.s-1)
+      real, intent(OUT) :: pcondicea(ngrid,nlay)
       real, intent(OUT) :: pdtcloudco2(ngrid,nlay)    ! tendency on temperature due to latent heat
       INTEGER, INTENT(IN) :: nq                 ! number of tracers
@@ -187,4 +188,8 @@
       DOUBLE PRECISION:: rho,zu,NN,gradT !For Saturation Index computation
       DOUBLE PRECISION :: SatIndex(ngrid,nlay),SatIndexmap(ngrid)
+
+c D. BARDET : sensibility test
+      REAL :: No_dust(ngrid,nlay)
+      REAL :: Mo_dust(ngrid,nlay)
       
 c      logical :: CLFvaryingCO2
@@ -433,10 +438,10 @@
              ENDDO
            ELSE
-!SatIndex not favorable for GW : leave pt untouched
+! SatIndex not favorable for GW : leave pt untouched
              pteff(ig,l)=pt(ig,l)
              co2cloudfrac(ig,l)=mincloud
            ENDIF                 ! of if(SatIndexmap...
          ENDDO ! of DO ig=1,ngrid
-!     Totalcloud frac of the column missing here
+! Totalcloud frac of the column missing here
 c
 c No sub-grid cloud representation (CLFvarying=false)
@@ -608,5 +613,11 @@
      &     pplay,pplev,pteff,sum_subpdt,
      &     pqeff,sum_subpdq,subpdqcloudco2,subpdtcloudco2,
-     &     nq,tauscaling,mem_Mccn_co2,mem_Mh2o_co2,mem_Nccn_co2)
+     &     nq,tauscaling,mem_Mccn_co2,mem_Mh2o_co2,mem_Nccn_co2,
+     &     No_dust,Mo_dust)
+c D. BARDET: sensibility test
+c      call WRITEDIAGFI(ngrid,"No_dust","Nombre particules de poussiere"
+c     &        ,"part/kg",3,No_dust)
+c      call WRITEDIAGFI(ngrid,"Mo_dust","Masse particules de poussiere"
+c     &        ,"kg/kg ",3,Mo_dust)
 c ==============================================================================
 c      3.  Updating tendencies after cloud scheme:
@@ -657,4 +668,14 @@
 c   Compute final tendencies after time loop:
 c------------------------------------------------
+c Condensation/sublimation tendency after clouds scheme (to replace
+c zcondicea in newcondens.F
+
+      DO l=nlay, 1, -1
+        DO ig = 1, ngrid
+           pcondicea(ig,l) = sum_subpdq(ig,l,igcm_co2_ice)
+     &                       /real(imicroco2)
+        ENDDO
+      ENDDO
+
 c CO2 flux at surface (kg.m-2.s-1)
       do ig=1,ngrid 
@@ -856,8 +877,8 @@
       ENDDO 
      
-c     A correction if a lot of subliming CO2 fills the 1st layer FF04/2005
-c     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-c     Then that should not affect the ice particle radius
-       
+c ======================================================================     
+c A correction if a lot of subliming CO2 fills the 1st layer FF04/2005
+c Then that should not affect the ice particle radius
+c ======================================================================         
       do ig=1,ngrid
         if(pdpsrf(ig)*ptimestep.gt.0.9*(pplev(ig,1)-pplev(ig,2)))then
@@ -896,5 +917,5 @@
         enddo
       enddo
-!Everything modified by CO2 microphysics must be wrt co2cloudfrac
+! Everything modified by CO2 microphysics must be wrt co2cloudfrac
       IF (CLFvaryingCO2) THEN
         DO l=1,nlay
@@ -964,7 +985,15 @@
       call WRITEDIAGFI(ngrid,"mem_Mh2o_co2","H2O mass in CO2 crystal"
      &        ,"kg/kg ",3,mem_Mh2o_co2)         
-
+c D.BARDET: sensibility test 
+c      call WRITEDIAGFI(ngrid,"No_dust","Nombre particules de poussiere"
+c     &        ,"part/kg",3,No_dust)
+c      call WRITEDIAGFI(ngrid,"Mo_dust","Masse particules de poussiere"
+c     &        ,"kg/kg ",3,Mo_dust) 
       END SUBROUTINE co2cloud
+
+c ===================================================================
 c Subroutines used to write variables of memory in start files       
+c ===================================================================
+
       SUBROUTINE ini_co2cloud(ngrid,nlayer)
   
@@ -979,5 +1008,5 @@
 
       END SUBROUTINE ini_co2cloud
-
+c ----------------------------------
       SUBROUTINE end_co2cloud
 
Index: trunk/LMDZ.MARS/libf/phymars/improvedCO2clouds_mod.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/improvedCO2clouds_mod.F	(revision 1985)
+++ trunk/LMDZ.MARS/libf/phymars/improvedCO2clouds_mod.F	(revision 1996)
@@ -9,7 +9,9 @@
      &             pqeff,sum_subpdq,subpdqcloudco2,subpdtcloudco2,
      &             nq,tauscaling,
-     &             mem_Mccn_co2,mem_Mh2o_co2,mem_Nccn_co2)
+     &             mem_Mccn_co2,mem_Mh2o_co2,mem_Nccn_co2,
+     &             No_dust,Mo_dust)
       USE comcstfi_h, only: pi, g, cpp
-      USE updaterad, only: updaterice_micro, updaterice_microco2
+      USE updaterad, only: updaterice_micro, updaterice_microco2,
+     &                     updaterccnCO2
       use tracer_mod, only: igcm_dust_mass, igcm_dust_number, rho_dust,
      &                      igcm_h2o_ice, igcm_ccn_mass,
@@ -17,5 +19,5 @@
      &                      igcm_co2, igcm_co2_ice, igcm_ccnco2_mass,
      &                      igcm_ccnco2_number, nuiceco2_sed,
-     &                      rho_ice_co2
+     &                      rho_ice_co2,nuiceco2_ref
       use conc_mod, only: mmean
       use datafile_mod, only: datadir
@@ -84,4 +86,6 @@
       REAL,INTENT(out) :: subpdtcloudco2(ngrid,nlay)  ! tendency on temperature due
                                    ! to latent heat
+      REAL,INTENT(out) :: No_dust(ngrid,nlay)
+      REAL,INTENT(out) :: Mo_dust(ngrid,nlay)
 
 c------------------------------------------------------------------
@@ -108,5 +112,11 @@
       DOUBLE PRECISION pco2,psat  ! Co2 vapor partial pressure (Pa)
       DOUBLE PRECISION satu ! Co2 vapor saturation ratio over ice
-      DOUBLE PRECISION Mo,No,No_dust,Mo_dust
+      DOUBLE PRECISION Mo ,No
+      
+c D.BARDET: sensibility test
+c      REAL, SAVE :: No ! when sensibility test
+c      DOUBLE PRECISION No_dust(ngrid,nlay) ! when sensibility test
+c      DOUBLE PRECISION Mo_dust(ngrid,nlay) ! when sensibility test 
+     
       DOUBLE PRECISION  Rn, Rm, dev2,dev3, n_derf, m_derf
       DOUBLE PRECISION mem_Mccn_co2(ngrid,nlay) ! Memory of CCN mass of H2O and dust used by CO2
@@ -297,4 +307,7 @@
         l3=0.0528288d0
         l4=-0.000103183d0
+        
+c D.BARDET:
+c        No = 1.e10        
         firstcall=.false.
       END IF
@@ -377,18 +390,9 @@
            IF ( satu .ge. 1 ) THEN ! if there is condensation
 
-c We do rdust computation "by hand" because we don't want to
-c change the mininumum rdust value in updaterad... It would
-c mess up various part of the GCM !
-              
-              rdust(ig,l)= zq(ig,l,igcm_dust_mass)
-     &             *0.75/(pi*rho_dust
-     &             * zq(ig,l,igcm_dust_number))
-              rdust(ig,l)= rdust(ig,l)**(1./3.)
-              if (zq(ig,l,igcm_dust_mass)*tauscaling(ig) .le. 1.e-20 
-     &             .or.  zq(ig,l,igcm_dust_number)*tauscaling(ig) .le.1
-     &             .or. rdust(ig,l) .le. 1.e-9) then
-                 rdust(ig,l)=1.e-9
-              endif
-              rdust(ig,l)=min(5.e-4,rdust(ig,l))
+          call updaterccnCO2(zq(ig,l,igcm_dust_mass),
+     &          zq(ig,l,igcm_dust_number),rdust(ig,l),tauscaling(ig))
+
+c D.BARDET: sensibility test
+c              rdust=2.e-6
       
 c Expand the dust moments into a binned distribution
@@ -397,5 +401,7 @@
               m_aer(:)=0.
 
-              Mo = zq(ig,l,igcm_dust_mass)* tauscaling(ig)+1.e-30
+              Mo =4.*pi*rho_dust*No*rdust(ig,l)**(3.)
+     &           *dexp(9.*nuiceco2_ref/2.)/3. ! in Madeleine et al 2011
+     
               No = zq(ig,l,igcm_dust_number)* tauscaling(ig)+1.e-30
 
@@ -526,11 +532,9 @@
 c Indeed, if we are supersaturated and still don't have at least one nuclei, we should better wait
 c to avoid unrealistic value for nuclei radius and so on for cases that remain negligible.
-           No   = zq(ig,l,igcm_ccnco2_number)* tauscaling(ig)+1.e-30
-           IF (No .ge. 1)THEN   ! we trigger crystal growth
-              interm1 = DBLE(zq(ig,l,igcm_co2_ice))
-              interm2 = DBLE(zq(ig,l,igcm_ccnco2_mass))
-              interm3 = DBLE(zq(ig,l,igcm_ccnco2_number))
-              call updaterice_microco2(interm1,
-     &            interm2,interm3,
+             IF (zq(ig,l,igcm_ccnco2_number)
+     &         * tauscaling(ig)+1.e-30.ge. 1)THEN   ! we trigger crystal growth
+              
+              call updaterice_microco2(zq(ig,l,igcm_co2_ice),
+     &            zq(ig,l,igcm_ccnco2_mass),zq(ig,l,igcm_ccnco2_number),
      &            tauscaling(ig),riceco2(ig,l),rhocloudco2(ig,l))
 
Index: trunk/LMDZ.MARS/libf/phymars/improvedclouds_mod.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/improvedclouds_mod.F	(revision 1985)
+++ trunk/LMDZ.MARS/libf/phymars/improvedclouds_mod.F	(revision 1996)
@@ -12,4 +12,5 @@
       USE ioipsl_getincom
       USE updaterad
+      USE watersat_mod, ONLY: watersat
       use tracer_mod, only: rho_ice, nuice_sed, igcm_h2o_vap,
      &                      igcm_h2o_ice, igcm_dust_mass,
Index: trunk/LMDZ.MARS/libf/phymars/newcondens.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/newcondens.F	(revision 1985)
+++ trunk/LMDZ.MARS/libf/phymars/newcondens.F	(revision 1996)
@@ -4,5 +4,7 @@
      $                  piceco2,psolaralb,pemisurf,
      $                  pdtc,pdtsrfc,pdpsrf,pduc,pdvc,pdqc,
-     $                  fluxsurf_sw,zls)
+     $                  fluxsurf_sw,zls,
+     $                  zdqssed_co2,pcondicea_co2microp,
+     $                  zdtcloudco2)
                                                    
        use tracer_mod, only: noms
@@ -24,4 +26,5 @@
 c   author:   Francois Forget     1994-1996
 c   ------
+c             adapted to external CO2 ice clouds scheme by Deborah Bardet (2018) '
 c
 c   input:
@@ -90,4 +93,9 @@
       REAL,INTENT(IN) :: pdq(ngrid,nlayer,nq) ! tendency on tracers from
                                               ! previous physical processes
+
+      REAL,INTENT(IN) :: zdqssed_co2(ngrid)  ! CO2 flux at the surface  (kg.m-2.s-1)
+      REAL,INTENT(IN) :: pcondicea_co2microp(ngrid,nlayer)! tendency due to CO2 condensation (kg/kg.s-1)
+      REAL,INTENT(IN) :: zdtcloudco2(ngrid,nlayer) ! tendency on temperature due to latent heat                 
+
       REAL,INTENT(INOUT) :: piceco2(ngrid) ! CO2 ice on the surface (kg.m-2)
       REAL,INTENT(INOUT) :: psolaralb(ngrid,2) ! albedo of the surface
@@ -173,4 +181,8 @@
       integer flag
 
+c D.BARDET: to debug 
+      real ztc3D(ngrid,nlayer)
+      REAL ztm3D(ngrid,nlayer)
+      REAL zmflux3D(ngrid,nlayer)
 c----------------------------------------------------------------------
 
@@ -280,4 +292,5 @@
       end if
 
+      IF (.NOT. co2clouds) then
 c     forecast of atmospheric temperature zt and frost temperature ztcond
 c     --------------------------------------------------------------------
@@ -329,4 +342,35 @@
          ENDDO
       ENDDO
+      
+      ELSE
+         
+        DO ig=1,ngrid 
+         zfallice(ig,1) = zdqssed_co2(ig)
+        ENDDO
+        DO l=nlayer , 1, -1
+            DO ig=1,ngrid 
+         zcondicea(ig,l) = pcondicea_co2microp(ig,l)* 
+     &                        (pplev(ig,l) - pplev(ig,l+1))/g
+            ENDDO
+        ENDDO
+        DO l=nlayer, 1, -1
+         DO ig=1, ngrid
+            zt(ig,l)=pt(ig,l)+ pdt(ig,l)*ptimestep
+            pdtc(ig,l)=0.
+         ENDDO
+      ENDDO 
+      ENDIF ! if not co2clouds
+
+      call WRITEdiagfi(ngrid,"pdtc_atm",
+     &         "temperature tendency due to CO2 condensation",
+     &         " ",3,pdtc) 
+     
+       call WRITEdiagfi(ngrid,"zcondicea",
+     &         "",
+     &         " ",3,zcondicea)         
+      
+       call WRITEdiagfi(ngrid,"zfallice",
+     &         "",
+     &         " ",2,zfallice(ngrid,1))
 
 c     *************************
@@ -624,5 +668,5 @@
 c           """"""""""""""""""""""""
             DO l=1,nlayer
- 
+               IF(.not. co2clouds) THEN
 c             Tendencies on T
                 zdtsig(ig,l) = (1/masse(l)) *
@@ -630,4 +674,14 @@
      &        - zmflux(l+1)*(ztm(l+1) - ztc(l))
      &        + zcondicea(ig,l)*(ztcond(ig,l)-ztc(l))  )
+               ELSE
+                zdtsig(ig,l) = (1/masse(l)) *
+     &        ( zmflux(l)*(ztm(l) - ztc(l)) 
+     &        - zmflux(l+1)*(ztm(l+1) - ztc(l)))               
+               ENDIF
+c D.BARDET: for diagnotics 
+                zmflux3D(ig,l)=zmflux(l)
+                ztm3D(ig,l)=ztm(l)
+                ztc3D(ig,l)=ztc(l)
+                
                 pdtc(ig,l) =  pdtc(ig,l) + zdtsig(ig,l)
 
@@ -799,5 +853,4 @@
 #endif
 
-      return
       end
 
@@ -924,4 +977,3 @@
 c         end if
 
-      return
       end
Index: trunk/LMDZ.MARS/libf/phymars/physiq_mod.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/physiq_mod.F	(revision 1985)
+++ trunk/LMDZ.MARS/libf/phymars/physiq_mod.F	(revision 1996)
@@ -14,5 +14,6 @@
      $            ,pdu,pdv,pdt,pdq,pdpsrf)
 
-      use watercloud_mod
+      use watercloud_mod, only: watercloud
+      use watersat_mod, only: watersat
       use co2cloud_mod, only: co2cloud, mem_Mccn_co2, mem_Mh2o_co2,
      &                        mem_Nccn_co2
@@ -238,4 +239,5 @@
       real rhocloudco2(ngrid,nlayer) !co2 Cloud density (kg.m-3)
       real zdqssed_co2(ngrid)  ! CO2 flux at the surface  (kg.m-2.s-1)
+      real zcondicea_co2microp(ngrid,nlayer)
 c     Variables used by the photochemistry
       logical :: asis             ! true  : adaptative semi-implicit symmetric (asis) chemical solver
@@ -1108,6 +1110,7 @@
      $        zdum1,zdum2,zdh,pdq,zflubid,
      $        zdudif,zdvdif,zdhdif,zdtsdif,q2,
-     &        zdqdif,zdqsdif,wstar,zcdv,zcdh,hfmax_th,sensibFlux,
-     &	      dustliftday,local_time)
+     &        zdqdif,zdqsdif,wstar,zcdv,zcdh,hfmax_th,
+     &        zcondicea_co2microp,sensibFlux,
+     &        dustliftday,local_time)
 
           DO ig=1,ngrid
@@ -1269,5 +1272,4 @@
 
 
-
 c-----------------------------------------------------------------------
 c   8. Specific parameterizations for tracers 
@@ -1354,5 +1356,4 @@
            endif ! of if scavenging
                       
-
          END IF  ! of IF (water)
 
@@ -1385,5 +1386,5 @@
      &           rsedcloudco2,rhocloudco2,
      &           rsedcloud,rhocloud,zzlev,zdqssed_co2,
-     &           pdu,pu)
+     &           pdu,pu,zcondicea_co2microp)
 
 
@@ -1479,5 +1480,4 @@
       END IF                    ! of IF (co2clouds)
 
-
 c   8b. Aerosol particles
 c     -------------------
@@ -1709,7 +1709,7 @@
      $              co2ice,albedo,emis,
      $              zdtc,zdtsurfc,pdpsrf,zduc,zdvc,zdqc,
-     $              fluxsurf_sw,zls)!,
-c     &              zzlev,zdqssed_co2,zdqcloudco2,
-c     &              zdtcloudco2)
+     $              fluxsurf_sw,zls,
+     $              zdqssed_co2,zcondicea_co2microp,
+     &              zdtcloudco2)
 
          DO l=1,nlayer
@@ -1759,5 +1759,6 @@
 #endif
       
-      ENDIF  ! of IF (callcond)      
+      ENDIF  ! of IF (callcond)
+
 c-----------------------------------------------------------------------
 c   11. Surface  and sub-surface soil temperature
@@ -2142,4 +2143,5 @@
 c               if (icetot(ig)*1e3.lt.0.01) rave(ig)=0.
              enddo
+
              call watersat(ngrid*nlayer,zt,zplay,zqsat)
              satu(:,:) = zq(:,:,igcm_h2o_vap)/zqsat(:,:)
@@ -2617,5 +2619,9 @@
             call WRITEDIAGFI(ngrid,'co2_ice','co2_ice','kg/kg',
      &                       3,zq(:,:,igcm_co2_ice))
-          endif ! of if (co2clouds)
+            call WRITEDIAGFI(ngrid,'precip_co2_ice',
+     &                       'surface deposition of co2 ice',
+     &                       'kg.m-2.s-1',2,
+     &                       zdqssed(1:ngrid,igcm_co2_ice))
+           endif ! of if (co2clouds)
          endif ! of if (tracer.and.(igcm_co2.ne.0))
         ! Output He tracer, if there is one
Index: trunk/LMDZ.MARS/libf/phymars/simpleclouds.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/simpleclouds.F	(revision 1985)
+++ trunk/LMDZ.MARS/libf/phymars/simpleclouds.F	(revision 1996)
@@ -4,4 +4,5 @@
      &             nq,tau,rice)
       USE updaterad
+      USE watersat_mod, ONLY: watersat
       use tracer_mod, only: igcm_h2o_vap, igcm_h2o_ice
       USE comcstfi_h
Index: trunk/LMDZ.MARS/libf/phymars/updaterad.F90
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/updaterad.F90	(revision 1985)
+++ trunk/LMDZ.MARS/libf/phymars/updaterad.F90	(revision 1996)
@@ -34,4 +34,5 @@
 real, parameter :: r3ccnmin = 1.e-21    ! ie rccnmin = 0.1 microns
 real, parameter :: rccnmin  = 0.1e-6
+real, parameter :: rccnCO2min  = 1e-9
 
 real, parameter :: r3ccnmax = 125.e-12  ! ie rccnmax  = 500 microns
@@ -289,4 +290,52 @@
 
 
+
+
+!============================================================================
+!============================================================================
+!============================================================================
+! This subroutine computes the mass mean radius, 
+! used for heterogenous nucleation on CCNs in microphysics of CO2.
+! For a lognormal distribution :
+! geometric mean radius = mass mean radius x exp(-1.5 sigma0^2)
+subroutine updaterccnCO2(qccn,nccn,rccn,tauscaling)
+use tracer_mod, only: rho_dust
+USE comcstfi_h
+implicit none
+
+real, intent(in) :: qccn,nccn ! needed if doubleq
+real, intent(in), optional :: tauscaling ! useful for realistic thresholds
+
+real, intent(out) :: rccn
+
+real coeff
+
+
+if (present(tauscaling)) then
+  coeff = tauscaling ! threshold on realistic values
+else
+  coeff = 1. ! threshold on virtual values
+endif
+
+if ((nccn .le. nccn_threshold/coeff) .or. (qccn .le. qccn_threshold/coeff)) then
+
+   rccn = rccnCO2min
+
+else
+
+   rccn  =  qccn * 0.75 / pi / rho_dust / nccn
+   rccn = rccn**(1./3.)
+
+endif
+
+rccn=min(5.E-4,rccn)
+     
+end subroutine updaterccnCO2
+!============================================================================
+!============================================================================
+!============================================================================
+
+
+
 end module updaterad
 
Index: trunk/LMDZ.MARS/libf/phymars/vdifc_mod.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/vdifc_mod.F	(revision 1985)
+++ trunk/LMDZ.MARS/libf/phymars/vdifc_mod.F	(revision 1996)
@@ -12,5 +12,6 @@
      $                pdudif,pdvdif,pdhdif,pdtsrf,pq2,
      $                pdqdif,pdqsdif,wstar,zcdv_true,zcdh_true,
-     $                hfmax,sensibFlux,dustliftday,local_time)
+     $                hfmax,pcondicea_co2microp,sensibFlux,
+     $                dustliftday,local_time)
 
       use tracer_mod, only: noms, igcm_dust_mass, igcm_dust_number,
@@ -20,4 +21,5 @@
       use surfdat_h, only: watercaptag, frost_albedo_threshold, dryness
       USE comcstfi_h, ONLY: cpp, r, rcp, g
+      use watersat_mod, only: watersat
       use turb_mod, only: turb_resolved, ustar, tstar
       use compute_dtau_mod, only: ti_injection,tf_injection
@@ -69,5 +71,6 @@
       REAL,INTENT(IN) :: co2ice (ngrid), ppopsk(ngrid,nlay)
       logical,INTENT(IN) :: lecrit
-
+      REAL,INTENT(IN) :: pcondicea_co2microp(ngrid,nlay)! tendency due to CO2 condensation (kg/kg.s-1)
+      
       REAL,INTENT(IN) :: pz0(ngrid) ! surface roughness length (m)
 
@@ -633,8 +636,6 @@
 c      (computation of zcondicea and dmice)
 
-      zcondicea(ig,:)=0.
-      pdtc(ig,:)=0.
-
-      DO l=nlay , 1, -1
+      IF (.NOT. co2clouds) then
+       DO l=nlay , 1, -1
            IF(zt(ig,l).LT.ztcond(ig,l)) THEN
                pdtc(ig,l)=(ztcond(ig,l) - zt(ig,l))/ptimestep
@@ -643,9 +644,17 @@
               dmice(ig,l)= dmice(ig,l) + zcondicea(ig,l)*ptimestep
             END IF
-      ENDDO
-
-         ENDDO    !of Do j=1,XXX 
-
-      ENDDO   !of Do ig=1,nlay
+       ENDDO
+      ELSE
+       DO l=nlay , 1, -1
+         zcondicea(ig,l)= 0.!pcondicea_co2microp(ig,l)* 
+c     &                        (pplev(ig,l) - pplev(ig,l+1))/g
+         dmice(ig,l)= 0.!dmice(ig,l) + zcondicea(ig,l)*ptimestep
+         pdtc(ig,l)=0.
+       ENDDO    
+      ENDIF
+      
+       ENDDO!of Do j=1,XXX 
+
+      ENDDO   !of Do ig=1,ngrid
 
       pdtsrf(:)=(ztsrf2(:)-ptsrf(:))/ptimestep
Index: trunk/LMDZ.MARS/libf/phymars/watercloud_mod.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/watercloud_mod.F	(revision 1985)
+++ trunk/LMDZ.MARS/libf/phymars/watercloud_mod.F	(revision 1996)
@@ -14,4 +14,5 @@
      &                     updaterice_typ
       USE improvedclouds_mod, ONLY: improvedclouds
+      USE watersat_mod, ONLY: watersat
       use tracer_mod, only: nqmx, igcm_h2o_vap, igcm_h2o_ice,
      &                      igcm_dust_mass, igcm_dust_number,
Index: trunk/LMDZ.MARS/libf/phymars/watersat.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/watersat.F	(revision 1985)
+++ trunk/LMDZ.MARS/libf/phymars/watersat.F	(revision 1996)
@@ -1,3 +1,10 @@
+      MODULE watersat_mod
+      
+      IMPLICIT NONE
+      
+      CONTAINS 
+      
       SUBROUTINE watersat(naersize,t,p,qsat)
+      
       IMPLICIT NONE
 
@@ -7,4 +14,5 @@
 c   and Temperature (K) array
 c
+c  Move in module by Deborah BARDET 02/07/18
 c=======================================================================
 
@@ -15,18 +23,20 @@
 
 c   INPUT
-      integer naersize 
-      real t(naersize) , p(naersize)
+      integer, intent(in) :: naersize 
+      real, intent(in) :: t(naersize)
+      real, intent(in) :: p(naersize)
 c   OUTPUT
-      real qsat(naersize)
+      real, intent(out) :: qsat(naersize)
 
 c   local:
 c   ------
       INTEGER i
-      REAL r2,r3,r4 , To, es
-      SAVE r2,r3,r4
-      DATA r2,r3,r4/611.14,21.875,7.66/
-      SAVE To
-      DATA To/273.16/
-          
+      REAL,PARAMETER :: r2 = 611.14
+      REAL,PARAMETER :: r3 = 21.875
+      REAL,PARAMETER :: r4 = 7.66
+      REAL,PARAMETER :: To = 273.16
+      REAL es
+      
+      
       do i=1,naersize
 c        pression de vapeur saturante :
@@ -44,5 +54,5 @@
       enddo
 
-      RETURN
-      END
-
+      END SUBROUTINE watersat
+      
+      END MODULE watersat_mod
