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

Last change on this file since 1783 was 1783, checked in by raasch, 8 years ago

NetCDF routines modularized; new parameter netcdf_deflate; further changes in the pmc

  • Property svn:keywords set to Id
File size: 24.5 KB
Line 
1!> @file data_output_3d.f90
2!--------------------------------------------------------------------------------!
3! This file is part of PALM.
4!
5! PALM is free software: you can redistribute it and/or modify it under the terms
6! of the GNU General Public License as published by the Free Software Foundation,
7! either version 3 of the License, or (at your option) any later version.
8!
9! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
10! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
12!
13! You should have received a copy of the GNU General Public License along with
14! PALM. If not, see <http://www.gnu.org/licenses/>.
15!
16! Copyright 1997-2015 Leibniz Universitaet Hannover
17!--------------------------------------------------------------------------------!
18!
19! Current revisions:
20! ------------------
21! name change of netcdf routines and module + related changes
22!
23! Former revisions:
24! -----------------
25! $Id: data_output_3d.f90 1783 2016-03-06 18:36:17Z raasch $
26!
27! 1745 2016-02-05 13:06:51Z gronemeier
28! Bugfix: test if time axis limit exceeds moved to point after call of check_open
29!
30! 1691 2015-10-26 16:17:44Z maronga
31! Added output of radiative heating rates for RRTMG
32!
33! 1682 2015-10-07 23:56:08Z knoop
34! Code annotations made doxygen readable
35!
36! 1585 2015-04-30 07:05:52Z maronga
37! Added support for RRTMG
38!
39! 1551 2015-03-03 14:18:16Z maronga
40! Added suppport for land surface model and radiation model output. In the course
41! of this action, the limits for vertical loops have been changed (from nzb and
42! nzt+1 to nzb_do and nzt_do, respectively in order to allow soil model output).
43! Moreover, a new vertical grid zs was introduced.
44!
45! 1359 2014-04-11 17:15:14Z hoffmann
46! New particle structure integrated.
47!
48! 1353 2014-04-08 15:21:23Z heinze
49! REAL constants provided with KIND-attribute
50!
51! 1327 2014-03-21 11:00:16Z raasch
52! parts concerning avs output removed,
53! -netcdf output queries
54!
55! 1320 2014-03-20 08:40:49Z raasch
56! ONLY-attribute added to USE-statements,
57! kind-parameters added to all INTEGER and REAL declaration statements,
58! kinds are defined in new module kinds,
59! old module precision_kind is removed,
60! revision history before 2012 removed,
61! comment fields (!:) to be used for variable explanations added to
62! all variable declaration statements
63!
64! 1318 2014-03-17 13:35:16Z raasch
65! barrier argument removed from cpu_log,
66! module interfaces removed
67!
68! 1308 2014-03-13 14:58:42Z fricke
69! Check, if the limit of the time dimension is exceeded for parallel output
70! To increase the performance for parallel output, the following is done:
71! - Update of time axis is only done by PE0
72!
73! 1244 2013-10-31 08:16:56Z raasch
74! Bugfix for index bounds in case of 3d-parallel output
75!
76! 1115 2013-03-26 18:16:16Z hoffmann
77! ql is calculated by calc_liquid_water_content
78!
79! 1106 2013-03-04 05:31:38Z raasch
80! array_kind renamed precision_kind
81!
82! 1076 2012-12-05 08:30:18Z hoffmann
83! Bugfix in output of ql
84!
85! 1053 2012-11-13 17:11:03Z hoffmann
86! +nr, qr, prr, qc and averaged quantities
87!
88! 1036 2012-10-22 13:43:42Z raasch
89! code put under GPL (PALM 3.9)
90!
91! 1031 2012-10-19 14:35:30Z raasch
92! netCDF4 without parallel file support implemented
93!
94! 1007 2012-09-19 14:30:36Z franke
95! Bugfix: missing calculation of ql_vp added
96!
97! Revision 1.1  1997/09/03 06:29:36  raasch
98! Initial revision
99!
100!
101! Description:
102! ------------
103!> Output of the 3D-arrays in netCDF and/or AVS format.
104!------------------------------------------------------------------------------!
105 SUBROUTINE data_output_3d( av )
106 
107
108    USE arrays_3d,                                                             &
109        ONLY:  e, nr, p, pt, q, qc, ql, ql_c, ql_v, qr, rho, sa, tend, u, v,   &
110               vpt, w
111       
112    USE averaging
113       
114    USE cloud_parameters,                                                      &
115        ONLY:  l_d_cp, prr, pt_d_t
116       
117    USE control_parameters,                                                    &
118        ONLY:  avs_data_file, cloud_physics, do3d, do3d_avs_n,                 &
119               do3d_no, do3d_time_count, io_blocks, io_group,                  &
120               message_string, ntdim_3d,                                       &
121               nz_do3d, plot_3d_precision, psolver, simulated_time,            &
122               simulated_time_chr, skip_do_avs, time_since_reference_point
123       
124    USE cpulog,                                                                &
125        ONLY:  log_point, cpu_log
126       
127    USE indices,                                                               &
128        ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nzt,  &
129               nzb
130       
131    USE kinds
132   
133    USE land_surface_model_mod,                                                &
134        ONLY: m_soil, m_soil_av, nzb_soil, nzt_soil, t_soil, t_soil_av
135
136#if defined( __netcdf )
137    USE NETCDF
138#endif
139
140    USE netcdf_interface,                                                      &
141        ONLY:  id_set_3d, id_var_do3d, id_var_time_3d, nc_stat,                &
142               netcdf_data_format, netcdf_handle_error
143       
144    USE particle_attributes,                                                   &
145        ONLY:  grid_particles, number_of_particles, particles,                 &
146               particle_advection_start, prt_count
147       
148    USE pegrid
149
150    USE radiation_model_mod,                                                   &
151        ONLY:  rad_lw_in, rad_lw_in_av, rad_lw_out, rad_lw_out_av,             &
152               rad_lw_cs_hr, rad_lw_cs_hr_av, rad_lw_hr, rad_lw_hr_av,         &
153               rad_sw_in, rad_sw_in_av, rad_sw_out, rad_sw_out_av,             &
154               rad_sw_cs_hr, rad_sw_cs_hr_av, rad_sw_hr, rad_sw_hr_av
155
156
157    IMPLICIT NONE
158
159    CHARACTER (LEN=9) ::  simulated_time_mod  !<
160
161    INTEGER(iwp) ::  av        !<
162    INTEGER(iwp) ::  i         !<
163    INTEGER(iwp) ::  if        !<
164    INTEGER(iwp) ::  j         !<
165    INTEGER(iwp) ::  k         !<
166    INTEGER(iwp) ::  n         !<
167    INTEGER(iwp) ::  nzb_do    !< vertical lower limit for data output
168    INTEGER(iwp) ::  nzt_do    !< vertical upper limit for data output
169    INTEGER(iwp) ::  pos       !<
170    INTEGER(iwp) ::  prec      !<
171    INTEGER(iwp) ::  psi       !<
172
173    LOGICAL      ::  found     !<
174    LOGICAL      ::  resorted  !<
175
176    REAL(wp)     ::  mean_r    !<
177    REAL(wp)     ::  s_r2      !<
178    REAL(wp)     ::  s_r3      !<
179
180    REAL(sp), DIMENSION(:,:,:), ALLOCATABLE ::  local_pf  !<
181
182    REAL(wp), DIMENSION(:,:,:), POINTER ::  to_be_resorted  !<
183
184!
185!-- Return, if nothing to output
186    IF ( do3d_no(av) == 0 )  RETURN
187
188    CALL cpu_log (log_point(14),'data_output_3d','start')
189
190!
191!-- Open output file.
192!-- Also creates coordinate and fld-file for AVS.
193!-- For classic or 64bit netCDF output or output of other (old) data formats,
194!-- for a run on more than one PE, each PE opens its own file and
195!-- writes the data of its subdomain in binary format (regardless of the format
196!-- the user has requested). After the run, these files are combined to one
197!-- file by combine_plot_fields in the format requested by the user (netcdf
198!-- and/or avs).
199!-- For netCDF4/HDF5 output, data is written in parallel into one file.
200    IF ( netcdf_data_format < 5 )  THEN
201       CALL check_open( 30 )
202       IF ( myid == 0 )  CALL check_open( 106+av*10 )
203    ELSE
204       CALL check_open( 106+av*10 )
205    ENDIF
206
207!
208!-- For parallel netcdf output the time axis must be limited. Return, if this
209!-- limit is exceeded. This could be the case, if the simulated time exceeds
210!-- the given end time by the length of the given output interval.
211    IF ( netcdf_data_format > 4 )  THEN
212       IF ( do3d_time_count(av) + 1 > ntdim_3d(av) )  THEN
213          WRITE ( message_string, * ) 'Output of 3d data is not given at t=',  &
214                                      simulated_time, '&because the maximum ', & 
215                                      'number of output time levels is ',      &
216                                      'exceeded.'
217          CALL message( 'data_output_3d', 'PA0387', 0, 1, 0, 6, 0 )
218          CALL cpu_log( log_point(14), 'data_output_3d', 'stop' )
219          RETURN
220       ENDIF
221    ENDIF
222    WRITE(9,*) '___hier4'
223    CALL local_flush(9)
224
225!
226!-- Update the netCDF time axis
227!-- In case of parallel output, this is only done by PE0 to increase the
228!-- performance.
229#if defined( __netcdf )
230    do3d_time_count(av) = do3d_time_count(av) + 1
231    IF ( myid == 0 )  THEN
232       nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_time_3d(av),           &
233                               (/ time_since_reference_point /),            &
234                               start = (/ do3d_time_count(av) /),           &
235                               count = (/ 1 /) )
236       CALL netcdf_handle_error( 'data_output_3d', 376 )
237    ENDIF
238#endif
239
240!
241!-- Loop over all variables to be written.
242    if = 1
243
244    DO  WHILE ( do3d(av,if)(1:1) /= ' ' )
245!
246!--    Store the array chosen on the temporary array.
247       resorted = .FALSE.
248       nzb_do = nzb
249       nzt_do = nz_do3d
250
251!
252!--    Allocate a temporary array with the desired output dimensions.
253       ALLOCATE( local_pf(nxlg:nxrg,nysg:nyng,nzb_do:nzt_do) )
254
255       SELECT CASE ( TRIM( do3d(av,if) ) )
256
257          CASE ( 'e' )
258             IF ( av == 0 )  THEN
259                to_be_resorted => e
260             ELSE
261                to_be_resorted => e_av
262             ENDIF
263
264          CASE ( 'lpt' )
265             IF ( av == 0 )  THEN
266                to_be_resorted => pt
267             ELSE
268                to_be_resorted => lpt_av
269             ENDIF
270
271          CASE ( 'm_soil' )
272             nzb_do = nzb_soil
273             nzt_do = nzt_soil
274!
275!--          For soil model quantities, it is required to re-allocate local_pf
276             DEALLOCATE ( local_pf )
277             ALLOCATE( local_pf(nxlg:nxrg,nysg:nyng,nzb_do:nzt_do) )
278
279             IF ( av == 0 )  THEN
280                to_be_resorted => m_soil
281             ELSE
282                to_be_resorted => m_soil_av
283             ENDIF
284
285          CASE ( 'nr' )
286             IF ( av == 0 )  THEN
287                to_be_resorted => nr
288             ELSE
289                to_be_resorted => nr_av
290             ENDIF
291
292          CASE ( 'p' )
293             IF ( av == 0 )  THEN
294                IF ( psolver /= 'sor' )  CALL exchange_horiz( p, nbgp )
295                to_be_resorted => p
296             ELSE
297                IF ( psolver /= 'sor' )  CALL exchange_horiz( p_av, nbgp )
298                to_be_resorted => p_av
299             ENDIF
300
301          CASE ( 'pc' )  ! particle concentration (requires ghostpoint exchange)
302             IF ( av == 0 )  THEN
303                IF ( simulated_time >= particle_advection_start )  THEN
304                   tend = prt_count
305                   CALL exchange_horiz( tend, nbgp )
306                ELSE
307                   tend = 0.0_wp
308                ENDIF
309                DO  i = nxlg, nxrg
310                   DO  j = nysg, nyng
311                      DO  k = nzb_do, nzt_do
312                         local_pf(i,j,k) = tend(k,j,i)
313                      ENDDO
314                   ENDDO
315                ENDDO
316                resorted = .TRUE.
317             ELSE
318                CALL exchange_horiz( pc_av, nbgp )
319                to_be_resorted => pc_av
320             ENDIF
321
322          CASE ( 'pr' )  ! mean particle radius (effective radius)
323             IF ( av == 0 )  THEN
324                IF ( simulated_time >= particle_advection_start )  THEN
325                   DO  i = nxl, nxr
326                      DO  j = nys, nyn
327                         DO  k = nzb_do, nzt_do
328                            number_of_particles = prt_count(k,j,i)
329                            IF (number_of_particles <= 0)  CYCLE
330                            particles => grid_particles(k,j,i)%particles(1:number_of_particles)
331                            s_r2 = 0.0_wp
332                            s_r3 = 0.0_wp
333                            DO  n = 1, number_of_particles
334                               IF ( particles(n)%particle_mask )  THEN
335                                  s_r2 = s_r2 + particles(n)%radius**2 * &
336                                         particles(n)%weight_factor
337                                  s_r3 = s_r3 + particles(n)%radius**3 * &
338                                         particles(n)%weight_factor
339                               ENDIF
340                            ENDDO
341                            IF ( s_r2 > 0.0_wp )  THEN
342                               mean_r = s_r3 / s_r2
343                            ELSE
344                               mean_r = 0.0_wp
345                            ENDIF
346                            tend(k,j,i) = mean_r
347                         ENDDO
348                      ENDDO
349                   ENDDO
350                   CALL exchange_horiz( tend, nbgp )
351                ELSE
352                   tend = 0.0_wp
353                ENDIF
354                DO  i = nxlg, nxrg
355                   DO  j = nysg, nyng
356                      DO  k = nzb_do, nzt_do
357                         local_pf(i,j,k) = tend(k,j,i)
358                      ENDDO
359                   ENDDO
360                ENDDO
361                resorted = .TRUE.
362             ELSE
363                CALL exchange_horiz( pr_av, nbgp )
364                to_be_resorted => pr_av
365             ENDIF
366
367          CASE ( 'prr' )
368             IF ( av == 0 )  THEN
369                CALL exchange_horiz( prr, nbgp )
370                DO  i = nxlg, nxrg
371                   DO  j = nysg, nyng
372                      DO  k = nzb, nzt+1
373                         local_pf(i,j,k) = prr(k,j,i)
374                      ENDDO
375                   ENDDO
376                ENDDO
377             ELSE
378                CALL exchange_horiz( prr_av, nbgp )
379                DO  i = nxlg, nxrg
380                   DO  j = nysg, nyng
381                      DO  k = nzb, nzt+1
382                         local_pf(i,j,k) = prr_av(k,j,i)
383                      ENDDO
384                   ENDDO
385                ENDDO
386             ENDIF
387             resorted = .TRUE.
388
389          CASE ( 'pt' )
390             IF ( av == 0 )  THEN
391                IF ( .NOT. cloud_physics ) THEN
392                   to_be_resorted => pt
393                ELSE
394                   DO  i = nxlg, nxrg
395                      DO  j = nysg, nyng
396                         DO  k = nzb_do, nzt_do
397                            local_pf(i,j,k) = pt(k,j,i) + l_d_cp *             &
398                                                          pt_d_t(k) *          &
399                                                          ql(k,j,i)
400                         ENDDO
401                      ENDDO
402                   ENDDO
403                   resorted = .TRUE.
404                ENDIF
405             ELSE
406                to_be_resorted => pt_av
407             ENDIF
408
409          CASE ( 'q' )
410             IF ( av == 0 )  THEN
411                to_be_resorted => q
412             ELSE
413                to_be_resorted => q_av
414             ENDIF
415
416          CASE ( 'qc' )
417             IF ( av == 0 )  THEN
418                to_be_resorted => qc
419             ELSE
420                to_be_resorted => qc_av
421             ENDIF
422
423          CASE ( 'ql' )
424             IF ( av == 0 )  THEN
425                to_be_resorted => ql
426             ELSE
427                to_be_resorted => ql_av
428             ENDIF
429
430          CASE ( 'ql_c' )
431             IF ( av == 0 )  THEN
432                to_be_resorted => ql_c
433             ELSE
434                to_be_resorted => ql_c_av
435             ENDIF
436
437          CASE ( 'ql_v' )
438             IF ( av == 0 )  THEN
439                to_be_resorted => ql_v
440             ELSE
441                to_be_resorted => ql_v_av
442             ENDIF
443
444          CASE ( 'ql_vp' )
445             IF ( av == 0 )  THEN
446                IF ( simulated_time >= particle_advection_start )  THEN
447                   DO  i = nxl, nxr
448                      DO  j = nys, nyn
449                         DO  k = nzb_do, nzt_do
450                            number_of_particles = prt_count(k,j,i)
451                            IF (number_of_particles <= 0)  CYCLE
452                            particles => grid_particles(k,j,i)%particles(1:number_of_particles)
453                            DO  n = 1, number_of_particles
454                               IF ( particles(n)%particle_mask )  THEN
455                                  tend(k,j,i) =  tend(k,j,i) +                 &
456                                                 particles(n)%weight_factor /  &
457                                                 prt_count(k,j,i)
458                               ENDIF
459                            ENDDO
460                         ENDDO
461                      ENDDO
462                   ENDDO
463                   CALL exchange_horiz( tend, nbgp )
464                ELSE
465                   tend = 0.0_wp
466                ENDIF
467                DO  i = nxlg, nxrg
468                   DO  j = nysg, nyng
469                      DO  k = nzb_do, nzt_do
470                         local_pf(i,j,k) = tend(k,j,i)
471                      ENDDO
472                   ENDDO
473                ENDDO
474                resorted = .TRUE.
475             ELSE
476                CALL exchange_horiz( ql_vp_av, nbgp )
477                to_be_resorted => ql_vp_av
478             ENDIF
479
480          CASE ( 'qr' )
481             IF ( av == 0 )  THEN
482                to_be_resorted => qr
483             ELSE
484                to_be_resorted => qr_av
485             ENDIF
486
487          CASE ( 'qv' )
488             IF ( av == 0 )  THEN
489                DO  i = nxlg, nxrg
490                   DO  j = nysg, nyng
491                      DO  k = nzb_do, nzt_do
492                         local_pf(i,j,k) = q(k,j,i) - ql(k,j,i)
493                      ENDDO
494                   ENDDO
495                ENDDO
496                resorted = .TRUE.
497             ELSE
498                to_be_resorted => qv_av
499             ENDIF
500
501          CASE ( 'rad_sw_in' )
502             IF ( av == 0 )  THEN
503                to_be_resorted => rad_sw_in
504             ELSE
505                to_be_resorted => rad_sw_in_av
506             ENDIF
507
508          CASE ( 'rad_sw_out' )
509             IF ( av == 0 )  THEN
510                to_be_resorted => rad_sw_out
511             ELSE
512                to_be_resorted => rad_sw_out_av
513             ENDIF
514
515          CASE ( 'rad_sw_cs_hr' )
516             IF ( av == 0 )  THEN
517                to_be_resorted => rad_sw_cs_hr
518             ELSE
519                to_be_resorted => rad_sw_cs_hr_av
520             ENDIF
521
522          CASE ( 'rad_sw_hr' )
523             IF ( av == 0 )  THEN
524                to_be_resorted => rad_sw_hr
525             ELSE
526                to_be_resorted => rad_sw_hr_av
527             ENDIF
528
529          CASE ( 'rad_lw_in' )
530             IF ( av == 0 )  THEN
531                to_be_resorted => rad_lw_in
532             ELSE
533                to_be_resorted => rad_lw_in_av
534             ENDIF
535
536          CASE ( 'rad_lw_out' )
537             IF ( av == 0 )  THEN
538                to_be_resorted => rad_lw_out
539             ELSE
540                to_be_resorted => rad_lw_out_av
541             ENDIF
542
543          CASE ( 'rad_lw_cs_hr' )
544             IF ( av == 0 )  THEN
545                to_be_resorted => rad_lw_cs_hr
546             ELSE
547                to_be_resorted => rad_lw_cs_hr_av
548             ENDIF
549
550          CASE ( 'rad_lw_hr' )
551             IF ( av == 0 )  THEN
552                to_be_resorted => rad_lw_hr
553             ELSE
554                to_be_resorted => rad_lw_hr_av
555             ENDIF
556
557          CASE ( 'rho' )
558             IF ( av == 0 )  THEN
559                to_be_resorted => rho
560             ELSE
561                to_be_resorted => rho_av
562             ENDIF
563
564          CASE ( 's' )
565             IF ( av == 0 )  THEN
566                to_be_resorted => q
567             ELSE
568                to_be_resorted => s_av
569             ENDIF
570
571          CASE ( 'sa' )
572             IF ( av == 0 )  THEN
573                to_be_resorted => sa
574             ELSE
575                to_be_resorted => sa_av
576             ENDIF
577
578          CASE ( 't_soil' )
579             nzb_do = nzb_soil
580             nzt_do = nzt_soil
581!
582!--          For soil model quantities, it is required to re-allocate local_pf
583             DEALLOCATE ( local_pf )
584             ALLOCATE( local_pf(nxlg:nxrg,nysg:nyng,nzb_do:nzt_do) )
585
586             IF ( av == 0 )  THEN
587                to_be_resorted => t_soil
588             ELSE
589                to_be_resorted => t_soil_av
590             ENDIF
591
592          CASE ( 'u' )
593             IF ( av == 0 )  THEN
594                to_be_resorted => u
595             ELSE
596                to_be_resorted => u_av
597             ENDIF
598
599          CASE ( 'v' )
600             IF ( av == 0 )  THEN
601                to_be_resorted => v
602             ELSE
603                to_be_resorted => v_av
604             ENDIF
605
606          CASE ( 'vpt' )
607             IF ( av == 0 )  THEN
608                to_be_resorted => vpt
609             ELSE
610                to_be_resorted => vpt_av
611             ENDIF
612
613          CASE ( 'w' )
614             IF ( av == 0 )  THEN
615                to_be_resorted => w
616             ELSE
617                to_be_resorted => w_av
618             ENDIF
619
620          CASE DEFAULT
621!
622!--          User defined quantity
623             CALL user_data_output_3d( av, do3d(av,if), found, local_pf,       &
624                                       nzb_do, nzt_do )
625             resorted = .TRUE.
626
627             IF ( .NOT. found )  THEN
628                message_string =  'no output available for: ' //               &
629                                  TRIM( do3d(av,if) )
630                CALL message( 'data_output_3d', 'PA0182', 0, 0, 0, 6, 0 )
631             ENDIF
632
633       END SELECT
634
635!
636!--    Resort the array to be output, if not done above
637       IF ( .NOT. resorted )  THEN
638          DO  i = nxlg, nxrg
639             DO  j = nysg, nyng
640                DO  k = nzb_do, nzt_do
641                   local_pf(i,j,k) = to_be_resorted(k,j,i)
642                ENDDO
643             ENDDO
644          ENDDO
645       ENDIF
646
647!
648!--    Output of the 3D-array
649#if defined( __parallel )
650       IF ( netcdf_data_format < 5 )  THEN
651!
652!--       Non-parallel netCDF output. Data is output in parallel in
653!--       FORTRAN binary format here, and later collected into one file by
654!--       combine_plot_fields
655          IF ( myid == 0 )  THEN
656             WRITE ( 30 )  time_since_reference_point,                   &
657                           do3d_time_count(av), av
658          ENDIF
659          DO  i = 0, io_blocks-1
660             IF ( i == io_group )  THEN
661                WRITE ( 30 )  nxlg, nxrg, nysg, nyng, nzb_do, nzt_do
662                WRITE ( 30 )  local_pf(:,:,nzb_do:nzt_do)
663             ENDIF
664#if defined( __parallel )
665             CALL MPI_BARRIER( comm2d, ierr )
666#endif
667          ENDDO
668
669       ELSE
670#if defined( __netcdf )
671!
672!--       Parallel output in netCDF4/HDF5 format.
673!--       Do not output redundant ghost point data except for the
674!--       boundaries of the total domain.
675          IF ( nxr == nx  .AND.  nyn /= ny )  THEN
676             nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if),  &
677                               local_pf(nxl:nxr+1,nys:nyn,nzb_do:nzt_do),    &
678                start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /),  &
679                count = (/ nxr-nxl+2, nyn-nys+1, nzt_do-nzb_do+1, 1 /) )
680          ELSEIF ( nxr /= nx  .AND.  nyn == ny )  THEN
681             nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if),  &
682                               local_pf(nxl:nxr,nys:nyn+1,nzb_do:nzt_do),    &
683                start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /),  &
684                count = (/ nxr-nxl+1, nyn-nys+2, nzt_do-nzb_do+1, 1 /) )
685          ELSEIF ( nxr == nx  .AND.  nyn == ny )  THEN
686             nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if),  &
687                             local_pf(nxl:nxr+1,nys:nyn+1,nzb_do:nzt_do  ),  &
688                start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /),  &
689                count = (/ nxr-nxl+2, nyn-nys+2, nzt_do-nzb_do+1, 1 /) )
690          ELSE
691             nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if),  &
692                                 local_pf(nxl:nxr,nys:nyn,nzb_do:nzt_do),    &
693                start = (/ nxl+1, nys+1, nzb_do+1, do3d_time_count(av) /),  &
694                count = (/ nxr-nxl+1, nyn-nys+1, nzt_do-nzb_do+1, 1 /) )
695          ENDIF
696          CALL netcdf_handle_error( 'data_output_3d', 386 )
697#endif
698       ENDIF
699#else
700#if defined( __netcdf )
701       nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if),        &
702                         local_pf(nxl:nxr+1,nys:nyn+1,nzb_do:nzt_do),        &
703                         start = (/ 1, 1, 1, do3d_time_count(av) /),     &
704                         count = (/ nx+2, ny+2, nzt_do-nzb_do+1, 1 /) )
705       CALL netcdf_handle_error( 'data_output_3d', 446 )
706#endif
707#endif
708
709       if = if + 1
710
711!
712!--    Deallocate temporary array
713       DEALLOCATE ( local_pf )
714
715    ENDDO
716
717    CALL cpu_log( log_point(14), 'data_output_3d', 'stop' )
718
719!
720!-- Formats.
7213300 FORMAT ('variable ',I4,'  file=',A,'  filetype=unformatted  skip=',I12/   &
722             'label = ',A,A)
723
724 END SUBROUTINE data_output_3d
Note: See TracBrowser for help on using the repository browser.