source: trunk/LMDZ.GENERIC/libf/phystd/condensation_generic_mod.F90 @ 2785

Last change on this file since 2785 was 2725, checked in by aslmd, 4 years ago

switch to epsi_generic & RLVTT_generic

File size: 8.4 KB
Line 
1module condensation_generic_mod
2    implicit none
3   
4contains
5   
6    subroutine condensation_generic(ngrid,nlayer,nq,ptimestep, pplev, pplay,    &
7                pt, pq, pdt, pdq, pdtlsc, pdqvaplsc, pdqliqlsc, rneb)
8        use ioipsl_getin_p_mod, only: getin_p !-> to get the metallicity
9        use generic_cloud_common_h
10        USE tracer_h
11        USE mod_phys_lmdz_para, only: is_master
12        use generic_tracer_index_mod, only: generic_tracer_index
13        IMPLICIT none
14
15!=======================================================================
16!     
17!     Purpose
18!     -------
19!     Calculates large-scale condensation of generic tracer "tname".
20!     By convention, tname ends with the suffix "_vap", as it represents the
21!     gas phase of the generic tracer
22!     
23!     Authors
24!     -------
25!     Adapted from largescale.F90 by Lucas Teinturier & Noé Clément (2022)
26!     largescale.F90 adapted from the LMDTERRE code by R. Wordsworth (2009)
27!     Original author Z. X. Li (1993)
28!     
29!=========================================================================
30
31        INTEGER, intent(in) :: ngrid,nlayer,nq
32
33!       Arguments
34        REAL, intent(in) :: ptimestep             ! intervalle du temps (s)
35        REAL, intent(in) :: pplev(ngrid,nlayer+1) ! pression a inter-couche
36        REAL, intent(in) :: pplay(ngrid,nlayer)   ! pression au milieu de couche
37        REAL, intent(in) :: pt(ngrid,nlayer)      ! temperature (K)
38        REAL, intent(in) :: pq(ngrid,nlayer,nq)   ! tracer mixing ratio (kg/kg)
39        REAL, intent(in) :: pdt(ngrid,nlayer)     ! physical temperature tendency (K/s)
40        REAL, intent(in) :: pdq(ngrid,nlayer,nq)  ! physical tracer tendency (K/s)
41        ! CHARACTER(*), intent(in) :: tname_vap     ! name of the tracer we consider. BY convention, it ends with _vap !!!
42        REAL, intent(out) :: pdtlsc(ngrid,nlayer)  ! incrementation de la temperature (K)
43        REAL, intent(out) :: pdqvaplsc(ngrid,nlayer,nq) ! incrementation de la vapeur du traceur
44        REAL, intent(out) :: pdqliqlsc(ngrid,nlayer,nq) ! incrementation du traceur liquide
45        REAL, intent(out) :: rneb(ngrid,nlayer,nq)    ! fraction nuageuse
46
47!       Options :
48        real, save :: metallicity !metallicity of planet
49        REAL, SAVE :: qvap_deep   ! deep mixing ratio of water vapor when simulating bottom less planets
50!$OMP THREADPRIVATE(metallicity, qvap_deep)
51
52!       Local variables
53
54        ! to call only one time the ice/vap pair of a tracer
55        logical call_ice_vap_generic
56
57        INTEGER i, k , nn, iq
58        INTEGER,PARAMETER :: nitermax=5000
59        INTEGER,PARAMETER :: tau=14400.
60        DOUBLE PRECISION,PARAMETER :: alpha=.1,qthreshold=1.d-8
61        ! JL13: if "careful, T<Tmin in psat water" appears often, you may want to stabilise the model by
62        !                   decreasing alpha and increasing nitermax accordingly
63        DOUBLE PRECISION zq(ngrid)
64        DOUBLE PRECISION zcond(ngrid),zcond_iter
65        DOUBLE PRECISION zqs(ngrid)
66        real zt(ngrid),local_p,psat_tmp,dlnpsat_tmp,Lcp,zqs_temp,zdqs
67        integer igcm_generic_vap, igcm_generic_ice! index of the vap and ice of generic_tracer
68        ! CHARACTER(len=*) :: tname_ice
69        ! evaporation calculations
70        REAL dqevap(ngrid,nlayer),dtevap(ngrid,nlayer)     
71        REAL qevap(ngrid,nlayer,nq)
72        REAL tevap(ngrid,nlayer)
73
74        DOUBLE PRECISION zx_q(ngrid)
75        LOGICAL,SAVE :: firstcall=.true.
76!$OMP THREADPRIVATE(firstcall)
77        IF (firstcall) THEN
78                write(*,*) "value for metallicity? "
79                metallicity=0.0 ! default value
80                call getin_p("metallicity",metallicity)
81                write(*,*) " metallicity = ",metallicity
82
83                write(*,*) "Deep water vapor mixing ratio ? (no effect if negative) "
84                qvap_deep=-1. ! default value
85                call getin_p("qvap_deep",qvap_deep)
86                write(*,*) " qvap_deep = ",qvap_deep   
87
88                firstcall = .false.
89        ENDIF
90!       Initialisation of outputs and local variables
91        pdtlsc(1:ngrid,1:nlayer)  = 0.0
92        pdqvaplsc(1:ngrid,1:nlayer,1:nq)  = 0.0
93        pdqliqlsc(1:ngrid,1:nlayer,1:nq) = 0.0
94        dqevap(1:ngrid,1:nlayer)=0.0
95        dtevap(1:ngrid,1:nlayer)=0.0
96        qevap(1:ngrid,1:nlayer,1:nq)=0.0
97        tevap(1:ngrid,1:nlayer)=0.0
98        rneb(1:ngrid,1:nlayer,1:nq) = 0.0
99        ! Let's loop on tracers
100        do iq=1,nq
101
102                call generic_tracer_index(nq,iq,igcm_generic_vap,igcm_generic_ice,call_ice_vap_generic)
103
104                if(call_ice_vap_generic) then ! to call only one time the ice/vap pair of a tracer
105                        m=constants_mass(iq)
106                        delta_vapH=constants_delta_vapH(iq)
107                        Tref=constants_Tref(iq)
108                        Pref=constants_Pref(iq)
109                        epsi_generic=constants_epsi_generic(iq)
110                        RLVTT_generic=constants_RLVTT_generic(iq)
111                        metallicity_coeff=constants_metallicity_coeff(iq)
112
113                        Lcp=RLVTT_generic/cpp ! need to be init here
114
115                        !  Vertical loop (from top to bottom)
116                        DO k = nlayer, 1, -1
117                                zt(1:ngrid)=pt(1:ngrid,k)+pdt(1:ngrid,k)*ptimestep
118
119                                ! Computes Psat and the partial condensation
120                                DO i = 1, ngrid
121                                        local_p=pplay(i,k)
122                                        if(zt(i).le.15.) then
123                                                print*,'in lsc',i,k,zt(i)
124                                        !           zt(i)=15.   ! check too low temperatures
125                                        endif
126                                        zx_q(i) = pq(i,k,igcm_generic_vap)+pdq(i,k,igcm_generic_vap)*ptimestep
127                                        ! iterative process to stabilize the scheme when large water amounts JL12
128                                        zcond(i) = 0.0d0
129                                        Do nn=1,nitermax 
130                                                call Psat_generic(zt(i),local_p,metallicity,psat_tmp,zqs_temp)
131                                                zqs(i)=zqs_temp
132                                                call Lcpdqsat_generic(zt(i),local_p,psat_tmp,zqs_temp,zdqs,dlnpsat_tmp)
133                                                zcond_iter = alpha*(zx_q(i)-zqs(i))/(1.d0+zdqs)
134                                                !zcond can be negative here
135                                                zx_q(i) = zx_q(i) - zcond_iter
136                                                zcond(i) = zcond(i) + zcond_iter
137                                                zt(i) = zt(i) + zcond_iter*Lcp
138                                                if (ABS(zcond_iter/alpha/zqs(i)).lt.qthreshold) exit
139                                                if (nn.eq.nitermax) print*,'itermax in largescale'
140                                        End do ! niter
141                                        zcond(i)=MAX(zcond(i),-(pq(i,k,igcm_generic_ice)+pdq(i,k,igcm_generic_ice)*ptimestep))
142
143                                        if (zcond(i) .gt. 0.) then
144                                                rneb(i,k,iq)=1
145                                        else
146                                                rneb(i,k,iq)=0.
147                                        endif
148
149                                        zcond(i) = zcond(i)/ptimestep
150                                ENDDO ! i=1,ngrid
151
152                                !Tendances de t et q
153                                pdqvaplsc(1:ngrid,k,igcm_generic_vap)  = - zcond(1:ngrid)
154                                pdqliqlsc(1:ngrid,k,igcm_generic_ice) = - pdqvaplsc(1:ngrid,k,igcm_generic_vap)
155                                pdtlsc(1:ngrid,k)  = pdtlsc(1:ngrid,k) + pdqliqlsc(1:ngrid,k,igcm_generic_ice)*Lcp
156
157                        Enddo ! k= nlayer, 1, -1
158
159                        if (qvap_deep >= 0.) then
160                                !brings lower generic vapor ratio to a fixed value.
161                                ! tau=3600. seems too fast
162                                pdqvaplsc(1:ngrid,1,igcm_generic_vap) = (qvap_deep - pq(1:ngrid,1,igcm_generic_vap))/tau - pdq(1:ngrid,1,igcm_generic_vap)
163                        endif
164                endif !if(call_ice_vap_generic)
165        enddo ! iq=1,nq
166
167    end subroutine condensation_generic
168end module condensation_generic_mod
Note: See TracBrowser for help on using the repository browser.