Index: palm/trunk/SOURCE/data_output_3d.f90
===================================================================
--- palm/trunk/SOURCE/data_output_3d.f90	(revision 392)
+++ palm/trunk/SOURCE/data_output_3d.f90	(revision 493)
@@ -76,14 +76,21 @@
 !-- Open output file.
 !-- Also creates coordinate and fld-file for AVS.
-!-- In case of a run on more than one PE, each PE opens its own file and
+!-- For classic or 64bit NetCDF output or output of other (old) data formats,
+!-- for a run on more than one PE, each PE opens its own file and
 !-- writes the data of its subdomain in binary format (regardless of the format
 !-- the user has requested). After the run, these files are combined to one
 !-- file by combine_plot_fields in the format requested by the user (netcdf
-!-- and/or avs). 
-    IF ( avs_output  .OR.  ( numprocs > 1 ) )  CALL check_open( 30 )
-
-#if defined( __netcdf )
-    IF ( myid == 0  .AND.  netcdf_output )  CALL check_open( 106+av*10 )
-#endif
+!-- and/or avs).
+!-- For NetCDF4/HDF5 output, data is written in parallel into one file.
+    IF ( netcdf_output )  THEN
+       IF ( netcdf_data_format < 3 )  THEN
+          CALL check_open( 30 )
+          IF ( myid == 0 )  CALL check_open( 106+av*10 )
+       ELSE
+          CALL check_open( 106+av*10 )
+       ENDIF
+    ELSE
+       IF ( avs_output  .OR.  ( numprocs > 1 ) )  CALL check_open( 30 )
+    ENDIF
 
 !
@@ -94,11 +101,13 @@
 !-- Update the NetCDF time axis
 #if defined( __netcdf )
-    do3d_time_count(av) = do3d_time_count(av) + 1
-    IF ( myid == 0  .AND.  netcdf_output )  THEN
-       nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_time_3d(av), &
-                               (/ time_since_reference_point /),  &
-                               start = (/ do3d_time_count(av) /), &
-                               count = (/ 1 /) )
-       CALL handle_netcdf_error( 'data_output_3d', 376 )
+    IF ( myid == 0  .OR.  netcdf_data_format > 2 )  THEN
+       do3d_time_count(av) = do3d_time_count(av) + 1
+       IF ( netcdf_output )  THEN
+          nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_time_3d(av), &
+                                  (/ time_since_reference_point /),  &
+                                  start = (/ do3d_time_count(av) /), &
+                                  count = (/ 1 /) )
+          CALL handle_netcdf_error( 'data_output_3d', 376 )
+       ENDIF
     ENDIF
 #endif
@@ -376,9 +385,45 @@
 !--       Uncompressed output.
 #if defined( __parallel )
-          IF ( netcdf_output  .AND.  myid == 0 )  THEN
-             WRITE ( 30 )  simulated_time, do3d_time_count(av), av
+          IF ( netcdf_output )  THEN
+             IF ( netcdf_data_format < 3 )  THEN
+!
+!--             Classic or 64bit format. Data is output in parallel in FORTRAN
+!--             binary format here, and later collected into one file by
+!--             combine_plot_fields
+                IF ( myid == 0 )  THEN
+                   WRITE ( 30 )  simulated_time, do3d_time_count(av), av
+                ENDIF
+                WRITE ( 30 )  nxl-1, nxr+1, nys-1, nyn+1, nzb, nz_do3d
+                WRITE ( 30 )  local_pf
+
+             ELSE
+!
+!--             Output in NetCDF4/HDF5 format.
+!--             Do not output redundant ghost point data except for the
+!--             boundaries of the total domain.
+                IF ( nxr == nx  .AND.  nyn /= ny )  THEN
+                   nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), &
+                                  local_pf(nxl:nxr+1,nys:nyn,nzb:nz_do3d),    &
+                      start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /), &
+                      count = (/ nxr-nxl+2, nyn-nys+1, nz_do3d-nzb+1, 1 /) )
+                ELSEIF ( nxr /= nx  .AND.  nyn == ny )  THEN
+                   nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), &
+                                  local_pf(nxl:nxr,nys:nyn+1,nzb:nz_do3d),    &
+                      start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /), &
+                      count = (/ nxr-nxl+1, nyn-nys+2, nz_do3d-nzb+1, 1 /) )
+                ELSEIF ( nxr == nx  .AND.  nyn == ny )  THEN
+                   nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), &
+                                  local_pf(nxl:nxr+1,nys:nyn+1,nzb:nz_do3d),  &
+                      start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /), &
+                      count = (/ nxr-nxl+2, nyn-nys+2, nz_do3d-nzb+1, 1 /) )
+                ELSE
+                   nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), &
+                                  local_pf(nxl:nxr,nys:nyn,nzb:nz_do3d),      &
+                      start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /), &
+                      count = (/ nxr-nxl+1, nyn-nys+1, nz_do3d-nzb+1, 1 /) )
+                ENDIF
+                CALL handle_netcdf_error( 'data_output_3d', 386 )
+             ENDIF
           ENDIF
-          WRITE ( 30 )  nxl-1, nxr+1, nys-1, nyn+1, nzb, nz_do3d
-          WRITE ( 30 )  local_pf
 #else
           IF ( avs_output )  THEN
@@ -387,9 +432,11 @@
 #if defined( __netcdf )
           IF ( netcdf_output )  THEN
-             nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if),       &
-                                  local_pf(nxl:nxr+1,nys:nyn+1,nzb:nz_do3d),  &
-                                  start = (/ 1, 1, 1, do3d_time_count(av) /), &
-                                  count = (/ nx+2, ny+2, nz_do3d-nzb+1, 1 /) )
-             CALL handle_netcdf_error( 'data_output_3d', 386 )
+
+             nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if),    &
+                               local_pf(nxl:nxr+1,nys:nyn+1,nzb:nz_do3d),  &
+                               start = (/ 1, 1, 1, do3d_time_count(av) /), &
+                               count = (/ nx+2, ny+2, nz_do3d-nzb+1, 1 /) )
+             CALL handle_netcdf_error( 'data_output_3d', 446 )
+
           ENDIF
 #endif
