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