source: LMDZ6/trunk/libf/phylmd/stratosphere_mask.f90 @ 5327

Last change on this file since 5327 was 5285, checked in by abarral, 3 weeks ago

As discussed internally, remove generic ONLY: ... for new _mod_h modules

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