1 | !> @file advec_s_pw.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-2017 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: advec_s_pw.f90 2233 2017-05-30 18:08:54Z maronga $ |
---|
27 | ! |
---|
28 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
29 | ! topography representation via flags |
---|
30 | ! |
---|
31 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
32 | ! Forced header and separation lines into 80 columns |
---|
33 | ! |
---|
34 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
35 | ! Module renamed (removed _mod) |
---|
36 | ! |
---|
37 | ! |
---|
38 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
39 | ! Module renamed |
---|
40 | ! |
---|
41 | ! |
---|
42 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
43 | ! Code annotations made doxygen readable |
---|
44 | ! |
---|
45 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
46 | ! missing variables added to ONLY list |
---|
47 | ! |
---|
48 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
49 | ! REAL constants provided with KIND-attribute |
---|
50 | ! |
---|
51 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
52 | ! ONLY-attribute added to USE-statements, |
---|
53 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
54 | ! kinds are defined in new module kinds, |
---|
55 | ! revision history before 2012 removed, |
---|
56 | ! comment fields (!:) to be used for variable explanations added to |
---|
57 | ! all variable declaration statements |
---|
58 | ! |
---|
59 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
60 | ! code put under GPL (PALM 3.9) |
---|
61 | ! |
---|
62 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
63 | ! cpp switch __nopointer added for pointer free version |
---|
64 | ! |
---|
65 | ! Revision 1.1 1997/08/29 08:54:20 raasch |
---|
66 | ! Initial revision |
---|
67 | ! |
---|
68 | ! |
---|
69 | ! Description: |
---|
70 | ! ------------ |
---|
71 | !> Advection term for scalar variables using the Piacsek and Williams scheme |
---|
72 | !> (form C3). Contrary to PW itself, for reasons of accuracy their scheme is |
---|
73 | !> slightly modified as follows: the values of those scalars that are used for |
---|
74 | !> the computation of the flux divergence are reduced by the value of the |
---|
75 | !> relevant scalar at the location where the difference is computed (sk(k,j,i)). |
---|
76 | !> NOTE: at the first grid point above the surface computation still takes place! |
---|
77 | !------------------------------------------------------------------------------! |
---|
78 | MODULE advec_s_pw_mod |
---|
79 | |
---|
80 | |
---|
81 | PRIVATE |
---|
82 | PUBLIC advec_s_pw |
---|
83 | |
---|
84 | INTERFACE advec_s_pw |
---|
85 | MODULE PROCEDURE advec_s_pw |
---|
86 | MODULE PROCEDURE advec_s_pw_ij |
---|
87 | END INTERFACE |
---|
88 | |
---|
89 | CONTAINS |
---|
90 | |
---|
91 | |
---|
92 | !------------------------------------------------------------------------------! |
---|
93 | ! Description: |
---|
94 | ! ------------ |
---|
95 | !> Call for all grid points |
---|
96 | !------------------------------------------------------------------------------! |
---|
97 | SUBROUTINE advec_s_pw( sk ) |
---|
98 | |
---|
99 | USE arrays_3d, & |
---|
100 | ONLY: dd2zu, tend, u, v, w |
---|
101 | |
---|
102 | USE control_parameters, & |
---|
103 | ONLY: u_gtrans, v_gtrans |
---|
104 | |
---|
105 | USE grid_variables, & |
---|
106 | ONLY: ddx, ddy |
---|
107 | |
---|
108 | USE indices, & |
---|
109 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, & |
---|
110 | nzt, wall_flags_0 |
---|
111 | |
---|
112 | USE kinds |
---|
113 | |
---|
114 | |
---|
115 | IMPLICIT NONE |
---|
116 | |
---|
117 | INTEGER(iwp) :: i !< |
---|
118 | INTEGER(iwp) :: j !< |
---|
119 | INTEGER(iwp) :: k !< |
---|
120 | |
---|
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+1, nzt |
---|
131 | tend(k,j,i) = tend(k,j,i) + & |
---|
132 | ( -0.5_wp * ( ( u(k,j,i+1) - u_gtrans ) * ( sk(k,j,i+1) - sk(k,j,i) ) & |
---|
133 | - ( u(k,j,i) - u_gtrans ) * ( sk(k,j,i-1) - sk(k,j,i) ) & |
---|
134 | ) * ddx & |
---|
135 | -0.5_wp * ( ( v(k,j+1,i) - v_gtrans ) * ( sk(k,j+1,i) - sk(k,j,i) ) & |
---|
136 | - ( v(k,j,i) - v_gtrans ) * ( sk(k,j-1,i) - sk(k,j,i) ) & |
---|
137 | ) * ddy & |
---|
138 | - ( w(k,j,i) * ( sk(k+1,j,i) - sk(k,j,i) ) & |
---|
139 | - w(k-1,j,i) * ( sk(k-1,j,i) - sk(k,j,i) ) & |
---|
140 | ) * dd2zu(k) & |
---|
141 | ) * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
142 | ENDDO |
---|
143 | ENDDO |
---|
144 | ENDDO |
---|
145 | |
---|
146 | END SUBROUTINE advec_s_pw |
---|
147 | |
---|
148 | |
---|
149 | !------------------------------------------------------------------------------! |
---|
150 | ! Description: |
---|
151 | ! ------------ |
---|
152 | !> Call for grid point i,j |
---|
153 | !------------------------------------------------------------------------------! |
---|
154 | SUBROUTINE advec_s_pw_ij( i, j, sk ) |
---|
155 | |
---|
156 | USE arrays_3d, & |
---|
157 | ONLY: dd2zu, 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, nzt, wall_flags_0 |
---|
167 | |
---|
168 | USE kinds |
---|
169 | |
---|
170 | |
---|
171 | IMPLICIT NONE |
---|
172 | |
---|
173 | INTEGER(iwp) :: i !< |
---|
174 | INTEGER(iwp) :: j !< |
---|
175 | INTEGER(iwp) :: k !< |
---|
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+1, nzt |
---|
185 | tend(k,j,i) = tend(k,j,i) + & |
---|
186 | ( -0.5_wp * ( ( u(k,j,i+1) - u_gtrans ) * ( sk(k,j,i+1) - sk(k,j,i) ) & |
---|
187 | - ( u(k,j,i) - u_gtrans ) * ( sk(k,j,i-1) - sk(k,j,i) ) & |
---|
188 | ) * ddx & |
---|
189 | -0.5_wp * ( ( v(k,j+1,i) - v_gtrans ) * ( sk(k,j+1,i) - sk(k,j,i) ) & |
---|
190 | - ( v(k,j,i) - v_gtrans ) * ( sk(k,j-1,i) - sk(k,j,i) ) & |
---|
191 | ) * ddy & |
---|
192 | - ( w(k,j,i) * ( sk(k+1,j,i) - sk(k,j,i) ) & |
---|
193 | - w(k-1,j,i) * ( sk(k-1,j,i) - sk(k,j,i) ) & |
---|
194 | ) * dd2zu(k) & |
---|
195 | ) * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
196 | ENDDO |
---|
197 | |
---|
198 | END SUBROUTINE advec_s_pw_ij |
---|
199 | |
---|
200 | END MODULE advec_s_pw_mod |
---|