1 | SUBROUTINE data_output_2d( mode, av ) |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Current revisions: |
---|
5 | ! ----------------- |
---|
6 | ! Splitting of parallel I/O |
---|
7 | ! |
---|
8 | ! Former revisions: |
---|
9 | ! ----------------- |
---|
10 | ! $Id: data_output_2d.f90 759 2011-09-15 13:58:31Z raasch $ |
---|
11 | ! |
---|
12 | ! 729 2011-05-26 10:33:34Z heinze |
---|
13 | ! Exchange ghost layers for p regardless of used pressure solver (except SOR). |
---|
14 | ! |
---|
15 | ! 691 2011-03-04 08:45:30Z maronga |
---|
16 | ! Replaced simulated_time by time_since_reference_point |
---|
17 | ! |
---|
18 | ! 673 2011-01-18 16:19:48Z suehring |
---|
19 | ! When using Multigrid or SOR solver an additional CALL exchange_horiz is |
---|
20 | ! is needed for pressure output. |
---|
21 | ! |
---|
22 | ! 667 2010-12-23 12:06:00Z suehring/gryschka |
---|
23 | ! nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng in loops and |
---|
24 | ! allocation of arrays local_2d and total_2d. |
---|
25 | ! Calls of exchange_horiz are modiefied. |
---|
26 | ! |
---|
27 | ! 622 2010-12-10 08:08:13Z raasch |
---|
28 | ! optional barriers included in order to speed up collective operations |
---|
29 | ! |
---|
30 | ! 493 2010-03-01 08:30:24Z raasch |
---|
31 | ! NetCDF4 support (parallel output) |
---|
32 | ! |
---|
33 | ! 367 2009-08-25 08:35:52Z maronga |
---|
34 | ! simulated_time in NetCDF output replaced by time_since_reference_point. |
---|
35 | ! Output of NetCDF messages with aid of message handling routine. |
---|
36 | ! Bugfix: averaging along z is not allowed for 2d quantities (e.g. u* and z0) |
---|
37 | ! Output of messages replaced by message handling routine. |
---|
38 | ! Output of user defined 2D (XY) arrays at z=nzb+1 is now possible |
---|
39 | ! Bugfix: to_be_resorted => s_av for time-averaged scalars |
---|
40 | ! Calculation of shf* and qsws* added. |
---|
41 | ! |
---|
42 | ! 215 2008-11-18 09:54:31Z raasch |
---|
43 | ! Bugfix: no output of particle concentration and radius unless particles |
---|
44 | ! have been started |
---|
45 | ! |
---|
46 | ! 96 2007-06-04 08:07:41Z raasch |
---|
47 | ! Output of density and salinity |
---|
48 | ! |
---|
49 | ! 75 2007-03-22 09:54:05Z raasch |
---|
50 | ! Output of precipitation amount/rate and roughness length, |
---|
51 | ! 2nd+3rd argument removed from exchange horiz |
---|
52 | ! |
---|
53 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
54 | ! |
---|
55 | ! Revision 1.5 2006/08/22 13:50:29 raasch |
---|
56 | ! xz and yz cross sections now up to nzt+1 |
---|
57 | ! |
---|
58 | ! Revision 1.2 2006/02/23 10:19:22 raasch |
---|
59 | ! Output of time-averaged data, output of averages along x, y, or z, |
---|
60 | ! output of user-defined quantities, |
---|
61 | ! section data are copied from local_pf to local_2d before they are output, |
---|
62 | ! output of particle concentration and mean radius, |
---|
63 | ! Former subroutine plot_2d renamed data_output_2d, pl2d.. renamed do2d.., |
---|
64 | ! anz renamed ngp, ebene renamed section, pl2d_.._anz renamed do2d_.._n |
---|
65 | ! |
---|
66 | ! Revision 1.1 1997/08/11 06:24:09 raasch |
---|
67 | ! Initial revision |
---|
68 | ! |
---|
69 | ! |
---|
70 | ! Description: |
---|
71 | ! ------------ |
---|
72 | ! Data output of horizontal cross-sections in NetCDF format or binary format |
---|
73 | ! compatible to old graphic software iso2d. |
---|
74 | ! Attention: The position of the sectional planes is still not always computed |
---|
75 | ! --------- correctly. (zu is used always)! |
---|
76 | !------------------------------------------------------------------------------! |
---|
77 | |
---|
78 | USE arrays_3d |
---|
79 | USE averaging |
---|
80 | USE cloud_parameters |
---|
81 | USE control_parameters |
---|
82 | USE cpulog |
---|
83 | USE grid_variables |
---|
84 | USE indices |
---|
85 | USE interfaces |
---|
86 | USE netcdf_control |
---|
87 | USE particle_attributes |
---|
88 | USE pegrid |
---|
89 | |
---|
90 | IMPLICIT NONE |
---|
91 | |
---|
92 | CHARACTER (LEN=2) :: do2d_mode, mode |
---|
93 | CHARACTER (LEN=4) :: grid |
---|
94 | CHARACTER (LEN=25) :: section_chr |
---|
95 | CHARACTER (LEN=50) :: rtext |
---|
96 | INTEGER :: av, ngp, file_id, i, if, is, iis, j, k, l, layer_xy, n, psi, & |
---|
97 | s, sender, & |
---|
98 | ind(4) |
---|
99 | LOGICAL :: found, resorted, two_d |
---|
100 | REAL :: mean_r, s_r3, s_r4 |
---|
101 | REAL, DIMENSION(:), ALLOCATABLE :: level_z |
---|
102 | REAL, DIMENSION(:,:), ALLOCATABLE :: local_2d, local_2d_l |
---|
103 | REAL, DIMENSION(:,:,:), ALLOCATABLE :: local_pf |
---|
104 | #if defined( __parallel ) |
---|
105 | REAL, DIMENSION(:,:), ALLOCATABLE :: total_2d |
---|
106 | #endif |
---|
107 | REAL, DIMENSION(:,:,:), POINTER :: to_be_resorted |
---|
108 | |
---|
109 | NAMELIST /LOCAL/ rtext |
---|
110 | |
---|
111 | CALL cpu_log (log_point(3),'data_output_2d','start') |
---|
112 | |
---|
113 | ! |
---|
114 | !-- Immediate return, if no output is requested (no respective sections |
---|
115 | !-- found in parameter data_output) |
---|
116 | IF ( mode == 'xy' .AND. .NOT. data_output_xy(av) ) RETURN |
---|
117 | IF ( mode == 'xz' .AND. .NOT. data_output_xz(av) ) RETURN |
---|
118 | IF ( mode == 'yz' .AND. .NOT. data_output_yz(av) ) RETURN |
---|
119 | |
---|
120 | two_d = .FALSE. ! local variable to distinguish between output of pure 2D |
---|
121 | ! arrays and cross-sections of 3D arrays. |
---|
122 | |
---|
123 | ! |
---|
124 | !-- Depending on the orientation of the cross-section, the respective output |
---|
125 | !-- files have to be opened. |
---|
126 | SELECT CASE ( mode ) |
---|
127 | |
---|
128 | CASE ( 'xy' ) |
---|
129 | s = 1 |
---|
130 | ALLOCATE( level_z(nzb:nzt+1), local_2d(nxlg:nxrg,nysg:nyng) ) |
---|
131 | |
---|
132 | ! |
---|
133 | !-- Classic and 64bit offset NetCDF output is done only on PE0. |
---|
134 | !-- netCDF4/HDF5 output is done in parallel on all PEs. |
---|
135 | IF ( netcdf_output .AND. ( myid == 0 .OR. netcdf_data_format > 2 ) ) & |
---|
136 | THEN |
---|
137 | CALL check_open( 101+av*10 ) |
---|
138 | ENDIF |
---|
139 | |
---|
140 | IF ( data_output_2d_on_each_pe ) THEN |
---|
141 | CALL check_open( 21 ) |
---|
142 | ELSE |
---|
143 | IF ( myid == 0 ) THEN |
---|
144 | IF ( iso2d_output ) CALL check_open( 21 ) |
---|
145 | #if defined( __parallel ) |
---|
146 | ALLOCATE( total_2d(-nbgp:nx+nbgp,-nbgp:ny+nbgp) ) |
---|
147 | #endif |
---|
148 | ENDIF |
---|
149 | ENDIF |
---|
150 | |
---|
151 | CASE ( 'xz' ) |
---|
152 | s = 2 |
---|
153 | ALLOCATE( local_2d(nxlg:nxrg,nzb:nzt+1) ) |
---|
154 | |
---|
155 | ! |
---|
156 | !-- Classic and 64bit offset NetCDF output is done only on PE0. |
---|
157 | !-- netCDF4/HDF5 output may be done in parallel on all PEs. |
---|
158 | IF ( netcdf_output .AND. ( myid == 0 .OR. netcdf_data_format > 2 ) ) & |
---|
159 | THEN |
---|
160 | CALL check_open( 102+av*10 ) |
---|
161 | ENDIF |
---|
162 | |
---|
163 | IF ( data_output_2d_on_each_pe ) THEN |
---|
164 | CALL check_open( 22 ) |
---|
165 | ELSE |
---|
166 | IF ( myid == 0 ) THEN |
---|
167 | IF ( iso2d_output ) CALL check_open( 22 ) |
---|
168 | #if defined( __parallel ) |
---|
169 | ALLOCATE( total_2d(-nbgp:nx+nbgp,nzb:nzt+1) ) |
---|
170 | #endif |
---|
171 | ENDIF |
---|
172 | ENDIF |
---|
173 | |
---|
174 | CASE ( 'yz' ) |
---|
175 | |
---|
176 | s = 3 |
---|
177 | ALLOCATE( local_2d(nysg:nyng,nzb:nzt+1) ) |
---|
178 | |
---|
179 | ! |
---|
180 | !-- Classic and 64bit offset NetCDF output is done only on PE0. |
---|
181 | !-- netCDF4/HDF5 output may be done in parallel on all PEs. |
---|
182 | IF ( netcdf_output .AND. ( myid == 0 .OR. netcdf_data_format > 2 ) ) & |
---|
183 | THEN |
---|
184 | CALL check_open( 103+av*10 ) |
---|
185 | ENDIF |
---|
186 | |
---|
187 | IF ( data_output_2d_on_each_pe ) THEN |
---|
188 | CALL check_open( 23 ) |
---|
189 | ELSE |
---|
190 | IF ( myid == 0 ) THEN |
---|
191 | IF ( iso2d_output ) CALL check_open( 23 ) |
---|
192 | #if defined( __parallel ) |
---|
193 | ALLOCATE( total_2d(-nbgp:ny+nbgp,nzb:nzt+1) ) |
---|
194 | #endif |
---|
195 | ENDIF |
---|
196 | ENDIF |
---|
197 | |
---|
198 | CASE DEFAULT |
---|
199 | |
---|
200 | message_string = 'unknown cross-section: ' // TRIM( mode ) |
---|
201 | CALL message( 'data_output_2d', 'PA0180', 1, 2, 0, 6, 0 ) |
---|
202 | |
---|
203 | END SELECT |
---|
204 | |
---|
205 | ! |
---|
206 | !-- Allocate a temporary array for resorting (kji -> ijk). |
---|
207 | ALLOCATE( local_pf(nxlg:nxrg,nysg:nyng,nzb:nzt+1) ) |
---|
208 | |
---|
209 | ! |
---|
210 | !-- Loop of all variables to be written. |
---|
211 | !-- Output dimensions chosen |
---|
212 | if = 1 |
---|
213 | l = MAX( 2, LEN_TRIM( do2d(av,if) ) ) |
---|
214 | do2d_mode = do2d(av,if)(l-1:l) |
---|
215 | |
---|
216 | DO WHILE ( do2d(av,if)(1:1) /= ' ' ) |
---|
217 | |
---|
218 | IF ( do2d_mode == mode ) THEN |
---|
219 | ! |
---|
220 | !-- Store the array chosen on the temporary array. |
---|
221 | resorted = .FALSE. |
---|
222 | SELECT CASE ( TRIM( do2d(av,if) ) ) |
---|
223 | |
---|
224 | CASE ( 'e_xy', 'e_xz', 'e_yz' ) |
---|
225 | IF ( av == 0 ) THEN |
---|
226 | to_be_resorted => e |
---|
227 | ELSE |
---|
228 | to_be_resorted => e_av |
---|
229 | ENDIF |
---|
230 | IF ( mode == 'xy' ) level_z = zu |
---|
231 | |
---|
232 | CASE ( 'lwp*_xy' ) ! 2d-array |
---|
233 | IF ( av == 0 ) THEN |
---|
234 | DO i = nxlg, nxrg |
---|
235 | DO j = nysg, nyng |
---|
236 | local_pf(i,j,nzb+1) = SUM( ql(nzb:nzt,j,i) * & |
---|
237 | dzw(1:nzt+1) ) |
---|
238 | ENDDO |
---|
239 | ENDDO |
---|
240 | ELSE |
---|
241 | DO i = nxlg, nxrg |
---|
242 | DO j = nysg, nyng |
---|
243 | local_pf(i,j,nzb+1) = lwp_av(j,i) |
---|
244 | ENDDO |
---|
245 | ENDDO |
---|
246 | ENDIF |
---|
247 | resorted = .TRUE. |
---|
248 | two_d = .TRUE. |
---|
249 | level_z(nzb+1) = zu(nzb+1) |
---|
250 | |
---|
251 | CASE ( 'p_xy', 'p_xz', 'p_yz' ) |
---|
252 | IF ( av == 0 ) THEN |
---|
253 | IF ( psolver /= 'sor' ) CALL exchange_horiz( p, nbgp ) |
---|
254 | to_be_resorted => p |
---|
255 | ELSE |
---|
256 | IF ( psolver /= 'sor' ) CALL exchange_horiz( p_av, nbgp ) |
---|
257 | to_be_resorted => p_av |
---|
258 | ENDIF |
---|
259 | IF ( mode == 'xy' ) level_z = zu |
---|
260 | |
---|
261 | CASE ( 'pc_xy', 'pc_xz', 'pc_yz' ) ! particle concentration |
---|
262 | IF ( av == 0 ) THEN |
---|
263 | IF ( simulated_time >= particle_advection_start ) THEN |
---|
264 | tend = prt_count |
---|
265 | CALL exchange_horiz( tend, nbgp ) |
---|
266 | ELSE |
---|
267 | tend = 0.0 |
---|
268 | ENDIF |
---|
269 | DO i = nxlg, nxrg |
---|
270 | DO j = nysg, nyng |
---|
271 | DO k = nzb, nzt+1 |
---|
272 | local_pf(i,j,k) = tend(k,j,i) |
---|
273 | ENDDO |
---|
274 | ENDDO |
---|
275 | ENDDO |
---|
276 | resorted = .TRUE. |
---|
277 | ELSE |
---|
278 | CALL exchange_horiz( pc_av, nbgp ) |
---|
279 | to_be_resorted => pc_av |
---|
280 | ENDIF |
---|
281 | |
---|
282 | CASE ( 'pr_xy', 'pr_xz', 'pr_yz' ) ! mean particle radius |
---|
283 | IF ( av == 0 ) THEN |
---|
284 | IF ( simulated_time >= particle_advection_start ) THEN |
---|
285 | DO i = nxl, nxr |
---|
286 | DO j = nys, nyn |
---|
287 | DO k = nzb, nzt+1 |
---|
288 | psi = prt_start_index(k,j,i) |
---|
289 | s_r3 = 0.0 |
---|
290 | s_r4 = 0.0 |
---|
291 | DO n = psi, psi+prt_count(k,j,i)-1 |
---|
292 | s_r3 = s_r3 + particles(n)%radius**3 |
---|
293 | s_r4 = s_r4 + particles(n)%radius**4 |
---|
294 | ENDDO |
---|
295 | IF ( s_r3 /= 0.0 ) THEN |
---|
296 | mean_r = s_r4 / s_r3 |
---|
297 | ELSE |
---|
298 | mean_r = 0.0 |
---|
299 | ENDIF |
---|
300 | tend(k,j,i) = mean_r |
---|
301 | ENDDO |
---|
302 | ENDDO |
---|
303 | ENDDO |
---|
304 | CALL exchange_horiz( tend, nbgp ) |
---|
305 | ELSE |
---|
306 | tend = 0.0 |
---|
307 | END IF |
---|
308 | DO i = nxlg, nxrg |
---|
309 | DO j = nysg, nyng |
---|
310 | DO k = nzb, nzt+1 |
---|
311 | local_pf(i,j,k) = tend(k,j,i) |
---|
312 | ENDDO |
---|
313 | ENDDO |
---|
314 | ENDDO |
---|
315 | resorted = .TRUE. |
---|
316 | ELSE |
---|
317 | CALL exchange_horiz( pr_av, nbgp ) |
---|
318 | to_be_resorted => pr_av |
---|
319 | ENDIF |
---|
320 | |
---|
321 | CASE ( 'pra*_xy' ) ! 2d-array / integral quantity => no av |
---|
322 | CALL exchange_horiz_2d( precipitation_amount ) |
---|
323 | DO i = nxlg, nxrg |
---|
324 | DO j = nysg, nyng |
---|
325 | local_pf(i,j,nzb+1) = precipitation_amount(j,i) |
---|
326 | ENDDO |
---|
327 | ENDDO |
---|
328 | precipitation_amount = 0.0 ! reset for next integ. interval |
---|
329 | resorted = .TRUE. |
---|
330 | two_d = .TRUE. |
---|
331 | level_z(nzb+1) = zu(nzb+1) |
---|
332 | |
---|
333 | CASE ( 'prr*_xy' ) ! 2d-array |
---|
334 | IF ( av == 0 ) THEN |
---|
335 | CALL exchange_horiz_2d( precipitation_rate ) |
---|
336 | DO i = nxlg, nxrg |
---|
337 | DO j = nysg, nyng |
---|
338 | local_pf(i,j,nzb+1) = precipitation_rate(j,i) |
---|
339 | ENDDO |
---|
340 | ENDDO |
---|
341 | ELSE |
---|
342 | CALL exchange_horiz_2d( precipitation_rate_av ) |
---|
343 | DO i = nxlg, nxrg |
---|
344 | DO j = nysg, nyng |
---|
345 | local_pf(i,j,nzb+1) = precipitation_rate_av(j,i) |
---|
346 | ENDDO |
---|
347 | ENDDO |
---|
348 | ENDIF |
---|
349 | resorted = .TRUE. |
---|
350 | two_d = .TRUE. |
---|
351 | level_z(nzb+1) = zu(nzb+1) |
---|
352 | |
---|
353 | CASE ( 'pt_xy', 'pt_xz', 'pt_yz' ) |
---|
354 | IF ( av == 0 ) THEN |
---|
355 | IF ( .NOT. cloud_physics ) THEN |
---|
356 | to_be_resorted => pt |
---|
357 | ELSE |
---|
358 | DO i = nxlg, nxrg |
---|
359 | DO j = nysg, nyng |
---|
360 | DO k = nzb, nzt+1 |
---|
361 | local_pf(i,j,k) = pt(k,j,i) + l_d_cp * & |
---|
362 | pt_d_t(k) * & |
---|
363 | ql(k,j,i) |
---|
364 | ENDDO |
---|
365 | ENDDO |
---|
366 | ENDDO |
---|
367 | resorted = .TRUE. |
---|
368 | ENDIF |
---|
369 | ELSE |
---|
370 | to_be_resorted => pt_av |
---|
371 | ENDIF |
---|
372 | IF ( mode == 'xy' ) level_z = zu |
---|
373 | |
---|
374 | CASE ( 'q_xy', 'q_xz', 'q_yz' ) |
---|
375 | IF ( av == 0 ) THEN |
---|
376 | to_be_resorted => q |
---|
377 | ELSE |
---|
378 | to_be_resorted => q_av |
---|
379 | ENDIF |
---|
380 | IF ( mode == 'xy' ) level_z = zu |
---|
381 | |
---|
382 | CASE ( 'ql_xy', 'ql_xz', 'ql_yz' ) |
---|
383 | IF ( av == 0 ) THEN |
---|
384 | to_be_resorted => ql |
---|
385 | ELSE |
---|
386 | to_be_resorted => ql_av |
---|
387 | ENDIF |
---|
388 | IF ( mode == 'xy' ) level_z = zu |
---|
389 | |
---|
390 | CASE ( 'ql_c_xy', 'ql_c_xz', 'ql_c_yz' ) |
---|
391 | IF ( av == 0 ) THEN |
---|
392 | to_be_resorted => ql_c |
---|
393 | ELSE |
---|
394 | to_be_resorted => ql_c_av |
---|
395 | ENDIF |
---|
396 | IF ( mode == 'xy' ) level_z = zu |
---|
397 | |
---|
398 | CASE ( 'ql_v_xy', 'ql_v_xz', 'ql_v_yz' ) |
---|
399 | IF ( av == 0 ) THEN |
---|
400 | to_be_resorted => ql_v |
---|
401 | ELSE |
---|
402 | to_be_resorted => ql_v_av |
---|
403 | ENDIF |
---|
404 | IF ( mode == 'xy' ) level_z = zu |
---|
405 | |
---|
406 | CASE ( 'ql_vp_xy', 'ql_vp_xz', 'ql_vp_yz' ) |
---|
407 | IF ( av == 0 ) THEN |
---|
408 | to_be_resorted => ql_vp |
---|
409 | ELSE |
---|
410 | to_be_resorted => ql_vp_av |
---|
411 | ENDIF |
---|
412 | IF ( mode == 'xy' ) level_z = zu |
---|
413 | |
---|
414 | CASE ( 'qsws*_xy' ) ! 2d-array |
---|
415 | IF ( av == 0 ) THEN |
---|
416 | DO i = nxlg, nxrg |
---|
417 | DO j = nysg, nyng |
---|
418 | local_pf(i,j,nzb+1) = qsws(j,i) |
---|
419 | ENDDO |
---|
420 | ENDDO |
---|
421 | ELSE |
---|
422 | DO i = nxlg, nxrg |
---|
423 | DO j = nysg, nyng |
---|
424 | local_pf(i,j,nzb+1) = qsws_av(j,i) |
---|
425 | ENDDO |
---|
426 | ENDDO |
---|
427 | ENDIF |
---|
428 | resorted = .TRUE. |
---|
429 | two_d = .TRUE. |
---|
430 | level_z(nzb+1) = zu(nzb+1) |
---|
431 | |
---|
432 | CASE ( 'qv_xy', 'qv_xz', 'qv_yz' ) |
---|
433 | IF ( av == 0 ) THEN |
---|
434 | DO i = nxlg, nxrg |
---|
435 | DO j = nysg, nyng |
---|
436 | DO k = nzb, nzt+1 |
---|
437 | local_pf(i,j,k) = q(k,j,i) - ql(k,j,i) |
---|
438 | ENDDO |
---|
439 | ENDDO |
---|
440 | ENDDO |
---|
441 | resorted = .TRUE. |
---|
442 | ELSE |
---|
443 | to_be_resorted => qv_av |
---|
444 | ENDIF |
---|
445 | IF ( mode == 'xy' ) level_z = zu |
---|
446 | |
---|
447 | CASE ( 'rho_xy', 'rho_xz', 'rho_yz' ) |
---|
448 | IF ( av == 0 ) THEN |
---|
449 | to_be_resorted => rho |
---|
450 | ELSE |
---|
451 | to_be_resorted => rho_av |
---|
452 | ENDIF |
---|
453 | |
---|
454 | CASE ( 's_xy', 's_xz', 's_yz' ) |
---|
455 | IF ( av == 0 ) THEN |
---|
456 | to_be_resorted => q |
---|
457 | ELSE |
---|
458 | to_be_resorted => s_av |
---|
459 | ENDIF |
---|
460 | |
---|
461 | CASE ( 'sa_xy', 'sa_xz', 'sa_yz' ) |
---|
462 | IF ( av == 0 ) THEN |
---|
463 | to_be_resorted => sa |
---|
464 | ELSE |
---|
465 | to_be_resorted => sa_av |
---|
466 | ENDIF |
---|
467 | |
---|
468 | CASE ( 'shf*_xy' ) ! 2d-array |
---|
469 | IF ( av == 0 ) THEN |
---|
470 | DO i = nxlg, nxrg |
---|
471 | DO j = nysg, nyng |
---|
472 | local_pf(i,j,nzb+1) = shf(j,i) |
---|
473 | ENDDO |
---|
474 | ENDDO |
---|
475 | ELSE |
---|
476 | DO i = nxlg, nxrg |
---|
477 | DO j = nysg, nyng |
---|
478 | local_pf(i,j,nzb+1) = shf_av(j,i) |
---|
479 | ENDDO |
---|
480 | ENDDO |
---|
481 | ENDIF |
---|
482 | resorted = .TRUE. |
---|
483 | two_d = .TRUE. |
---|
484 | level_z(nzb+1) = zu(nzb+1) |
---|
485 | |
---|
486 | CASE ( 't*_xy' ) ! 2d-array |
---|
487 | IF ( av == 0 ) THEN |
---|
488 | DO i = nxlg, nxrg |
---|
489 | DO j = nysg, nyng |
---|
490 | local_pf(i,j,nzb+1) = ts(j,i) |
---|
491 | ENDDO |
---|
492 | ENDDO |
---|
493 | ELSE |
---|
494 | DO i = nxlg, nxrg |
---|
495 | DO j = nysg, nyng |
---|
496 | local_pf(i,j,nzb+1) = ts_av(j,i) |
---|
497 | ENDDO |
---|
498 | ENDDO |
---|
499 | ENDIF |
---|
500 | resorted = .TRUE. |
---|
501 | two_d = .TRUE. |
---|
502 | level_z(nzb+1) = zu(nzb+1) |
---|
503 | |
---|
504 | CASE ( 'u_xy', 'u_xz', 'u_yz' ) |
---|
505 | IF ( av == 0 ) THEN |
---|
506 | to_be_resorted => u |
---|
507 | ELSE |
---|
508 | to_be_resorted => u_av |
---|
509 | ENDIF |
---|
510 | IF ( mode == 'xy' ) level_z = zu |
---|
511 | ! |
---|
512 | !-- Substitute the values generated by "mirror" boundary condition |
---|
513 | !-- at the bottom boundary by the real surface values. |
---|
514 | IF ( do2d(av,if) == 'u_xz' .OR. do2d(av,if) == 'u_yz' ) THEN |
---|
515 | IF ( ibc_uv_b == 0 ) local_pf(:,:,nzb) = 0.0 |
---|
516 | ENDIF |
---|
517 | |
---|
518 | CASE ( 'u*_xy' ) ! 2d-array |
---|
519 | IF ( av == 0 ) THEN |
---|
520 | DO i = nxlg, nxrg |
---|
521 | DO j = nysg, nyng |
---|
522 | local_pf(i,j,nzb+1) = us(j,i) |
---|
523 | ENDDO |
---|
524 | ENDDO |
---|
525 | ELSE |
---|
526 | DO i = nxlg, nxrg |
---|
527 | DO j = nysg, nyng |
---|
528 | local_pf(i,j,nzb+1) = us_av(j,i) |
---|
529 | ENDDO |
---|
530 | ENDDO |
---|
531 | ENDIF |
---|
532 | resorted = .TRUE. |
---|
533 | two_d = .TRUE. |
---|
534 | level_z(nzb+1) = zu(nzb+1) |
---|
535 | |
---|
536 | CASE ( 'v_xy', 'v_xz', 'v_yz' ) |
---|
537 | IF ( av == 0 ) THEN |
---|
538 | to_be_resorted => v |
---|
539 | ELSE |
---|
540 | to_be_resorted => v_av |
---|
541 | ENDIF |
---|
542 | IF ( mode == 'xy' ) level_z = zu |
---|
543 | ! |
---|
544 | !-- Substitute the values generated by "mirror" boundary condition |
---|
545 | !-- at the bottom boundary by the real surface values. |
---|
546 | IF ( do2d(av,if) == 'v_xz' .OR. do2d(av,if) == 'v_yz' ) THEN |
---|
547 | IF ( ibc_uv_b == 0 ) local_pf(:,:,nzb) = 0.0 |
---|
548 | ENDIF |
---|
549 | |
---|
550 | CASE ( 'vpt_xy', 'vpt_xz', 'vpt_yz' ) |
---|
551 | IF ( av == 0 ) THEN |
---|
552 | to_be_resorted => vpt |
---|
553 | ELSE |
---|
554 | to_be_resorted => vpt_av |
---|
555 | ENDIF |
---|
556 | IF ( mode == 'xy' ) level_z = zu |
---|
557 | |
---|
558 | CASE ( 'w_xy', 'w_xz', 'w_yz' ) |
---|
559 | IF ( av == 0 ) THEN |
---|
560 | to_be_resorted => w |
---|
561 | ELSE |
---|
562 | to_be_resorted => w_av |
---|
563 | ENDIF |
---|
564 | IF ( mode == 'xy' ) level_z = zw |
---|
565 | |
---|
566 | CASE ( 'z0*_xy' ) ! 2d-array |
---|
567 | IF ( av == 0 ) THEN |
---|
568 | DO i = nxlg, nxrg |
---|
569 | DO j = nysg, nyng |
---|
570 | local_pf(i,j,nzb+1) = z0(j,i) |
---|
571 | ENDDO |
---|
572 | ENDDO |
---|
573 | ELSE |
---|
574 | DO i = nxlg, nxrg |
---|
575 | DO j = nysg, nyng |
---|
576 | local_pf(i,j,nzb+1) = z0_av(j,i) |
---|
577 | ENDDO |
---|
578 | ENDDO |
---|
579 | ENDIF |
---|
580 | resorted = .TRUE. |
---|
581 | two_d = .TRUE. |
---|
582 | level_z(nzb+1) = zu(nzb+1) |
---|
583 | |
---|
584 | CASE DEFAULT |
---|
585 | ! |
---|
586 | !-- User defined quantity |
---|
587 | CALL user_data_output_2d( av, do2d(av,if), found, grid, & |
---|
588 | local_pf, two_d ) |
---|
589 | resorted = .TRUE. |
---|
590 | |
---|
591 | IF ( grid == 'zu' ) THEN |
---|
592 | IF ( mode == 'xy' ) level_z = zu |
---|
593 | ELSEIF ( grid == 'zw' ) THEN |
---|
594 | IF ( mode == 'xy' ) level_z = zw |
---|
595 | ELSEIF ( grid == 'zu1' ) THEN |
---|
596 | IF ( mode == 'xy' ) level_z(nzb+1) = zu(nzb+1) |
---|
597 | ENDIF |
---|
598 | |
---|
599 | IF ( .NOT. found ) THEN |
---|
600 | message_string = 'no output provided for: ' // & |
---|
601 | TRIM( do2d(av,if) ) |
---|
602 | CALL message( 'data_output_2d', 'PA0181', 0, 0, 0, 6, 0 ) |
---|
603 | ENDIF |
---|
604 | |
---|
605 | END SELECT |
---|
606 | |
---|
607 | ! |
---|
608 | !-- Resort the array to be output, if not done above |
---|
609 | IF ( .NOT. resorted ) THEN |
---|
610 | DO i = nxlg, nxrg |
---|
611 | DO j = nysg, nyng |
---|
612 | DO k = nzb, nzt+1 |
---|
613 | local_pf(i,j,k) = to_be_resorted(k,j,i) |
---|
614 | ENDDO |
---|
615 | ENDDO |
---|
616 | ENDDO |
---|
617 | ENDIF |
---|
618 | |
---|
619 | ! |
---|
620 | !-- Output of the individual cross-sections, depending on the cross- |
---|
621 | !-- section mode chosen. |
---|
622 | is = 1 |
---|
623 | loop1: DO WHILE ( section(is,s) /= -9999 .OR. two_d ) |
---|
624 | |
---|
625 | SELECT CASE ( mode ) |
---|
626 | |
---|
627 | CASE ( 'xy' ) |
---|
628 | ! |
---|
629 | !-- Determine the cross section index |
---|
630 | IF ( two_d ) THEN |
---|
631 | layer_xy = nzb+1 |
---|
632 | ELSE |
---|
633 | layer_xy = section(is,s) |
---|
634 | ENDIF |
---|
635 | |
---|
636 | ! |
---|
637 | !-- Update the NetCDF xy cross section time axis |
---|
638 | IF ( myid == 0 .OR. netcdf_data_format > 2 ) THEN |
---|
639 | IF ( simulated_time /= do2d_xy_last_time(av) ) THEN |
---|
640 | do2d_xy_time_count(av) = do2d_xy_time_count(av) + 1 |
---|
641 | do2d_xy_last_time(av) = simulated_time |
---|
642 | IF ( ( .NOT. data_output_2d_on_each_pe .AND. & |
---|
643 | netcdf_output ) .OR. netcdf_data_format > 2 ) & |
---|
644 | THEN |
---|
645 | #if defined( __netcdf ) |
---|
646 | nc_stat = NF90_PUT_VAR( id_set_xy(av), & |
---|
647 | id_var_time_xy(av), & |
---|
648 | (/ time_since_reference_point /), & |
---|
649 | start = (/ do2d_xy_time_count(av) /), & |
---|
650 | count = (/ 1 /) ) |
---|
651 | CALL handle_netcdf_error( 'data_output_2d', 53 ) |
---|
652 | #endif |
---|
653 | ENDIF |
---|
654 | ENDIF |
---|
655 | ENDIF |
---|
656 | ! |
---|
657 | !-- If required, carry out averaging along z |
---|
658 | IF ( section(is,s) == -1 .AND. .NOT. two_d ) THEN |
---|
659 | |
---|
660 | local_2d = 0.0 |
---|
661 | ! |
---|
662 | !-- Carry out the averaging (all data are on the PE) |
---|
663 | DO k = nzb, nzt+1 |
---|
664 | DO j = nysg, nyng |
---|
665 | DO i = nxlg, nxrg |
---|
666 | local_2d(i,j) = local_2d(i,j) + local_pf(i,j,k) |
---|
667 | ENDDO |
---|
668 | ENDDO |
---|
669 | ENDDO |
---|
670 | |
---|
671 | local_2d = local_2d / ( nzt -nzb + 2.0) |
---|
672 | |
---|
673 | ELSE |
---|
674 | ! |
---|
675 | !-- Just store the respective section on the local array |
---|
676 | local_2d = local_pf(:,:,layer_xy) |
---|
677 | |
---|
678 | ENDIF |
---|
679 | |
---|
680 | #if defined( __parallel ) |
---|
681 | IF ( netcdf_output .AND. netcdf_data_format > 2 ) THEN |
---|
682 | ! |
---|
683 | !-- Output in NetCDF4/HDF5 format. |
---|
684 | !-- Do not output redundant ghost point data except for the |
---|
685 | !-- boundaries of the total domain. |
---|
686 | IF ( two_d ) THEN |
---|
687 | iis = 1 |
---|
688 | ELSE |
---|
689 | iis = is |
---|
690 | ENDIF |
---|
691 | |
---|
692 | #if defined( __netcdf ) |
---|
693 | IF ( nxr == nx .AND. nyn /= ny ) THEN |
---|
694 | nc_stat = NF90_PUT_VAR( id_set_xy(av), & |
---|
695 | id_var_do2d(av,if), & |
---|
696 | local_2d(nxl:nxr+1,nys:nyn), & |
---|
697 | start = (/ nxl+1, nys+1, iis, & |
---|
698 | do2d_xy_time_count(av) /), & |
---|
699 | count = (/ nxr-nxl+2, & |
---|
700 | nyn-nys+1, 1, 1 /) ) |
---|
701 | ELSEIF ( nxr /= nx .AND. nyn == ny ) THEN |
---|
702 | nc_stat = NF90_PUT_VAR( id_set_xy(av), & |
---|
703 | id_var_do2d(av,if), & |
---|
704 | local_2d(nxl:nxr,nys:nyn+1), & |
---|
705 | start = (/ nxl+1, nys+1, iis, & |
---|
706 | do2d_xy_time_count(av) /), & |
---|
707 | count = (/ nxr-nxl+1, & |
---|
708 | nyn-nys+2, 1, 1 /) ) |
---|
709 | ELSEIF ( nxr == nx .AND. nyn == ny ) THEN |
---|
710 | nc_stat = NF90_PUT_VAR( id_set_xy(av), & |
---|
711 | id_var_do2d(av,if), & |
---|
712 | local_2d(nxl:nxr+1,nys:nyn+1),& |
---|
713 | start = (/ nxl+1, nys+1, iis, & |
---|
714 | do2d_xy_time_count(av) /), & |
---|
715 | count = (/ nxr-nxl+2, & |
---|
716 | nyn-nys+2, 1, 1 /) ) |
---|
717 | ELSE |
---|
718 | nc_stat = NF90_PUT_VAR( id_set_xy(av), & |
---|
719 | id_var_do2d(av,if), & |
---|
720 | local_2d(nxl:nxr,nys:nyn), & |
---|
721 | start = (/ nxl+1, nys+1, iis, & |
---|
722 | do2d_xy_time_count(av) /), & |
---|
723 | count = (/ nxr-nxl+1, & |
---|
724 | nyn-nys+1, 1, 1 /) ) |
---|
725 | ENDIF |
---|
726 | |
---|
727 | CALL handle_netcdf_error( 'data_output_2d', 55 ) |
---|
728 | #endif |
---|
729 | ELSE |
---|
730 | |
---|
731 | IF ( data_output_2d_on_each_pe ) THEN |
---|
732 | ! |
---|
733 | !-- Output of partial arrays on each PE |
---|
734 | #if defined( __netcdf ) |
---|
735 | IF ( netcdf_output .AND. myid == 0 ) THEN |
---|
736 | WRITE ( 21 ) time_since_reference_point, & |
---|
737 | do2d_xy_time_count(av), av |
---|
738 | ENDIF |
---|
739 | #endif |
---|
740 | DO i = 0, io_blocks-1 |
---|
741 | IF ( i == io_group ) THEN |
---|
742 | WRITE ( 21 ) nxlg, nxrg, nysg, nyng |
---|
743 | WRITE ( 21 ) local_2d |
---|
744 | ENDIF |
---|
745 | #if defined( __parallel ) |
---|
746 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
747 | #endif |
---|
748 | ENDDO |
---|
749 | |
---|
750 | ELSE |
---|
751 | ! |
---|
752 | !-- PE0 receives partial arrays from all processors and |
---|
753 | !-- then outputs them. Here a barrier has to be set, |
---|
754 | !-- because otherwise "-MPI- FATAL: Remote protocol queue |
---|
755 | !-- full" may occur. |
---|
756 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
757 | |
---|
758 | ngp = ( nxrg-nxlg+1 ) * ( nyng-nysg+1 ) |
---|
759 | IF ( myid == 0 ) THEN |
---|
760 | ! |
---|
761 | !-- Local array can be relocated directly. |
---|
762 | total_2d(nxlg:nxrg,nysg:nyng) = local_2d |
---|
763 | ! |
---|
764 | !-- Receive data from all other PEs. |
---|
765 | DO n = 1, numprocs-1 |
---|
766 | ! |
---|
767 | !-- Receive index limits first, then array. |
---|
768 | !-- Index limits are received in arbitrary order from |
---|
769 | !-- the PEs. |
---|
770 | CALL MPI_RECV( ind(1), 4, MPI_INTEGER, & |
---|
771 | MPI_ANY_SOURCE, 0, comm2d, & |
---|
772 | status, ierr ) |
---|
773 | sender = status(MPI_SOURCE) |
---|
774 | DEALLOCATE( local_2d ) |
---|
775 | ALLOCATE( local_2d(ind(1):ind(2),ind(3):ind(4)) ) |
---|
776 | CALL MPI_RECV( local_2d(ind(1),ind(3)), ngp, & |
---|
777 | MPI_REAL, sender, 1, comm2d, & |
---|
778 | status, ierr ) |
---|
779 | total_2d(ind(1):ind(2),ind(3):ind(4)) = local_2d |
---|
780 | ENDDO |
---|
781 | ! |
---|
782 | !-- Output of the total cross-section. |
---|
783 | IF ( iso2d_output ) THEN |
---|
784 | WRITE (21) total_2d(-nbgp:nx+nbgp,-nbgp:ny+nbgp) |
---|
785 | ENDIF |
---|
786 | ! |
---|
787 | !-- Relocate the local array for the next loop increment |
---|
788 | DEALLOCATE( local_2d ) |
---|
789 | ALLOCATE( local_2d(nxlg:nxrg,nysg:nyng) ) |
---|
790 | |
---|
791 | #if defined( __netcdf ) |
---|
792 | IF ( netcdf_output ) THEN |
---|
793 | IF ( two_d ) THEN |
---|
794 | nc_stat = NF90_PUT_VAR( id_set_xy(av), & |
---|
795 | id_var_do2d(av,if), & |
---|
796 | total_2d(0:nx+1,0:ny+1), & |
---|
797 | start = (/ 1, 1, 1, do2d_xy_time_count(av) /), & |
---|
798 | count = (/ nx+2, ny+2, 1, 1 /) ) |
---|
799 | ELSE |
---|
800 | nc_stat = NF90_PUT_VAR( id_set_xy(av), & |
---|
801 | id_var_do2d(av,if), & |
---|
802 | total_2d(0:nx+1,0:ny+1), & |
---|
803 | start = (/ 1, 1, is, do2d_xy_time_count(av) /), & |
---|
804 | count = (/ nx+2, ny+2, 1, 1 /) ) |
---|
805 | ENDIF |
---|
806 | CALL handle_netcdf_error( 'data_output_2d', 54 ) |
---|
807 | ENDIF |
---|
808 | #endif |
---|
809 | |
---|
810 | ELSE |
---|
811 | ! |
---|
812 | !-- First send the local index limits to PE0 |
---|
813 | ind(1) = nxlg; ind(2) = nxrg |
---|
814 | ind(3) = nysg; ind(4) = nyng |
---|
815 | CALL MPI_SEND( ind(1), 4, MPI_INTEGER, 0, 0, & |
---|
816 | comm2d, ierr ) |
---|
817 | ! |
---|
818 | !-- Send data to PE0 |
---|
819 | CALL MPI_SEND( local_2d(nxlg,nysg), ngp, & |
---|
820 | MPI_REAL, 0, 1, comm2d, ierr ) |
---|
821 | ENDIF |
---|
822 | ! |
---|
823 | !-- A barrier has to be set, because otherwise some PEs may |
---|
824 | !-- proceed too fast so that PE0 may receive wrong data on |
---|
825 | !-- tag 0 |
---|
826 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
827 | ENDIF |
---|
828 | |
---|
829 | ENDIF |
---|
830 | #else |
---|
831 | IF ( iso2d_output ) THEN |
---|
832 | WRITE (21) local_2d(nxl:nxr+1,nys:nyn+1) |
---|
833 | ENDIF |
---|
834 | #if defined( __netcdf ) |
---|
835 | IF ( netcdf_output ) THEN |
---|
836 | IF ( two_d ) THEN |
---|
837 | nc_stat = NF90_PUT_VAR( id_set_xy(av), & |
---|
838 | id_var_do2d(av,if), & |
---|
839 | local_2d(nxl:nxr+1,nys:nyn+1), & |
---|
840 | start = (/ 1, 1, 1, do2d_xy_time_count(av) /), & |
---|
841 | count = (/ nx+2, ny+2, 1, 1 /) ) |
---|
842 | ELSE |
---|
843 | nc_stat = NF90_PUT_VAR( id_set_xy(av), & |
---|
844 | id_var_do2d(av,if), & |
---|
845 | local_2d(nxl:nxr+1,nys:nyn+1), & |
---|
846 | start = (/ 1, 1, is, do2d_xy_time_count(av) /), & |
---|
847 | count = (/ nx+2, ny+2, 1, 1 /) ) |
---|
848 | ENDIF |
---|
849 | CALL handle_netcdf_error( 'data_output_2d', 447 ) |
---|
850 | ENDIF |
---|
851 | #endif |
---|
852 | #endif |
---|
853 | do2d_xy_n = do2d_xy_n + 1 |
---|
854 | ! |
---|
855 | !-- Write LOCAL parameter set for ISO2D. |
---|
856 | IF ( myid == 0 .AND. iso2d_output ) THEN |
---|
857 | IF ( section(is,s) /= -1 ) THEN |
---|
858 | WRITE ( section_chr, '(''z = '',F7.2,'' m (GP '',I3, & |
---|
859 | &'')'')' & |
---|
860 | ) level_z(layer_xy), layer_xy |
---|
861 | ELSE |
---|
862 | section_chr = 'averaged along z' |
---|
863 | ENDIF |
---|
864 | IF ( av == 0 ) THEN |
---|
865 | rtext = TRIM( do2d(av,if) ) // ' t = ' // & |
---|
866 | TRIM( simulated_time_chr ) // ' ' // & |
---|
867 | TRIM( section_chr ) |
---|
868 | ELSE |
---|
869 | rtext = TRIM( do2d(av,if) ) // ' averaged t = ' // & |
---|
870 | TRIM( simulated_time_chr ) // ' ' // & |
---|
871 | TRIM( section_chr ) |
---|
872 | ENDIF |
---|
873 | WRITE (27,LOCAL) |
---|
874 | ENDIF |
---|
875 | ! |
---|
876 | !-- For 2D-arrays (e.g. u*) only one cross-section is available. |
---|
877 | !-- Hence exit loop of output levels. |
---|
878 | IF ( two_d ) THEN |
---|
879 | two_d = .FALSE. |
---|
880 | EXIT loop1 |
---|
881 | ENDIF |
---|
882 | |
---|
883 | CASE ( 'xz' ) |
---|
884 | ! |
---|
885 | !-- Update the NetCDF xz cross section time axis |
---|
886 | IF ( myid == 0 .OR. netcdf_data_format > 2 ) THEN |
---|
887 | |
---|
888 | IF ( simulated_time /= do2d_xz_last_time(av) ) THEN |
---|
889 | do2d_xz_time_count(av) = do2d_xz_time_count(av) + 1 |
---|
890 | do2d_xz_last_time(av) = simulated_time |
---|
891 | IF ( ( .NOT. data_output_2d_on_each_pe .AND. & |
---|
892 | netcdf_output ) .OR. netcdf_data_format > 2 ) & |
---|
893 | THEN |
---|
894 | #if defined( __netcdf ) |
---|
895 | nc_stat = NF90_PUT_VAR( id_set_xz(av), & |
---|
896 | id_var_time_xz(av), & |
---|
897 | (/ time_since_reference_point /), & |
---|
898 | start = (/ do2d_xz_time_count(av) /), & |
---|
899 | count = (/ 1 /) ) |
---|
900 | CALL handle_netcdf_error( 'data_output_2d', 56 ) |
---|
901 | #endif |
---|
902 | ENDIF |
---|
903 | ENDIF |
---|
904 | |
---|
905 | ENDIF |
---|
906 | |
---|
907 | ! |
---|
908 | !-- If required, carry out averaging along y |
---|
909 | IF ( section(is,s) == -1 ) THEN |
---|
910 | |
---|
911 | ALLOCATE( local_2d_l(nxlg:nxrg,nzb:nzt+1) ) |
---|
912 | local_2d_l = 0.0 |
---|
913 | ngp = ( nxrg-nxlg+1 ) * ( nzt-nzb+2 ) |
---|
914 | ! |
---|
915 | !-- First local averaging on the PE |
---|
916 | DO k = nzb, nzt+1 |
---|
917 | DO j = nys, nyn |
---|
918 | DO i = nxlg, nxrg |
---|
919 | local_2d_l(i,k) = local_2d_l(i,k) + & |
---|
920 | local_pf(i,j,k) |
---|
921 | ENDDO |
---|
922 | ENDDO |
---|
923 | ENDDO |
---|
924 | #if defined( __parallel ) |
---|
925 | ! |
---|
926 | !-- Now do the averaging over all PEs along y |
---|
927 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
928 | CALL MPI_ALLREDUCE( local_2d_l(nxlg,nzb), & |
---|
929 | local_2d(nxlg,nzb), ngp, MPI_REAL, & |
---|
930 | MPI_SUM, comm1dy, ierr ) |
---|
931 | #else |
---|
932 | local_2d = local_2d_l |
---|
933 | #endif |
---|
934 | local_2d = local_2d / ( ny + 1.0 ) |
---|
935 | |
---|
936 | DEALLOCATE( local_2d_l ) |
---|
937 | |
---|
938 | ELSE |
---|
939 | ! |
---|
940 | !-- Just store the respective section on the local array |
---|
941 | !-- (but only if it is available on this PE!) |
---|
942 | IF ( section(is,s) >= nys .AND. section(is,s) <= nyn ) & |
---|
943 | THEN |
---|
944 | local_2d = local_pf(:,section(is,s),nzb:nzt+1) |
---|
945 | ENDIF |
---|
946 | |
---|
947 | ENDIF |
---|
948 | |
---|
949 | #if defined( __parallel ) |
---|
950 | IF ( netcdf_output .AND. netcdf_data_format > 2 ) THEN |
---|
951 | ! |
---|
952 | !-- ATTENTION: The following lines are a workaround, because |
---|
953 | !-- independet output does not work with the |
---|
954 | !-- current NetCDF4 installation. Therefore, data |
---|
955 | !-- are transferred from PEs having the cross |
---|
956 | !-- sections to other PEs along y having no cross |
---|
957 | !-- section data. Some of these data are the |
---|
958 | !-- output. |
---|
959 | !-- BEGIN WORKAROUND--------------------------------------- |
---|
960 | IF ( npey /= 1 .AND. section(is,s) /= -1) THEN |
---|
961 | ALLOCATE( local_2d_l(nxlg:nxrg,nzb:nzt+1) ) |
---|
962 | local_2d_l = 0.0 |
---|
963 | IF ( section(is,s) >= nys .AND. section(is,s) <= nyn )& |
---|
964 | THEN |
---|
965 | local_2d_l = local_2d |
---|
966 | ENDIF |
---|
967 | #if defined( __parallel ) |
---|
968 | ! |
---|
969 | !-- Distribute data over all PEs along y |
---|
970 | ngp = ( nxrg-nxlg+1 ) * ( nzt-nzb+2 ) |
---|
971 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
972 | CALL MPI_ALLREDUCE( local_2d_l(nxlg,nzb), & |
---|
973 | local_2d(nxlg,nzb), ngp, & |
---|
974 | MPI_REAL, MPI_SUM, comm1dy, ierr ) |
---|
975 | #else |
---|
976 | local_2d = local_2d_l |
---|
977 | #endif |
---|
978 | DEALLOCATE( local_2d_l ) |
---|
979 | ENDIF |
---|
980 | !-- END WORKAROUND----------------------------------------- |
---|
981 | |
---|
982 | ! |
---|
983 | !-- Output in NetCDF4/HDF5 format. |
---|
984 | !-- Output only on those PEs where the respective cross |
---|
985 | !-- sections reside. Cross sections averaged along y are |
---|
986 | !-- output on the respective first PE along y (myidy=0). |
---|
987 | IF ( ( section(is,s) >= nys .AND. & |
---|
988 | section(is,s) <= nyn ) .OR. & |
---|
989 | ( section(is,s) == -1 .AND. myidy == 0 ) ) THEN |
---|
990 | ! |
---|
991 | !-- Do not output redundant ghost point data except for the |
---|
992 | !-- boundaries of the total domain. |
---|
993 | #if defined( __netcdf ) |
---|
994 | IF ( nxr == nx ) THEN |
---|
995 | nc_stat = NF90_PUT_VAR( id_set_xz(av), & |
---|
996 | id_var_do2d(av,if), & |
---|
997 | local_2d(nxl:nxr+1,nzb:nzt+1), & |
---|
998 | start = (/ nxl+1, is, 1, & |
---|
999 | do2d_xz_time_count(av) /), & |
---|
1000 | count = (/ nxr-nxl+2, 1, & |
---|
1001 | nzt+2, 1 /) ) |
---|
1002 | ELSE |
---|
1003 | nc_stat = NF90_PUT_VAR( id_set_xz(av), & |
---|
1004 | id_var_do2d(av,if), & |
---|
1005 | local_2d(nxl:nxr,nzb:nzt+1), & |
---|
1006 | start = (/ nxl+1, is, 1, & |
---|
1007 | do2d_xz_time_count(av) /), & |
---|
1008 | count = (/ nxr-nxl+1, 1, & |
---|
1009 | nzt+2, 1 /) ) |
---|
1010 | ENDIF |
---|
1011 | |
---|
1012 | CALL handle_netcdf_error( 'data_output_2d', 57 ) |
---|
1013 | |
---|
1014 | ELSE |
---|
1015 | ! |
---|
1016 | !-- Output on other PEs. Only one point is output!! |
---|
1017 | !-- ATTENTION: This is a workaround (see above)!! |
---|
1018 | IF ( npey /= 1 ) THEN |
---|
1019 | nc_stat = NF90_PUT_VAR( id_set_xz(av), & |
---|
1020 | id_var_do2d(av,if), & |
---|
1021 | local_2d(nxl:nxl,nzb:nzb), & |
---|
1022 | start = (/ nxl+1, is, 1, & |
---|
1023 | do2d_xz_time_count(av) /), & |
---|
1024 | count = (/ 1, 1, 1, 1 /) ) |
---|
1025 | CALL handle_netcdf_error( 'data_output_2d', 451 ) |
---|
1026 | ENDIF |
---|
1027 | #endif |
---|
1028 | ENDIF |
---|
1029 | |
---|
1030 | ELSE |
---|
1031 | |
---|
1032 | IF ( data_output_2d_on_each_pe ) THEN |
---|
1033 | ! |
---|
1034 | !-- Output of partial arrays on each PE. If the cross |
---|
1035 | !-- section does not reside on the PE, output special |
---|
1036 | !-- index values. |
---|
1037 | #if defined( __netcdf ) |
---|
1038 | IF ( netcdf_output .AND. myid == 0 ) THEN |
---|
1039 | WRITE ( 22 ) time_since_reference_point, & |
---|
1040 | do2d_xz_time_count(av), av |
---|
1041 | ENDIF |
---|
1042 | #endif |
---|
1043 | DO i = 0, io_blocks-1 |
---|
1044 | IF ( i == io_group ) THEN |
---|
1045 | IF ( ( section(is,s) >= nys .AND. & |
---|
1046 | section(is,s) <= nyn ) .OR. & |
---|
1047 | ( section(is,s) == -1 .AND. & |
---|
1048 | nys-1 == -1 ) ) & |
---|
1049 | THEN |
---|
1050 | WRITE (22) nxlg, nxrg, nzb, nzt+1 |
---|
1051 | WRITE (22) local_2d |
---|
1052 | ELSE |
---|
1053 | WRITE (22) -1, -1, -1, -1 |
---|
1054 | ENDIF |
---|
1055 | ENDIF |
---|
1056 | #if defined( __parallel ) |
---|
1057 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
1058 | #endif |
---|
1059 | ENDDO |
---|
1060 | |
---|
1061 | ELSE |
---|
1062 | ! |
---|
1063 | !-- PE0 receives partial arrays from all processors of the |
---|
1064 | !-- respective cross section and outputs them. Here a |
---|
1065 | !-- barrier has to be set, because otherwise |
---|
1066 | !-- "-MPI- FATAL: Remote protocol queue full" may occur. |
---|
1067 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
1068 | |
---|
1069 | ngp = ( nxrg-nxlg+1 ) * ( nzt-nzb+2 ) |
---|
1070 | IF ( myid == 0 ) THEN |
---|
1071 | ! |
---|
1072 | !-- Local array can be relocated directly. |
---|
1073 | IF ( ( section(is,s) >= nys .AND. & |
---|
1074 | section(is,s) <= nyn ) .OR. & |
---|
1075 | ( section(is,s) == -1 .AND. nys-1 == -1 ) ) & |
---|
1076 | THEN |
---|
1077 | total_2d(nxlg:nxrg,nzb:nzt+1) = local_2d |
---|
1078 | ENDIF |
---|
1079 | ! |
---|
1080 | !-- Receive data from all other PEs. |
---|
1081 | DO n = 1, numprocs-1 |
---|
1082 | ! |
---|
1083 | !-- Receive index limits first, then array. |
---|
1084 | !-- Index limits are received in arbitrary order from |
---|
1085 | !-- the PEs. |
---|
1086 | CALL MPI_RECV( ind(1), 4, MPI_INTEGER, & |
---|
1087 | MPI_ANY_SOURCE, 0, comm2d, & |
---|
1088 | status, ierr ) |
---|
1089 | ! |
---|
1090 | !-- Not all PEs have data for XZ-cross-section. |
---|
1091 | IF ( ind(1) /= -9999 ) THEN |
---|
1092 | sender = status(MPI_SOURCE) |
---|
1093 | DEALLOCATE( local_2d ) |
---|
1094 | ALLOCATE( local_2d(ind(1):ind(2), & |
---|
1095 | ind(3):ind(4)) ) |
---|
1096 | CALL MPI_RECV( local_2d(ind(1),ind(3)), ngp, & |
---|
1097 | MPI_REAL, sender, 1, comm2d, & |
---|
1098 | status, ierr ) |
---|
1099 | total_2d(ind(1):ind(2),ind(3):ind(4)) = & |
---|
1100 | local_2d |
---|
1101 | ENDIF |
---|
1102 | ENDDO |
---|
1103 | ! |
---|
1104 | !-- Output of the total cross-section. |
---|
1105 | IF ( iso2d_output ) THEN |
---|
1106 | WRITE (22) total_2d(-nbgp:nx+nbgp,nzb:nzt+1) |
---|
1107 | ENDIF |
---|
1108 | ! |
---|
1109 | !-- Relocate the local array for the next loop increment |
---|
1110 | DEALLOCATE( local_2d ) |
---|
1111 | ALLOCATE( local_2d(nxlg:nxrg,nzb:nzt+1) ) |
---|
1112 | |
---|
1113 | #if defined( __netcdf ) |
---|
1114 | IF ( netcdf_output ) THEN |
---|
1115 | nc_stat = NF90_PUT_VAR( id_set_xz(av), & |
---|
1116 | id_var_do2d(av,if), & |
---|
1117 | total_2d(0:nx+1,nzb:nzt+1),& |
---|
1118 | start = (/ 1, is, 1, do2d_xz_time_count(av) /), & |
---|
1119 | count = (/ nx+2, 1, nz+2, 1 /) ) |
---|
1120 | CALL handle_netcdf_error( 'data_output_2d', 58 ) |
---|
1121 | ENDIF |
---|
1122 | #endif |
---|
1123 | |
---|
1124 | ELSE |
---|
1125 | ! |
---|
1126 | !-- If the cross section resides on the PE, send the |
---|
1127 | !-- local index limits, otherwise send -9999 to PE0. |
---|
1128 | IF ( ( section(is,s) >= nys .AND. & |
---|
1129 | section(is,s) <= nyn ) .OR. & |
---|
1130 | ( section(is,s) == -1 .AND. nys-1 == -1 ) ) & |
---|
1131 | THEN |
---|
1132 | ind(1) = nxlg; ind(2) = nxrg |
---|
1133 | ind(3) = nzb; ind(4) = nzt+1 |
---|
1134 | ELSE |
---|
1135 | ind(1) = -9999; ind(2) = -9999 |
---|
1136 | ind(3) = -9999; ind(4) = -9999 |
---|
1137 | ENDIF |
---|
1138 | CALL MPI_SEND( ind(1), 4, MPI_INTEGER, 0, 0, & |
---|
1139 | comm2d, ierr ) |
---|
1140 | ! |
---|
1141 | !-- If applicable, send data to PE0. |
---|
1142 | IF ( ind(1) /= -9999 ) THEN |
---|
1143 | CALL MPI_SEND( local_2d(nxlg,nzb), ngp, & |
---|
1144 | MPI_REAL, 0, 1, comm2d, ierr ) |
---|
1145 | ENDIF |
---|
1146 | ENDIF |
---|
1147 | ! |
---|
1148 | !-- A barrier has to be set, because otherwise some PEs may |
---|
1149 | !-- proceed too fast so that PE0 may receive wrong data on |
---|
1150 | !-- tag 0 |
---|
1151 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
1152 | ENDIF |
---|
1153 | |
---|
1154 | ENDIF |
---|
1155 | #else |
---|
1156 | IF ( iso2d_output ) THEN |
---|
1157 | WRITE (22) local_2d(nxl:nxr+1,nzb:nzt+1) |
---|
1158 | ENDIF |
---|
1159 | #if defined( __netcdf ) |
---|
1160 | IF ( netcdf_output ) THEN |
---|
1161 | nc_stat = NF90_PUT_VAR( id_set_xz(av), & |
---|
1162 | id_var_do2d(av,if), & |
---|
1163 | local_2d(nxl:nxr+1,nzb:nzt+1), & |
---|
1164 | start = (/ 1, is, 1, do2d_xz_time_count(av) /), & |
---|
1165 | count = (/ nx+2, 1, nz+2, 1 /) ) |
---|
1166 | CALL handle_netcdf_error( 'data_output_2d', 451 ) |
---|
1167 | ENDIF |
---|
1168 | #endif |
---|
1169 | #endif |
---|
1170 | do2d_xz_n = do2d_xz_n + 1 |
---|
1171 | ! |
---|
1172 | !-- Write LOCAL-parameter set for ISO2D. |
---|
1173 | IF ( myid == 0 .AND. iso2d_output ) THEN |
---|
1174 | IF ( section(is,s) /= -1 ) THEN |
---|
1175 | WRITE ( section_chr, '(''y = '',F8.2,'' m (GP '',I3, & |
---|
1176 | &'')'')' & |
---|
1177 | ) section(is,s)*dy, section(is,s) |
---|
1178 | ELSE |
---|
1179 | section_chr = 'averaged along y' |
---|
1180 | ENDIF |
---|
1181 | IF ( av == 0 ) THEN |
---|
1182 | rtext = TRIM( do2d(av,if) ) // ' t = ' // & |
---|
1183 | TRIM( simulated_time_chr ) // ' ' // & |
---|
1184 | TRIM( section_chr ) |
---|
1185 | ELSE |
---|
1186 | rtext = TRIM( do2d(av,if) ) // ' averaged t = ' // & |
---|
1187 | TRIM( simulated_time_chr ) // ' ' // & |
---|
1188 | TRIM( section_chr ) |
---|
1189 | ENDIF |
---|
1190 | WRITE (28,LOCAL) |
---|
1191 | ENDIF |
---|
1192 | |
---|
1193 | CASE ( 'yz' ) |
---|
1194 | ! |
---|
1195 | !-- Update the NetCDF yz cross section time axis |
---|
1196 | IF ( myid == 0 .OR. netcdf_data_format > 2 ) THEN |
---|
1197 | |
---|
1198 | IF ( simulated_time /= do2d_yz_last_time(av) ) THEN |
---|
1199 | do2d_yz_time_count(av) = do2d_yz_time_count(av) + 1 |
---|
1200 | do2d_yz_last_time(av) = simulated_time |
---|
1201 | IF ( ( .NOT. data_output_2d_on_each_pe .AND. & |
---|
1202 | netcdf_output ) .OR. netcdf_data_format > 2 ) & |
---|
1203 | THEN |
---|
1204 | #if defined( __netcdf ) |
---|
1205 | nc_stat = NF90_PUT_VAR( id_set_yz(av), & |
---|
1206 | id_var_time_yz(av), & |
---|
1207 | (/ time_since_reference_point /), & |
---|
1208 | start = (/ do2d_yz_time_count(av) /), & |
---|
1209 | count = (/ 1 /) ) |
---|
1210 | CALL handle_netcdf_error( 'data_output_2d', 59 ) |
---|
1211 | #endif |
---|
1212 | ENDIF |
---|
1213 | ENDIF |
---|
1214 | |
---|
1215 | ENDIF |
---|
1216 | ! |
---|
1217 | !-- If required, carry out averaging along x |
---|
1218 | IF ( section(is,s) == -1 ) THEN |
---|
1219 | |
---|
1220 | ALLOCATE( local_2d_l(nysg:nyng,nzb:nzt+1) ) |
---|
1221 | local_2d_l = 0.0 |
---|
1222 | ngp = ( nyng-nysg+1 ) * ( nzt-nzb+2 ) |
---|
1223 | ! |
---|
1224 | !-- First local averaging on the PE |
---|
1225 | DO k = nzb, nzt+1 |
---|
1226 | DO j = nysg, nyng |
---|
1227 | DO i = nxl, nxr |
---|
1228 | local_2d_l(j,k) = local_2d_l(j,k) + & |
---|
1229 | local_pf(i,j,k) |
---|
1230 | ENDDO |
---|
1231 | ENDDO |
---|
1232 | ENDDO |
---|
1233 | #if defined( __parallel ) |
---|
1234 | ! |
---|
1235 | !-- Now do the averaging over all PEs along x |
---|
1236 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1237 | CALL MPI_ALLREDUCE( local_2d_l(nysg,nzb), & |
---|
1238 | local_2d(nysg,nzb), ngp, MPI_REAL, & |
---|
1239 | MPI_SUM, comm1dx, ierr ) |
---|
1240 | #else |
---|
1241 | local_2d = local_2d_l |
---|
1242 | #endif |
---|
1243 | local_2d = local_2d / ( nx + 1.0 ) |
---|
1244 | |
---|
1245 | DEALLOCATE( local_2d_l ) |
---|
1246 | |
---|
1247 | ELSE |
---|
1248 | ! |
---|
1249 | !-- Just store the respective section on the local array |
---|
1250 | !-- (but only if it is available on this PE!) |
---|
1251 | IF ( section(is,s) >= nxl .AND. section(is,s) <= nxr ) & |
---|
1252 | THEN |
---|
1253 | local_2d = local_pf(section(is,s),:,nzb:nzt+1) |
---|
1254 | ENDIF |
---|
1255 | |
---|
1256 | ENDIF |
---|
1257 | |
---|
1258 | #if defined( __parallel ) |
---|
1259 | IF ( netcdf_output .AND. netcdf_data_format > 2 ) THEN |
---|
1260 | ! |
---|
1261 | !-- ATTENTION: The following lines are a workaround, because |
---|
1262 | !-- independet output does not work with the |
---|
1263 | !-- current NetCDF4 installation. Therefore, data |
---|
1264 | !-- are transferred from PEs having the cross |
---|
1265 | !-- sections to other PEs along y having no cross |
---|
1266 | !-- section data. Some of these data are the |
---|
1267 | !-- output. |
---|
1268 | !-- BEGIN WORKAROUND--------------------------------------- |
---|
1269 | IF ( npex /= 1 .AND. section(is,s) /= -1) THEN |
---|
1270 | ALLOCATE( local_2d_l(nysg:nyng,nzb:nzt+1) ) |
---|
1271 | local_2d_l = 0.0 |
---|
1272 | IF ( section(is,s) >= nxl .AND. section(is,s) <= nxr )& |
---|
1273 | THEN |
---|
1274 | local_2d_l = local_2d |
---|
1275 | ENDIF |
---|
1276 | #if defined( __parallel ) |
---|
1277 | ! |
---|
1278 | !-- Distribute data over all PEs along x |
---|
1279 | ngp = ( nyng-nysg+1 ) * ( nzt-nzb + 2 ) |
---|
1280 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1281 | CALL MPI_ALLREDUCE( local_2d_l(nysg,nzb), & |
---|
1282 | local_2d(nysg,nzb), ngp, & |
---|
1283 | MPI_REAL, MPI_SUM, comm1dx, ierr ) |
---|
1284 | #else |
---|
1285 | local_2d = local_2d_l |
---|
1286 | #endif |
---|
1287 | DEALLOCATE( local_2d_l ) |
---|
1288 | ENDIF |
---|
1289 | !-- END WORKAROUND----------------------------------------- |
---|
1290 | |
---|
1291 | ! |
---|
1292 | !-- Output in NetCDF4/HDF5 format. |
---|
1293 | !-- Output only on those PEs where the respective cross |
---|
1294 | !-- sections reside. Cross sections averaged along x are |
---|
1295 | !-- output on the respective first PE along x (myidx=0). |
---|
1296 | IF ( ( section(is,s) >= nxl .AND. & |
---|
1297 | section(is,s) <= nxr ) .OR. & |
---|
1298 | ( section(is,s) == -1 .AND. myidx == 0 ) ) THEN |
---|
1299 | ! |
---|
1300 | !-- Do not output redundant ghost point data except for the |
---|
1301 | !-- boundaries of the total domain. |
---|
1302 | #if defined( __netcdf ) |
---|
1303 | IF ( nyn == ny ) THEN |
---|
1304 | nc_stat = NF90_PUT_VAR( id_set_yz(av), & |
---|
1305 | id_var_do2d(av,if), & |
---|
1306 | local_2d(nys:nyn+1,nzb:nzt+1), & |
---|
1307 | start = (/ is, nys+1, 1, & |
---|
1308 | do2d_yz_time_count(av) /), & |
---|
1309 | count = (/ 1, nyn-nys+2, & |
---|
1310 | nzt+2, 1 /) ) |
---|
1311 | ELSE |
---|
1312 | nc_stat = NF90_PUT_VAR( id_set_yz(av), & |
---|
1313 | id_var_do2d(av,if), & |
---|
1314 | local_2d(nys:nyn,nzb:nzt+1), & |
---|
1315 | start = (/ is, nys+1, 1, & |
---|
1316 | do2d_yz_time_count(av) /), & |
---|
1317 | count = (/ 1, nyn-nys+1, & |
---|
1318 | nzt+2, 1 /) ) |
---|
1319 | ENDIF |
---|
1320 | |
---|
1321 | CALL handle_netcdf_error( 'data_output_2d', 60 ) |
---|
1322 | |
---|
1323 | ELSE |
---|
1324 | ! |
---|
1325 | !-- Output on other PEs. Only one point is output!! |
---|
1326 | !-- ATTENTION: This is a workaround (see above)!! |
---|
1327 | IF ( npex /= 1 ) THEN |
---|
1328 | nc_stat = NF90_PUT_VAR( id_set_yz(av), & |
---|
1329 | id_var_do2d(av,if), & |
---|
1330 | local_2d(nys:nys,nzb:nzb), & |
---|
1331 | start = (/ is, nys+1, 1, & |
---|
1332 | do2d_yz_time_count(av) /), & |
---|
1333 | count = (/ 1, 1, 1, 1 /) ) |
---|
1334 | CALL handle_netcdf_error( 'data_output_2d', 452 ) |
---|
1335 | ENDIF |
---|
1336 | #endif |
---|
1337 | ENDIF |
---|
1338 | |
---|
1339 | ELSE |
---|
1340 | |
---|
1341 | IF ( data_output_2d_on_each_pe ) THEN |
---|
1342 | ! |
---|
1343 | !-- Output of partial arrays on each PE. If the cross |
---|
1344 | !-- section does not reside on the PE, output special |
---|
1345 | !-- index values. |
---|
1346 | #if defined( __netcdf ) |
---|
1347 | IF ( netcdf_output .AND. myid == 0 ) THEN |
---|
1348 | WRITE ( 23 ) time_since_reference_point, & |
---|
1349 | do2d_yz_time_count(av), av |
---|
1350 | ENDIF |
---|
1351 | #endif |
---|
1352 | DO i = 0, io_blocks-1 |
---|
1353 | IF ( i == io_group ) THEN |
---|
1354 | IF ( ( section(is,s) >= nxl .AND. & |
---|
1355 | section(is,s) <= nxr ) .OR. & |
---|
1356 | ( section(is,s) == -1 .AND. & |
---|
1357 | nxl-1 == -1 ) ) & |
---|
1358 | THEN |
---|
1359 | WRITE (23) nysg, nyng, nzb, nzt+1 |
---|
1360 | WRITE (23) local_2d |
---|
1361 | ELSE |
---|
1362 | WRITE (23) -1, -1, -1, -1 |
---|
1363 | ENDIF |
---|
1364 | ENDIF |
---|
1365 | #if defined( __parallel ) |
---|
1366 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
1367 | #endif |
---|
1368 | ENDDO |
---|
1369 | |
---|
1370 | ELSE |
---|
1371 | ! |
---|
1372 | !-- PE0 receives partial arrays from all processors of the |
---|
1373 | !-- respective cross section and outputs them. Here a |
---|
1374 | !-- barrier has to be set, because otherwise |
---|
1375 | !-- "-MPI- FATAL: Remote protocol queue full" may occur. |
---|
1376 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
1377 | |
---|
1378 | ngp = ( nyng-nysg+1 ) * ( nzt-nzb+2 ) |
---|
1379 | IF ( myid == 0 ) THEN |
---|
1380 | ! |
---|
1381 | !-- Local array can be relocated directly. |
---|
1382 | IF ( ( section(is,s) >= nxl .AND. & |
---|
1383 | section(is,s) <= nxr ) .OR. & |
---|
1384 | ( section(is,s) == -1 .AND. nxl-1 == -1 ) ) & |
---|
1385 | THEN |
---|
1386 | total_2d(nysg:nyng,nzb:nzt+1) = local_2d |
---|
1387 | ENDIF |
---|
1388 | ! |
---|
1389 | !-- Receive data from all other PEs. |
---|
1390 | DO n = 1, numprocs-1 |
---|
1391 | ! |
---|
1392 | !-- Receive index limits first, then array. |
---|
1393 | !-- Index limits are received in arbitrary order from |
---|
1394 | !-- the PEs. |
---|
1395 | CALL MPI_RECV( ind(1), 4, MPI_INTEGER, & |
---|
1396 | MPI_ANY_SOURCE, 0, comm2d, & |
---|
1397 | status, ierr ) |
---|
1398 | ! |
---|
1399 | !-- Not all PEs have data for YZ-cross-section. |
---|
1400 | IF ( ind(1) /= -9999 ) THEN |
---|
1401 | sender = status(MPI_SOURCE) |
---|
1402 | DEALLOCATE( local_2d ) |
---|
1403 | ALLOCATE( local_2d(ind(1):ind(2), & |
---|
1404 | ind(3):ind(4)) ) |
---|
1405 | CALL MPI_RECV( local_2d(ind(1),ind(3)), ngp, & |
---|
1406 | MPI_REAL, sender, 1, comm2d, & |
---|
1407 | status, ierr ) |
---|
1408 | total_2d(ind(1):ind(2),ind(3):ind(4)) = & |
---|
1409 | local_2d |
---|
1410 | ENDIF |
---|
1411 | ENDDO |
---|
1412 | ! |
---|
1413 | !-- Output of the total cross-section. |
---|
1414 | IF ( iso2d_output ) THEN |
---|
1415 | WRITE (23) total_2d(0:ny+1,nzb:nzt+1) |
---|
1416 | ENDIF |
---|
1417 | ! |
---|
1418 | !-- Relocate the local array for the next loop increment |
---|
1419 | DEALLOCATE( local_2d ) |
---|
1420 | ALLOCATE( local_2d(nysg:nyng,nzb:nzt+1) ) |
---|
1421 | |
---|
1422 | #if defined( __netcdf ) |
---|
1423 | IF ( netcdf_output ) THEN |
---|
1424 | nc_stat = NF90_PUT_VAR( id_set_yz(av), & |
---|
1425 | id_var_do2d(av,if), & |
---|
1426 | total_2d(0:ny+1,nzb:nzt+1),& |
---|
1427 | start = (/ is, 1, 1, do2d_yz_time_count(av) /), & |
---|
1428 | count = (/ 1, ny+2, nz+2, 1 /) ) |
---|
1429 | CALL handle_netcdf_error( 'data_output_2d', 61 ) |
---|
1430 | ENDIF |
---|
1431 | #endif |
---|
1432 | |
---|
1433 | ELSE |
---|
1434 | ! |
---|
1435 | !-- If the cross section resides on the PE, send the |
---|
1436 | !-- local index limits, otherwise send -9999 to PE0. |
---|
1437 | IF ( ( section(is,s) >= nxl .AND. & |
---|
1438 | section(is,s) <= nxr ) .OR. & |
---|
1439 | ( section(is,s) == -1 .AND. nxl-1 == -1 ) ) & |
---|
1440 | THEN |
---|
1441 | ind(1) = nysg; ind(2) = nyng |
---|
1442 | ind(3) = nzb; ind(4) = nzt+1 |
---|
1443 | ELSE |
---|
1444 | ind(1) = -9999; ind(2) = -9999 |
---|
1445 | ind(3) = -9999; ind(4) = -9999 |
---|
1446 | ENDIF |
---|
1447 | CALL MPI_SEND( ind(1), 4, MPI_INTEGER, 0, 0, & |
---|
1448 | comm2d, ierr ) |
---|
1449 | ! |
---|
1450 | !-- If applicable, send data to PE0. |
---|
1451 | IF ( ind(1) /= -9999 ) THEN |
---|
1452 | CALL MPI_SEND( local_2d(nysg,nzb), ngp, & |
---|
1453 | MPI_REAL, 0, 1, comm2d, ierr ) |
---|
1454 | ENDIF |
---|
1455 | ENDIF |
---|
1456 | ! |
---|
1457 | !-- A barrier has to be set, because otherwise some PEs may |
---|
1458 | !-- proceed too fast so that PE0 may receive wrong data on |
---|
1459 | !-- tag 0 |
---|
1460 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
1461 | ENDIF |
---|
1462 | |
---|
1463 | ENDIF |
---|
1464 | #else |
---|
1465 | IF ( iso2d_output ) THEN |
---|
1466 | WRITE (23) local_2d(nys:nyn+1,nzb:nzt+1) |
---|
1467 | ENDIF |
---|
1468 | #if defined( __netcdf ) |
---|
1469 | IF ( netcdf_output ) THEN |
---|
1470 | nc_stat = NF90_PUT_VAR( id_set_yz(av), & |
---|
1471 | id_var_do2d(av,if), & |
---|
1472 | local_2d(nys:nyn+1,nzb:nzt+1), & |
---|
1473 | start = (/ is, 1, 1, do2d_xz_time_count(av) /), & |
---|
1474 | count = (/ 1, ny+2, nz+2, 1 /) ) |
---|
1475 | CALL handle_netcdf_error( 'data_output_2d', 452 ) |
---|
1476 | ENDIF |
---|
1477 | #endif |
---|
1478 | #endif |
---|
1479 | do2d_yz_n = do2d_yz_n + 1 |
---|
1480 | ! |
---|
1481 | !-- Write LOCAL-parameter set for ISO2D. |
---|
1482 | IF ( myid == 0 .AND. iso2d_output ) THEN |
---|
1483 | IF ( section(is,s) /= -1 ) THEN |
---|
1484 | WRITE ( section_chr, '(''x = '',F8.2,'' m (GP '',I3, & |
---|
1485 | &'')'')' & |
---|
1486 | ) section(is,s)*dx, section(is,s) |
---|
1487 | ELSE |
---|
1488 | section_chr = 'averaged along x' |
---|
1489 | ENDIF |
---|
1490 | IF ( av == 0 ) THEN |
---|
1491 | rtext = TRIM( do2d(av,if) ) // ' t = ' // & |
---|
1492 | TRIM( simulated_time_chr ) // ' ' // & |
---|
1493 | TRIM( section_chr ) |
---|
1494 | ELSE |
---|
1495 | rtext = TRIM( do2d(av,if) ) // ' averaged t = ' // & |
---|
1496 | TRIM( simulated_time_chr ) // ' ' // & |
---|
1497 | TRIM( section_chr ) |
---|
1498 | ENDIF |
---|
1499 | WRITE (29,LOCAL) |
---|
1500 | ENDIF |
---|
1501 | |
---|
1502 | END SELECT |
---|
1503 | |
---|
1504 | is = is + 1 |
---|
1505 | ENDDO loop1 |
---|
1506 | |
---|
1507 | ENDIF |
---|
1508 | |
---|
1509 | if = if + 1 |
---|
1510 | l = MAX( 2, LEN_TRIM( do2d(av,if) ) ) |
---|
1511 | do2d_mode = do2d(av,if)(l-1:l) |
---|
1512 | |
---|
1513 | ENDDO |
---|
1514 | |
---|
1515 | ! |
---|
1516 | !-- Deallocate temporary arrays. |
---|
1517 | IF ( ALLOCATED( level_z ) ) DEALLOCATE( level_z ) |
---|
1518 | DEALLOCATE( local_pf, local_2d ) |
---|
1519 | #if defined( __parallel ) |
---|
1520 | IF ( .NOT. data_output_2d_on_each_pe .AND. myid == 0 ) THEN |
---|
1521 | DEALLOCATE( total_2d ) |
---|
1522 | ENDIF |
---|
1523 | #endif |
---|
1524 | |
---|
1525 | ! |
---|
1526 | !-- Close plot output file. |
---|
1527 | file_id = 20 + s |
---|
1528 | |
---|
1529 | IF ( data_output_2d_on_each_pe ) THEN |
---|
1530 | DO i = 0, io_blocks-1 |
---|
1531 | IF ( i == io_group ) THEN |
---|
1532 | CALL close_file( file_id ) |
---|
1533 | ENDIF |
---|
1534 | #if defined( __parallel ) |
---|
1535 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
1536 | #endif |
---|
1537 | ENDDO |
---|
1538 | ELSE |
---|
1539 | IF ( myid == 0 ) CALL close_file( file_id ) |
---|
1540 | ENDIF |
---|
1541 | |
---|
1542 | |
---|
1543 | CALL cpu_log (log_point(3),'data_output_2d','stop','nobarrier') |
---|
1544 | |
---|
1545 | END SUBROUTINE data_output_2d |
---|