1 | SUBROUTINE lpm_init_sgs_tke |
---|
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: lpm_init_sgs_tke.f90 1321 2014-03-20 09:40:40Z suehring $ |
---|
27 | ! |
---|
28 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
29 | ! ONLY-attribute added to USE-statements, |
---|
30 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
31 | ! kinds are defined in new module kinds, |
---|
32 | ! comment fields (!:) to be used for variable explanations added to |
---|
33 | ! all variable declaration statements |
---|
34 | ! |
---|
35 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
36 | ! code put under GPL (PALM 3.9) |
---|
37 | ! |
---|
38 | ! 849 2012-03-15 10:35:09Z raasch |
---|
39 | ! initial revision (former part of advec_particles) |
---|
40 | ! |
---|
41 | ! |
---|
42 | ! Description: |
---|
43 | ! ------------ |
---|
44 | ! Calculates quantities required for considering the SGS velocity fluctuations |
---|
45 | ! in the particle transport by a stochastic approach. The respective |
---|
46 | ! quantities are: SGS-TKE gradients and horizontally averaged profiles of the |
---|
47 | ! SGS TKE and the resolved-scale velocity variances. |
---|
48 | !------------------------------------------------------------------------------! |
---|
49 | |
---|
50 | USE arrays_3d, & |
---|
51 | ONLY: de_dx, de_dy, de_dz, diss, e, u, v, w, zu |
---|
52 | |
---|
53 | USE grid_variables, & |
---|
54 | ONLY: ddx, ddy |
---|
55 | |
---|
56 | USE indices, & |
---|
57 | ONLY: nbgp, ngp_2dh_outer, nx, nxl, nxr, ny, nyn, nys, nz, nzb, & |
---|
58 | nzb_s_inner, nzb_s_outer, nzt |
---|
59 | |
---|
60 | USE kinds |
---|
61 | |
---|
62 | USE particle_attributes, & |
---|
63 | ONLY: sgs_wfu_part, sgs_wfv_part, sgs_wfw_part |
---|
64 | |
---|
65 | USE pegrid |
---|
66 | |
---|
67 | USE statistics, & |
---|
68 | ONLY: flow_statistics_called, hom, sums, sums_l |
---|
69 | |
---|
70 | IMPLICIT NONE |
---|
71 | |
---|
72 | INTEGER(iwp) :: i !: |
---|
73 | INTEGER(iwp) :: j !: |
---|
74 | INTEGER(iwp) :: k !: |
---|
75 | |
---|
76 | |
---|
77 | ! |
---|
78 | !-- TKE gradient along x and y |
---|
79 | DO i = nxl, nxr |
---|
80 | DO j = nys, nyn |
---|
81 | DO k = nzb, nzt+1 |
---|
82 | |
---|
83 | IF ( k <= nzb_s_inner(j,i-1) .AND. k > nzb_s_inner(j,i) .AND. & |
---|
84 | k > nzb_s_inner(j,i+1) ) & |
---|
85 | THEN |
---|
86 | de_dx(k,j,i) = 2.0 * sgs_wfu_part * ( e(k,j,i+1) - e(k,j,i) ) & |
---|
87 | * ddx |
---|
88 | ELSEIF ( k > nzb_s_inner(j,i-1) .AND. k > nzb_s_inner(j,i) & |
---|
89 | .AND. k <= nzb_s_inner(j,i+1) ) & |
---|
90 | THEN |
---|
91 | de_dx(k,j,i) = 2.0 * sgs_wfu_part * ( e(k,j,i) - e(k,j,i-1) ) & |
---|
92 | * ddx |
---|
93 | ELSEIF ( k < nzb_s_inner(j,i) .AND. k < nzb_s_inner(j,i+1) ) & |
---|
94 | THEN |
---|
95 | de_dx(k,j,i) = 0.0 |
---|
96 | ELSEIF ( k < nzb_s_inner(j,i-1) .AND. k < nzb_s_inner(j,i) ) & |
---|
97 | THEN |
---|
98 | de_dx(k,j,i) = 0.0 |
---|
99 | ELSE |
---|
100 | de_dx(k,j,i) = sgs_wfu_part * ( e(k,j,i+1) - e(k,j,i-1) ) * ddx |
---|
101 | ENDIF |
---|
102 | |
---|
103 | IF ( k <= nzb_s_inner(j-1,i) .AND. k > nzb_s_inner(j,i) .AND. & |
---|
104 | k > nzb_s_inner(j+1,i) ) & |
---|
105 | THEN |
---|
106 | de_dy(k,j,i) = 2.0 * sgs_wfv_part * ( e(k,j+1,i) - e(k,j,i) ) & |
---|
107 | * ddy |
---|
108 | ELSEIF ( k > nzb_s_inner(j-1,i) .AND. k > nzb_s_inner(j,i) & |
---|
109 | .AND. k <= nzb_s_inner(j+1,i) ) & |
---|
110 | THEN |
---|
111 | de_dy(k,j,i) = 2.0 * sgs_wfv_part * ( e(k,j,i) - e(k,j-1,i) ) & |
---|
112 | * ddy |
---|
113 | ELSEIF ( k < nzb_s_inner(j,i) .AND. k < nzb_s_inner(j+1,i) ) & |
---|
114 | THEN |
---|
115 | de_dy(k,j,i) = 0.0 |
---|
116 | ELSEIF ( k < nzb_s_inner(j-1,i) .AND. k < nzb_s_inner(j,i) ) & |
---|
117 | THEN |
---|
118 | de_dy(k,j,i) = 0.0 |
---|
119 | ELSE |
---|
120 | de_dy(k,j,i) = sgs_wfv_part * ( e(k,j+1,i) - e(k,j-1,i) ) * ddy |
---|
121 | ENDIF |
---|
122 | |
---|
123 | ENDDO |
---|
124 | ENDDO |
---|
125 | ENDDO |
---|
126 | |
---|
127 | ! |
---|
128 | !-- TKE gradient along z, including bottom and top boundary conditions |
---|
129 | DO i = nxl, nxr |
---|
130 | DO j = nys, nyn |
---|
131 | |
---|
132 | DO k = nzb_s_inner(j,i)+2, nzt-1 |
---|
133 | de_dz(k,j,i) = 2.0 * sgs_wfw_part * & |
---|
134 | ( e(k+1,j,i) - e(k-1,j,i) ) / ( zu(k+1)-zu(k-1) ) |
---|
135 | ENDDO |
---|
136 | |
---|
137 | k = nzb_s_inner(j,i) |
---|
138 | de_dz(nzb:k,j,i) = 0.0 |
---|
139 | de_dz(k+1,j,i) = 2.0 * sgs_wfw_part * ( e(k+2,j,i) - e(k+1,j,i) ) & |
---|
140 | / ( zu(k+2) - zu(k+1) ) |
---|
141 | de_dz(nzt,j,i) = 0.0 |
---|
142 | de_dz(nzt+1,j,i) = 0.0 |
---|
143 | ENDDO |
---|
144 | ENDDO |
---|
145 | |
---|
146 | |
---|
147 | ! |
---|
148 | !-- Lateral boundary conditions |
---|
149 | CALL exchange_horiz( de_dx, nbgp ) |
---|
150 | CALL exchange_horiz( de_dy, nbgp ) |
---|
151 | CALL exchange_horiz( de_dz, nbgp ) |
---|
152 | CALL exchange_horiz( diss, nbgp ) |
---|
153 | |
---|
154 | |
---|
155 | ! |
---|
156 | !-- Calculate the horizontally averaged profiles of SGS TKE and resolved |
---|
157 | !-- velocity variances (they may have been already calculated in routine |
---|
158 | !-- flow_statistics). |
---|
159 | IF ( .NOT. flow_statistics_called ) THEN |
---|
160 | |
---|
161 | ! |
---|
162 | !-- First calculate horizontally averaged profiles of the horizontal |
---|
163 | !-- velocities. |
---|
164 | sums_l(:,1,0) = 0.0 |
---|
165 | sums_l(:,2,0) = 0.0 |
---|
166 | |
---|
167 | DO i = nxl, nxr |
---|
168 | DO j = nys, nyn |
---|
169 | DO k = nzb_s_outer(j,i), nzt+1 |
---|
170 | sums_l(k,1,0) = sums_l(k,1,0) + u(k,j,i) |
---|
171 | sums_l(k,2,0) = sums_l(k,2,0) + v(k,j,i) |
---|
172 | ENDDO |
---|
173 | ENDDO |
---|
174 | ENDDO |
---|
175 | |
---|
176 | #if defined( __parallel ) |
---|
177 | ! |
---|
178 | !-- Compute total sum from local sums |
---|
179 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
180 | CALL MPI_ALLREDUCE( sums_l(nzb,1,0), sums(nzb,1), nzt+2-nzb, & |
---|
181 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
182 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
183 | CALL MPI_ALLREDUCE( sums_l(nzb,2,0), sums(nzb,2), nzt+2-nzb, & |
---|
184 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
185 | #else |
---|
186 | sums(:,1) = sums_l(:,1,0) |
---|
187 | sums(:,2) = sums_l(:,2,0) |
---|
188 | #endif |
---|
189 | |
---|
190 | ! |
---|
191 | !-- Final values are obtained by division by the total number of grid |
---|
192 | !-- points used for the summation. |
---|
193 | hom(:,1,1,0) = sums(:,1) / ngp_2dh_outer(:,0) ! u |
---|
194 | hom(:,1,2,0) = sums(:,2) / ngp_2dh_outer(:,0) ! v |
---|
195 | |
---|
196 | ! |
---|
197 | !-- Now calculate the profiles of SGS TKE and the resolved-scale |
---|
198 | !-- velocity variances |
---|
199 | sums_l(:,8,0) = 0.0 |
---|
200 | sums_l(:,30,0) = 0.0 |
---|
201 | sums_l(:,31,0) = 0.0 |
---|
202 | sums_l(:,32,0) = 0.0 |
---|
203 | DO i = nxl, nxr |
---|
204 | DO j = nys, nyn |
---|
205 | DO k = nzb_s_outer(j,i), nzt+1 |
---|
206 | sums_l(k,8,0) = sums_l(k,8,0) + e(k,j,i) |
---|
207 | sums_l(k,30,0) = sums_l(k,30,0) + ( u(k,j,i) - hom(k,1,1,0) )**2 |
---|
208 | sums_l(k,31,0) = sums_l(k,31,0) + ( v(k,j,i) - hom(k,1,2,0) )**2 |
---|
209 | sums_l(k,32,0) = sums_l(k,32,0) + w(k,j,i)**2 |
---|
210 | ENDDO |
---|
211 | ENDDO |
---|
212 | ENDDO |
---|
213 | |
---|
214 | #if defined( __parallel ) |
---|
215 | ! |
---|
216 | !-- Compute total sum from local sums |
---|
217 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
218 | CALL MPI_ALLREDUCE( sums_l(nzb,8,0), sums(nzb,8), nzt+2-nzb, & |
---|
219 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
220 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
221 | CALL MPI_ALLREDUCE( sums_l(nzb,30,0), sums(nzb,30), nzt+2-nzb, & |
---|
222 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
223 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
224 | CALL MPI_ALLREDUCE( sums_l(nzb,31,0), sums(nzb,31), nzt+2-nzb, & |
---|
225 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
226 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
227 | CALL MPI_ALLREDUCE( sums_l(nzb,32,0), sums(nzb,32), nzt+2-nzb, & |
---|
228 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
229 | |
---|
230 | #else |
---|
231 | sums(:,8) = sums_l(:,8,0) |
---|
232 | sums(:,30) = sums_l(:,30,0) |
---|
233 | sums(:,31) = sums_l(:,31,0) |
---|
234 | sums(:,32) = sums_l(:,32,0) |
---|
235 | #endif |
---|
236 | |
---|
237 | ! |
---|
238 | !-- Final values are obtained by division by the total number of grid |
---|
239 | !-- points used for the summation. |
---|
240 | hom(:,1,8,0) = sums(:,8) / ngp_2dh_outer(:,0) ! e |
---|
241 | hom(:,1,30,0) = sums(:,30) / ngp_2dh_outer(:,0) ! u*2 |
---|
242 | hom(:,1,31,0) = sums(:,31) / ngp_2dh_outer(:,0) ! v*2 |
---|
243 | hom(:,1,32,0) = sums(:,32) / ngp_2dh_outer(:,0) ! w*2 |
---|
244 | |
---|
245 | ENDIF |
---|
246 | |
---|
247 | END SUBROUTINE lpm_init_sgs_tke |
---|