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