Index: /palm/trunk/SOURCE/data_output_mask.f90
===================================================================
--- /palm/trunk/SOURCE/data_output_mask.f90	(revision 4895)
+++ /palm/trunk/SOURCE/data_output_mask.f90	(revision 4896)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! small re-formatting to follow the coding standard
+! 
+! 4895 2021-03-03 15:39:08Z suehring
 ! Remove offset in terrain-following masked output
 ! 
@@ -531,6 +534,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
Index: /palm/trunk/SOURCE/init_masks.f90
===================================================================
--- /palm/trunk/SOURCE/init_masks.f90	(revision 4895)
+++ /palm/trunk/SOURCE/init_masks.f90	(revision 4896)
@@ -24,4 +24,7 @@
 ! -----------------
 ! $Id$
+! small re-formatting to follow the coding standard
+!
+! 4895 2021-03-03 15:39:08Z suehring
 ! Allow only mask_k_over_surface >= 1 for terrain-following mask output
 !
@@ -159,9 +162,10 @@
     DO  mid = 1, masks
 
-       do_mask     (mid,:) = data_output_masks(mid,:)
+       do_mask(mid,:)      = data_output_masks(mid,:)
        do_mask_user(mid,:) = data_output_masks_user(mid,:)
-       mask      (mid,1,:) = mask_x(mid,:)
-       mask      (mid,2,:) = mask_y(mid,:)
-       mask      (mid,3,:) = mask_z(mid,:)
+
+       mask(mid,1,:) = mask_x(mid,:)
+       mask(mid,2,:) = mask_y(mid,:)
+       mask(mid,3,:) = mask_z(mid,:)
 !
 !--    Flag a mask as terrain following
Index: /palm/trunk/SOURCE/radiation_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/radiation_model_mod.f90	(revision 4895)
+++ /palm/trunk/SOURCE/radiation_model_mod.f90	(revision 4896)
@@ -27,4 +27,7 @@
 ! -----------------
 ! $Id$
+! typo in file appendix removed
+!
+! 4875 2021-02-17 11:56:22Z scharf
 ! bugfix for interpolating external radiation on first timestep
 !
@@ -3125,5 +3128,5 @@
        IF ( .NOT. lw_exists )  THEN
           message_string = 'Input file RRTMG_LW for rrtmg model missing.& Please provide ' //      &
-                           TRIM( run_identifier ) // '_lsw file in the INPUT directory.'
+                           TRIM( run_identifier ) // '_rlw file in the INPUT directory.'
           CALL message( 'radiation_init', 'PA0583', 1, 2, 0, 6, 0 )
        ENDIF
Index: /palm/trunk/SOURCE/restart_data_mpi_io_mod.f90
===================================================================
--- /palm/trunk/SOURCE/restart_data_mpi_io_mod.f90	(revision 4895)
+++ /palm/trunk/SOURCE/restart_data_mpi_io_mod.f90	(revision 4896)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! more meaningful variable names assigned,
+! redundant code removed
+!
+! 4893 2021-03-02 16:39:14Z raasch
 ! revised output of surface data via MPI-IO for better performance
 !
@@ -206,5 +210,5 @@
     INTEGER(iwp)            ::  win_surf = -1    !<
 #endif
-    INTEGER(iwp)            ::  total_number_of_surface_values  !< total number of values for one variable
+    INTEGER(iwp)            ::  total_number_of_surface_elements  !< total number of surface elements for one variable
 
     INTEGER(KIND=rd_offset_kind) ::  array_position   !<
@@ -213,12 +217,12 @@
     INTEGER(iwp), DIMENSION(:,:), POINTER, CONTIGUOUS   ::  array_2di   !<
 
-    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  e_end_index     !< extended end index, every grid cell has at least one value
-    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  e_start_index   !<
-    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  m_end_index     !< module copy of end_index
-    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  m_start_index   !<
-    INTEGER(iwp), DIMENSION(:),   ALLOCATABLE ::  thread_index    !<
-    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  target_thread   !<
-    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  transfer_index  !<
-    INTEGER(iwp), DIMENSION(:),   ALLOCATABLE ::  thread_values   !<
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  e_end_index       !< extended end index, every grid cell has at least one value
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  e_start_index     !<
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  m_end_index       !< module copy of end_index
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  m_start_index     !<
+    INTEGER(iwp), DIMENSION(:),   ALLOCATABLE ::  nr_surfaces_in_tb !< number of surface elements in transfer buffer
+    INTEGER(iwp), DIMENSION(:),   ALLOCATABLE ::  s_index_in_tb     !< start index of surface elements in transfer buffer
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  s_index_in_window !< start index for the pe in the rma window
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  transfer_index    !<
 !
 !-- Indices for cyclic fill
@@ -334,5 +338,5 @@
     PRIVATE
 
-    PUBLIC  restart_file_size, total_number_of_surface_values
+    PUBLIC  restart_file_size, total_number_of_surface_elements
 
 !
@@ -3107,10 +3111,10 @@
         IF ( TRIM( array_names(i) ) == TRIM( name ) )  THEN
 !
-!--        ATTENTION: The total_number_of_surface_values and wp MUST be INTERGER(8).
-!--        The compiler (at least Intel) first computes total_number_of_surface_values*wp
+!--        ATTENTION: The total_number_of_surface_elements and wp MUST be INTERGER(8).
+!--        The compiler (at least Intel) first computes total_number_of_surface_elements*wp
 !--        and then does the conversion to INTEGER(8).
-!--        This may lead to wrong results when total_number_of_surface_values*wp is > 2*10**6
+!--        This may lead to wrong results when total_number_of_surface_elements*wp is > 2*10**6
            array_position = array_offset(i) + ( lo_first_index - 1 ) *                             &
-                            INT( total_number_of_surface_values, idp ) * INT( wp, idp )
+                            INT( total_number_of_surface_elements, idp ) * INT( wp, idp )
            found = .TRUE.
            EXIT
@@ -3121,9 +3125,4 @@
 !-- In case of 2d-data, name is written only once
     IF ( lo_first_index == 1 )  THEN
-
-       IF ( header_array_index == max_nr_arrays )  THEN
-          message_string = 'maximum number of 2d/3d-array entries in restart file header exceeded'
-          CALL message( 'rrd_mpi_io_surface', 'PA0585', 1, 2, 0, 6, 0 )
-       ENDIF
 
        array_names(header_array_index)  = name
@@ -3184,17 +3183,17 @@
 !
 !--       Copy from RMA window into output array (data) to allow transfering data to target PEs.
-!--       Check, if the number of surface values per grid cell match the index setup.
-          lo_index = thread_values
+!--       Check, if the number of surface elements per horizontal gridbox match the index setup.
+          lo_index = nr_surfaces_in_tb
           DO  i = nxl, nxr
              DO  j = nys, nyn
-                is = lo_index(target_thread(j,i)) + 1
+                is = lo_index(s_index_in_window(j,i)) + 1
                 ie = is + m_end_index(j,i) - m_start_index(j,i)
                 data(m_start_index(j,i):m_end_index(j,i)) = array_1d(is:ie)
-                lo_index(target_thread(j,i)) = lo_index(target_thread(j,i)) +                      &
-                                               e_end_index(j,i) - e_start_index(j,i) + 1
+                lo_index(s_index_in_window(j,i)) = lo_index(s_index_in_window(j,i)) +              &
+                                                   e_end_index(j,i) - e_start_index(j,i) + 1
 !
 !--             TODO: Test can be removed later.
                 IF ( e_end_index(j,i)-e_start_index(j,i)+1 /= NINT( array_1d(is-1) ) )  THEN
-                   WRITE( 9, '(A,6I8)' ) 'Nr surface values does not match ', j, i,                &
+                   WRITE( 9, '(A,6I8)' ) 'Nr surface elements does not match ', j, i,              &
                                          e_start_index(j,i), e_end_index(j,i),                     &
                                          e_end_index(j,i)-e_start_index(j,i)+1 ,                   &
@@ -3219,5 +3218,5 @@
                 IF ( e_end_index(j,i)-e_start_index(j,i)+1 /= NINT(array_out(e_start_index(j,i))) )&
                 THEN
-                   WRITE( 9, '(A,6I8)' ) 'Nr surface values does not match ', j, i,                &
+                   WRITE( 9, '(A,6I8)' ) 'Nr surface elements does not match ', j, i,              &
                                          e_start_index(j,i), e_end_index(j,i),                     &
                                          e_end_index(j,i)-e_start_index(j,i)+1,                    &
@@ -3559,10 +3558,10 @@
 !
 !-- Copy from input array (data) to RMA window to allow the target PEs to get the appropiate data.
-!-- At this point, a dummy surface element is added. This makes sure that every x-y grid cell owns
+!-- At this point, a dummy surface element is added. This makes sure that every x-y gridbox owns
 !-- at least one surface element. This way, bookkeeping becomes much easier.
-    lo_index = thread_values
+    lo_index = nr_surfaces_in_tb
     DO  i = nxl, nxr
        DO  j = nys, nyn
-          is = lo_index(target_thread(j,i)) + 1
+          is = lo_index(s_index_in_window(j,i)) + 1
           ie = is + m_end_index(j,i) - m_start_index(j,i)
 !
@@ -3570,6 +3569,6 @@
           array_1d(is-1)  = e_end_index(j,i) - e_start_index(j,i) + 1
           array_1d(is:ie) = data(m_start_index(j,i):m_end_index(j,i))
-          lo_index(target_thread(j,i)) = lo_index(target_thread(j,i)) +                            &
-                                         e_end_index(j,i) - e_start_index(j,i) + 1
+          lo_index(s_index_in_window(j,i)) = lo_index(s_index_in_window(j,i)) +                    &
+                                             e_end_index(j,i) - e_start_index(j,i) + 1
        ENDDO
     ENDDO
@@ -3627,5 +3626,5 @@
 #endif
 
-    array_position = array_position + total_number_of_surface_values * wp
+    array_position = array_position + total_number_of_surface_elements * wp
 
  END SUBROUTINE wrd_mpi_io_surface
@@ -3805,12 +3804,12 @@
 #endif
 
-    IF ( ALLOCATED( e_start_index ) )   DEALLOCATE( e_start_index  )
-    IF ( ALLOCATED( e_end_index )   )   DEALLOCATE( e_end_index    )
-    IF ( ALLOCATED( m_start_index ) )   DEALLOCATE( m_start_index  )
-    IF ( ALLOCATED( m_end_index )   )   DEALLOCATE( m_end_index    )
-    IF ( ALLOCATED( target_thread ) )   DEALLOCATE( target_thread  )
-    IF ( ALLOCATED( thread_index )  )   DEALLOCATE( thread_index   )
-    IF ( ALLOCATED( thread_values ) )   DEALLOCATE( thread_values  )
-    IF ( ALLOCATED( transfer_index ) )  DEALLOCATE( transfer_index  )
+    IF ( ALLOCATED( e_start_index )     )   DEALLOCATE( e_start_index )
+    IF ( ALLOCATED( e_end_index )       )   DEALLOCATE( e_end_index )
+    IF ( ALLOCATED( m_start_index )     )   DEALLOCATE( m_start_index )
+    IF ( ALLOCATED( m_end_index )       )   DEALLOCATE( m_end_index )
+    IF ( ALLOCATED( nr_surfaces_in_tb ) )   DEALLOCATE( nr_surfaces_in_tb )
+    IF ( ALLOCATED( s_index_in_tb )     )   DEALLOCATE( s_index_in_tb )
+    IF ( ALLOCATED( s_index_in_window ) )   DEALLOCATE( s_index_in_window )
+    IF ( ALLOCATED( transfer_index )    )   DEALLOCATE( transfer_index )
 
     IF ( .NOT. pe_active_for_read )  RETURN
@@ -3884,8 +3883,8 @@
     INTEGER(iwp), DIMENSION(1)              ::  dims1               !< global dimension for MPI_TYPE_CREATE_SUBARRAY
     INTEGER(iwp), DIMENSION(1)              ::  lsize1              !< local size for MPI_TYPE_CREATE_SUBARRAY
-    INTEGER(iwp), DIMENSION(0:numprocs-1)   ::  nr_cells_to_thread  !<
+    INTEGER(iwp), DIMENSION(0:numprocs-1)   ::  nr_gp_with_surfaces_for_pe  !< number of horizontal gridpoints containing surface elements for the respective pe
+    INTEGER(iwp), DIMENSION(0:numprocs-1)   ::  nr_surface_elements_for_pe !< total number of surface elements for the respective pe
     INTEGER(iwp), DIMENSION(0:pdims(1))     ::  nr_surf_cells_x     !<
     INTEGER(iwp), DIMENSION(0:pdims(1))     ::  nr_surf_cells_x_s   !<
-    INTEGER(iwp), DIMENSION(0:numprocs-1)   ::  nr_values_to_thread !<
     INTEGER(iwp), DIMENSION(1)              ::  start1              !< start index for MPI_TYPE_CREATE_SUBARRAY
     INTEGER(iwp), DIMENSION(nxl:nxr)        ::  sum_y               !<
@@ -3903,6 +3902,6 @@
 #endif
 
-    LOGICAL, INTENT(OUT) ::  data_to_write      !< returns .TRUE., if surface data have been written
-    LOGICAL              ::  only_dummy_values  !< only dummy values, i.e. no data to write
+    LOGICAL, INTENT(OUT) ::  data_to_write        !< returns .TRUE., if surface data have been written
+    LOGICAL              ::  only_dummy_elements  !< only dummy elements, i.e. no data to write
 
 
@@ -3935,12 +3934,12 @@
        RETURN
     ELSE
-       IF ( .NOT. ALLOCATED( e_end_index )    )  ALLOCATE( e_end_index(nys:nyn,nxl:nxr)   )
-       IF ( .NOT. ALLOCATED( e_start_index )  )  ALLOCATE( e_start_index(nys:nyn,nxl:nxr) )
-       IF ( .NOT. ALLOCATED( m_end_index )    )  ALLOCATE( m_end_index(nys:nyn,nxl:nxr)   )
-       IF ( .NOT. ALLOCATED( m_start_index )  )  ALLOCATE( m_start_index(nys:nyn,nxl:nxr) )
-       IF ( .NOT. ALLOCATED( target_thread )  )  ALLOCATE( target_thread(nys:nyn,nxl:nxr) )
-       IF ( .NOT. ALLOCATED( thread_index )   )  ALLOCATE( thread_index(0:numprocs-1)     )
-       IF ( .NOT. ALLOCATED( thread_values )  )  ALLOCATE( thread_values(0:numprocs-1)    )
-       IF ( .NOT. ALLOCATED( transfer_index ) )  ALLOCATE( transfer_index(4,0:numprocs-1) )
+       IF ( .NOT. ALLOCATED( e_end_index )        )  ALLOCATE( e_end_index(nys:nyn,nxl:nxr) )
+       IF ( .NOT. ALLOCATED( e_start_index )      )  ALLOCATE( e_start_index(nys:nyn,nxl:nxr) )
+       IF ( .NOT. ALLOCATED( m_end_index )        )  ALLOCATE( m_end_index(nys:nyn,nxl:nxr) )
+       IF ( .NOT. ALLOCATED( m_start_index )      )  ALLOCATE( m_start_index(nys:nyn,nxl:nxr) )
+       IF ( .NOT. ALLOCATED( nr_surfaces_in_tb )  )  ALLOCATE( nr_surfaces_in_tb(0:numprocs-1) )
+       IF ( .NOT. ALLOCATED( s_index_in_tb )      )  ALLOCATE( s_index_in_tb(0:numprocs-1) )
+       IF ( .NOT. ALLOCATED( s_index_in_window )  )  ALLOCATE( s_index_in_window(nys:nyn,nxl:nxr) )
+       IF ( .NOT. ALLOCATED( transfer_index )     )  ALLOCATE( transfer_index(4,0:numprocs-1) )
     ENDIF
 
@@ -3974,5 +3973,5 @@
        ENDDO
 !
-!--    Distribute these values to all PEs along y.
+!--    Distribute these elements to all PEs along y.
        CALL MPI_ALLREDUCE( nr_surf_cells_y_s, nr_surf_cells_y, SIZE( nr_surf_cells_y ),            &
                            MPI_INTEGER, MPI_SUM, comm1dy, ierr )
@@ -4055,18 +4054,18 @@
 #endif
 
-    total_number_of_surface_values = 0
+    total_number_of_surface_elements = 0
     DO  i = 0, numprocs-1
        IF ( i == myid )  THEN
-          glo_start = total_number_of_surface_values + 1
-       ENDIF
-       total_number_of_surface_values = total_number_of_surface_values + nr_surfcells_all_r(i,1)
+          glo_start = total_number_of_surface_elements + 1
+       ENDIF
+       total_number_of_surface_elements = total_number_of_surface_elements + nr_surfcells_all_r(i,1)
     ENDDO
-    only_dummy_values = ( MAXVAL( nr_surfcells_all_r(:,2) ) <= 0 )
+    only_dummy_elements = ( MAXVAL( nr_surfcells_all_r(:,2) ) <= 0 )
 
 !
 !-- Compute indices of equally distributed surface elements.
-!-- Number of surface values scheduled for ouput on this PE:
-    nr_surfcells_pe  = total_number_of_surface_values  / numprocs
-    rest_cells_pe    = MOD( total_number_of_surface_values, numprocs )
+!-- Number of surface elements scheduled for ouput on this PE:
+    nr_surfcells_pe  = total_number_of_surface_elements  / numprocs
+    rest_cells_pe    = MOD( total_number_of_surface_elements, numprocs )
     rest_bound       = rest_cells_pe * ( nr_surfcells_pe + 1 )
     m_start_index    = start_index
@@ -4074,23 +4073,24 @@
 
 !
-!-- Compute number of elements on source PE, which have to be send to the corresponding target PE.
-#if defined( __parallel )
-    nr_cells_to_thread  = 0
-    nr_values_to_thread = 0
+!-- Compute number of surface elements on source PE, which have to be send to the corresponding
+!-- target PE.
+#if defined( __parallel )
+    nr_gp_with_surfaces_for_pe = 0
+    nr_surface_elements_for_pe = 0
     DO  i = nxl, nxr
        DO  j = nys, nyn
           IF ( rest_cells_pe == 0 )  THEN
-             target_thread(j,i) = ( global_start(j,i) - 1 ) / nr_surfcells_pe
+             s_index_in_window(j,i) = ( global_start(j,i) - 1 ) / nr_surfcells_pe
           ELSE
              IF ( global_start(j,i) <= rest_bound )  THEN
-                target_thread(j,i) = ( global_start(j,i) - 1 ) / ( nr_surfcells_pe + 1 )
+                s_index_in_window(j,i) = ( global_start(j,i) - 1 ) / ( nr_surfcells_pe + 1 )
              ELSE
-                target_thread(j,i) = ( global_start(j,i) - rest_bound - 1 ) / nr_surfcells_pe
-                target_thread(j,i) = target_thread(j,i) + rest_cells_pe
+                s_index_in_window(j,i) = ( global_start(j,i) - rest_bound - 1 ) / nr_surfcells_pe
+                s_index_in_window(j,i) = s_index_in_window(j,i) + rest_cells_pe
              ENDIF
 !
 !--          TODO: Test output, to be removed later.
-             IF ( target_thread(j,i) >= numprocs )  THEN
-                WRITE( 9,'(A,8I8)' )  'target_thread ', j, i, target_thread(j,i),                  &
+             IF ( s_index_in_window(j,i) >= numprocs )  THEN
+                WRITE( 9,'(A,8I8)' )  's_index_in_window ', j, i, s_index_in_window(j,i),          &
                                       global_start(j,i) , nr_surfcells_pe
                 FLUSH( 9 )
@@ -4098,7 +4098,9 @@
              ENDIF
           ENDIF
-          nr_cells_to_thread(target_thread(j,i))  = nr_cells_to_thread(target_thread(j,i)) + 1
-          nr_values_to_thread(target_thread(j,i)) = nr_values_to_thread(target_thread(j,i)) +      &
-                                                    e_end_index(j,i) - e_start_index(j,i) + 1
+          nr_gp_with_surfaces_for_pe(s_index_in_window(j,i)) =                                     &
+                                             nr_gp_with_surfaces_for_pe(s_index_in_window(j,i)) + 1
+          nr_surface_elements_for_pe(s_index_in_window(j,i)) =                                     &
+                                             nr_surface_elements_for_pe(s_index_in_window(j,i)) +  &
+                                             e_end_index(j,i) - e_start_index(j,i) + 1
        ENDDO
     ENDDO
@@ -4106,17 +4108,17 @@
 !
 !-- Compute start index in the transfer buffer on the source side for the corresponding target PE.
-    thread_index(0)  = 1
-    thread_values(0) = 1
+    s_index_in_tb(0)     = 1
+    nr_surfaces_in_tb(0) = 1
     DO  n = 1, numprocs-1
-       thread_index(n)  = thread_index(n-1) + nr_cells_to_thread(n-1)
-       thread_values(n) = thread_values(n-1) + nr_values_to_thread(n-1)
+       s_index_in_tb(n)     = s_index_in_tb(n-1)     + nr_gp_with_surfaces_for_pe(n-1)
+       nr_surfaces_in_tb(n) = nr_surfaces_in_tb(n-1) + nr_surface_elements_for_pe(n-1)
     ENDDO
 !
 !-- Buffer distribution on the source side.
     DO  n = 0, numprocs-1
-       transfer_index_s(1,n) = thread_index(n)
-       transfer_index_s(2,n) = nr_cells_to_thread(n)
-       transfer_index_s(3,n) = thread_values(n)
-       transfer_index_s(4,n) = nr_values_to_thread(n)
+       transfer_index_s(1,n) = s_index_in_tb(n)
+       transfer_index_s(2,n) = nr_gp_with_surfaces_for_pe(n)
+       transfer_index_s(3,n) = nr_surfaces_in_tb(n)
+       transfer_index_s(4,n) = nr_surface_elements_for_pe(n)
     ENDDO
 
@@ -4128,5 +4130,5 @@
 !
 !-- Create surface element file type.
-    IF ( total_number_of_surface_values > 0 .AND. .NOT. only_dummy_values)  THEN
+    IF ( total_number_of_surface_elements > 0 .AND. .NOT. only_dummy_elements)  THEN
         data_to_write = .TRUE.
     ELSE
@@ -4144,5 +4146,5 @@
 
     IF ( sm_io%iam_io_pe )  THEN
-       IF ( total_number_of_surface_values > 0 )  THEN
+       IF ( total_number_of_surface_elements > 0 )  THEN
            CALL MPI_TYPE_CREATE_SUBARRAY( 1, dims1, lsize1, start1, MPI_ORDER_FORTRAN, MPI_REAL,   &
                                           ft_surf, ierr )
@@ -4152,5 +4154,5 @@
 !
 !-- Allocate rma window to supply surface data to other PEs.
-    CALL rd_alloc_rma_mem( array_1d, SUM( nr_values_to_thread ), win_surf )
+    CALL rd_alloc_rma_mem( array_1d, SUM( nr_surface_elements_for_pe ), win_surf )
 !
 !-- Allocate shared array on IO-PE to supply data for MPI-IO (write or read).
@@ -4167,10 +4169,10 @@
     ENDIF
 #else
-    IF ( total_number_of_surface_values > 0  .AND.  .NOT. only_dummy_values )  THEN
+    IF ( total_number_of_surface_elements > 0  .AND.  .NOT. only_dummy_elements )  THEN
         data_to_write = .TRUE.
     ELSE
         data_to_write = .FALSE.
     ENDIF
-    ALLOCATE( array_out(1:total_number_of_surface_values) )
+    ALLOCATE( array_out(1:total_number_of_surface_elements) )
 #endif
 
@@ -4269,5 +4271,5 @@
        local_indices(2,:) = 0
 
-       winsize = MAX( 2 * SUM( nr_cells_to_thread ), 2 )
+       winsize = MAX( 2 * SUM( nr_gp_with_surfaces_for_pe ), 2 )
 
        ALLOCATE( surf_val_index(2,winsize) )
@@ -4276,11 +4278,11 @@
        CALL MPI_WIN_FENCE( 0, win_ind, ierr )
 
-       lo_index = thread_index
+       lo_index = s_index_in_tb
        DO  i = nxl, nxr
           DO  j = nys, nyn
-             surf_val_index(1,lo_index(target_thread(j,i))) = global_start(j,i)
-             surf_val_index(2,lo_index(target_thread(j,i))) = global_end(j,i) - global_start(j,i)  &
-                                                              + 1
-             lo_index(target_thread(j,i)) = lo_index(target_thread(j,i)) + 1
+             surf_val_index(1,lo_index(s_index_in_window(j,i))) = global_start(j,i)
+             surf_val_index(2,lo_index(s_index_in_window(j,i))) = global_end(j,i) -                &
+                                                                  global_start(j,i) + 1
+             lo_index(s_index_in_window(j,i)) = lo_index(s_index_in_window(j,i)) + 1
           ENDDO
        ENDDO
Index: /palm/trunk/SOURCE/surface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/surface_mod.f90	(revision 4895)
+++ /palm/trunk/SOURCE/surface_mod.f90	(revision 4896)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! variable renamed
+!
+! 4893 2021-03-02 16:39:14Z raasch
 ! revised output of surface data via MPI-IO for better performance
 !
@@ -221,5 +224,5 @@
                rrd_mpi_io_global_array,                                                            &
                rrd_mpi_io_surface,                                                                 &
-               total_number_of_surface_values,                                                     &
+               total_number_of_surface_elements,                                                   &
                wrd_mpi_io,                                                                         &
                wrd_mpi_io_global_array,                                                            &
@@ -4019,5 +4022,5 @@
           IF ( .NOT. surface_data_to_write )  CYCLE
 
-          ns_h_on_file(l) = total_number_of_surface_values
+          ns_h_on_file(l) = total_number_of_surface_elements
 
           CALL wrd_mpi_io( 'global_start_index_h_' // dum, global_start_index )
@@ -4153,5 +4156,5 @@
           IF ( .NOT. surface_data_to_write )  CYCLE
 
-          ns_v_on_file(l) = total_number_of_surface_values
+          ns_v_on_file(l) = total_number_of_surface_elements
 
           CALL wrd_mpi_io( 'global_start_index_v_' // dum, global_start_index )
