1 | MODULE advec_s_up_mod |
---|
2 | |
---|
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 | ! |
---|
17 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
18 | !--------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: advec_s_up.f90 1321 2014-03-20 09:40:40Z suehring $ |
---|
27 | ! |
---|
28 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
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 |
---|
35 | ! |
---|
36 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
37 | ! code put under GPL (PALM 3.9) |
---|
38 | ! |
---|
39 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
40 | ! cpp switch __nopointer added for pointer free version |
---|
41 | ! |
---|
42 | ! 981 2012-08-09 14:57:44Z maronga |
---|
43 | ! Typo removed |
---|
44 | ! |
---|
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 | |
---|
72 | USE arrays_3d, & |
---|
73 | ONLY: ddzu, tend, u, v, w |
---|
74 | |
---|
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 | |
---|
87 | IMPLICIT NONE |
---|
88 | |
---|
89 | INTEGER(iwp) :: i !: |
---|
90 | INTEGER(iwp) :: j !: |
---|
91 | INTEGER(iwp) :: k !: |
---|
92 | |
---|
93 | REAL(wp) :: ukomp !: |
---|
94 | REAL(wp) :: vkomp !: |
---|
95 | REAL(wp) :: wkomp !: |
---|
96 | #if defined( __nopointer ) |
---|
97 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !: |
---|
98 | #else |
---|
99 | REAL(wp), DIMENSION(:,:,:), POINTER :: sk |
---|
100 | #endif |
---|
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 |
---|
110 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
111 | ( sk(k,j,i) - sk(k,j,i-1) ) * ddx |
---|
112 | ELSE |
---|
113 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
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 |
---|
120 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
121 | ( sk(k,j,i) - sk(k,j-1,i) ) * ddy |
---|
122 | ELSE |
---|
123 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
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 |
---|
130 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
131 | ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) |
---|
132 | ELSE |
---|
133 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
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 | |
---|
149 | USE arrays_3d, & |
---|
150 | ONLY: ddzu, tend, u, v, w |
---|
151 | |
---|
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 | |
---|
164 | IMPLICIT NONE |
---|
165 | |
---|
166 | INTEGER(iwp) :: i !: |
---|
167 | INTEGER(iwp) :: j !: |
---|
168 | INTEGER(iwp) :: k !: |
---|
169 | |
---|
170 | REAL(wp) :: ukomp !: |
---|
171 | REAL(wp) :: vkomp !: |
---|
172 | REAL(wp) :: wkomp !: |
---|
173 | |
---|
174 | #if defined( __nopointer ) |
---|
175 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !: |
---|
176 | #else |
---|
177 | REAL(wp), DIMENSION(:,:,:), POINTER :: sk |
---|
178 | #endif |
---|
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 |
---|
186 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
187 | ( sk(k,j,i) - sk(k,j,i-1) ) * ddx |
---|
188 | ELSE |
---|
189 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
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 |
---|
196 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
197 | ( sk(k,j,i) - sk(k,j-1,i) ) * ddy |
---|
198 | ELSE |
---|
199 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
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 |
---|
206 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
207 | ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) |
---|
208 | ELSE |
---|
209 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
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 |
---|