[2772] | 1 | ! |
---|
| 2 | ! $Id: stratosphere_mask.f90 5285 2024-10-28 13:33:29Z evignon $ |
---|
| 3 | ! |
---|
[3123] | 4 | SUBROUTINE stratosphere_mask(missing_val, pphis, t_seri, pplay, xlat) |
---|
[2527] | 5 | |
---|
| 6 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 7 | ! |
---|
| 8 | ! determination of tropopause height and temperature from gridded temperature data |
---|
| 9 | ! |
---|
[3119] | 10 | ! reference: Reichler, T., M. Dameris, and R. Sausen (GRL, 10.1029/2003GL018240, 2003) |
---|
[2527] | 11 | ! modified: 6/28/06 tjr |
---|
| 12 | ! adapted to LMDZ by C. Kleinschmitt (2016-02-15) |
---|
[3119] | 13 | ! committed to LMDz by O. Boucher (2016) with a mistake |
---|
| 14 | ! mistake corrected by O. Boucher (2017-12-11) |
---|
[2527] | 15 | ! |
---|
[3119] | 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 |
---|
[2527] | 25 | ! |
---|
[3119] | 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 |
---|
[2527] | 31 | ! |
---|
| 32 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 33 | |
---|
| 34 | USE dimphy |
---|
[2536] | 35 | USE phys_local_var_mod, ONLY: stratomask |
---|
[2992] | 36 | USE phys_local_var_mod, ONLY: p_tropopause, z_tropopause, t_tropopause |
---|
[2772] | 37 | USE print_control_mod, ONLY: lunout, prt_level |
---|
[2527] | 38 | |
---|
[5285] | 39 | USE yomcst_mod_h |
---|
[2527] | 40 | IMPLICIT NONE |
---|
| 41 | |
---|
[3123] | 42 | |
---|
[5274] | 43 | |
---|
[2992] | 44 | REAL, INTENT(IN) :: missing_val ! missing value, also XIOS |
---|
[3123] | 45 | REAL,DIMENSION(klon),INTENT(IN) :: pphis ! Geopotentiel de surface |
---|
[2527] | 46 | REAL,DIMENSION(klon,klev),INTENT(IN) :: t_seri ! Temperature |
---|
| 47 | REAL,DIMENSION(klon,klev),INTENT(IN) :: pplay ! pression pour le mileu de chaque couche (en Pa) |
---|
| 48 | REAL,DIMENSION(klon),INTENT(IN) :: xlat ! latitudes pour chaque point |
---|
| 49 | |
---|
| 50 | REAL, PARAMETER :: plimu=45000. |
---|
| 51 | REAL, PARAMETER :: pliml=7500. |
---|
| 52 | REAL, PARAMETER :: gamma=-0.002 |
---|
| 53 | LOGICAL, PARAMETER :: dofill=.true. |
---|
[2992] | 54 | REAL,DIMENSION(klon) :: tp |
---|
[2527] | 55 | REAL,DIMENSION(klev) :: t, p |
---|
[2992] | 56 | INTEGER :: i, k, ifil |
---|
[2527] | 57 | REAL :: ptrp, ttrp, ztrp, psrf, zsrf, pi |
---|
| 58 | |
---|
| 59 | pi = 4.*ATAN(1.) |
---|
| 60 | |
---|
[2992] | 61 | !--computing tropopause |
---|
[2527] | 62 | DO 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) |
---|
[3123] | 68 | zsrf=pphis(i)/RG !--altitude de la surface |
---|
[2992] | 69 | call twmo(missing_val, klev, t, p, psrf, zsrf, plimu, pliml, gamma, ptrp, ttrp, ztrp) |
---|
[2527] | 70 | tp(i)=ptrp |
---|
[2992] | 71 | p_tropopause(i)=ptrp |
---|
| 72 | z_tropopause(i)=ztrp |
---|
| 73 | t_tropopause(i)=ttrp |
---|
[2527] | 74 | ENDDO |
---|
| 75 | |
---|
[2992] | 76 | !--filling holes in tp but not in p_tropopause |
---|
[2527] | 77 | IF (dofill) THEN |
---|
| 78 | ifil=0 |
---|
| 79 | DO i=1,klon |
---|
[2992] | 80 | IF (ABS(tp(i)/missing_val-1.0).LT.0.01) THEN |
---|
[2527] | 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 | ! |
---|
| 87 | ENDIF |
---|
| 88 | ! |
---|
| 89 | DO i=1, klon |
---|
| 90 | DO k=1, klev |
---|
| 91 | IF (pplay(i,k).LT.tp(i)) THEN |
---|
[2536] | 92 | stratomask(i,k)=1.0 |
---|
[2527] | 93 | ELSE |
---|
[2536] | 94 | stratomask(i,k)=0.0 |
---|
[2527] | 95 | ENDIF |
---|
| 96 | ENDDO |
---|
| 97 | ENDDO |
---|
| 98 | |
---|
[2992] | 99 | IF (ifil.GT.0 .AND. prt_level >5) THEN |
---|
[2772] | 100 | write(lunout,*)'Tropopause: number of undetermined values =', ifil |
---|
[2527] | 101 | ENDIF |
---|
| 102 | |
---|
| 103 | RETURN |
---|
| 104 | END SUBROUTINE stratosphere_mask |
---|
| 105 | |
---|
| 106 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 107 | ! twmo |
---|
| 108 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 109 | |
---|
[2992] | 110 | subroutine twmo(missing_val, level, t, p, ps, zs, plimu, pliml, gamma, ptrp, ttrp, ztrp) |
---|
[2527] | 111 | |
---|
[3119] | 112 | ! reference: Reichler, T., M. Dameris, and R. Sausen (GRL, 10.1029/2003GL018240, 2003) |
---|
| 113 | |
---|
[5285] | 114 | USE yomcst_mod_h |
---|
[2527] | 115 | implicit none |
---|
| 116 | |
---|
| 117 | |
---|
[5274] | 118 | |
---|
[2527] | 119 | integer,intent(in) :: level |
---|
[2992] | 120 | real,intent(in) :: missing_val |
---|
[2527] | 121 | real,intent(in),dimension(level):: t, p |
---|
| 122 | real,intent(in) :: plimu, pliml, gamma, ps, zs |
---|
| 123 | real,intent(out) :: ptrp, ttrp, ztrp |
---|
| 124 | |
---|
| 125 | real,parameter :: deltaz = 2000.0 |
---|
| 126 | |
---|
| 127 | real :: faktor |
---|
| 128 | real :: pmk, pm, a, b, tm, dtdp, dtdz, dlnp, tdlnp |
---|
| 129 | real :: ag, bg, ptph, ttph, a0, b0 |
---|
| 130 | real :: pm0, tm0, pmk0, dtdz0 |
---|
| 131 | real :: p2km, asum, aquer |
---|
| 132 | real :: pmk2, pm2, a2, b2, tm2, dtdp2, dtdz2 |
---|
| 133 | integer :: icount, jj, j |
---|
| 134 | |
---|
[2992] | 135 | ptrp=missing_val |
---|
| 136 | ttrp=missing_val |
---|
| 137 | ztrp=missing_val |
---|
[2527] | 138 | |
---|
[3119] | 139 | faktor = -RG/RD |
---|
[2527] | 140 | |
---|
| 141 | do 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 | |
---|
| 198 | 110 continue |
---|
| 199 | enddo ! test next level |
---|
| 200 | |
---|
| 201 | 888 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 | |
---|
| 209 | jj = LEVEL ! bottom |
---|
| 210 | do while ((P(jj).gt.PS) .or. (T(jj).lt.100)) ! T must be valid too |
---|
| 211 | jj=jj-1 |
---|
| 212 | enddo |
---|
| 213 | |
---|
| 214 | DLNP = log(PS/P(jj)) ! from surface pressure |
---|
| 215 | TM = T(jj) ! take TM of lowest level (better: extrapolate) |
---|
| 216 | TDLNP = TM*DLNP |
---|
| 217 | |
---|
| 218 | do 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 |
---|
| 223 | enddo |
---|
| 224 | |
---|
| 225 | DLNP = log(P(jj)/PTRP) ! up to tropopause pressure |
---|
| 226 | TM = 0.5 * (T(jj) + TTRP) ! use TTRP to get TM of this level |
---|
| 227 | TDLNP = TDLNP + TM*DLNP |
---|
| 228 | |
---|
[3119] | 229 | ZTRP = ZS + TDLNP*RD/RG |
---|
[2527] | 230 | |
---|
[3119] | 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 |
---|
[2527] | 239 | |
---|
| 240 | return |
---|
| 241 | |
---|
| 242 | 999 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 | |
---|
| 250 | enddo |
---|
| 251 | |
---|
| 252 | ! no tropopouse found |
---|
| 253 | return |
---|
| 254 | end subroutine twmo |
---|