[1850] | 1 | !> @file nudging_mod.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[1239] | 3 | ! This file is part of PALM. |
---|
| 4 | ! |
---|
[2000] | 5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
| 6 | ! terms of the GNU General Public License as published by the Free Software |
---|
| 7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
| 8 | ! version. |
---|
[1239] | 9 | ! |
---|
| 10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 13 | ! |
---|
| 14 | ! You should have received a copy of the GNU General Public License along with |
---|
| 15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 16 | ! |
---|
[2101] | 17 | ! Copyright 1997-2017 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1239] | 19 | ! |
---|
| 20 | ! Current revisions: |
---|
| 21 | ! ------------------ |
---|
[1383] | 22 | ! |
---|
[2233] | 23 | ! |
---|
[1383] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: nudging_mod.f90 2271 2017-06-09 12:34:55Z sward $ |
---|
[2271] | 27 | ! Error message changed |
---|
| 28 | ! |
---|
| 29 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
[1383] | 30 | ! |
---|
[2233] | 31 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
| 32 | ! Adjustments to new topography concept |
---|
| 33 | ! |
---|
[2001] | 34 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 35 | ! Forced header and separation lines into 80 columns |
---|
| 36 | ! |
---|
[1851] | 37 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
| 38 | ! Module renamed |
---|
| 39 | ! |
---|
| 40 | ! |
---|
[1758] | 41 | ! 1757 2016-02-22 15:49:32Z maronga |
---|
| 42 | ! Bugfix: allow for using higher vertical resolution in nudging file than grid |
---|
| 43 | ! spacing in the LES model |
---|
| 44 | ! |
---|
[1683] | 45 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 46 | ! Code annotations made doxygen readable |
---|
| 47 | ! |
---|
[1399] | 48 | ! 1398 2014-05-07 11:15:00Z heinze |
---|
| 49 | ! Subroutine nudge_ref is extended to set u_init and v_init to the current |
---|
| 50 | ! nudging profiles |
---|
| 51 | ! |
---|
[1383] | 52 | ! 1382 2014-04-30 12:15:41Z boeske |
---|
[1382] | 53 | ! Changed the weighting factor that is used in the summation of nudging |
---|
| 54 | ! tendencies for profile data output from weight_pres to weight_substep, |
---|
| 55 | ! added Neumann boundary conditions for profile data output of nudging terms at |
---|
| 56 | ! nzt+1 |
---|
[1366] | 57 | ! |
---|
[1381] | 58 | ! 1380 2014-04-28 12:40:45Z heinze |
---|
| 59 | ! Subroutine nudge_ref added to account for proper upper scalar boundary |
---|
| 60 | ! conditions in case of nudging |
---|
| 61 | ! |
---|
[1366] | 62 | ! 1365 2014-04-22 15:03:56Z boeske |
---|
[1365] | 63 | ! Variable t renamed nt, variable currtnudge renamed tmp_tnudge, |
---|
| 64 | ! summation of nudging tendencies for data output added |
---|
| 65 | ! +sums_ls_l, tmp_tend |
---|
| 66 | ! Added new subroutine calc_tnudge, which calculates the current nudging time |
---|
| 67 | ! scale at each time step |
---|
[1354] | 68 | ! |
---|
[1356] | 69 | ! 1355 2014-04-10 10:21:29Z heinze |
---|
| 70 | ! Error message specified. |
---|
| 71 | ! |
---|
[1354] | 72 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 73 | ! REAL constants provided with KIND-attribute |
---|
| 74 | ! |
---|
[1321] | 75 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 76 | ! ONLY-attribute added to USE-statements, |
---|
| 77 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 78 | ! kinds are defined in new module kinds, |
---|
| 79 | ! old module precision_kind is removed, |
---|
| 80 | ! revision history before 2012 removed, |
---|
| 81 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 82 | ! all variable declaration statements |
---|
[1239] | 83 | ! |
---|
[1319] | 84 | ! 1318 2014-03-17 13:35:16Z raasch |
---|
| 85 | ! module interfaces removed |
---|
| 86 | ! |
---|
[1269] | 87 | ! 1268 2013-12-12 09:47:53Z heinze |
---|
| 88 | ! bugfix: argument of calc_mean_profile corrected |
---|
| 89 | ! |
---|
[1252] | 90 | ! 1251 2013-11-07 08:14:30Z heinze |
---|
| 91 | ! bugfix: calculate dtm and dtp also in vector version |
---|
| 92 | ! |
---|
[1250] | 93 | ! 1249 2013-11-06 10:45:47Z heinze |
---|
| 94 | ! remove call of user module |
---|
| 95 | ! reformatting |
---|
| 96 | ! |
---|
[1242] | 97 | ! 1241 2013-10-30 11:36:58Z heinze |
---|
| 98 | ! Initial revision |
---|
[1239] | 99 | ! |
---|
| 100 | ! Description: |
---|
| 101 | ! ------------ |
---|
[1682] | 102 | !> Nudges u, v, pt and q to given profiles on a relaxation timescale tnudge. |
---|
| 103 | !> Profiles are read in from NUDGIN_DATA. Code is based on Neggers et al. (2012) |
---|
| 104 | !> and also part of DALES and UCLA-LES. |
---|
[1239] | 105 | !--------------------------------------------------------------------------------! |
---|
[1682] | 106 | MODULE nudge_mod |
---|
| 107 | |
---|
[1239] | 108 | |
---|
| 109 | PRIVATE |
---|
[1380] | 110 | PUBLIC init_nudge, calc_tnudge, nudge, nudge_ref |
---|
[1239] | 111 | SAVE |
---|
| 112 | |
---|
| 113 | INTERFACE nudge |
---|
| 114 | MODULE PROCEDURE nudge |
---|
| 115 | MODULE PROCEDURE nudge_ij |
---|
| 116 | END INTERFACE nudge |
---|
| 117 | |
---|
| 118 | CONTAINS |
---|
| 119 | |
---|
[1682] | 120 | !------------------------------------------------------------------------------! |
---|
| 121 | ! Description: |
---|
| 122 | ! ------------ |
---|
| 123 | !> @todo Missing subroutine description. |
---|
| 124 | !------------------------------------------------------------------------------! |
---|
[1239] | 125 | SUBROUTINE init_nudge |
---|
| 126 | |
---|
[1320] | 127 | USE arrays_3d, & |
---|
[1365] | 128 | ONLY: ptnudge, qnudge, timenudge, tmp_tnudge, tnudge, unudge, & |
---|
| 129 | vnudge, wnudge, zu |
---|
[1239] | 130 | |
---|
[1320] | 131 | USE control_parameters, & |
---|
| 132 | ONLY: dt_3d, lptnudge, lqnudge, lunudge, lvnudge, lwnudge, & |
---|
| 133 | message_string, ntnudge |
---|
| 134 | |
---|
| 135 | USE indices, & |
---|
| 136 | ONLY: nzb, nzt |
---|
| 137 | |
---|
| 138 | USE kinds |
---|
| 139 | |
---|
[1239] | 140 | IMPLICIT NONE |
---|
| 141 | |
---|
| 142 | |
---|
[1682] | 143 | INTEGER(iwp) :: finput = 90 !< |
---|
| 144 | INTEGER(iwp) :: ierrn !< |
---|
| 145 | INTEGER(iwp) :: k !< |
---|
| 146 | INTEGER(iwp) :: nt !< |
---|
[1239] | 147 | |
---|
[1682] | 148 | CHARACTER(1) :: hash !< |
---|
[1320] | 149 | |
---|
[1682] | 150 | REAL(wp) :: highheight !< |
---|
| 151 | REAL(wp) :: highqnudge !< |
---|
| 152 | REAL(wp) :: highptnudge !< |
---|
| 153 | REAL(wp) :: highunudge !< |
---|
| 154 | REAL(wp) :: highvnudge !< |
---|
| 155 | REAL(wp) :: highwnudge !< |
---|
| 156 | REAL(wp) :: hightnudge !< |
---|
[1320] | 157 | |
---|
[1682] | 158 | REAL(wp) :: lowheight !< |
---|
| 159 | REAL(wp) :: lowqnudge !< |
---|
| 160 | REAL(wp) :: lowptnudge !< |
---|
| 161 | REAL(wp) :: lowunudge !< |
---|
| 162 | REAL(wp) :: lowvnudge !< |
---|
| 163 | REAL(wp) :: lowwnudge !< |
---|
| 164 | REAL(wp) :: lowtnudge !< |
---|
[1320] | 165 | |
---|
[1682] | 166 | REAL(wp) :: fac !< |
---|
[1320] | 167 | |
---|
[1239] | 168 | ALLOCATE( ptnudge(nzb:nzt+1,1:ntnudge), qnudge(nzb:nzt+1,1:ntnudge), & |
---|
| 169 | tnudge(nzb:nzt+1,1:ntnudge), unudge(nzb:nzt+1,1:ntnudge), & |
---|
| 170 | vnudge(nzb:nzt+1,1:ntnudge), wnudge(nzb:nzt+1,1:ntnudge) ) |
---|
| 171 | |
---|
[1365] | 172 | ALLOCATE( tmp_tnudge(nzb:nzt) ) |
---|
| 173 | |
---|
[1239] | 174 | ALLOCATE( timenudge(0:ntnudge) ) |
---|
| 175 | |
---|
[1353] | 176 | ptnudge = 0.0_wp; qnudge = 0.0_wp; tnudge = 0.0_wp; unudge = 0.0_wp |
---|
| 177 | vnudge = 0.0_wp; wnudge = 0.0_wp; timenudge = 0.0_wp |
---|
[1365] | 178 | ! |
---|
| 179 | !-- Initialize array tmp_nudge with a current nudging time scale of 6 hours |
---|
| 180 | tmp_tnudge = 21600.0_wp |
---|
[1239] | 181 | |
---|
[1365] | 182 | nt = 0 |
---|
[1249] | 183 | OPEN ( finput, FILE='NUDGING_DATA', STATUS='OLD', & |
---|
| 184 | FORM='FORMATTED', IOSTAT=ierrn ) |
---|
[1239] | 185 | |
---|
[1249] | 186 | IF ( ierrn /= 0 ) THEN |
---|
[1239] | 187 | message_string = 'file NUDGING_DATA does not exist' |
---|
| 188 | CALL message( 'nudging', 'PA0365', 1, 2, 0, 6, 0 ) |
---|
| 189 | ENDIF |
---|
| 190 | |
---|
| 191 | ierrn = 0 |
---|
| 192 | |
---|
| 193 | rloop:DO |
---|
[1365] | 194 | nt = nt + 1 |
---|
[1239] | 195 | hash = "#" |
---|
[1320] | 196 | ierrn = 1 ! not zero |
---|
[1239] | 197 | ! |
---|
| 198 | !-- Search for the next line consisting of "# time", |
---|
| 199 | !-- from there onwards the profiles will be read |
---|
| 200 | DO WHILE ( .NOT. ( hash == "#" .AND. ierrn == 0 ) ) |
---|
| 201 | |
---|
[1365] | 202 | READ ( finput, *, IOSTAT=ierrn ) hash, timenudge(nt) |
---|
[1249] | 203 | IF ( ierrn < 0 ) EXIT rloop |
---|
[1239] | 204 | |
---|
| 205 | ENDDO |
---|
| 206 | |
---|
| 207 | ierrn = 0 |
---|
[1249] | 208 | READ ( finput, *, IOSTAT=ierrn ) lowheight, lowtnudge, lowunudge, & |
---|
| 209 | lowvnudge, lowwnudge , lowptnudge, & |
---|
| 210 | lowqnudge |
---|
[1239] | 211 | |
---|
[1249] | 212 | IF ( ierrn /= 0 ) THEN |
---|
[1239] | 213 | message_string = 'errors in file NUDGING_DATA' |
---|
| 214 | CALL message( 'nudging', 'PA0366', 1, 2, 0, 6, 0 ) |
---|
| 215 | ENDIF |
---|
| 216 | |
---|
| 217 | ierrn = 0 |
---|
[1249] | 218 | READ ( finput, *, IOSTAT=ierrn ) highheight, hightnudge, highunudge, & |
---|
| 219 | highvnudge, highwnudge , highptnudge, & |
---|
| 220 | highqnudge |
---|
[1239] | 221 | |
---|
[1249] | 222 | IF ( ierrn /= 0 ) THEN |
---|
[1239] | 223 | message_string = 'errors in file NUDGING_DATA' |
---|
| 224 | CALL message( 'nudging', 'PA0366', 1, 2, 0, 6, 0 ) |
---|
| 225 | ENDIF |
---|
| 226 | |
---|
| 227 | DO k = nzb, nzt+1 |
---|
[1757] | 228 | DO WHILE ( highheight < zu(k) ) |
---|
[1239] | 229 | lowheight = highheight |
---|
| 230 | lowtnudge = hightnudge |
---|
| 231 | lowunudge = highunudge |
---|
| 232 | lowvnudge = highvnudge |
---|
| 233 | lowwnudge = highwnudge |
---|
| 234 | lowptnudge = highptnudge |
---|
| 235 | lowqnudge = highqnudge |
---|
| 236 | |
---|
| 237 | ierrn = 0 |
---|
[1249] | 238 | READ ( finput, *, IOSTAT=ierrn ) highheight , hightnudge , & |
---|
| 239 | highunudge , highvnudge , & |
---|
| 240 | highwnudge , highptnudge, & |
---|
| 241 | highqnudge |
---|
| 242 | IF (ierrn /= 0 ) THEN |
---|
[2271] | 243 | WRITE( message_string, * ) 'zu(',k,') = ', zu(k), 'm is ',& |
---|
[1355] | 244 | 'higher than the maximum height in NUDING_DATA which ', & |
---|
| 245 | 'is ', lowheight, 'm. Interpolation on PALM ', & |
---|
| 246 | 'grid is not possible.' |
---|
| 247 | CALL message( 'nudging', 'PA0364', 1, 2, 0, 6, 0 ) |
---|
[1239] | 248 | ENDIF |
---|
[1757] | 249 | ENDDO |
---|
[1239] | 250 | |
---|
| 251 | ! |
---|
| 252 | !-- Interpolation of prescribed profiles in space |
---|
| 253 | |
---|
[1249] | 254 | fac = ( highheight - zu(k) ) / ( highheight - lowheight ) |
---|
[1239] | 255 | |
---|
[1365] | 256 | tnudge(k,nt) = fac * lowtnudge + ( 1.0_wp - fac ) * hightnudge |
---|
| 257 | unudge(k,nt) = fac * lowunudge + ( 1.0_wp - fac ) * highunudge |
---|
| 258 | vnudge(k,nt) = fac * lowvnudge + ( 1.0_wp - fac ) * highvnudge |
---|
| 259 | wnudge(k,nt) = fac * lowwnudge + ( 1.0_wp - fac ) * highwnudge |
---|
| 260 | ptnudge(k,nt) = fac * lowptnudge + ( 1.0_wp - fac ) * highptnudge |
---|
| 261 | qnudge(k,nt) = fac * lowqnudge + ( 1.0_wp - fac ) * highqnudge |
---|
[1239] | 262 | ENDDO |
---|
| 263 | |
---|
| 264 | ENDDO rloop |
---|
| 265 | |
---|
[1249] | 266 | CLOSE ( finput ) |
---|
[1239] | 267 | |
---|
| 268 | ! |
---|
| 269 | !-- Prevent nudging if nudging profiles exhibt too small values |
---|
[1241] | 270 | !-- not used so far |
---|
[1353] | 271 | lptnudge = ANY( ABS( ptnudge ) > 1.0e-8_wp ) |
---|
| 272 | lqnudge = ANY( ABS( qnudge ) > 1.0e-8_wp ) |
---|
| 273 | lunudge = ANY( ABS( unudge ) > 1.0e-8_wp ) |
---|
| 274 | lvnudge = ANY( ABS( vnudge ) > 1.0e-8_wp ) |
---|
| 275 | lwnudge = ANY( ABS( wnudge ) > 1.0e-8_wp ) |
---|
[1239] | 276 | |
---|
| 277 | END SUBROUTINE init_nudge |
---|
| 278 | |
---|
[1365] | 279 | |
---|
[1682] | 280 | !------------------------------------------------------------------------------! |
---|
| 281 | ! Description: |
---|
| 282 | ! ------------ |
---|
| 283 | !> @todo Missing subroutine description. |
---|
| 284 | !------------------------------------------------------------------------------! |
---|
[1365] | 285 | SUBROUTINE calc_tnudge ( time ) |
---|
| 286 | |
---|
| 287 | USE arrays_3d, & |
---|
| 288 | ONLY: timenudge, tmp_tnudge, tnudge |
---|
| 289 | |
---|
| 290 | USE control_parameters, & |
---|
| 291 | ONLY: dt_3d |
---|
| 292 | |
---|
| 293 | USE indices, & |
---|
| 294 | ONLY: nzb, nzt |
---|
| 295 | |
---|
| 296 | USE kinds |
---|
| 297 | |
---|
| 298 | IMPLICIT NONE |
---|
| 299 | |
---|
| 300 | |
---|
[1682] | 301 | REAL(wp) :: dtm !< |
---|
| 302 | REAL(wp) :: dtp !< |
---|
| 303 | REAL(wp) :: time !< |
---|
[1365] | 304 | |
---|
[1682] | 305 | INTEGER(iwp) :: k !< |
---|
| 306 | INTEGER(iwp) :: nt !< |
---|
[1365] | 307 | |
---|
| 308 | nt = 1 |
---|
| 309 | DO WHILE ( time > timenudge(nt) ) |
---|
| 310 | nt = nt+1 |
---|
| 311 | ENDDO |
---|
| 312 | IF ( time /= timenudge(1) ) THEN |
---|
| 313 | nt = nt-1 |
---|
| 314 | ENDIF |
---|
| 315 | |
---|
| 316 | dtm = ( time - timenudge(nt) ) / ( timenudge(nt+1) - timenudge(nt) ) |
---|
| 317 | dtp = ( timenudge(nt+1) - time ) / ( timenudge(nt+1) - timenudge(nt) ) |
---|
| 318 | |
---|
| 319 | DO k = nzb, nzt |
---|
| 320 | tmp_tnudge(k) = MAX( dt_3d, tnudge(k,nt) * dtp + tnudge(k,nt+1) * dtm ) |
---|
| 321 | ENDDO |
---|
| 322 | |
---|
| 323 | END SUBROUTINE calc_tnudge |
---|
| 324 | |
---|
[1239] | 325 | !------------------------------------------------------------------------------! |
---|
[1682] | 326 | ! Description: |
---|
| 327 | ! ------------ |
---|
| 328 | !> Call for all grid points |
---|
[1239] | 329 | !------------------------------------------------------------------------------! |
---|
| 330 | SUBROUTINE nudge ( time, prog_var ) |
---|
| 331 | |
---|
[1320] | 332 | USE arrays_3d, & |
---|
[1365] | 333 | ONLY: pt, ptnudge, q, qnudge, tend, timenudge, tmp_tnudge, tnudge, & |
---|
| 334 | u, unudge, v, vnudge |
---|
[1239] | 335 | |
---|
[1320] | 336 | USE control_parameters, & |
---|
[1365] | 337 | ONLY: dt_3d, intermediate_timestep_count, message_string |
---|
[1320] | 338 | |
---|
| 339 | USE indices, & |
---|
[2232] | 340 | ONLY: nxl, nxr, nys, nyn, nzb, nzt, wall_flags_0 |
---|
[1320] | 341 | |
---|
[1365] | 342 | USE kinds |
---|
[1320] | 343 | |
---|
| 344 | USE statistics, & |
---|
[1382] | 345 | ONLY: hom, sums_ls_l, weight_substep |
---|
[1320] | 346 | |
---|
[1239] | 347 | IMPLICIT NONE |
---|
| 348 | |
---|
[1682] | 349 | CHARACTER (LEN=*) :: prog_var !< |
---|
[1239] | 350 | |
---|
[1682] | 351 | REAL(wp) :: tmp_tend !< |
---|
| 352 | REAL(wp) :: dtm !< |
---|
| 353 | REAL(wp) :: dtp !< |
---|
| 354 | REAL(wp) :: time !< |
---|
[1239] | 355 | |
---|
[1682] | 356 | INTEGER(iwp) :: i !< |
---|
| 357 | INTEGER(iwp) :: j !< |
---|
| 358 | INTEGER(iwp) :: k !< |
---|
| 359 | INTEGER(iwp) :: nt !< |
---|
[1239] | 360 | |
---|
| 361 | |
---|
[1365] | 362 | nt = 1 |
---|
| 363 | DO WHILE ( time > timenudge(nt) ) |
---|
| 364 | nt = nt+1 |
---|
[1251] | 365 | ENDDO |
---|
| 366 | IF ( time /= timenudge(1) ) THEN |
---|
[1365] | 367 | nt = nt-1 |
---|
[1251] | 368 | ENDIF |
---|
| 369 | |
---|
[1365] | 370 | dtm = ( time - timenudge(nt) ) / ( timenudge(nt+1) - timenudge(nt) ) |
---|
| 371 | dtp = ( timenudge(nt+1) - time ) / ( timenudge(nt+1) - timenudge(nt) ) |
---|
[1251] | 372 | |
---|
[1239] | 373 | SELECT CASE ( prog_var ) |
---|
| 374 | |
---|
| 375 | CASE ( 'u' ) |
---|
| 376 | |
---|
| 377 | DO i = nxl, nxr |
---|
| 378 | DO j = nys, nyn |
---|
[1382] | 379 | |
---|
[2232] | 380 | DO k = nzb+1, nzt |
---|
[1239] | 381 | |
---|
[1365] | 382 | tmp_tend = - ( hom(k,1,1,0) - ( unudge(k,nt) * dtp + & |
---|
| 383 | unudge(k,nt+1) * dtm ) ) / tmp_tnudge(k) |
---|
[1239] | 384 | |
---|
[2232] | 385 | tend(k,j,i) = tend(k,j,i) + tmp_tend * & |
---|
| 386 | MERGE( 1.0_wp, 0.0_wp, & |
---|
| 387 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
[1239] | 388 | |
---|
[1365] | 389 | sums_ls_l(k,6) = sums_ls_l(k,6) + tmp_tend * & |
---|
[1382] | 390 | weight_substep(intermediate_timestep_count) |
---|
[1239] | 391 | ENDDO |
---|
[1382] | 392 | |
---|
| 393 | sums_ls_l(nzt+1,6) = sums_ls_l(nzt,6) |
---|
| 394 | |
---|
[1239] | 395 | ENDDO |
---|
| 396 | ENDDO |
---|
| 397 | |
---|
| 398 | CASE ( 'v' ) |
---|
| 399 | |
---|
| 400 | DO i = nxl, nxr |
---|
| 401 | DO j = nys, nyn |
---|
[1382] | 402 | |
---|
[2232] | 403 | DO k = nzb+1, nzt |
---|
[1239] | 404 | |
---|
[1365] | 405 | tmp_tend = - ( hom(k,1,2,0) - ( vnudge(k,nt) * dtp + & |
---|
| 406 | vnudge(k,nt+1) * dtm ) ) / tmp_tnudge(k) |
---|
[1239] | 407 | |
---|
[2232] | 408 | tend(k,j,i) = tend(k,j,i) + tmp_tend * & |
---|
| 409 | MERGE( 1.0_wp, 0.0_wp, & |
---|
| 410 | BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
[1239] | 411 | |
---|
[1365] | 412 | sums_ls_l(k,7) = sums_ls_l(k,7) + tmp_tend * & |
---|
[1382] | 413 | weight_substep(intermediate_timestep_count) |
---|
[1239] | 414 | ENDDO |
---|
[1382] | 415 | |
---|
| 416 | sums_ls_l(nzt+1,7) = sums_ls_l(nzt,7) |
---|
| 417 | |
---|
[1239] | 418 | ENDDO |
---|
| 419 | ENDDO |
---|
| 420 | |
---|
| 421 | CASE ( 'pt' ) |
---|
| 422 | |
---|
| 423 | DO i = nxl, nxr |
---|
| 424 | DO j = nys, nyn |
---|
[1382] | 425 | |
---|
[2232] | 426 | DO k = nzb+1, nzt |
---|
[1239] | 427 | |
---|
[1365] | 428 | tmp_tend = - ( hom(k,1,4,0) - ( ptnudge(k,nt) * dtp + & |
---|
| 429 | ptnudge(k,nt+1) * dtm ) ) / tmp_tnudge(k) |
---|
[1239] | 430 | |
---|
[2232] | 431 | tend(k,j,i) = tend(k,j,i) + tmp_tend * & |
---|
| 432 | MERGE( 1.0_wp, 0.0_wp, & |
---|
| 433 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1239] | 434 | |
---|
[1365] | 435 | sums_ls_l(k,4) = sums_ls_l(k,4) + tmp_tend * & |
---|
[1382] | 436 | weight_substep(intermediate_timestep_count) |
---|
[1239] | 437 | ENDDO |
---|
[1382] | 438 | |
---|
| 439 | sums_ls_l(nzt+1,4) = sums_ls_l(nzt,4) |
---|
| 440 | |
---|
[1239] | 441 | ENDDO |
---|
| 442 | ENDDO |
---|
| 443 | |
---|
| 444 | CASE ( 'q' ) |
---|
| 445 | |
---|
| 446 | DO i = nxl, nxr |
---|
| 447 | DO j = nys, nyn |
---|
[1382] | 448 | |
---|
[2232] | 449 | DO k = nzb+1, nzt |
---|
[1239] | 450 | |
---|
[1365] | 451 | tmp_tend = - ( hom(k,1,41,0) - ( qnudge(k,nt) * dtp + & |
---|
| 452 | qnudge(k,nt+1) * dtm ) ) / tmp_tnudge(k) |
---|
[1239] | 453 | |
---|
[2232] | 454 | tend(k,j,i) = tend(k,j,i) + tmp_tend * & |
---|
| 455 | MERGE( 1.0_wp, 0.0_wp, & |
---|
| 456 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1239] | 457 | |
---|
[1365] | 458 | sums_ls_l(k,5) = sums_ls_l(k,5) + tmp_tend * & |
---|
[1382] | 459 | weight_substep(intermediate_timestep_count) |
---|
[1239] | 460 | ENDDO |
---|
[1382] | 461 | |
---|
| 462 | sums_ls_l(nzt+1,5) = sums_ls_l(nzt,5) |
---|
| 463 | |
---|
[1239] | 464 | ENDDO |
---|
| 465 | ENDDO |
---|
| 466 | |
---|
| 467 | CASE DEFAULT |
---|
| 468 | message_string = 'unknown prognostic variable "' // prog_var // '"' |
---|
| 469 | CALL message( 'nudge', 'PA0367', 1, 2, 0, 6, 0 ) |
---|
| 470 | |
---|
| 471 | END SELECT |
---|
| 472 | |
---|
| 473 | END SUBROUTINE nudge |
---|
| 474 | |
---|
| 475 | |
---|
| 476 | !------------------------------------------------------------------------------! |
---|
[1682] | 477 | ! Description: |
---|
| 478 | ! ------------ |
---|
| 479 | !> Call for grid point i,j |
---|
[1239] | 480 | !------------------------------------------------------------------------------! |
---|
| 481 | |
---|
| 482 | SUBROUTINE nudge_ij( i, j, time, prog_var ) |
---|
| 483 | |
---|
[1320] | 484 | USE arrays_3d, & |
---|
[1365] | 485 | ONLY: pt, ptnudge, q, qnudge, tend, timenudge, tmp_tnudge, tnudge, & |
---|
| 486 | u, unudge, v, vnudge |
---|
[1239] | 487 | |
---|
[1320] | 488 | USE control_parameters, & |
---|
[1365] | 489 | ONLY: dt_3d, intermediate_timestep_count, message_string |
---|
[1320] | 490 | |
---|
| 491 | USE indices, & |
---|
[2232] | 492 | ONLY: nxl, nxr, nys, nyn, nzb, nzt, wall_flags_0 |
---|
[1320] | 493 | |
---|
[1365] | 494 | USE kinds |
---|
[1320] | 495 | |
---|
| 496 | USE statistics, & |
---|
[1382] | 497 | ONLY: hom, sums_ls_l, weight_substep |
---|
[1320] | 498 | |
---|
[1239] | 499 | IMPLICIT NONE |
---|
| 500 | |
---|
| 501 | |
---|
[1682] | 502 | CHARACTER (LEN=*) :: prog_var !< |
---|
[1239] | 503 | |
---|
[1682] | 504 | REAL(wp) :: tmp_tend !< |
---|
| 505 | REAL(wp) :: dtm !< |
---|
| 506 | REAL(wp) :: dtp !< |
---|
| 507 | REAL(wp) :: time !< |
---|
[1239] | 508 | |
---|
[1682] | 509 | INTEGER(iwp) :: i !< |
---|
| 510 | INTEGER(iwp) :: j !< |
---|
| 511 | INTEGER(iwp) :: k !< |
---|
| 512 | INTEGER(iwp) :: nt !< |
---|
[1239] | 513 | |
---|
[1320] | 514 | |
---|
[1365] | 515 | nt = 1 |
---|
| 516 | DO WHILE ( time > timenudge(nt) ) |
---|
| 517 | nt = nt+1 |
---|
[1239] | 518 | ENDDO |
---|
[1249] | 519 | IF ( time /= timenudge(1) ) THEN |
---|
[1365] | 520 | nt = nt-1 |
---|
[1239] | 521 | ENDIF |
---|
| 522 | |
---|
[1365] | 523 | dtm = ( time - timenudge(nt) ) / ( timenudge(nt+1) - timenudge(nt) ) |
---|
| 524 | dtp = ( timenudge(nt+1) - time ) / ( timenudge(nt+1) - timenudge(nt) ) |
---|
[1239] | 525 | |
---|
| 526 | SELECT CASE ( prog_var ) |
---|
| 527 | |
---|
| 528 | CASE ( 'u' ) |
---|
| 529 | |
---|
[2232] | 530 | DO k = nzb+1, nzt |
---|
[1239] | 531 | |
---|
[1365] | 532 | tmp_tend = - ( hom(k,1,1,0) - ( unudge(k,nt) * dtp + & |
---|
| 533 | unudge(k,nt+1) * dtm ) ) / tmp_tnudge(k) |
---|
[1239] | 534 | |
---|
[2232] | 535 | tend(k,j,i) = tend(k,j,i) + tmp_tend * & |
---|
| 536 | MERGE( 1.0_wp, 0.0_wp, & |
---|
| 537 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
[1365] | 538 | |
---|
| 539 | sums_ls_l(k,6) = sums_ls_l(k,6) + tmp_tend & |
---|
[1382] | 540 | * weight_substep(intermediate_timestep_count) |
---|
[1239] | 541 | ENDDO |
---|
| 542 | |
---|
[1382] | 543 | sums_ls_l(nzt+1,6) = sums_ls_l(nzt,6) |
---|
| 544 | |
---|
[1239] | 545 | CASE ( 'v' ) |
---|
| 546 | |
---|
[2232] | 547 | DO k = nzb+1, nzt |
---|
[1239] | 548 | |
---|
[1365] | 549 | tmp_tend = - ( hom(k,1,2,0) - ( vnudge(k,nt) * dtp + & |
---|
| 550 | vnudge(k,nt+1) * dtm ) ) / tmp_tnudge(k) |
---|
[1239] | 551 | |
---|
[2232] | 552 | tend(k,j,i) = tend(k,j,i) + tmp_tend * & |
---|
| 553 | MERGE( 1.0_wp, 0.0_wp, & |
---|
| 554 | BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
[1365] | 555 | |
---|
| 556 | sums_ls_l(k,7) = sums_ls_l(k,7) + tmp_tend & |
---|
[1382] | 557 | * weight_substep(intermediate_timestep_count) |
---|
[1239] | 558 | ENDDO |
---|
| 559 | |
---|
[1382] | 560 | sums_ls_l(nzt+1,7) = sums_ls_l(nzt,7) |
---|
[1239] | 561 | |
---|
| 562 | CASE ( 'pt' ) |
---|
| 563 | |
---|
[2232] | 564 | DO k = nzb+1, nzt |
---|
[1239] | 565 | |
---|
[1365] | 566 | tmp_tend = - ( hom(k,1,4,0) - ( ptnudge(k,nt) * dtp + & |
---|
| 567 | ptnudge(k,nt+1) * dtm ) ) / tmp_tnudge(k) |
---|
[1239] | 568 | |
---|
[2232] | 569 | tend(k,j,i) = tend(k,j,i) + tmp_tend * & |
---|
| 570 | MERGE( 1.0_wp, 0.0_wp, & |
---|
| 571 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1365] | 572 | |
---|
| 573 | sums_ls_l(k,4) = sums_ls_l(k,4) + tmp_tend & |
---|
[1382] | 574 | * weight_substep(intermediate_timestep_count) |
---|
[1239] | 575 | ENDDO |
---|
| 576 | |
---|
[1382] | 577 | sums_ls_l(nzt+1,4) = sums_ls_l(nzt,4) |
---|
[1239] | 578 | |
---|
[1382] | 579 | |
---|
[1239] | 580 | CASE ( 'q' ) |
---|
| 581 | |
---|
[2232] | 582 | DO k = nzb+1, nzt |
---|
[1239] | 583 | |
---|
[1365] | 584 | tmp_tend = - ( hom(k,1,41,0) - ( qnudge(k,nt) * dtp + & |
---|
| 585 | qnudge(k,nt+1) * dtm ) ) / tmp_tnudge(k) |
---|
[1239] | 586 | |
---|
[2232] | 587 | tend(k,j,i) = tend(k,j,i) + tmp_tend * & |
---|
| 588 | MERGE( 1.0_wp, 0.0_wp, & |
---|
| 589 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1365] | 590 | |
---|
| 591 | sums_ls_l(k,5) = sums_ls_l(k,5) + tmp_tend & |
---|
[1382] | 592 | * weight_substep(intermediate_timestep_count) |
---|
[1239] | 593 | ENDDO |
---|
| 594 | |
---|
[1382] | 595 | sums_ls_l(nzt+1,5) = sums_ls_l(nzt,5) |
---|
| 596 | |
---|
[1239] | 597 | CASE DEFAULT |
---|
| 598 | message_string = 'unknown prognostic variable "' // prog_var // '"' |
---|
| 599 | CALL message( 'nudge', 'PA0367', 1, 2, 0, 6, 0 ) |
---|
| 600 | |
---|
| 601 | END SELECT |
---|
| 602 | |
---|
| 603 | |
---|
| 604 | END SUBROUTINE nudge_ij |
---|
| 605 | |
---|
[1380] | 606 | |
---|
[1682] | 607 | !------------------------------------------------------------------------------! |
---|
| 608 | ! Description: |
---|
| 609 | ! ------------ |
---|
| 610 | !> @todo Missing subroutine description. |
---|
| 611 | !------------------------------------------------------------------------------! |
---|
[1380] | 612 | SUBROUTINE nudge_ref ( time ) |
---|
| 613 | |
---|
| 614 | USE arrays_3d, & |
---|
[1398] | 615 | ONLY: time_vert, ptnudge, pt_init, qnudge, q_init, unudge, u_init, & |
---|
| 616 | vnudge, v_init |
---|
[1380] | 617 | |
---|
| 618 | USE kinds |
---|
| 619 | |
---|
| 620 | |
---|
| 621 | IMPLICIT NONE |
---|
| 622 | |
---|
[1682] | 623 | INTEGER(iwp) :: nt !< |
---|
[1380] | 624 | |
---|
[1682] | 625 | REAL(wp) :: fac !< |
---|
| 626 | REAL(wp), INTENT(in) :: time !< |
---|
[1380] | 627 | |
---|
| 628 | ! |
---|
| 629 | !-- Interpolation in time of NUDGING_DATA for pt_init and q_init. This is |
---|
| 630 | !-- needed for correct upper boundary conditions for pt and q and in case that |
---|
| 631 | ! large scale subsidence as well as scalar Rayleigh-damping are used |
---|
| 632 | nt = 1 |
---|
| 633 | DO WHILE ( time > time_vert(nt) ) |
---|
| 634 | nt = nt + 1 |
---|
| 635 | ENDDO |
---|
| 636 | IF ( time /= time_vert(nt) ) THEN |
---|
| 637 | nt = nt - 1 |
---|
| 638 | ENDIF |
---|
| 639 | |
---|
| 640 | fac = ( time-time_vert(nt) ) / ( time_vert(nt+1)-time_vert(nt) ) |
---|
| 641 | |
---|
| 642 | pt_init = ptnudge(:,nt) + fac * ( ptnudge(:,nt+1) - ptnudge(:,nt) ) |
---|
| 643 | q_init = qnudge(:,nt) + fac * ( qnudge(:,nt+1) - qnudge(:,nt) ) |
---|
[1398] | 644 | u_init = unudge(:,nt) + fac * ( unudge(:,nt+1) - unudge(:,nt) ) |
---|
| 645 | v_init = vnudge(:,nt) + fac * ( vnudge(:,nt+1) - vnudge(:,nt) ) |
---|
[1380] | 646 | |
---|
| 647 | END SUBROUTINE nudge_ref |
---|
| 648 | |
---|
[1239] | 649 | END MODULE nudge_mod |
---|