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