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