1 | !> @file advec_u_up.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of the PALM model system. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
6 | ! terms of the GNU General Public License as published by the Free Software |
---|
7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
8 | ! 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-2018 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: advec_u_up.f90 2718 2018-01-02 08:49:38Z schwenkel $ |
---|
27 | ! Corrected "Former revisions" section |
---|
28 | ! |
---|
29 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
30 | ! Change in file header (GPL part) |
---|
31 | ! |
---|
32 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
33 | ! |
---|
34 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
35 | ! topography representation via flags |
---|
36 | ! |
---|
37 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
38 | ! Forced header and separation lines into 80 columns |
---|
39 | ! |
---|
40 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
41 | ! Module renamed (removed _mod) |
---|
42 | ! |
---|
43 | ! |
---|
44 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
45 | ! Module renamed |
---|
46 | ! |
---|
47 | ! |
---|
48 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
49 | ! Code annotations made doxygen readable |
---|
50 | ! |
---|
51 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
52 | ! REAL constants provided with KIND-attribute |
---|
53 | ! |
---|
54 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
55 | ! ONLY-attribute added to USE-statements, |
---|
56 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
57 | ! kinds are defined in new module kinds, |
---|
58 | ! revision history before 2012 removed, |
---|
59 | ! comment fields (!:) to be used for variable explanations added to |
---|
60 | ! all variable declaration statements |
---|
61 | ! |
---|
62 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
63 | ! code put under GPL (PALM 3.9) |
---|
64 | ! |
---|
65 | ! Revision 1.1 1997/08/29 08:55:25 raasch |
---|
66 | ! Initial revision |
---|
67 | ! |
---|
68 | ! |
---|
69 | ! Description: |
---|
70 | ! ------------ |
---|
71 | !> Advection term for the u velocity-component using upstream scheme. |
---|
72 | !> NOTE: vertical advection at k=1 still has wrong grid spacing for w>0! |
---|
73 | !> The same problem occurs for all topography boundaries! |
---|
74 | !------------------------------------------------------------------------------! |
---|
75 | MODULE advec_u_up_mod |
---|
76 | |
---|
77 | |
---|
78 | PRIVATE |
---|
79 | PUBLIC advec_u_up |
---|
80 | |
---|
81 | INTERFACE advec_u_up |
---|
82 | MODULE PROCEDURE advec_u_up |
---|
83 | MODULE PROCEDURE advec_u_up_ij |
---|
84 | END INTERFACE advec_u_up |
---|
85 | |
---|
86 | CONTAINS |
---|
87 | |
---|
88 | |
---|
89 | !------------------------------------------------------------------------------! |
---|
90 | ! Description: |
---|
91 | ! ------------ |
---|
92 | !> Call for all grid points |
---|
93 | !------------------------------------------------------------------------------! |
---|
94 | SUBROUTINE advec_u_up |
---|
95 | |
---|
96 | USE arrays_3d, & |
---|
97 | ONLY: ddzu, tend, u, v, w |
---|
98 | |
---|
99 | USE control_parameters, & |
---|
100 | ONLY: u_gtrans, v_gtrans |
---|
101 | |
---|
102 | USE grid_variables, & |
---|
103 | ONLY: ddx, ddy |
---|
104 | |
---|
105 | USE indices, & |
---|
106 | ONLY: nxlu, nxr, nyn, nys, nzb, nzt, wall_flags_0 |
---|
107 | |
---|
108 | USE kinds |
---|
109 | |
---|
110 | |
---|
111 | IMPLICIT NONE |
---|
112 | |
---|
113 | INTEGER(iwp) :: i !< |
---|
114 | INTEGER(iwp) :: j !< |
---|
115 | INTEGER(iwp) :: k !< |
---|
116 | |
---|
117 | REAL(wp) :: ukomp !< |
---|
118 | REAL(wp) :: vkomp !< |
---|
119 | REAL(wp) :: wkomp !< |
---|
120 | |
---|
121 | |
---|
122 | DO i = nxlu, nxr |
---|
123 | DO j = nys, nyn |
---|
124 | DO k = nzb+1, nzt |
---|
125 | ! |
---|
126 | !-- x-direction |
---|
127 | ukomp = u(k,j,i) - u_gtrans |
---|
128 | IF ( ukomp > 0.0_wp ) THEN |
---|
129 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
130 | ( u(k,j,i) - u(k,j,i-1) ) * ddx & |
---|
131 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
132 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
133 | ELSE |
---|
134 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
135 | ( u(k,j,i+1) - u(k,j,i) ) * ddx & |
---|
136 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
137 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
138 | ENDIF |
---|
139 | ! |
---|
140 | !-- y-direction |
---|
141 | vkomp = 0.25_wp * ( v(k,j,i) + v(k,j+1,i) + & |
---|
142 | v(k,j,i-1) + v(k,j+1,i-1) ) - v_gtrans |
---|
143 | IF ( vkomp > 0.0_wp ) THEN |
---|
144 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
145 | ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
146 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
147 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
148 | ELSE |
---|
149 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
150 | ( u(k,j+1,i) - u(k,j,i) ) * ddy & |
---|
151 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
152 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
153 | ENDIF |
---|
154 | ! |
---|
155 | !-- z-direction |
---|
156 | wkomp = 0.25_wp * ( w(k,j,i) + w(k-1,j,i) + & |
---|
157 | w(k,j,i-1) + w(k-1,j,i-1) ) |
---|
158 | IF ( wkomp > 0.0_wp ) THEN |
---|
159 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
160 | ( u(k,j,i) - u(k-1,j,i) ) * ddzu(k) & |
---|
161 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
162 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
163 | ELSE |
---|
164 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
165 | ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
166 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
167 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
168 | ENDIF |
---|
169 | |
---|
170 | ENDDO |
---|
171 | ENDDO |
---|
172 | ENDDO |
---|
173 | |
---|
174 | END SUBROUTINE advec_u_up |
---|
175 | |
---|
176 | |
---|
177 | !------------------------------------------------------------------------------! |
---|
178 | ! Description: |
---|
179 | ! ------------ |
---|
180 | !> Call for grid point i,j |
---|
181 | !------------------------------------------------------------------------------! |
---|
182 | SUBROUTINE advec_u_up_ij( i, j ) |
---|
183 | |
---|
184 | USE arrays_3d, & |
---|
185 | ONLY: ddzu, tend, u, v, w |
---|
186 | |
---|
187 | USE control_parameters, & |
---|
188 | ONLY: u_gtrans, v_gtrans |
---|
189 | |
---|
190 | USE grid_variables, & |
---|
191 | ONLY: ddx, ddy |
---|
192 | |
---|
193 | USE indices, & |
---|
194 | ONLY: nzb, nzt, wall_flags_0 |
---|
195 | |
---|
196 | USE kinds |
---|
197 | |
---|
198 | |
---|
199 | IMPLICIT NONE |
---|
200 | |
---|
201 | INTEGER(iwp) :: i !< |
---|
202 | INTEGER(iwp) :: j !< |
---|
203 | INTEGER(iwp) :: k !< |
---|
204 | |
---|
205 | REAL(wp) :: ukomp !< |
---|
206 | REAL(wp) :: vkomp !< |
---|
207 | REAL(wp) :: wkomp !< |
---|
208 | |
---|
209 | |
---|
210 | DO k = nzb+1, nzt |
---|
211 | ! |
---|
212 | !-- x-direction |
---|
213 | ukomp = u(k,j,i) - u_gtrans |
---|
214 | IF ( ukomp > 0.0_wp ) THEN |
---|
215 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
216 | ( u(k,j,i) - u(k,j,i-1) ) * ddx & |
---|
217 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
218 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
219 | ELSE |
---|
220 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
221 | ( u(k,j,i+1) - u(k,j,i) ) * ddx & |
---|
222 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
223 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
224 | ENDIF |
---|
225 | ! |
---|
226 | !-- y-direction |
---|
227 | vkomp = 0.25_wp * ( v(k,j,i) + v(k,j+1,i) + v(k,j,i-1) + v(k,j+1,i-1) & |
---|
228 | ) - v_gtrans |
---|
229 | IF ( vkomp > 0.0_wp ) THEN |
---|
230 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
231 | ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
232 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
233 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
234 | ELSE |
---|
235 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
236 | ( u(k,j+1,i) - u(k,j,i) ) * ddy & |
---|
237 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
238 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
239 | ENDIF |
---|
240 | ! |
---|
241 | !-- z-direction |
---|
242 | wkomp = 0.25_wp * ( w(k,j,i) + w(k-1,j,i) + w(k,j,i-1) + w(k-1,j,i-1) ) |
---|
243 | IF ( wkomp > 0.0_wp ) THEN |
---|
244 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
245 | ( u(k,j,i) - u(k-1,j,i) ) * ddzu(k) & |
---|
246 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
247 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
248 | ELSE |
---|
249 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
250 | ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
251 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
252 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
253 | ENDIF |
---|
254 | |
---|
255 | ENDDO |
---|
256 | |
---|
257 | END SUBROUTINE advec_u_up_ij |
---|
258 | |
---|
259 | END MODULE advec_u_up_mod |
---|