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