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

Last change on this file since 1255 was 1016, checked in by jleconte, 11 years ago

07/08/2013 == JL

  • Water cycle in double precision (largescale+moistadj)
  • Improved wate rayleigh.
  • First step for rayleigh with variable species. Now, just need to change optcv.
  • changed some interpolation indices in callcorrk to limit dependency of OLR on the number of layers
File size: 6.2 KB
Line 
1      subroutine largescale(ngrid,nq,ptimestep, pplev, pplay, pt, pq,   &
2                        pdt, pdq, pdtlsc, pdqvaplsc, pdqliqlsc, rneb)
3
4
5!     to use  'getin'
6      use ioipsl_getincom
7      use watercommon_h, only : RLVTT, RCPD, RVTMP2,  &
8          T_h2O_ice_clouds,T_h2O_ice_liq,Psat_waterDP,Lcpdqsat_waterDP
9      USE tracer_h
10      IMPLICIT none
11
12!==================================================================
13!     
14!     Purpose
15!     -------
16!     Calculates large-scale (stratiform) H2O condensation.
17!     
18!     Authors
19!     -------
20!     Adapted from the LMDTERRE code by R. Wordsworth (2009)
21!     Original author Z. X. Li (1993)
22!     
23!==================================================================
24
25#include "dimensions.h"
26#include "dimphys.h"
27#include "comcstfi.h"
28
29#include "callkeys.h"
30
31      INTEGER ngrid,nq
32
33!     Arguments
34      REAL ptimestep                 ! intervalle du temps (s)
35      REAL pplev(ngrid,nlayermx+1) ! pression a inter-couche
36      REAL pplay(ngrid,nlayermx)   ! pression au milieu de couche
37      REAL pt(ngrid,nlayermx)      ! temperature (K)
38      REAL pq(ngrid,nlayermx,nq) ! tracer mixing ratio (kg/kg)
39      REAL pdt(ngrid,nlayermx)     ! physical temperature tenedency (K/s)
40      REAL pdq(ngrid,nlayermx,nq)! physical tracer tenedency (K/s)
41      REAL pdtlsc(ngrid,nlayermx)  ! incrementation de la temperature (K)
42      REAL pdqvaplsc(ngrid,nlayermx) ! incrementation de la vapeur d'eau
43      REAL pdqliqlsc(ngrid,nlayermx) ! incrementation de l'eau liquide
44      REAL rneb(ngrid,nlayermx)    ! fraction nuageuse
45
46
47!     Options du programme
48      REAL, SAVE :: ratqs   ! determine largeur de la distribution de vapeur
49
50!     Variables locales
51      REAL CBRT
52      EXTERNAL CBRT
53      INTEGER i, k , nn
54      INTEGER,PARAMETER :: nitermax=5000
55      DOUBLE PRECISION,PARAMETER :: alpha=.1,qthreshold=1.d-8
56      ! JL13: if "careful, T<Tmin in psat water" appears often, you may want to stabilise the model by
57      !                   decreasing alpha and increasing nitermax accordingly
58      DOUBLE PRECISION zt(ngrid), zq(ngrid)
59      DOUBLE PRECISION zcond(ngrid),zcond_iter
60      DOUBLE PRECISION zdelq(ngrid)
61      DOUBLE PRECISION zqs(ngrid), zdqs(ngrid)
62      DOUBLE PRECISION local_p,psat_tmp,dlnpsat_tmp,Lcp
63     
64! evaporation calculations
65      REAL dqevap(ngrid,nlayermx),dtevap(ngrid,nlayermx)     
66      REAL qevap(ngrid,nlayermx,nq)
67      REAL tevap(ngrid,nlayermx)
68
69      DOUBLE PRECISION zx_q(ngrid)
70      LOGICAL,SAVE :: firstcall=.true.
71
72
73      IF (firstcall) THEN
74
75         write(*,*) "value for ratqs? "
76         ratqs=0.2 ! default value
77         call getin("ratqs",ratqs)
78         write(*,*) " ratqs = ",ratqs
79
80         firstcall = .false.
81      ENDIF
82
83!     GCM -----> subroutine variables, initialisation of outputs
84
85      pdtlsc(1:ngrid,1:nlayermx)  = 0.0
86      pdqvaplsc(1:ngrid,1:nlayermx)  = 0.0
87      pdqliqlsc(1:ngrid,1:nlayermx) = 0.0
88      rneb(1:ngrid,1:nlayermx) = 0.0
89      Lcp=RLVTT/RCPD
90
91
92      ! Evaporate cloud water/ice
93      call evap(ngrid,nq,ptimestep,pt,pq,pdq,pdt,dqevap,dtevap,qevap,tevap)
94      ! note: we use qevap but not tevap in largescale/moistadj
95            ! otherwise is a big mess
96
97
98!  Boucle verticale (du haut vers le bas)
99   DO k = nlayermx, 1, -1
100
101      zt(1:ngrid)=pt(1:ngrid,k)+(pdt(1:ngrid,k)+dtevap(1:ngrid,k))*ptimestep
102      zq(1:ngrid)=qevap(1:ngrid,k,igcm_h2o_vap) !liquid water is included in qevap
103
104!     Calculer la vapeur d'eau saturante et
105!     determiner la condensation partielle
106      DO i = 1, ngrid
107
108         local_p=pplay(i,k)
109         if(zt(i).le.15.) then
110            print*,'in lsc',i,k,zt(i)
111!           zt(i)=15.   ! check too low temperatures
112         endif
113         call Psat_waterDP(zt(i),local_p,psat_tmp,zqs(i))
114 
115         zdelq(i) = MAX(MIN(ratqs * zq(i),1.-zq(i)),1.d-12)
116         rneb(i,k) = (zq(i)+zdelq(i)-zqs(i)) / (2.0*zdelq(i))
117         if (rneb(i,k).lt.0.) then  !no clouds
118
119            rneb(i,k)=0.
120            zcond(i)=0.
121
122         else if ((rneb(i,k).gt.0.99).or.(ratqs.lt.1.e-6)) then    !complete cloud cover, we start without evaporating
123            rneb(i,k)=1.
124            zt(i)=pt(i,k)+pdt(i,k)*ptimestep
125            zx_q(i) = pq(i,k,igcm_h2o_vap)+pdq(i,k,igcm_h2o_vap)*ptimestep
126            dqevap(i,k)=0.
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_waterDP(zt(i),local_p,psat_tmp,zqs(i))
131               call Lcpdqsat_waterDP(zt(i),local_p,psat_tmp,zqs(i),zdqs(i),dlnpsat_tmp)
132               zcond_iter = alpha*(zx_q(i)-zqs(i))/(1.d0+zdqs(i))         
133                  !zcond can be negative here
134               zx_q(i) = zx_q(i) - zcond_iter
135               zcond(i) = zcond(i) + zcond_iter
136               zt(i) = zt(i) + zcond_iter*Lcp
137               if (ABS(zcond_iter/alpha/zqs(i)).lt.qthreshold) exit
138!              if (ABS(zcond_iter/alpha).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_h2o_ice)+pdq(i,k,igcm_h2o_ice)*ptimestep))
142
143         else   !standard case     
144
145            zx_q(i) = (zq(i)+zdelq(i)+zqs(i))/2.0d0 !water vapor in cloudy sky
146!           iterative process to stabilize the scheme when large water amounts JL12
147            zcond(i) = 0.0d0
148            Do nn=1,nitermax 
149               call Lcpdqsat_waterDP(zt(i),local_p,psat_tmp,zqs(i),zdqs(i),dlnpsat_tmp)
150               zcond_iter = MAX(0.0d0,alpha*(zx_q(i)-zqs(i))/(1.d0+zdqs(i)))       
151                  !zcond always postive! cannot evaporate clouds!
152                  !this is why we must reevaporate before largescale
153               zx_q(i) = zx_q(i) - zcond_iter
154               zcond(i) = zcond(i) + zcond_iter
155               if (ABS(zcond_iter/alpha/zqs(i)).lt.qthreshold) exit
156!              if (ABS(zcond_iter/alpha).lt.qthreshold) exit
157               zt(i) = zt(i) + zcond_iter*Lcp*rneb(i,k)
158               call Psat_waterDP(zt(i),local_p,psat_tmp,zqs(i))
159               if (nn.eq.nitermax) print*,'itermax in largescale'
160            End do ! niter
161
162         Endif
163
164         zcond(i) = zcond(i)*rneb(i,k)/ptimestep ! JL12
165
166      ENDDO
167
168!     Tendances de t et q
169         pdqvaplsc(1:ngrid,k)  = dqevap(1:ngrid,k) - zcond(1:ngrid)
170         pdqliqlsc(1:ngrid,k) = - pdqvaplsc(1:ngrid,k)
171         pdtlsc(1:ngrid,k)  = pdqliqlsc(1:ngrid,k)*real(Lcp)
172
173   Enddo ! k= nlayermx, 1, -1
174 
175
176      return
177      end
Note: See TracBrowser for help on using the repository browser.