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