1 | SUBROUTINE data_output_3d( av ) |
---|
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-2012 Leibniz University Hannover |
---|
18 | !--------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ------------------ |
---|
22 | ! array_kind renamed precision_kind |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: data_output_3d.f90 1106 2013-03-04 05:31:38Z raasch $ |
---|
27 | ! |
---|
28 | ! 1076 2012-12-05 08:30:18Z hoffmann |
---|
29 | ! Bugfix in output of ql |
---|
30 | ! |
---|
31 | ! 1053 2012-11-13 17:11:03Z hoffmann |
---|
32 | ! +nr, qr, prr, qc and averaged quantities |
---|
33 | ! |
---|
34 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
35 | ! code put under GPL (PALM 3.9) |
---|
36 | ! |
---|
37 | ! 1031 2012-10-19 14:35:30Z raasch |
---|
38 | ! netCDF4 without parallel file support implemented |
---|
39 | ! |
---|
40 | ! 1007 2012-09-19 14:30:36Z franke |
---|
41 | ! Bugfix: missing calculation of ql_vp added |
---|
42 | ! |
---|
43 | ! 790 2011-11-29 03:11:20Z raasch |
---|
44 | ! bugfix: calculation of 'pr' must depend on the particle weighting factor, |
---|
45 | ! nzt+1 replaced by nz_do3d for 'pr' |
---|
46 | ! |
---|
47 | ! 771 2011-10-27 10:56:21Z heinze |
---|
48 | ! +lpt |
---|
49 | ! |
---|
50 | ! 759 2011-09-15 13:58:31Z raasch |
---|
51 | ! Splitting of parallel I/O |
---|
52 | ! |
---|
53 | ! 727 2011-04-20 20:05:25Z suehring |
---|
54 | ! Exchange ghost layers also for p_av. |
---|
55 | ! |
---|
56 | ! 725 2011-04-11 09:37:01Z suehring |
---|
57 | ! Exchange ghost layers for p regardless of used pressure solver (except SOR). |
---|
58 | ! |
---|
59 | ! 691 2011-03-04 08:45:30Z maronga |
---|
60 | ! Replaced simulated_time by time_since_reference_point |
---|
61 | ! |
---|
62 | ! 673 2011-01-18 16:19:48Z suehring |
---|
63 | ! When using Multigrid or SOR solver an additional CALL exchange_horiz is |
---|
64 | ! is needed for pressure output. |
---|
65 | ! |
---|
66 | ! 667 2010-12-23 12:06:00Z suehring/gryschka |
---|
67 | ! nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng in loops and |
---|
68 | ! allocation of arrays. Calls of exchange_horiz are modified. |
---|
69 | ! Skip-value skip_do_avs changed to a dynamic adaption of ghost points. |
---|
70 | ! |
---|
71 | ! 646 2010-12-15 13:03:52Z raasch |
---|
72 | ! bugfix: missing define statements for netcdf added |
---|
73 | ! |
---|
74 | ! 493 2010-03-01 08:30:24Z raasch |
---|
75 | ! netCDF4 support (parallel output) |
---|
76 | ! |
---|
77 | ! 355 2009-07-17 01:03:01Z letzel |
---|
78 | ! simulated_time in netCDF output replaced by time_since_reference_point. |
---|
79 | ! Output of netCDF messages with aid of message handling routine. |
---|
80 | ! Output of messages replaced by message handling routine. |
---|
81 | ! Bugfix: to_be_resorted => s_av for time-averaged scalars |
---|
82 | ! |
---|
83 | ! 96 2007-06-04 08:07:41Z raasch |
---|
84 | ! Output of density and salinity |
---|
85 | ! |
---|
86 | ! 75 2007-03-22 09:54:05Z raasch |
---|
87 | ! 2nd+3rd argument removed from exchange horiz |
---|
88 | ! |
---|
89 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
90 | ! |
---|
91 | ! Revision 1.3 2006/06/02 15:18:59 raasch |
---|
92 | ! +argument "found", -argument grid in call of routine user_data_output_3d |
---|
93 | ! |
---|
94 | ! Revision 1.2 2006/02/23 10:23:07 raasch |
---|
95 | ! Former subroutine plot_3d renamed data_output_3d, pl.. renamed do.., |
---|
96 | ! .._anz renamed .._n, |
---|
97 | ! output extended to (almost) all quantities, output of user-defined quantities |
---|
98 | ! |
---|
99 | ! Revision 1.1 1997/09/03 06:29:36 raasch |
---|
100 | ! Initial revision |
---|
101 | ! |
---|
102 | ! |
---|
103 | ! Description: |
---|
104 | ! ------------ |
---|
105 | ! Output of the 3D-arrays in netCDF and/or AVS format. |
---|
106 | !------------------------------------------------------------------------------! |
---|
107 | |
---|
108 | USE arrays_3d |
---|
109 | USE averaging |
---|
110 | USE cloud_parameters |
---|
111 | USE control_parameters |
---|
112 | USE cpulog |
---|
113 | USE indices |
---|
114 | USE interfaces |
---|
115 | USE netcdf_control |
---|
116 | USE particle_attributes |
---|
117 | USE pegrid |
---|
118 | USE precision_kind |
---|
119 | |
---|
120 | IMPLICIT NONE |
---|
121 | |
---|
122 | CHARACTER (LEN=9) :: simulated_time_mod |
---|
123 | |
---|
124 | INTEGER :: av, i, if, j, k, n, pos, prec, psi |
---|
125 | |
---|
126 | LOGICAL :: found, resorted |
---|
127 | |
---|
128 | REAL :: mean_r, s_r3, s_r4 |
---|
129 | |
---|
130 | REAL(spk), DIMENSION(:,:,:), ALLOCATABLE :: local_pf |
---|
131 | |
---|
132 | REAL, DIMENSION(:,:,:), POINTER :: to_be_resorted |
---|
133 | |
---|
134 | ! |
---|
135 | !-- Return, if nothing to output |
---|
136 | IF ( do3d_no(av) == 0 ) RETURN |
---|
137 | |
---|
138 | CALL cpu_log (log_point(14),'data_output_3d','start') |
---|
139 | |
---|
140 | ! |
---|
141 | !-- Open output file. |
---|
142 | !-- Also creates coordinate and fld-file for AVS. |
---|
143 | !-- For classic or 64bit netCDF output or output of other (old) data formats, |
---|
144 | !-- for a run on more than one PE, each PE opens its own file and |
---|
145 | !-- writes the data of its subdomain in binary format (regardless of the format |
---|
146 | !-- the user has requested). After the run, these files are combined to one |
---|
147 | !-- file by combine_plot_fields in the format requested by the user (netcdf |
---|
148 | !-- and/or avs). |
---|
149 | !-- For netCDF4/HDF5 output, data is written in parallel into one file. |
---|
150 | IF ( netcdf_output ) THEN |
---|
151 | IF ( netcdf_data_format < 5 ) THEN |
---|
152 | CALL check_open( 30 ) |
---|
153 | IF ( myid == 0 ) CALL check_open( 106+av*10 ) |
---|
154 | ELSE |
---|
155 | CALL check_open( 106+av*10 ) |
---|
156 | ENDIF |
---|
157 | ELSE |
---|
158 | IF ( avs_output .OR. ( numprocs > 1 ) ) CALL check_open( 30 ) |
---|
159 | ENDIF |
---|
160 | |
---|
161 | ! |
---|
162 | !-- Allocate a temporary array with the desired output dimensions. |
---|
163 | ALLOCATE( local_pf(nxlg:nxrg,nysg:nyng,nzb:nz_do3d) ) |
---|
164 | |
---|
165 | ! |
---|
166 | !-- Update the netCDF time axis |
---|
167 | #if defined( __netcdf ) |
---|
168 | IF ( myid == 0 .OR. netcdf_data_format > 4 ) THEN |
---|
169 | do3d_time_count(av) = do3d_time_count(av) + 1 |
---|
170 | IF ( netcdf_output ) THEN |
---|
171 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_time_3d(av), & |
---|
172 | (/ time_since_reference_point /), & |
---|
173 | start = (/ do3d_time_count(av) /), & |
---|
174 | count = (/ 1 /) ) |
---|
175 | CALL handle_netcdf_error( 'data_output_3d', 376 ) |
---|
176 | ENDIF |
---|
177 | ENDIF |
---|
178 | #endif |
---|
179 | |
---|
180 | ! |
---|
181 | !-- Loop over all variables to be written. |
---|
182 | if = 1 |
---|
183 | |
---|
184 | DO WHILE ( do3d(av,if)(1:1) /= ' ' ) |
---|
185 | ! |
---|
186 | !-- Set the precision for data compression. |
---|
187 | IF ( do3d_compress ) THEN |
---|
188 | DO i = 1, 100 |
---|
189 | IF ( plot_3d_precision(i)%variable == do3d(av,if) ) THEN |
---|
190 | prec = plot_3d_precision(i)%precision |
---|
191 | EXIT |
---|
192 | ENDIF |
---|
193 | ENDDO |
---|
194 | ENDIF |
---|
195 | |
---|
196 | ! |
---|
197 | !-- Store the array chosen on the temporary array. |
---|
198 | resorted = .FALSE. |
---|
199 | SELECT CASE ( TRIM( do3d(av,if) ) ) |
---|
200 | |
---|
201 | CASE ( 'e' ) |
---|
202 | IF ( av == 0 ) THEN |
---|
203 | to_be_resorted => e |
---|
204 | ELSE |
---|
205 | to_be_resorted => e_av |
---|
206 | ENDIF |
---|
207 | |
---|
208 | CASE ( 'lpt' ) |
---|
209 | IF ( av == 0 ) THEN |
---|
210 | to_be_resorted => pt |
---|
211 | ELSE |
---|
212 | to_be_resorted => lpt_av |
---|
213 | ENDIF |
---|
214 | |
---|
215 | CASE ( 'nr' ) |
---|
216 | IF ( av == 0 ) THEN |
---|
217 | to_be_resorted => nr |
---|
218 | ELSE |
---|
219 | to_be_resorted => nr_av |
---|
220 | ENDIF |
---|
221 | |
---|
222 | CASE ( 'p' ) |
---|
223 | IF ( av == 0 ) THEN |
---|
224 | IF ( psolver /= 'sor' ) CALL exchange_horiz( p, nbgp ) |
---|
225 | to_be_resorted => p |
---|
226 | ELSE |
---|
227 | IF ( psolver /= 'sor' ) CALL exchange_horiz( p_av, nbgp ) |
---|
228 | to_be_resorted => p_av |
---|
229 | ENDIF |
---|
230 | |
---|
231 | CASE ( 'pc' ) ! particle concentration (requires ghostpoint exchange) |
---|
232 | IF ( av == 0 ) THEN |
---|
233 | tend = prt_count |
---|
234 | CALL exchange_horiz( tend, nbgp ) |
---|
235 | DO i = nxlg, nxrg |
---|
236 | DO j = nysg, nyng |
---|
237 | DO k = nzb, nz_do3d |
---|
238 | local_pf(i,j,k) = tend(k,j,i) |
---|
239 | ENDDO |
---|
240 | ENDDO |
---|
241 | ENDDO |
---|
242 | resorted = .TRUE. |
---|
243 | ELSE |
---|
244 | CALL exchange_horiz( pc_av, nbgp ) |
---|
245 | to_be_resorted => pc_av |
---|
246 | ENDIF |
---|
247 | |
---|
248 | CASE ( 'pr' ) ! mean particle radius |
---|
249 | IF ( av == 0 ) THEN |
---|
250 | DO i = nxl, nxr |
---|
251 | DO j = nys, nyn |
---|
252 | DO k = nzb, nz_do3d |
---|
253 | psi = prt_start_index(k,j,i) |
---|
254 | s_r3 = 0.0 |
---|
255 | s_r4 = 0.0 |
---|
256 | DO n = psi, psi+prt_count(k,j,i)-1 |
---|
257 | s_r3 = s_r3 + particles(n)%radius**3 * & |
---|
258 | particles(n)%weight_factor |
---|
259 | s_r4 = s_r4 + particles(n)%radius**4 * & |
---|
260 | particles(n)%weight_factor |
---|
261 | ENDDO |
---|
262 | IF ( s_r3 /= 0.0 ) THEN |
---|
263 | mean_r = s_r4 / s_r3 |
---|
264 | ELSE |
---|
265 | mean_r = 0.0 |
---|
266 | ENDIF |
---|
267 | tend(k,j,i) = mean_r |
---|
268 | ENDDO |
---|
269 | ENDDO |
---|
270 | ENDDO |
---|
271 | CALL exchange_horiz( tend, nbgp ) |
---|
272 | DO i = nxlg, nxrg |
---|
273 | DO j = nysg, nyng |
---|
274 | DO k = nzb, nz_do3d |
---|
275 | local_pf(i,j,k) = tend(k,j,i) |
---|
276 | ENDDO |
---|
277 | ENDDO |
---|
278 | ENDDO |
---|
279 | resorted = .TRUE. |
---|
280 | ELSE |
---|
281 | CALL exchange_horiz( pr_av, nbgp ) |
---|
282 | to_be_resorted => pr_av |
---|
283 | ENDIF |
---|
284 | |
---|
285 | CASE ( 'prr' ) |
---|
286 | IF ( av == 0 ) THEN |
---|
287 | CALL exchange_horiz( prr, nbgp ) |
---|
288 | DO i = nxlg, nxrg |
---|
289 | DO j = nysg, nyng |
---|
290 | DO k = nzb, nzt+1 |
---|
291 | local_pf(i,j,k) = prr(k,j,i) |
---|
292 | ENDDO |
---|
293 | ENDDO |
---|
294 | ENDDO |
---|
295 | ELSE |
---|
296 | CALL exchange_horiz( prr_av, nbgp ) |
---|
297 | DO i = nxlg, nxrg |
---|
298 | DO j = nysg, nyng |
---|
299 | DO k = nzb, nzt+1 |
---|
300 | local_pf(i,j,k) = prr_av(k,j,i) |
---|
301 | ENDDO |
---|
302 | ENDDO |
---|
303 | ENDDO |
---|
304 | ENDIF |
---|
305 | resorted = .TRUE. |
---|
306 | |
---|
307 | CASE ( 'pt' ) |
---|
308 | IF ( av == 0 ) THEN |
---|
309 | IF ( .NOT. cloud_physics ) THEN |
---|
310 | to_be_resorted => pt |
---|
311 | ELSE |
---|
312 | DO i = nxlg, nxrg |
---|
313 | DO j = nysg, nyng |
---|
314 | DO k = nzb, nz_do3d |
---|
315 | local_pf(i,j,k) = pt(k,j,i) + l_d_cp * & |
---|
316 | pt_d_t(k) * & |
---|
317 | ql(k,j,i) |
---|
318 | ENDDO |
---|
319 | ENDDO |
---|
320 | ENDDO |
---|
321 | resorted = .TRUE. |
---|
322 | ENDIF |
---|
323 | ELSE |
---|
324 | to_be_resorted => pt_av |
---|
325 | ENDIF |
---|
326 | |
---|
327 | CASE ( 'q' ) |
---|
328 | IF ( av == 0 ) THEN |
---|
329 | to_be_resorted => q |
---|
330 | ELSE |
---|
331 | to_be_resorted => q_av |
---|
332 | ENDIF |
---|
333 | |
---|
334 | CASE ( 'qc' ) |
---|
335 | IF ( av == 0 ) THEN |
---|
336 | to_be_resorted => ql |
---|
337 | ELSE |
---|
338 | to_be_resorted => ql_av |
---|
339 | ENDIF |
---|
340 | |
---|
341 | CASE ( 'ql' ) |
---|
342 | IF ( av == 0 ) THEN |
---|
343 | IF ( cloud_physics .AND. icloud_scheme == 0 ) THEN |
---|
344 | DO i = nxlg, nxrg |
---|
345 | DO j = nysg, nyng |
---|
346 | DO k = nzb, nz_do3d |
---|
347 | local_pf(i,j,k) = ql(k,j,i) + qr(k,j,i) |
---|
348 | ENDDO |
---|
349 | ENDDO |
---|
350 | ENDDO |
---|
351 | resorted = .TRUE. |
---|
352 | ELSE |
---|
353 | to_be_resorted => ql |
---|
354 | ENDIF |
---|
355 | ELSE |
---|
356 | IF ( cloud_physics .AND. icloud_scheme == 0 ) THEN |
---|
357 | DO i = nxlg, nxrg |
---|
358 | DO j = nysg, nyng |
---|
359 | DO k = nzb, nz_do3d |
---|
360 | local_pf(i,j,k) = ql_av(k,j,i) + qr_av(k,j,i) |
---|
361 | ENDDO |
---|
362 | ENDDO |
---|
363 | ENDDO |
---|
364 | resorted = .TRUE. |
---|
365 | ELSE |
---|
366 | to_be_resorted => ql_av |
---|
367 | ENDIF |
---|
368 | ENDIF |
---|
369 | |
---|
370 | CASE ( 'ql_c' ) |
---|
371 | IF ( av == 0 ) THEN |
---|
372 | to_be_resorted => ql_c |
---|
373 | ELSE |
---|
374 | to_be_resorted => ql_c_av |
---|
375 | ENDIF |
---|
376 | |
---|
377 | CASE ( 'ql_v' ) |
---|
378 | IF ( av == 0 ) THEN |
---|
379 | to_be_resorted => ql_v |
---|
380 | ELSE |
---|
381 | to_be_resorted => ql_v_av |
---|
382 | ENDIF |
---|
383 | |
---|
384 | CASE ( 'ql_vp' ) |
---|
385 | IF ( av == 0 ) THEN |
---|
386 | DO i = nxl, nxr |
---|
387 | DO j = nys, nyn |
---|
388 | DO k = nzb, nz_do3d |
---|
389 | psi = prt_start_index(k,j,i) |
---|
390 | DO n = psi, psi+prt_count(k,j,i)-1 |
---|
391 | tend(k,j,i) = tend(k,j,i) + & |
---|
392 | particles(n)%weight_factor / & |
---|
393 | prt_count(k,j,i) |
---|
394 | ENDDO |
---|
395 | ENDDO |
---|
396 | ENDDO |
---|
397 | ENDDO |
---|
398 | CALL exchange_horiz( tend, nbgp ) |
---|
399 | DO i = nxlg, nxrg |
---|
400 | DO j = nysg, nyng |
---|
401 | DO k = nzb, nz_do3d |
---|
402 | local_pf(i,j,k) = tend(k,j,i) |
---|
403 | ENDDO |
---|
404 | ENDDO |
---|
405 | ENDDO |
---|
406 | resorted = .TRUE. |
---|
407 | ELSE |
---|
408 | CALL exchange_horiz( ql_vp_av, nbgp ) |
---|
409 | to_be_resorted => ql_vp_av |
---|
410 | ENDIF |
---|
411 | |
---|
412 | CASE ( 'qr' ) |
---|
413 | IF ( av == 0 ) THEN |
---|
414 | to_be_resorted => qr |
---|
415 | ELSE |
---|
416 | to_be_resorted => qr_av |
---|
417 | ENDIF |
---|
418 | |
---|
419 | CASE ( 'qv' ) |
---|
420 | IF ( av == 0 ) THEN |
---|
421 | DO i = nxlg, nxrg |
---|
422 | DO j = nysg, nyng |
---|
423 | DO k = nzb, nz_do3d |
---|
424 | local_pf(i,j,k) = q(k,j,i) - ql(k,j,i) |
---|
425 | ENDDO |
---|
426 | ENDDO |
---|
427 | ENDDO |
---|
428 | resorted = .TRUE. |
---|
429 | ELSE |
---|
430 | to_be_resorted => qv_av |
---|
431 | ENDIF |
---|
432 | |
---|
433 | CASE ( 'rho' ) |
---|
434 | IF ( av == 0 ) THEN |
---|
435 | to_be_resorted => rho |
---|
436 | ELSE |
---|
437 | to_be_resorted => rho_av |
---|
438 | ENDIF |
---|
439 | |
---|
440 | CASE ( 's' ) |
---|
441 | IF ( av == 0 ) THEN |
---|
442 | to_be_resorted => q |
---|
443 | ELSE |
---|
444 | to_be_resorted => s_av |
---|
445 | ENDIF |
---|
446 | |
---|
447 | CASE ( 'sa' ) |
---|
448 | IF ( av == 0 ) THEN |
---|
449 | to_be_resorted => sa |
---|
450 | ELSE |
---|
451 | to_be_resorted => sa_av |
---|
452 | ENDIF |
---|
453 | |
---|
454 | CASE ( 'u' ) |
---|
455 | IF ( av == 0 ) THEN |
---|
456 | to_be_resorted => u |
---|
457 | ELSE |
---|
458 | to_be_resorted => u_av |
---|
459 | ENDIF |
---|
460 | |
---|
461 | CASE ( 'v' ) |
---|
462 | IF ( av == 0 ) THEN |
---|
463 | to_be_resorted => v |
---|
464 | ELSE |
---|
465 | to_be_resorted => v_av |
---|
466 | ENDIF |
---|
467 | |
---|
468 | CASE ( 'vpt' ) |
---|
469 | IF ( av == 0 ) THEN |
---|
470 | to_be_resorted => vpt |
---|
471 | ELSE |
---|
472 | to_be_resorted => vpt_av |
---|
473 | ENDIF |
---|
474 | |
---|
475 | CASE ( 'w' ) |
---|
476 | IF ( av == 0 ) THEN |
---|
477 | to_be_resorted => w |
---|
478 | ELSE |
---|
479 | to_be_resorted => w_av |
---|
480 | ENDIF |
---|
481 | |
---|
482 | CASE DEFAULT |
---|
483 | ! |
---|
484 | !-- User defined quantity |
---|
485 | CALL user_data_output_3d( av, do3d(av,if), found, local_pf, & |
---|
486 | nz_do3d ) |
---|
487 | resorted = .TRUE. |
---|
488 | |
---|
489 | IF ( .NOT. found ) THEN |
---|
490 | message_string = 'no output available for: ' // & |
---|
491 | TRIM( do3d(av,if) ) |
---|
492 | CALL message( 'data_output_3d', 'PA0182', 0, 0, 0, 6, 0 ) |
---|
493 | ENDIF |
---|
494 | |
---|
495 | END SELECT |
---|
496 | |
---|
497 | ! |
---|
498 | !-- Resort the array to be output, if not done above |
---|
499 | IF ( .NOT. resorted ) THEN |
---|
500 | DO i = nxlg, nxrg |
---|
501 | DO j = nysg, nyng |
---|
502 | DO k = nzb, nz_do3d |
---|
503 | local_pf(i,j,k) = to_be_resorted(k,j,i) |
---|
504 | ENDDO |
---|
505 | ENDDO |
---|
506 | ENDDO |
---|
507 | ENDIF |
---|
508 | |
---|
509 | ! |
---|
510 | !-- Output of the volume data information for the AVS-FLD-file. |
---|
511 | do3d_avs_n = do3d_avs_n + 1 |
---|
512 | IF ( myid == 0 .AND. avs_output ) THEN |
---|
513 | ! |
---|
514 | !-- AVS-labels must not contain any colons. Hence they must be removed |
---|
515 | !-- from the time character string. |
---|
516 | simulated_time_mod = simulated_time_chr |
---|
517 | DO WHILE ( SCAN( simulated_time_mod, ':' ) /= 0 ) |
---|
518 | pos = SCAN( simulated_time_mod, ':' ) |
---|
519 | simulated_time_mod(pos:pos) = '/' |
---|
520 | ENDDO |
---|
521 | |
---|
522 | IF ( av == 0 ) THEN |
---|
523 | WRITE ( 33, 3300 ) do3d_avs_n, TRIM( avs_data_file ), & |
---|
524 | skip_do_avs, TRIM( do3d(av,if) ), & |
---|
525 | TRIM( simulated_time_mod ) |
---|
526 | ELSE |
---|
527 | WRITE ( 33, 3300 ) do3d_avs_n, TRIM( avs_data_file ), & |
---|
528 | skip_do_avs, TRIM( do3d(av,if) ) // & |
---|
529 | ' averaged', TRIM( simulated_time_mod ) |
---|
530 | ENDIF |
---|
531 | ! |
---|
532 | !-- Determine the Skip-value for the next array. Record end and start |
---|
533 | !-- require 4 byte each. |
---|
534 | skip_do_avs = skip_do_avs + ( ( ( nx+2*nbgp ) * ( ny+2*nbgp ) * & |
---|
535 | ( nz_do3d+1 ) ) * 4 + 8 ) |
---|
536 | ENDIF |
---|
537 | |
---|
538 | ! |
---|
539 | !-- Output of the 3D-array. (compressed/uncompressed) |
---|
540 | IF ( do3d_compress ) THEN |
---|
541 | ! |
---|
542 | !-- Compression, output of compression information on FLD-file and output |
---|
543 | !-- of compressed data. |
---|
544 | CALL write_compressed( local_pf, 30, 33, myid, nxl, nxr, nyn, nys, & |
---|
545 | nzb, nz_do3d, prec, nbgp ) |
---|
546 | ELSE |
---|
547 | ! |
---|
548 | !-- Uncompressed output. |
---|
549 | #if defined( __parallel ) |
---|
550 | IF ( netcdf_output ) THEN |
---|
551 | IF ( netcdf_data_format < 5 ) THEN |
---|
552 | ! |
---|
553 | !-- Non-parallel netCDF output. Data is output in parallel in |
---|
554 | !-- FORTRAN binary format here, and later collected into one file by |
---|
555 | !-- combine_plot_fields |
---|
556 | IF ( myid == 0 ) THEN |
---|
557 | WRITE ( 30 ) time_since_reference_point, & |
---|
558 | do3d_time_count(av), av |
---|
559 | ENDIF |
---|
560 | DO i = 0, io_blocks-1 |
---|
561 | IF ( i == io_group ) THEN |
---|
562 | WRITE ( 30 ) nxlg, nxrg, nysg, nyng, nzb, nz_do3d |
---|
563 | WRITE ( 30 ) local_pf |
---|
564 | ENDIF |
---|
565 | #if defined( __parallel ) |
---|
566 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
567 | #endif |
---|
568 | ENDDO |
---|
569 | |
---|
570 | ELSE |
---|
571 | #if defined( __netcdf ) |
---|
572 | ! |
---|
573 | !-- Parallel output in netCDF4/HDF5 format. |
---|
574 | !-- Do not output redundant ghost point data except for the |
---|
575 | !-- boundaries of the total domain. |
---|
576 | IF ( nxr == nx .AND. nyn /= ny ) THEN |
---|
577 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
578 | local_pf(nxl:nxrg,nys:nyn,nzb:nz_do3d), & |
---|
579 | start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /), & |
---|
580 | count = (/ nxr-nxl+1+nbgp, nyn-nys+1, nz_do3d-nzb+1, 1 /) ) |
---|
581 | ELSEIF ( nxr /= nx .AND. nyn == ny ) THEN |
---|
582 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
583 | local_pf(nxl:nxr,nys:nyng,nzb:nz_do3d), & |
---|
584 | start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /), & |
---|
585 | count = (/ nxr-nxl+1, nyn-nys+1+nbgp, nz_do3d-nzb+1, 1 /) ) |
---|
586 | ELSEIF ( nxr == nx .AND. nyn == ny ) THEN |
---|
587 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
588 | local_pf(nxl:nxrg,nys:nyng,nzb:nz_do3d), & |
---|
589 | start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /), & |
---|
590 | count = (/ nxr-nxl+1+nbgp, nyn-nys+1+nbgp, nz_do3d-nzb+1, 1 /) ) |
---|
591 | ELSE |
---|
592 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
593 | local_pf(nxl:nxr,nys:nyn,nzb:nz_do3d), & |
---|
594 | start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /), & |
---|
595 | count = (/ nxr-nxl+1, nyn-nys+1, nz_do3d-nzb+1, 1 /) ) |
---|
596 | ENDIF |
---|
597 | CALL handle_netcdf_error( 'data_output_3d', 386 ) |
---|
598 | #endif |
---|
599 | ENDIF |
---|
600 | ENDIF |
---|
601 | #else |
---|
602 | IF ( avs_output ) THEN |
---|
603 | WRITE ( 30 ) local_pf(nxl:nxr+1,nys:nyn+1,:) |
---|
604 | ENDIF |
---|
605 | #if defined( __netcdf ) |
---|
606 | IF ( netcdf_output ) THEN |
---|
607 | |
---|
608 | nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), & |
---|
609 | local_pf(nxl:nxr+1,nys:nyn+1,nzb:nz_do3d), & |
---|
610 | start = (/ 1, 1, 1, do3d_time_count(av) /), & |
---|
611 | count = (/ nx+2, ny+2, nz_do3d-nzb+1, 1 /) ) |
---|
612 | CALL handle_netcdf_error( 'data_output_3d', 446 ) |
---|
613 | |
---|
614 | ENDIF |
---|
615 | #endif |
---|
616 | #endif |
---|
617 | ENDIF |
---|
618 | |
---|
619 | if = if + 1 |
---|
620 | |
---|
621 | ENDDO |
---|
622 | |
---|
623 | ! |
---|
624 | !-- Deallocate temporary array. |
---|
625 | DEALLOCATE( local_pf ) |
---|
626 | |
---|
627 | |
---|
628 | CALL cpu_log (log_point(14),'data_output_3d','stop','nobarrier') |
---|
629 | |
---|
630 | ! |
---|
631 | !-- Formats. |
---|
632 | 3300 FORMAT ('variable ',I4,' file=',A,' filetype=unformatted skip=',I12/ & |
---|
633 | 'label = ',A,A) |
---|
634 | |
---|
635 | END SUBROUTINE data_output_3d |
---|