source: trunk/LMDZ.GENERIC/libf/phystd/largescale.F90 @ 3523

Last change on this file since 3523 was 2871, checked in by jleconte, 23 months ago

Improved rain evaporation for les + correction in callkeys

File size: 7.1 KB
RevLine 
[1308]1      subroutine largescale(ngrid,nlayer,nq,ptimestep, pplev, pplay,    &
2                    pt, pq, pdt, pdq, pdtlsc, pdqvaplsc, pdqliqlsc, rneb)
[728]3
[1016]4
[1521]5      use ioipsl_getin_p_mod, only: getin_p
[728]6      use watercommon_h, only : RLVTT, RCPD, RVTMP2,  &
[1993]7          T_h2O_ice_clouds,T_h2O_ice_liq,Psat_water,Lcpdqsat_water
[787]8      USE tracer_h
[728]9      IMPLICIT none
10
11!==================================================================
12!     
13!     Purpose
14!     -------
15!     Calculates large-scale (stratiform) H2O condensation.
16!     
17!     Authors
18!     -------
19!     Adapted from the LMDTERRE code by R. Wordsworth (2009)
20!     Original author Z. X. Li (1993)
21!     
22!==================================================================
23
[1308]24      INTEGER ngrid,nlayer,nq
[728]25
26!     Arguments
27      REAL ptimestep                 ! intervalle du temps (s)
[1308]28      REAL pplev(ngrid,nlayer+1) ! pression a inter-couche
29      REAL pplay(ngrid,nlayer)   ! pression au milieu de couche
30      REAL pt(ngrid,nlayer)      ! temperature (K)
31      REAL pq(ngrid,nlayer,nq) ! tracer mixing ratio (kg/kg)
32      REAL pdt(ngrid,nlayer)     ! physical temperature tenedency (K/s)
33      REAL pdq(ngrid,nlayer,nq)! physical tracer tenedency (K/s)
34      REAL pdtlsc(ngrid,nlayer)  ! incrementation de la temperature (K)
35      REAL pdqvaplsc(ngrid,nlayer) ! incrementation de la vapeur d'eau
36      REAL pdqliqlsc(ngrid,nlayer) ! incrementation de l'eau liquide
37      REAL rneb(ngrid,nlayer)    ! fraction nuageuse
[728]38
39
40!     Options du programme
[1016]41      REAL, SAVE :: ratqs   ! determine largeur de la distribution de vapeur
[2871]42      REAL, SAVE :: qvap_deep   ! deep mixing ratio of water vapor when simulating bottom less planets
43!$OMP THREADPRIVATE(ratqs, qvap_deep)
[728]44
45!     Variables locales
46      REAL CBRT
47      EXTERNAL CBRT
48      INTEGER i, k , nn
[1016]49      INTEGER,PARAMETER :: nitermax=5000
50      DOUBLE PRECISION,PARAMETER :: alpha=.1,qthreshold=1.d-8
[875]51      ! JL13: if "careful, T<Tmin in psat water" appears often, you may want to stabilise the model by
52      !                   decreasing alpha and increasing nitermax accordingly
[1993]53      DOUBLE PRECISION zq(ngrid)
[1016]54      DOUBLE PRECISION zcond(ngrid),zcond_iter
55      DOUBLE PRECISION zdelq(ngrid)
[1993]56      DOUBLE PRECISION zqs(ngrid)
57      real zt(ngrid),local_p,psat_tmp,dlnpsat_tmp,Lcp,zqs_temp,zdqs
[728]58     
59! evaporation calculations
[1308]60      REAL dqevap(ngrid,nlayer),dtevap(ngrid,nlayer)     
61      REAL qevap(ngrid,nlayer,nq)
62      REAL tevap(ngrid,nlayer)
[728]63
[1016]64      DOUBLE PRECISION zx_q(ngrid)
65      LOGICAL,SAVE :: firstcall=.true.
[1315]66!$OMP THREADPRIVATE(firstcall)
[728]67
[1016]68
69      IF (firstcall) THEN
70
71         write(*,*) "value for ratqs? "
72         ratqs=0.2 ! default value
[1315]73         call getin_p("ratqs",ratqs)
[1016]74         write(*,*) " ratqs = ",ratqs
75
[2871]76         write(*,*) "Deep water vapor mixing ratio ? (no effect if negative) "
77         qvap_deep=-1. ! default value
78         call getin_p("qvap_deep",qvap_deep)
79         write(*,*) " qvap_deep = ",qvap_deep
80
[1016]81         firstcall = .false.
82      ENDIF
83
[728]84!     GCM -----> subroutine variables, initialisation of outputs
85
[1308]86      pdtlsc(1:ngrid,1:nlayer)  = 0.0
87      pdqvaplsc(1:ngrid,1:nlayer)  = 0.0
88      pdqliqlsc(1:ngrid,1:nlayer) = 0.0
89      rneb(1:ngrid,1:nlayer) = 0.0
[1016]90      Lcp=RLVTT/RCPD
[728]91
92
93      ! Evaporate cloud water/ice
[1308]94      call evap(ngrid,nlayer,nq,ptimestep,pt,pq,pdq,pdt,dqevap,dtevap,qevap,tevap)
[728]95      ! note: we use qevap but not tevap in largescale/moistadj
96            ! otherwise is a big mess
97
98
99!  Boucle verticale (du haut vers le bas)
[1308]100   DO k = nlayer, 1, -1
[728]101
[787]102      zt(1:ngrid)=pt(1:ngrid,k)+(pdt(1:ngrid,k)+dtevap(1:ngrid,k))*ptimestep
103      zq(1:ngrid)=qevap(1:ngrid,k,igcm_h2o_vap) !liquid water is included in qevap
[728]104
105!     Calculer la vapeur d'eau saturante et
106!     determiner la condensation partielle
[787]107      DO i = 1, ngrid
[728]108
[1016]109         local_p=pplay(i,k)
[773]110         if(zt(i).le.15.) then
[786]111            print*,'in lsc',i,k,zt(i)
112!           zt(i)=15.   ! check too low temperatures
[773]113         endif
[1993]114         call Psat_water(zt(i),local_p,psat_tmp,zqs_temp)
115         zqs(i)=zqs_temp
[728]116 
[1016]117         zdelq(i) = MAX(MIN(ratqs * zq(i),1.-zq(i)),1.d-12)
[786]118         rneb(i,k) = (zq(i)+zdelq(i)-zqs(i)) / (2.0*zdelq(i))
[1830]119#ifdef MESOSCALE
120         if (rneb(i,k).lt.0.01) then  !no clouds MESO
121#else
[786]122         if (rneb(i,k).lt.0.) then  !no clouds
[1830]123#endif
[786]124
125            rneb(i,k)=0.
126            zcond(i)=0.
127
[1016]128         else if ((rneb(i,k).gt.0.99).or.(ratqs.lt.1.e-6)) then    !complete cloud cover, we start without evaporating
[786]129            rneb(i,k)=1.
130            zt(i)=pt(i,k)+pdt(i,k)*ptimestep
131            zx_q(i) = pq(i,k,igcm_h2o_vap)+pdq(i,k,igcm_h2o_vap)*ptimestep
132            dqevap(i,k)=0.
133!           iterative process to stabilize the scheme when large water amounts JL12
[1016]134            zcond(i) = 0.0d0
[786]135            Do nn=1,nitermax 
[1993]136               call Psat_water(zt(i),local_p,psat_tmp,zqs_temp)
137               zqs(i)=zqs_temp
138               call Lcpdqsat_water(zt(i),local_p,psat_tmp,zqs_temp,zdqs,dlnpsat_tmp)
139               zcond_iter = alpha*(zx_q(i)-zqs(i))/(1.d0+zdqs)     
[786]140                  !zcond can be negative here
141               zx_q(i) = zx_q(i) - zcond_iter
142               zcond(i) = zcond(i) + zcond_iter
[1016]143               zt(i) = zt(i) + zcond_iter*Lcp
144               if (ABS(zcond_iter/alpha/zqs(i)).lt.qthreshold) exit
145!              if (ABS(zcond_iter/alpha).lt.qthreshold) exit
146               if (nn.eq.nitermax) print*,'itermax in largescale'
[786]147            End do ! niter
148            zcond(i)=MAX(zcond(i),-(pq(i,k,igcm_h2o_ice)+pdq(i,k,igcm_h2o_ice)*ptimestep))
149
150         else   !standard case     
[1830]151#ifdef MESOSCALE
152            rneb(i,k)=1. !LES/MESO case
153            zx_q(i) = (zq(i)+zqs(i))/2.0d0 ! LES
154#else
[1016]155            zx_q(i) = (zq(i)+zdelq(i)+zqs(i))/2.0d0 !water vapor in cloudy sky
[1830]156#endif
[786]157!           iterative process to stabilize the scheme when large water amounts JL12
[1016]158            zcond(i) = 0.0d0
[2073]159            Do nn=1,nitermax
160               ! use zqs_temp and not zqs(i) to force type conversion
161               ! -- might not be a good solution, actually
162               ! but this is compliant with "complete cloud cover" case above
163               call Lcpdqsat_water(zt(i),local_p,psat_tmp,zqs_temp,zdqs,dlnpsat_tmp)
[1993]164               zcond_iter = MAX(0.0d0,alpha*(zx_q(i)-zqs(i))/(1.d0+zdqs))         
[786]165                  !zcond always postive! cannot evaporate clouds!
166                  !this is why we must reevaporate before largescale
167               zx_q(i) = zx_q(i) - zcond_iter
168               zcond(i) = zcond(i) + zcond_iter
[1016]169               if (ABS(zcond_iter/alpha/zqs(i)).lt.qthreshold) exit
170!              if (ABS(zcond_iter/alpha).lt.qthreshold) exit
171               zt(i) = zt(i) + zcond_iter*Lcp*rneb(i,k)
[1993]172               call Psat_water(zt(i),local_p,psat_tmp,zqs_temp)
173               zqs(i)=zqs_temp
[1016]174               if (nn.eq.nitermax) print*,'itermax in largescale'
[786]175            End do ! niter
176
[728]177         Endif
178
[786]179         zcond(i) = zcond(i)*rneb(i,k)/ptimestep ! JL12
[728]180
181      ENDDO
182
183!     Tendances de t et q
[787]184         pdqvaplsc(1:ngrid,k)  = dqevap(1:ngrid,k) - zcond(1:ngrid)
185         pdqliqlsc(1:ngrid,k) = - pdqvaplsc(1:ngrid,k)
[1993]186         pdtlsc(1:ngrid,k)  = pdqliqlsc(1:ngrid,k)*Lcp
[728]187
[1308]188   Enddo ! k= nlayer, 1, -1
[728]189
[2871]190   if (qvap_deep >= 0.) then
191      !brings lower vapor ratio to a fixed value.
192      ! tau=3600. seems too fast
193      pdqvaplsc(1:ngrid,1) = (qvap_deep - pq(1:ngrid,1,igcm_h2o_vap))/14400. - pdq(1:ngrid,1,igcm_h2o_vap)
194   endif
195
196
[728]197      end
Note: See TracBrowser for help on using the repository browser.