Index: palm/trunk/SOURCE/read_restart_data_mod.f90
===================================================================
--- palm/trunk/SOURCE/read_restart_data_mod.f90	(revision 4514)
+++ palm/trunk/SOURCE/read_restart_data_mod.f90	(revision 4517)
@@ -1147,5 +1147,5 @@
 
 !
-!--    Close restart File
+!--    Close restart file
        CALL rd_mpi_io_close
 
@@ -1376,5 +1376,5 @@
 ! Description:
 ! ------------
-!> Reads processor specific data of variables and arrays from restart file
+!> Reads processor (subdomain) specific data of variables and arrays from restart file
 !> (binary format).
 !------------------------------------------------------------------------------!
@@ -1385,4 +1385,5 @@
     CHARACTER (LEN=10) ::  binary_version_local
     CHARACTER (LEN=10) ::  version_on_file
+    CHARACTER (LEN=20) ::  tmp_name               !< temporary variable
 
     INTEGER(iwp) ::  files_to_be_opened  !<
@@ -1428,5 +1429,6 @@
     INTEGER(isp), DIMENSION(:,:,:), ALLOCATABLE ::  tmp_2d_seq_random  !< temporary array for storing random generator data
 
-    LOGICAL ::  found
+    LOGICAL ::  array_found                      !<
+    LOGICAL ::  found                            !<
 
     REAL(wp), DIMENSION(:,:),   ALLOCATABLE   ::  tmp_2d         !< temporary array for storing 2D data
@@ -1438,816 +1440,1193 @@
 !-- Read data from previous model run.
     CALL cpu_log( log_point_s(14), 'rrd_local', 'start' )
-!
-!-- Allocate temporary buffer arrays. In previous versions, there were
-!-- declared as automated arrays, causing memory problems when these
-!-- were allocate on stack.
-    ALLOCATE( nxlfa(numprocs_previous_run,1000) )
-    ALLOCATE( nxrfa(numprocs_previous_run,1000) )
-    ALLOCATE( nynfa(numprocs_previous_run,1000) )
-    ALLOCATE( nysfa(numprocs_previous_run,1000) )
-    ALLOCATE( offset_xa(numprocs_previous_run,1000) )
-    ALLOCATE( offset_ya(numprocs_previous_run,1000) )
-
-!
-!-- Check which of the restart files contain data needed for the subdomain
-!-- of this PE
-    files_to_be_opened = 0
-
-    DO  i = 1, numprocs_previous_run
-!
-!--    Store array bounds of the previous run ("pr") in temporary scalars
-       nxlpr = hor_index_bounds_previous_run(1,i-1)
-       nxrpr = hor_index_bounds_previous_run(2,i-1)
-       nyspr = hor_index_bounds_previous_run(3,i-1)
-       nynpr = hor_index_bounds_previous_run(4,i-1)
-
-!
-!--    Determine the offsets. They may be non-zero in case that the total domain
-!--    on file is smaller than the current total domain.
-       offset_x = ( nxl / ( nx_on_file + 1 ) ) * ( nx_on_file + 1 )
-       offset_y = ( nys / ( ny_on_file + 1 ) ) * ( ny_on_file + 1 )
-
-!
-!--    Start with this offset and then check, if the subdomain on file
-!--    matches another time(s) in the current subdomain by shifting it
-!--    for nx_on_file+1, ny_on_file+1 respectively
-
-       shift_y = 0
-       j       = 0
-       DO WHILE (  nyspr+shift_y <= nyn-offset_y )
-
-          IF ( nynpr+shift_y >= nys-offset_y ) THEN
-
-             shift_x = 0
-             DO WHILE ( nxlpr+shift_x <= nxr-offset_x )
-
-                IF ( nxrpr+shift_x >= nxl-offset_x ) THEN
-                   j = j +1
-                   IF ( j > 1000 )  THEN
-!
-!--                   Array bound exceeded
-                      message_string = 'data from subdomain of previous' //                        &
-                                       ' run mapped more than 1000 times'
-                      CALL message( 'rrd_local', 'PA0284', 2, 2, -1, 6, 1 )
+
+    IF ( TRIM( restart_data_format_input ) == 'fortran_binary' )  THEN
+!
+!--    Input in Fortran binary format
+
+!
+!--    Allocate temporary buffer arrays. In previous versions, there were
+!--    declared as automated arrays, causing memory problems when these
+!--    were allocate on stack.
+       ALLOCATE( nxlfa(numprocs_previous_run,1000) )
+       ALLOCATE( nxrfa(numprocs_previous_run,1000) )
+       ALLOCATE( nynfa(numprocs_previous_run,1000) )
+       ALLOCATE( nysfa(numprocs_previous_run,1000) )
+       ALLOCATE( offset_xa(numprocs_previous_run,1000) )
+       ALLOCATE( offset_ya(numprocs_previous_run,1000) )
+
+!
+!--    Check which of the restart files contain data needed for the subdomain
+!--    of this PE
+       files_to_be_opened = 0
+
+       DO  i = 1, numprocs_previous_run
+!
+!--       Store array bounds of the previous run ("pr") in temporary scalars
+          nxlpr = hor_index_bounds_previous_run(1,i-1)
+          nxrpr = hor_index_bounds_previous_run(2,i-1)
+          nyspr = hor_index_bounds_previous_run(3,i-1)
+          nynpr = hor_index_bounds_previous_run(4,i-1)
+
+!
+!--       Determine the offsets. They may be non-zero in case that the total domain
+!--       on file is smaller than the current total domain.
+          offset_x = ( nxl / ( nx_on_file + 1 ) ) * ( nx_on_file + 1 )
+          offset_y = ( nys / ( ny_on_file + 1 ) ) * ( ny_on_file + 1 )
+
+!
+!--       Start with this offset and then check, if the subdomain on file
+!--       matches another time(s) in the current subdomain by shifting it
+!--       for nx_on_file+1, ny_on_file+1 respectively
+
+          shift_y = 0
+          j       = 0
+          DO WHILE (  nyspr+shift_y <= nyn-offset_y )
+
+             IF ( nynpr+shift_y >= nys-offset_y ) THEN
+
+                shift_x = 0
+                DO WHILE ( nxlpr+shift_x <= nxr-offset_x )
+
+                   IF ( nxrpr+shift_x >= nxl-offset_x ) THEN
+                      j = j +1
+                      IF ( j > 1000 )  THEN
+!
+!--                      Array bound exceeded
+                         message_string = 'data from subdomain of previous' //                        &
+                                          ' run mapped more than 1000 times'
+                         CALL message( 'rrd_local', 'PA0284', 2, 2, -1, 6, 1 )
+                      ENDIF
+
+                      IF ( j == 1 )  THEN
+                         files_to_be_opened = files_to_be_opened + 1
+                         file_list(files_to_be_opened) = i-1
+                      ENDIF
+
+                      offset_xa(files_to_be_opened,j) = offset_x + shift_x
+                      offset_ya(files_to_be_opened,j) = offset_y + shift_y
+!
+!--                   Index bounds of overlapping data
+                      nxlfa(files_to_be_opened,j) = MAX( nxl-offset_x-shift_x, nxlpr )
+                      nxrfa(files_to_be_opened,j) = MIN( nxr-offset_x-shift_x, nxrpr )
+                      nysfa(files_to_be_opened,j) = MAX( nys-offset_y-shift_y, nyspr )
+                      nynfa(files_to_be_opened,j) = MIN( nyn-offset_y-shift_y, nynpr )
+
                    ENDIF
 
-                   IF ( j == 1 )  THEN
-                      files_to_be_opened = files_to_be_opened + 1
-                      file_list(files_to_be_opened) = i-1
-                   ENDIF
-
-                   offset_xa(files_to_be_opened,j) = offset_x + shift_x
-                   offset_ya(files_to_be_opened,j) = offset_y + shift_y
-!
-!--                Index bounds of overlapping data
-                   nxlfa(files_to_be_opened,j) = MAX( nxl-offset_x-shift_x, nxlpr )
-                   nxrfa(files_to_be_opened,j) = MIN( nxr-offset_x-shift_x, nxrpr )
-                   nysfa(files_to_be_opened,j) = MAX( nys-offset_y-shift_y, nyspr )
-                   nynfa(files_to_be_opened,j) = MIN( nyn-offset_y-shift_y, nynpr )
-
-                ENDIF
-
-                shift_x = shift_x + ( nx_on_file + 1 )
-             ENDDO
-
+                   shift_x = shift_x + ( nx_on_file + 1 )
+                ENDDO
+
+             ENDIF
+
+             shift_y = shift_y + ( ny_on_file + 1 )
+          ENDDO
+
+          IF ( j > 0 )  overlap_count(files_to_be_opened) = j
+
+       ENDDO
+
+!
+!--    Save the id-string of the current process, since myid_char may now be used
+!--    to open files created by PEs with other id.
+       myid_char_save = myid_char
+
+       IF ( files_to_be_opened /= 1  .OR.  numprocs /= numprocs_previous_run )  THEN
+          WRITE( message_string, * ) 'number of PEs or virtual PE-grid changed in restart run. & ',   &
+                                     'Set debug_output =.T. to get a list of files from which the & ',&
+                                     'single PEs will read respectively'
+          CALL message( 'rrd_local', 'PA0285', 0, 0, 0, 6, 0 )
+          IF ( debug_output )  THEN
+             IF ( files_to_be_opened <= 120 )  THEN
+                WRITE( debug_string, '(2A,1X,120(I6.6,1X))' )                                         &
+                     'number of PEs or virtual PE-grid changed in restart run.  PE will read from ',  &
+                     'files ', file_list(1:files_to_be_opened)
+             ELSE
+                WRITE( debug_string, '(3A,1X,120(I6.6,1X),A)' )                                      &
+                     'number of PEs or virtual PE-grid changed in restart run.  PE will read from ',  &
+                     'files ', file_list(1:120), '... and more'
+             ENDIF
+             CALL debug_message( 'rrd_local', 'info' )
           ENDIF
-
-          shift_y = shift_y + ( ny_on_file + 1 )
-       ENDDO
-
-       IF ( j > 0 )  overlap_count(files_to_be_opened) = j
-
-    ENDDO
-
-!
-!-- Save the id-string of the current process, since myid_char may now be used
-!-- to open files created by PEs with other id.
-    myid_char_save = myid_char
-
-    IF ( files_to_be_opened /= 1  .OR.  numprocs /= numprocs_previous_run )  THEN
-       WRITE( message_string, * ) 'number of PEs or virtual PE-grid changed in restart run. & ',   &
-                                  'Set debug_output =.T. to get a list of files from which the & ',&
-                                  'single PEs will read respectively'
-       CALL message( 'rrd_local', 'PA0285', 0, 0, 0, 6, 0 )
-       IF ( debug_output )  THEN
-          IF ( files_to_be_opened <= 120 )  THEN
-             WRITE( debug_string, '(2A,1X,120(I6.6,1X))' )                                         &
-                  'number of PEs or virtual PE-grid changed in restart run.  PE will read from ',  &
-                  'files ', file_list(1:files_to_be_opened)
-          ELSE
-             WRITE( debug_string, '(3A,1X,120(I6.6,1X),A)' )                                      &
-                  'number of PEs or virtual PE-grid changed in restart run.  PE will read from ',  &
-                  'files ', file_list(1:120), '... and more'
-          ENDIF
-          CALL debug_message( 'rrd_local', 'info' )
-       ENDIF
-    ENDIF
-
-!
-!-- 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,'(''_'',I6.6)')  j
-
-!
-!--    Open the restart file. If this file has been created by PE0 (_000000),
-!--    the global variables at the beginning of the file have to be skipped
-!--    first.
-       CALL check_open( 13 )
-       IF ( j == 0 )  CALL rrd_skip_global
-
-!
-!--    First compare the version numbers
-       READ ( 13 )  length
-       READ ( 13 )  restart_string(1:length)
-       READ ( 13 )  version_on_file
-
-       binary_version_local = '4.7'
-       IF ( TRIM( version_on_file ) /= TRIM( binary_version_local ) )  THEN
-          WRITE( message_string, * ) 'version mismatch concerning ',                               &
-                                     'binary_version_local:',                                      &
-                                     '&version on file    = "', TRIM( version_on_file ), '"',      &
-                                     '&version in program = "', TRIM( binary_version_local ), '"'
-          CALL message( 'rrd_local', 'PA0286', 1, 2, 0, 6, 0 )
-       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
-          WRITE( message_string, * ) 'problem with index bound nxl on ',                           &
-                                     'restart file "', myid_char, '"',                             &
-                                     '&nxl = ', nxl_on_file, ' but it should be',                  &
-                                     '&= ', hor_index_bounds_previous_run(1,j),                    &
-                                     '&from the index bound information array'
-          CALL message( 'rrd_local', 'PA0287', 2, 2, -1, 6, 1 )
-       ENDIF
-
-       IF ( nxr_on_file /= hor_index_bounds_previous_run(2,j) )  THEN
-           WRITE( message_string, * ) 'problem with index bound nxr on ',                          &
-                                      'restart file "', myid_char, '"'  ,                          &
-                                      ' nxr = ', nxr_on_file, ' but it should be',                 &
-                                      ' = ', hor_index_bounds_previous_run(2,j),                   &
-                                      ' from the index bound information array'
-          CALL message( 'rrd_local', 'PA0288', 2, 2, -1, 6, 1 )
-
-       ENDIF
-
-       IF ( nys_on_file /= hor_index_bounds_previous_run(3,j) )  THEN
-          WRITE( message_string, * ) 'problem with index bound nys on ',                           &
-                                     'restart file "', myid_char, '"',                             &
-                                     '&nys = ', nys_on_file, ' but it should be',                  &
-                                     '&= ', hor_index_bounds_previous_run(3,j),                    &
-                                     '&from the index bound information array'
-          CALL message( 'rrd_local', 'PA0289', 2, 2, -1, 6, 1 )
-       ENDIF
-
-       IF ( nyn_on_file /= hor_index_bounds_previous_run(4,j) )  THEN
-          WRITE( message_string, * ) 'problem with index bound nyn on ',                           &
-                                     'restart file "', myid_char, '"',                             &
-                                     '&nyn = ', nyn_on_file, ' but it should be',                  &
-                                     '&= ', hor_index_bounds_previous_run(4,j),                    &
-                                     '&from the index bound information array'
-          CALL message( 'rrd_local', 'PA0290', 2, 2, -1, 6, 1 )
-       ENDIF
-
-       IF ( nzb_on_file /= nzb )  THEN
-          WRITE( message_string, * ) 'mismatch between actual data and data ',                     &
-                                     'from prior run on PE ', myid,                                &
-                                     '&nzb on file = ', nzb_on_file,                               &
-                                     '&nzb         = ', nzb
-          CALL message( 'rrd_local', 'PA0291', 1, 2, 0, 6, 0 )
-       ENDIF
-
-       IF ( nzt_on_file /= nzt )  THEN
-          WRITE( message_string, * ) 'mismatch between actual data and data ',                     &
-                                     'from prior run on PE ', myid,                                &
-                                     '&nzt on file = ', nzt_on_file,                               &
-                                     '&nzt         = ', nzt
-          CALL message( 'rrd_local', 'PA0292', 1, 2, 0, 6, 0 )
-       ENDIF
-
-!
-!--    Allocate temporary arrays sized as the arrays on the restart file
-       ALLOCATE( tmp_2d(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp),      &
-                 tmp_3d(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,                               &
-                        nxl_on_file-nbgp:nxr_on_file+nbgp) )
-
-!
-!--    Read arrays
-!--    ATTENTION: If the following read commands have been altered, the
-!--    ---------- version number of the variable binary_version_local must
-!--               be altered, too. Furthermore, the output list of arrays in
-!--               wrd_write_local must also be altered
-!--               accordingly.
-       READ ( 13 )  length
-       READ ( 13 )  restart_string(1:length)
-
-
-!
-!--    Loop over processor specific field data
-       DO  WHILE ( restart_string(1:length) /= '*** end ***' )
-
-!
-!--       Map data on file as often as needed (data are read only for k=1)
-          DO  k = 1, overlap_count(i)
-
-             found = .FALSE.
-
-!
-!--          Get the index range of the subdomain on file which overlap with
-!--          the current subdomain
-             nxlf = nxlfa(i,k)
-             nxlc = nxlfa(i,k) + offset_xa(i,k)
-             nxrf = nxrfa(i,k)
-             nxrc = nxrfa(i,k) + offset_xa(i,k)
-             nysf = nysfa(i,k)
-             nysc = nysfa(i,k) + offset_ya(i,k)
-             nynf = nynfa(i,k)
-             nync = nynfa(i,k) + offset_ya(i,k)
-
-
-             SELECT CASE ( restart_string(1:length) )
-
-                CASE ( 'ghf_av' )
-                   IF ( .NOT. ALLOCATED( ghf_av ) )  THEN
-                      ALLOCATE( ghf_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   ghf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
-                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'e' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   e(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'e_av' )
-                   IF ( .NOT. ALLOCATED( e_av ) )  THEN
-                      ALLOCATE( e_av(nzb:nzt+1,nys-nbgp:nyn+nbgp,                                  &
-                                     nxl-nbgp:nxr+nbgp) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   e_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'kh' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   kh(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                 &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'kh_av' )
-                   IF ( .NOT. ALLOCATED( kh_av ) )  THEN
-                      ALLOCATE( kh_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   kh_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'km' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   km(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                 &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'km_av' )
-                   IF ( .NOT. ALLOCATED( km_av ) )  THEN
-                      ALLOCATE( km_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   km_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'lpt_av' )
-                   IF ( .NOT. ALLOCATED( lpt_av ) )  THEN
-                      ALLOCATE( lpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   lpt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'lwp_av' )
-                   IF ( .NOT. ALLOCATED( lwp_av ) )  THEN
-                      ALLOCATE( lwp_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   lwp_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
-                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'p' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   p(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'p_av' )
-                   IF ( .NOT. ALLOCATED( p_av ) )  THEN
-                      ALLOCATE( p_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   p_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'pt' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   pt(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                 &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'pt_av' )
-                   IF ( .NOT. ALLOCATED( pt_av ) )  THEN
-                      ALLOCATE( pt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   pt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'pt_2m_av' )
-                   IF ( .NOT. ALLOCATED( pt_2m_av ) )  THEN
-                      ALLOCATE( pt_2m_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   pt_2m_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                            &
-                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'q' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   q(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'q_av' )
-                   IF ( .NOT. ALLOCATED( q_av ) )  THEN
-                      ALLOCATE( q_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   q_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'ql' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   ql(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                 &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'ql_av' )
-                   IF ( .NOT. ALLOCATED( ql_av ) )  THEN
-                      ALLOCATE( ql_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   ql_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'qsurf_av' )
-                   IF ( .NOT. ALLOCATED( qsurf_av ) )  THEN
-                      ALLOCATE( qsurf_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   qsurf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
-                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'qsws_av' )
-                   IF ( .NOT. ALLOCATED( qsws_av ) )  THEN
-                      ALLOCATE( qsws_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   qsws_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                             &
-                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'qv_av' )
-                   IF ( .NOT. ALLOCATED( qv_av ) )  THEN
-                      ALLOCATE( qv_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   qv_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'r_a_av' )
-                   IF ( .NOT. ALLOCATED( r_a_av ) )  THEN
-                      ALLOCATE( r_a_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   r_a_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
-                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'random_iv' )  ! still unresolved issue
-                   IF ( k == 1 )  READ ( 13 )  random_iv
-                   IF ( k == 1 )  READ ( 13 )  random_iy
-
-                CASE ( 'seq_random_array' )
-                   ALLOCATE( tmp_2d_id_random(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) )
-                   ALLOCATE( tmp_2d_seq_random(5,nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) )
-                   IF ( .NOT. ALLOCATED( id_random_array ) )  THEN
-                      ALLOCATE( id_random_array(nys:nyn,nxl:nxr) )
-                   ENDIF
-                   IF ( .NOT. ALLOCATED( seq_random_array ) )  THEN
-                      ALLOCATE( seq_random_array(5,nys:nyn,nxl:nxr) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d_id_random
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d_seq_random
-                   id_random_array(nysc:nync,nxlc:nxrc) = tmp_2d_id_random(nysf:nynf,nxlf:nxrf)
-                   seq_random_array(:,nysc:nync,nxlc:nxrc) = tmp_2d_seq_random(:,nysf:nynf,nxlf:nxrf)
-                   DEALLOCATE( tmp_2d_id_random, tmp_2d_seq_random )
-
-                CASE ( 's' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   s(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 's_av' )
-                   IF ( .NOT. ALLOCATED( s_av ) )  THEN
-                      ALLOCATE( s_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg))
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   s_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'shf_av' )
-                   IF ( .NOT. ALLOCATED( shf_av ) )  THEN
-                      ALLOCATE( shf_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   shf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                              &
-                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'ssurf_av' )
-                   IF ( .NOT. ALLOCATED( ssurf_av ) )  THEN
-                      ALLOCATE( ssurf_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   ssurf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
-                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'ssws_av' )
-                   IF ( .NOT. ALLOCATED( ssws_av ) )  THEN
-                      ALLOCATE( ssws_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   ssws_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                             &
-                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'ti_av' )
-                   IF ( .NOT. ALLOCATED( ti_av ) )  THEN
-                      ALLOCATE( ti_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
-                   ENDIF
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
-                                                    nxl_on_file:nxr_on_file) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   ti_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
-
-                CASE ( 'ts_av' )
-                   IF ( .NOT. ALLOCATED( ts_av ) )  THEN
-                      ALLOCATE( ts_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   ts_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                               &
-                        tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'tsurf_av' )
-                   IF ( .NOT. ALLOCATED( tsurf_av ) )  THEN
-                      ALLOCATE( tsurf_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   tsurf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
-                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'u' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   u(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'u_av' )
-                   IF ( .NOT. ALLOCATED( u_av ) )  THEN
-                      ALLOCATE( u_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   u_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'u_center_av' )
-                   IF ( .NOT. ALLOCATED( u_center_av ) )  THEN
-                      ALLOCATE( u_center_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
-                   ENDIF
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
-                                                    nxl_on_file:nxr_on_file) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   u_center_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
-
-                CASE ( 'uu_av' )
-                   IF ( .NOT. ALLOCATED( uu_av ) )  THEN
-                      ALLOCATE( uu_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
-                   ENDIF
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
-                                                    nxl_on_file:nxr_on_file) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   uu_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
-
-                CASE ( 'uv_10m_av' )
-                   IF ( .NOT. ALLOCATED( uv_10m_av ) )  THEN
-                      ALLOCATE( uv_10m_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   uv_10m_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                           &
-                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'u_m_l' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
-                                                    1:2) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   IF ( bc_radiation_l )  THEN
-                      u_m_l(:,nysc-nbgp:nync+nbgp,:) =  tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
-                   ENDIF
-
-                CASE ( 'u_m_n' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,ny-1:ny,                             &
-                                                    nxl_on_file-nbgp:nxr_on_file+nbgp) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   IF ( bc_radiation_n )  THEN
-                      u_m_n(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
-                   ENDIF
-
-                CASE ( 'u_m_r' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
-                                                    nx-1:nx) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   IF ( bc_radiation_r )  THEN
-                      u_m_r(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
-                   ENDIF
-
-                CASE ( 'u_m_s' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,0:1,                                 &
-                                                    nxl_on_file-nbgp:nxr_on_file+nbgp) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   IF ( bc_radiation_s )  THEN
-                      u_m_s(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
-                   ENDIF
-
-                CASE ( 'us_av' )
-                   IF ( .NOT. ALLOCATED( us_av ) )  THEN
-                      ALLOCATE( us_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   us_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                               &
-                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'v' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   v(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'v_av' )
-                   IF ( .NOT. ALLOCATED( v_av ) )  THEN
-                      ALLOCATE( v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   v_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'v_center_av' )
-                   IF ( .NOT. ALLOCATED( v_center_av ) )  THEN
-                      ALLOCATE( v_center_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
-                   ENDIF
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
-                                                    nxl_on_file:nxr_on_file) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   v_center_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
-
-                CASE ( 'vv_av' )
-                   IF ( .NOT. ALLOCATED( vv_av ) )  THEN
-                      ALLOCATE( vv_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
-                   ENDIF
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
-                                                    nxl_on_file:nxr_on_file) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   vv_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
-
-                CASE ( 'v_m_l' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
-                                                    0:1) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   IF ( bc_radiation_l )  THEN
-                      v_m_l(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
-                   ENDIF
-
-                CASE ( 'v_m_n' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,ny-1:ny,                             &
-                                                    nxl_on_file-nbgp:nxr_on_file+nbgp) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   IF ( bc_radiation_n )  THEN
-                      v_m_n(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
-                   ENDIF
-
-                CASE ( 'v_m_r' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
-                                                    nx-1:nx) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   IF ( bc_radiation_r )  THEN
-                      v_m_r(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
-                   ENDIF
-
-                CASE ( 'v_m_s' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,1:2,                                 &
-                                                    nxl_on_file-nbgp:nxr_on_file+nbgp) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   IF ( bc_radiation_s )  THEN
-                      v_m_s(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
-                   ENDIF
-
-                CASE ( 'vpt' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   vpt(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'vpt_av' )
-                   IF ( .NOT. ALLOCATED( vpt_av ) )  THEN
-                      ALLOCATE( vpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   vpt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'w' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   w(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'w_av' )
-                   IF ( .NOT. ALLOCATED( w_av ) )  THEN
-                      ALLOCATE( w_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_3d
-                   w_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
-                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'ww_av' )
-                   IF ( .NOT. ALLOCATED( ww_av ) )  THEN
-                      ALLOCATE( ww_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
-                   ENDIF
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
-                                                    nxl_on_file:nxr_on_file) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   ww_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
-
-                CASE ( 'w_m_l' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
-                                                    0:1) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   IF ( bc_radiation_l )  THEN
-                      w_m_l(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
-                   ENDIF
-
-                CASE ( 'w_m_n' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,ny-1:ny,                             &
-                                                    nxl_on_file-nbgp:nxr_on_file+nbgp) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   IF ( bc_radiation_n )  THEN
-                      w_m_n(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
-                   ENDIF
-
-                CASE ( 'w_m_r' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
-                                                    nx-1:nx) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   IF ( bc_radiation_r )  THEN
-                      w_m_r(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
-                   ENDIF
-
-                CASE ( 'w_m_s' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,0:1,                                 &
-                                                    nxl_on_file-nbgp:nxr_on_file+nbgp) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   IF ( bc_radiation_s )  THEN
-                      w_m_s(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
-                   ENDIF
-
-                CASE ( 'wspeed_av' )
-                   IF ( .NOT. ALLOCATED( wspeed_av ) )  THEN
-                      ALLOCATE( wspeed_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
-                   ENDIF
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
-                                                    nxl_on_file:nxr_on_file) )
-                      READ ( 13 )  tmp_3d_non_standard
-                   ENDIF
-                   wspeed_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
-
-                CASE ( 'z0_av' )
-                   IF ( .NOT. ALLOCATED( z0_av ) )  THEN
-                      ALLOCATE( z0_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   z0_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                               &
-                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'z0h_av' )
-                   IF ( .NOT. ALLOCATED( z0h_av ) )  THEN
-                      ALLOCATE( z0h_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   z0h_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                              &
-                       tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'z0q_av' )
-                   IF ( .NOT. ALLOCATED( z0q_av ) )  THEN
-                      ALLOCATE( z0q_av(nysg:nyng,nxlg:nxrg) )
-                   ENDIF
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   z0q_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                              &
-                       tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE DEFAULT
-
-!
-!--                Read restart data of surfaces
-                   IF ( .NOT. found )  CALL surface_rrd_local( k, nxlf, nxlc, nxl_on_file, nxrf,   &
-                                                               nxr_on_file, nynf, nyn_on_file,     &
-                                                               nysf, nysc, nys_on_file, found )
-!
-!--                Read restart data of other modules
-                   IF ( .NOT. found ) CALL module_interface_rrd_local(                             &
-                                                               k, nxlf, nxlc, nxl_on_file, nxrf,   &
-                                                               nxrc, nxr_on_file, nynf, nync,      &
-                                                               nyn_on_file, nysf, nysc,            &
-                                                               nys_on_file, tmp_2d, tmp_3d, found )
-
-
-                   IF ( .NOT. found )  THEN
-                      WRITE( message_string, * ) 'unknown variable named "',                       &
-                                                 restart_string(1:length),                         &
-                                                '" found in subdomain data ',                      &
-                                                'from prior run on PE ', myid
-                      CALL message( 'rrd_local', 'PA0302', 1, 2, 0, 6, 0 )
-
-                   ENDIF
-
-             END SELECT
-
-          ENDDO ! overlaploop
-
-!
-!--       Deallocate non standard array needed for specific variables only
-          IF ( ALLOCATED( tmp_3d_non_standard ) )  DEALLOCATE( tmp_3d_non_standard )
-
-!
-!--       Read next character string
+       ENDIF
+
+!
+!--    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,'(''_'',I6.6)')  j
+
+!
+!--       Open the restart file. If this file has been created by PE0 (_000000),
+!--       the global variables at the beginning of the file have to be skipped
+!--       first.
+          CALL check_open( 13 )
+          IF ( j == 0 )  CALL rrd_skip_global
+
+!
+!--       First compare the version numbers
           READ ( 13 )  length
           READ ( 13 )  restart_string(1:length)
-
-       ENDDO ! dataloop
-!
-!--    Close the restart file
-       CALL close_file( 13 )
-
-       DEALLOCATE( tmp_2d, tmp_3d )
-
-    ENDDO  ! loop over restart files
-!
-!-- Deallocate temporary buffer arrays
-    DEALLOCATE( nxlfa )
-    DEALLOCATE( nxrfa )
-    DEALLOCATE( nynfa )
-    DEALLOCATE( nysfa )
-    DEALLOCATE( offset_xa )
-    DEALLOCATE( offset_ya )
-!
-!-- Restore the original filename for the restart file to be written
-    myid_char = myid_char_save
+          READ ( 13 )  version_on_file
+
+          binary_version_local = '4.7'
+          IF ( TRIM( version_on_file ) /= TRIM( binary_version_local ) )  THEN
+             WRITE( message_string, * ) 'version mismatch concerning ',                               &
+                                        'binary_version_local:',                                      &
+                                        '&version on file    = "', TRIM( version_on_file ), '"',      &
+                                        '&version in program = "', TRIM( binary_version_local ), '"'
+             CALL message( 'rrd_local', 'PA0286', 1, 2, 0, 6, 0 )
+          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
+             WRITE( message_string, * ) 'problem with index bound nxl on ',                           &
+                                        'restart file "', myid_char, '"',                             &
+                                        '&nxl = ', nxl_on_file, ' but it should be',                  &
+                                        '&= ', hor_index_bounds_previous_run(1,j),                    &
+                                        '&from the index bound information array'
+             CALL message( 'rrd_local', 'PA0287', 2, 2, -1, 6, 1 )
+          ENDIF
+
+          IF ( nxr_on_file /= hor_index_bounds_previous_run(2,j) )  THEN
+              WRITE( message_string, * ) 'problem with index bound nxr on ',                          &
+                                         'restart file "', myid_char, '"'  ,                          &
+                                         ' nxr = ', nxr_on_file, ' but it should be',                 &
+                                         ' = ', hor_index_bounds_previous_run(2,j),                   &
+                                         ' from the index bound information array'
+             CALL message( 'rrd_local', 'PA0288', 2, 2, -1, 6, 1 )
+
+          ENDIF
+
+          IF ( nys_on_file /= hor_index_bounds_previous_run(3,j) )  THEN
+             WRITE( message_string, * ) 'problem with index bound nys on ',                           &
+                                        'restart file "', myid_char, '"',                             &
+                                        '&nys = ', nys_on_file, ' but it should be',                  &
+                                        '&= ', hor_index_bounds_previous_run(3,j),                    &
+                                        '&from the index bound information array'
+             CALL message( 'rrd_local', 'PA0289', 2, 2, -1, 6, 1 )
+          ENDIF
+
+          IF ( nyn_on_file /= hor_index_bounds_previous_run(4,j) )  THEN
+             WRITE( message_string, * ) 'problem with index bound nyn on ',                           &
+                                        'restart file "', myid_char, '"',                             &
+                                        '&nyn = ', nyn_on_file, ' but it should be',                  &
+                                        '&= ', hor_index_bounds_previous_run(4,j),                    &
+                                        '&from the index bound information array'
+             CALL message( 'rrd_local', 'PA0290', 2, 2, -1, 6, 1 )
+          ENDIF
+
+          IF ( nzb_on_file /= nzb )  THEN
+             WRITE( message_string, * ) 'mismatch between actual data and data ',                     &
+                                        'from prior run on PE ', myid,                                &
+                                        '&nzb on file = ', nzb_on_file,                               &
+                                        '&nzb         = ', nzb
+             CALL message( 'rrd_local', 'PA0291', 1, 2, 0, 6, 0 )
+          ENDIF
+
+          IF ( nzt_on_file /= nzt )  THEN
+             WRITE( message_string, * ) 'mismatch between actual data and data ',                     &
+                                        'from prior run on PE ', myid,                                &
+                                        '&nzt on file = ', nzt_on_file,                               &
+                                        '&nzt         = ', nzt
+             CALL message( 'rrd_local', 'PA0292', 1, 2, 0, 6, 0 )
+          ENDIF
+
+!
+!--       Allocate temporary arrays sized as the arrays on the restart file
+          ALLOCATE( tmp_2d(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp),      &
+                    tmp_3d(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,                               &
+                           nxl_on_file-nbgp:nxr_on_file+nbgp) )
+
+!
+!--       Read arrays
+!--       ATTENTION: If the following read commands have been altered, the
+!--       ---------- version number of the variable binary_version_local must
+!--                  be altered, too. Furthermore, the output list of arrays in
+!--                  wrd_write_local must also be altered
+!--                  accordingly.
+          READ ( 13 )  length
+          READ ( 13 )  restart_string(1:length)
+
+
+!
+!--       Loop over processor specific field data
+          DO  WHILE ( restart_string(1:length) /= '*** end ***' )
+
+!
+!--          Map data on file as often as needed (data are read only for k=1)
+             DO  k = 1, overlap_count(i)
+
+                found = .FALSE.
+
+!
+!--             Get the index range of the subdomain on file which overlap with
+!--             the current subdomain
+                nxlf = nxlfa(i,k)
+                nxlc = nxlfa(i,k) + offset_xa(i,k)
+                nxrf = nxrfa(i,k)
+                nxrc = nxrfa(i,k) + offset_xa(i,k)
+                nysf = nysfa(i,k)
+                nysc = nysfa(i,k) + offset_ya(i,k)
+                nynf = nynfa(i,k)
+                nync = nynfa(i,k) + offset_ya(i,k)
+
+
+                SELECT CASE ( restart_string(1:length) )
+
+                   CASE ( 'ghf_av' )
+                      IF ( .NOT. ALLOCATED( ghf_av ) )  THEN
+                         ALLOCATE( ghf_av(nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d
+                      ghf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
+                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'e' )
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      e(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'e_av' )
+                      IF ( .NOT. ALLOCATED( e_av ) )  THEN
+                         ALLOCATE( e_av(nzb:nzt+1,nys-nbgp:nyn+nbgp,                                  &
+                                        nxl-nbgp:nxr+nbgp) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      e_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'kh' )
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      kh(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                 &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'kh_av' )
+                      IF ( .NOT. ALLOCATED( kh_av ) )  THEN
+                         ALLOCATE( kh_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      kh_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'km' )
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      km(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                 &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'km_av' )
+                      IF ( .NOT. ALLOCATED( km_av ) )  THEN
+                         ALLOCATE( km_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      km_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'lpt_av' )
+                      IF ( .NOT. ALLOCATED( lpt_av ) )  THEN
+                         ALLOCATE( lpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      lpt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'lwp_av' )
+                      IF ( .NOT. ALLOCATED( lwp_av ) )  THEN
+                         ALLOCATE( lwp_av(nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d
+                      lwp_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
+                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'p' )
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      p(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'p_av' )
+                      IF ( .NOT. ALLOCATED( p_av ) )  THEN
+                         ALLOCATE( p_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      p_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'pt' )
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      pt(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                 &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'pt_av' )
+                      IF ( .NOT. ALLOCATED( pt_av ) )  THEN
+                         ALLOCATE( pt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      pt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'pt_2m_av' )
+                      IF ( .NOT. ALLOCATED( pt_2m_av ) )  THEN
+                         ALLOCATE( pt_2m_av(nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d
+                      pt_2m_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                            &
+                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'q' )
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      q(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'q_av' )
+                      IF ( .NOT. ALLOCATED( q_av ) )  THEN
+                         ALLOCATE( q_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      q_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'ql' )
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      ql(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                 &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'ql_av' )
+                      IF ( .NOT. ALLOCATED( ql_av ) )  THEN
+                         ALLOCATE( ql_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      ql_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'qsurf_av' )
+                      IF ( .NOT. ALLOCATED( qsurf_av ) )  THEN
+                         ALLOCATE( qsurf_av(nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d
+                      qsurf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
+                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'qsws_av' )
+                      IF ( .NOT. ALLOCATED( qsws_av ) )  THEN
+                         ALLOCATE( qsws_av(nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d
+                      qsws_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                             &
+                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'qv_av' )
+                      IF ( .NOT. ALLOCATED( qv_av ) )  THEN
+                         ALLOCATE( qv_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      qv_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'r_a_av' )
+                      IF ( .NOT. ALLOCATED( r_a_av ) )  THEN
+                         ALLOCATE( r_a_av(nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d
+                      r_a_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
+                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'random_iv' )  ! still unresolved issue
+                      IF ( k == 1 )  READ ( 13 )  random_iv
+                      IF ( k == 1 )  READ ( 13 )  random_iy
+
+                   CASE ( 'seq_random_array' )
+                      ALLOCATE( tmp_2d_id_random(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) )
+                      ALLOCATE( tmp_2d_seq_random(5,nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) )
+                      IF ( .NOT. ALLOCATED( id_random_array ) )  THEN
+                         ALLOCATE( id_random_array(nys:nyn,nxl:nxr) )
+                      ENDIF
+                      IF ( .NOT. ALLOCATED( seq_random_array ) )  THEN
+                         ALLOCATE( seq_random_array(5,nys:nyn,nxl:nxr) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d_id_random
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d_seq_random
+                      id_random_array(nysc:nync,nxlc:nxrc) = tmp_2d_id_random(nysf:nynf,nxlf:nxrf)
+                      seq_random_array(:,nysc:nync,nxlc:nxrc) = tmp_2d_seq_random(:,nysf:nynf,nxlf:nxrf)
+                      DEALLOCATE( tmp_2d_id_random, tmp_2d_seq_random )
+
+                   CASE ( 's' )
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      s(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 's_av' )
+                      IF ( .NOT. ALLOCATED( s_av ) )  THEN
+                         ALLOCATE( s_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg))
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      s_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'shf_av' )
+                      IF ( .NOT. ALLOCATED( shf_av ) )  THEN
+                         ALLOCATE( shf_av(nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d
+                      shf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                              &
+                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'ssurf_av' )
+                      IF ( .NOT. ALLOCATED( ssurf_av ) )  THEN
+                         ALLOCATE( ssurf_av(nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d
+                      ssurf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
+                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'ssws_av' )
+                      IF ( .NOT. ALLOCATED( ssws_av ) )  THEN
+                         ALLOCATE( ssws_av(nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d
+                      ssws_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                             &
+                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'ti_av' )
+                      IF ( .NOT. ALLOCATED( ti_av ) )  THEN
+                         ALLOCATE( ti_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
+                      ENDIF
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
+                                                       nxl_on_file:nxr_on_file) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      ti_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
+
+                   CASE ( 'ts_av' )
+                      IF ( .NOT. ALLOCATED( ts_av ) )  THEN
+                         ALLOCATE( ts_av(nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d
+                      ts_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                               &
+                           tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'tsurf_av' )
+                      IF ( .NOT. ALLOCATED( tsurf_av ) )  THEN
+                         ALLOCATE( tsurf_av(nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d
+                      tsurf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
+                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'u' )
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      u(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'u_av' )
+                      IF ( .NOT. ALLOCATED( u_av ) )  THEN
+                         ALLOCATE( u_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      u_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'u_center_av' )
+                      IF ( .NOT. ALLOCATED( u_center_av ) )  THEN
+                         ALLOCATE( u_center_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
+                      ENDIF
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
+                                                       nxl_on_file:nxr_on_file) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      u_center_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
+
+                   CASE ( 'uu_av' )
+                      IF ( .NOT. ALLOCATED( uu_av ) )  THEN
+                         ALLOCATE( uu_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
+                      ENDIF
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
+                                                       nxl_on_file:nxr_on_file) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      uu_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
+
+                   CASE ( 'uv_10m_av' )
+                      IF ( .NOT. ALLOCATED( uv_10m_av ) )  THEN
+                         ALLOCATE( uv_10m_av(nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d
+                      uv_10m_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                           &
+                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'u_m_l' )
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
+                                                       1:2) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      IF ( bc_radiation_l )  THEN
+                         u_m_l(:,nysc-nbgp:nync+nbgp,:) =  tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
+                      ENDIF
+
+                   CASE ( 'u_m_n' )
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,ny-1:ny,                             &
+                                                       nxl_on_file-nbgp:nxr_on_file+nbgp) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      IF ( bc_radiation_n )  THEN
+                         u_m_n(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
+                      ENDIF
+
+                   CASE ( 'u_m_r' )
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
+                                                       nx-1:nx) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      IF ( bc_radiation_r )  THEN
+                         u_m_r(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
+                      ENDIF
+
+                   CASE ( 'u_m_s' )
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,0:1,                                 &
+                                                       nxl_on_file-nbgp:nxr_on_file+nbgp) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      IF ( bc_radiation_s )  THEN
+                         u_m_s(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
+                      ENDIF
+
+                   CASE ( 'us_av' )
+                      IF ( .NOT. ALLOCATED( us_av ) )  THEN
+                         ALLOCATE( us_av(nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d
+                      us_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                               &
+                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'v' )
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      v(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'v_av' )
+                      IF ( .NOT. ALLOCATED( v_av ) )  THEN
+                         ALLOCATE( v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      v_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'v_center_av' )
+                      IF ( .NOT. ALLOCATED( v_center_av ) )  THEN
+                         ALLOCATE( v_center_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
+                      ENDIF
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
+                                                       nxl_on_file:nxr_on_file) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      v_center_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
+
+                   CASE ( 'vv_av' )
+                      IF ( .NOT. ALLOCATED( vv_av ) )  THEN
+                      ALLOCATE( vv_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
+                      ENDIF
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
+                                                       nxl_on_file:nxr_on_file) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      vv_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
+
+                   CASE ( 'v_m_l' )
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
+                                                       0:1) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      IF ( bc_radiation_l )  THEN
+                         v_m_l(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
+                      ENDIF
+
+                   CASE ( 'v_m_n' )
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,ny-1:ny,                             &
+                                                       nxl_on_file-nbgp:nxr_on_file+nbgp) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      IF ( bc_radiation_n )  THEN
+                         v_m_n(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
+                      ENDIF
+
+                   CASE ( 'v_m_r' )
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
+                                                       nx-1:nx) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      IF ( bc_radiation_r )  THEN
+                         v_m_r(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
+                      ENDIF
+
+                   CASE ( 'v_m_s' )
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,1:2,                                 &
+                                                       nxl_on_file-nbgp:nxr_on_file+nbgp) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      IF ( bc_radiation_s )  THEN
+                         v_m_s(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
+                      ENDIF
+
+                   CASE ( 'vpt' )
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      vpt(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'vpt_av' )
+                      IF ( .NOT. ALLOCATED( vpt_av ) )  THEN
+                         ALLOCATE( vpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      vpt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'w' )
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      w(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'w_av' )
+                      IF ( .NOT. ALLOCATED( w_av ) )  THEN
+                         ALLOCATE( w_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_3d
+                      w_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
+                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'ww_av' )
+                      IF ( .NOT. ALLOCATED( ww_av ) )  THEN
+                         ALLOCATE( ww_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
+                      ENDIF
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
+                                                       nxl_on_file:nxr_on_file) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      ww_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
+
+                   CASE ( 'w_m_l' )
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
+                                                       0:1) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      IF ( bc_radiation_l )  THEN
+                         w_m_l(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
+                      ENDIF
+
+                   CASE ( 'w_m_n' )
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,ny-1:ny,                             &
+                                                       nxl_on_file-nbgp:nxr_on_file+nbgp) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      IF ( bc_radiation_n )  THEN
+                         w_m_n(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
+                      ENDIF
+
+                   CASE ( 'w_m_r' )
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
+                                                       nx-1:nx) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      IF ( bc_radiation_r )  THEN
+                         w_m_r(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
+                      ENDIF
+
+                   CASE ( 'w_m_s' )
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,0:1,                                 &
+                                                       nxl_on_file-nbgp:nxr_on_file+nbgp) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      IF ( bc_radiation_s )  THEN
+                         w_m_s(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
+                      ENDIF
+
+                   CASE ( 'wspeed_av' )
+                      IF ( .NOT. ALLOCATED( wspeed_av ) )  THEN
+                         ALLOCATE( wspeed_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
+                      ENDIF
+                      IF ( k == 1 )  THEN
+                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
+                                                       nxl_on_file:nxr_on_file) )
+                         READ ( 13 )  tmp_3d_non_standard
+                      ENDIF
+                      wspeed_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
+
+                   CASE ( 'z0_av' )
+                      IF ( .NOT. ALLOCATED( z0_av ) )  THEN
+                         ALLOCATE( z0_av(nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d
+                      z0_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                               &
+                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'z0h_av' )
+                      IF ( .NOT. ALLOCATED( z0h_av ) )  THEN
+                         ALLOCATE( z0h_av(nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d
+                      z0h_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                              &
+                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE ( 'z0q_av' )
+                      IF ( .NOT. ALLOCATED( z0q_av ) )  THEN
+                         ALLOCATE( z0q_av(nysg:nyng,nxlg:nxrg) )
+                      ENDIF
+                      IF ( k == 1 )  READ ( 13 )  tmp_2d
+                      z0q_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                              &
+                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
+
+                   CASE DEFAULT
+
+!
+!--                   Read restart data of surfaces
+                      IF ( .NOT. found )  CALL surface_rrd_local( k, nxlf, nxlc, nxl_on_file, nxrf,   &
+                                                                  nxr_on_file, nynf, nyn_on_file,     &
+                                                                  nysf, nysc, nys_on_file, found )
+!
+!--                   Read restart data of other modules
+                      IF ( .NOT. found ) CALL module_interface_rrd_local(                             &
+                                                                  k, nxlf, nxlc, nxl_on_file, nxrf,   &
+                                                                  nxrc, nxr_on_file, nynf, nync,      &
+                                                                  nyn_on_file, nysf, nysc,            &
+                                                                  nys_on_file, tmp_2d, tmp_3d, found )
+
+
+                      IF ( .NOT. found )  THEN
+                         WRITE( message_string, * ) 'unknown variable named "',                       &
+                                                    restart_string(1:length),                         &
+                                                   '" found in subdomain data ',                      &
+                                                   'from prior run on PE ', myid
+                         CALL message( 'rrd_local', 'PA0302', 1, 2, 0, 6, 0 )
+
+                      ENDIF
+
+                END SELECT
+
+             ENDDO ! overlaploop
+
+!
+!--          Deallocate non standard array needed for specific variables only
+             IF ( ALLOCATED( tmp_3d_non_standard ) )  DEALLOCATE( tmp_3d_non_standard )
+
+!
+!--          Read next character string
+             READ ( 13 )  length
+             READ ( 13 )  restart_string(1:length)
+
+          ENDDO ! dataloop
+!
+!--       Close the restart file
+          CALL close_file( 13 )
+
+          DEALLOCATE( tmp_2d, tmp_3d )
+
+       ENDDO  ! loop over restart files
+!
+!--    Deallocate temporary buffer arrays
+       DEALLOCATE( nxlfa )
+       DEALLOCATE( nxrfa )
+       DEALLOCATE( nynfa )
+       DEALLOCATE( nysfa )
+       DEALLOCATE( offset_xa )
+       DEALLOCATE( offset_ya )
+!
+!--    Restore the original filename for the restart file to be written
+       myid_char = myid_char_save
+
+
+    ELSEIF ( TRIM( restart_data_format_input ) == 'mpi' )  THEN
+
+!
+!--    Read global restart data using MPI-IO
+!
+!--    Open the MPI-IO restart file.
+       CALL rd_mpi_io_open( 'read', 'BININ' // TRIM( coupling_char ) )
+
+
+       CALL rd_mpi_io_check_array( 'ghf_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF (.NOT. ALLOCATED( ghf_av ) )  ALLOCATE( ghf_av(nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'ghf_av', ghf_av )
+       ENDIF
+
+       CALL rrd_mpi_io( 'e', e )
+
+       CALL rd_mpi_io_check_array( 'e_av' , found = array_found )
+       IF ( array_found  )  THEN
+          IF ( .NOT. ALLOCATED( e_av ) )  ALLOCATE( e_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'e_av', e_av )
+       ENDIF
+
+       CALL rrd_mpi_io( 'kh', kh )
+
+       CALL rd_mpi_io_check_array( 'kh_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( kh_av ) )  ALLOCATE( kh_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'kh_av', kh_av )
+       ENDIF
+
+       CALL rrd_mpi_io( 'km' , km)
+
+       CALL rd_mpi_io_check_array( 'km_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( km_av ) )  ALLOCATE( km_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'km_av', km_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'lpt_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( lpt_av ) )  ALLOCATE( lpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'lpt_av', lpt_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'lwp_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( lwp_av ) )  ALLOCATE( lwp_av(nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'lwp_av', lwp_av )
+       ENDIF
+
+       CALL rrd_mpi_io( 'p', p)
+
+       CALL rd_mpi_io_check_array( 'p_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( p_av ) )  ALLOCATE( p_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'p_av', p_av )
+       ENDIF
+
+       CALL rrd_mpi_io( 'pt', pt)
+
+       CALL rd_mpi_io_check_array( 'pt_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( pt_av ) )  ALLOCATE( pt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'pt_av', pt_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'pt_2m_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( pt_2m_av ) )  ALLOCATE( pt_2m_av(nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'pt_2m_av', pt_2m_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'q' , found = array_found )
+       IF ( array_found )  THEN
+          CALL rrd_mpi_io( 'q', q )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'q_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( q_av ) )  ALLOCATE( q_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'q_av', q_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'ql' , found = array_found )
+       IF ( array_found )  THEN
+          CALL rrd_mpi_io( 'ql', ql )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'ql_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( ql_av ) )  ALLOCATE( ql_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'ql_av', ql_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'qsurf_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( qsurf_av ) )  ALLOCATE( qsurf_av(nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'qsurf_av', qsurf_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'qsws_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( qsws_av ) )  ALLOCATE( qsws_av(nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'qsws_av', qsws_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'qv_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( qv_av ) )  ALLOCATE( qv_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'qv_av', qv_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'r_a_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( r_a_av ) )  ALLOCATE( r_a_av(nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'r_a_av', r_a_av )
+       ENDIF
+
+!
+!--    ATTENTION: The random seeds are global data! If independent values for every PE are required,
+!--    the general approach of PE indendent restart will be lost. That means that in general the
+!--    parallel random number generator in random_generator_parallel_mod should be used!
+       CALL rrd_mpi_io_global_array( 'random_iv', random_iv )
+       CALL rrd_mpi_io( 'random_iy', random_iy )
+
+       CALL rd_mpi_io_check_array( 'id_random_array' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( id_random_array ) )  ALLOCATE( id_random_array(nys:nyn,nxl:nxr) )
+          IF ( .NOT. ALLOCATED( seq_random_array ) )  ALLOCATE( seq_random_array(5,nys:nyn,nxl:nxr) )
+          CALL rrd_mpi_io( 'id_random_array', id_random_array)
+          DO  i = 1, SIZE( seq_random_array, 1 )
+             WRITE( tmp_name, '(A,I2.2)' )  'seq_random_array', i
+             CALL rrd_mpi_io( TRIM(tmp_name), seq_random_array(i,:,:) )
+          ENDDO
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 's' , found = array_found )
+       IF ( array_found )  THEN
+          CALL rrd_mpi_io( 's', s )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 's_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( s_av ) )  ALLOCATE( s_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 's_av', s_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'shf_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( shf_av ) )  ALLOCATE( shf_av(nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'shf_av', shf_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'ssurf_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( ssurf_av ) )  ALLOCATE( ssurf_av(nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'ssurf_av', ssurf_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'ssws_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( ssws_av ) )  ALLOCATE( ssws_av(nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'ssws_av', ssws_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'ti_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( ti_av ) )  ALLOCATE( ti_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'ti_av', ti_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'ts_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( ts_av ) )  ALLOCATE( ts_av(nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'ts_av', ts_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'tsurf_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( tsurf_av ) )  ALLOCATE( tsurf_av(nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'tsurf_av', tsurf_av )
+       ENDIF
+
+       CALL rrd_mpi_io( 'u', u)
+
+       CALL rd_mpi_io_check_array( 'u_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( u_av ) )  ALLOCATE( u_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'u_av', u_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'u_center_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( u_center_av ) )  ALLOCATE( u_center_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
+          CALL rrd_mpi_io( 'u_center_av', u_center_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'uu_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( uu_av ) )  ALLOCATE( uu_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
+          CALL rrd_mpi_io( 'uu_av', uu_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'uv_10m_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( uv_10m_av ) )  ALLOCATE( uv_10m_av(nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'uv_10m_av', uv_10m_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'u_m_l' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( u_m_l ) )  ALLOCATE( u_m_l(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'u_m_l', u_m_l )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'u_m_n' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( u_m_n ) )  ALLOCATE( u_m_n(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'u_m_n', u_m_n )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'u_m_r' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( u_m_r ) )  ALLOCATE( u_m_r(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'u_m_r', u_m_r )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'u_m_s' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( u_m_s ) )  ALLOCATE( u_m_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'u_m_s', u_m_s )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'us_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( us_av ) )  ALLOCATE( us_av(nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'us_av', us_av )
+       ENDIF
+
+       CALL rrd_mpi_io( 'v', v )
+
+       CALL rd_mpi_io_check_array( 'v_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( v_av ) )  ALLOCATE( v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'v_av', v_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'v_center_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( v_center_av ) )  ALLOCATE( v_center_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
+          CALL rrd_mpi_io( 'v_center_av', v_center_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'vv_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( vv_av ) )  ALLOCATE( vv_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
+          CALL rrd_mpi_io( 'vv_av', vv_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'v_m_l' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( v_m_l ) )  ALLOCATE( v_m_l(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'v_m_l', v_m_l )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'v_m_n' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( v_m_n ) )  ALLOCATE( v_m_n(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'v_m_n', v_m_n )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'v_m_r' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( v_m_r ) )  ALLOCATE( v_m_r(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'v_m_r', v_m_r )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'v_m_s' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( v_m_s ) )  ALLOCATE( v_m_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'v_m_s', v_m_s )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'vpt' , found = array_found )
+       IF ( array_found )  THEN
+          CALL rrd_mpi_io( 'vpt',  vpt)
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'vpt_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( vpt_av ) )  ALLOCATE( vpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'vpt_av', vpt_av )
+       ENDIF
+
+       CALL rrd_mpi_io( 'w', w)
+
+       CALL rd_mpi_io_check_array( 'w_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( w_av ) )  ALLOCATE( w_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'w_av', w_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'ww_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( ww_av ) )  ALLOCATE( w_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
+          CALL rrd_mpi_io( 'ww_av', ww_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'w_m_l' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( w_m_l ) )  ALLOCATE( w_m_l(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'w_m_l', w_m_l )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'w_m_n' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( w_m_n ) )  ALLOCATE( w_m_n(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'w_m_n', w_m_n )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'w_m_r' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( w_m_r ) )  ALLOCATE( w_m_r(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'w_m_r', w_m_r )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'w_m_s' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( w_m_s ) )  ALLOCATE( w_m_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'w_m_s', w_m_s )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'wspeed_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( wspeed_av ) )  ALLOCATE( wspeed_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
+          CALL rrd_mpi_io( 'wspeed_av', wspeed_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'z0_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( z0_av ) )  ALLOCATE( z0_av(nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'z0_av', z0_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'z0h_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( z0h_av ) )  ALLOCATE( z0h_av(nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'z0h_av', z0h_av )
+       ENDIF
+
+       CALL rd_mpi_io_check_array( 'z0q_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( z0q_av ) )  ALLOCATE( z0q_av(nysg:nyng,nxlg:nxrg) )
+          CALL rrd_mpi_io( 'z0q_av', z0q_av )
+       ENDIF
+
+!
+!--    Read restart data of surfaces
+       CALL surface_rrd_local
+
+!
+!--    Read restart data of other modules
+       CALL module_interface_rrd_local
+
+!
+!--    Close restart file
+       CALL rd_mpi_io_close
+
+    ENDIF
 
 !
