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