1 | SUBROUTINE inflow_turbulence |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Actual revisions: |
---|
5 | ! ----------------- |
---|
6 | ! |
---|
7 | ! |
---|
8 | ! Former revisions: |
---|
9 | ! ----------------- |
---|
10 | ! $Id: inflow_turbulence.f90 163 2008-05-05 14:09:05Z raasch $ |
---|
11 | ! |
---|
12 | ! |
---|
13 | ! Description: |
---|
14 | ! ------------ |
---|
15 | ! Imposing turbulence at the respective inflow using the turbulence |
---|
16 | ! recycling method of Kataoka and Mizuno (2002). |
---|
17 | !------------------------------------------------------------------------------! |
---|
18 | |
---|
19 | USE arrays_3d |
---|
20 | USE control_parameters |
---|
21 | USE cpulog |
---|
22 | USE grid_variables |
---|
23 | USE indices |
---|
24 | USE interfaces |
---|
25 | USE pegrid |
---|
26 | |
---|
27 | |
---|
28 | IMPLICIT NONE |
---|
29 | |
---|
30 | INTEGER :: i, imax, j, k, ngp_ifd, ngp_pr |
---|
31 | |
---|
32 | REAL, DIMENSION(1:2) :: volume_flow_l, volume_flow_offset |
---|
33 | REAL, DIMENSION(nzb:nzt+1,5) :: avpr, avpr_l |
---|
34 | REAL, DIMENSION(nzb:nzt+1,nys-1:nyn+1,5) :: inflow_dist |
---|
35 | |
---|
36 | CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' ) |
---|
37 | |
---|
38 | ! |
---|
39 | !-- Carry out horizontal averaging in the recycling plane |
---|
40 | avpr_l = 0.0 |
---|
41 | ngp_pr = ( nzt - nzb + 2 ) * 5 |
---|
42 | ngp_ifd = ngp_pr * ( nyn - nys + 3 ) |
---|
43 | |
---|
44 | ! |
---|
45 | !-- First, local averaging within the recycling domain |
---|
46 | IF ( recycling_plane >= nxl ) THEN |
---|
47 | |
---|
48 | imax = MIN( nxr, recycling_plane ) |
---|
49 | |
---|
50 | DO i = nxl, imax |
---|
51 | DO j = nys, nyn |
---|
52 | DO k = nzb, nzt+1 |
---|
53 | |
---|
54 | avpr_l(k,1) = avpr_l(k,1) + u(k,j,i) |
---|
55 | avpr_l(k,2) = avpr_l(k,2) + v(k,j,i) |
---|
56 | avpr_l(k,3) = avpr_l(k,3) + w(k,j,i) |
---|
57 | avpr_l(k,4) = avpr_l(k,4) + pt(k,j,i) |
---|
58 | avpr_l(k,5) = avpr_l(k,5) + e(k,j,i) |
---|
59 | |
---|
60 | ENDDO |
---|
61 | ENDDO |
---|
62 | ENDDO |
---|
63 | |
---|
64 | ENDIF |
---|
65 | |
---|
66 | ! WRITE (9,*) '*** averaged profiles avpr_l' |
---|
67 | ! DO k = nzb, nzt+1 |
---|
68 | ! WRITE (9,'(F5.1,1X,F5.1,1X,F5.1,1X,F6.1,1X,F7.2)') avpr_l(k,1),avpr_l(k,2),avpr_l(k,3),avpr_l(k,4),avpr_l(k,5) |
---|
69 | ! ENDDO |
---|
70 | ! WRITE (9,*) ' ' |
---|
71 | |
---|
72 | #if defined( __parallel ) |
---|
73 | ! |
---|
74 | !-- Now, averaging over all PEs |
---|
75 | CALL MPI_ALLREDUCE( avpr_l(nzb,1), avpr(nzb,1), ngp_pr, MPI_REAL, MPI_SUM, & |
---|
76 | comm2d, ierr ) |
---|
77 | #else |
---|
78 | avpr = avpr_l |
---|
79 | #endif |
---|
80 | |
---|
81 | avpr = avpr / ( ( ny + 1 ) * ( recycling_plane + 1 ) ) |
---|
82 | |
---|
83 | ! WRITE (9,*) '*** averaged profiles' |
---|
84 | ! DO k = nzb, nzt+1 |
---|
85 | ! WRITE (9,'(F5.1,1X,F5.1,1X,F5.1,1X,F6.1,1X,F7.2)') avpr(k,1),avpr(k,2),avpr(k,3),avpr(k,4),avpr(k,5) |
---|
86 | ! ENDDO |
---|
87 | ! WRITE (9,*) ' ' |
---|
88 | |
---|
89 | ! |
---|
90 | !-- Calculate the disturbances at the recycling plane |
---|
91 | i = recycling_plane |
---|
92 | |
---|
93 | IF ( myidx == id_recycling ) THEN |
---|
94 | |
---|
95 | DO j = nys-1, nyn+1 |
---|
96 | DO k = nzb, nzt+1 |
---|
97 | |
---|
98 | inflow_dist(k,j,1) = u(k,j,i+1) - avpr(k,1) |
---|
99 | inflow_dist(k,j,2) = v(k,j,i) - avpr(k,2) |
---|
100 | inflow_dist(k,j,3) = w(k,j,i) - avpr(k,3) |
---|
101 | inflow_dist(k,j,4) = pt(k,j,i) - avpr(k,4) |
---|
102 | inflow_dist(k,j,5) = e(k,j,i) - avpr(k,5) |
---|
103 | |
---|
104 | ENDDO |
---|
105 | ENDDO |
---|
106 | |
---|
107 | ENDIF |
---|
108 | |
---|
109 | ! |
---|
110 | !-- For parallel runs, send the disturbances to the respective inflow PE |
---|
111 | #if defined( __parallel ) |
---|
112 | IF ( myidx == id_recycling .AND. myidx /= id_inflow ) THEN |
---|
113 | |
---|
114 | CALL MPI_SEND( inflow_dist(nzb,nys-1,1), ngp_ifd, MPI_REAL, & |
---|
115 | id_inflow, 1, comm1dx, ierr ) |
---|
116 | |
---|
117 | ELSEIF ( myidx /= id_recycling .AND. myidx == id_inflow ) THEN |
---|
118 | |
---|
119 | inflow_dist = 0.0 |
---|
120 | CALL MPI_RECV( inflow_dist(nzb,nys-1,1), ngp_ifd, MPI_REAL, & |
---|
121 | id_recycling, 1, comm1dx, status, ierr ) |
---|
122 | |
---|
123 | ENDIF |
---|
124 | #endif |
---|
125 | |
---|
126 | ! |
---|
127 | !-- Add the disturbance at the inflow |
---|
128 | IF ( nxl == 0 ) THEN |
---|
129 | |
---|
130 | DO j = nys-1, nyn+1 |
---|
131 | DO k = nzb, nzt+1 |
---|
132 | |
---|
133 | ! WRITE (9,*) 'j=',j,' k=',k |
---|
134 | ! WRITE (9,*) 'mean_u = ', mean_inflow_profiles(k,1), ' dist_u = ',& |
---|
135 | ! inflow_dist(k,j,1) |
---|
136 | ! WRITE (9,*) 'mean_v = ', mean_inflow_profiles(k,2), ' dist_v = ',& |
---|
137 | ! inflow_dist(k,j,2) |
---|
138 | ! WRITE (9,*) 'mean_w = 0.0', ' dist_w = ',& |
---|
139 | ! inflow_dist(k,j,3) |
---|
140 | ! WRITE (9,*) 'mean_pt = ', mean_inflow_profiles(k,4), ' dist_pt = ',& |
---|
141 | ! inflow_dist(k,j,4) |
---|
142 | ! WRITE (9,*) 'mean_e = ', mean_inflow_profiles(k,5), ' dist_e = ',& |
---|
143 | ! inflow_dist(k,j,5) |
---|
144 | u(k,j,0) = mean_inflow_profiles(k,1) + & |
---|
145 | inflow_dist(k,j,1) * inflow_damping_factor(k) |
---|
146 | v(k,j,-1) = mean_inflow_profiles(k,2) + & |
---|
147 | inflow_dist(k,j,2) * inflow_damping_factor(k) |
---|
148 | w(k,j,-1) = inflow_dist(k,j,3) * inflow_damping_factor(k) |
---|
149 | pt(k,j,-1) = mean_inflow_profiles(k,4) + & |
---|
150 | inflow_dist(k,j,4) * inflow_damping_factor(k) |
---|
151 | e(k,j,-1) = mean_inflow_profiles(k,5) + & |
---|
152 | inflow_dist(k,j,5) * inflow_damping_factor(k) |
---|
153 | e(k,j,-1) = MAX( e(k,j,-1), 0.0 ) |
---|
154 | |
---|
155 | ENDDO |
---|
156 | ENDDO |
---|
157 | |
---|
158 | ENDIF |
---|
159 | |
---|
160 | ! |
---|
161 | !-- Conserve the volume flow at the inflow in order to avoid generation of |
---|
162 | !-- waves in the stable layer |
---|
163 | ! IF ( conserve_volume_flow .AND. inflow_l ) THEN |
---|
164 | |
---|
165 | ! volume_flow(1) = 0.0 |
---|
166 | ! volume_flow_l(1) = 0.0 |
---|
167 | |
---|
168 | ! i = 0 |
---|
169 | |
---|
170 | ! DO j = nys, nyn |
---|
171 | ! |
---|
172 | !-- Sum up the volume flow through the south/north boundary |
---|
173 | ! DO k = nzb_2d(j,i) + 1, nzt |
---|
174 | ! volume_flow_l(1) = volume_flow_l(1) + u(k,j,i) * dzu(k) |
---|
175 | ! ENDDO |
---|
176 | ! ENDDO |
---|
177 | |
---|
178 | #if defined( __parallel ) |
---|
179 | ! CALL MPI_ALLREDUCE( volume_flow_l(1), volume_flow(1), 1, MPI_REAL, & |
---|
180 | ! MPI_SUM, comm1dy, ierr ) |
---|
181 | #else |
---|
182 | ! volume_flow = volume_flow_l |
---|
183 | #endif |
---|
184 | ! volume_flow_offset(1) = ( volume_flow_initial(1) - volume_flow(1) ) & |
---|
185 | ! / volume_flow_area(1) |
---|
186 | |
---|
187 | ! DO j = nys-1, nyn+1 |
---|
188 | ! DO k = nzb_v_inner(j,i) + 1, nzt |
---|
189 | ! u(k,j,i) = u(k,j,i) + volume_flow_offset(1) |
---|
190 | ! ENDDO |
---|
191 | ! ENDDO |
---|
192 | |
---|
193 | ! ENDIF |
---|
194 | |
---|
195 | CALL cpu_log( log_point(40), 'inflow_turbulence', 'stop' ) |
---|
196 | |
---|
197 | |
---|
198 | END SUBROUTINE inflow_turbulence |
---|