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