[2772] | 1 | ! $Id: stratosphere_mask.F90 5158 2024-08-02 12:12:03Z fhourdin $ |
---|
[5099] | 2 | |
---|
[3123] | 3 | SUBROUTINE stratosphere_mask(missing_val, pphis, t_seri, pplay, xlat) |
---|
[2527] | 4 | |
---|
[5144] | 5 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
[5099] | 6 | |
---|
[5144] | 7 | ! determination of tropopause height and temperature from gridded temperature data |
---|
[5099] | 8 | |
---|
[5144] | 9 | ! reference: Reichler, T., M. Dameris, and R. Sausen (GRL, 10.1029/2003GL018240, 2003) |
---|
| 10 | ! modified: 6/28/06 tjr |
---|
| 11 | ! adapted to LMDZ by C. Kleinschmitt (2016-02-15) |
---|
| 12 | ! committed to LMDz by O. Boucher (2016) with a mistake |
---|
| 13 | ! mistake corrected by O. Boucher (2017-12-11) |
---|
[5099] | 14 | |
---|
[5144] | 15 | ! input: temp(nlon,nlat,nlev) 3D-temperature field |
---|
| 16 | ! ps(nlon,nlat) 2D-surface pressure field |
---|
| 17 | ! zs(nlon,nlat) 2D-surface height |
---|
| 18 | ! nlon grid points in x |
---|
| 19 | ! nlat grid points in y |
---|
| 20 | ! pfull(nlon,nlat,nlev) full pressure levels in Pa |
---|
| 21 | ! plimu upper limit for tropopause pressure |
---|
| 22 | ! pliml lower limit for tropopause pressure |
---|
| 23 | ! gamma tropopause criterion, e.g. -0.002 K/m |
---|
[5099] | 24 | |
---|
[5144] | 25 | ! output: p_tropopause(klon) tropopause pressure in Pa with missing values |
---|
| 26 | ! t_tropopause(klon) tropopause temperature in K with missing values |
---|
| 27 | ! z_tropopause(klon) tropopause height in m with missing values |
---|
| 28 | ! stratomask stratospheric mask withtout missing values |
---|
| 29 | ! ifil # of undetermined values |
---|
[5099] | 30 | |
---|
[5144] | 31 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
[2527] | 32 | |
---|
[5144] | 33 | USE dimphy |
---|
| 34 | USE phys_local_var_mod, ONLY: stratomask |
---|
| 35 | USE phys_local_var_mod, ONLY: p_tropopause, z_tropopause, t_tropopause |
---|
| 36 | USE lmdz_print_control, ONLY: lunout, prt_level |
---|
| 37 | USE lmdz_yomcst |
---|
[2527] | 38 | |
---|
[5144] | 39 | IMPLICIT NONE |
---|
[2527] | 40 | |
---|
[5144] | 41 | REAL, INTENT(IN) :: missing_val ! missing value, also XIOS |
---|
| 42 | REAL, DIMENSION(klon), INTENT(IN) :: pphis ! Geopotentiel de surface |
---|
| 43 | REAL, DIMENSION(klon, klev), INTENT(IN) :: t_seri ! Temperature |
---|
| 44 | REAL, DIMENSION(klon, klev), INTENT(IN) :: pplay ! pression pour le mileu de chaque couche (en Pa) |
---|
| 45 | REAL, DIMENSION(klon), INTENT(IN) :: xlat ! latitudes pour chaque point |
---|
[3123] | 46 | |
---|
[5144] | 47 | REAL, PARAMETER :: plimu = 45000. |
---|
| 48 | REAL, PARAMETER :: pliml = 7500. |
---|
| 49 | REAL, PARAMETER :: gamma = -0.002 |
---|
| 50 | LOGICAL, PARAMETER :: dofill = .TRUE. |
---|
| 51 | REAL, DIMENSION(klon) :: tp |
---|
| 52 | REAL, DIMENSION(klev) :: t, p |
---|
| 53 | INTEGER :: i, k, ifil |
---|
| 54 | REAL :: ptrp, ttrp, ztrp, psrf, zsrf, pi |
---|
[2527] | 55 | |
---|
[5144] | 56 | pi = 4. * ATAN(1.) |
---|
[2527] | 57 | |
---|
[5144] | 58 | !--computing tropopause |
---|
| 59 | DO i = 1, klon |
---|
| 60 | DO k = 1, klev |
---|
| 61 | t(k) = t_seri(i, klev + 1 - k) |
---|
| 62 | p(k) = pplay(i, klev + 1 - k) |
---|
| 63 | ENDDO |
---|
| 64 | psrf = pplay(i, 1) |
---|
| 65 | zsrf = pphis(i) / RG !--altitude de la surface |
---|
| 66 | CALL twmo(missing_val, klev, t, p, psrf, zsrf, plimu, pliml, gamma, ptrp, ttrp, ztrp) |
---|
| 67 | tp(i) = ptrp |
---|
| 68 | p_tropopause(i) = ptrp |
---|
| 69 | z_tropopause(i) = ztrp |
---|
| 70 | t_tropopause(i) = ttrp |
---|
[2527] | 71 | ENDDO |
---|
| 72 | |
---|
[5144] | 73 | !--filling holes in tp but not in p_tropopause |
---|
| 74 | IF (dofill) THEN |
---|
| 75 | ifil = 0 |
---|
| 76 | DO i = 1, klon |
---|
| 77 | IF (ABS(tp(i) / missing_val - 1.0)<0.01) THEN |
---|
| 78 | !set missing values to very simple profile (neighbour averaging too expensive in LMDZ) |
---|
| 79 | tp(i) = 50000. - 20000. * cos(xlat(i) / 360. * 2. * pi) |
---|
| 80 | ifil = ifil + 1 |
---|
| 81 | ENDIF |
---|
| 82 | ENDDO |
---|
| 83 | |
---|
[2527] | 84 | ENDIF |
---|
[5144] | 85 | |
---|
| 86 | DO i = 1, klon |
---|
| 87 | DO k = 1, klev |
---|
| 88 | IF (pplay(i, k)<tp(i)) THEN |
---|
| 89 | stratomask(i, k) = 1.0 |
---|
| 90 | ELSE |
---|
| 91 | stratomask(i, k) = 0.0 |
---|
| 92 | ENDIF |
---|
| 93 | ENDDO |
---|
[2527] | 94 | ENDDO |
---|
[5099] | 95 | |
---|
[5144] | 96 | IF (ifil>0 .AND. prt_level >5) THEN |
---|
| 97 | WRITE(lunout, *)'Tropopause: number of undetermined values =', ifil |
---|
[2527] | 98 | ENDIF |
---|
| 99 | |
---|
| 100 | END SUBROUTINE stratosphere_mask |
---|
| 101 | |
---|
| 102 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 103 | ! twmo |
---|
| 104 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 105 | |
---|
[5103] | 106 | SUBROUTINE twmo(missing_val, level, t, p, ps, zs, plimu, pliml, gamma, ptrp, ttrp, ztrp) |
---|
[2527] | 107 | |
---|
[5144] | 108 | ! reference: Reichler, T., M. Dameris, and R. Sausen (GRL, 10.1029/2003GL018240, 2003) |
---|
[3119] | 109 | |
---|
[5144] | 110 | USE lmdz_yomcst |
---|
[2527] | 111 | |
---|
[5144] | 112 | IMPLICIT NONE |
---|
[2527] | 113 | |
---|
[5144] | 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 |
---|
[2527] | 119 | |
---|
[5144] | 120 | REAL, parameter :: deltaz = 2000.0 |
---|
[2527] | 121 | |
---|
[5158] | 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 |
---|
[5144] | 128 | INTEGER :: icount, jj, j |
---|
[2527] | 129 | |
---|
[5144] | 130 | ptrp = missing_val |
---|
| 131 | ttrp = missing_val |
---|
| 132 | ztrp = missing_val |
---|
[2527] | 133 | |
---|
[5144] | 134 | faktor = -RG / RD |
---|
[2527] | 135 | |
---|
[5144] | 136 | DO j = level, 2, -1 |
---|
[2527] | 137 | |
---|
[5144] | 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 |
---|
[2527] | 146 | |
---|
[5144] | 147 | ! dt/dz valid? |
---|
| 148 | IF (j==level) go to 999 ! no, start level, initialize first |
---|
| 149 | IF (dtdz<=gamma) go to 999 ! no, dt/dz < -2 K/km |
---|
| 150 | IF (dtdz0>gamma) go to 999 ! no, dt/dz below > -2 K/km |
---|
| 151 | IF (pm>plimu) go to 999 ! no, pm too low |
---|
[2527] | 152 | |
---|
[5144] | 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) |
---|
[2527] | 157 | |
---|
[5144] | 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) |
---|
[2527] | 163 | |
---|
[5144] | 164 | IF (ptph<pliml) go to 999 |
---|
| 165 | IF (ptph>plimu) go to 999 |
---|
[2527] | 166 | |
---|
[5144] | 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 |
---|
[2527] | 171 | |
---|
[5144] | 172 | ! test until apm < p2km |
---|
[5158] | 173 | DO jj = j, 2, -1 |
---|
[2527] | 174 | |
---|
[5144] | 175 | pmk2 = .5 * (p(jj - 1)**rkappa + p(jj)**rkappa) ! p mean ^kappa |
---|
| 176 | pm2 = pmk2**(1 / rkappa) ! p mean |
---|
| 177 | IF(pm2>ptph) go to 110 ! doesn't happen |
---|
| 178 | IF(pm2<p2km) go to 888 ! ptropo is valid |
---|
[2527] | 179 | |
---|
[5144] | 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 |
---|
[2527] | 189 | |
---|
[5144] | 190 | ! discard ptropo ? |
---|
| 191 | IF (aquer<=gamma) go to 999 ! dt/dz above < gamma |
---|
| 192 | |
---|
| 193 | 110 continue |
---|
[2527] | 194 | enddo ! test next level |
---|
| 195 | |
---|
[5144] | 196 | 888 continue ! ptph is valid |
---|
[2527] | 197 | ptrp = ptph |
---|
| 198 | ttrp = ttph |
---|
| 199 | |
---|
[5144] | 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) |
---|
[2527] | 203 | |
---|
[5144] | 204 | jj = LEVEL ! bottom |
---|
| 205 | DO while ((P(jj)>PS) .OR. (T(jj)<100)) ! T must be valid too |
---|
| 206 | jj = jj - 1 |
---|
| 207 | END DO |
---|
[2527] | 208 | |
---|
[5144] | 209 | DLNP = log(PS / P(jj)) ! from surface pressure |
---|
| 210 | TM = T(jj) ! take TM of lowest level (better: extrapolate) |
---|
| 211 | TDLNP = TM * DLNP |
---|
[2527] | 212 | |
---|
[5144] | 213 | DO while ((JJ>=2) .AND. (PTRP<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 | END DO |
---|
[2527] | 219 | |
---|
[5144] | 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 |
---|
[2527] | 223 | |
---|
[5144] | 224 | ZTRP = ZS + TDLNP * RD / RG |
---|
[2527] | 225 | |
---|
[5144] | 226 | !!if (ZTRP .lt. 0) THEN |
---|
| 227 | !! PRINT*,'ZTRP=',ZTRP |
---|
| 228 | !! PRINT*,'PS=',PS |
---|
| 229 | !! PRINT*,'P=',P |
---|
| 230 | !! PRINT*,'T=',T |
---|
| 231 | !! PRINT*,'ZS=',ZS |
---|
| 232 | !! stop |
---|
| 233 | !!endif |
---|
[2527] | 234 | |
---|
[5144] | 235 | return |
---|
[2527] | 236 | |
---|
[5144] | 237 | 999 continue ! continue search at next higher level |
---|
[2527] | 238 | tm0 = tm |
---|
| 239 | pm0 = pm |
---|
| 240 | pmk0 = pmk |
---|
[5144] | 241 | dtdz0 = dtdz |
---|
[2527] | 242 | a0 = a |
---|
| 243 | b0 = b |
---|
| 244 | |
---|
[5144] | 245 | END DO |
---|
[2527] | 246 | |
---|
[5144] | 247 | ! no tropopouse found |
---|
[5105] | 248 | |
---|
[5103] | 249 | END SUBROUTINE twmo |
---|