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 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_w_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:56:33 raasch |
---|
53 | ! Initial revision |
---|
54 | ! |
---|
55 | ! |
---|
56 | ! Description: |
---|
57 | ! ------------ |
---|
58 | !> Advection term for the w 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_w_up_mod |
---|
63 | |
---|
64 | |
---|
65 | PRIVATE |
---|
66 | PUBLIC advec_w_up |
---|
67 | |
---|
68 | INTERFACE advec_w_up |
---|
69 | MODULE PROCEDURE advec_w_up |
---|
70 | MODULE PROCEDURE advec_w_up_ij |
---|
71 | END INTERFACE advec_w_up |
---|
72 | |
---|
73 | CONTAINS |
---|
74 | |
---|
75 | |
---|
76 | !------------------------------------------------------------------------------! |
---|
77 | ! Description: |
---|
78 | ! ------------ |
---|
79 | !> Call for all grid points |
---|
80 | !------------------------------------------------------------------------------! |
---|
81 | SUBROUTINE advec_w_up |
---|
82 | |
---|
83 | USE arrays_3d, & |
---|
84 | ONLY: ddzw, 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: nxl, nxr, nyn, nys, nzb_w_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 | |
---|
107 | |
---|
108 | DO i = nxl, nxr |
---|
109 | DO j = nys, nyn |
---|
110 | DO k = nzb_w_inner(j,i)+1, nzt-1 |
---|
111 | ! |
---|
112 | !-- x-direction |
---|
113 | ukomp = 0.25_wp * ( u(k,j,i) + u(k,j,i+1) + & |
---|
114 | u(k+1,j,i) + u(k+1,j,i+1) ) - u_gtrans |
---|
115 | IF ( ukomp > 0.0_wp ) THEN |
---|
116 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
117 | ( w(k,j,i) - w(k,j,i-1) ) * ddx |
---|
118 | ELSE |
---|
119 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
120 | ( w(k,j,i+1) - w(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+1,j,i) + v(k+1,j+1,i) ) - v_gtrans |
---|
126 | IF ( vkomp > 0.0_wp ) THEN |
---|
127 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
128 | ( w(k,j,i) - w(k,j-1,i) ) * ddy |
---|
129 | ELSE |
---|
130 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
131 | ( w(k,j+1,i) - w(k,j,i) ) * ddy |
---|
132 | ENDIF |
---|
133 | ! |
---|
134 | !-- z-direction |
---|
135 | IF ( w(k,j,i) > 0.0_wp ) THEN |
---|
136 | tend(k,j,i) = tend(k,j,i) - w(k,j,i) * & |
---|
137 | ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
138 | ELSE |
---|
139 | tend(k,j,i) = tend(k,j,i) - w(k,j,i) * & |
---|
140 | ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) |
---|
141 | ENDIF |
---|
142 | |
---|
143 | ENDDO |
---|
144 | ENDDO |
---|
145 | ENDDO |
---|
146 | |
---|
147 | END SUBROUTINE advec_w_up |
---|
148 | |
---|
149 | |
---|
150 | !------------------------------------------------------------------------------! |
---|
151 | ! Description: |
---|
152 | ! ------------ |
---|
153 | !> Call for grid point i,j |
---|
154 | !------------------------------------------------------------------------------! |
---|
155 | SUBROUTINE advec_w_up_ij( i, j ) |
---|
156 | |
---|
157 | USE arrays_3d, & |
---|
158 | ONLY: ddzw, tend, u, v, w |
---|
159 | |
---|
160 | USE control_parameters, & |
---|
161 | ONLY: u_gtrans, v_gtrans |
---|
162 | |
---|
163 | USE grid_variables, & |
---|
164 | ONLY: ddx, ddy |
---|
165 | |
---|
166 | USE indices, & |
---|
167 | ONLY: nzb_w_inner, nzt |
---|
168 | |
---|
169 | USE kinds |
---|
170 | |
---|
171 | |
---|
172 | IMPLICIT NONE |
---|
173 | |
---|
174 | INTEGER(iwp) :: i !< |
---|
175 | INTEGER(iwp) :: j !< |
---|
176 | INTEGER(iwp) :: k !< |
---|
177 | |
---|
178 | REAL(wp) :: ukomp !< |
---|
179 | REAL(wp) :: vkomp !< |
---|
180 | |
---|
181 | |
---|
182 | DO k = nzb_w_inner(j,i)+1, nzt-1 |
---|
183 | ! |
---|
184 | !-- x-direction |
---|
185 | ukomp = 0.25_wp * ( u(k,j,i) + u(k,j,i+1) + u(k+1,j,i) + u(k+1,j,i+1) & |
---|
186 | ) - u_gtrans |
---|
187 | IF ( ukomp > 0.0_wp ) THEN |
---|
188 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
189 | ( w(k,j,i) - w(k,j,i-1) ) * ddx |
---|
190 | ELSE |
---|
191 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
192 | ( w(k,j,i+1) - w(k,j,i) ) * ddx |
---|
193 | ENDIF |
---|
194 | ! |
---|
195 | !-- y-direction |
---|
196 | vkomp = 0.25_wp * ( v(k,j,i) + v(k,j+1,i) + v(k+1,j,i) + v(k+1,j+1,i) & |
---|
197 | ) - v_gtrans |
---|
198 | IF ( vkomp > 0.0_wp ) THEN |
---|
199 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
200 | ( w(k,j,i) - w(k,j-1,i) ) * ddy |
---|
201 | ELSE |
---|
202 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
203 | ( w(k,j+1,i) - w(k,j,i) ) * ddy |
---|
204 | ENDIF |
---|
205 | ! |
---|
206 | !-- z-direction |
---|
207 | IF ( w(k,j,i) > 0.0_wp ) THEN |
---|
208 | tend(k,j,i) = tend(k,j,i) - w(k,j,i) * & |
---|
209 | ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
210 | ELSE |
---|
211 | tend(k,j,i) = tend(k,j,i) - w(k,j,i) * & |
---|
212 | ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) |
---|
213 | ENDIF |
---|
214 | |
---|
215 | ENDDO |
---|
216 | |
---|
217 | END SUBROUTINE advec_w_up_ij |
---|
218 | |
---|
219 | END MODULE advec_w_up_mod |
---|