1 | !> @file advec_u_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_u_up.f90 1874 2016-04-18 14:51:10Z hellstea $ |
---|
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 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
39 | ! REAL constants provided with KIND-attribute |
---|
40 | ! |
---|
41 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
42 | ! ONLY-attribute added to USE-statements, |
---|
43 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
44 | ! kinds are defined in new module kinds, |
---|
45 | ! revision history before 2012 removed, |
---|
46 | ! comment fields (!:) to be used for variable explanations added to |
---|
47 | ! all variable declaration statements |
---|
48 | ! |
---|
49 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
50 | ! code put under GPL (PALM 3.9) |
---|
51 | ! |
---|
52 | ! Revision 1.1 1997/08/29 08:55:25 raasch |
---|
53 | ! Initial revision |
---|
54 | ! |
---|
55 | ! |
---|
56 | ! Description: |
---|
57 | ! ------------ |
---|
58 | !> Advection term for the u velocity-component using upstream scheme. |
---|
59 | !> NOTE: vertical advection at k=1 still has wrong grid spacing for w>0! |
---|
60 | !> The same problem occurs for all topography boundaries! |
---|
61 | !------------------------------------------------------------------------------! |
---|
62 | MODULE advec_u_up_mod |
---|
63 | |
---|
64 | |
---|
65 | PRIVATE |
---|
66 | PUBLIC advec_u_up |
---|
67 | |
---|
68 | INTERFACE advec_u_up |
---|
69 | MODULE PROCEDURE advec_u_up |
---|
70 | MODULE PROCEDURE advec_u_up_ij |
---|
71 | END INTERFACE advec_u_up |
---|
72 | |
---|
73 | CONTAINS |
---|
74 | |
---|
75 | |
---|
76 | !------------------------------------------------------------------------------! |
---|
77 | ! Description: |
---|
78 | ! ------------ |
---|
79 | !> Call for all grid points |
---|
80 | !------------------------------------------------------------------------------! |
---|
81 | SUBROUTINE advec_u_up |
---|
82 | |
---|
83 | USE arrays_3d, & |
---|
84 | ONLY: ddzu, tend, u, v, w |
---|
85 | |
---|
86 | USE control_parameters, & |
---|
87 | ONLY: u_gtrans, v_gtrans |
---|
88 | |
---|
89 | USE grid_variables, & |
---|
90 | ONLY: ddx, ddy |
---|
91 | |
---|
92 | USE indices, & |
---|
93 | ONLY: nxlu, nxr, nyn, nys, nzb_u_inner, nzt |
---|
94 | |
---|
95 | USE kinds |
---|
96 | |
---|
97 | |
---|
98 | IMPLICIT NONE |
---|
99 | |
---|
100 | INTEGER(iwp) :: i !< |
---|
101 | INTEGER(iwp) :: j !< |
---|
102 | INTEGER(iwp) :: k !< |
---|
103 | |
---|
104 | REAL(wp) :: ukomp !< |
---|
105 | REAL(wp) :: vkomp !< |
---|
106 | REAL(wp) :: wkomp !< |
---|
107 | |
---|
108 | |
---|
109 | DO i = nxlu, nxr |
---|
110 | DO j = nys, nyn |
---|
111 | DO k = nzb_u_inner(j,i)+1, nzt |
---|
112 | ! |
---|
113 | !-- x-direction |
---|
114 | ukomp = u(k,j,i) - u_gtrans |
---|
115 | IF ( ukomp > 0.0_wp ) THEN |
---|
116 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
117 | ( u(k,j,i) - u(k,j,i-1) ) * ddx |
---|
118 | ELSE |
---|
119 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
120 | ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
121 | ENDIF |
---|
122 | ! |
---|
123 | !-- y-direction |
---|
124 | vkomp = 0.25_wp * ( v(k,j,i) + v(k,j+1,i) + & |
---|
125 | v(k,j,i-1) + v(k,j+1,i-1) ) - v_gtrans |
---|
126 | IF ( vkomp > 0.0_wp ) THEN |
---|
127 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
128 | ( u(k,j,i) - u(k,j-1,i) ) * ddy |
---|
129 | ELSE |
---|
130 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
131 | ( u(k,j+1,i) - u(k,j,i) ) * ddy |
---|
132 | ENDIF |
---|
133 | ! |
---|
134 | !-- z-direction |
---|
135 | wkomp = 0.25_wp * ( w(k,j,i) + w(k-1,j,i) + & |
---|
136 | w(k,j,i-1) + w(k-1,j,i-1) ) |
---|
137 | IF ( wkomp > 0.0_wp ) THEN |
---|
138 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
139 | ( u(k,j,i) - u(k-1,j,i) ) * ddzu(k) |
---|
140 | ELSE |
---|
141 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
142 | ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) |
---|
143 | ENDIF |
---|
144 | |
---|
145 | ENDDO |
---|
146 | ENDDO |
---|
147 | ENDDO |
---|
148 | |
---|
149 | END SUBROUTINE advec_u_up |
---|
150 | |
---|
151 | |
---|
152 | !------------------------------------------------------------------------------! |
---|
153 | ! Description: |
---|
154 | ! ------------ |
---|
155 | !> Call for grid point i,j |
---|
156 | !------------------------------------------------------------------------------! |
---|
157 | SUBROUTINE advec_u_up_ij( i, j ) |
---|
158 | |
---|
159 | USE arrays_3d, & |
---|
160 | ONLY: ddzu, tend, u, v, w |
---|
161 | |
---|
162 | USE control_parameters, & |
---|
163 | ONLY: u_gtrans, v_gtrans |
---|
164 | |
---|
165 | USE grid_variables, & |
---|
166 | ONLY: ddx, ddy |
---|
167 | |
---|
168 | USE indices, & |
---|
169 | ONLY: nzb_u_inner, nzt |
---|
170 | |
---|
171 | USE kinds |
---|
172 | |
---|
173 | |
---|
174 | IMPLICIT NONE |
---|
175 | |
---|
176 | INTEGER(iwp) :: i !< |
---|
177 | INTEGER(iwp) :: j !< |
---|
178 | INTEGER(iwp) :: k !< |
---|
179 | |
---|
180 | REAL(wp) :: ukomp !< |
---|
181 | REAL(wp) :: vkomp !< |
---|
182 | REAL(wp) :: wkomp !< |
---|
183 | |
---|
184 | |
---|
185 | DO k = nzb_u_inner(j,i)+1, nzt |
---|
186 | ! |
---|
187 | !-- x-direction |
---|
188 | ukomp = u(k,j,i) - u_gtrans |
---|
189 | IF ( ukomp > 0.0_wp ) THEN |
---|
190 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
191 | ( u(k,j,i) - u(k,j,i-1) ) * ddx |
---|
192 | ELSE |
---|
193 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
194 | ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
195 | ENDIF |
---|
196 | ! |
---|
197 | !-- y-direction |
---|
198 | vkomp = 0.25_wp * ( v(k,j,i) + v(k,j+1,i) + v(k,j,i-1) + v(k,j+1,i-1) & |
---|
199 | ) - v_gtrans |
---|
200 | IF ( vkomp > 0.0_wp ) THEN |
---|
201 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
202 | ( u(k,j,i) - u(k,j-1,i) ) * ddy |
---|
203 | ELSE |
---|
204 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
205 | ( u(k,j+1,i) - u(k,j,i) ) * ddy |
---|
206 | ENDIF |
---|
207 | ! |
---|
208 | !-- z-direction |
---|
209 | wkomp = 0.25_wp * ( w(k,j,i) + w(k-1,j,i) + w(k,j,i-1) + w(k-1,j,i-1) ) |
---|
210 | IF ( wkomp > 0.0_wp ) THEN |
---|
211 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
212 | ( u(k,j,i) - u(k-1,j,i) ) * ddzu(k) |
---|
213 | ELSE |
---|
214 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
215 | ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) |
---|
216 | ENDIF |
---|
217 | |
---|
218 | ENDDO |
---|
219 | |
---|
220 | END SUBROUTINE advec_u_up_ij |
---|
221 | |
---|
222 | END MODULE advec_u_up_mod |
---|