1 | !> @file advec_s_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_s_up.f90 2718 2018-01-02 08:49:38Z scharf $ |
---|
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 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
52 | ! missing variables added to ONLY list |
---|
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 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
69 | ! cpp switch __nopointer added for pointer free version |
---|
70 | ! |
---|
71 | ! 981 2012-08-09 14:57:44Z maronga |
---|
72 | ! Typo removed |
---|
73 | ! |
---|
74 | ! Revision 1.1 1997/08/29 08:54:33 raasch |
---|
75 | ! Initial revision |
---|
76 | ! |
---|
77 | ! |
---|
78 | ! Description: |
---|
79 | ! ------------ |
---|
80 | !> Advection term for scalar quantities using the Upstream scheme. |
---|
81 | !> NOTE: vertical advection at k=1 still has wrong grid spacing for w>0! |
---|
82 | !> The same problem occurs for all topography boundaries! |
---|
83 | !------------------------------------------------------------------------------! |
---|
84 | MODULE advec_s_up_mod |
---|
85 | |
---|
86 | |
---|
87 | PRIVATE |
---|
88 | PUBLIC advec_s_up |
---|
89 | |
---|
90 | INTERFACE advec_s_up |
---|
91 | MODULE PROCEDURE advec_s_up |
---|
92 | MODULE PROCEDURE advec_s_up_ij |
---|
93 | END INTERFACE advec_s_up |
---|
94 | |
---|
95 | CONTAINS |
---|
96 | |
---|
97 | |
---|
98 | !------------------------------------------------------------------------------! |
---|
99 | ! Description: |
---|
100 | ! ------------ |
---|
101 | !> Call for all grid points |
---|
102 | !------------------------------------------------------------------------------! |
---|
103 | SUBROUTINE advec_s_up( sk ) |
---|
104 | |
---|
105 | USE arrays_3d, & |
---|
106 | ONLY: ddzu, tend, u, v, w |
---|
107 | |
---|
108 | USE control_parameters, & |
---|
109 | ONLY: u_gtrans, v_gtrans |
---|
110 | |
---|
111 | USE grid_variables, & |
---|
112 | ONLY: ddx, ddy |
---|
113 | |
---|
114 | USE indices, & |
---|
115 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt, & |
---|
116 | wall_flags_0 |
---|
117 | |
---|
118 | USE kinds |
---|
119 | |
---|
120 | |
---|
121 | IMPLICIT NONE |
---|
122 | |
---|
123 | INTEGER(iwp) :: i !< |
---|
124 | INTEGER(iwp) :: j !< |
---|
125 | INTEGER(iwp) :: k !< |
---|
126 | |
---|
127 | REAL(wp) :: ukomp !< |
---|
128 | REAL(wp) :: vkomp !< |
---|
129 | REAL(wp) :: wkomp !< |
---|
130 | #if defined( __nopointer ) |
---|
131 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !< |
---|
132 | #else |
---|
133 | REAL(wp), DIMENSION(:,:,:), POINTER :: sk |
---|
134 | #endif |
---|
135 | |
---|
136 | |
---|
137 | DO i = nxl, nxr |
---|
138 | DO j = nys, nyn |
---|
139 | DO k = nzb+1, nzt |
---|
140 | ! |
---|
141 | !-- x-direction |
---|
142 | ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
143 | IF ( ukomp > 0.0_wp ) THEN |
---|
144 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
145 | ( sk(k,j,i) - sk(k,j,i-1) ) * ddx & |
---|
146 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
147 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
148 | ELSE |
---|
149 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
150 | ( sk(k,j,i+1) - sk(k,j,i) ) * ddx & |
---|
151 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
152 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
153 | ENDIF |
---|
154 | ! |
---|
155 | !-- y-direction |
---|
156 | vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
157 | IF ( vkomp > 0.0_wp ) THEN |
---|
158 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
159 | ( sk(k,j,i) - sk(k,j-1,i) ) * ddy & |
---|
160 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
161 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
162 | ELSE |
---|
163 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
164 | ( sk(k,j+1,i) - sk(k,j,i) ) * ddy & |
---|
165 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
166 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
167 | ENDIF |
---|
168 | ! |
---|
169 | !-- z-direction |
---|
170 | wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
171 | IF ( wkomp > 0.0_wp ) THEN |
---|
172 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
173 | ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) & |
---|
174 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
175 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
176 | ELSE |
---|
177 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
178 | ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) & |
---|
179 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
180 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
181 | ENDIF |
---|
182 | |
---|
183 | ENDDO |
---|
184 | ENDDO |
---|
185 | ENDDO |
---|
186 | |
---|
187 | END SUBROUTINE advec_s_up |
---|
188 | |
---|
189 | |
---|
190 | !------------------------------------------------------------------------------! |
---|
191 | ! Description: |
---|
192 | ! ------------ |
---|
193 | !> Call for grid point i,j |
---|
194 | !------------------------------------------------------------------------------! |
---|
195 | SUBROUTINE advec_s_up_ij( i, j, sk ) |
---|
196 | |
---|
197 | USE arrays_3d, & |
---|
198 | ONLY: ddzu, tend, u, v, w |
---|
199 | |
---|
200 | USE control_parameters, & |
---|
201 | ONLY: u_gtrans, v_gtrans |
---|
202 | |
---|
203 | USE grid_variables, & |
---|
204 | ONLY: ddx, ddy |
---|
205 | |
---|
206 | USE indices, & |
---|
207 | ONLY: nxlg, nxrg, nyng, nysg, nzb, nzt, wall_flags_0 |
---|
208 | |
---|
209 | USE kinds |
---|
210 | |
---|
211 | |
---|
212 | IMPLICIT NONE |
---|
213 | |
---|
214 | INTEGER(iwp) :: i !< |
---|
215 | INTEGER(iwp) :: j !< |
---|
216 | INTEGER(iwp) :: k !< |
---|
217 | |
---|
218 | REAL(wp) :: ukomp !< |
---|
219 | REAL(wp) :: vkomp !< |
---|
220 | REAL(wp) :: wkomp !< |
---|
221 | |
---|
222 | #if defined( __nopointer ) |
---|
223 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !< |
---|
224 | #else |
---|
225 | REAL(wp), DIMENSION(:,:,:), POINTER :: sk |
---|
226 | #endif |
---|
227 | |
---|
228 | |
---|
229 | DO k = nzb+1, nzt |
---|
230 | ! |
---|
231 | !-- x-direction |
---|
232 | ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
233 | IF ( ukomp > 0.0_wp ) THEN |
---|
234 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
235 | ( sk(k,j,i) - sk(k,j,i-1) ) * ddx & |
---|
236 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
237 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
238 | ELSE |
---|
239 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
240 | ( sk(k,j,i+1) - sk(k,j,i) ) * ddx & |
---|
241 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
242 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
243 | ENDIF |
---|
244 | ! |
---|
245 | !-- y-direction |
---|
246 | vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
247 | IF ( vkomp > 0.0_wp ) THEN |
---|
248 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
249 | ( sk(k,j,i) - sk(k,j-1,i) ) * ddy & |
---|
250 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
251 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
252 | ELSE |
---|
253 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
254 | ( sk(k,j+1,i) - sk(k,j,i) ) * ddy & |
---|
255 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
256 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
257 | ENDIF |
---|
258 | ! |
---|
259 | !-- z-direction |
---|
260 | wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
261 | IF ( wkomp > 0.0_wp ) THEN |
---|
262 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
263 | ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) & |
---|
264 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
265 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
266 | ELSE |
---|
267 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
268 | ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) & |
---|
269 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
270 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
271 | ENDIF |
---|
272 | |
---|
273 | ENDDO |
---|
274 | |
---|
275 | END SUBROUTINE advec_s_up_ij |
---|
276 | |
---|
277 | END MODULE advec_s_up_mod |
---|