1 | SUBROUTINE stratosphere_mask(t_seri, pplay, xlat) |
---|
2 | |
---|
3 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
4 | ! |
---|
5 | ! determination of tropopause height and temperature from gridded temperature data |
---|
6 | ! |
---|
7 | ! reference: Reichler, T., M. Dameris, and R. Sausen (2003): |
---|
8 | ! modified: 6/28/06 tjr |
---|
9 | ! adapted to LMDZ by C. Kleinschmitt (2016-02-15) |
---|
10 | ! |
---|
11 | ! input: temp(nlon,nlat,nlev) 3D-temperature field |
---|
12 | ! ps(nlon,nlat) 2D-surface pressure field |
---|
13 | ! zs(nlon,nlat) 2D-surface height |
---|
14 | ! nlon grid points in x |
---|
15 | ! nlat grid points in y |
---|
16 | ! pfull(nlon,nlat,nlev) full pressure levels in Pa |
---|
17 | ! plimu upper limit for tropopause pressure |
---|
18 | ! pliml lower limit for tropopause pressure |
---|
19 | ! gamma tropopause criterion, e.g. -0.002 K/m |
---|
20 | ! |
---|
21 | ! output: tp(nlon, nlat) tropopause pressure in Pa, -999. if undefined |
---|
22 | ! ttp(nlon, nlat) tropopause temperature in K, -999. if undefined |
---|
23 | ! ztp(nlon, nlat) tropopause height in m, -999. if undefined |
---|
24 | ! tperr # of undetermined values |
---|
25 | ! |
---|
26 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
27 | |
---|
28 | USE dimphy |
---|
29 | USE phys_local_var_mod, ONLY: stratomask |
---|
30 | #ifdef CPP_StratAer |
---|
31 | USE phys_local_var_mod, ONLY: p_tropopause |
---|
32 | #endif |
---|
33 | |
---|
34 | IMPLICIT NONE |
---|
35 | |
---|
36 | REAL,DIMENSION(klon,klev),INTENT(IN) :: t_seri ! Temperature |
---|
37 | REAL,DIMENSION(klon,klev),INTENT(IN) :: pplay ! pression pour le mileu de chaque couche (en Pa) |
---|
38 | REAL,DIMENSION(klon),INTENT(IN) :: xlat ! latitudes pour chaque point |
---|
39 | |
---|
40 | REAL, PARAMETER :: plimu=45000. |
---|
41 | REAL, PARAMETER :: pliml=7500. |
---|
42 | REAL, PARAMETER :: gamma=-0.002 |
---|
43 | LOGICAL, PARAMETER :: dofill=.true. |
---|
44 | REAL,DIMENSION(klon) :: tp, ttp, ztp |
---|
45 | REAL,DIMENSION(klev) :: t, p |
---|
46 | INTEGER :: tperr, i, k, invert, ifil |
---|
47 | REAL :: ptrp, ttrp, ztrp, psrf, zsrf, pi |
---|
48 | |
---|
49 | pi = 4.*ATAN(1.) |
---|
50 | |
---|
51 | tperr = 0 |
---|
52 | DO i=1,klon |
---|
53 | DO k=1,klev |
---|
54 | t(k)=t_seri(i,klev+1-k) |
---|
55 | p(k)=pplay(i,klev+1-k) |
---|
56 | ENDDO |
---|
57 | psrf=pplay(i,1) |
---|
58 | zsrf=0.0 |
---|
59 | call twmo(klev, t, p, psrf, zsrf, plimu, pliml, gamma, ptrp, ttrp, ztrp) |
---|
60 | tp(i)=ptrp |
---|
61 | ttp(i)=ttrp |
---|
62 | ztp(i)=ztrp |
---|
63 | IF (ptrp.lt.0.0) THEN |
---|
64 | tperr = tperr+1 |
---|
65 | ENDIF |
---|
66 | ENDDO |
---|
67 | |
---|
68 | ! fill holes |
---|
69 | IF (dofill) THEN |
---|
70 | ifil=0 |
---|
71 | DO i=1,klon |
---|
72 | IF (tp(i).lt.-990.) THEN |
---|
73 | !set missing values to very simple profile (neighbour averaging too expensive in LMDZ) |
---|
74 | tp(i)=50000.-20000.*cos(xlat(i)/360.*2.*pi) |
---|
75 | ifil=ifil+1 |
---|
76 | ENDIF |
---|
77 | ENDDO |
---|
78 | ! |
---|
79 | IF (ifil.ne.tperr) THEN |
---|
80 | CALL abort_physic('stratosphere_mask', 'inconsistency',1) |
---|
81 | ENDIF |
---|
82 | ENDIF |
---|
83 | ! |
---|
84 | DO i=1, klon |
---|
85 | DO k=1, klev |
---|
86 | IF (pplay(i,k).LT.tp(i)) THEN |
---|
87 | stratomask(i,k)=1.0 |
---|
88 | ELSE |
---|
89 | stratomask(i,k)=0.0 |
---|
90 | ENDIF |
---|
91 | ENDDO |
---|
92 | ENDDO |
---|
93 | |
---|
94 | !--this is only diagnosedd in the case of StratAer |
---|
95 | !--but it could be useful to LMDz |
---|
96 | #ifdef CPP_StratAer |
---|
97 | p_tropopause(:)=tp(:) |
---|
98 | #endif |
---|
99 | |
---|
100 | IF (ifil.gt.0) THEN |
---|
101 | print *,'Tropopause: number of undetermined values =', ifil |
---|
102 | ENDIF |
---|
103 | |
---|
104 | RETURN |
---|
105 | END SUBROUTINE stratosphere_mask |
---|
106 | |
---|
107 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
108 | ! twmo |
---|
109 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
110 | |
---|
111 | subroutine twmo(level, t, p, ps, zs, plimu, pliml, gamma, ptrp, ttrp, ztrp) |
---|
112 | |
---|
113 | implicit none |
---|
114 | |
---|
115 | include "YOMCST.h" |
---|
116 | |
---|
117 | integer,intent(in) :: level |
---|
118 | real,intent(in),dimension(level):: t, p |
---|
119 | real,intent(in) :: plimu, pliml, gamma, ps, zs |
---|
120 | real,intent(out) :: ptrp, ttrp, ztrp |
---|
121 | |
---|
122 | real,parameter :: deltaz = 2000.0 |
---|
123 | |
---|
124 | real :: faktor |
---|
125 | real :: pmk, pm, a, b, tm, dtdp, dtdz, dlnp, tdlnp |
---|
126 | real :: ag, bg, ptph, ttph, a0, b0 |
---|
127 | real :: pm0, tm0, pmk0, dtdz0 |
---|
128 | real :: p2km, asum, aquer |
---|
129 | real :: pmk2, pm2, a2, b2, tm2, dtdp2, dtdz2 |
---|
130 | integer :: icount, jj, j |
---|
131 | |
---|
132 | ptrp=-999.0 |
---|
133 | ttrp=-999.0 |
---|
134 | ztrp=-999.0 |
---|
135 | |
---|
136 | faktor = -RG/R |
---|
137 | |
---|
138 | do j=level,2,-1 |
---|
139 | |
---|
140 | ! dt/dz |
---|
141 | pmk= 0.5 * (p(j-1)**rkappa+p(j)**rkappa) ! p**k at half level |
---|
142 | pm = pmk**(1./rkappa) ! p at half level |
---|
143 | a = (t(j-1)-t(j))/(p(j-1)**rkappa-p(j)**rkappa) ! dT/dp^k |
---|
144 | b = t(j)-(a*p(j)**rkappa) |
---|
145 | tm = a * pmk + b ! T at half level |
---|
146 | dtdp = a * rkappa * pm**(rkappa-1.) ! dT/dp at half level |
---|
147 | dtdz = faktor*dtdp*pm/tm ! dT/dz at half level |
---|
148 | |
---|
149 | ! dt/dz valid? |
---|
150 | if (j.eq.level) go to 999 ! no, start level, initialize first |
---|
151 | if (dtdz.le.gamma) go to 999 ! no, dt/dz < -2 K/km |
---|
152 | if (dtdz0.gt.gamma) go to 999 ! no, dt/dz below > -2 K/km |
---|
153 | if (pm.gt.plimu) go to 999 ! no, pm too low |
---|
154 | |
---|
155 | ! dtdz is valid, calculate tropopause pressure ptph |
---|
156 | ag = (dtdz-dtdz0) / (pmk-pmk0) |
---|
157 | bg = dtdz0 - (ag * pmk0) |
---|
158 | ptph = exp(log((gamma-bg)/ag)/rkappa) |
---|
159 | |
---|
160 | ! calculate temperature at this ptph assuming linear gamma |
---|
161 | ! interpolation |
---|
162 | ttph = tm0 |
---|
163 | ttph = ttph - (bg * log(pm0) + ag * (pm0**rkappa) /rkappa) / faktor*t(j) |
---|
164 | ttph = ttph + (bg * log(ptph) + ag * (ptph**rkappa)/rkappa) / faktor*t(j) |
---|
165 | |
---|
166 | if (ptph.lt.pliml) go to 999 |
---|
167 | if (ptph.gt.plimu) go to 999 |
---|
168 | |
---|
169 | ! 2nd test: dtdz above 2 km must not exceed gamma |
---|
170 | p2km = ptph + deltaz*(pm/tm)*faktor ! p at ptph + 2km |
---|
171 | asum = 0.0 ! dtdz above |
---|
172 | icount = 0 ! number of levels above |
---|
173 | |
---|
174 | ! test until apm < p2km |
---|
175 | do jj=j,2,-1 |
---|
176 | |
---|
177 | pmk2 = .5 * (p(jj-1)**rkappa+p(jj)**rkappa) ! p mean ^kappa |
---|
178 | pm2 = pmk2**(1/rkappa) ! p mean |
---|
179 | if(pm2.gt.ptph) go to 110 ! doesn't happen |
---|
180 | if(pm2.lt.p2km) go to 888 ! ptropo is valid |
---|
181 | |
---|
182 | a2 = (t(jj-1)-t(jj)) ! a |
---|
183 | a2 = a2/(p(jj-1)**rkappa-p(jj)**rkappa) |
---|
184 | b2 = t(jj)-(a2*p(jj)**rkappa) ! b |
---|
185 | tm2 = a2 * pmk2 + b2 ! T mean |
---|
186 | dtdp2 = a2 * rkappa * (pm2**(rkappa-1)) ! dt/dp |
---|
187 | dtdz2 = faktor*dtdp2*pm2/tm2 |
---|
188 | asum = asum+dtdz2 |
---|
189 | icount = icount+1 |
---|
190 | aquer = asum/float(icount) ! dt/dz mean |
---|
191 | |
---|
192 | ! discard ptropo ? |
---|
193 | if (aquer.le.gamma) go to 999 ! dt/dz above < gamma |
---|
194 | |
---|
195 | 110 continue |
---|
196 | enddo ! test next level |
---|
197 | |
---|
198 | 888 continue ! ptph is valid |
---|
199 | ptrp = ptph |
---|
200 | ttrp = ttph |
---|
201 | |
---|
202 | ! now calculate height of tropopause by integrating hypsometric equation |
---|
203 | ! from ps to ptrp |
---|
204 | ! linearly interpolate in p (results are identical to p^kappa) |
---|
205 | |
---|
206 | jj = LEVEL ! bottom |
---|
207 | do while ((P(jj).gt.PS) .or. (T(jj).lt.100)) ! T must be valid too |
---|
208 | jj=jj-1 |
---|
209 | enddo |
---|
210 | |
---|
211 | DLNP = log(PS/P(jj)) ! from surface pressure |
---|
212 | TM = T(jj) ! take TM of lowest level (better: extrapolate) |
---|
213 | TDLNP = TM*DLNP |
---|
214 | |
---|
215 | do while ( (JJ.ge.2) .and. (PTRP.lt.P(jj-1)) ) |
---|
216 | DLNP = log(P(jj)/P(jj-1)) |
---|
217 | TM = 0.5 * (T(jj) + T(jj-1)) |
---|
218 | TDLNP = TDLNP + TM*DLNP |
---|
219 | JJ=JJ-1 |
---|
220 | enddo |
---|
221 | |
---|
222 | DLNP = log(P(jj)/PTRP) ! up to tropopause pressure |
---|
223 | TM = 0.5 * (T(jj) + TTRP) ! use TTRP to get TM of this level |
---|
224 | TDLNP = TDLNP + TM*DLNP |
---|
225 | |
---|
226 | ZTRP = ZS + TDLNP*R/RG |
---|
227 | |
---|
228 | if (ZTRP .lt. 0) then |
---|
229 | print*,ZTRP |
---|
230 | print*,PS |
---|
231 | print*,P |
---|
232 | print*,T |
---|
233 | print*,ZS |
---|
234 | stop |
---|
235 | endif |
---|
236 | |
---|
237 | return |
---|
238 | |
---|
239 | 999 continue ! continue search at next higher level |
---|
240 | tm0 = tm |
---|
241 | pm0 = pm |
---|
242 | pmk0 = pmk |
---|
243 | dtdz0 = dtdz |
---|
244 | a0 = a |
---|
245 | b0 = b |
---|
246 | |
---|
247 | enddo |
---|
248 | |
---|
249 | ! no tropopouse found |
---|
250 | return |
---|
251 | end subroutine twmo |
---|