1 | !> @file advec_s_up.f90 |
---|
2 | !--------------------------------------------------------------------------------! |
---|
3 | ! This file is part of PALM. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
6 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
7 | ! either version 3 of the License, or (at your option) any later version. |
---|
8 | ! |
---|
9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
10 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
11 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
12 | ! |
---|
13 | ! You should have received a copy of the GNU General Public License along with |
---|
14 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
15 | ! |
---|
16 | ! Copyright 1997-2016 Leibniz Universitaet Hannover |
---|
17 | !--------------------------------------------------------------------------------! |
---|
18 | ! |
---|
19 | ! Current revisions: |
---|
20 | ! ----------------- |
---|
21 | ! |
---|
22 | ! |
---|
23 | ! Former revisions: |
---|
24 | ! ----------------- |
---|
25 | ! $Id: advec_s_up.f90 1874 2016-04-18 14:51:10Z suehring $ |
---|
26 | ! |
---|
27 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
28 | ! Module renamed (removed _mod) |
---|
29 | ! |
---|
30 | ! |
---|
31 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
32 | ! Module renamed |
---|
33 | ! |
---|
34 | ! |
---|
35 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
36 | ! Code annotations made doxygen readable |
---|
37 | ! |
---|
38 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
39 | ! missing variables added to ONLY list |
---|
40 | ! |
---|
41 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
42 | ! REAL constants provided with KIND-attribute |
---|
43 | ! |
---|
44 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
45 | ! ONLY-attribute added to USE-statements, |
---|
46 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
47 | ! kinds are defined in new module kinds, |
---|
48 | ! revision history before 2012 removed, |
---|
49 | ! comment fields (!:) to be used for variable explanations added to |
---|
50 | ! all variable declaration statements |
---|
51 | ! |
---|
52 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
53 | ! code put under GPL (PALM 3.9) |
---|
54 | ! |
---|
55 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
56 | ! cpp switch __nopointer added for pointer free version |
---|
57 | ! |
---|
58 | ! 981 2012-08-09 14:57:44Z maronga |
---|
59 | ! Typo removed |
---|
60 | ! |
---|
61 | ! Revision 1.1 1997/08/29 08:54:33 raasch |
---|
62 | ! Initial revision |
---|
63 | ! |
---|
64 | ! |
---|
65 | ! Description: |
---|
66 | ! ------------ |
---|
67 | !> Advection term for scalar quantities using the Upstream scheme. |
---|
68 | !> NOTE: vertical advection at k=1 still has wrong grid spacing for w>0! |
---|
69 | !> The same problem occurs for all topography boundaries! |
---|
70 | !------------------------------------------------------------------------------! |
---|
71 | MODULE advec_s_up_mod |
---|
72 | |
---|
73 | |
---|
74 | PRIVATE |
---|
75 | PUBLIC advec_s_up |
---|
76 | |
---|
77 | INTERFACE advec_s_up |
---|
78 | MODULE PROCEDURE advec_s_up |
---|
79 | MODULE PROCEDURE advec_s_up_ij |
---|
80 | END INTERFACE advec_s_up |
---|
81 | |
---|
82 | CONTAINS |
---|
83 | |
---|
84 | |
---|
85 | !------------------------------------------------------------------------------! |
---|
86 | ! Description: |
---|
87 | ! ------------ |
---|
88 | !> Call for all grid points |
---|
89 | !------------------------------------------------------------------------------! |
---|
90 | SUBROUTINE advec_s_up( sk ) |
---|
91 | |
---|
92 | USE arrays_3d, & |
---|
93 | ONLY: ddzu, tend, u, v, w |
---|
94 | |
---|
95 | USE control_parameters, & |
---|
96 | ONLY: u_gtrans, v_gtrans |
---|
97 | |
---|
98 | USE grid_variables, & |
---|
99 | ONLY: ddx, ddy |
---|
100 | |
---|
101 | USE indices, & |
---|
102 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzb_s_inner,& |
---|
103 | nzt |
---|
104 | |
---|
105 | USE kinds |
---|
106 | |
---|
107 | |
---|
108 | IMPLICIT NONE |
---|
109 | |
---|
110 | INTEGER(iwp) :: i !< |
---|
111 | INTEGER(iwp) :: j !< |
---|
112 | INTEGER(iwp) :: k !< |
---|
113 | |
---|
114 | REAL(wp) :: ukomp !< |
---|
115 | REAL(wp) :: vkomp !< |
---|
116 | REAL(wp) :: wkomp !< |
---|
117 | #if defined( __nopointer ) |
---|
118 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !< |
---|
119 | #else |
---|
120 | REAL(wp), DIMENSION(:,:,:), POINTER :: sk |
---|
121 | #endif |
---|
122 | |
---|
123 | |
---|
124 | DO i = nxl, nxr |
---|
125 | DO j = nys, nyn |
---|
126 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
127 | ! |
---|
128 | !-- x-direction |
---|
129 | ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
130 | IF ( ukomp > 0.0_wp ) THEN |
---|
131 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
132 | ( sk(k,j,i) - sk(k,j,i-1) ) * ddx |
---|
133 | ELSE |
---|
134 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
135 | ( sk(k,j,i+1) - sk(k,j,i) ) * ddx |
---|
136 | ENDIF |
---|
137 | ! |
---|
138 | !-- y-direction |
---|
139 | vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
140 | IF ( vkomp > 0.0_wp ) THEN |
---|
141 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
142 | ( sk(k,j,i) - sk(k,j-1,i) ) * ddy |
---|
143 | ELSE |
---|
144 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
145 | ( sk(k,j+1,i) - sk(k,j,i) ) * ddy |
---|
146 | ENDIF |
---|
147 | ! |
---|
148 | !-- z-direction |
---|
149 | wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
150 | IF ( wkomp > 0.0_wp ) THEN |
---|
151 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
152 | ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) |
---|
153 | ELSE |
---|
154 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
155 | ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) |
---|
156 | ENDIF |
---|
157 | |
---|
158 | ENDDO |
---|
159 | ENDDO |
---|
160 | ENDDO |
---|
161 | |
---|
162 | END SUBROUTINE advec_s_up |
---|
163 | |
---|
164 | |
---|
165 | !------------------------------------------------------------------------------! |
---|
166 | ! Description: |
---|
167 | ! ------------ |
---|
168 | !> Call for grid point i,j |
---|
169 | !------------------------------------------------------------------------------! |
---|
170 | SUBROUTINE advec_s_up_ij( i, j, sk ) |
---|
171 | |
---|
172 | USE arrays_3d, & |
---|
173 | ONLY: ddzu, tend, u, v, w |
---|
174 | |
---|
175 | USE control_parameters, & |
---|
176 | ONLY: u_gtrans, v_gtrans |
---|
177 | |
---|
178 | USE grid_variables, & |
---|
179 | ONLY: ddx, ddy |
---|
180 | |
---|
181 | USE indices, & |
---|
182 | ONLY: nxlg, nxrg, nyng, nysg, nzb, nzb_s_inner, nzt |
---|
183 | |
---|
184 | USE kinds |
---|
185 | |
---|
186 | |
---|
187 | IMPLICIT NONE |
---|
188 | |
---|
189 | INTEGER(iwp) :: i !< |
---|
190 | INTEGER(iwp) :: j !< |
---|
191 | INTEGER(iwp) :: k !< |
---|
192 | |
---|
193 | REAL(wp) :: ukomp !< |
---|
194 | REAL(wp) :: vkomp !< |
---|
195 | REAL(wp) :: wkomp !< |
---|
196 | |
---|
197 | #if defined( __nopointer ) |
---|
198 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !< |
---|
199 | #else |
---|
200 | REAL(wp), DIMENSION(:,:,:), POINTER :: sk |
---|
201 | #endif |
---|
202 | |
---|
203 | |
---|
204 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
205 | ! |
---|
206 | !-- x-direction |
---|
207 | ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
208 | IF ( ukomp > 0.0_wp ) THEN |
---|
209 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
210 | ( sk(k,j,i) - sk(k,j,i-1) ) * ddx |
---|
211 | ELSE |
---|
212 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
213 | ( sk(k,j,i+1) - sk(k,j,i) ) * ddx |
---|
214 | ENDIF |
---|
215 | ! |
---|
216 | !-- y-direction |
---|
217 | vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
218 | IF ( vkomp > 0.0_wp ) THEN |
---|
219 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
220 | ( sk(k,j,i) - sk(k,j-1,i) ) * ddy |
---|
221 | ELSE |
---|
222 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
223 | ( sk(k,j+1,i) - sk(k,j,i) ) * ddy |
---|
224 | ENDIF |
---|
225 | ! |
---|
226 | !-- z-direction |
---|
227 | wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
228 | IF ( wkomp > 0.0_wp ) THEN |
---|
229 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
230 | ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) |
---|
231 | ELSE |
---|
232 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
233 | ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) |
---|
234 | ENDIF |
---|
235 | |
---|
236 | ENDDO |
---|
237 | |
---|
238 | END SUBROUTINE advec_s_up_ij |
---|
239 | |
---|
240 | END MODULE advec_s_up_mod |
---|