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