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