[1873] | 1 | !> @file advec_w_up.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1036] | 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. |
---|
[1036] | 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 | ! |
---|
[2718] | 17 | ! Copyright 1997-2018 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[1] | 21 | ! ----------------- |
---|
[1354] | 22 | ! |
---|
[2233] | 23 | ! |
---|
[1321] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: advec_w_up.f90 3255 2018-09-17 11:57:36Z knoop $ |
---|
[3255] | 27 | ! Missing wall flags added |
---|
| 28 | ! |
---|
| 29 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
[2716] | 30 | ! Corrected "Former revisions" section |
---|
| 31 | ! |
---|
| 32 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
| 33 | ! Change in file header (GPL part) |
---|
[1321] | 34 | ! |
---|
[2716] | 35 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
| 36 | ! |
---|
[2233] | 37 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
| 38 | ! topography representation via flags |
---|
| 39 | ! |
---|
[2001] | 40 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 41 | ! Forced header and separation lines into 80 columns |
---|
| 42 | ! |
---|
[1874] | 43 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
| 44 | ! Module renamed (removed _mod) |
---|
| 45 | ! |
---|
| 46 | ! |
---|
[1851] | 47 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
| 48 | ! Module renamed |
---|
| 49 | ! |
---|
| 50 | ! |
---|
[1683] | 51 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 52 | ! Code annotations made doxygen readable |
---|
| 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 | ! revision history before 2012 removed, |
---|
| 62 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 63 | ! all variable declaration statements |
---|
[1] | 64 | ! |
---|
[1037] | 65 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 66 | ! code put under GPL (PALM 3.9) |
---|
| 67 | ! |
---|
[1] | 68 | ! Revision 1.1 1997/08/29 08:56:33 raasch |
---|
| 69 | ! Initial revision |
---|
| 70 | ! |
---|
| 71 | ! |
---|
| 72 | ! Description: |
---|
| 73 | ! ------------ |
---|
[1682] | 74 | !> Advection term for the w velocity-component using upstream scheme. |
---|
| 75 | !> NOTE: vertical advection at k=1 still has wrong grid spacing for w>0 |
---|
| 76 | !> The same problem occurs for all topography boundaries! |
---|
[1] | 77 | !------------------------------------------------------------------------------! |
---|
[1682] | 78 | MODULE advec_w_up_mod |
---|
| 79 | |
---|
[1] | 80 | |
---|
| 81 | PRIVATE |
---|
| 82 | PUBLIC advec_w_up |
---|
| 83 | |
---|
| 84 | INTERFACE advec_w_up |
---|
| 85 | MODULE PROCEDURE advec_w_up |
---|
| 86 | MODULE PROCEDURE advec_w_up_ij |
---|
| 87 | END INTERFACE advec_w_up |
---|
| 88 | |
---|
| 89 | CONTAINS |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | !------------------------------------------------------------------------------! |
---|
[1682] | 93 | ! Description: |
---|
| 94 | ! ------------ |
---|
| 95 | !> Call for all grid points |
---|
[1] | 96 | !------------------------------------------------------------------------------! |
---|
| 97 | SUBROUTINE advec_w_up |
---|
| 98 | |
---|
[1320] | 99 | USE arrays_3d, & |
---|
| 100 | ONLY: ddzw, tend, u, v, w |
---|
[1] | 101 | |
---|
[1320] | 102 | USE control_parameters, & |
---|
| 103 | ONLY: u_gtrans, v_gtrans |
---|
| 104 | |
---|
| 105 | USE grid_variables, & |
---|
| 106 | ONLY: ddx, ddy |
---|
| 107 | |
---|
| 108 | USE indices, & |
---|
[2232] | 109 | ONLY: nxl, nxr, nyn, nys, nzb, nzt, wall_flags_0 |
---|
[1320] | 110 | |
---|
| 111 | USE kinds |
---|
| 112 | |
---|
| 113 | |
---|
[1] | 114 | IMPLICIT NONE |
---|
| 115 | |
---|
[1682] | 116 | INTEGER(iwp) :: i !< |
---|
| 117 | INTEGER(iwp) :: j !< |
---|
| 118 | INTEGER(iwp) :: k !< |
---|
[1] | 119 | |
---|
[1682] | 120 | REAL(wp) :: ukomp !< |
---|
| 121 | REAL(wp) :: vkomp !< |
---|
[1] | 122 | |
---|
[1320] | 123 | |
---|
[1] | 124 | DO i = nxl, nxr |
---|
| 125 | DO j = nys, nyn |
---|
[2232] | 126 | DO k = nzb+1, nzt-1 |
---|
[1] | 127 | ! |
---|
| 128 | !-- x-direction |
---|
[1353] | 129 | ukomp = 0.25_wp * ( u(k,j,i) + u(k,j,i+1) + & |
---|
[1] | 130 | u(k+1,j,i) + u(k+1,j,i+1) ) - u_gtrans |
---|
[1353] | 131 | IF ( ukomp > 0.0_wp ) THEN |
---|
[1320] | 132 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
[2232] | 133 | ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
| 134 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 135 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
[1] | 136 | ELSE |
---|
[1320] | 137 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
[2232] | 138 | ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
| 139 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 140 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
[1] | 141 | ENDIF |
---|
| 142 | ! |
---|
| 143 | !-- y-direction |
---|
[1353] | 144 | vkomp = 0.25_wp * ( v(k,j,i) + v(k,j+1,i) + & |
---|
[1] | 145 | v(k+1,j,i) + v(k+1,j+1,i) ) - v_gtrans |
---|
[1353] | 146 | IF ( vkomp > 0.0_wp ) THEN |
---|
[1320] | 147 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
[2232] | 148 | ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
| 149 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 150 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
[1] | 151 | ELSE |
---|
[1320] | 152 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
[2232] | 153 | ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
| 154 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 155 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
[1] | 156 | ENDIF |
---|
| 157 | ! |
---|
| 158 | !-- z-direction |
---|
[1353] | 159 | IF ( w(k,j,i) > 0.0_wp ) THEN |
---|
[1320] | 160 | tend(k,j,i) = tend(k,j,i) - w(k,j,i) * & |
---|
[2232] | 161 | ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
| 162 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 163 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
[1] | 164 | ELSE |
---|
[1320] | 165 | tend(k,j,i) = tend(k,j,i) - w(k,j,i) * & |
---|
[2232] | 166 | ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
| 167 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 168 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
[1] | 169 | ENDIF |
---|
| 170 | |
---|
| 171 | ENDDO |
---|
| 172 | ENDDO |
---|
| 173 | ENDDO |
---|
| 174 | |
---|
| 175 | END SUBROUTINE advec_w_up |
---|
| 176 | |
---|
| 177 | |
---|
| 178 | !------------------------------------------------------------------------------! |
---|
[1682] | 179 | ! Description: |
---|
| 180 | ! ------------ |
---|
| 181 | !> Call for grid point i,j |
---|
[1] | 182 | !------------------------------------------------------------------------------! |
---|
| 183 | SUBROUTINE advec_w_up_ij( i, j ) |
---|
| 184 | |
---|
[1320] | 185 | USE arrays_3d, & |
---|
| 186 | ONLY: ddzw, tend, u, v, w |
---|
[1] | 187 | |
---|
[1320] | 188 | USE control_parameters, & |
---|
| 189 | ONLY: u_gtrans, v_gtrans |
---|
| 190 | |
---|
| 191 | USE grid_variables, & |
---|
| 192 | ONLY: ddx, ddy |
---|
| 193 | |
---|
| 194 | USE indices, & |
---|
[2232] | 195 | ONLY: nzb, nzt, wall_flags_0 |
---|
[1320] | 196 | |
---|
| 197 | USE kinds |
---|
| 198 | |
---|
| 199 | |
---|
[1] | 200 | IMPLICIT NONE |
---|
| 201 | |
---|
[1682] | 202 | INTEGER(iwp) :: i !< |
---|
| 203 | INTEGER(iwp) :: j !< |
---|
| 204 | INTEGER(iwp) :: k !< |
---|
[1] | 205 | |
---|
[1682] | 206 | REAL(wp) :: ukomp !< |
---|
| 207 | REAL(wp) :: vkomp !< |
---|
[1] | 208 | |
---|
[1320] | 209 | |
---|
[2232] | 210 | DO k = nzb+1, nzt-1 |
---|
[1] | 211 | ! |
---|
| 212 | !-- x-direction |
---|
[1353] | 213 | ukomp = 0.25_wp * ( u(k,j,i) + u(k,j,i+1) + u(k+1,j,i) + u(k+1,j,i+1) & |
---|
[1] | 214 | ) - u_gtrans |
---|
[1353] | 215 | IF ( ukomp > 0.0_wp ) THEN |
---|
[1320] | 216 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
[3255] | 217 | ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
| 218 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 219 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
[1] | 220 | ELSE |
---|
[1320] | 221 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
[3255] | 222 | ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
| 223 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 224 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
[1] | 225 | ENDIF |
---|
| 226 | ! |
---|
| 227 | !-- y-direction |
---|
[1353] | 228 | vkomp = 0.25_wp * ( v(k,j,i) + v(k,j+1,i) + v(k+1,j,i) + v(k+1,j+1,i) & |
---|
[1] | 229 | ) - v_gtrans |
---|
[1353] | 230 | IF ( vkomp > 0.0_wp ) THEN |
---|
[1320] | 231 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
[3255] | 232 | ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
| 233 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 234 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
[1] | 235 | ELSE |
---|
[1320] | 236 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
[3255] | 237 | ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
| 238 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 239 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
[1] | 240 | ENDIF |
---|
| 241 | ! |
---|
| 242 | !-- z-direction |
---|
[1353] | 243 | IF ( w(k,j,i) > 0.0_wp ) THEN |
---|
[1320] | 244 | tend(k,j,i) = tend(k,j,i) - w(k,j,i) * & |
---|
[3255] | 245 | ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
| 246 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 247 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
[1] | 248 | ELSE |
---|
[1320] | 249 | tend(k,j,i) = tend(k,j,i) - w(k,j,i) * & |
---|
[3255] | 250 | ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
| 251 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 252 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
[1] | 253 | ENDIF |
---|
| 254 | |
---|
| 255 | ENDDO |
---|
| 256 | |
---|
| 257 | END SUBROUTINE advec_w_up_ij |
---|
| 258 | |
---|
| 259 | END MODULE advec_w_up_mod |
---|