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