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