[1873] | 1 | !> @file advec_s_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_s_up.f90 2233 2017-05-30 18:08:54Z raasch $ |
---|
| 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 | ! |
---|
[1375] | 45 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
| 46 | ! missing variables added to ONLY list |
---|
| 47 | ! |
---|
[1354] | 48 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 49 | ! REAL constants provided with KIND-attribute |
---|
| 50 | ! |
---|
[1321] | 51 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 52 | ! ONLY-attribute added to USE-statements, |
---|
| 53 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 54 | ! kinds are defined in new module kinds, |
---|
| 55 | ! revision history before 2012 removed, |
---|
| 56 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 57 | ! all variable declaration statements |
---|
[1] | 58 | ! |
---|
[1037] | 59 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 60 | ! code put under GPL (PALM 3.9) |
---|
| 61 | ! |
---|
[1011] | 62 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
| 63 | ! cpp switch __nopointer added for pointer free version |
---|
| 64 | ! |
---|
[982] | 65 | ! 981 2012-08-09 14:57:44Z maronga |
---|
| 66 | ! Typo removed |
---|
| 67 | ! |
---|
[1] | 68 | ! Revision 1.1 1997/08/29 08:54:33 raasch |
---|
| 69 | ! Initial revision |
---|
| 70 | ! |
---|
| 71 | ! |
---|
| 72 | ! Description: |
---|
| 73 | ! ------------ |
---|
[1682] | 74 | !> Advection term for scalar quantities using the 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_s_up_mod |
---|
| 79 | |
---|
[1] | 80 | |
---|
| 81 | PRIVATE |
---|
| 82 | PUBLIC advec_s_up |
---|
| 83 | |
---|
| 84 | INTERFACE advec_s_up |
---|
| 85 | MODULE PROCEDURE advec_s_up |
---|
| 86 | MODULE PROCEDURE advec_s_up_ij |
---|
| 87 | END INTERFACE advec_s_up |
---|
| 88 | |
---|
| 89 | CONTAINS |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | !------------------------------------------------------------------------------! |
---|
[1682] | 93 | ! Description: |
---|
| 94 | ! ------------ |
---|
| 95 | !> Call for all grid points |
---|
[1] | 96 | !------------------------------------------------------------------------------! |
---|
| 97 | SUBROUTINE advec_s_up( sk ) |
---|
| 98 | |
---|
[1320] | 99 | USE arrays_3d, & |
---|
| 100 | ONLY: ddzu, 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, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt, & |
---|
| 110 | wall_flags_0 |
---|
[1320] | 111 | |
---|
| 112 | USE kinds |
---|
| 113 | |
---|
| 114 | |
---|
[1] | 115 | IMPLICIT NONE |
---|
| 116 | |
---|
[1682] | 117 | INTEGER(iwp) :: i !< |
---|
| 118 | INTEGER(iwp) :: j !< |
---|
| 119 | INTEGER(iwp) :: k !< |
---|
[1] | 120 | |
---|
[1682] | 121 | REAL(wp) :: ukomp !< |
---|
| 122 | REAL(wp) :: vkomp !< |
---|
| 123 | REAL(wp) :: wkomp !< |
---|
[1010] | 124 | #if defined( __nopointer ) |
---|
[1682] | 125 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !< |
---|
[1010] | 126 | #else |
---|
[1320] | 127 | REAL(wp), DIMENSION(:,:,:), POINTER :: sk |
---|
[1010] | 128 | #endif |
---|
[1] | 129 | |
---|
| 130 | |
---|
| 131 | DO i = nxl, nxr |
---|
| 132 | DO j = nys, nyn |
---|
[2232] | 133 | DO k = nzb+1, nzt |
---|
[1] | 134 | ! |
---|
| 135 | !-- x-direction |
---|
[1353] | 136 | ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
| 137 | IF ( ukomp > 0.0_wp ) THEN |
---|
[1320] | 138 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
[2232] | 139 | ( sk(k,j,i) - sk(k,j,i-1) ) * ddx & |
---|
| 140 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 141 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 142 | ELSE |
---|
[1320] | 143 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
[2232] | 144 | ( sk(k,j,i+1) - sk(k,j,i) ) * ddx & |
---|
| 145 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 146 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 147 | ENDIF |
---|
| 148 | ! |
---|
| 149 | !-- y-direction |
---|
[1353] | 150 | vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
| 151 | IF ( vkomp > 0.0_wp ) THEN |
---|
[1320] | 152 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
[2232] | 153 | ( sk(k,j,i) - sk(k,j-1,i) ) * ddy & |
---|
| 154 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 155 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 156 | ELSE |
---|
[1320] | 157 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
[2232] | 158 | ( sk(k,j+1,i) - sk(k,j,i) ) * ddy & |
---|
| 159 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 160 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 161 | ENDIF |
---|
| 162 | ! |
---|
| 163 | !-- z-direction |
---|
[1353] | 164 | wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
| 165 | IF ( wkomp > 0.0_wp ) THEN |
---|
[1320] | 166 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
[2232] | 167 | ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) & |
---|
| 168 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 169 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 170 | ELSE |
---|
[1320] | 171 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
[2232] | 172 | ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) & |
---|
| 173 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 174 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 175 | ENDIF |
---|
| 176 | |
---|
| 177 | ENDDO |
---|
| 178 | ENDDO |
---|
| 179 | ENDDO |
---|
| 180 | |
---|
| 181 | END SUBROUTINE advec_s_up |
---|
| 182 | |
---|
| 183 | |
---|
| 184 | !------------------------------------------------------------------------------! |
---|
[1682] | 185 | ! Description: |
---|
| 186 | ! ------------ |
---|
| 187 | !> Call for grid point i,j |
---|
[1] | 188 | !------------------------------------------------------------------------------! |
---|
| 189 | SUBROUTINE advec_s_up_ij( i, j, sk ) |
---|
| 190 | |
---|
[1320] | 191 | USE arrays_3d, & |
---|
| 192 | ONLY: ddzu, tend, u, v, w |
---|
[1] | 193 | |
---|
[1320] | 194 | USE control_parameters, & |
---|
| 195 | ONLY: u_gtrans, v_gtrans |
---|
| 196 | |
---|
| 197 | USE grid_variables, & |
---|
| 198 | ONLY: ddx, ddy |
---|
| 199 | |
---|
| 200 | USE indices, & |
---|
[2232] | 201 | ONLY: nxlg, nxrg, nyng, nysg, nzb, nzt, wall_flags_0 |
---|
[1320] | 202 | |
---|
| 203 | USE kinds |
---|
| 204 | |
---|
| 205 | |
---|
[1] | 206 | IMPLICIT NONE |
---|
| 207 | |
---|
[1682] | 208 | INTEGER(iwp) :: i !< |
---|
| 209 | INTEGER(iwp) :: j !< |
---|
| 210 | INTEGER(iwp) :: k !< |
---|
[1] | 211 | |
---|
[1682] | 212 | REAL(wp) :: ukomp !< |
---|
| 213 | REAL(wp) :: vkomp !< |
---|
| 214 | REAL(wp) :: wkomp !< |
---|
[1320] | 215 | |
---|
[1010] | 216 | #if defined( __nopointer ) |
---|
[1682] | 217 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !< |
---|
[1010] | 218 | #else |
---|
[1320] | 219 | REAL(wp), DIMENSION(:,:,:), POINTER :: sk |
---|
[1010] | 220 | #endif |
---|
[1] | 221 | |
---|
| 222 | |
---|
[2232] | 223 | DO k = nzb+1, nzt |
---|
[1] | 224 | ! |
---|
| 225 | !-- x-direction |
---|
[1353] | 226 | ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
| 227 | IF ( ukomp > 0.0_wp ) THEN |
---|
[1320] | 228 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
[2232] | 229 | ( sk(k,j,i) - sk(k,j,i-1) ) * ddx & |
---|
| 230 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 231 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 232 | ELSE |
---|
[1320] | 233 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
[2232] | 234 | ( sk(k,j,i+1) - sk(k,j,i) ) * ddx & |
---|
| 235 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 236 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 237 | ENDIF |
---|
| 238 | ! |
---|
| 239 | !-- y-direction |
---|
[1353] | 240 | vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
| 241 | IF ( vkomp > 0.0_wp ) THEN |
---|
[1320] | 242 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
[2232] | 243 | ( sk(k,j,i) - sk(k,j-1,i) ) * ddy & |
---|
| 244 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 245 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 246 | ELSE |
---|
[1320] | 247 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
[2232] | 248 | ( sk(k,j+1,i) - sk(k,j,i) ) * ddy & |
---|
| 249 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 250 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 251 | ENDIF |
---|
| 252 | ! |
---|
| 253 | !-- z-direction |
---|
[1353] | 254 | wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
| 255 | IF ( wkomp > 0.0_wp ) THEN |
---|
[1320] | 256 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
[2232] | 257 | ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) & |
---|
| 258 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 259 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 260 | ELSE |
---|
[1320] | 261 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
[2232] | 262 | ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) & |
---|
| 263 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 264 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 265 | ENDIF |
---|
| 266 | |
---|
| 267 | ENDDO |
---|
| 268 | |
---|
| 269 | END SUBROUTINE advec_s_up_ij |
---|
| 270 | |
---|
| 271 | END MODULE advec_s_up_mod |
---|