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