[1873] | 1 | !> @file advec_s_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_s_up.f90 2718 2018-01-02 08:49:38Z sward $ |
---|
[2716] | 27 | ! Corrected "Former revisions" section |
---|
| 28 | ! |
---|
| 29 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
| 30 | ! Change in file header (GPL part) |
---|
[1321] | 31 | ! |
---|
[2716] | 32 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
| 33 | ! |
---|
[2233] | 34 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
| 35 | ! topography representation via flags |
---|
| 36 | ! |
---|
[2001] | 37 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 38 | ! Forced header and separation lines into 80 columns |
---|
| 39 | ! |
---|
[1874] | 40 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
| 41 | ! Module renamed (removed _mod) |
---|
| 42 | ! |
---|
| 43 | ! |
---|
[1851] | 44 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
| 45 | ! Module renamed |
---|
| 46 | ! |
---|
| 47 | ! |
---|
[1683] | 48 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 49 | ! Code annotations made doxygen readable |
---|
| 50 | ! |
---|
[1375] | 51 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
| 52 | ! missing variables added to ONLY list |
---|
| 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 | ! |
---|
[1011] | 68 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
| 69 | ! cpp switch __nopointer added for pointer free version |
---|
| 70 | ! |
---|
[982] | 71 | ! 981 2012-08-09 14:57:44Z maronga |
---|
| 72 | ! Typo removed |
---|
| 73 | ! |
---|
[1] | 74 | ! Revision 1.1 1997/08/29 08:54:33 raasch |
---|
| 75 | ! Initial revision |
---|
| 76 | ! |
---|
| 77 | ! |
---|
| 78 | ! Description: |
---|
| 79 | ! ------------ |
---|
[1682] | 80 | !> Advection term for scalar quantities using the Upstream scheme. |
---|
| 81 | !> NOTE: vertical advection at k=1 still has wrong grid spacing for w>0! |
---|
| 82 | !> The same problem occurs for all topography boundaries! |
---|
[1] | 83 | !------------------------------------------------------------------------------! |
---|
[1682] | 84 | MODULE advec_s_up_mod |
---|
| 85 | |
---|
[1] | 86 | |
---|
| 87 | PRIVATE |
---|
| 88 | PUBLIC advec_s_up |
---|
| 89 | |
---|
| 90 | INTERFACE advec_s_up |
---|
| 91 | MODULE PROCEDURE advec_s_up |
---|
| 92 | MODULE PROCEDURE advec_s_up_ij |
---|
| 93 | END INTERFACE advec_s_up |
---|
| 94 | |
---|
| 95 | CONTAINS |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | !------------------------------------------------------------------------------! |
---|
[1682] | 99 | ! Description: |
---|
| 100 | ! ------------ |
---|
| 101 | !> Call for all grid points |
---|
[1] | 102 | !------------------------------------------------------------------------------! |
---|
| 103 | SUBROUTINE advec_s_up( sk ) |
---|
| 104 | |
---|
[1320] | 105 | USE arrays_3d, & |
---|
| 106 | ONLY: ddzu, tend, u, v, w |
---|
[1] | 107 | |
---|
[1320] | 108 | USE control_parameters, & |
---|
| 109 | ONLY: u_gtrans, v_gtrans |
---|
| 110 | |
---|
| 111 | USE grid_variables, & |
---|
| 112 | ONLY: ddx, ddy |
---|
| 113 | |
---|
| 114 | USE indices, & |
---|
[2232] | 115 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt, & |
---|
| 116 | wall_flags_0 |
---|
[1320] | 117 | |
---|
| 118 | USE kinds |
---|
| 119 | |
---|
| 120 | |
---|
[1] | 121 | IMPLICIT NONE |
---|
| 122 | |
---|
[1682] | 123 | INTEGER(iwp) :: i !< |
---|
| 124 | INTEGER(iwp) :: j !< |
---|
| 125 | INTEGER(iwp) :: k !< |
---|
[1] | 126 | |
---|
[1682] | 127 | REAL(wp) :: ukomp !< |
---|
| 128 | REAL(wp) :: vkomp !< |
---|
| 129 | REAL(wp) :: wkomp !< |
---|
[1010] | 130 | #if defined( __nopointer ) |
---|
[1682] | 131 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !< |
---|
[1010] | 132 | #else |
---|
[1320] | 133 | REAL(wp), DIMENSION(:,:,:), POINTER :: sk |
---|
[1010] | 134 | #endif |
---|
[1] | 135 | |
---|
| 136 | |
---|
| 137 | DO i = nxl, nxr |
---|
| 138 | DO j = nys, nyn |
---|
[2232] | 139 | DO k = nzb+1, nzt |
---|
[1] | 140 | ! |
---|
| 141 | !-- x-direction |
---|
[1353] | 142 | ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
| 143 | IF ( ukomp > 0.0_wp ) THEN |
---|
[1320] | 144 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
[2232] | 145 | ( sk(k,j,i) - sk(k,j,i-1) ) * ddx & |
---|
| 146 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 147 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 148 | ELSE |
---|
[1320] | 149 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
[2232] | 150 | ( sk(k,j,i+1) - sk(k,j,i) ) * ddx & |
---|
| 151 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 152 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 153 | ENDIF |
---|
| 154 | ! |
---|
| 155 | !-- y-direction |
---|
[1353] | 156 | vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
| 157 | IF ( vkomp > 0.0_wp ) THEN |
---|
[1320] | 158 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
[2232] | 159 | ( sk(k,j,i) - sk(k,j-1,i) ) * ddy & |
---|
| 160 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 161 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 162 | ELSE |
---|
[1320] | 163 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
[2232] | 164 | ( sk(k,j+1,i) - sk(k,j,i) ) * ddy & |
---|
| 165 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 166 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 167 | ENDIF |
---|
| 168 | ! |
---|
| 169 | !-- z-direction |
---|
[1353] | 170 | wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
| 171 | IF ( wkomp > 0.0_wp ) THEN |
---|
[1320] | 172 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
[2232] | 173 | ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) & |
---|
| 174 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 175 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 176 | ELSE |
---|
[1320] | 177 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
[2232] | 178 | ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) & |
---|
| 179 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 180 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 181 | ENDIF |
---|
| 182 | |
---|
| 183 | ENDDO |
---|
| 184 | ENDDO |
---|
| 185 | ENDDO |
---|
| 186 | |
---|
| 187 | END SUBROUTINE advec_s_up |
---|
| 188 | |
---|
| 189 | |
---|
| 190 | !------------------------------------------------------------------------------! |
---|
[1682] | 191 | ! Description: |
---|
| 192 | ! ------------ |
---|
| 193 | !> Call for grid point i,j |
---|
[1] | 194 | !------------------------------------------------------------------------------! |
---|
| 195 | SUBROUTINE advec_s_up_ij( i, j, sk ) |
---|
| 196 | |
---|
[1320] | 197 | USE arrays_3d, & |
---|
| 198 | ONLY: ddzu, tend, u, v, w |
---|
[1] | 199 | |
---|
[1320] | 200 | USE control_parameters, & |
---|
| 201 | ONLY: u_gtrans, v_gtrans |
---|
| 202 | |
---|
| 203 | USE grid_variables, & |
---|
| 204 | ONLY: ddx, ddy |
---|
| 205 | |
---|
| 206 | USE indices, & |
---|
[2232] | 207 | ONLY: nxlg, nxrg, nyng, nysg, nzb, nzt, wall_flags_0 |
---|
[1320] | 208 | |
---|
| 209 | USE kinds |
---|
| 210 | |
---|
| 211 | |
---|
[1] | 212 | IMPLICIT NONE |
---|
| 213 | |
---|
[1682] | 214 | INTEGER(iwp) :: i !< |
---|
| 215 | INTEGER(iwp) :: j !< |
---|
| 216 | INTEGER(iwp) :: k !< |
---|
[1] | 217 | |
---|
[1682] | 218 | REAL(wp) :: ukomp !< |
---|
| 219 | REAL(wp) :: vkomp !< |
---|
| 220 | REAL(wp) :: wkomp !< |
---|
[1320] | 221 | |
---|
[1010] | 222 | #if defined( __nopointer ) |
---|
[1682] | 223 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !< |
---|
[1010] | 224 | #else |
---|
[1320] | 225 | REAL(wp), DIMENSION(:,:,:), POINTER :: sk |
---|
[1010] | 226 | #endif |
---|
[1] | 227 | |
---|
| 228 | |
---|
[2232] | 229 | DO k = nzb+1, nzt |
---|
[1] | 230 | ! |
---|
| 231 | !-- x-direction |
---|
[1353] | 232 | ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
| 233 | IF ( ukomp > 0.0_wp ) THEN |
---|
[1320] | 234 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
[2232] | 235 | ( sk(k,j,i) - sk(k,j,i-1) ) * ddx & |
---|
| 236 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 237 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 238 | ELSE |
---|
[1320] | 239 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
[2232] | 240 | ( sk(k,j,i+1) - sk(k,j,i) ) * ddx & |
---|
| 241 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 242 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 243 | ENDIF |
---|
| 244 | ! |
---|
| 245 | !-- y-direction |
---|
[1353] | 246 | vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
| 247 | IF ( vkomp > 0.0_wp ) THEN |
---|
[1320] | 248 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
[2232] | 249 | ( sk(k,j,i) - sk(k,j-1,i) ) * ddy & |
---|
| 250 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 251 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 252 | ELSE |
---|
[1320] | 253 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
[2232] | 254 | ( sk(k,j+1,i) - sk(k,j,i) ) * ddy & |
---|
| 255 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 256 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 257 | ENDIF |
---|
| 258 | ! |
---|
| 259 | !-- z-direction |
---|
[1353] | 260 | wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
| 261 | IF ( wkomp > 0.0_wp ) THEN |
---|
[1320] | 262 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
[2232] | 263 | ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) & |
---|
| 264 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 265 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 266 | ELSE |
---|
[1320] | 267 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
[2232] | 268 | ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) & |
---|
| 269 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 270 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[1] | 271 | ENDIF |
---|
| 272 | |
---|
| 273 | ENDDO |
---|
| 274 | |
---|
| 275 | END SUBROUTINE advec_s_up_ij |
---|
| 276 | |
---|
| 277 | END MODULE advec_s_up_mod |
---|