1 | !> @file advec_s_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-2016 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: advec_s_up.f90 2001 2016-08-20 18:41:22Z suehring $ |
---|
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 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
43 | ! missing variables added to ONLY list |
---|
44 | ! |
---|
45 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
46 | ! REAL constants provided with KIND-attribute |
---|
47 | ! |
---|
48 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
49 | ! ONLY-attribute added to USE-statements, |
---|
50 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
51 | ! kinds are defined in new module kinds, |
---|
52 | ! revision history before 2012 removed, |
---|
53 | ! comment fields (!:) to be used for variable explanations added to |
---|
54 | ! all variable declaration statements |
---|
55 | ! |
---|
56 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
57 | ! code put under GPL (PALM 3.9) |
---|
58 | ! |
---|
59 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
60 | ! cpp switch __nopointer added for pointer free version |
---|
61 | ! |
---|
62 | ! 981 2012-08-09 14:57:44Z maronga |
---|
63 | ! Typo removed |
---|
64 | ! |
---|
65 | ! Revision 1.1 1997/08/29 08:54:33 raasch |
---|
66 | ! Initial revision |
---|
67 | ! |
---|
68 | ! |
---|
69 | ! Description: |
---|
70 | ! ------------ |
---|
71 | !> Advection term for scalar quantities using the Upstream scheme. |
---|
72 | !> NOTE: vertical advection at k=1 still has wrong grid spacing for w>0! |
---|
73 | !> The same problem occurs for all topography boundaries! |
---|
74 | !------------------------------------------------------------------------------! |
---|
75 | MODULE advec_s_up_mod |
---|
76 | |
---|
77 | |
---|
78 | PRIVATE |
---|
79 | PUBLIC advec_s_up |
---|
80 | |
---|
81 | INTERFACE advec_s_up |
---|
82 | MODULE PROCEDURE advec_s_up |
---|
83 | MODULE PROCEDURE advec_s_up_ij |
---|
84 | END INTERFACE advec_s_up |
---|
85 | |
---|
86 | CONTAINS |
---|
87 | |
---|
88 | |
---|
89 | !------------------------------------------------------------------------------! |
---|
90 | ! Description: |
---|
91 | ! ------------ |
---|
92 | !> Call for all grid points |
---|
93 | !------------------------------------------------------------------------------! |
---|
94 | SUBROUTINE advec_s_up( sk ) |
---|
95 | |
---|
96 | USE arrays_3d, & |
---|
97 | ONLY: ddzu, tend, u, v, w |
---|
98 | |
---|
99 | USE control_parameters, & |
---|
100 | ONLY: u_gtrans, v_gtrans |
---|
101 | |
---|
102 | USE grid_variables, & |
---|
103 | ONLY: ddx, ddy |
---|
104 | |
---|
105 | USE indices, & |
---|
106 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzb_s_inner,& |
---|
107 | nzt |
---|
108 | |
---|
109 | USE kinds |
---|
110 | |
---|
111 | |
---|
112 | IMPLICIT NONE |
---|
113 | |
---|
114 | INTEGER(iwp) :: i !< |
---|
115 | INTEGER(iwp) :: j !< |
---|
116 | INTEGER(iwp) :: k !< |
---|
117 | |
---|
118 | REAL(wp) :: ukomp !< |
---|
119 | REAL(wp) :: vkomp !< |
---|
120 | REAL(wp) :: wkomp !< |
---|
121 | #if defined( __nopointer ) |
---|
122 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !< |
---|
123 | #else |
---|
124 | REAL(wp), DIMENSION(:,:,:), POINTER :: sk |
---|
125 | #endif |
---|
126 | |
---|
127 | |
---|
128 | DO i = nxl, nxr |
---|
129 | DO j = nys, nyn |
---|
130 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
131 | ! |
---|
132 | !-- x-direction |
---|
133 | ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
134 | IF ( ukomp > 0.0_wp ) THEN |
---|
135 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
136 | ( sk(k,j,i) - sk(k,j,i-1) ) * ddx |
---|
137 | ELSE |
---|
138 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
139 | ( sk(k,j,i+1) - sk(k,j,i) ) * ddx |
---|
140 | ENDIF |
---|
141 | ! |
---|
142 | !-- y-direction |
---|
143 | vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
144 | IF ( vkomp > 0.0_wp ) THEN |
---|
145 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
146 | ( sk(k,j,i) - sk(k,j-1,i) ) * ddy |
---|
147 | ELSE |
---|
148 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
149 | ( sk(k,j+1,i) - sk(k,j,i) ) * ddy |
---|
150 | ENDIF |
---|
151 | ! |
---|
152 | !-- z-direction |
---|
153 | wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
154 | IF ( wkomp > 0.0_wp ) THEN |
---|
155 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
156 | ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) |
---|
157 | ELSE |
---|
158 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
159 | ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) |
---|
160 | ENDIF |
---|
161 | |
---|
162 | ENDDO |
---|
163 | ENDDO |
---|
164 | ENDDO |
---|
165 | |
---|
166 | END SUBROUTINE advec_s_up |
---|
167 | |
---|
168 | |
---|
169 | !------------------------------------------------------------------------------! |
---|
170 | ! Description: |
---|
171 | ! ------------ |
---|
172 | !> Call for grid point i,j |
---|
173 | !------------------------------------------------------------------------------! |
---|
174 | SUBROUTINE advec_s_up_ij( i, j, sk ) |
---|
175 | |
---|
176 | USE arrays_3d, & |
---|
177 | ONLY: ddzu, tend, u, v, w |
---|
178 | |
---|
179 | USE control_parameters, & |
---|
180 | ONLY: u_gtrans, v_gtrans |
---|
181 | |
---|
182 | USE grid_variables, & |
---|
183 | ONLY: ddx, ddy |
---|
184 | |
---|
185 | USE indices, & |
---|
186 | ONLY: nxlg, nxrg, nyng, nysg, nzb, nzb_s_inner, nzt |
---|
187 | |
---|
188 | USE kinds |
---|
189 | |
---|
190 | |
---|
191 | IMPLICIT NONE |
---|
192 | |
---|
193 | INTEGER(iwp) :: i !< |
---|
194 | INTEGER(iwp) :: j !< |
---|
195 | INTEGER(iwp) :: k !< |
---|
196 | |
---|
197 | REAL(wp) :: ukomp !< |
---|
198 | REAL(wp) :: vkomp !< |
---|
199 | REAL(wp) :: wkomp !< |
---|
200 | |
---|
201 | #if defined( __nopointer ) |
---|
202 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !< |
---|
203 | #else |
---|
204 | REAL(wp), DIMENSION(:,:,:), POINTER :: sk |
---|
205 | #endif |
---|
206 | |
---|
207 | |
---|
208 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
209 | ! |
---|
210 | !-- x-direction |
---|
211 | ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
212 | IF ( ukomp > 0.0_wp ) THEN |
---|
213 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
214 | ( sk(k,j,i) - sk(k,j,i-1) ) * ddx |
---|
215 | ELSE |
---|
216 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
217 | ( sk(k,j,i+1) - sk(k,j,i) ) * ddx |
---|
218 | ENDIF |
---|
219 | ! |
---|
220 | !-- y-direction |
---|
221 | vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
222 | IF ( vkomp > 0.0_wp ) THEN |
---|
223 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
224 | ( sk(k,j,i) - sk(k,j-1,i) ) * ddy |
---|
225 | ELSE |
---|
226 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
227 | ( sk(k,j+1,i) - sk(k,j,i) ) * ddy |
---|
228 | ENDIF |
---|
229 | ! |
---|
230 | !-- z-direction |
---|
231 | wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
232 | IF ( wkomp > 0.0_wp ) THEN |
---|
233 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
234 | ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) |
---|
235 | ELSE |
---|
236 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
237 | ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) |
---|
238 | ENDIF |
---|
239 | |
---|
240 | ENDDO |
---|
241 | |
---|
242 | END SUBROUTINE advec_s_up_ij |
---|
243 | |
---|
244 | END MODULE advec_s_up_mod |
---|