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