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