1 | SUBROUTINE lpm_init_sgs_tke |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Current revisions: |
---|
5 | ! ------------------ |
---|
6 | ! |
---|
7 | ! |
---|
8 | ! Former revisions: |
---|
9 | ! ----------------- |
---|
10 | ! $Id: lpm_init_sgs_tke.f90 849 2012-03-15 10:35:09Z raasch $ |
---|
11 | ! |
---|
12 | ! |
---|
13 | ! Description: |
---|
14 | ! ------------ |
---|
15 | ! Calculates quantities required for considering the SGS velocity fluctuations |
---|
16 | ! in the particle transport by a stochastic approach. The respective |
---|
17 | ! quantities are: SGS-TKE gradients and horizontally averaged profiles of the |
---|
18 | ! SGS TKE and the resolved-scale velocity variances. |
---|
19 | !------------------------------------------------------------------------------! |
---|
20 | |
---|
21 | USE arrays_3d |
---|
22 | USE control_parameters |
---|
23 | USE grid_variables |
---|
24 | USE indices |
---|
25 | USE particle_attributes |
---|
26 | USE pegrid |
---|
27 | USE statistics |
---|
28 | |
---|
29 | IMPLICIT NONE |
---|
30 | |
---|
31 | INTEGER :: i, j, k |
---|
32 | |
---|
33 | |
---|
34 | ! |
---|
35 | !-- TKE gradient along x and y |
---|
36 | DO i = nxl, nxr |
---|
37 | DO j = nys, nyn |
---|
38 | DO k = nzb, nzt+1 |
---|
39 | |
---|
40 | IF ( k <= nzb_s_inner(j,i-1) .AND. k > nzb_s_inner(j,i) .AND. & |
---|
41 | k > nzb_s_inner(j,i+1) ) & |
---|
42 | THEN |
---|
43 | de_dx(k,j,i) = 2.0 * sgs_wfu_part * ( e(k,j,i+1) - e(k,j,i) ) & |
---|
44 | * ddx |
---|
45 | ELSEIF ( k > nzb_s_inner(j,i-1) .AND. k > nzb_s_inner(j,i) & |
---|
46 | .AND. k <= nzb_s_inner(j,i+1) ) & |
---|
47 | THEN |
---|
48 | de_dx(k,j,i) = 2.0 * sgs_wfu_part * ( e(k,j,i) - e(k,j,i-1) ) & |
---|
49 | * ddx |
---|
50 | ELSEIF ( k < nzb_s_inner(j,i) .AND. k < nzb_s_inner(j,i+1) ) & |
---|
51 | THEN |
---|
52 | de_dx(k,j,i) = 0.0 |
---|
53 | ELSEIF ( k < nzb_s_inner(j,i-1) .AND. k < nzb_s_inner(j,i) ) & |
---|
54 | THEN |
---|
55 | de_dx(k,j,i) = 0.0 |
---|
56 | ELSE |
---|
57 | de_dx(k,j,i) = sgs_wfu_part * ( e(k,j,i+1) - e(k,j,i-1) ) * ddx |
---|
58 | ENDIF |
---|
59 | |
---|
60 | IF ( k <= nzb_s_inner(j-1,i) .AND. k > nzb_s_inner(j,i) .AND. & |
---|
61 | k > nzb_s_inner(j+1,i) ) & |
---|
62 | THEN |
---|
63 | de_dy(k,j,i) = 2.0 * sgs_wfv_part * ( e(k,j+1,i) - e(k,j,i) ) & |
---|
64 | * ddy |
---|
65 | ELSEIF ( k > nzb_s_inner(j-1,i) .AND. k > nzb_s_inner(j,i) & |
---|
66 | .AND. k <= nzb_s_inner(j+1,i) ) & |
---|
67 | THEN |
---|
68 | de_dy(k,j,i) = 2.0 * sgs_wfv_part * ( e(k,j,i) - e(k,j-1,i) ) & |
---|
69 | * ddy |
---|
70 | ELSEIF ( k < nzb_s_inner(j,i) .AND. k < nzb_s_inner(j+1,i) ) & |
---|
71 | THEN |
---|
72 | de_dy(k,j,i) = 0.0 |
---|
73 | ELSEIF ( k < nzb_s_inner(j-1,i) .AND. k < nzb_s_inner(j,i) ) & |
---|
74 | THEN |
---|
75 | de_dy(k,j,i) = 0.0 |
---|
76 | ELSE |
---|
77 | de_dy(k,j,i) = sgs_wfv_part * ( e(k,j+1,i) - e(k,j-1,i) ) * ddy |
---|
78 | ENDIF |
---|
79 | |
---|
80 | ENDDO |
---|
81 | ENDDO |
---|
82 | ENDDO |
---|
83 | |
---|
84 | ! |
---|
85 | !-- TKE gradient along z, including bottom and top boundary conditions |
---|
86 | DO i = nxl, nxr |
---|
87 | DO j = nys, nyn |
---|
88 | |
---|
89 | DO k = nzb_s_inner(j,i)+2, nzt-1 |
---|
90 | de_dz(k,j,i) = 2.0 * sgs_wfw_part * & |
---|
91 | ( e(k+1,j,i) - e(k-1,j,i) ) / ( zu(k+1)-zu(k-1) ) |
---|
92 | ENDDO |
---|
93 | |
---|
94 | k = nzb_s_inner(j,i) |
---|
95 | de_dz(nzb:k,j,i) = 0.0 |
---|
96 | de_dz(k+1,j,i) = 2.0 * sgs_wfw_part * ( e(k+2,j,i) - e(k+1,j,i) ) & |
---|
97 | / ( zu(k+2) - zu(k+1) ) |
---|
98 | de_dz(nzt,j,i) = 0.0 |
---|
99 | de_dz(nzt+1,j,i) = 0.0 |
---|
100 | ENDDO |
---|
101 | ENDDO |
---|
102 | |
---|
103 | |
---|
104 | ! |
---|
105 | !-- Lateral boundary conditions |
---|
106 | CALL exchange_horiz( de_dx, nbgp ) |
---|
107 | CALL exchange_horiz( de_dy, nbgp ) |
---|
108 | CALL exchange_horiz( de_dz, nbgp ) |
---|
109 | CALL exchange_horiz( diss, nbgp ) |
---|
110 | |
---|
111 | |
---|
112 | ! |
---|
113 | !-- Calculate the horizontally averaged profiles of SGS TKE and resolved |
---|
114 | !-- velocity variances (they may have been already calculated in routine |
---|
115 | !-- flow_statistics). |
---|
116 | IF ( .NOT. flow_statistics_called ) THEN |
---|
117 | |
---|
118 | ! |
---|
119 | !-- First calculate horizontally averaged profiles of the horizontal |
---|
120 | !-- velocities. |
---|
121 | sums_l(:,1,0) = 0.0 |
---|
122 | sums_l(:,2,0) = 0.0 |
---|
123 | |
---|
124 | DO i = nxl, nxr |
---|
125 | DO j = nys, nyn |
---|
126 | DO k = nzb_s_outer(j,i), nzt+1 |
---|
127 | sums_l(k,1,0) = sums_l(k,1,0) + u(k,j,i) |
---|
128 | sums_l(k,2,0) = sums_l(k,2,0) + v(k,j,i) |
---|
129 | ENDDO |
---|
130 | ENDDO |
---|
131 | ENDDO |
---|
132 | |
---|
133 | #if defined( __parallel ) |
---|
134 | ! |
---|
135 | !-- Compute total sum from local sums |
---|
136 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
137 | CALL MPI_ALLREDUCE( sums_l(nzb,1,0), sums(nzb,1), nzt+2-nzb, & |
---|
138 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
139 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
140 | CALL MPI_ALLREDUCE( sums_l(nzb,2,0), sums(nzb,2), nzt+2-nzb, & |
---|
141 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
142 | #else |
---|
143 | sums(:,1) = sums_l(:,1,0) |
---|
144 | sums(:,2) = sums_l(:,2,0) |
---|
145 | #endif |
---|
146 | |
---|
147 | ! |
---|
148 | !-- Final values are obtained by division by the total number of grid |
---|
149 | !-- points used for the summation. |
---|
150 | hom(:,1,1,0) = sums(:,1) / ngp_2dh_outer(:,0) ! u |
---|
151 | hom(:,1,2,0) = sums(:,2) / ngp_2dh_outer(:,0) ! v |
---|
152 | |
---|
153 | ! |
---|
154 | !-- Now calculate the profiles of SGS TKE and the resolved-scale |
---|
155 | !-- velocity variances |
---|
156 | sums_l(:,8,0) = 0.0 |
---|
157 | sums_l(:,30,0) = 0.0 |
---|
158 | sums_l(:,31,0) = 0.0 |
---|
159 | sums_l(:,32,0) = 0.0 |
---|
160 | DO i = nxl, nxr |
---|
161 | DO j = nys, nyn |
---|
162 | DO k = nzb_s_outer(j,i), nzt+1 |
---|
163 | sums_l(k,8,0) = sums_l(k,8,0) + e(k,j,i) |
---|
164 | sums_l(k,30,0) = sums_l(k,30,0) + ( u(k,j,i) - hom(k,1,1,0) )**2 |
---|
165 | sums_l(k,31,0) = sums_l(k,31,0) + ( v(k,j,i) - hom(k,1,2,0) )**2 |
---|
166 | sums_l(k,32,0) = sums_l(k,32,0) + w(k,j,i)**2 |
---|
167 | ENDDO |
---|
168 | ENDDO |
---|
169 | ENDDO |
---|
170 | |
---|
171 | #if defined( __parallel ) |
---|
172 | ! |
---|
173 | !-- Compute total sum from local sums |
---|
174 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
175 | CALL MPI_ALLREDUCE( sums_l(nzb,8,0), sums(nzb,8), nzt+2-nzb, & |
---|
176 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
177 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
178 | CALL MPI_ALLREDUCE( sums_l(nzb,30,0), sums(nzb,30), nzt+2-nzb, & |
---|
179 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
180 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
181 | CALL MPI_ALLREDUCE( sums_l(nzb,31,0), sums(nzb,31), nzt+2-nzb, & |
---|
182 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
183 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
184 | CALL MPI_ALLREDUCE( sums_l(nzb,32,0), sums(nzb,32), nzt+2-nzb, & |
---|
185 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
186 | |
---|
187 | #else |
---|
188 | sums(:,8) = sums_l(:,8,0) |
---|
189 | sums(:,30) = sums_l(:,30,0) |
---|
190 | sums(:,31) = sums_l(:,31,0) |
---|
191 | sums(:,32) = sums_l(:,32,0) |
---|
192 | #endif |
---|
193 | |
---|
194 | ! |
---|
195 | !-- Final values are obtained by division by the total number of grid |
---|
196 | !-- points used for the summation. |
---|
197 | hom(:,1,8,0) = sums(:,8) / ngp_2dh_outer(:,0) ! e |
---|
198 | hom(:,1,30,0) = sums(:,30) / ngp_2dh_outer(:,0) ! u*2 |
---|
199 | hom(:,1,31,0) = sums(:,31) / ngp_2dh_outer(:,0) ! v*2 |
---|
200 | hom(:,1,32,0) = sums(:,32) / ngp_2dh_outer(:,0) ! w*2 |
---|
201 | |
---|
202 | ENDIF |
---|
203 | |
---|
204 | END SUBROUTINE lpm_init_sgs_tke |
---|