source: palm/trunk/SOURCE/data_output_3d.f90 @ 4180

Last change on this file since 4180 was 4180, checked in by scharf, 5 years ago

removed comments in 'Former revisions' section that are older than 01.01.2019

  • Property svn:keywords set to Id
File size: 25.4 KB
Line 
1!> @file data_output_3d.f90
2!------------------------------------------------------------------------------!
3! This file is part of the PALM model system.
4!
5! PALM is free software: you can redistribute it and/or modify it under the
6! terms of the GNU General Public License as published by the Free Software
7! Foundation, either version 3 of the License, or (at your option) any later
8! 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-2019 Leibniz Universitaet Hannover
18!------------------------------------------------------------------------------!
19!
20! Current revisions:
21! ------------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: data_output_3d.f90 4180 2019-08-21 14:37:54Z scharf $
27! bugfix for r4155
28!
29! 4155 2019-08-14 06:25:18Z raasch
30! bugfix for 3d-output in serial mode (ghost points must not be written)
31!
32! 4127 2019-07-30 14:47:10Z suehring
33! Adjustment for top boundary index for plant-canopy model outputs
34! (merge from branch resler)
35!
36! 4048 2019-06-21 21:00:21Z knoop
37! Moved tcm_data_output_3d to module_interface
38!
39! 4039 2019-06-18 10:32:41Z suehring
40! modularize diagnostic output
41!
42! 3994 2019-05-22 18:08:09Z suehring
43! output of turbulence intensity added
44!
45! 3987 2019-05-22 09:52:13Z kanani
46! Introduce alternative switch for debug output during timestepping
47!
48! 3885 2019-04-11 11:29:34Z kanani
49! Changes related to global restructuring of location messages and introduction
50! of additional debug messages
51!
52! 3814 2019-03-26 08:40:31Z pavelkrc
53! unused variables removed
54!
55! 3655 2019-01-07 16:51:22Z knoop
56! Bugfix: use time_since_reference_point instead of simulated_time (relevant
57! when using wall/soil spinup)
58!
59!
60! Description:
61! ------------
62!> Output of the 3D-arrays in netCDF and/or AVS format.
63!------------------------------------------------------------------------------!
64 SUBROUTINE data_output_3d( av )
65 
66
67    USE arrays_3d,                                                             &
68        ONLY:  d_exner, e, p, pt, q, ql, ql_c, ql_v, s, tend, u, v, vpt, w
69
70    USE averaging
71
72    USE basic_constants_and_equations_mod,                                     &
73        ONLY:  lv_d_cp
74
75    USE bulk_cloud_model_mod,                                                  &
76        ONLY:  bulk_cloud_model
77
78    USE control_parameters,                                                    &
79        ONLY:  debug_output_timestep,                                          &
80               do3d, do3d_no, do3d_time_count, io_blocks, io_group,            &
81               land_surface, message_string, ntdim_3d, nz_do3d, plant_canopy,  &
82               psolver, time_since_reference_point, urban_surface,             &
83               varnamelength
84
85    USE cpulog,                                                                &
86        ONLY:  log_point, cpu_log
87
88#if defined( __parallel )
89    USE indices,                                                               &
90        ONLY:  nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt,     &
91               wall_flags_0
92#else
93    USE indices,                                                               &
94        ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nzb,  &
95               nzt, wall_flags_0
96#endif
97
98    USE kinds
99
100    USE land_surface_model_mod,                                                &
101        ONLY: lsm_data_output_3d, nzb_soil, nzt_soil
102
103    USE module_interface,                                                      &
104        ONLY:  module_interface_data_output_3d
105
106#if defined( __netcdf )
107    USE NETCDF
108#endif
109
110    USE netcdf_interface,                                                      &
111        ONLY:  fill_value, id_set_3d, id_var_do3d, id_var_time_3d, nc_stat,    &
112               netcdf_data_format, netcdf_handle_error
113
114    USE particle_attributes,                                                   &
115        ONLY:  grid_particles, number_of_particles, particles,                 &
116               particle_advection_start, prt_count
117
118    USE pegrid
119
120    USE plant_canopy_model_mod,                                                &
121        ONLY:  pch_index
122
123    USE radiation_model_mod,                                                   &
124        ONLY:  nz_urban_b, nz_urban_t
125
126    USE urban_surface_mod,                                                     &
127        ONLY:  usm_data_output_3d
128
129
130    IMPLICIT NONE
131
132    INTEGER(iwp) ::  av        !< flag for (non-)average output
133    INTEGER(iwp) ::  flag_nr   !< number of masking flag
134    INTEGER(iwp) ::  i         !< loop index
135    INTEGER(iwp) ::  ivar      !< variable index
136    INTEGER(iwp) ::  j         !< loop index
137    INTEGER(iwp) ::  k         !< loop index
138    INTEGER(iwp) ::  n         !< loop index
139    INTEGER(iwp) ::  nzb_do    !< vertical lower limit for data output
140    INTEGER(iwp) ::  nzt_do    !< vertical upper limit for data output
141
142    LOGICAL      ::  found     !< true if output variable was found
143    LOGICAL      ::  resorted  !< true if variable is resorted
144
145    REAL(wp)     ::  mean_r    !< mean particle radius
146    REAL(wp)     ::  s_r2      !< sum( particle-radius**2 )
147    REAL(wp)     ::  s_r3      !< sum( particle-radius**3 )
148
149    REAL(sp), DIMENSION(:,:,:), ALLOCATABLE ::  local_pf  !< output array
150
151    REAL(wp), DIMENSION(:,:,:), POINTER ::  to_be_resorted  !< pointer to array which shall be output
152
153    CHARACTER (LEN=varnamelength) ::  trimvar  !< TRIM of output-variable string
154
155!
156!-- Return, if nothing to output
157    IF ( do3d_no(av) == 0 )  RETURN
158
159    IF ( debug_output_timestep )  CALL debug_message( 'data_output_3d', 'start' )
160
161    CALL cpu_log (log_point(14),'data_output_3d','start')
162
163!
164!-- Open output file.
165!-- For classic or 64bit netCDF output on more than one PE, each PE opens its
166!-- own file and writes the data of its subdomain in binary format. After the
167!-- run, these files are combined to one NetCDF file by combine_plot_fields.
168!-- For netCDF4/HDF5 output, data is written in parallel into one file.
169    IF ( netcdf_data_format < 5 )  THEN
170#if defined( __parallel )
171       CALL check_open( 30 )
172#endif
173       IF ( myid == 0 )  CALL check_open( 106+av*10 )
174    ELSE
175       CALL check_open( 106+av*10 )
176    ENDIF
177
178!
179!-- For parallel netcdf output the time axis must be limited. Return, if this
180!-- limit is exceeded. This could be the case, if the simulated time exceeds
181!-- the given end time by the length of the given output interval.
182    IF ( netcdf_data_format > 4 )  THEN
183       IF ( do3d_time_count(av) + 1 > ntdim_3d(av) )  THEN
184          WRITE ( message_string, * ) 'Output of 3d data is not given at t=',               &
185                                      time_since_reference_point, 's because the maximum ', & 
186                                      'number of output time levels is ',                   &
187                                      'exceeded.'
188          CALL message( 'data_output_3d', 'PA0387', 0, 1, 0, 6, 0 )
189          CALL cpu_log( log_point(14), 'data_output_3d', 'stop' )
190          RETURN
191       ENDIF
192    ENDIF
193
194!
195!-- Update the netCDF time axis
196!-- In case of parallel output, this is only done by PE0 to increase the
197!-- performance.
198#if defined( __netcdf )
199    do3d_time_count(av) = do3d_time_count(av) + 1
200    IF ( myid == 0 )  THEN
201       nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_time_3d(av),           &
202                               (/ time_since_reference_point /),            &
203                               start = (/ do3d_time_count(av) /),           &
204                               count = (/ 1 /) )
205       CALL netcdf_handle_error( 'data_output_3d', 376 )
206    ENDIF
207#endif
208
209!
210!-- Loop over all variables to be written.
211    ivar = 1
212
213    DO  WHILE ( do3d(av,ivar)(1:1) /= ' ' )
214
215!
216!--    Initiate found flag and resorting flag
217       found = .FALSE.
218       resorted = .FALSE.
219       trimvar = TRIM( do3d(av,ivar) )
220
221!
222!--    Temporary solution to account for data output within the new urban
223!--    surface model (urban_surface_mod.f90), see also SELECT CASE ( trimvar ).
224!--    Store the array chosen on the temporary array.
225       nzb_do   = nzb
226!
227!--    Set top index for 3D output. Note in case of plant-canopy model
228!--    these index is determined by pch_index.
229       IF ( plant_canopy  .AND.  trimvar(1:4) == 'pcm_' )  THEN
230          nzt_do   = pch_index
231       ELSE
232          nzt_do   = nz_do3d
233       ENDIF
234
235!
236!--    Allocate a temporary array with the desired output dimensions.
237       ALLOCATE( local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do) )
238!
239!--    Before each output, set array local_pf to fill value
240       local_pf = fill_value
241!
242!--    Set masking flag for topography for not resorted arrays
243       flag_nr = 0
244
245       SELECT CASE ( trimvar )
246
247          CASE ( 'e' )
248             IF ( av == 0 )  THEN
249                to_be_resorted => e
250             ELSE
251                IF ( .NOT. ALLOCATED( e_av ) ) THEN
252                   ALLOCATE( e_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
253                   e_av = REAL( fill_value, KIND = wp )
254                ENDIF
255                to_be_resorted => e_av
256             ENDIF
257
258          CASE ( 'thetal' )
259             IF ( av == 0 )  THEN
260                to_be_resorted => pt
261             ELSE
262                IF ( .NOT. ALLOCATED( lpt_av ) ) THEN
263                   ALLOCATE( lpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
264                   lpt_av = REAL( fill_value, KIND = wp )
265                ENDIF
266                to_be_resorted => lpt_av
267             ENDIF
268
269          CASE ( 'p' )
270             IF ( av == 0 )  THEN
271                IF ( psolver /= 'sor' )  CALL exchange_horiz( p, nbgp )
272                to_be_resorted => p
273             ELSE
274                IF ( .NOT. ALLOCATED( p_av ) ) THEN
275                   ALLOCATE( p_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
276                   p_av = REAL( fill_value, KIND = wp )
277                ENDIF
278                IF ( psolver /= 'sor' )  CALL exchange_horiz( p_av, nbgp )
279                to_be_resorted => p_av
280             ENDIF
281
282          CASE ( 'pc' )  ! particle concentration (requires ghostpoint exchange)
283             IF ( av == 0 )  THEN
284                IF ( time_since_reference_point >= particle_advection_start )  THEN
285                   tend = prt_count
286                ELSE
287                   tend = 0.0_wp
288                ENDIF
289                DO  i = nxl, nxr
290                   DO  j = nys, nyn
291                      DO  k = nzb_do, nzt_do
292                         local_pf(i,j,k) = tend(k,j,i)
293                      ENDDO
294                   ENDDO
295                ENDDO
296                resorted = .TRUE.
297             ELSE
298                IF ( .NOT. ALLOCATED( pc_av ) ) THEN
299                   ALLOCATE( pc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
300                   pc_av = REAL( fill_value, KIND = wp )
301                ENDIF
302                to_be_resorted => pc_av
303             ENDIF
304
305          CASE ( 'pr' )  ! mean particle radius (effective radius)
306             IF ( av == 0 )  THEN
307                IF ( time_since_reference_point >= particle_advection_start )  THEN
308                   DO  i = nxl, nxr
309                      DO  j = nys, nyn
310                         DO  k = nzb_do, nzt_do
311                            number_of_particles = prt_count(k,j,i)
312                            IF (number_of_particles <= 0)  CYCLE
313                            particles => grid_particles(k,j,i)%particles(1:number_of_particles)
314                            s_r2 = 0.0_wp
315                            s_r3 = 0.0_wp
316                            DO  n = 1, number_of_particles
317                               IF ( particles(n)%particle_mask )  THEN
318                                  s_r2 = s_r2 + particles(n)%radius**2 * &
319                                         particles(n)%weight_factor
320                                  s_r3 = s_r3 + particles(n)%radius**3 * &
321                                         particles(n)%weight_factor
322                               ENDIF
323                            ENDDO
324                            IF ( s_r2 > 0.0_wp )  THEN
325                               mean_r = s_r3 / s_r2
326                            ELSE
327                               mean_r = 0.0_wp
328                            ENDIF
329                            tend(k,j,i) = mean_r
330                         ENDDO
331                      ENDDO
332                   ENDDO
333                ELSE
334                   tend = 0.0_wp
335                ENDIF
336                DO  i = nxl, nxr
337                   DO  j = nys, nyn
338                      DO  k = nzb_do, nzt_do
339                         local_pf(i,j,k) = tend(k,j,i)
340                      ENDDO
341                   ENDDO
342                ENDDO
343                resorted = .TRUE.
344             ELSE
345                IF ( .NOT. ALLOCATED( pr_av ) ) THEN
346                   ALLOCATE( pr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
347                   pr_av = REAL( fill_value, KIND = wp )
348                ENDIF
349                to_be_resorted => pr_av
350             ENDIF
351
352          CASE ( 'theta' )
353             IF ( av == 0 )  THEN
354                IF ( .NOT. bulk_cloud_model ) THEN
355                   to_be_resorted => pt
356                ELSE
357                   DO  i = nxl, nxr
358                      DO  j = nys, nyn
359                         DO  k = nzb_do, nzt_do
360                            local_pf(i,j,k) = pt(k,j,i) + lv_d_cp *            &
361                                                          d_exner(k) *         &
362                                                          ql(k,j,i)
363                         ENDDO
364                      ENDDO
365                   ENDDO
366                   resorted = .TRUE.
367                ENDIF
368             ELSE
369                IF ( .NOT. ALLOCATED( pt_av ) ) THEN
370                   ALLOCATE( pt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
371                   pt_av = REAL( fill_value, KIND = wp )
372                ENDIF
373                to_be_resorted => pt_av
374             ENDIF
375
376          CASE ( 'q' )
377             IF ( av == 0 )  THEN
378                to_be_resorted => q
379             ELSE
380                IF ( .NOT. ALLOCATED( q_av ) ) THEN
381                   ALLOCATE( q_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
382                   q_av = REAL( fill_value, KIND = wp )
383                ENDIF
384                to_be_resorted => q_av
385             ENDIF
386
387          CASE ( 'ql' )
388             IF ( av == 0 )  THEN
389                to_be_resorted => ql
390             ELSE
391                IF ( .NOT. ALLOCATED( ql_av ) ) THEN
392                   ALLOCATE( ql_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
393                   ql_av = REAL( fill_value, KIND = wp )
394                ENDIF
395                to_be_resorted => ql_av
396             ENDIF
397
398          CASE ( 'ql_c' )
399             IF ( av == 0 )  THEN
400                to_be_resorted => ql_c
401             ELSE
402                IF ( .NOT. ALLOCATED( ql_c_av ) ) THEN
403                   ALLOCATE( ql_c_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
404                   ql_c_av = REAL( fill_value, KIND = wp )
405                ENDIF
406                to_be_resorted => ql_c_av
407             ENDIF
408
409          CASE ( 'ql_v' )
410             IF ( av == 0 )  THEN
411                to_be_resorted => ql_v
412             ELSE
413                IF ( .NOT. ALLOCATED( ql_v_av ) ) THEN
414                   ALLOCATE( ql_v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
415                   ql_v_av = REAL( fill_value, KIND = wp )
416                ENDIF
417                to_be_resorted => ql_v_av
418             ENDIF
419
420          CASE ( 'ql_vp' )
421             IF ( av == 0 )  THEN
422                IF ( time_since_reference_point >= particle_advection_start )  THEN
423                   DO  i = nxl, nxr
424                      DO  j = nys, nyn
425                         DO  k = nzb_do, nzt_do
426                            number_of_particles = prt_count(k,j,i)
427                            IF (number_of_particles <= 0)  CYCLE
428                            particles => grid_particles(k,j,i)%particles(1:number_of_particles)
429                            DO  n = 1, number_of_particles
430                               IF ( particles(n)%particle_mask )  THEN
431                                  tend(k,j,i) =  tend(k,j,i) +                 &
432                                                 particles(n)%weight_factor /  &
433                                                 prt_count(k,j,i)
434                               ENDIF
435                            ENDDO
436                         ENDDO
437                      ENDDO
438                   ENDDO
439                ELSE
440                   tend = 0.0_wp
441                ENDIF
442                DO  i = nxl, nxr
443                   DO  j = nys, nyn
444                      DO  k = nzb_do, nzt_do
445                         local_pf(i,j,k) = tend(k,j,i)
446                      ENDDO
447                   ENDDO
448                ENDDO
449                resorted = .TRUE.
450             ELSE
451                IF ( .NOT. ALLOCATED( ql_vp_av ) ) THEN
452                   ALLOCATE( ql_vp_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
453                   ql_vp_av = REAL( fill_value, KIND = wp )
454                ENDIF
455                to_be_resorted => ql_vp_av
456             ENDIF
457
458          CASE ( 'qv' )
459             IF ( av == 0 )  THEN
460                DO  i = nxl, nxr
461                   DO  j = nys, nyn
462                      DO  k = nzb_do, nzt_do
463                         local_pf(i,j,k) = q(k,j,i) - ql(k,j,i)
464                      ENDDO
465                   ENDDO
466                ENDDO
467                resorted = .TRUE.
468             ELSE
469                IF ( .NOT. ALLOCATED( qv_av ) ) THEN
470                   ALLOCATE( qv_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
471                   qv_av = REAL( fill_value, KIND = wp )
472                ENDIF
473                to_be_resorted => qv_av
474             ENDIF
475
476          CASE ( 's' )
477             IF ( av == 0 )  THEN
478                to_be_resorted => s
479             ELSE
480                IF ( .NOT. ALLOCATED( s_av ) ) THEN
481                   ALLOCATE( s_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
482                   s_av = REAL( fill_value, KIND = wp )
483                ENDIF
484                to_be_resorted => s_av
485             ENDIF
486
487          CASE ( 'u' )
488             flag_nr = 1
489             IF ( av == 0 )  THEN
490                to_be_resorted => u
491             ELSE
492                IF ( .NOT. ALLOCATED( u_av ) ) THEN
493                   ALLOCATE( u_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
494                   u_av = REAL( fill_value, KIND = wp )
495                ENDIF
496                to_be_resorted => u_av
497             ENDIF
498
499          CASE ( 'v' )
500             flag_nr = 2
501             IF ( av == 0 )  THEN
502                to_be_resorted => v
503             ELSE
504                IF ( .NOT. ALLOCATED( v_av ) ) THEN
505                   ALLOCATE( v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
506                   v_av = REAL( fill_value, KIND = wp )
507                ENDIF
508                to_be_resorted => v_av
509             ENDIF
510
511          CASE ( 'thetav' )
512             IF ( av == 0 )  THEN
513                to_be_resorted => vpt
514             ELSE
515                IF ( .NOT. ALLOCATED( vpt_av ) ) THEN
516                   ALLOCATE( vpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
517                   vpt_av = REAL( fill_value, KIND = wp )
518                ENDIF
519                to_be_resorted => vpt_av
520             ENDIF
521
522          CASE ( 'w' )
523             flag_nr = 3
524             IF ( av == 0 )  THEN
525                to_be_resorted => w
526             ELSE
527                IF ( .NOT. ALLOCATED( w_av ) ) THEN
528                   ALLOCATE( w_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
529                   w_av = REAL( fill_value, KIND = wp )
530                ENDIF
531                to_be_resorted => w_av
532             ENDIF
533
534          CASE DEFAULT
535!
536!--          Quantities of other modules
537             IF ( .NOT. found )  THEN
538                CALL module_interface_data_output_3d(                          &
539                        av, trimvar, found, local_pf,                          &
540                        fill_value, resorted, nzb_do, nzt_do                   &
541                     )
542             ENDIF
543
544!
545!--          Temporary workaround: ToDo: refactor local_pf allocation
546             IF ( .NOT. found  .AND.  urban_surface  .AND.  trimvar(1:4) == 'usm_' )  THEN
547!
548!--             For urban model quantities, it is required to re-allocate local_pf
549                nzb_do = nz_urban_b
550                nzt_do = nz_urban_t
551
552                DEALLOCATE ( local_pf )
553                ALLOCATE( local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do) )
554                local_pf = fill_value
555
556                CALL usm_data_output_3d( av, trimvar, found, local_pf,         &
557                                         nzb_do, nzt_do )
558                resorted = .TRUE.
559
560!
561!--             If no soil model variable was found, re-allocate local_pf
562                IF ( .NOT. found )  THEN
563                   nzb_do = nzb
564                   nzt_do = nz_do3d
565
566                   DEALLOCATE ( local_pf )
567                   ALLOCATE( local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do) )
568                ENDIF
569
570             ENDIF
571
572!
573!--          Temporary workaround: ToDo: refactor local_pf allocation
574             IF ( .NOT. found  .AND.  land_surface )  THEN
575!
576!--             For soil model quantities, it is required to re-allocate local_pf
577                nzb_do = nzb_soil
578                nzt_do = nzt_soil
579
580                DEALLOCATE ( local_pf )
581                ALLOCATE( local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do) )
582                local_pf = fill_value
583
584                CALL lsm_data_output_3d( av, trimvar, found, local_pf )
585                resorted = .TRUE.
586
587!
588!--             If no soil model variable was found, re-allocate local_pf
589                IF ( .NOT. found )  THEN
590                   nzb_do = nzb
591                   nzt_do = nz_do3d
592
593                   DEALLOCATE ( local_pf )
594                   ALLOCATE( local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do) )
595                ENDIF
596
597             ENDIF
598
599             IF ( .NOT. found )  THEN
600                message_string =  'no output available for: ' //               &
601                                  TRIM( do3d(av,ivar) )
602                CALL message( 'data_output_3d', 'PA0182', 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 = nxl, nxr
611             DO  j = nys, nyn
612                DO  k = nzb_do, nzt_do
613                   local_pf(i,j,k) = MERGE(                                    &
614                                      to_be_resorted(k,j,i),                   &
615                                      REAL( fill_value, KIND = wp ),           &
616                                      BTEST( wall_flags_0(k,j,i), flag_nr ) )
617                ENDDO
618             ENDDO
619          ENDDO
620       ENDIF
621
622!
623!--    Output of the 3D-array
624#if defined( __parallel )
625       IF ( netcdf_data_format < 5 )  THEN
626!
627!--       Non-parallel netCDF output. Data is output in parallel in
628!--       FORTRAN binary format here, and later collected into one file by
629!--       combine_plot_fields
630          IF ( myid == 0 )  THEN
631             WRITE ( 30 )  time_since_reference_point,                   &
632                           do3d_time_count(av), av
633          ENDIF
634          DO  i = 0, io_blocks-1
635             IF ( i == io_group )  THEN
636                WRITE ( 30 )  nxl, nxr, nys, nyn, nzb_do, nzt_do
637                WRITE ( 30 )  local_pf(:,:,nzb_do:nzt_do)
638             ENDIF
639
640             CALL MPI_BARRIER( comm2d, ierr )
641
642          ENDDO
643
644       ELSE
645#if defined( __netcdf )
646!
647!--       Parallel output in netCDF4/HDF5 format.
648!          IF ( nxr == nx  .AND.  nyn /= ny )  THEN
649!             nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,ivar),  &
650!                               local_pf(nxl:nxr+1,nys:nyn,nzb_do:nzt_do),    &
651!                start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /),  &
652!                count = (/ nxr-nxl+2, nyn-nys+1, nzt_do-nzb_do+1, 1 /) )
653!          ELSEIF ( nxr /= nx  .AND.  nyn == ny )  THEN
654!             nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,ivar),  &
655!                               local_pf(nxl:nxr,nys:nyn+1,nzb_do:nzt_do),    &
656!                start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /),  &
657!                count = (/ nxr-nxl+1, nyn-nys+2, nzt_do-nzb_do+1, 1 /) )
658!          ELSEIF ( nxr == nx  .AND.  nyn == ny )  THEN
659!             nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,ivar),  &
660!                             local_pf(nxl:nxr+1,nys:nyn+1,nzb_do:nzt_do  ),  &
661!                start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /),  &
662!                count = (/ nxr-nxl+2, nyn-nys+2, nzt_do-nzb_do+1, 1 /) )
663!          ELSE
664             nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,ivar),  &
665                                 local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do),    &
666                start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /),  &
667                count = (/ nxr-nxl+1, nyn-nys+1, nzt_do-nzb_do+1, 1 /) )
668!          ENDIF
669          CALL netcdf_handle_error( 'data_output_3d', 386 )
670#endif
671       ENDIF
672#else
673#if defined( __netcdf )
674       nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,ivar),        &
675                         local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do),          &
676                         start = (/ 1, 1, 1, do3d_time_count(av) /),       &
677                         count = (/ nx+1, ny+1, nzt_do-nzb_do+1, 1 /) )
678       CALL netcdf_handle_error( 'data_output_3d', 446 )
679#endif
680#endif
681
682       ivar = ivar + 1
683
684!
685!--    Deallocate temporary array
686       DEALLOCATE ( local_pf )
687
688    ENDDO
689
690    CALL cpu_log( log_point(14), 'data_output_3d', 'stop' )
691
692    IF ( debug_output_timestep )  CALL debug_message( 'data_output_3d', 'end' )
693
694
695 END SUBROUTINE data_output_3d
Note: See TracBrowser for help on using the repository browser.