[1682] | 1 | !> @file subsidence.f90 |
---|
[1036] | 2 | !--------------------------------------------------------------------------------! |
---|
| 3 | ! This file is part of PALM. |
---|
| 4 | ! |
---|
| 5 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 6 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 7 | ! either version 3 of the License, or (at your option) any later version. |
---|
| 8 | ! |
---|
| 9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 10 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 11 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 12 | ! |
---|
| 13 | ! You should have received a copy of the GNU General Public License along with |
---|
| 14 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 15 | ! |
---|
[1310] | 16 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
[1036] | 17 | !--------------------------------------------------------------------------------! |
---|
| 18 | ! |
---|
[411] | 19 | ! Current revisions: |
---|
| 20 | ! ----------------- |
---|
[1683] | 21 | ! |
---|
| 22 | ! |
---|
[1383] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
| 25 | ! $Id: subsidence.f90 1683 2015-10-07 23:57:51Z raasch $ |
---|
| 26 | ! |
---|
[1683] | 27 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 28 | ! Code annotations made doxygen readable |
---|
| 29 | ! |
---|
[1490] | 30 | ! 1489 2014-10-30 08:09:12Z raasch |
---|
| 31 | ! bugfix: sums_ls_l can only be used if large_scale_forcing is switched on |
---|
| 32 | ! |
---|
[1383] | 33 | ! 1382 2014-04-30 12:15:41Z boeske |
---|
[1382] | 34 | ! Changed the weighting factor that is used in the summation of subsidence |
---|
| 35 | ! tendencies for profile data output from weight_pres to weight_substep |
---|
| 36 | ! added Neumann boundary conditions for profile data output of subsidence terms |
---|
| 37 | ! at nzt+1 |
---|
[1321] | 38 | ! |
---|
[1381] | 39 | ! 1380 2014-04-28 12:40:45Z heinze |
---|
| 40 | ! Shifting only necessary in case of scalar Rayleigh damping |
---|
| 41 | ! |
---|
[1366] | 42 | ! 1365 2014-04-22 15:03:56Z boeske |
---|
| 43 | ! Summation of subsidence tendencies for data output added |
---|
| 44 | ! +ls_index, sums_ls_l, tmp_tend |
---|
| 45 | ! |
---|
[1354] | 46 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 47 | ! REAL constants provided with KIND-attribute |
---|
| 48 | ! |
---|
[1321] | 49 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 50 | ! ONLY-attribute added to USE-statements, |
---|
| 51 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 52 | ! kinds are defined in new module kinds, |
---|
| 53 | ! old module precision_kind is removed, |
---|
| 54 | ! revision history before 2012 removed, |
---|
| 55 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 56 | ! all variable declaration statements |
---|
[411] | 57 | ! |
---|
[1037] | 58 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 59 | ! code put under GPL (PALM 3.9) |
---|
| 60 | ! |
---|
[464] | 61 | ! Revision 3.7 2009-12-11 14:15:58Z heinze |
---|
| 62 | ! Initial revision |
---|
[411] | 63 | ! |
---|
| 64 | ! Description: |
---|
| 65 | ! ------------ |
---|
[1682] | 66 | !> Impact of large-scale subsidence or ascent as tendency term for use |
---|
| 67 | !> in the prognostic equation of potential temperature. This enables the |
---|
| 68 | !> construction of a constant boundary layer height z_i with time. |
---|
[411] | 69 | !-----------------------------------------------------------------------------! |
---|
[1682] | 70 | MODULE subsidence_mod |
---|
| 71 | |
---|
[411] | 72 | |
---|
| 73 | |
---|
| 74 | IMPLICIT NONE |
---|
| 75 | |
---|
| 76 | PRIVATE |
---|
| 77 | PUBLIC init_w_subsidence, subsidence |
---|
| 78 | |
---|
| 79 | INTERFACE init_w_subsidence |
---|
| 80 | MODULE PROCEDURE init_w_subsidence |
---|
| 81 | END INTERFACE init_w_subsidence |
---|
| 82 | |
---|
| 83 | INTERFACE subsidence |
---|
| 84 | MODULE PROCEDURE subsidence |
---|
| 85 | MODULE PROCEDURE subsidence_ij |
---|
| 86 | END INTERFACE subsidence |
---|
| 87 | |
---|
| 88 | CONTAINS |
---|
| 89 | |
---|
[1682] | 90 | !------------------------------------------------------------------------------! |
---|
| 91 | ! Description: |
---|
| 92 | ! ------------ |
---|
| 93 | !> @todo Missing subroutine description. |
---|
| 94 | !------------------------------------------------------------------------------! |
---|
[411] | 95 | SUBROUTINE init_w_subsidence |
---|
| 96 | |
---|
[1320] | 97 | USE arrays_3d, & |
---|
| 98 | ONLY: dzu, w_subs, zu |
---|
[411] | 99 | |
---|
[1320] | 100 | USE control_parameters, & |
---|
| 101 | ONLY: message_string, ocean, subs_vertical_gradient, & |
---|
| 102 | subs_vertical_gradient_level, subs_vertical_gradient_level_i |
---|
| 103 | |
---|
| 104 | USE indices, & |
---|
| 105 | ONLY: nzb, nzt |
---|
| 106 | |
---|
| 107 | USE kinds |
---|
| 108 | |
---|
[411] | 109 | IMPLICIT NONE |
---|
| 110 | |
---|
[1682] | 111 | INTEGER(iwp) :: i !< |
---|
| 112 | INTEGER(iwp) :: k !< |
---|
[411] | 113 | |
---|
[1682] | 114 | REAL(wp) :: gradient !< |
---|
| 115 | REAL(wp) :: ws_surface !< |
---|
[1320] | 116 | |
---|
[1365] | 117 | IF ( .NOT. ALLOCATED( w_subs )) THEN |
---|
[411] | 118 | ALLOCATE( w_subs(nzb:nzt+1) ) |
---|
[1353] | 119 | w_subs = 0.0_wp |
---|
[411] | 120 | ENDIF |
---|
| 121 | |
---|
[1365] | 122 | IF ( ocean ) THEN |
---|
[411] | 123 | message_string = 'Applying large scale vertical motion is not ' // & |
---|
| 124 | 'allowed for ocean runs' |
---|
| 125 | CALL message( 'init_w_subsidence', 'PA0324', 2, 2, 0, 6, 0 ) |
---|
| 126 | ENDIF |
---|
| 127 | |
---|
| 128 | ! |
---|
| 129 | !-- Compute the profile of the subsidence/ascent velocity |
---|
| 130 | !-- using the given gradients |
---|
| 131 | i = 1 |
---|
[1353] | 132 | gradient = 0.0_wp |
---|
| 133 | ws_surface = 0.0_wp |
---|
[411] | 134 | |
---|
| 135 | |
---|
[580] | 136 | subs_vertical_gradient_level_i(1) = 0 |
---|
[411] | 137 | DO k = 1, nzt+1 |
---|
[1365] | 138 | IF ( i < 11 ) THEN |
---|
[580] | 139 | IF ( subs_vertical_gradient_level(i) < zu(k) .AND. & |
---|
[1353] | 140 | subs_vertical_gradient_level(i) >= 0.0_wp ) THEN |
---|
| 141 | gradient = subs_vertical_gradient(i) / 100.0_wp |
---|
[580] | 142 | subs_vertical_gradient_level_i(i) = k - 1 |
---|
[411] | 143 | i = i + 1 |
---|
| 144 | ENDIF |
---|
| 145 | ENDIF |
---|
[1353] | 146 | IF ( gradient /= 0.0_wp ) THEN |
---|
[411] | 147 | IF ( k /= 1 ) THEN |
---|
| 148 | w_subs(k) = w_subs(k-1) + dzu(k) * gradient |
---|
| 149 | ELSE |
---|
[1353] | 150 | w_subs(k) = ws_surface + 0.5_wp * dzu(k) * gradient |
---|
[411] | 151 | ENDIF |
---|
| 152 | ELSE |
---|
| 153 | w_subs(k) = w_subs(k-1) |
---|
| 154 | ENDIF |
---|
| 155 | ENDDO |
---|
| 156 | |
---|
| 157 | ! |
---|
| 158 | !-- In case of no given gradients for the subsidence/ascent velocity, |
---|
| 159 | !-- choose zero gradient |
---|
[1353] | 160 | IF ( subs_vertical_gradient_level(1) == -9999999.9_wp ) THEN |
---|
| 161 | subs_vertical_gradient_level(1) = 0.0_wp |
---|
[411] | 162 | ENDIF |
---|
| 163 | |
---|
| 164 | END SUBROUTINE init_w_subsidence |
---|
| 165 | |
---|
| 166 | |
---|
[1682] | 167 | !------------------------------------------------------------------------------! |
---|
| 168 | ! Description: |
---|
| 169 | ! ------------ |
---|
| 170 | !> @todo Missing subroutine description. |
---|
| 171 | !------------------------------------------------------------------------------! |
---|
[1365] | 172 | SUBROUTINE subsidence( tendency, var, var_init, ls_index ) |
---|
[411] | 173 | |
---|
[1320] | 174 | USE arrays_3d, & |
---|
| 175 | ONLY: ddzu, w_subs |
---|
[411] | 176 | |
---|
[1320] | 177 | USE control_parameters, & |
---|
[1380] | 178 | ONLY: dt_3d, intermediate_timestep_count, large_scale_forcing, & |
---|
| 179 | scalar_rayleigh_damping |
---|
[1320] | 180 | |
---|
| 181 | USE indices, & |
---|
| 182 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzb_s_inner,& |
---|
| 183 | nzt |
---|
| 184 | |
---|
| 185 | USE kinds |
---|
| 186 | |
---|
[1365] | 187 | USE statistics, & |
---|
[1382] | 188 | ONLY: sums_ls_l, weight_substep |
---|
[1365] | 189 | |
---|
[411] | 190 | IMPLICIT NONE |
---|
| 191 | |
---|
[1682] | 192 | INTEGER(iwp) :: i !< |
---|
| 193 | INTEGER(iwp) :: j !< |
---|
| 194 | INTEGER(iwp) :: k !< |
---|
| 195 | INTEGER(iwp) :: ls_index !< |
---|
[411] | 196 | |
---|
[1682] | 197 | REAL(wp) :: tmp_tend !< |
---|
| 198 | REAL(wp) :: tmp_grad !< |
---|
[411] | 199 | |
---|
[1682] | 200 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: var !< |
---|
| 201 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: tendency !< |
---|
| 202 | REAL(wp), DIMENSION(nzb:nzt+1) :: var_init !< |
---|
| 203 | REAL(wp), DIMENSION(nzb:nzt+1) :: var_mod !< |
---|
[411] | 204 | |
---|
[464] | 205 | var_mod = var_init |
---|
[411] | 206 | |
---|
| 207 | ! |
---|
| 208 | !-- Influence of w_subsidence on the current tendency term |
---|
| 209 | DO i = nxl, nxr |
---|
| 210 | DO j = nys, nyn |
---|
[1382] | 211 | |
---|
[411] | 212 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
[1365] | 213 | IF ( w_subs(k) < 0.0_wp ) THEN ! large-scale subsidence |
---|
| 214 | tmp_tend = - w_subs(k) * & |
---|
| 215 | ( var(k+1,j,i) - var(k,j,i) ) * ddzu(k+1) |
---|
| 216 | ELSE ! large-scale ascent |
---|
| 217 | tmp_tend = - w_subs(k) * & |
---|
| 218 | ( var(k,j,i) - var(k-1,j,i) ) * ddzu(k) |
---|
[411] | 219 | ENDIF |
---|
[1365] | 220 | |
---|
| 221 | tendency(k,j,i) = tendency(k,j,i) + tmp_tend |
---|
| 222 | |
---|
| 223 | IF ( large_scale_forcing ) THEN |
---|
| 224 | sums_ls_l(k,ls_index) = sums_ls_l(k,ls_index) + tmp_tend & |
---|
[1382] | 225 | * weight_substep(intermediate_timestep_count) |
---|
[1365] | 226 | ENDIF |
---|
[411] | 227 | ENDDO |
---|
[1382] | 228 | |
---|
| 229 | sums_ls_l(nzt+1,ls_index) = sums_ls_l(nzt,ls_index) |
---|
| 230 | |
---|
[411] | 231 | ENDDO |
---|
| 232 | ENDDO |
---|
| 233 | |
---|
| 234 | ! |
---|
| 235 | !-- Shifting of the initial profile is especially necessary with Rayleigh |
---|
| 236 | !-- damping switched on |
---|
[1380] | 237 | IF ( scalar_rayleigh_damping ) THEN |
---|
| 238 | DO k = nzb, nzt |
---|
| 239 | IF ( w_subs(k) < 0.0_wp ) THEN ! large-scale subsidence |
---|
| 240 | var_mod(k) = var_init(k) - dt_3d * w_subs(k) * & |
---|
| 241 | ( var_init(k+1) - var_init(k) ) * ddzu(k+1) |
---|
| 242 | ENDIF |
---|
| 243 | ENDDO |
---|
[411] | 244 | ! |
---|
[1380] | 245 | !-- At the upper boundary, the initial profile is shifted with aid of |
---|
| 246 | !-- the gradient tmp_grad. (This is ok if the gradients are linear.) |
---|
| 247 | IF ( w_subs(nzt) < 0.0_wp ) THEN |
---|
| 248 | tmp_grad = ( var_init(nzt+1) - var_init(nzt) ) * ddzu(nzt+1) |
---|
| 249 | var_mod(nzt+1) = var_init(nzt+1) - & |
---|
| 250 | dt_3d * w_subs(nzt+1) * tmp_grad |
---|
| 251 | ENDIF |
---|
[411] | 252 | |
---|
| 253 | |
---|
[1380] | 254 | DO k = nzt+1, nzb+1, -1 |
---|
| 255 | IF ( w_subs(k) >= 0.0_wp ) THEN ! large-scale ascent |
---|
| 256 | var_mod(k) = var_init(k) - dt_3d * w_subs(k) * & |
---|
| 257 | ( var_init(k) - var_init(k-1) ) * ddzu(k) |
---|
| 258 | ENDIF |
---|
| 259 | ENDDO |
---|
| 260 | ! |
---|
| 261 | !-- At the lower boundary shifting is not necessary because the |
---|
| 262 | !-- subsidence velocity w_subs(nzb) vanishes. |
---|
| 263 | IF ( w_subs(nzb+1) >= 0.0_wp ) THEN |
---|
| 264 | var_mod(nzb) = var_init(nzb) |
---|
[411] | 265 | ENDIF |
---|
[1380] | 266 | |
---|
| 267 | var_init = var_mod |
---|
[411] | 268 | ENDIF |
---|
| 269 | |
---|
| 270 | |
---|
| 271 | END SUBROUTINE subsidence |
---|
| 272 | |
---|
[1682] | 273 | !------------------------------------------------------------------------------! |
---|
| 274 | ! Description: |
---|
| 275 | ! ------------ |
---|
| 276 | !> @todo Missing subroutine description. |
---|
| 277 | !------------------------------------------------------------------------------! |
---|
[1365] | 278 | SUBROUTINE subsidence_ij( i, j, tendency, var, var_init, ls_index ) |
---|
[411] | 279 | |
---|
[1320] | 280 | USE arrays_3d, & |
---|
| 281 | ONLY: ddzu, w_subs |
---|
[411] | 282 | |
---|
[1320] | 283 | USE control_parameters, & |
---|
[1380] | 284 | ONLY: dt_3d, intermediate_timestep_count, large_scale_forcing, & |
---|
| 285 | scalar_rayleigh_damping |
---|
[1320] | 286 | |
---|
| 287 | USE indices, & |
---|
| 288 | ONLY: nxl, nxlg, nxrg, nyng, nys, nysg, nzb_s_inner, nzb, nzt |
---|
| 289 | |
---|
| 290 | USE kinds |
---|
| 291 | |
---|
[1365] | 292 | USE statistics, & |
---|
[1382] | 293 | ONLY: sums_ls_l, weight_substep |
---|
[1365] | 294 | |
---|
[411] | 295 | IMPLICIT NONE |
---|
| 296 | |
---|
[1682] | 297 | INTEGER(iwp) :: i !< |
---|
| 298 | INTEGER(iwp) :: j !< |
---|
| 299 | INTEGER(iwp) :: k !< |
---|
| 300 | INTEGER(iwp) :: ls_index !< |
---|
[411] | 301 | |
---|
[1682] | 302 | REAL(wp) :: tmp_tend !< |
---|
| 303 | REAL(wp) :: tmp_grad !< |
---|
[411] | 304 | |
---|
[1682] | 305 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: var !< |
---|
| 306 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: tendency !< |
---|
| 307 | REAL(wp), DIMENSION(nzb:nzt+1) :: var_init !< |
---|
| 308 | REAL(wp), DIMENSION(nzb:nzt+1) :: var_mod !< |
---|
[411] | 309 | |
---|
[464] | 310 | var_mod = var_init |
---|
[411] | 311 | |
---|
| 312 | ! |
---|
| 313 | !-- Influence of w_subsidence on the current tendency term |
---|
| 314 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
[1365] | 315 | IF ( w_subs(k) < 0.0_wp ) THEN ! large-scale subsidence |
---|
| 316 | tmp_tend = - w_subs(k) * ( var(k+1,j,i) - var(k,j,i) ) * ddzu(k+1) |
---|
| 317 | ELSE ! large-scale ascent |
---|
| 318 | tmp_tend = - w_subs(k) * ( var(k,j,i) - var(k-1,j,i) ) * ddzu(k) |
---|
[411] | 319 | ENDIF |
---|
[1365] | 320 | |
---|
| 321 | tendency(k,j,i) = tendency(k,j,i) + tmp_tend |
---|
| 322 | |
---|
| 323 | IF ( large_scale_forcing ) THEN |
---|
| 324 | sums_ls_l(k,ls_index) = sums_ls_l(k,ls_index) + tmp_tend & |
---|
[1382] | 325 | * weight_substep(intermediate_timestep_count) |
---|
[1365] | 326 | ENDIF |
---|
[411] | 327 | ENDDO |
---|
| 328 | |
---|
[1489] | 329 | IF ( large_scale_forcing ) THEN |
---|
| 330 | sums_ls_l(nzt+1,ls_index) = sums_ls_l(nzt,ls_index) |
---|
| 331 | ENDIF |
---|
[411] | 332 | |
---|
| 333 | ! |
---|
| 334 | !-- Shifting of the initial profile is especially necessary with Rayleigh |
---|
| 335 | !-- damping switched on |
---|
[1380] | 336 | IF ( scalar_rayleigh_damping ) THEN |
---|
| 337 | IF ( i == nxl .AND. j == nys ) THEN ! shifting only once per PE |
---|
[411] | 338 | |
---|
[1380] | 339 | DO k = nzb, nzt |
---|
| 340 | IF ( w_subs(k) < 0.0_wp ) THEN ! large-scale subsidence |
---|
| 341 | var_mod(k) = var_init(k) - dt_3d * w_subs(k) * & |
---|
| 342 | ( var_init(k+1) - var_init(k) ) * ddzu(k+1) |
---|
| 343 | ENDIF |
---|
| 344 | ENDDO |
---|
| 345 | ! |
---|
| 346 | !-- At the upper boundary, the initial profile is shifted with aid of |
---|
| 347 | !-- the gradient tmp_grad. (This is ok if the gradients are linear.) |
---|
| 348 | IF ( w_subs(nzt) < 0.0_wp ) THEN |
---|
| 349 | tmp_grad = ( var_init(nzt+1) - var_init(nzt) ) * ddzu(nzt+1) |
---|
| 350 | var_mod(nzt+1) = var_init(nzt+1) - & |
---|
| 351 | dt_3d * w_subs(nzt+1) * tmp_grad |
---|
[411] | 352 | ENDIF |
---|
| 353 | |
---|
| 354 | |
---|
[1380] | 355 | DO k = nzt+1, nzb+1, -1 |
---|
| 356 | IF ( w_subs(k) >= 0.0_wp ) THEN ! large-scale ascent |
---|
| 357 | var_mod(k) = var_init(k) - dt_3d * w_subs(k) * & |
---|
| 358 | ( var_init(k) - var_init(k-1) ) * ddzu(k) |
---|
| 359 | ENDIF |
---|
| 360 | ENDDO |
---|
| 361 | ! |
---|
| 362 | !-- At the lower boundary shifting is not necessary because the |
---|
| 363 | !-- subsidence velocity w_subs(nzb) vanishes. |
---|
| 364 | IF ( w_subs(nzb+1) >= 0.0_wp ) THEN |
---|
| 365 | var_mod(nzb) = var_init(nzb) |
---|
[411] | 366 | ENDIF |
---|
| 367 | |
---|
[1380] | 368 | var_init = var_mod |
---|
[411] | 369 | |
---|
[1380] | 370 | ENDIF |
---|
[411] | 371 | ENDIF |
---|
| 372 | |
---|
| 373 | END SUBROUTINE subsidence_ij |
---|
| 374 | |
---|
| 375 | |
---|
| 376 | END MODULE subsidence_mod |
---|