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