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