Index: palm/trunk/SOURCE/data_output_mask.f90
===================================================================
--- palm/trunk/SOURCE/data_output_mask.f90	(revision 4457)
+++ palm/trunk/SOURCE/data_output_mask.f90	(revision 4559)
@@ -1,20 +1,20 @@
 !> @file data_output_mask.f90
-!------------------------------------------------------------------------------!
+!--------------------------------------------------------------------------------------------------!
 ! This file is part of the PALM model system.
 !
-! PALM is free software: you can redistribute it and/or modify it under the
-! terms of the GNU General Public License as published by the Free Software
-! Foundation, either version 3 of the License, or (at your option) any later
-! version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with
-! PALM. If not, see <http://www.gnu.org/licenses/>.
+! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General
+! Public License as published by the Free Software Foundation, either version 3 of the License, or
+! (at your option) any later version.
+!
+! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
+! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+! Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along with PALM. If not, see
+! <http://www.gnu.org/licenses/>.
+
 !
 ! Copyright 1997-2020 Leibniz Universitaet Hannover
-!------------------------------------------------------------------------------!
+!--------------------------------------------------------------------------------------------------!
 !
 ! Current revisions:
@@ -25,16 +25,18 @@
 ! -----------------
 ! $Id$
+! file re-formatted to follow the PALM coding standard
+!
+! 4457 2020-03-11 14:20:43Z raasch
 ! use statement for exchange horiz added
-! 
+!
 ! 4444 2020-03-05 15:59:50Z raasch
 ! bugfix: cpp-directives for serial mode added
 !
 ! 4377 2020-01-15 11:10:51Z gronemeier
-! bugfix: set fill value for output according to wall_flags_total_0 for
-!         non-terrain following output
+! bugfix: set fill value for output according to wall_flags_total_0 for non-terrain following output
 !
 ! 4360 2020-01-07 11:25:50Z suehring
-! Introduction of wall_flags_total_0, which currently sets bits based on static
-! topography information used in wall_flags_static_0
+! Introduction of wall_flags_total_0, which currently sets bits based on static topography
+! information used in wall_flags_static_0
 !
 ! 4331 2019-12-10 18:25:02Z suehring
@@ -51,10 +53,10 @@
 !
 ! 4167 2019-08-16 11:01:48Z suehring
-! Changed behaviour of masked output over surface to follow terrain and ignore
-! buildings (J.Resler, T.Gronemeier)
+! Changed behaviour of masked output over surface to follow terrain and ignore buildings
+! (J.Resler, T.Gronemeier)
 !
 ! 4069 2019-07-01 14:05:51Z Giersch
-! Masked output running index mid has been introduced as a local variable to
-! avoid runtime error (Loop variable has been modified) in time_integration
+! Masked output running index mid has been introduced as a local variable to avoid runtime error
+! (Loop variable has been modified) in time_integration
 !
 ! 4039 2019-06-18 10:32:41Z suehring
@@ -76,5 +78,5 @@
 ! ------------
 !> Masked data output in netCDF format for current mask (current value of mid).
-!------------------------------------------------------------------------------!
+!--------------------------------------------------------------------------------------------------!
  SUBROUTINE data_output_mask( av, mid )
 
@@ -82,63 +84,60 @@
 
 #if defined( __netcdf )
-    USE arrays_3d,                                                             &
-        ONLY:  e, nc, nr, p, pt, q, qc, ql, ql_c, ql_v, qr, rho_ocean, s, sa,  &
-               tend, u, v, vpt, w, d_exner
-
-    USE averaging,                                                             &
-        ONLY:  e_av, lpt_av, nc_av, nr_av, p_av, pc_av, pr_av, pt_av, q_av,    &
-               qc_av, ql_av, ql_c_av, ql_v_av, ql_vp_av, qv_av, qr_av,         &
-               rho_ocean_av, s_av, sa_av, u_av, v_av, vpt_av, w_av
-
-    USE basic_constants_and_equations_mod,                                     &
+    USE arrays_3d,                                                                                 &
+        ONLY:  d_exner, e, nc, nr, p, pt, q, qc, ql, ql_c, ql_v, qr, rho_ocean, s, sa, tend, u, v, &
+               vpt, w
+
+    USE averaging,                                                                                 &
+        ONLY:  e_av, lpt_av, nc_av, nr_av, p_av, pc_av, pr_av, pt_av, q_av, qc_av, ql_av, ql_c_av, &
+               ql_v_av, ql_vp_av, qv_av, qr_av, rho_ocean_av, s_av, sa_av, u_av, v_av, vpt_av, w_av
+
+    USE basic_constants_and_equations_mod,                                                         &
         ONLY:  lv_d_cp
 
-    USE chemistry_model_mod,                                                   &
+    USE chemistry_model_mod,                                                                       &
         ONLY:  chem_data_output_mask
 
-    USE control_parameters,                                                    &
-        ONLY:  air_chemistry, domask, domask_no, domask_time_count, mask_i,    &
-               mask_j, mask_k, mask_size_l, mask_surface,                                                   &
-               max_masks, message_string, nz_do3d, salsa,                      &
+    USE control_parameters,                                                                        &
+        ONLY:  air_chemistry, domask, domask_no, domask_time_count, mask_i, mask_j, mask_k,        &
+               mask_size_l, mask_surface, max_masks, message_string, nz_do3d, salsa,               &
                time_since_reference_point
 
 #if defined( __parallel )
-    USE control_parameters,                                                    &
+    USE control_parameters,                                                                        &
         ONLY:  mask_size, mask_start_l
 #endif
 
-    USE cpulog,                                                                &
+    USE cpulog,                                                                                    &
         ONLY:  cpu_log, log_point
 
-    USE diagnostic_output_quantities_mod,                                      &
+    USE diagnostic_output_quantities_mod,                                                          &
         ONLY:  doq_output_mask
 
-    USE exchange_horiz_mod,                                                    &
+    USE exchange_horiz_mod,                                                                        &
         ONLY:  exchange_horiz
 
-    USE indices,                                                               &
+    USE indices,                                                                                   &
         ONLY:  nbgp, nxl, nxr, nyn, nys, nzb, nzt, wall_flags_total_0
 
     USE kinds
 
-    USE bulk_cloud_model_mod,                                                  &
+    USE bulk_cloud_model_mod,                                                                      &
         ONLY:  bulk_cloud_model
 
     USE NETCDF
 
-    USE netcdf_interface,                                                      &
-        ONLY:  fill_value, id_set_mask, id_var_domask, id_var_time_mask,       &
-               nc_stat, netcdf_data_format, netcdf_handle_error
-
-    USE particle_attributes,                                                   &
-        ONLY:  grid_particles, number_of_particles, particles,                 &
-               particle_advection_start, prt_count
+    USE netcdf_interface,                                                                          &
+        ONLY:  fill_value, id_set_mask, id_var_domask, id_var_time_mask, nc_stat,                  &
+               netcdf_data_format, netcdf_handle_error
+
+    USE particle_attributes,                                                                       &
+        ONLY:  grid_particles, number_of_particles, particles, particle_advection_start, prt_count
 
     USE pegrid
 
-    USE radiation_model_mod,                                                   &
+    USE radiation_model_mod,                                                                       &
         ONLY:  radiation, radiation_data_output_mask
 
-    USE salsa_mod,                                                             &
+    USE salsa_mod,                                                                                 &
         ONLY:  salsa_data_output_mask
 
@@ -149,18 +148,18 @@
     INTEGER(iwp) ::  flag_nr                 !< number of masking flag
     INTEGER(iwp) ::  i                       !< loop index
+    INTEGER(iwp) ::  im                      !< loop index for masked variables
     INTEGER(iwp) ::  ivar                    !< variable index
     INTEGER(iwp) ::  j                       !< loop index
+    INTEGER(iwp) ::  jm                      !< loop index for masked variables
     INTEGER(iwp) ::  k                       !< loop index
-    INTEGER(iwp) ::  im                      !< loop index for masked variables
-    INTEGER(iwp) ::  jm                      !< loop index for masked variables
     INTEGER(iwp) ::  kk                      !< vertical index
+    INTEGER(iwp) ::  ktt                     !< k index of highest terrain surface
     INTEGER(iwp) ::  mid                     !< masked output running index
     INTEGER(iwp) ::  n                       !< loop index
     INTEGER(iwp) ::  netcdf_data_format_save !< value of netcdf_data_format
-    INTEGER(iwp) ::  ktt                     !< k index of highest terrain surface
 #if defined( __parallel )
+    INTEGER(iwp) ::  ind(6)                  !< index limits (lower/upper bounds) of array 'local_2d'
     INTEGER(iwp) ::  ngp                     !< number of grid points of an output slice
     INTEGER(iwp) ::  sender                  !< PE id of sending PE
-    INTEGER(iwp) ::  ind(6)                  !< index limits (lower/upper bounds) of array 'local_2d'
 #endif
 
@@ -178,4 +177,5 @@
     REAL(wp), DIMENSION(:,:,:), POINTER ::  to_be_resorted  !< points to array which shall be output
 
+
 !
 !-- Return, if nothing to output
@@ -185,6 +185,6 @@
 
 !
-!-- Parallel netcdf output is not tested so far for masked data, hence
-!-- netcdf_data_format is switched back to non-paralell output.
+!-- Parallel netcdf output is not tested so far for masked data, hence netcdf_data_format is
+!-- switched back to non-paralell output.
     netcdf_data_format_save = netcdf_data_format
     IF ( netcdf_data_format == 5 ) netcdf_data_format = 3
@@ -201,9 +201,8 @@
 #if defined( __parallel )
     IF ( myid == 0 )  THEN
-       ALLOCATE( total_pf(mask_size(mid,1),mask_size(mid,2),mask_size(mid,3)) )
+       ALLOCATE( total_pf( mask_size(mid,1),mask_size(mid,2),mask_size(mid,3) ) )
     ENDIF
 #endif
-    ALLOCATE( local_pf(mask_size_l(mid,1),mask_size_l(mid,2), &
-                       mask_size_l(mid,3)) )
+    ALLOCATE( local_pf( mask_size_l(mid,1),mask_size_l(mid,2), mask_size_l(mid,3) ) )
 
 !
@@ -211,7 +210,7 @@
     domask_time_count(mid,av) = domask_time_count(mid,av) + 1
     IF ( myid == 0  .OR.  netcdf_data_format > 4 )  THEN
-       nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_time_mask(mid,av), &
-                               (/ time_since_reference_point /),              &
-                               start = (/ domask_time_count(mid,av) /),       &
+       nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_time_mask(mid,av),                      &
+                               (/ time_since_reference_point /),                                   &
+                               start = (/ domask_time_count(mid,av) /),                            &
                                count = (/ 1 /) )
        CALL netcdf_handle_error( 'data_output_mask', 460 )
@@ -225,8 +224,7 @@
 !
 !--    Reallocate local_pf on PE 0 since its shape changes during MPI exchange
-       IF ( netcdf_data_format < 5   .AND.  myid == 0  .AND.  ivar > 1 )  THEN
+       IF ( netcdf_data_format < 5  .AND.  myid == 0  .AND.  ivar > 1 )  THEN
           DEALLOCATE( local_pf )
-          ALLOCATE( local_pf(mask_size_l(mid,1),mask_size_l(mid,2), &
-                             mask_size_l(mid,3)) )
+          ALLOCATE( local_pf( mask_size_l(mid,1),mask_size_l(mid,2), mask_size_l(mid,3) ) )
        ENDIF
 !
@@ -281,6 +279,5 @@
                       DO  j = 1, mask_size_l(mid,2)
                          DO  k = 1, mask_size_l(mid,3)
-                            local_pf(i,j,k) =  tend(mask_k(mid,k), &
-                                      mask_j(mid,j),mask_i(mid,i))
+                            local_pf(i,j,k) =  tend( mask_k(mid,k), mask_j(mid,j), mask_i(mid,i) )
                          ENDDO
                       ENDDO
@@ -294,5 +291,5 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )),&
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 ) ),     &
                                        DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
@@ -321,5 +318,5 @@
                          DO  k = nzb, nz_do3d
                             number_of_particles = prt_count(k,j,i)
-                            IF (number_of_particles <= 0)  CYCLE
+                            IF ( number_of_particles <= 0 )  CYCLE
                             particles => grid_particles(k,j,i)%particles(1:number_of_particles)
                             s_r2 = 0.0_wp
@@ -327,7 +324,7 @@
                             DO  n = 1, number_of_particles
                                IF ( particles(n)%particle_mask )  THEN
-                                  s_r2 = s_r2 + grid_particles(k,j,i)%particles(n)%radius**2 * &
+                                  s_r2 = s_r2 + grid_particles(k,j,i)%particles(n)%radius**2 *     &
                                          grid_particles(k,j,i)%particles(n)%weight_factor
-                                  s_r3 = s_r3 + grid_particles(k,j,i)%particles(n)%radius**3 * &
+                                  s_r3 = s_r3 + grid_particles(k,j,i)%particles(n)%radius**3 *     &
                                          grid_particles(k,j,i)%particles(n)%weight_factor
                                ENDIF
@@ -350,6 +347,5 @@
                       DO  j = 1, mask_size_l(mid,2)
                          DO  k = 1, mask_size_l(mid,3)
-                            local_pf(i,j,k) =  tend(mask_k(mid,k), &
-                                      mask_j(mid,j),mask_i(mid,i))
+                            local_pf(i,j,k) =  tend( mask_k(mid,k), mask_j(mid,j), mask_i(mid,i) )
                          ENDDO
                       ENDDO
@@ -363,6 +359,6 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
-                                         DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )),      &
+                                       DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
@@ -392,8 +388,7 @@
                          DO  j = 1, mask_size_l(mid,2)
                             DO  k = 1, mask_size_l(mid,3)
-                               local_pf(i,j,k) =  &
-                                  pt(mask_k(mid,k),mask_j(mid,j),mask_i(mid,i)) &
-                                  + lv_d_cp * d_exner(mask_k(mid,k)) *          &
-                                    ql(mask_k(mid,k),mask_j(mid,j),mask_i(mid,i))
+                               local_pf(i,j,k) = pt( mask_k(mid,k), mask_j(mid,j), mask_i(mid,i) ) &
+                                                 + lv_d_cp * d_exner( mask_k(mid,k) ) *            &
+                                                   ql(mask_k(mid,k),mask_j(mid,j),mask_i(mid,i) )
                             ENDDO
                          ENDDO
@@ -407,6 +402,6 @@
                             im = mask_i(mid,i)
                             jm = mask_j(mid,j)
-                            ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
-                                             DIM = 1 ) - 1
+                            ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )),   &
+                                          DIM = 1 ) - 1
                             DO  k = 1, mask_size_l(mid,3)
                                kk = MIN( ktt+mask_k(mid,k), nzt+1 )
@@ -415,5 +410,6 @@
                                   local_pf(i,j,k) = fill_value
                                ELSE
-                                  local_pf(i,j,k) = pt(kk,jm,im) + lv_d_cp * d_exner(kk) * ql(kk,jm,im)
+                                  local_pf(i,j,k) = pt(kk,jm,im) +                                 &
+                                                    lv_d_cp * d_exner(kk) * ql(kk,jm,im)
                                ENDIF
                             ENDDO
@@ -469,11 +465,10 @@
                          DO  k = nzb, nz_do3d
                             number_of_particles = prt_count(k,j,i)
-                            IF (number_of_particles <= 0)  CYCLE
+                            IF ( number_of_particles <= 0 )  CYCLE
                             particles => grid_particles(k,j,i)%particles(1:number_of_particles)
                             DO  n = 1, number_of_particles
                                IF ( particles(n)%particle_mask )  THEN
                                   tend(k,j,i) = tend(k,j,i) + &
-                                          particles(n)%weight_factor / &
-                                          prt_count(k,j,i)
+                                          particles(n)%weight_factor / prt_count(k,j,i)
                                ENDIF
                             ENDDO
@@ -489,6 +484,5 @@
                       DO  j = 1, mask_size_l(mid,2)
                          DO  k = 1, mask_size_l(mid,3)
-                            local_pf(i,j,k) =  tend(mask_k(mid,k), &
-                                      mask_j(mid,j),mask_i(mid,i))
+                            local_pf(i,j,k) =  tend( mask_k(mid,k), mask_j(mid,j), mask_i(mid,i) )
                          ENDDO
                       ENDDO
@@ -502,6 +496,6 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
-                                          DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )),      &
+                                       DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
@@ -528,7 +522,6 @@
                       DO  j = 1, mask_size_l(mid,2)
                          DO  k = 1, mask_size_l(mid,3)
-                            local_pf(i,j,k) =  &
-                                 q(mask_k(mid,k),mask_j(mid,j),mask_i(mid,i)) -  &
-                                 ql(mask_k(mid,k),mask_j(mid,j),mask_i(mid,i))
+                            local_pf(i,j,k) = q(  mask_k(mid,k), mask_j(mid,j), mask_i(mid,i) ) -  &
+                                              ql( mask_k(mid,k), mask_j(mid,j), mask_i(mid,i) )
                          ENDDO
                       ENDDO
@@ -542,6 +535,6 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
-                                          DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )),      &
+                                       DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
@@ -622,35 +615,29 @@
           CASE DEFAULT
 !
-!--          Set flag to steer output of radiation, land-surface, or user-defined
-!--          quantities
+!--          Set flag to steer output of radiation, land-surface, or user-defined quantities
              found = .FALSE.
 !
 !--          Radiation quantity
              IF ( .NOT. found  .AND. radiation )  THEN
-                CALL radiation_data_output_mask(av, domask(mid,av,ivar), found,&
-                                                local_pf, mid )
+                CALL radiation_data_output_mask( av, domask(mid,av,ivar), found, local_pf, mid )
              ENDIF
 
              IF ( .NOT. found  .AND. air_chemistry )  THEN
-                CALL chem_data_output_mask(av, domask(mid,av,ivar), found,     &
-                                           local_pf, mid )
+                CALL chem_data_output_mask( av, domask(mid,av,ivar), found, local_pf, mid )
              ENDIF
 !
 !--          Check for diagnostic quantities
              IF ( .NOT. found )  THEN
-                CALL doq_output_mask( av, domask(mid,av,ivar), found, local_pf,   &
-                                      mid)
+                CALL doq_output_mask( av, domask(mid,av,ivar), found, local_pf, mid )
              ENDIF
 !
 !--          SALSA quantities
-             IF ( .NOT. found .AND. salsa )  THEN
-                CALL salsa_data_output_mask( av, domask(mid,av,ivar), found,   &
-                                             local_pf, mid )
+             IF ( .NOT. found  .AND.  salsa )  THEN
+                CALL salsa_data_output_mask( av, domask(mid,av,ivar), found, local_pf, mid )
              ENDIF
 !
 !--          User defined quantity
              IF ( .NOT. found )  THEN
-                CALL user_data_output_mask(av, domask(mid,av,ivar), found,     &
-                                           local_pf, mid )
+                CALL user_data_output_mask( av, domask(mid,av,ivar), found, local_pf, mid )
              ENDIF
 
@@ -658,5 +645,5 @@
 
              IF ( .NOT. found )  THEN
-                WRITE ( message_string, * ) 'no masked output available for: ',&
+                WRITE ( message_string, * ) 'no masked output available for: ',                    &
                                             TRIM( domask(mid,av,ivar) )
                 CALL message( 'data_output_mask', 'PA0327', 0, 0, 0, 6, 0 )
@@ -674,13 +661,13 @@
                 DO  j = 1, mask_size_l(mid,2)
                    DO  k = 1, mask_size_l(mid,3)
-                      local_pf(i,j,k) = MERGE( to_be_resorted(mask_k(mid,k),  &
-                                                              mask_j(mid,j),  &
-                                                              mask_i(mid,i)), &
-                                               REAL( fill_value, KIND = wp ), &
-                                               BTEST( wall_flags_total_0(     &
-                                                              mask_k(mid,k),  &
-                                                              mask_j(mid,j),  &
-                                                              mask_i(mid,i)), &
-                                                      flag_nr ) )
+                      local_pf(i,j,k) = MERGE( to_be_resorted( mask_k(mid,k),                      &
+                                                               mask_j(mid,j),                      &
+                                                               mask_i(mid,i)),                     &
+                                               REAL( fill_value, KIND = wp ),                      &
+                                               BTEST( wall_flags_total_0( mask_k(mid,k),           &
+                                                                          mask_j(mid,j),           &
+                                                                          mask_i(mid,i) ),         &
+                                                      flag_nr )                                    &
+                                             )
                    ENDDO
                 ENDDO
@@ -695,6 +682,6 @@
                    im = mask_i(mid,i)
                    jm = mask_j(mid,j)
-                   ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
-                                    DIM = 1 ) - 1
+                   ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 ) ),           &
+                                 DIM = 1 ) - 1
                    DO  k = 1, mask_size_l(mid,3)
                       kk = MIN( ktt+mask_k(mid,k), nzt+1 )
@@ -726,10 +713,10 @@
 !
 !--       (1) a. Parallel I/O using netCDF 4 (not yet tested)
-          nc_stat = NF90_PUT_VAR( id_set_mask(mid,av),                         &
-               id_var_domask(mid,av,ivar), local_pf,                           &
-               start = (/ mask_start_l(mid,1), mask_start_l(mid,2),            &
-                          mask_start_l(mid,3), domask_time_count(mid,av) /),   &
-               count = (/ mask_size_l(mid,1), mask_size_l(mid,2),              &
-                          mask_size_l(mid,3), 1 /) )
+          nc_stat = NF90_PUT_VAR( id_set_mask(mid,av),                                             &
+                                  id_var_domask(mid,av,ivar), local_pf,                            &
+                                  start = (/ mask_start_l(mid,1), mask_start_l(mid,2),             &
+                                             mask_start_l(mid,3), domask_time_count(mid,av) /),    &
+                                  count = (/ mask_size_l(mid,1), mask_size_l(mid,2),               &
+                                             mask_size_l(mid,3), 1 /) )
           CALL netcdf_handle_error( 'data_output_mask', 461 )
        ELSE
@@ -737,7 +724,7 @@
 !
 !--       (1) b. Conventional I/O only through PE0
-!--       PE0 receives partial arrays from all processors of the respective mask
-!--       and outputs them. Here a barrier has to be set, because otherwise
-!--       "-MPI- FATAL: Remote protocol queue full" may occur.
+!--       PE0 receives partial arrays from all processors of the respective mask and outputs them.
+!--       Here a barrier has to be set, because otherwise "-MPI- FATAL: Remote protocol queue full"
+!--       may occur.
           CALL MPI_BARRIER( comm2d, ierr )
 
@@ -746,9 +733,8 @@
 !
 !--          Local array can be relocated directly.
-             total_pf( &
-               mask_start_l(mid,1):mask_start_l(mid,1)+mask_size_l(mid,1)-1, &
-               mask_start_l(mid,2):mask_start_l(mid,2)+mask_size_l(mid,2)-1, &
-               mask_start_l(mid,3):mask_start_l(mid,3)+mask_size_l(mid,3)-1 ) &
-               = local_pf
+             total_pf( mask_start_l(mid,1):mask_start_l(mid,1)+mask_size_l(mid,1)-1,               &
+                       mask_start_l(mid,2):mask_start_l(mid,2)+mask_size_l(mid,2)-1,               &
+                       mask_start_l(mid,3):mask_start_l(mid,3)+mask_size_l(mid,3)-1 )              &
+                  = local_pf
 !
 !--          Receive data from all other PEs.
@@ -757,35 +743,31 @@
 !--             Receive index limits first, then array.
 !--             Index limits are received in arbitrary order from the PEs.
-                CALL MPI_RECV( ind(1), 6, MPI_INTEGER, MPI_ANY_SOURCE, 0,  &
-                     comm2d, status, ierr )
+                CALL MPI_RECV( ind(1), 6, MPI_INTEGER, MPI_ANY_SOURCE, 0, comm2d, status, ierr )
 !
 !--             Not all PEs have data for the mask
                 IF ( ind(1) /= -9999 )  THEN
-                   ngp = ( ind(2)-ind(1)+1 ) * (ind(4)-ind(3)+1 ) *  &
-                         ( ind(6)-ind(5)+1 )
+                   ngp = ( ind(2)-ind(1)+1 ) * (ind(4)-ind(3)+1 ) * ( ind(6)-ind(5)+1 )
                    sender = status(MPI_SOURCE)
                    DEALLOCATE( local_pf )
-                   ALLOCATE(local_pf(ind(1):ind(2),ind(3):ind(4),ind(5):ind(6)))
-                   CALL MPI_RECV( local_pf(ind(1),ind(3),ind(5)), ngp,  &
-                        MPI_REAL, sender, 1, comm2d, status, ierr )
-                   total_pf(ind(1):ind(2),ind(3):ind(4),ind(5):ind(6)) &
-                        = local_pf
+                   ALLOCATE( local_pf( ind(1):ind(2),ind(3):ind(4),ind(5):ind(6) ) )
+                   CALL MPI_RECV( local_pf(ind(1),ind(3),ind(5)), ngp, MPI_REAL, sender, 1, comm2d,&
+                                  status, ierr )
+                   total_pf( ind(1):ind(2),ind(3):ind(4),ind(5):ind(6) ) = local_pf
                 ENDIF
              ENDDO
 
-             nc_stat = NF90_PUT_VAR( id_set_mask(mid,av),                      &
-                  id_var_domask(mid,av,ivar), total_pf,                        &
-                  start = (/ 1, 1, 1, domask_time_count(mid,av) /),            &
-                  count = (/ mask_size(mid,1), mask_size(mid,2),               &
-                             mask_size(mid,3), 1 /) )
+             nc_stat = NF90_PUT_VAR( id_set_mask(mid,av),                                          &
+                                     id_var_domask(mid,av,ivar), total_pf,                         &
+                                     start = (/ 1, 1, 1, domask_time_count(mid,av) /),             &
+                                     count = (/ mask_size(mid,1), mask_size(mid,2),                &
+                                                mask_size(mid,3), 1 /) )
              CALL netcdf_handle_error( 'data_output_mask', 462 )
 
           ELSE
 !
-!--          If at least part of the mask resides on the PE, send the index
-!--          limits for the target array, otherwise send -9999 to PE0.
-             IF ( mask_size_l(mid,1) > 0 .AND.  mask_size_l(mid,2) > 0 .AND. &
-                  mask_size_l(mid,3) > 0  ) &
-                  THEN
+!--          If at least part of the mask resides on the PE, send the index limits for the target
+!--          array, otherwise send -9999 to PE0.
+             IF ( mask_size_l(mid,1) > 0  .AND.  mask_size_l(mid,2) > 0  .AND.                     &
+                  mask_size_l(mid,3) > 0  )  THEN
                 ind(1) = mask_start_l(mid,1)
                 ind(2) = mask_start_l(mid,1) + mask_size_l(mid,1) - 1
@@ -803,11 +785,10 @@
 !--          If applicable, send data to PE0.
              IF ( ind(1) /= -9999 )  THEN
-                CALL MPI_SEND( local_pf(1,1,1), ngp, MPI_REAL, 0, 1, comm2d, &
-                     ierr )
+                CALL MPI_SEND( local_pf(1,1,1), ngp, MPI_REAL, 0, 1, comm2d, ierr )
              ENDIF
           ENDIF
 !
-!--       A barrier has to be set, because otherwise some PEs may proceed too
-!--       fast so that PE0 may receive wrong data on tag 0.
+!--       A barrier has to be set, because otherwise some PEs may proceed too fast so that PE0 may
+!--       receive wrong data on tag 0.
           CALL MPI_BARRIER( comm2d, ierr )
 #if defined( __netcdf4_parallel )
@@ -816,11 +797,11 @@
 #else
 !
-!--    (2) For serial execution of PALM, the single processor (PE0) holds all
-!--    data and writes them directly to file.
-       nc_stat = NF90_PUT_VAR( id_set_mask(mid,av),                            &
-                               id_var_domask(mid,av,ivar), local_pf,           &
-                             start = (/ 1, 1, 1, domask_time_count(mid,av) /), &
-                             count = (/ mask_size_l(mid,1), mask_size_l(mid,2),&
-                               mask_size_l(mid,3), 1 /) )
+!--    (2) For serial execution of PALM, the single processor (PE0) holds all data and writes them
+!--        directly to file.
+       nc_stat = NF90_PUT_VAR( id_set_mask(mid,av),                                                &
+                               id_var_domask(mid,av,ivar), local_pf,                               &
+                               start = (/ 1, 1, 1, domask_time_count(mid,av) /),                   &
+                               count = (/ mask_size_l(mid,1), mask_size_l(mid,2),                  &
+                                          mask_size_l(mid,3), 1 /) )
        CALL netcdf_handle_error( 'data_output_mask', 463 )
 #endif
