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