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