Index: /trunk/LMDZ.GENERIC/libf/phystd/callcorrk.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/callcorrk.F90	(revision 3043)
+++ /trunk/LMDZ.GENERIC/libf/phystd/callcorrk.F90	(revision 3044)
@@ -444,5 +444,5 @@
 
          if(varfixed .and. generic_condensation .and. .not. water)then
-            write(*,*) "Deep water vapor mixing ratio ? (no effect if negative) "
+            write(*,*) "Deep generic tracer vapor mixing ratio ? (no effect if negative) "
             qvap_deep=-1. ! default value
             call getin_p("qvap_deep",qvap_deep)
Index: /trunk/LMDZ.GENERIC/libf/phystd/condensation_generic_mod.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/condensation_generic_mod.F90	(revision 3043)
+++ /trunk/LMDZ.GENERIC/libf/phystd/condensation_generic_mod.F90	(revision 3044)
@@ -47,6 +47,8 @@
 !       Options : 
         real, save :: metallicity !metallicity of planet
-        REAL, SAVE :: qvap_deep   ! deep mixing ratio of water vapor when simulating bottom less planets
-!$OMP THREADPRIVATE(metallicity, qvap_deep)
+        REAL, SAVE :: qvap_deep   ! deep mixing ratio of vapor when simulating bottom less planets
+        REAL, SAVE :: qvap_top   ! top mixing ratio of vapor when simulating bottom less planets
+        logical, save :: perfect_vap_profile
+!$OMP THREADPRIVATE(metallicity, qvap_deep, qvap_top, perfect_vap_profile)
 
 !       Local variables
@@ -57,5 +59,6 @@
         INTEGER i, k , nn, iq
         INTEGER,PARAMETER :: nitermax=5000
-        INTEGER,PARAMETER :: tau=86400 ! tau is in seconds and must not be lower than the physical step time.
+        REAL tau ! tau is in seconds and must not be lower than the physical step time.
+        integer k_cold_trap
         DOUBLE PRECISION,PARAMETER :: alpha=.1,qthreshold=1.d-8
         ! JL13: if "careful, T<Tmin in psat water" appears often, you may want to stabilise the model by
@@ -65,4 +68,5 @@
         DOUBLE PRECISION zqs(ngrid)
         real zt(ngrid),local_p,psat_tmp,dlnpsat_tmp,Lcp,zqs_temp,zdqs
+        real zqs_temp_1, zqs_temp_2, zqs_temp_3
         integer igcm_generic_vap, igcm_generic_ice! index of the vap and ice of generic_tracer
         ! CHARACTER(len=*) :: tname_ice
@@ -82,8 +86,18 @@
                 write(*,*) " metallicity = ",metallicity
 
-                write(*,*) "Deep water vapor mixing ratio ? (no effect if negative) "
+                write(*,*) "Deep generic tracer vapor mixing ratio ? (no effect if negative) "
                 qvap_deep=-1. ! default value
                 call getin_p("qvap_deep",qvap_deep)
                 write(*,*) " qvap_deep = ",qvap_deep   
+
+                write(*,*) "top generic tracer vapor mixing ratio ? (no effect if negative) "
+                qvap_top=-1. ! default value
+                call getin_p("qvap_top",qvap_top)
+                write(*,*) " qvap_top = ",qvap_top 
+                
+                write(*,*) " perfect_vap_profile ? "
+                perfect_vap_profile=.false. ! default value
+                call getin_p("perfect_vap_profile",perfect_vap_profile)
+                write(*,*) " perfect_vap_profile = ",perfect_vap_profile
 
                 firstcall = .false.
@@ -181,9 +195,68 @@
                         Enddo ! k= nlayer, 1, -1
 
+                        if ((perfect_vap_profile) .and. (ngrid.eq.1)) then
+                                ! perfect_vap_profile is a mode that should a priori only be used in 1D:
+                                ! it aims to force the vap profile:
+                                ! - below condensation, it is forced to qvap_deep
+                                ! - at condensation levels, it is forced to 99% of sat
+                                ! - above the cold trap, it is forced to the value allowed by the cold trap
+                                tau=3*24*3600
+
+                                k_cold_trap = 2
+                                do k=2,nlayer-1
+
+                                        zt(1)=pt(1,k-1)+pdt(1,k-1)*ptimestep
+                                        call Psat_generic(zt(1),pplay(1,k-1),metallicity,psat_tmp,zqs_temp_1)
+                                        zt(1)=pt(1,k)+pdt(1,k)*ptimestep
+                                        call Psat_generic(zt(1),pplay(1,k),metallicity,psat_tmp,zqs_temp_2)
+                                        zt(1)=pt(1,k+1)+pdt(1,k+1)*ptimestep
+                                        call Psat_generic(zt(1),pplay(1,k+1),metallicity,psat_tmp,zqs_temp_3)
+
+                                        if ((zqs_temp_1 .gt. zqs_temp_2) .and. (zqs_temp_3 .gt. zqs_temp_2)) then
+                                                k_cold_trap = k
+                                                exit
+                                        endif
+                                enddo
+                                if (k_cold_trap .lt. nlayer) then
+                                        do k=k_cold_trap+1,nlayer
+                                                pdqvaplsc(1,k,igcm_generic_vap) = (pq(1,k_cold_trap,igcm_generic_vap) - pq(1,k,igcm_generic_vap))/tau - pdq(1,k,igcm_generic_vap)
+                                        enddo
+                                endif
+
+                                do k=1,k_cold_trap
+                                        zt(1)=pt(1,k)+pdt(1,k)*ptimestep
+                                        call Psat_generic(zt(1),pplay(1,k),metallicity,psat_tmp,zqs_temp)
+                                        if (zqs_temp .gt. qvap_deep) then
+                                                pdqvaplsc(1,k,igcm_generic_vap)  = (qvap_deep - pq(1,k,igcm_generic_vap))/tau - pdq(1,k,igcm_generic_vap)
+                                        endif
+                                        if (zqs_temp .lt. qvap_deep) then
+                                                pdqvaplsc(1,k,igcm_generic_vap)  = (0.99*zqs_temp - pq(1,k,igcm_generic_vap))/tau - pdq(1,k,igcm_generic_vap)
+                                        endif
+                                enddo
+
+                                pdqliqlsc(1:ngrid,:,igcm_generic_ice) = 0.
+                                pdtlsc(1:ngrid,:)  = 0.
+                        endif
+
                         if (qvap_deep >= 0.) then
+                                if (ngrid.eq.1) then ! if 1D
+                                        tau=3*24*3600  ! tau must not be lower than the physical step time. In 1D time step is very long
+                                else
+                                        tau=3600 ! for 3D
+                                endif
                                 !brings lower generic vapor ratio to a fixed value.
                                 ! tau is in seconds and must not be lower than the physical step time.
                                 pdqvaplsc(1:ngrid,1,igcm_generic_vap) = (qvap_deep - pq(1:ngrid,1,igcm_generic_vap))/tau - pdq(1:ngrid,1,igcm_generic_vap)
                         endif
+                        if (qvap_top >= 0.) then
+                                if (ngrid.eq.1) then ! if 1D
+                                        tau=3*24*3600  ! tau must not be lower than the physical step time. In 1D time step is very long
+                                else
+                                        tau=3600 ! for 3D
+                                endif
+                                !brings lower generic vapor ratio to a fixed value.
+                                ! tau is in seconds and must not be lower than the physical step time.
+                                pdqvaplsc(1:ngrid,nlayer,igcm_generic_vap) = (qvap_top - pq(1:ngrid,nlayer,igcm_generic_vap))/tau - pdq(1:ngrid,nlayer,igcm_generic_vap)
+                        endif
                 endif !if(call_ice_vap_generic)
         enddo ! iq=1,nq
