1 | MODULE advec_w_up_mod |
---|
2 | |
---|
3 | !--------------------------------------------------------------------------------! |
---|
4 | ! This file is part of PALM. |
---|
5 | ! |
---|
6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
8 | ! either version 3 of the License, or (at your option) any later 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-2014 Leibniz Universitaet Hannover |
---|
18 | !--------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: advec_w_up.f90 1321 2014-03-20 09:40:40Z raasch $ |
---|
27 | ! |
---|
28 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
29 | ! ONLY-attribute added to USE-statements, |
---|
30 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
31 | ! kinds are defined in new module kinds, |
---|
32 | ! revision history before 2012 removed, |
---|
33 | ! comment fields (!:) to be used for variable explanations added to |
---|
34 | ! all variable declaration statements |
---|
35 | ! |
---|
36 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
37 | ! code put under GPL (PALM 3.9) |
---|
38 | ! |
---|
39 | ! Revision 1.1 1997/08/29 08:56:33 raasch |
---|
40 | ! Initial revision |
---|
41 | ! |
---|
42 | ! |
---|
43 | ! Description: |
---|
44 | ! ------------ |
---|
45 | ! Advection term for the w velocity-component using upstream scheme. |
---|
46 | ! NOTE: vertical advection at k=1 still has wrong grid spacing for w>0 |
---|
47 | ! The same problem occurs for all topography boundaries! |
---|
48 | !------------------------------------------------------------------------------! |
---|
49 | |
---|
50 | PRIVATE |
---|
51 | PUBLIC advec_w_up |
---|
52 | |
---|
53 | INTERFACE advec_w_up |
---|
54 | MODULE PROCEDURE advec_w_up |
---|
55 | MODULE PROCEDURE advec_w_up_ij |
---|
56 | END INTERFACE advec_w_up |
---|
57 | |
---|
58 | CONTAINS |
---|
59 | |
---|
60 | |
---|
61 | !------------------------------------------------------------------------------! |
---|
62 | ! Call for all grid points |
---|
63 | !------------------------------------------------------------------------------! |
---|
64 | SUBROUTINE advec_w_up |
---|
65 | |
---|
66 | USE arrays_3d, & |
---|
67 | ONLY: ddzw, tend, u, v, w |
---|
68 | |
---|
69 | USE control_parameters, & |
---|
70 | ONLY: u_gtrans, v_gtrans |
---|
71 | |
---|
72 | USE grid_variables, & |
---|
73 | ONLY: ddx, ddy |
---|
74 | |
---|
75 | USE indices, & |
---|
76 | ONLY: nxl, nxr, nyn, nys, nzb_w_inner, nzt |
---|
77 | |
---|
78 | USE kinds |
---|
79 | |
---|
80 | |
---|
81 | IMPLICIT NONE |
---|
82 | |
---|
83 | INTEGER(iwp) :: i !: |
---|
84 | INTEGER(iwp) :: j !: |
---|
85 | INTEGER(iwp) :: k !: |
---|
86 | |
---|
87 | REAL(wp) :: ukomp !: |
---|
88 | REAL(wp) :: vkomp !: |
---|
89 | |
---|
90 | |
---|
91 | DO i = nxl, nxr |
---|
92 | DO j = nys, nyn |
---|
93 | DO k = nzb_w_inner(j,i)+1, nzt-1 |
---|
94 | ! |
---|
95 | !-- x-direction |
---|
96 | ukomp = 0.25 * ( u(k,j,i) + u(k,j,i+1) + & |
---|
97 | u(k+1,j,i) + u(k+1,j,i+1) ) - u_gtrans |
---|
98 | IF ( ukomp > 0.0 ) THEN |
---|
99 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
100 | ( w(k,j,i) - w(k,j,i-1) ) * ddx |
---|
101 | ELSE |
---|
102 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
103 | ( w(k,j,i+1) - w(k,j,i) ) * ddx |
---|
104 | ENDIF |
---|
105 | ! |
---|
106 | !-- y-direction |
---|
107 | vkomp = 0.25 * ( v(k,j,i) + v(k,j+1,i) + & |
---|
108 | v(k+1,j,i) + v(k+1,j+1,i) ) - v_gtrans |
---|
109 | IF ( vkomp > 0.0 ) THEN |
---|
110 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
111 | ( w(k,j,i) - w(k,j-1,i) ) * ddy |
---|
112 | ELSE |
---|
113 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
114 | ( w(k,j+1,i) - w(k,j,i) ) * ddy |
---|
115 | ENDIF |
---|
116 | ! |
---|
117 | !-- z-direction |
---|
118 | IF ( w(k,j,i) > 0.0 ) THEN |
---|
119 | tend(k,j,i) = tend(k,j,i) - w(k,j,i) * & |
---|
120 | ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
121 | ELSE |
---|
122 | tend(k,j,i) = tend(k,j,i) - w(k,j,i) * & |
---|
123 | ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) |
---|
124 | ENDIF |
---|
125 | |
---|
126 | ENDDO |
---|
127 | ENDDO |
---|
128 | ENDDO |
---|
129 | |
---|
130 | END SUBROUTINE advec_w_up |
---|
131 | |
---|
132 | |
---|
133 | !------------------------------------------------------------------------------! |
---|
134 | ! Call for grid point i,j |
---|
135 | !------------------------------------------------------------------------------! |
---|
136 | SUBROUTINE advec_w_up_ij( i, j ) |
---|
137 | |
---|
138 | USE arrays_3d, & |
---|
139 | ONLY: ddzw, tend, u, v, w |
---|
140 | |
---|
141 | USE control_parameters, & |
---|
142 | ONLY: u_gtrans, v_gtrans |
---|
143 | |
---|
144 | USE grid_variables, & |
---|
145 | ONLY: ddx, ddy |
---|
146 | |
---|
147 | USE indices, & |
---|
148 | ONLY: nzb_w_inner, nzt |
---|
149 | |
---|
150 | USE kinds |
---|
151 | |
---|
152 | |
---|
153 | IMPLICIT NONE |
---|
154 | |
---|
155 | INTEGER(iwp) :: i !: |
---|
156 | INTEGER(iwp) :: j !: |
---|
157 | INTEGER(iwp) :: k !: |
---|
158 | |
---|
159 | REAL(wp) :: ukomp !: |
---|
160 | REAL(wp) :: vkomp !: |
---|
161 | |
---|
162 | |
---|
163 | DO k = nzb_w_inner(j,i)+1, nzt-1 |
---|
164 | ! |
---|
165 | !-- x-direction |
---|
166 | ukomp = 0.25 * ( u(k,j,i) + u(k,j,i+1) + u(k+1,j,i) + u(k+1,j,i+1) & |
---|
167 | ) - u_gtrans |
---|
168 | IF ( ukomp > 0.0 ) THEN |
---|
169 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
170 | ( w(k,j,i) - w(k,j,i-1) ) * ddx |
---|
171 | ELSE |
---|
172 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
173 | ( w(k,j,i+1) - w(k,j,i) ) * ddx |
---|
174 | ENDIF |
---|
175 | ! |
---|
176 | !-- y-direction |
---|
177 | vkomp = 0.25 * ( v(k,j,i) + v(k,j+1,i) + v(k+1,j,i) + v(k+1,j+1,i) & |
---|
178 | ) - v_gtrans |
---|
179 | IF ( vkomp > 0.0 ) THEN |
---|
180 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
181 | ( w(k,j,i) - w(k,j-1,i) ) * ddy |
---|
182 | ELSE |
---|
183 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
184 | ( w(k,j+1,i) - w(k,j,i) ) * ddy |
---|
185 | ENDIF |
---|
186 | ! |
---|
187 | !-- z-direction |
---|
188 | IF ( w(k,j,i) > 0.0 ) THEN |
---|
189 | tend(k,j,i) = tend(k,j,i) - w(k,j,i) * & |
---|
190 | ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
191 | ELSE |
---|
192 | tend(k,j,i) = tend(k,j,i) - w(k,j,i) * & |
---|
193 | ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) |
---|
194 | ENDIF |
---|
195 | |
---|
196 | ENDDO |
---|
197 | |
---|
198 | END SUBROUTINE advec_w_up_ij |
---|
199 | |
---|
200 | END MODULE advec_w_up_mod |
---|