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 3538 2018-11-20 10:55:41Z gronemeier $ |
---|
27 | ! Remove unnecessary double-masking of topography |
---|
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 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
55 | ! missing variables added to ONLY list |
---|
56 | ! |
---|
57 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
58 | ! REAL constants provided with KIND-attribute |
---|
59 | ! |
---|
60 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
61 | ! ONLY-attribute added to USE-statements, |
---|
62 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
63 | ! kinds are defined in new module kinds, |
---|
64 | ! revision history before 2012 removed, |
---|
65 | ! comment fields (!:) to be used for variable explanations added to |
---|
66 | ! all variable declaration statements |
---|
67 | ! |
---|
68 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
69 | ! code put under GPL (PALM 3.9) |
---|
70 | ! |
---|
71 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
72 | ! cpp switch __nopointer added for pointer free version |
---|
73 | ! |
---|
74 | ! 981 2012-08-09 14:57:44Z maronga |
---|
75 | ! Typo removed |
---|
76 | ! |
---|
77 | ! Revision 1.1 1997/08/29 08:54:33 raasch |
---|
78 | ! Initial revision |
---|
79 | ! |
---|
80 | ! |
---|
81 | ! Description: |
---|
82 | ! ------------ |
---|
83 | !> Advection term for scalar quantities using the Upstream scheme. |
---|
84 | !> NOTE: vertical advection at k=1 still has wrong grid spacing for w>0! |
---|
85 | !> The same problem occurs for all topography boundaries! |
---|
86 | !------------------------------------------------------------------------------! |
---|
87 | MODULE advec_s_up_mod |
---|
88 | |
---|
89 | |
---|
90 | PRIVATE |
---|
91 | PUBLIC advec_s_up |
---|
92 | |
---|
93 | INTERFACE advec_s_up |
---|
94 | MODULE PROCEDURE advec_s_up |
---|
95 | MODULE PROCEDURE advec_s_up_ij |
---|
96 | END INTERFACE advec_s_up |
---|
97 | |
---|
98 | CONTAINS |
---|
99 | |
---|
100 | |
---|
101 | !------------------------------------------------------------------------------! |
---|
102 | ! Description: |
---|
103 | ! ------------ |
---|
104 | !> Call for all grid points |
---|
105 | !------------------------------------------------------------------------------! |
---|
106 | SUBROUTINE advec_s_up( sk ) |
---|
107 | |
---|
108 | USE arrays_3d, & |
---|
109 | ONLY: ddzu, tend, u, v, w |
---|
110 | |
---|
111 | USE control_parameters, & |
---|
112 | ONLY: u_gtrans, v_gtrans |
---|
113 | |
---|
114 | USE grid_variables, & |
---|
115 | ONLY: ddx, ddy |
---|
116 | |
---|
117 | USE indices, & |
---|
118 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt |
---|
119 | |
---|
120 | USE kinds |
---|
121 | |
---|
122 | |
---|
123 | IMPLICIT NONE |
---|
124 | |
---|
125 | INTEGER(iwp) :: i !< |
---|
126 | INTEGER(iwp) :: j !< |
---|
127 | INTEGER(iwp) :: k !< |
---|
128 | |
---|
129 | REAL(wp) :: ukomp !< |
---|
130 | REAL(wp) :: vkomp !< |
---|
131 | REAL(wp) :: wkomp !< |
---|
132 | #if defined( __nopointer ) |
---|
133 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !< |
---|
134 | #else |
---|
135 | REAL(wp), DIMENSION(:,:,:), POINTER :: sk |
---|
136 | #endif |
---|
137 | |
---|
138 | |
---|
139 | DO i = nxl, nxr |
---|
140 | DO j = nys, nyn |
---|
141 | DO k = nzb+1, nzt |
---|
142 | ! |
---|
143 | !-- x-direction |
---|
144 | ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
145 | IF ( ukomp > 0.0_wp ) THEN |
---|
146 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
147 | ( sk(k,j,i) - sk(k,j,i-1) ) * ddx |
---|
148 | ELSE |
---|
149 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
150 | ( sk(k,j,i+1) - sk(k,j,i) ) * ddx |
---|
151 | ENDIF |
---|
152 | ! |
---|
153 | !-- y-direction |
---|
154 | vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
155 | IF ( vkomp > 0.0_wp ) THEN |
---|
156 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
157 | ( sk(k,j,i) - sk(k,j-1,i) ) * ddy |
---|
158 | ELSE |
---|
159 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
160 | ( sk(k,j+1,i) - sk(k,j,i) ) * ddy |
---|
161 | ENDIF |
---|
162 | ! |
---|
163 | !-- z-direction |
---|
164 | wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
165 | IF ( wkomp > 0.0_wp ) THEN |
---|
166 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
167 | ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) |
---|
168 | ELSE |
---|
169 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
170 | ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) |
---|
171 | ENDIF |
---|
172 | |
---|
173 | ENDDO |
---|
174 | ENDDO |
---|
175 | ENDDO |
---|
176 | |
---|
177 | END SUBROUTINE advec_s_up |
---|
178 | |
---|
179 | |
---|
180 | !------------------------------------------------------------------------------! |
---|
181 | ! Description: |
---|
182 | ! ------------ |
---|
183 | !> Call for grid point i,j |
---|
184 | !------------------------------------------------------------------------------! |
---|
185 | SUBROUTINE advec_s_up_ij( i, j, sk ) |
---|
186 | |
---|
187 | USE arrays_3d, & |
---|
188 | ONLY: ddzu, tend, u, v, w |
---|
189 | |
---|
190 | USE control_parameters, & |
---|
191 | ONLY: u_gtrans, v_gtrans |
---|
192 | |
---|
193 | USE grid_variables, & |
---|
194 | ONLY: ddx, ddy |
---|
195 | |
---|
196 | USE indices, & |
---|
197 | ONLY: nxlg, nxrg, nyng, nysg, nzb, nzt |
---|
198 | |
---|
199 | USE kinds |
---|
200 | |
---|
201 | |
---|
202 | IMPLICIT NONE |
---|
203 | |
---|
204 | INTEGER(iwp) :: i !< |
---|
205 | INTEGER(iwp) :: j !< |
---|
206 | INTEGER(iwp) :: k !< |
---|
207 | |
---|
208 | REAL(wp) :: ukomp !< |
---|
209 | REAL(wp) :: vkomp !< |
---|
210 | REAL(wp) :: wkomp !< |
---|
211 | |
---|
212 | #if defined( __nopointer ) |
---|
213 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !< |
---|
214 | #else |
---|
215 | REAL(wp), DIMENSION(:,:,:), POINTER :: sk |
---|
216 | #endif |
---|
217 | |
---|
218 | |
---|
219 | DO k = nzb+1, nzt |
---|
220 | ! |
---|
221 | !-- x-direction |
---|
222 | ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
223 | IF ( ukomp > 0.0_wp ) THEN |
---|
224 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
225 | ( sk(k,j,i) - sk(k,j,i-1) ) * ddx |
---|
226 | ELSE |
---|
227 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
228 | ( sk(k,j,i+1) - sk(k,j,i) ) * ddx |
---|
229 | ENDIF |
---|
230 | ! |
---|
231 | !-- y-direction |
---|
232 | vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
233 | IF ( vkomp > 0.0_wp ) THEN |
---|
234 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
235 | ( sk(k,j,i) - sk(k,j-1,i) ) * ddy |
---|
236 | ELSE |
---|
237 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
238 | ( sk(k,j+1,i) - sk(k,j,i) ) * ddy |
---|
239 | ENDIF |
---|
240 | ! |
---|
241 | !-- z-direction |
---|
242 | wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
243 | IF ( wkomp > 0.0_wp ) THEN |
---|
244 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
245 | ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) |
---|
246 | ELSE |
---|
247 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
248 | ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) |
---|
249 | ENDIF |
---|
250 | |
---|
251 | ENDDO |
---|
252 | |
---|
253 | END SUBROUTINE advec_s_up_ij |
---|
254 | |
---|
255 | END MODULE advec_s_up_mod |
---|