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