source: LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/stratosphere_mask.F90 @ 3152

Last change on this file since 3152 was 2536, checked in by oboucher, 8 years ago

Introducing stratomask diagnostic on where the stratosphere is
flag_aerosol_strat = 2 for CMIP6 strat aerosol forcing

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