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