Index: palm/trunk/SOURCE/data_output_2d.f90
===================================================================
--- palm/trunk/SOURCE/data_output_2d.f90	(revision 2292)
+++ palm/trunk/SOURCE/data_output_2d.f90	(revision 2512)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! upper bounds of cross section output changed from nx+1,ny+1 to nx,ny
+! no output of ghost layer data
+! 
+! 2292 2017-06-20 09:51:42Z schwenkel
 ! Implementation of new microphysic scheme: cloud_scheme = 'morrison' 
 ! includes two more prognostic equations for cloud drop concentration (nc)  
@@ -165,6 +169,6 @@
 ! Description:
 ! ------------
-!> Data output of horizontal cross-sections in netCDF format or binary format
-!> compatible to old graphic software iso2d.
+!> Data output of cross-sections in netCDF format or binary format
+!> to be later converted to NetCDF by helper routine combine_plot_fields.
 !> Attention: The position of the sectional planes is still not always computed 
 !> ---------  correctly. (zu is used always)!
@@ -201,6 +205,5 @@
         
     USE indices,                                                               &
-        ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg,       &
-               nz, nzb, nzt
+        ONLY:  nbgp, nx, nxl, nxr, ny, nyn, nys, nz, nzb, nzt
                
     USE kinds
@@ -271,5 +274,4 @@
     REAL(wp), DIMENSION(:,:), ALLOCATABLE   ::  local_2d            !<
     REAL(wp), DIMENSION(:,:), ALLOCATABLE   ::  local_2d_l          !<
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE   ::  tmp_2d              !< temporary field used to exchange surface-related quantities
 
     REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  local_pf            !<
@@ -303,5 +305,5 @@
        CASE ( 'xy' )
           s_ind = 1
-          ALLOCATE( level_z(nzb:nzt+1), local_2d(nxlg:nxrg,nysg:nyng) )
+          ALLOCATE( level_z(nzb:nzt+1), local_2d(nxl:nxr,nys:nyn) )
 
           IF ( netcdf_data_format > 4 )  THEN
@@ -311,5 +313,5 @@
              ENDDO
              ns = ns - 1
-             ALLOCATE( local_2d_sections(nxlg:nxrg,nysg:nyng,1:ns) )
+             ALLOCATE( local_2d_sections(nxl:nxr,nys:nyn,1:ns) )
              local_2d_sections = 0.0_wp
           ENDIF
@@ -325,5 +327,5 @@
              IF ( myid == 0 )  THEN
 #if defined( __parallel )
-                ALLOCATE( total_2d(-nbgp:nx+nbgp,-nbgp:ny+nbgp) )
+                ALLOCATE( total_2d(0:nx,0:ny) )
 #endif
              ENDIF
@@ -332,5 +334,5 @@
        CASE ( 'xz' )
           s_ind = 2
-          ALLOCATE( local_2d(nxlg:nxrg,nzb:nzt+1) )
+          ALLOCATE( local_2d(nxl:nxr,nzb:nzt+1) )
 
           IF ( netcdf_data_format > 4 )  THEN
@@ -340,6 +342,6 @@
              ENDDO
              ns = ns - 1
-             ALLOCATE( local_2d_sections(nxlg:nxrg,1:ns,nzb:nzt+1) )
-             ALLOCATE( local_2d_sections_l(nxlg:nxrg,1:ns,nzb:nzt+1) )
+             ALLOCATE( local_2d_sections(nxl:nxr,1:ns,nzb:nzt+1) )
+             ALLOCATE( local_2d_sections_l(nxl:nxr,1:ns,nzb:nzt+1) )
              local_2d_sections = 0.0_wp; local_2d_sections_l = 0.0_wp
           ENDIF
@@ -356,5 +358,5 @@
              IF ( myid == 0 )  THEN
 #if defined( __parallel )
-                ALLOCATE( total_2d(-nbgp:nx+nbgp,nzb:nzt+1) )
+                ALLOCATE( total_2d(0:nx,nzb:nzt+1) )
 #endif
              ENDIF
@@ -363,5 +365,5 @@
        CASE ( 'yz' )
           s_ind = 3
-          ALLOCATE( local_2d(nysg:nyng,nzb:nzt+1) )
+          ALLOCATE( local_2d(nys:nyn,nzb:nzt+1) )
 
           IF ( netcdf_data_format > 4 )  THEN
@@ -371,6 +373,6 @@
              ENDDO
              ns = ns - 1
-             ALLOCATE( local_2d_sections(1:ns,nysg:nyng,nzb:nzt+1) )
-             ALLOCATE( local_2d_sections_l(1:ns,nysg:nyng,nzb:nzt+1) )
+             ALLOCATE( local_2d_sections(1:ns,nys:nyn,nzb:nzt+1) )
+             ALLOCATE( local_2d_sections_l(1:ns,nys:nyn,nzb:nzt+1) )
              local_2d_sections = 0.0_wp; local_2d_sections_l = 0.0_wp
           ENDIF
@@ -387,5 +389,5 @@
              IF ( myid == 0 )  THEN
 #if defined( __parallel )
-                ALLOCATE( total_2d(-nbgp:ny+nbgp,nzb:nzt+1) )
+                ALLOCATE( total_2d(0:ny,nzb:nzt+1) )
 #endif
              ENDIF
@@ -434,10 +436,6 @@
 !
 !-- Allocate a temporary array for resorting (kji -> ijk).
-    ALLOCATE( local_pf(nxlg:nxrg,nysg:nyng,nzb:nzt+1) )
+    ALLOCATE( local_pf(nxl:nxr,nys:nyn,nzb:nzt+1) )
     local_pf = 0.0
-!
-!-- Allocate temporary array used for exchanging ghoist points of surface-data
-    ALLOCATE( tmp_2d(nysg:nyng,nxlg:nxrg) )
-    tmp_2d = 0.0
 
 !
@@ -481,6 +479,6 @@
              CASE ( 'lwp*_xy' )        ! 2d-array
                 IF ( av == 0 )  THEN
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                          local_pf(i,j,nzb+1) = SUM( ql(nzb:nzt,j,i) *          &
                                                     dzw(1:nzt+1) )
@@ -488,6 +486,6 @@
                    ENDDO
                 ELSE
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                          local_pf(i,j,nzb+1) = lwp_av(j,i)
                       ENDDO
@@ -519,28 +517,19 @@
                       i = surf_def_h(0)%i(m)
                       j = surf_def_h(0)%j(m)
-                      tmp_2d(j,i) = surf_def_h(0)%ol(m)
+                      local_pf(i,j,nzb+1) = surf_def_h(0)%ol(m)
                    ENDDO
                    DO  m = 1, surf_lsm_h%ns
                       i = surf_lsm_h%i(m)
                       j = surf_lsm_h%j(m)
-                      tmp_2d(j,i) = surf_lsm_h%ol(m)
+                      local_pf(i,j,nzb+1) = surf_lsm_h%ol(m)
                    ENDDO
                    DO  m = 1, surf_usm_h%ns
                       i = surf_usm_h%i(m)
                       j = surf_usm_h%j(m)
-                      tmp_2d(j,i) = surf_usm_h%ol(m)
-                   ENDDO
-
-                   CALL exchange_horiz_2d( tmp_2d, nbgp )
-
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
-                         local_pf(i,j,nzb+1) = tmp_2d(j,i)
-                      ENDDO
-                   ENDDO
-
-                ELSE
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+                      local_pf(i,j,nzb+1) = surf_usm_h%ol(m)
+                   ENDDO
+                ELSE
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                          local_pf(i,j,nzb+1) = ol_av(j,i)
                       ENDDO
@@ -565,10 +554,10 @@
                    IF ( simulated_time >= particle_advection_start )  THEN
                       tend = prt_count
-                      CALL exchange_horiz( tend, nbgp )
+!                      CALL exchange_horiz( tend, nbgp )
                    ELSE
                       tend = 0.0_wp
                    ENDIF
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                          DO  k = nzb, nzt+1
                             local_pf(i,j,k) = tend(k,j,i)
@@ -578,5 +567,5 @@
                    resorted = .TRUE.
                 ELSE
-                   CALL exchange_horiz( pc_av, nbgp )
+!                   CALL exchange_horiz( pc_av, nbgp )
                    to_be_resorted => pc_av
                 ENDIF
@@ -610,10 +599,10 @@
                          ENDDO
                       ENDDO
-                      CALL exchange_horiz( tend, nbgp )
+!                      CALL exchange_horiz( tend, nbgp )
                    ELSE
                       tend = 0.0_wp
                    ENDIF
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                          DO  k = nzb, nzt+1
                             local_pf(i,j,k) = tend(k,j,i)
@@ -623,12 +612,12 @@
                    resorted = .TRUE.
                 ELSE
-                   CALL exchange_horiz( pr_av, nbgp )
+!                   CALL exchange_horiz( pr_av, nbgp )
                    to_be_resorted => pr_av
                 ENDIF
 
              CASE ( 'pra*_xy' )        ! 2d-array / integral quantity => no av
-                CALL exchange_horiz_2d( precipitation_amount )
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+!                CALL exchange_horiz_2d( precipitation_amount )
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                       local_pf(i,j,nzb+1) =  precipitation_amount(j,i)
                    ENDDO
@@ -641,14 +630,14 @@
              CASE ( 'prr*_xy' )        ! 2d-array
                 IF ( av == 0 )  THEN
-                   CALL exchange_horiz_2d( prr(nzb+1,:,:) )
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+!                   CALL exchange_horiz_2d( prr(nzb+1,:,:) )
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                          local_pf(i,j,nzb+1) = prr(nzb+1,j,i) * hyrho(nzb+1)
                       ENDDO
                    ENDDO
                 ELSE
-                   CALL exchange_horiz_2d( prr_av(nzb+1,:,:) )
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+!                   CALL exchange_horiz_2d( prr_av(nzb+1,:,:) )
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                          local_pf(i,j,nzb+1) = prr_av(nzb+1,j,i) * hyrho(nzb+1)
                       ENDDO
@@ -661,7 +650,7 @@
              CASE ( 'prr_xy', 'prr_xz', 'prr_yz' )
                 IF ( av == 0 )  THEN
-                   CALL exchange_horiz( prr, nbgp )
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+!                   CALL exchange_horiz( prr, nbgp )
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                          DO  k = nzb, nzt+1
                             local_pf(i,j,k) = prr(k,j,i) * hyrho(nzb+1)
@@ -670,7 +659,7 @@
                    ENDDO
                 ELSE
-                   CALL exchange_horiz( prr_av, nbgp )
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+!                   CALL exchange_horiz( prr_av, nbgp )
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                          DO  k = nzb, nzt+1
                             local_pf(i,j,k) = prr_av(k,j,i) * hyrho(nzb+1)
@@ -687,6 +676,6 @@
                       to_be_resorted => pt
                    ELSE
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                             DO  k = nzb, nzt+1
                                local_pf(i,j,k) = pt(k,j,i) + l_d_cp *          &
@@ -762,10 +751,10 @@
                          ENDDO
                       ENDDO
-                      CALL exchange_horiz( tend, nbgp )
+!                      CALL exchange_horiz( tend, nbgp )
                    ELSE
                       tend = 0.0_wp
                    ENDIF
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                          DO  k = nzb, nzt+1
                             local_pf(i,j,k) = tend(k,j,i)
@@ -775,5 +764,5 @@
                    resorted = .TRUE.
                 ELSE
-                   CALL exchange_horiz( ql_vp_av, nbgp )
+!                   CALL exchange_horiz( ql_vp_av, nbgp )
                    to_be_resorted => ql_vp
                 ENDIF
@@ -793,27 +782,19 @@
                       i = surf_def_h(0)%i(m)
                       j = surf_def_h(0)%j(m)
-                      tmp_2d(j,i) = surf_def_h(0)%qsws(m)
+                      local_pf(i,j,nzb+1) = surf_def_h(0)%qsws(m)
                    ENDDO
                    DO  m = 1, surf_lsm_h%ns
                       i = surf_lsm_h%i(m)
                       j = surf_lsm_h%j(m)
-                      tmp_2d(j,i) = surf_lsm_h%qsws(m)
+                      local_pf(i,j,nzb+1) = surf_lsm_h%qsws(m)
                    ENDDO
                    DO  m = 1, surf_usm_h%ns
                       i = surf_usm_h%i(m)
                       j = surf_usm_h%j(m)
-                      tmp_2d(j,i) = surf_usm_h%qsws(m)
-                   ENDDO
-
-                   CALL exchange_horiz_2d( tmp_2d, nbgp )
-
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
-                         local_pf(i,j,nzb+1) = tmp_2d(j,i)
-                      ENDDO
-                   ENDDO
-                ELSE
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng 
+                      local_pf(i,j,nzb+1) = surf_usm_h%qsws(m)
+                   ENDDO
+                ELSE
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn 
                          local_pf(i,j,nzb+1) =  qsws_av(j,i)
                       ENDDO
@@ -826,6 +807,6 @@
              CASE ( 'qv_xy', 'qv_xz', 'qv_yz' )
                 IF ( av == 0 )  THEN
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                          DO  k = nzb, nzt+1
                             local_pf(i,j,k) = q(k,j,i) - ql(k,j,i)
@@ -867,27 +848,19 @@
                       i = surf_def_h(0)%i(m)
                       j = surf_def_h(0)%j(m)
-                      tmp_2d(j,i) = surf_def_h(0)%shf(m)
+                      local_pf(i,j,nzb+1) = surf_def_h(0)%shf(m)
                    ENDDO
                    DO  m = 1, surf_lsm_h%ns
                       i = surf_lsm_h%i(m)
                       j = surf_lsm_h%j(m)
-                      tmp_2d(j,i) = surf_lsm_h%shf(m)
+                      local_pf(i,j,nzb+1) = surf_lsm_h%shf(m)
                    ENDDO
                    DO  m = 1, surf_usm_h%ns
                       i = surf_usm_h%i(m)
                       j = surf_usm_h%j(m)
-                      tmp_2d(j,i) = surf_usm_h%shf(m)
-                   ENDDO
-
-                   CALL exchange_horiz_2d( tmp_2d, nbgp )
-
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
-                         local_pf(i,j,nzb+1) = tmp_2d(j,i)
-                      ENDDO
-                   ENDDO
-                ELSE
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+                      local_pf(i,j,nzb+1) = surf_usm_h%shf(m)
+                   ENDDO
+                ELSE
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                          local_pf(i,j,nzb+1) =  shf_av(j,i)
                       ENDDO
@@ -903,27 +876,19 @@
                       i = surf_def_h(0)%i(m)
                       j = surf_def_h(0)%j(m)
-                      tmp_2d(j,i) = surf_def_h(0)%ssws(m)
+                      local_pf(i,j,nzb+1) = surf_def_h(0)%ssws(m)
                    ENDDO
                    DO  m = 1, surf_lsm_h%ns
                       i = surf_lsm_h%i(m)
                       j = surf_lsm_h%j(m)
-                      tmp_2d(j,i) = surf_lsm_h%ssws(m)
+                      local_pf(i,j,nzb+1) = surf_lsm_h%ssws(m)
                    ENDDO
                    DO  m = 1, surf_usm_h%ns
                       i = surf_usm_h%i(m)
                       j = surf_usm_h%j(m)
-                      tmp_2d(j,i) = surf_usm_h%ssws(m)
-                   ENDDO
-
-                   CALL exchange_horiz_2d( tmp_2d, nbgp )
-
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
-                         local_pf(i,j,nzb+1) = tmp_2d(j,i)
-                      ENDDO
-                   ENDDO
-                ELSE
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng 
+                      local_pf(i,j,nzb+1) = surf_usm_h%ssws(m)
+                   ENDDO
+                ELSE
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn 
                          local_pf(i,j,nzb+1) =  ssws_av(j,i)
                       ENDDO
@@ -939,28 +904,19 @@
                       i = surf_def_h(0)%i(m)
                       j = surf_def_h(0)%j(m)
-                      tmp_2d(j,i) = surf_def_h(0)%ts(m)
+                      local_pf(i,j,nzb+1) = surf_def_h(0)%ts(m)
                    ENDDO
                    DO  m = 1, surf_lsm_h%ns
                       i = surf_lsm_h%i(m)
                       j = surf_lsm_h%j(m)
-                      tmp_2d(j,i) = surf_lsm_h%ts(m)
+                      local_pf(i,j,nzb+1) = surf_lsm_h%ts(m)
                    ENDDO
                    DO  m = 1, surf_usm_h%ns
                       i = surf_usm_h%i(m)
                       j = surf_usm_h%j(m)
-                      tmp_2d(j,i) = surf_usm_h%ts(m)
-                   ENDDO
-
-                   CALL exchange_horiz_2d( tmp_2d, nbgp )
-
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
-                         local_pf(i,j,nzb+1) = tmp_2d(j,i)
-                      ENDDO
-                   ENDDO
-
-                ELSE
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+                      local_pf(i,j,nzb+1) = surf_usm_h%ts(m)
+                   ENDDO
+                ELSE
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                          local_pf(i,j,nzb+1) = ts_av(j,i)
                       ENDDO
@@ -990,27 +946,19 @@
                       i = surf_def_h(0)%i(m)
                       j = surf_def_h(0)%j(m)
-                      tmp_2d(j,i) = surf_def_h(0)%us(m)
+                      local_pf(i,j,nzb+1) = surf_def_h(0)%us(m)
                    ENDDO
                    DO  m = 1, surf_lsm_h%ns
                       i = surf_lsm_h%i(m)
                       j = surf_lsm_h%j(m)
-                      tmp_2d(j,i) = surf_lsm_h%us(m)
+                      local_pf(i,j,nzb+1) = surf_lsm_h%us(m)
                    ENDDO
                    DO  m = 1, surf_usm_h%ns
                       i = surf_usm_h%i(m)
                       j = surf_usm_h%j(m)
-                      tmp_2d(j,i) = surf_usm_h%us(m)
-                   ENDDO
-
-                   CALL exchange_horiz_2d( tmp_2d, nbgp )
-
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
-                         local_pf(i,j,nzb+1) = tmp_2d(j,i)
-                      ENDDO
-                   ENDDO
-                ELSE
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+                      local_pf(i,j,nzb+1) = surf_usm_h%us(m)
+                   ENDDO
+                ELSE
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                          local_pf(i,j,nzb+1) = us_av(j,i)
                       ENDDO
@@ -1056,28 +1004,19 @@
                       i = surf_def_h(0)%i(m)
                       j = surf_def_h(0)%j(m)
-                      tmp_2d(j,i) = surf_def_h(0)%z0(m)
+                      local_pf(i,j,nzb+1) = surf_def_h(0)%z0(m)
                    ENDDO
                    DO  m = 1, surf_lsm_h%ns
                       i = surf_lsm_h%i(m)
                       j = surf_lsm_h%j(m)
-                      tmp_2d(j,i) = surf_lsm_h%z0(m)
+                      local_pf(i,j,nzb+1) = surf_lsm_h%z0(m)
                    ENDDO
                    DO  m = 1, surf_usm_h%ns
                       i = surf_usm_h%i(m)
                       j = surf_usm_h%j(m)
-                      tmp_2d(j,i) = surf_usm_h%z0(m)
-                   ENDDO
-
-                   CALL exchange_horiz_2d( tmp_2d, nbgp )
-
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
-                         local_pf(i,j,nzb+1) = tmp_2d(j,i)
-                      ENDDO
-                   ENDDO
-
-                ELSE
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+                      local_pf(i,j,nzb+1) = surf_usm_h%z0(m)
+                   ENDDO
+                ELSE
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                          local_pf(i,j,nzb+1) =  z0_av(j,i)
                       ENDDO
@@ -1093,27 +1032,19 @@
                       i = surf_def_h(0)%i(m)
                       j = surf_def_h(0)%j(m)
-                      tmp_2d(j,i) = surf_def_h(0)%z0h(m)
+                      local_pf(i,j,nzb+1) = surf_def_h(0)%z0h(m)
                    ENDDO
                    DO  m = 1, surf_lsm_h%ns
                       i = surf_lsm_h%i(m)
                       j = surf_lsm_h%j(m)
-                      tmp_2d(j,i) = surf_lsm_h%z0h(m)
+                      local_pf(i,j,nzb+1) = surf_lsm_h%z0h(m)
                    ENDDO
                    DO  m = 1, surf_usm_h%ns
                       i = surf_usm_h%i(m)
                       j = surf_usm_h%j(m)
-                      tmp_2d(j,i) = surf_usm_h%z0h(m)
-                   ENDDO
-
-                   CALL exchange_horiz_2d( tmp_2d, nbgp )
-
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
-                         local_pf(i,j,nzb+1) = tmp_2d(j,i)
-                      ENDDO
-                   ENDDO
-                ELSE
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+                      local_pf(i,j,nzb+1) = surf_usm_h%z0h(m)
+                   ENDDO
+                ELSE
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                          local_pf(i,j,nzb+1) =  z0h_av(j,i)
                       ENDDO
@@ -1129,27 +1060,19 @@
                       i = surf_def_h(0)%i(m)
                       j = surf_def_h(0)%j(m)
-                      tmp_2d(j,i) = surf_def_h(0)%z0q(m)
+                      local_pf(i,j,nzb+1) = surf_def_h(0)%z0q(m)
                    ENDDO
                    DO  m = 1, surf_lsm_h%ns
                       i = surf_lsm_h%i(m)
                       j = surf_lsm_h%j(m)
-                      tmp_2d(j,i) = surf_lsm_h%z0q(m)
+                      local_pf(i,j,nzb+1) = surf_lsm_h%z0q(m)
                    ENDDO
                    DO  m = 1, surf_usm_h%ns
                       i = surf_usm_h%i(m)
                       j = surf_usm_h%j(m)
-                      tmp_2d(j,i) = surf_usm_h%z0q(m)
-                   ENDDO
-
-                   CALL exchange_horiz_2d( tmp_2d, nbgp )
-
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
-                         local_pf(i,j,nzb+1) = tmp_2d(j,i)
-                      ENDDO
-                   ENDDO
-                ELSE
-                   DO  i = nxlg, nxrg
-                      DO  j = nysg, nyng
+                      local_pf(i,j,nzb+1) = surf_usm_h%z0q(m)
+                   ENDDO
+                ELSE
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
                          local_pf(i,j,nzb+1) =  z0q_av(j,i)
                       ENDDO
@@ -1206,6 +1129,6 @@
 !--       Resort the array to be output, if not done above
           IF ( .NOT. resorted )  THEN
-             DO  i = nxlg, nxrg
-                DO  j = nysg, nyng
+             DO  i = nxl, nxr
+                DO  j = nys, nyn
                    DO  k = nzb_do, nzt_do
                       local_pf(i,j,k) = to_be_resorted(k,j,i)
@@ -1269,6 +1192,6 @@
 !--                   Carry out the averaging (all data are on the PE)
                       DO  k = nzb_do, nzt_do
-                         DO  j = nysg, nyng
-                            DO  i = nxlg, nxrg
+                         DO  j = nys, nyn
+                            DO  i = nxl, nxr
                                local_2d(i,j) = local_2d(i,j) + local_pf(i,j,k)
                             ENDDO
@@ -1300,6 +1223,6 @@
 !--                   here on a local array and will be written to the output
 !--                   file afterwards to increase the performance.
-                      DO  i = nxlg, nxrg
-                         DO  j = nysg, nyng
+                      DO  i = nxl, nxr
+                         DO  j = nys, nyn
                             local_2d_sections(i,j,iis) = local_2d(i,j)
                          ENDDO
@@ -1319,5 +1242,5 @@
                          DO  i = 0, io_blocks-1
                             IF ( i == io_group )  THEN
-                               WRITE ( 21 )  nxlg, nxrg, nysg, nyng, nysg, nyng
+                               WRITE ( 21 )  nxl, nxr, nys, nyn, nys, nyn
                                WRITE ( 21 )  local_2d
                             ENDIF
@@ -1335,9 +1258,9 @@
                          CALL MPI_BARRIER( comm2d, ierr )
 
-                         ngp = ( nxrg-nxlg+1 ) * ( nyng-nysg+1 )
+                         ngp = ( nxr-nxl+1 ) * ( nyn-nys+1 )
                          IF ( myid == 0 )  THEN
 !
 !--                         Local array can be relocated directly.
-                            total_2d(nxlg:nxrg,nysg:nyng) = local_2d
+                            total_2d(nxl:nxr,nys:nyn) = local_2d
 !
 !--                         Receive data from all other PEs.
@@ -1361,5 +1284,5 @@
 !--                         Relocate the local array for the next loop increment
                             DEALLOCATE( local_2d )
-                            ALLOCATE( local_2d(nxlg:nxrg,nysg:nyng) )
+                            ALLOCATE( local_2d(nxl:nxr,nys:nyn) )
 
 #if defined( __netcdf )
@@ -1367,13 +1290,13 @@
                                nc_stat = NF90_PUT_VAR( id_set_xy(av),       &
                                                        id_var_do2d(av,if),  &
-                                                   total_2d(0:nx+1,0:ny+1), &
+                                                       total_2d(0:nx,0:ny), &
                              start = (/ 1, 1, 1, do2d_xy_time_count(av) /), &
-                                             count = (/ nx+2, ny+2, 1, 1 /) )
+                                             count = (/ nx+1, ny+1, 1, 1 /) )
                             ELSE
                                nc_stat = NF90_PUT_VAR( id_set_xy(av),       &
                                                        id_var_do2d(av,if),  &
-                                                   total_2d(0:nx+1,0:ny+1), &
+                                                       total_2d(0:nx,0:ny), &
                             start = (/ 1, 1, is, do2d_xy_time_count(av) /), &
-                                             count = (/ nx+2, ny+2, 1, 1 /) )
+                                             count = (/ nx+1, ny+1, 1, 1 /) )
                             ENDIF
                             CALL netcdf_handle_error( 'data_output_2d', 54 )
@@ -1383,11 +1306,11 @@
 !
 !--                         First send the local index limits to PE0
-                            ind(1) = nxlg; ind(2) = nxrg
-                            ind(3) = nysg; ind(4) = nyng
+                            ind(1) = nxl; ind(2) = nxr
+                            ind(3) = nys; ind(4) = nyn
                             CALL MPI_SEND( ind(1), 4, MPI_INTEGER, 0, 0,       &
                                            comm2d, ierr )
 !
 !--                         Send data to PE0
-                            CALL MPI_SEND( local_2d(nxlg,nysg), ngp,           &
+                            CALL MPI_SEND( local_2d(nxl,nys), ngp,             &
                                            MPI_REAL, 0, 1, comm2d, ierr )
                          ENDIF
@@ -1405,13 +1328,13 @@
                       nc_stat = NF90_PUT_VAR( id_set_xy(av),                &
                                               id_var_do2d(av,if),           &
-                                             local_2d(nxl:nxr+1,nys:nyn+1), &
+                                              local_2d(nxl:nxr,nys:nyn),    &
                              start = (/ 1, 1, 1, do2d_xy_time_count(av) /), &
-                                           count = (/ nx+2, ny+2, 1, 1 /) )
+                                           count = (/ nx+1, ny+1, 1, 1 /) )
                    ELSE
                       nc_stat = NF90_PUT_VAR( id_set_xy(av),                &
                                               id_var_do2d(av,if),           &
-                                             local_2d(nxl:nxr+1,nys:nyn+1), &
+                                              local_2d(nxl:nxr,nys:nyn),    &
                             start = (/ 1, 1, is, do2d_xy_time_count(av) /), &
-                                           count = (/ nx+2, ny+2, 1, 1 /) )
+                                           count = (/ nx+1, ny+1, 1, 1 /) )
                    ENDIF
                    CALL netcdf_handle_error( 'data_output_2d', 447 )
@@ -1455,12 +1378,12 @@
                    IF ( section(is,s_ind) == -1 )  THEN
 
-                      ALLOCATE( local_2d_l(nxlg:nxrg,nzb_do:nzt_do) )
+                      ALLOCATE( local_2d_l(nxl:nxr,nzb_do:nzt_do) )
                       local_2d_l = 0.0_wp
-                      ngp = ( nxrg-nxlg + 1 ) * ( nzt_do-nzb_do + 1 )
+                      ngp = ( nxr-nxl + 1 ) * ( nzt_do-nzb_do + 1 )
 !
 !--                   First local averaging on the PE
                       DO  k = nzb_do, nzt_do
                          DO  j = nys, nyn
-                            DO  i = nxlg, nxrg
+                            DO  i = nxl, nxr
                                local_2d_l(i,k) = local_2d_l(i,k) +             &
                                                  local_pf(i,j,k)
@@ -1472,6 +1395,6 @@
 !--                   Now do the averaging over all PEs along y
                       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
-                      CALL MPI_ALLREDUCE( local_2d_l(nxlg,nzb_do),                &
-                                          local_2d(nxlg,nzb_do), ngp, MPI_REAL,   &
+                      CALL MPI_ALLREDUCE( local_2d_l(nxl,nzb_do),                &
+                                          local_2d(nxl,nzb_do), ngp, MPI_REAL,   &
                                           MPI_SUM, comm1dy, ierr )
 #else
@@ -1508,5 +1431,5 @@
 !--                      stored here on a local array and will be written to the
 !--                      output file afterwards to increase the performance.
-                         DO  i = nxlg, nxrg
+                         DO  i = nxl, nxr
                             DO  k = nzb_do, nzt_do
                                local_2d_sections_l(i,is,k) = local_2d(i,k)
@@ -1536,5 +1459,5 @@
                                       nys-1 == -1 ) )                          &
                                THEN
-                                  WRITE (22)  nxlg, nxrg, nzb_do, nzt_do, nzb, nzt+1
+                                  WRITE (22)  nxl, nxr, nzb_do, nzt_do, nzb, nzt+1
                                   WRITE (22)  local_2d
                                ELSE
@@ -1555,5 +1478,5 @@
                          CALL MPI_BARRIER( comm2d, ierr )
 
-                         ngp = ( nxrg-nxlg + 1 ) * ( nzt_do-nzb_do + 1 )
+                         ngp = ( nxr-nxl + 1 ) * ( nzt_do-nzb_do + 1 )
                          IF ( myid == 0 )  THEN
 !
@@ -1563,5 +1486,5 @@
                                  ( section(is,s_ind) == -1  .AND.               &
                                    nys-1 == -1 ) )  THEN
-                               total_2d(nxlg:nxrg,nzb_do:nzt_do) = local_2d
+                               total_2d(nxl:nxr,nzb_do:nzt_do) = local_2d
                             ENDIF
 !
@@ -1592,12 +1515,12 @@
 !--                         Relocate the local array for the next loop increment
                             DEALLOCATE( local_2d )
-                            ALLOCATE( local_2d(nxlg:nxrg,nzb_do:nzt_do) )
+                            ALLOCATE( local_2d(nxl:nxr,nzb_do:nzt_do) )
 
 #if defined( __netcdf )
-                            nc_stat = NF90_PUT_VAR( id_set_xz(av),          &
-                                                 id_var_do2d(av,if),        &
-                                                 total_2d(0:nx+1,nzb_do:nzt_do),&
-                            start = (/ 1, is, 1, do2d_xz_time_count(av) /), &
-                                             count = (/ nx+2, 1, nzt_do-nzb_do+1, 1 /) )
+                            nc_stat = NF90_PUT_VAR( id_set_xz(av),             &
+                                                 id_var_do2d(av,if),           &
+                                                 total_2d(0:nx,nzb_do:nzt_do), &
+                               start = (/ 1, is, 1, do2d_xz_time_count(av) /), &
+                                          count = (/ nx+1, 1, nzt_do-nzb_do+1, 1 /) )
                             CALL netcdf_handle_error( 'data_output_2d', 58 )
 #endif
@@ -1611,5 +1534,5 @@
                                  ( section(is,s_ind) == -1  .AND.  nys-1 == -1 ) ) &
                             THEN
-                               ind(1) = nxlg; ind(2) = nxrg
+                               ind(1) = nxl; ind(2) = nxr
                                ind(3) = nzb_do;   ind(4) = nzt_do
                             ELSE
@@ -1622,5 +1545,5 @@
 !--                         If applicable, send data to PE0.
                             IF ( ind(1) /= -9999 )  THEN
-                               CALL MPI_SEND( local_2d(nxlg,nzb_do), ngp,         &
+                               CALL MPI_SEND( local_2d(nxl,nzb_do), ngp,         &
                                               MPI_REAL, 0, 1, comm2d, ierr )
                             ENDIF
@@ -1638,7 +1561,7 @@
                    nc_stat = NF90_PUT_VAR( id_set_xz(av),                   &
                                            id_var_do2d(av,if),              &
-                                           local_2d(nxl:nxr+1,nzb_do:nzt_do),   &
+                                           local_2d(nxl:nxr,nzb_do:nzt_do), &
                             start = (/ 1, is, 1, do2d_xz_time_count(av) /), &
-                                           count = (/ nx+2, 1, nzt_do-nzb_do+1, 1 /) )
+                                       count = (/ nx+1, 1, nzt_do-nzb_do+1, 1 /) )
                    CALL netcdf_handle_error( 'data_output_2d', 451 )
 #endif
@@ -1673,11 +1596,11 @@
                    IF ( section(is,s_ind) == -1 )  THEN
 
-                      ALLOCATE( local_2d_l(nysg:nyng,nzb_do:nzt_do) )
+                      ALLOCATE( local_2d_l(nys:nyn,nzb_do:nzt_do) )
                       local_2d_l = 0.0_wp
-                      ngp = ( nyng-nysg+1 ) * ( nzt_do-nzb_do+1 )
+                      ngp = ( nyn-nys+1 ) * ( nzt_do-nzb_do+1 )
 !
 !--                   First local averaging on the PE
                       DO  k = nzb_do, nzt_do
-                         DO  j = nysg, nyng
+                         DO  j = nys, nyn
                             DO  i = nxl, nxr
                                local_2d_l(j,k) = local_2d_l(j,k) +             &
@@ -1690,6 +1613,6 @@
 !--                   Now do the averaging over all PEs along x
                       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
-                      CALL MPI_ALLREDUCE( local_2d_l(nysg,nzb_do),                &
-                                          local_2d(nysg,nzb_do), ngp, MPI_REAL,   &
+                      CALL MPI_ALLREDUCE( local_2d_l(nys,nzb_do),                &
+                                          local_2d(nys,nzb_do), ngp, MPI_REAL,   &
                                           MPI_SUM, comm1dx, ierr )
 #else
@@ -1726,5 +1649,5 @@
 !--                      stored here on a local array and will be written to the
 !--                      output file afterwards to increase the performance.
-                         DO  j = nysg, nyng
+                         DO  j = nys, nyn
                             DO  k = nzb_do, nzt_do
                                local_2d_sections_l(is,j,k) = local_2d(j,k)
@@ -1754,5 +1677,5 @@
                                       nxl-1 == -1 ) )                          &
                                THEN
-                                  WRITE (23)  nysg, nyng, nzb_do, nzt_do, nzb, nzt+1
+                                  WRITE (23)  nys, nyn, nzb_do, nzt_do, nzb, nzt+1
                                   WRITE (23)  local_2d
                                ELSE
@@ -1773,5 +1696,5 @@
                          CALL MPI_BARRIER( comm2d, ierr )
 
-                         ngp = ( nyng-nysg+1 ) * ( nzt_do-nzb_do+1 )
+                         ngp = ( nyn-nys+1 ) * ( nzt_do-nzb_do+1 )
                          IF ( myid == 0 )  THEN
 !
@@ -1781,5 +1704,5 @@
                                  ( section(is,s_ind) == -1  .AND.  nxl-1 == -1 ) ) &
                             THEN
-                               total_2d(nysg:nyng,nzb_do:nzt_do) = local_2d
+                               total_2d(nys:nyn,nzb_do:nzt_do) = local_2d
                             ENDIF
 !
@@ -1810,12 +1733,12 @@
 !--                         Relocate the local array for the next loop increment
                             DEALLOCATE( local_2d )
-                            ALLOCATE( local_2d(nysg:nyng,nzb_do:nzt_do) )
+                            ALLOCATE( local_2d(nys:nyn,nzb_do:nzt_do) )
 
 #if defined( __netcdf )
-                            nc_stat = NF90_PUT_VAR( id_set_yz(av),          &
-                                                 id_var_do2d(av,if),        &
-                                                 total_2d(0:ny+1,nzb_do:nzt_do),&
-                            start = (/ is, 1, 1, do2d_yz_time_count(av) /), &
-                                             count = (/ 1, ny+2, nzt_do-nzb_do+1, 1 /) )
+                            nc_stat = NF90_PUT_VAR( id_set_yz(av),             &
+                                                 id_var_do2d(av,if),           &
+                                                 total_2d(0:ny,nzb_do:nzt_do), &
+                            start = (/ is, 1, 1, do2d_yz_time_count(av) /),    &
+                                       count = (/ 1, ny+1, nzt_do-nzb_do+1, 1 /) )
                             CALL netcdf_handle_error( 'data_output_2d', 61 )
 #endif
@@ -1829,5 +1752,5 @@
                                  ( section(is,s_ind) == -1  .AND.  nxl-1 == -1 ) ) &
                             THEN
-                               ind(1) = nysg; ind(2) = nyng
+                               ind(1) = nys; ind(2) = nyn
                                ind(3) = nzb_do;   ind(4) = nzt_do
                             ELSE
@@ -1840,5 +1763,5 @@
 !--                         If applicable, send data to PE0.
                             IF ( ind(1) /= -9999 )  THEN
-                               CALL MPI_SEND( local_2d(nysg,nzb_do), ngp,         &
+                               CALL MPI_SEND( local_2d(nys,nzb_do), ngp,         &
                                               MPI_REAL, 0, 1, comm2d, ierr )
                             ENDIF
@@ -1856,7 +1779,7 @@
                    nc_stat = NF90_PUT_VAR( id_set_yz(av),                   &
                                            id_var_do2d(av,if),              &
-                                           local_2d(nys:nyn+1,nzb_do:nzt_do),   &
+                                           local_2d(nys:nyn,nzb_do:nzt_do), &
                             start = (/ is, 1, 1, do2d_xz_time_count(av) /), &
-                                           count = (/ 1, ny+2, nzt_do-nzb_do+1, 1 /) )
+                                           count = (/ 1, ny+1, nzt_do-nzb_do+1, 1 /) )
                    CALL netcdf_handle_error( 'data_output_2d', 452 )
 #endif
@@ -1887,35 +1810,35 @@
 !--                   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_xy(av),                &
-                                                 id_var_do2d(av,if),           &
-                                                 local_2d_sections(nxl:nxr+1,  &
-                                                    nys:nyn,1:nis),            &
-                                                 start = (/ nxl+1, nys+1, 1,   &
-                                                    do2d_xy_time_count(av) /), &
-                                                 count = (/ nxr-nxl+2,         &
-                                                            nyn-nys+1, nis, 1  &
-                                                          /) )
-                      ELSEIF ( nxr /= nx  .AND.  nyn == ny )  THEN
-                         nc_stat = NF90_PUT_VAR( id_set_xy(av),                &
-                                                 id_var_do2d(av,if),           &
-                                                 local_2d_sections(nxl:nxr,    &
-                                                    nys:nyn+1,1:nis),          &
-                                                 start = (/ nxl+1, nys+1, 1,   &
-                                                    do2d_xy_time_count(av) /), &
-                                                 count = (/ nxr-nxl+1,         &
-                                                            nyn-nys+2, nis, 1  &
-                                                          /) )
-                      ELSEIF ( nxr == nx  .AND.  nyn == ny )  THEN
-                         nc_stat = NF90_PUT_VAR( id_set_xy(av),                &
-                                                 id_var_do2d(av,if),           &
-                                                 local_2d_sections(nxl:nxr+1,  &
-                                                    nys:nyn+1,1:nis),          &
-                                                 start = (/ nxl+1, nys+1, 1,   &
-                                                    do2d_xy_time_count(av) /), &
-                                                 count = (/ nxr-nxl+2,         &
-                                                            nyn-nys+2, nis, 1  &
-                                                          /) )
-                      ELSE
+!                      IF ( nxr == nx  .AND.  nyn /= ny )  THEN
+!                         nc_stat = NF90_PUT_VAR( id_set_xy(av),                &
+!                                                 id_var_do2d(av,if),           &
+!                                                 local_2d_sections(nxl:nxr+1,  &
+!                                                    nys:nyn,1:nis),            &
+!                                                 start = (/ nxl+1, nys+1, 1,   &
+!                                                    do2d_xy_time_count(av) /), &
+!                                                 count = (/ nxr-nxl+2,         &
+!                                                            nyn-nys+1, nis, 1  &
+!                                                          /) )
+!                      ELSEIF ( nxr /= nx  .AND.  nyn == ny )  THEN
+!                         nc_stat = NF90_PUT_VAR( id_set_xy(av),                &
+!                                                 id_var_do2d(av,if),           &
+!                                                 local_2d_sections(nxl:nxr,    &
+!                                                    nys:nyn+1,1:nis),          &
+!                                                 start = (/ nxl+1, nys+1, 1,   &
+!                                                    do2d_xy_time_count(av) /), &
+!                                                 count = (/ nxr-nxl+1,         &
+!                                                            nyn-nys+2, nis, 1  &
+!                                                          /) )
+!                      ELSEIF ( nxr == nx  .AND.  nyn == ny )  THEN
+!                         nc_stat = NF90_PUT_VAR( id_set_xy(av),                &
+!                                                 id_var_do2d(av,if),           &
+!                                                 local_2d_sections(nxl:nxr+1,  &
+!                                                    nys:nyn+1,1:nis),          &
+!                                                 start = (/ nxl+1, nys+1, 1,   &
+!                                                    do2d_xy_time_count(av) /), &
+!                                                 count = (/ nxr-nxl+2,         &
+!                                                            nyn-nys+2, nis, 1  &
+!                                                          /) )
+!                      ELSE
                          nc_stat = NF90_PUT_VAR( id_set_xy(av),                &
                                                  id_var_do2d(av,if),           &
@@ -1927,5 +1850,5 @@
                                                             nyn-nys+1, nis, 1  &
                                                           /) )
-                      ENDIF    
+!                      ENDIF    
 
                       CALL netcdf_handle_error( 'data_output_2d', 55 )
@@ -1946,8 +1869,8 @@
 !
 !--                      Distribute data over all PEs along y
-                         ngp = ( nxrg-nxlg+1 ) * ( nzt_do-nzb_do+1 ) * ns
+                         ngp = ( nxr-nxl+1 ) * ( nzt_do-nzb_do+1 ) * ns
                          IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr )
-                         CALL MPI_ALLREDUCE( local_2d_sections_l(nxlg,1,nzb_do),  &
-                                             local_2d_sections(nxlg,1,nzb_do),    &
+                         CALL MPI_ALLREDUCE( local_2d_sections_l(nxl,1,nzb_do),  &
+                                             local_2d_sections(nxl,1,nzb_do),    &
                                              ngp, MPI_REAL, MPI_SUM, comm1dy,  &
                                              ierr )
@@ -1959,14 +1882,14 @@
 !--                   Do not output redundant ghost point data except for the
 !--                   boundaries of the total domain.
-                      IF ( nxr == nx )  THEN
-                         nc_stat = NF90_PUT_VAR( id_set_xz(av),                &
-                                             id_var_do2d(av,if),               & 
-                                             local_2d_sections(nxl:nxr+1,1:ns, &
-                                                nzb_do:nzt_do),                &
-                                             start = (/ nxl+1, 1, 1,           &
-                                                do2d_xz_time_count(av) /),     &
-                                             count = (/ nxr-nxl+2, ns, nzt_do-nzb_do+1,  &
-                                                        1 /) )
-                      ELSE
+!                      IF ( nxr == nx )  THEN
+!                         nc_stat = NF90_PUT_VAR( id_set_xz(av),                &
+!                                             id_var_do2d(av,if),               & 
+!                                             local_2d_sections(nxl:nxr+1,1:ns, &
+!                                                nzb_do:nzt_do),                &
+!                                             start = (/ nxl+1, 1, 1,           &
+!                                                do2d_xz_time_count(av) /),     &
+!                                             count = (/ nxr-nxl+2, ns, nzt_do-nzb_do+1,  &
+!                                                        1 /) )
+!                      ELSE
                          nc_stat = NF90_PUT_VAR( id_set_xz(av),                &
                                              id_var_do2d(av,if),               &
@@ -1977,5 +1900,5 @@
                                              count = (/ nxr-nxl+1, ns, nzt_do-nzb_do+1,  &
                                                 1 /) )
-                      ENDIF
+!                      ENDIF
 
                       CALL netcdf_handle_error( 'data_output_2d', 57 )
@@ -1996,8 +1919,8 @@
 !
 !--                      Distribute data over all PEs along x
-                         ngp = ( nyng-nysg+1 ) * ( nzt-nzb + 2 ) * ns
+                         ngp = ( nyn-nys+1 ) * ( nzt-nzb + 2 ) * ns
                          IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr )
-                         CALL MPI_ALLREDUCE( local_2d_sections_l(1,nysg,nzb_do),  &
-                                             local_2d_sections(1,nysg,nzb_do),    &
+                         CALL MPI_ALLREDUCE( local_2d_sections_l(1,nys,nzb_do),  &
+                                             local_2d_sections(1,nys,nzb_do),    &
                                              ngp, MPI_REAL, MPI_SUM, comm1dx,  &
                                              ierr )
@@ -2009,14 +1932,14 @@
 !--                   Do not output redundant ghost point data except for the
 !--                   boundaries of the total domain.
-                      IF ( nyn == ny )  THEN
-                         nc_stat = NF90_PUT_VAR( id_set_yz(av),                &
-                                             id_var_do2d(av,if),               &
-                                             local_2d_sections(1:ns,           &
-                                                nys:nyn+1,nzb_do:nzt_do),      &
-                                             start = (/ 1, nys+1, 1,           &
-                                                do2d_yz_time_count(av) /),     &
-                                             count = (/ ns, nyn-nys+2,         &
-                                                        nzt_do-nzb_do+1, 1 /) )
-                      ELSE
+!                      IF ( nyn == ny )  THEN
+!                         nc_stat = NF90_PUT_VAR( id_set_yz(av),                &
+!                                             id_var_do2d(av,if),               &
+!                                             local_2d_sections(1:ns,           &
+!                                                nys:nyn+1,nzb_do:nzt_do),      &
+!                                             start = (/ 1, nys+1, 1,           &
+!                                                do2d_yz_time_count(av) /),     &
+!                                             count = (/ ns, nyn-nys+2,         &
+!                                                        nzt_do-nzb_do+1, 1 /) )
+!                      ELSE
                          nc_stat = NF90_PUT_VAR( id_set_yz(av),                &
                                              id_var_do2d(av,if),               &
@@ -2027,5 +1950,5 @@
                                              count = (/ ns, nyn-nys+1,         &
                                                         nzt_do-nzb_do+1, 1 /) )
-                      ENDIF
+!                      ENDIF
 
                       CALL netcdf_handle_error( 'data_output_2d', 60 )
