Index: palm/trunk/SCRIPTS/mrun
===================================================================
--- palm/trunk/SCRIPTS/mrun	(revision 145)
+++ palm/trunk/SCRIPTS/mrun	(revision 146)
@@ -207,5 +207,5 @@
  read_from_config=""
  restart_run=false
-# return_addres=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{print $2}')
+ return_addres=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{print $2}')
  if [[ $return_addres = 130.75.105.158 ]]
  then
Index: palm/trunk/SOURCE/CURRENT_MODIFICATIONS
===================================================================
--- palm/trunk/SOURCE/CURRENT_MODIFICATIONS	(revision 145)
+++ palm/trunk/SOURCE/CURRENT_MODIFICATIONS	(revision 146)
@@ -29,5 +29,14 @@
 to ..._var_list, hom_sum is now allocated in parin instead of init_3d_model
 
-init_3d_model, parin, read_var_list, read_3d_binary, write_var_list, write_3d_binary
+npex, npey moved from inipar- to d3par-namelist (parin)
+
+myid_char14 removed. This was used since on IBM machines the process rank may
+be changed when the final communicator is defined, in order to save the
+preliminary processor-id for opening the binary output file for restarts
+(unit 14), because otherwise a mismatch occured when reading this file in a
+restart job. This mechanism is not needed any more since the subdomain
+informations are now contained in file _0000. (parin, check_open)
+
+check_open, init_3d_model, modules, parin, read_var_list, read_3d_binary, write_var_list, write_3d_binary
 
 
Index: palm/trunk/SOURCE/calc_spectra.f90
===================================================================
--- palm/trunk/SOURCE/calc_spectra.f90	(revision 145)
+++ palm/trunk/SOURCE/calc_spectra.f90	(revision 146)
@@ -291,5 +291,5 @@
     IF ( myid == 0 )  THEN
 !
-!--    Sum of spectra for later averaging (see routine plot_spectra)
+!--    Sum of spectra for later averaging (see routine data_output_spectra)
 !--    Temperton fft results need to be normalized
        IF ( fft_method == 'temperton-algorithm' )  THEN
@@ -307,5 +307,5 @@
 
 !
-!-- n_sp_x is needed by plot_spectra_x
+!-- n_sp_x is needed by data_output_spectra_x
     n_sp_x = n
 
@@ -403,5 +403,5 @@
     IF ( myid == 0 )  THEN
 !
-!--    Sum of spectra for later averaging (see routine plot_spectra)
+!--    Sum of spectra for later averaging (see routine data_output_spectra)
 !--    Temperton fft results need to be normalized
        IF ( fft_method == 'temperton-algorithm' )  THEN
@@ -419,5 +419,5 @@
 
 !
-!-- n_sp_y is needed by plot_spectra_y
+!-- n_sp_y is needed by data_output_spectra_y
     n_sp_y = n
 
Index: palm/trunk/SOURCE/check_open.f90
===================================================================
--- palm/trunk/SOURCE/check_open.f90	(revision 145)
+++ palm/trunk/SOURCE/check_open.f90	(revision 146)
@@ -5,5 +5,6 @@
 ! -----------------
 ! First opening of unit 13 openes file _0000 on all PEs (parallel version)
-! because only this file contains the global variables
+! because only this file contains the global variables,
+! myid_char_14 removed
 !
 ! Former revisions:
@@ -191,5 +192,5 @@
              CALL MPI_BARRIER( comm2d, ierr )
 #endif
-             OPEN ( 14, FILE='BINOUT'//TRIM(coupling_char)//'/'//myid_char_14, &
+             OPEN ( 14, FILE='BINOUT'//TRIM(coupling_char)//'/'//myid_char, &
                         FORM='UNFORMATTED', POSITION='APPEND' )
           ENDIF
Index: palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- palm/trunk/SOURCE/init_3d_model.f90	(revision 145)
+++ palm/trunk/SOURCE/init_3d_model.f90	(revision 146)
@@ -7,5 +7,6 @@
 ! Actual revisions:
 ! -----------------
-! Allocation of hom_sum moved to parin
+! Allocation of hom_sum moved to parin, initialization of spectrum_x|y directly
+! after allocating theses arrays
 !
 ! Former revisions:
@@ -234,4 +235,6 @@
        ALLOCATE( spectrum_x( 1:nx/2, 1:10, 1:10 ), &
                  spectrum_y( 1:ny/2, 1:10, 1:10 ) )
+       spectrum_x = 0.0
+       spectrum_y = 0.0
     ENDIF
 
@@ -809,11 +812,4 @@
           ql = 0.0
           IF ( precipitation )  precipitation_amount = 0.0
-       ENDIF
-
-!
-!--    Initialize spectra
-       IF ( dt_dosp /= 9999999.9 )  THEN
-          spectrum_x = 0.0
-          spectrum_y = 0.0
        ENDIF
 
Index: palm/trunk/SOURCE/modules.f90
===================================================================
--- palm/trunk/SOURCE/modules.f90	(revision 145)
+++ palm/trunk/SOURCE/modules.f90	(revision 146)
@@ -6,4 +6,5 @@
 ! -----------------
 ! +hor_index_bounds, hor_index_bounds_previous_run, numprocs_previous_run
+! -myid_char_14
 !
 ! Former revisions:
@@ -957,5 +958,5 @@
 #endif
 #endif
-    CHARACTER(LEN=5)       ::  myid_char = '', myid_char_14 = ''
+    CHARACTER(LEN=5)       ::  myid_char = ''
     INTEGER                ::  myid=0, npex = -1, npey = -1, numprocs = 1, &
                                numprocs_previous_run = -1,                 &
Index: palm/trunk/SOURCE/parin.f90
===================================================================
--- palm/trunk/SOURCE/parin.f90	(revision 145)
+++ palm/trunk/SOURCE/parin.f90	(revision 146)
@@ -4,5 +4,7 @@
 ! Actual revisions:
 ! -----------------
-! Allocation of hom_sum moved from init_3d_model to here
+! Allocation of hom_sum moved from init_3d_model to here,
+! npex, npey moved from inipar to d3par, setting of myid_char_14 removed,
+! lad is allways allocated
 !
 ! Former revisions:
@@ -87,5 +89,5 @@
              lad_vertical_gradient, lad_vertical_gradient_level, &
              long_filter_factor, loop_optimization, mixing_length_1d, &
-             momentum_advec, netcdf_precision, npex, npey, nsor_ini, nx, ny, &
+             momentum_advec, netcdf_precision, nsor_ini, nx, ny, &
              nz, ocean, omega, outflow_damping_width, overshoot_limit_e, &
              overshoot_limit_pt, overshoot_limit_u, overshoot_limit_v, &
@@ -126,5 +128,6 @@
                        end_time, force_print_header, mg_cycles, &
                        mg_switch_to_pe0_level, netcdf_64bit, netcdf_64bit_3d, &
-                       ngsrb, normalizing_region, nsor, nz_do3d, omega_sor, &
+                       ngsrb, normalizing_region, npex, npey, nsor, nz_do3d, &
+                       omega_sor, &
                        prandtl_number, precipitation_amount_interval, &
                        profile_columns, profile_rows, psolver, &
@@ -142,21 +145,4 @@
                        return_username, run_identifier, tasks_per_node, &
                        write_binary
-
-
-#if defined( __parallel )
-!
-!-- Preliminary determination of processor-id which is needed here to open the
-!-- input files belonging to the corresponding processor and to produce
-!-- messages by PE0 only (myid and myid_char are later determined in
-!-- init_pegrid)
-    CALL MPI_COMM_RANK( comm_palm, myid, ierr )
-    WRITE (myid_char,'(''_'',I4.4)')  myid
-!
-!-- Since on IBM machines the process rank may be changed when the final
-!-- communicator is defined, save the preliminary processor-id for opening
-!-- the binary output file for restarts (unit 14), because otherwise
-!-- a mismatch occurs when reading this file in the next job
-    myid_char_14 = myid_char
-#endif
 
 !
@@ -186,8 +172,12 @@
 !
 !-- If required, read control parameters from restart file (produced by
-!-- a prior run)
+!-- a prior run). All PEs are reading from file created by PE0 (see check_open)
  12 IF ( TRIM( initializing_actions ) == 'read_restart_data' )  THEN
 
        CALL read_var_list
+!
+!--    The restart file will be reopened when reading the subdomain data
+       CALL close_file( 13 )
+
 !
 !--    Increment the run count
@@ -242,15 +232,9 @@
        ENDIF
 
-       ALLOCATE( ug(0:nz+1), vg(0:nz+1), &
-                 pt_init(0:nz+1), q_init(0:nz+1), sa_init(0:nz+1),          &
-                 u_init(0:nz+1), v_init(0:nz+1),                            &
-                 hom(0:nz+1,2,pr_palm+max_pr_user,0:statistic_regions),     &
+       ALLOCATE( lad(0:nz+1),pt_init(0:nz+1), q_init(0:nz+1), sa_init(0:nz+1), &
+                 ug(0:nz+1), u_init(0:nz+1), v_init(0:nz+1), vg(0:nz+1),       &
+                 hom(0:nz+1,2,pr_palm+max_pr_user,0:statistic_regions),        &
                  hom_sum(0:nz+1,pr_palm+max_pr_user,0:statistic_regions) )
        hom = 0.0
-
-       IF ( plant_canopy ) THEN
-          ALLOCATE( lad(0:nz+1) )
-          lad(:) = 0.0
-       ENDIF
 
     ENDIF
Index: palm/trunk/SOURCE/read_3d_binary.f90
===================================================================
--- palm/trunk/SOURCE/read_3d_binary.f90	(revision 145)
+++ palm/trunk/SOURCE/read_3d_binary.f90	(revision 146)
@@ -4,10 +4,10 @@
 ! Actual revisions:
 ! -----------------
-! Restart file has to be re-opened on all PEs except PE0
-! +call of user_read_restart_data,
-! -dopr_time_count,
+! Files from which restart data are to be read are determined and subsequently
+! opened,
+! +call of user_read_restart_data, -dopr_time_count,
 ! hom_sum, volume_flow_area, volume_flow_initial moved to read_var_list,
 ! reading of old profil parameters (cross_..., dopr_crossindex, profile_***)
-! removed
+! removed, initialization of spectrum_x|y removed
 !
 ! Former revisions:
@@ -57,355 +57,763 @@
     IMPLICIT NONE
 
+    CHARACTER (LEN=5)  ::  myid_char_save
     CHARACTER (LEN=10) ::  binary_version, version_on_file
     CHARACTER (LEN=20) ::  field_chr
 
-    INTEGER ::  idum1, myid_on_file, numprocs_on_file, nxl_on_file, &
-                nxr_on_file, nyn_on_file, nys_on_file, nzb_on_file, nzt_on_file
-
-!
-!-- Read data from previous model run. unit 13 already opened in parin
+    INTEGER ::  files_to_be_opened, i, idum1, j, myid_on_file,                &
+                numprocs_on_file, nxlc, nxl_on_file, nxrc, nxr_on_file, nync, &
+                nyn_on_file, nysc, nys_on_file, nzb_on_file, nzt_on_file
+
+    INTEGER, DIMENSION(:), ALLOCATABLE ::  file_list
+
+    REAL, DIMENSION(:,:), ALLOCATABLE     ::  tmp_2d
+    REAL, DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3d, tmp_3dw
+    REAL, DIMENSION(:,:,:,:), ALLOCATABLE ::  tmp_4d
+
+
+!
+!-- Read data from previous model run.
     CALL cpu_log( log_point_s(14), 'read_3d_binary', 'start' )
 
 !
-!-- Restart file has to be re-opened on all PEs except PE0
-    CALL check_open( 13 )
-
-!
-!-- First compare the version numbers
-    READ ( 13 )  version_on_file
-    binary_version = '3.1'
-    IF ( TRIM( version_on_file ) /= TRIM( binary_version ) )  THEN
-       IF ( myid == 0 )  THEN
-          PRINT*, '+++ init_3d_model: version mismatch concerning data ', &
-                  'from prior run'
-          PRINT*, '        version on file    = "', TRIM( version_on_file ),&
-                  '"'
-          PRINT*, '        version in program = "', TRIM( binary_version ), &
-                  '"'
+!-- Check which of the restart files contain data needed for the subdomain
+!-- of this PE
+    files_to_be_opened = 0
+    ALLOCATE( file_list(numprocs_previous_run) )
+
+    DO  i = 1, numprocs_previous_run
+
+!
+!--    Only data which overlap with the current subdomain have to be read
+       IF ( hor_index_bounds_previous_run(1,i-1) <= nxr  .AND.  &
+            hor_index_bounds_previous_run(2,i-1) >= nxl  .AND.  &
+            hor_index_bounds_previous_run(3,i-1) <= nyn  .AND.  &
+            hor_index_bounds_previous_run(4,i-1) >= nys )  THEN
+
+          files_to_be_opened = files_to_be_opened + 1
+          file_list(files_to_be_opened) = i-1
+
        ENDIF
-       CALL local_stop
+
+    ENDDO
+
+    myid_char_save = myid_char
+
+    DO i = 1, numprocs_previous_run
+       WRITE (9,*) 'i=',i-1, ' ibs= ',hor_index_bounds_previous_run(1:4,i-1)
+    ENDDO
+    CALL local_flush( 9 )
+
+    IF ( files_to_be_opened /= 1  .OR.  numprocs /= numprocs_previous_run ) &
+    THEN
+       PRINT*, '*** number of PEs or virtual PE-grid changed in restart run'
+       PRINT*, '    PE', myid, ' will read from files ', &
+               file_list(1:files_to_be_opened)
     ENDIF
 
 !
-!-- Read and compare number of processors, processor-id and array ranges
-    READ ( 13 )  numprocs_on_file, myid_on_file, nxl_on_file, nxr_on_file, &
-                 nys_on_file, nyn_on_file, nzb_on_file, nzt_on_file
-
-    IF ( numprocs_on_file /= numprocs )  THEN
-       PRINT*, '+++ init_3d_model: mismatch between actual data and data '
-       PRINT*, '                   from prior run on PE ', myid
-       PRINT*, '                   numprocs on file = ', numprocs_on_file
-       PRINT*, '                   numprocs         = ', numprocs
-       CALL local_stop
-    ENDIF
-
-    IF ( myid_on_file /= myid )  THEN
-       PRINT*, '+++ init_3d_model: mismatch between actual data and data '
-       PRINT*, '                   from prior run'
-       PRINT*, '                   myid_on_file = ', myid_on_file
-       PRINT*, '                   myid         = ', myid
+!-- Read data from all restart files determined above
+    DO  i = 1, files_to_be_opened
+
+       j = file_list(i)
+!
+!--    Set the filename (underscore followed by four digit processor id)
+       WRITE (myid_char,'(''_'',I4.4)')  j
+       WRITE (9,*) 'myid=',myid,' opening file "',myid_char,'"'
+       CALL local_flush( 9 )
+
+!
+!--    Open the restart file. If this file has been created by PE0 (_0000),
+!--    the global variables at the beginning of the file have to be skipped
+!--    first.
+       CALL check_open( 13 )
+       IF ( j == 0 )  CALL skip_var_list
+
+!
+!--    First compare the version numbers
+       READ ( 13 )  version_on_file
+       binary_version = '3.1'
+       IF ( TRIM( version_on_file ) /= TRIM( binary_version ) )  THEN
+          IF ( myid == 0 )  THEN
+             PRINT*, '+++ init_3d_model: version mismatch concerning data ', &
+                     'from prior run'
+             PRINT*, '        version on file    = "', TRIM( version_on_file ),&
+                     '"'
+             PRINT*, '        version in program = "', TRIM( binary_version ), &
+                     '"'
+          ENDIF
+          CALL local_stop
+       ENDIF
+
+!
+!--    Read number of processors, processor-id, and array ranges.
+!--    Compare the array ranges with those stored in the index bound array.
+       READ ( 13 )  numprocs_on_file, myid_on_file, nxl_on_file, nxr_on_file, &
+                    nys_on_file, nyn_on_file, nzb_on_file, nzt_on_file
+
+       IF ( nxl_on_file /= hor_index_bounds_previous_run(1,j) )  THEN
+          PRINT*, '+++ read_3d_binary: problem with index bound nxl on ', &
+                       ' restart file "', myid_char, '"'
+          PRINT*, '                    nxl = ', nxl_on_file, ' but it should be'
+          PRINT*, '                    = ', hor_index_bounds_previous_run(1,j)
+          PRINT*, '                    from the index bound information array'
 #if defined( __parallel )
-       CALL MPI_ABORT( comm2d, 9999, ierr )
+          CALL MPI_ABORT( comm2d, 9999, ierr )
 #else
-       CALL local_stop
+          CALL local_stop
 #endif
-    ENDIF
-
-    IF ( nxl_on_file /= nxl )  THEN
-       PRINT*, '+++ init_3d_model: mismatch between actual data and data '
-       PRINT*, '                   from prior run on PE ', myid
-       PRINT*, '                   nxl on file = ', nxl_on_file
-       PRINT*, '                   nxl         = ', nxl
+       ENDIF
+
+       IF ( nxr_on_file /= hor_index_bounds_previous_run(2,j) )  THEN
+          PRINT*, '+++ read_3d_binary: problem with index bound nxr on ', &
+                       ' restart file "', myid_char, '"'
+          PRINT*, '                    nxr = ', nxr_on_file, ' but it should be'
+          PRINT*, '                    = ', hor_index_bounds_previous_run(2,j)
+          PRINT*, '                    from the index bound information array'
 #if defined( __parallel )
-       CALL MPI_ABORT( comm2d, 9999, ierr )
+          CALL MPI_ABORT( comm2d, 9999, ierr )
 #else
-       CALL local_stop
+          CALL local_stop
 #endif
-    ENDIF
-
-    IF ( nxr_on_file /= nxr )  THEN
-       PRINT*, '+++ init_3d_model: mismatch between actual data and data '
-       PRINT*, '                   from prior run on PE ', myid
-       PRINT*, '                   nxr on file = ', nxr_on_file
-       PRINT*, '                   nxr         = ', nxr
+       ENDIF
+
+       IF ( nys_on_file /= hor_index_bounds_previous_run(3,j) )  THEN
+          PRINT*, '+++ read_3d_binary: problem with index bound nys on ', &
+                       ' restart file "', myid_char, '"'
+          PRINT*, '                    nys = ', nys_on_file, ' but it should be'
+          PRINT*, '                    = ', hor_index_bounds_previous_run(3,j)
+          PRINT*, '                    from the index bound information array'
 #if defined( __parallel )
-       CALL MPI_ABORT( comm2d, 9999, ierr )
+          CALL MPI_ABORT( comm2d, 9999, ierr )
 #else
-       CALL local_stop
+          CALL local_stop
 #endif
-    ENDIF
-
-    IF ( nys_on_file /= nys )  THEN
-       PRINT*, '+++ init_3d_model: mismatch between actual data and data '
-       PRINT*, '                   from prior run on PE ', myid
-       PRINT*, '                   nys on file = ', nys_on_file
-       PRINT*, '                   nys         = ', nys
+       ENDIF
+
+       IF ( nyn_on_file /= hor_index_bounds_previous_run(4,j) )  THEN
+          PRINT*, '+++ read_3d_binary: problem with index bound nyn on ', &
+                       ' restart file "', myid_char, '"'
+          PRINT*, '                    nyn = ', nyn_on_file, ' but it should be'
+          PRINT*, '                    = ', hor_index_bounds_previous_run(4,j)
+          PRINT*, '                    from the index bound information array'
 #if defined( __parallel )
-       CALL MPI_ABORT( comm2d, 9999, ierr )
+          CALL MPI_ABORT( comm2d, 9999, ierr )
 #else
-       CALL local_stop
+          CALL local_stop
 #endif
-    ENDIF
-
-    IF ( nyn_on_file /= nyn )  THEN
-       PRINT*, '+++ init_3d_model: mismatch between actual data and data '
-       PRINT*, '                   from prior run on PE ', myid
-       PRINT*, '                   nyn on file = ', nyn_on_file
-       PRINT*, '                   nyn         = ', nyn
-#if defined( __parallel )
-       CALL MPI_ABORT( comm2d, 9999, ierr )
-#else
-       CALL local_stop
-#endif
-    ENDIF
-
-    IF ( nzb_on_file /= nzb )  THEN
-       PRINT*, '+++ init_3d_model: mismatch between actual data and data '
-       PRINT*, '                   from prior run on PE ', myid
-       PRINT*, '                   nzb on file = ', nzb_on_file
-       PRINT*, '                   nzb         = ', nzb
-       CALL local_stop
-    ENDIF
-
-    IF ( nzt_on_file /= nzt )  THEN
-       PRINT*, '+++ init_3d_model: mismatch between actual data and data '
-       PRINT*, '                   from prior run on PE ', myid
-       PRINT*, '                   nzt on file = ', nzt_on_file
-       PRINT*, '                   nzt         = ', nzt
-       CALL local_stop
-    ENDIF
-
-!
-!-- Initialize spectra (for the case of just starting spectra computation
-!-- in continuation runs)
-    IF ( dt_dosp /= 9999999.9 )  THEN
-       spectrum_x = 0.0
-       spectrum_y = 0.0
-    ENDIF
-
-!
-!-- Read arrays
-!-- ATTENTION: If the following read commands have been altered, the 
-!-- ---------- version number of the variable binary_version must be altered,
-!--            too. Furthermore, the output list of arrays in write_3d_binary
-!--            must also be altered accordingly.
-    READ ( 13 )  field_chr
-    DO  WHILE ( TRIM( field_chr ) /= '*** end ***' )
-
-       SELECT CASE ( TRIM( field_chr ) )
-
-          CASE ( 'e' )
-             READ ( 13 )  e
-          CASE ( 'e_av' )
-             ALLOCATE( e_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  e_av
-          CASE ( 'e_m' )
-             READ ( 13 )  e_m
-          CASE ( 'iran' )
-             READ ( 13 )  iran, iran_part
-          CASE ( 'kh' )
-             READ ( 13 )  kh
-          CASE ( 'kh_m' )
-             READ ( 13 )  kh_m
-          CASE ( 'km' )
-             READ ( 13 )  km
-          CASE ( 'km_m' )
-             READ ( 13 )  km_m
-          CASE ( 'lwp_av' )
-             ALLOCATE( lwp_av(nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  lwp_av
-          CASE ( 'p' )
-             READ ( 13 )  p
-          CASE ( 'p_av' )
-             ALLOCATE( p_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  p_av
-          CASE ( 'pc_av' )
-             ALLOCATE( pc_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  pc_av
-          CASE ( 'pr_av' )
-             ALLOCATE( pr_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  pr_av
-          CASE ( 'precipitation_amount' )
-             READ ( 13 )  precipitation_amount
-          CASE ( 'precipitation_rate_a' )
-             ALLOCATE( precipitation_rate_av(nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  precipitation_rate_av
-          CASE ( 'pt' )
-             READ ( 13 )  pt
-          CASE ( 'pt_av' )
-             ALLOCATE( pt_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  pt_av
-          CASE ( 'pt_m' )
-             READ ( 13 )  pt_m
-          CASE ( 'q' )
-             READ ( 13 )  q
-          CASE ( 'q_av' )
-             ALLOCATE( q_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  q_av
-          CASE ( 'q_m' )
-             READ ( 13 )  q_m
-          CASE ( 'ql' )
-             READ ( 13 )  ql
-          CASE ( 'ql_av' )
-             ALLOCATE( ql_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  ql_av
-          CASE ( 'ql_c_av' )
-             ALLOCATE( ql_c_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  ql_c_av
-          CASE ( 'ql_v_av' )
-             ALLOCATE( ql_v_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  ql_v_av
-          CASE ( 'ql_vp_av' )
-             ALLOCATE( ql_vp_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  ql_vp_av
-          CASE ( 'qs' )
-             READ ( 13 )  qs
-          CASE ( 'qsws' )
-             READ ( 13 )  qsws
-          CASE ( 'qsws_m' )
-             READ ( 13 )  qsws_m
-          CASE ( 'qswst' )
-             READ ( 13 )  qswst
-          CASE ( 'qswst_m' )
-             READ ( 13 )  qswst_m
-          CASE ( 'qv_av' )
-             ALLOCATE( qv_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  qv_av
-          CASE ( 'random_iv' )
-             READ ( 13 )  random_iv
-             READ ( 13 )  random_iy
-          CASE ( 'rho_av' )
-             ALLOCATE( rho_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  rho_av
-          CASE ( 'rif' )
-             READ ( 13 )  rif
-          CASE ( 'rif_m' )
-             READ ( 13 )  rif_m
-          CASE ( 'rif_wall' )
-             READ ( 13 )  rif_wall
-          CASE ( 's_av' )
-             ALLOCATE( s_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  s_av
-          CASE ( 'sa' )
-             READ ( 13 )  sa
-          CASE ( 'sa_av' )
-             ALLOCATE( sa_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  sa_av
-          CASE ( 'saswsb' )
-             READ ( 13 )  saswsb
-          CASE ( 'saswst' )
-             READ ( 13 )  saswst
-          CASE ( 'shf' )
-             READ ( 13 )  shf
-          CASE ( 'shf_m' )
-             READ ( 13 )  shf_m
-          CASE ( 'spectrum_x' )
-             READ ( 13 )  spectrum_x
-          CASE ( 'spectrum_y' )
-             READ ( 13 )  spectrum_y
-          CASE ( 'ts' )
-             READ ( 13 )  ts
-          CASE ( 'ts_av' )
-             ALLOCATE( ts_av(nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  ts_av
-          CASE ( 'tswst' )
-             READ ( 13 )  tswst
-          CASE ( 'tswst_m' )
-             READ ( 13 )  tswst_m
-          CASE ( 'u' )
-             READ ( 13 )  u
-          CASE ( 'u_av' )
-             ALLOCATE( u_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  u_av
-          CASE ( 'u_m' )
-             READ ( 13 )  u_m
-          CASE ( 'u_m_l' )
-             READ ( 13 )  u_m_l
-          CASE ( 'u_m_n' )
-             READ ( 13 )  u_m_n
-          CASE ( 'u_m_r' )
-             READ ( 13 )  u_m_r
-          CASE ( 'u_m_s' )
-             READ ( 13 )  u_m_s
-          CASE ( 'us' )
-             READ ( 13 )  us
-          CASE ( 'usws' )
-             READ ( 13 )  usws
-          CASE ( 'uswst' )
-             READ ( 13 )  uswst
-          CASE ( 'usws_m' )
-             READ ( 13 )  usws_m
-          CASE ( 'uswst_m' )
-             READ ( 13 )  uswst_m
-          CASE ( 'us_av' )
-             ALLOCATE( us_av(nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  us_av
-          CASE ( 'v' )
-             READ ( 13 )  v
-          CASE ( 'v_av' )
-             ALLOCATE( v_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  v_av
-          CASE ( 'v_m' )
-             READ (13 )   v_m
-          CASE ( 'v_m_l' )
-             READ ( 13 )  v_m_l
-          CASE ( 'v_m_n' )
-             READ ( 13 )  v_m_n
-          CASE ( 'v_m_r' )
-             READ ( 13 )  v_m_r
-          CASE ( 'v_m_s' )
-             READ ( 13 )  v_m_s
-          CASE ( 'vpt' )
-             READ ( 13 )  vpt
-          CASE ( 'vpt_av' )
-             ALLOCATE( vpt_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  vpt_av
-          CASE ( 'vpt_m' )
-             READ ( 13 )  vpt_m
-          CASE ( 'vsws' )
-             READ ( 13 )  vsws
-          CASE ( 'vswst' )
-             READ ( 13 )  vswst
-          CASE ( 'vsws_m' )
-             READ ( 13 )  vsws_m
-          CASE ( 'vswst_m' )
-             READ ( 13 )  vswst_m
-          CASE ( 'w' )
-             READ ( 13 )  w
-          CASE ( 'w_av' )
-             ALLOCATE( w_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  w_av
-          CASE ( 'w_m' )
-             READ ( 13 )  w_m
-          CASE ( 'w_m_l' )
-             READ ( 13 )  w_m_l
-          CASE ( 'w_m_n' )
-             READ ( 13 )  w_m_n
-          CASE ( 'w_m_r' )
-             READ ( 13 )  w_m_r
-          CASE ( 'w_m_s' )
-             READ ( 13 )  w_m_s
-          CASE ( 'z0' )
-             READ ( 13 )  z0
-          CASE ( 'z0_av' )
-             ALLOCATE( z0_av(nys-1:nyn+1,nxl-1:nxr+1) )
-             READ ( 13 )  z0_av
-
-          CASE DEFAULT
-             PRINT*, '+++ init_3d_model: unknown field named "', &
-                     TRIM( field_chr ), '" found in'
-             PRINT*, '                   data from prior run on PE ', myid
-             CALL local_stop
-
-       END SELECT
-!
-!--    Read next character string
+       ENDIF
+
+       IF ( nzb_on_file /= nzb )  THEN
+          PRINT*, '+++ read_3d_binary: mismatch between actual data and data '
+          PRINT*, '                    from prior run on PE ', myid
+          PRINT*, '                    nzb on file = ', nzb_on_file
+          PRINT*, '                    nzb         = ', nzb
+          CALL local_stop
+       ENDIF
+
+       IF ( nzt_on_file /= nzt )  THEN
+          PRINT*, '+++ read_3d_binary: mismatch between actual data and data '
+          PRINT*, '                    from prior run on PE ', myid
+          PRINT*, '                    nzt on file = ', nzt_on_file
+          PRINT*, '                    nzt         = ', nzt
+          CALL local_stop
+       ENDIF
+
+!
+!--    Allocate temporary arrays sized as the arrays on the restart file
+       ALLOCATE( tmp_2d(nys_on_file-1:nyn_on_file+1,           &
+                        nxl_on_file-1:nxr_on_file+1),          &
+                 tmp_3d(nzb:nzt+1,nys_on_file-1:nyn_on_file+1, &
+                        nxl_on_file-1:nxr_on_file+1) )
+
+!
+!--    Determine the index range of those gridpoints to be copied from
+!--    the subdomains on the restart files to the current subdomain
+       nxlc = MAX( nxl, nxl_on_file )
+       nxrc = MIN( nxr, nxr_on_file )
+       nysc = MAX( nys, nys_on_file )
+       nync = MIN( nyn, nyn_on_file )
+
+!
+!--    Read arrays
+!--    ATTENTION: If the following read commands have been altered, the 
+!--    ---------- version number of the variable binary_version must be altered,
+!--               too. Furthermore, the output list of arrays in write_3d_binary
+!--               must also be altered accordingly.
        READ ( 13 )  field_chr
-
-    ENDDO
-
-!
-!-- Read user-defined restart data
-    CALL user_read_restart_data
+       DO  WHILE ( TRIM( field_chr ) /= '*** end ***' )
+
+          SELECT CASE ( TRIM( field_chr ) )
+
+             CASE ( 'e' )
+                READ ( 13 )  tmp_3d
+                e(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'e_av' )
+                IF ( .NOT. ALLOCATED( e_av ) )  THEN
+                   ALLOCATE( e_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                e_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'e_m' )
+                READ ( 13 )  tmp_3d
+                e_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'iran' ) ! matching random numbers is still unresolved issue
+                READ ( 13 )  iran, iran_part
+
+             CASE ( 'kh' )
+                READ ( 13 )  tmp_3d
+                kh(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'kh_m' )
+                READ ( 13 )  tmp_3d
+                kh_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'km' )
+                READ ( 13 )  tmp_3d
+                km(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'km_m' )
+                READ ( 13 )  tmp_3d
+                km_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'lwp_av' )
+                IF ( .NOT. ALLOCATED( lwp_av ) )  THEN
+                   ALLOCATE( lwp_av(nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_2d
+                lwp_av(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'p' )
+                READ ( 13 )  tmp_3d
+                p(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'p_av' )
+                IF ( .NOT. ALLOCATED( p_av ) )  THEN
+                   ALLOCATE( p_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                p_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'pc_av' )
+                IF ( .NOT. ALLOCATED( pc_av ) )  THEN
+                   ALLOCATE( pc_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                pc_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'pr_av' )
+                IF ( .NOT. ALLOCATED( pr_av ) )  THEN
+                   ALLOCATE( pr_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                pr_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'precipitation_amount' )
+                READ ( 13 )  tmp_2d
+                precipitation_amount(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'precipitation_rate_a' )
+                IF ( .NOT. ALLOCATED( precipitation_rate_av ) )  THEN
+                   ALLOCATE( precipitation_rate_av(nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_2d
+                precipitation_rate_av(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'pt' )
+                READ ( 13 )  tmp_3d
+                pt(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'pt_av' )
+                IF ( .NOT. ALLOCATED( pt_av ) )  THEN
+                   ALLOCATE( pt_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                pt_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'pt_m' )
+                READ ( 13 )  tmp_3d
+                pt_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'q' )
+                READ ( 13 )  tmp_3d
+                q(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'q_av' )
+                IF ( .NOT. ALLOCATED( q_av ) )  THEN
+                   ALLOCATE( q_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                q_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'q_m' )
+                READ ( 13 )  tmp_3d
+                q_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'ql' )
+                READ ( 13 )  tmp_3d
+                ql(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'ql_av' )
+                IF ( .NOT. ALLOCATED( ql_av ) )  THEN
+                   ALLOCATE( ql_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                ql_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'ql_c_av' )
+                IF ( .NOT. ALLOCATED( ql_c_av ) )  THEN
+                   ALLOCATE( ql_c_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                ql_c_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'ql_v_av' )
+                IF ( .NOT. ALLOCATED( ql_v_av ) )  THEN
+                   ALLOCATE( ql_v_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                ql_v_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'ql_vp_av' )
+                IF ( .NOT. ALLOCATED( ql_vp_av ) )  THEN
+                   ALLOCATE( ql_vp_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                ql_vp_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'qs' )
+                READ ( 13 )  tmp_2d
+                qs(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'qsws' )
+                READ ( 13 )  tmp_2d
+                qsws(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'qsws_m' )
+                READ ( 13 )  tmp_2d
+                qsws_m(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'qswst' )
+                READ ( 13 )  tmp_2d
+                qswst(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'qswst_m' )
+                READ ( 13 )  tmp_2d
+                qswst_m(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'qv_av' )
+                IF ( .NOT. ALLOCATED( qv_av ) )  THEN
+                   ALLOCATE( qv_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                qv_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'random_iv' )  ! still unresolved issue
+                READ ( 13 )  random_iv
+                READ ( 13 )  random_iy
+
+             CASE ( 'rho_av' )
+                IF ( .NOT. ALLOCATED( rho_av ) )  THEN
+                   ALLOCATE( rho_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                rho_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'rif' )
+                READ ( 13 )  tmp_2d
+                rif(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'rif_m' )
+                READ ( 13 )  tmp_2d
+                rif_m(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'rif_wall' )
+                ALLOCATE( tmp_4d(nzb:nzt+1,nys_on_file-1:nyn_on_file+1, &
+                                 nxl_on_file-1:nxr_on_file+1,1:4) )
+                READ ( 13 )  tmp_4d
+                rif_wall(:,nysc-1:nync+1,nxlc-1:nxrc+1,:) = &
+                                         tmp_4d(:,nysc-1:nync+1,nxlc-1:nxrc+1,:)
+                DEALLOCATE( tmp_4d )
+
+             CASE ( 's_av' )
+                IF ( .NOT. ALLOCATED( s_av ) )  THEN
+                   ALLOCATE( s_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                s_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'sa' )
+                READ ( 13 )  tmp_3d
+                sa(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'sa_av' )
+                IF ( .NOT. ALLOCATED( sa_av ) )  THEN
+                   ALLOCATE( sa_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                sa_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'saswsb' )
+                READ ( 13 )  tmp_2d
+                saswsb(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'saswst' )
+                READ ( 13 )  tmp_2d
+                saswst(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'shf' )
+                READ ( 13 )  tmp_2d
+                shf(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'shf_m' )
+                READ ( 13 )  tmp_2d
+                shf_m(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'spectrum_x' )
+                READ ( 13 )  spectrum_x
+
+             CASE ( 'spectrum_y' )
+                READ ( 13 )  spectrum_y
+
+             CASE ( 'ts' )
+                READ ( 13 )  tmp_2d
+                ts(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'ts_av' )
+                IF ( .NOT. ALLOCATED( ts_av ) )  THEN
+                   ALLOCATE( ts_av(nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_2d
+                ts_av(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'tswst' )
+                READ ( 13 )  tmp_2d
+                tswst(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'tswst_m' )
+                READ ( 13 )  tmp_2d
+                tswst_m(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'u' )
+                READ ( 13 )  tmp_3d
+                u(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'u_av' )
+                IF ( .NOT. ALLOCATED( u_av ) )  THEN
+                   ALLOCATE( u_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                u_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'u_m' )
+                READ ( 13 )  tmp_3d
+                u_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'u_m_l' )
+                ALLOCATE( tmp_3dw(nzb:nzt+1,nys_on_file-1:nyn_on_file+1,1:2) )
+                READ ( 13 )  tmp_3dw
+                IF ( outflow_l )  THEN
+                   u_m_l(:,nysc-1:nync+1,:) = tmp_3dw(:,nysc-1:nync+1,:)
+                ENDIF
+                DEALLOCATE( tmp_3dw )
+
+             CASE ( 'u_m_n' )
+                ALLOCATE( tmp_3dw(nzb:nzt+1,ny-1:ny, &
+                                  nxl_on_file-1:nxr_on_file+1) )
+                READ ( 13 )  tmp_3dw
+                IF ( outflow_n )  THEN
+                   u_m_n(:,:,nxlc-1:nxrc+1) = tmp_3dw(:,:,nxlc-1:nxrc+1)
+                ENDIF
+                DEALLOCATE( tmp_3dw )
+
+             CASE ( 'u_m_r' )
+                ALLOCATE( tmp_3dw(nzb:nzt+1,nys_on_file-1:nyn_on_file+1, &
+                                  nx-1:nx) )
+                READ ( 13 )  tmp_3dw
+                IF ( outflow_r )  THEN
+                   u_m_r(:,nysc-1:nync+1,:) = tmp_3dw(:,nysc-1:nync+1,:)
+                ENDIF
+                DEALLOCATE( tmp_3dw )
+
+             CASE ( 'u_m_s' )
+                ALLOCATE( tmp_3dw(nzb:nzt+1,0:1, &
+                                  nxl_on_file-1:nxr_on_file+1) )
+                READ ( 13 )  tmp_3dw
+                IF ( outflow_s )  THEN
+                   u_m_s(:,:,nxlc-1:nxrc+1) = tmp_3dw(:,:,nxlc-1:nxrc+1)
+                ENDIF
+                DEALLOCATE( tmp_3dw )
+
+             CASE ( 'us' )
+                READ ( 13 )  tmp_2d
+                us(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'usws' )
+                READ ( 13 )  tmp_2d
+                usws(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'uswst' )
+                READ ( 13 )  tmp_2d
+                uswst(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'usws_m' )
+                READ ( 13 )  tmp_2d
+                usws_m(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'uswst_m' )
+                READ ( 13 )  tmp_2d
+                uswst_m(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'us_av' )
+                IF ( .NOT. ALLOCATED( us_av ) )  THEN
+                   ALLOCATE( us_av(nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_2d
+                us_av(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'v' )
+                READ ( 13 )  tmp_3d
+                v(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'v_av' )
+                IF ( .NOT. ALLOCATED( v_av ) )  THEN
+                   ALLOCATE( v_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                v_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'v_m' )
+                READ ( 13 )  tmp_3d
+                v_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'v_m_l' )
+                ALLOCATE( tmp_3dw(nzb:nzt+1,nys_on_file-1:nyn_on_file+1,0:1) )
+                READ ( 13 )  tmp_3dw
+                IF ( outflow_l )  THEN
+                   v_m_l(:,nysc-1:nync+1,:) = tmp_3dw(:,nysc-1:nync+1,:)
+                ENDIF
+                DEALLOCATE( tmp_3dw )
+
+             CASE ( 'v_m_n' )
+                ALLOCATE( tmp_3dw(nzb:nzt+1,ny-1:ny, &
+                                  nxl_on_file-1:nxr_on_file+1) )
+                READ ( 13 )  tmp_3dw
+                IF ( outflow_n )  THEN
+                   v_m_n(:,:,nxlc-1:nxrc+1) = tmp_3dw(:,:,nxlc-1:nxrc+1)
+                ENDIF
+                DEALLOCATE( tmp_3dw )
+
+             CASE ( 'v_m_r' )
+                ALLOCATE( tmp_3dw(nzb:nzt+1,nys_on_file-1:nyn_on_file+1, &
+                                  nx-1:nx) )
+                READ ( 13 )  tmp_3dw
+                IF ( outflow_r )  THEN
+                   v_m_r(:,nysc-1:nync+1,:) = tmp_3dw(:,nysc-1:nync+1,:)
+                ENDIF
+                DEALLOCATE( tmp_3dw )
+
+             CASE ( 'v_m_s' )
+                ALLOCATE( tmp_3dw(nzb:nzt+1,1:2, &
+                                  nxl_on_file-1:nxr_on_file+1) )
+                READ ( 13 )  tmp_3dw
+                IF ( outflow_s )  THEN
+                   v_m_s(:,:,nxlc-1:nxrc+1) = tmp_3dw(:,:,nxlc-1:nxrc+1)
+                ENDIF
+                DEALLOCATE( tmp_3dw )
+
+             CASE ( 'vpt' )
+                READ ( 13 )  tmp_3d
+                vpt(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'vpt_av' )
+                IF ( .NOT. ALLOCATED( vpt_av ) )  THEN
+                   ALLOCATE( vpt_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                vpt_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'vpt_m' )
+                READ ( 13 )  tmp_3d
+                vpt_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'vsws' )
+                READ ( 13 )  tmp_2d
+                vsws(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'vswst' )
+                READ ( 13 )  tmp_2d
+                vswst(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'vsws_m' )
+                READ ( 13 )  tmp_2d
+                vsws_m(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'vswst_m' )
+                READ ( 13 )  tmp_2d
+                vswst_m(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'w' )
+                READ ( 13 )  tmp_3d
+                w(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'w_av' )
+                IF ( .NOT. ALLOCATED( w_av ) )  THEN
+                   ALLOCATE( w_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_3d
+                w_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'w_m' )
+                READ ( 13 )  tmp_3d
+                w_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_3d(:,nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'w_m_l' )
+                ALLOCATE( tmp_3dw(nzb:nzt+1,nys_on_file-1:nyn_on_file+1,0:1) )
+                READ ( 13 )  tmp_3dw
+                IF ( outflow_l )  THEN
+                   w_m_l(:,nysc-1:nync+1,:) = tmp_3dw(:,nysc-1:nync+1,:)
+                ENDIF
+                DEALLOCATE( tmp_3dw )
+
+             CASE ( 'w_m_n' )
+                ALLOCATE( tmp_3dw(nzb:nzt+1,ny-1:ny, &
+                                  nxl_on_file-1:nxr_on_file+1) )
+                READ ( 13 )  tmp_3dw
+                IF ( outflow_n )  THEN
+                   w_m_n(:,:,nxlc-1:nxrc+1) = tmp_3dw(:,:,nxlc-1:nxrc+1)
+                ENDIF
+                DEALLOCATE( tmp_3dw )
+
+             CASE ( 'w_m_r' )
+                ALLOCATE( tmp_3dw(nzb:nzt+1,nys_on_file-1:nyn_on_file+1, &
+                                  nx-1:nx) )
+                READ ( 13 )  tmp_3dw
+                IF ( outflow_r )  THEN
+                   w_m_r(:,nysc-1:nync+1,:) = tmp_3dw(:,nysc-1:nync+1,:)
+                ENDIF
+                DEALLOCATE( tmp_3dw )
+
+             CASE ( 'w_m_s' )
+                ALLOCATE( tmp_3dw(nzb:nzt+1,0:1, &
+                                  nxl_on_file-1:nxr_on_file+1) )
+                READ ( 13 )  tmp_3dw
+                IF ( outflow_s )  THEN
+                   w_m_s(:,:,nxlc-1:nxrc+1) = tmp_3dw(:,:,nxlc-1:nxrc+1)
+                ENDIF
+                DEALLOCATE( tmp_3dw )
+
+             CASE ( 'z0' )
+                READ ( 13 )  tmp_2d
+                z0(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE ( 'z0_av' )
+                IF ( .NOT. ALLOCATED( z0_av ) )  THEN
+                   ALLOCATE( z0_av(nys-1:nyn+1,nxl-1:nxr+1) )
+                ENDIF
+                READ ( 13 )  tmp_2d
+                z0_av(nysc-1:nync+1,nxlc-1:nxrc+1) = &
+                                          tmp_2d(nysc-1:nync+1,nxlc-1:nxrc+1)
+
+             CASE DEFAULT
+                PRINT*, '+++ read_3d_binary: unknown field named "', &
+                        TRIM( field_chr ), '" found in'
+                PRINT*, '                    data from prior run on PE ', myid
+                CALL local_stop
+
+          END SELECT
+!
+!--       Read next character string
+          READ ( 13 )  field_chr
+
+       ENDDO  ! loop over variables
+
+!
+!--    Read user-defined restart data
+       CALL user_read_restart_data
+
+!
+!--    Close the restart file
+       CALL close_file( 13 )
+
+       DEALLOCATE( tmp_2d, tmp_3d )
+
+    ENDDO  ! loop over restart files
+
+
+!
+!-- Restore the original filename for the restart file to be written
+    myid_char = myid_char_save
+
 
 !
Index: palm/trunk/SOURCE/read_var_list.f90
===================================================================
--- palm/trunk/SOURCE/read_var_list.f90	(revision 145)
+++ palm/trunk/SOURCE/read_var_list.f90	(revision 146)
@@ -4,9 +4,9 @@
 ! Actual revisions:
 ! -----------------
-! After reading the global variables, unit 13 is closed for all PEs except PE0
 ! +numprocs_previous_run, hor_index_bounds_previous_run,
 ! -cross_ts_*, npex, npey,
 ! hom_sum, volume_flow_area, volume_flow_initial moved from
-! read_3d_binary to here
+! read_3d_binary to here,
+! routine skip_var_list added at the end
 !
 ! Former revisions:
@@ -97,5 +97,7 @@
     READ ( 13 )  numprocs_previous_run
 
-    ALLOCATE( hor_index_bounds_previous_run(4,0:numprocs_previous_run-1) )
+    IF ( .NOT. ALLOCATED( hor_index_bounds_previous_run ) )  THEN
+       ALLOCATE( hor_index_bounds_previous_run(4,0:numprocs_previous_run-1) )
+    ENDIF
 
     READ ( 13 )  variable_chr
@@ -145,8 +147,10 @@
     ENDIF
     READ ( 13 )  statistic_regions
-    ALLOCATE( ug(0:nz+1), u_init(0:nz+1), vg(0:nz+1), v_init(0:nz+1), & 
-              pt_init(0:nz+1), q_init(0:nz+1), sa_init(0:nz+1),       &
-              hom(0:nz+1,2,pr_palm+max_pr_user,0:statistic_regions),  &
-              hom_sum(0:nz+1,pr_palm+max_pr_user,0:statistic_regions) )
+    IF ( .NOT. ALLOCATED( ug ) )  THEN
+       ALLOCATE( ug(0:nz+1), u_init(0:nz+1), vg(0:nz+1), v_init(0:nz+1), & 
+                 pt_init(0:nz+1), q_init(0:nz+1), sa_init(0:nz+1),       &
+                 hom(0:nz+1,2,pr_palm+max_pr_user,0:statistic_regions),  &
+                 hom_sum(0:nz+1,pr_palm+max_pr_user,0:statistic_regions) )
+    ENDIF
 
 !
@@ -533,6 +537,34 @@
     ENDDO
 
-    IF ( myid /= 0 )  CALL close_file( 13 )
-
 
  END SUBROUTINE read_var_list
+
+
+
+ SUBROUTINE skip_var_list
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+! Skipping the global control variables from restart-file (binary format)
+!------------------------------------------------------------------------------!
+
+    CHARACTER (LEN=10) ::  version_on_file
+    CHARACTER (LEN=30) ::  variable_chr
+
+    INTEGER ::  idum
+
+
+    READ ( 13 )  version_on_file
+
+    READ ( 13 )  variable_chr
+
+    DO  WHILE ( TRIM( variable_chr ) /= '*** end ***' )
+
+       READ ( 13 )  idum
+       READ ( 13 )  variable_chr
+
+    ENDDO
+
+
+ END SUBROUTINE skip_var_list
