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