Index: palm/trunk/SOURCE/land_surface_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 4693)
+++ palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 4694)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Fix reading of surface data from MPI restart file
+!
+! 4671 2020-09-09 20:27:58Z pavelkrc
 ! Implementation of downward facing USM and LSM surfaces for RTM 4.1
 ! Author: J. Resler (Institute of Computer Science, Prague)
@@ -7611,7 +7614,7 @@
     INTEGER(iwp) ::  l   !< running index surface orientation
 
-    INTEGER(iwp), DIMENSION(nys:nyn,nxl:nxr) ::  end_index
+    !INTEGER(iwp), DIMENSION(nys:nyn,nxl:nxr) ::  end_index
     INTEGER(iwp), DIMENSION(nys:nyn,nxl:nxr) ::  global_start
-    INTEGER(iwp), DIMENSION(nys:nyn,nxl:nxr) ::  start_index
+    !INTEGER(iwp), DIMENSION(nys:nyn,nxl:nxr) ::  start_index
 
     LOGICAL      :: array_found
@@ -7690,4 +7693,6 @@
                                           global_start )
 
+       IF ( MAXVAL( surf_lsm_h(l)%end_index ) <= 0 )  CYCLE
+
        CALL rrd_mpi_io_surface( 't_soil_h(' // dum // ')', t_soil_h(l)%var_2d )
        CALL rrd_mpi_io_surface( 'm_soil_h(' // dum // ')',  m_soil_h(l)%var_2d )
@@ -7705,11 +7710,11 @@
 !kk    Has to be discussed with the developpers
 
-       CALL rrd_mpi_io( 'lsm_start_index_v_' // dum,  start_index )
-       CALL rrd_mpi_io( 'lsm_end_index_v_' // dum,  end_index )
+       CALL rrd_mpi_io( 'lsm_start_index_v_' // dum,  surf_lsm_v(l)%start_index )
+       CALL rrd_mpi_io( 'lsm_end_index_v_' // dum,  surf_lsm_v(l)%end_index )
        CALL rrd_mpi_io( 'lsm_global_start_index_v_' // dum , global_start )
 
-       CALL rd_mpi_io_surface_filetypes( start_index, end_index, ldum, global_start )
-
-       IF ( MAXVAL( end_index ) <= 0 )  CYCLE
+       CALL rd_mpi_io_surface_filetypes( surf_lsm_v(l)%start_index, surf_lsm_v(l)%end_index, ldum, global_start )
+
+       IF ( MAXVAL( surf_lsm_v(l)%end_index ) <= 0 )  CYCLE
 
        CALL rrd_mpi_io_surface( 't_soil_v(' // dum // ')', t_soil_v(l)%var_2d )
Index: palm/trunk/SOURCE/radiation_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/radiation_model_mod.f90	(revision 4693)
+++ palm/trunk/SOURCE/radiation_model_mod.f90	(revision 4694)
@@ -28,4 +28,7 @@
 ! -----------------
 ! $Id$
+! Bugfix for tracing of maximum radiative fluxes
+!
+! 4686 2020-09-18 11:59:57Z pavelkrc
 ! Silence compiler warning about unused variable in serial build
 !
@@ -6421,6 +6424,8 @@
             CALL radiation_print_debug_surf( 'surfinl after reflected pass', surfinl, refstep )
             CALL radiation_print_debug_surf( 'surfins after reflected pass', surfins, refstep )
-            CALL radiation_print_debug_pcb( 'pcbinlw after reflected pass', pcbinlw, refstep )
-            CALL radiation_print_debug_pcb( 'pcbinsw after reflected pass', pcbinsw, refstep )
+            IF ( npcbl > 0 )  THEN
+               CALL radiation_print_debug_pcb( 'pcbinlw after reflected pass', pcbinlw, refstep )
+               CALL radiation_print_debug_pcb( 'pcbinsw after reflected pass', pcbinsw, refstep )
+            ENDIF
          ENDIF
 
Index: palm/trunk/SOURCE/restart_data_mpi_io_mod.f90
===================================================================
--- palm/trunk/SOURCE/restart_data_mpi_io_mod.f90	(revision 4693)
+++ palm/trunk/SOURCE/restart_data_mpi_io_mod.f90	(revision 4694)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Fix name of subroutine in message
+!
+! 4629 2020-07-29 09:37:56Z raasch
 ! support for MPI Fortran77 interface (mpif.h) removed
 !
@@ -3136,5 +3139,5 @@
 
        message_string = 'surface array "' // TRIM( name ) // '" not found in restart file'
-       CALL message( 'rrd_mpi_io_global_array_int_1d', 'PA0722', 3, 2, 0, 6, 0 )
+       CALL message( 'rrd_mpi_io_surface', 'PA0722', 3, 2, 0, 6, 0 )
 
     ENDIF
Index: palm/trunk/SOURCE/surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/surface_mod.f90	(revision 4693)
+++ palm/trunk/SOURCE/surface_mod.f90	(revision 4694)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Fix reading of surface data from MPI restart file
+!
+! 4682 2020-09-17 14:13:27Z pavelkrc
 ! Fix indexing of horizontal surfaces in write restart for full-3D cases
 !
@@ -5626,4 +5629,11 @@
           DO  j = nys, nyn
              surf_match_def  = surf_def_h(l)%end_index(j,i) >= surf_def_h(l)%start_index(j,i)
+             IF ( l < 2 )  THEN
+                surf_match_lsm  = surf_lsm_h(l)%end_index(j,i) >= surf_lsm_h(l)%start_index(j,i)
+                surf_match_usm  = surf_usm_h(l)%end_index(j,i) >= surf_usm_h(l)%start_index(j,i)
+             ELSE
+                surf_match_lsm  = .FALSE.
+                surf_match_usm  = .FALSE.
+             ENDIF
              IF ( surf_match_def )  THEN
 !
@@ -5640,31 +5650,22 @@
                 ENDDO
              ENDIF
+!--          Natural- and urban-like horizontal surfaces.
+             IF ( surf_match_lsm )  THEN
+                mm = surf_lsm_h(l)%start_index(j,i)
+                DO  m = surf_h(l)%start_index(j,i), surf_h(l)%end_index(j,i)
+                   IF ( surf_lsm_h(l)%end_index(j,i) >= mm )                                             &
+                      CALL restore_surface_elements( surf_lsm_h(l), mm, surf_h(l), m )
+                   mm = mm + 1
+                ENDDO
+             ENDIF
+             IF ( surf_match_usm )  THEN
+                mm = surf_usm_h(l)%start_index(j,i)
+                DO  m = surf_h(l)%start_index(j,i), surf_h(l)%end_index(j,i)
+                   IF ( surf_usm_h(l)%end_index(j,i) >= mm )                                             &
+                      CALL restore_surface_elements( surf_usm_h(l), mm, surf_h(l), m )
+                   mm = mm + 1
+                ENDDO
+             ENDIF
           ENDDO
-       ENDDO
-    ENDDO
-!
-!-- Natural- and urban-like horizontal surfaces.
-    DO  i = nxl, nxr
-       DO  j = nys, nyn
-          surf_match_lsm  = surf_lsm_h(l)%end_index(j,i) >= surf_lsm_h(l)%start_index(j,i)
-          surf_match_usm  = surf_usm_h(l)%end_index(j,i) >= surf_usm_h(l)%start_index(j,i)
-
-          IF ( surf_match_lsm )  THEN
-             mm = surf_lsm_h(l)%start_index(j,i)
-             DO  m = surf_h(0)%start_index(j,i), surf_h(0)%end_index(j,i)
-                IF ( surf_lsm_h(l)%end_index(j,i) >= mm )                                             &
-                   CALL restore_surface_elements( surf_lsm_h(l), mm, surf_h(0), m )
-                mm = mm + 1
-             ENDDO
-          ENDIF
-
-          IF ( surf_match_usm )  THEN
-             mm = surf_usm_h(l)%start_index(j,i)
-             DO  m = surf_h(0)%start_index(j,i), surf_h(0)%end_index(j,i)
-                IF ( surf_usm_h(l)%end_index(j,i) >= mm )                                             &
-                   CALL restore_surface_elements( surf_usm_h(l), mm, surf_h(0), m )
-                mm = mm + 1
-             ENDDO
-          ENDIF
        ENDDO
     ENDDO
Index: palm/trunk/SOURCE/urban_surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/urban_surface_mod.f90	(revision 4693)
+++ palm/trunk/SOURCE/urban_surface_mod.f90	(revision 4694)
@@ -27,4 +27,7 @@
 ! -----------------
 ! $Id$
+! Fix writing and reading of surface data to/from MPI restart file
+!
+! 4693 2020-09-22 19:47:04Z maronga
 ! Bugfix for last commit
 !
@@ -6498,4 +6501,6 @@
                                          global_start )
 
+       IF ( MAXVAL( surf_usm_h(l)%end_index ) <= 0 )  CYCLE
+
        IF ( .NOT.  ALLOCATED( t_surf_wall_h_1(l)%val ) )                                             &
           ALLOCATE( t_surf_wall_h_1(l)%val(1:surf_usm_h(l)%ns) )
@@ -6510,4 +6515,14 @@
        CALL rrd_mpi_io_surface( 't_surf_green_h(' // dum // ')', t_surf_green_h_1(l)%val )
 
+       IF ( .NOT.  ALLOCATED( m_liq_usm_h_1(l)%val ) )                                            &
+          ALLOCATE( m_liq_usm_h_1(l)%val(1:surf_usm_h(l)%ns) )
+       CALL rrd_mpi_io_surface( 'm_liq_usm_h(' // dum // ')', m_liq_usm_h_1(l)%val )
+
+       IF ( indoor_model )  THEN
+          IF ( .NOT.  ALLOCATED( surf_usm_h(l)%waste_heat ) )                                     &
+             ALLOCATE( surf_usm_h(l)%waste_heat(1:surf_usm_h(l)%ns) )
+          CALL rrd_mpi_io_surface( 'waste_heat_h(' // dum // ')', surf_usm_h(l)%waste_heat )
+       ENDIF
+
     ENDDO
     DO  l = 0, 3
@@ -6522,4 +6537,6 @@
                                          global_start )
 
+       IF ( MAXVAL( surf_usm_v(l)%end_index ) <= 0 )  CYCLE
+
        IF ( .NOT.  ALLOCATED( t_surf_wall_v_1(l)%val ) )                                             &
           ALLOCATE( t_surf_wall_v_1(l)%val(1:surf_usm_v(l)%ns) )
@@ -6547,4 +6564,6 @@
                                          global_start )
 
+       IF ( MAXVAL( surf_usm_h(l)%end_index ) <= 0 )  CYCLE
+
        IF ( .NOT.  ALLOCATED( t_wall_h_1(l)%val ) )                                                          &
           ALLOCATE( t_wall_h_1(l)%val(nzb_wall:nzt_wall+1,1:surf_usm_h(l)%ns) )
@@ -6558,4 +6577,5 @@
           ALLOCATE( t_green_h_1(l)%val(nzb_wall:nzt_wall+1,1:surf_usm_h(l)%ns) )
        CALL rrd_mpi_io_surface( 't_green_h(' // dum // ')', t_green_h_1(l)%val )
+
     ENDDO
 
@@ -6570,4 +6590,6 @@
        CALL rd_mpi_io_surface_filetypes( surf_usm_v(l)%start_index, surf_usm_v(l)%end_index, ldum, &
                                          global_start )
+
+       IF ( MAXVAL( surf_usm_v(l)%end_index ) <= 0 )  CYCLE
 
        IF ( .NOT. ALLOCATED( t_wall_v_1(l)%val ) )                                                   &
@@ -7392,5 +7414,4 @@
           WRITE( dum, '(I1)')  l
 
-          END DO
           CALL rd_mpi_io_surface_filetypes( surf_usm_h(l)%start_index, surf_usm_h(l)%end_index,             &
                                             surface_data_to_write, global_start_index )
@@ -7400,12 +7421,16 @@
           CALL wrd_mpi_io( 'usm_global_start_h_' // dum, global_start_index )
 
-          CALL wrd_mpi_io_surface( 't_surf_wall_h_' // dum,  t_surf_wall_h(l)%val )
-          CALL wrd_mpi_io_surface( 't_surf_window_h_' // dum, t_surf_window_h(l)%val )
-          CALL wrd_mpi_io_surface( 't_surf_green_h_' // dum, t_surf_green_h(l)%val )
-
-          CALL wrd_mpi_io_surface( 'm_liq_usm_h_' // dum, m_liq_usm_h(l)%val )
+          IF ( .NOT. surface_data_to_write )  CYCLE
+
+          CALL wrd_mpi_io_surface( 't_surf_wall_h(' // dum // ')',  t_surf_wall_h(l)%val )
+          CALL wrd_mpi_io_surface( 't_surf_window_h(' // dum // ')', t_surf_window_h(l)%val )
+          CALL wrd_mpi_io_surface( 't_surf_green_h(' // dum // ')', t_surf_green_h(l)%val )
+
+          CALL wrd_mpi_io_surface( 'm_liq_usm_h(' // dum // ')', m_liq_usm_h(l)%val )
           IF ( indoor_model )  THEN
-             CALL wrd_mpi_io_surface( 'waste_heat_h_' // dum, surf_usm_h(l)%waste_heat ) ! NEED TO BE CHECKED!!!!!
-          ENDIF
+             CALL wrd_mpi_io_surface( 'waste_heat_h(' // dum // ')', surf_usm_h(l)%waste_heat ) ! NEED TO BE CHECKED!!!!!
+          ENDIF
+
+       ENDDO
 
        DO  l = 0, 3
@@ -7439,7 +7464,9 @@
           CALL wrd_mpi_io( 'usm_global_start_h_2_' // dum, global_start_index )
 
-          CALL wrd_mpi_io_surface( 't_wall_h_' // dum, t_wall_h(l)%val )
-          CALL wrd_mpi_io_surface( 't_window_h_' // dum, t_window_h(l)%val )
-          CALL wrd_mpi_io_surface( 't_green_h_' // dum, t_green_h(l)%val )
+          IF ( .NOT. surface_data_to_write )  CYCLE
+
+          CALL wrd_mpi_io_surface( 't_wall_h(' // dum // ')', t_wall_h(l)%val )
+          CALL wrd_mpi_io_surface( 't_window_h(' // dum // ')', t_window_h(l)%val )
+          CALL wrd_mpi_io_surface( 't_green_h(' // dum // ')', t_green_h(l)%val )
 
        ENDDO
