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