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