Index: /palm/trunk/SOURCE/indoor_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/indoor_model_mod.f90	(revision 4782)
+++ /palm/trunk/SOURCE/indoor_model_mod.f90	(revision 4783)
@@ -20,9 +20,12 @@
 ! Current revisions:
 ! -----------------
-! Change parameters for summer_pars and winter_pars (responsible: S. Rissmann)
+!
 !
 ! Former revisions:
 ! -----------------
 ! $Id$
+! Change parameters for summer_pars and winter_pars (responsible: S. Rissmann)
+!
+! 4780 2020-11-10 11:17:10Z suehring
 ! Enable 3D data output also with 64-bit precision
 !
Index: /palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- /palm/trunk/SOURCE/init_3d_model.f90	(revision 4782)
+++ /palm/trunk/SOURCE/init_3d_model.f90	(revision 4783)
@@ -24,4 +24,7 @@
 ! -----------------
 ! $Id$
+! bugfix for reading restart data with MPI-I/O (does not work with blockwise I/O)
+!
+! 4680 2020-09-16 10:20:34Z gronemeier
 ! Add option to fix date or time of the simulation
 !
@@ -1086,7 +1089,30 @@
        IF ( TRIM( initializing_actions ) == 'cyclic_fill' )  THEN
 
+!
+!--       Blockwise I/O does not work together with MPI-I/O
+          IF ( restart_data_format_input(1:3) == 'mpi' )  THEN
+             CALL rrd_read_parts_of_global
+          ELSE
+             DO  i = 0, io_blocks-1
+                IF ( i == io_group )  THEN
+                   CALL rrd_read_parts_of_global
+                ENDIF
+#if defined( __parallel )
+                CALL MPI_BARRIER( comm2d, ierr )
+#endif
+             ENDDO
+          ENDIF
+
+       ENDIF
+
+!
+!--    Read processor specific binary data from restart file.
+!--    Blockwise I/O does not work together with MPI-I/O
+       IF ( restart_data_format_input(1:3) == 'mpi' )  THEN
+          CALL rrd_local
+       ELSE
           DO  i = 0, io_blocks-1
              IF ( i == io_group )  THEN
-                CALL rrd_read_parts_of_global
+                CALL rrd_local
              ENDIF
 #if defined( __parallel )
@@ -1094,17 +1120,5 @@
 #endif
           ENDDO
-
-       ENDIF
-
-!
-!--    Read processor specific binary data from restart file
-       DO  i = 0, io_blocks-1
-          IF ( i == io_group )  THEN
-             CALL rrd_local
-          ENDIF
-#if defined( __parallel )
-          CALL MPI_BARRIER( comm2d, ierr )
-#endif
-       ENDDO
+       ENDIF
 
 
Index: /palm/trunk/SOURCE/parin.f90
===================================================================
--- /palm/trunk/SOURCE/parin.f90	(revision 4782)
+++ /palm/trunk/SOURCE/parin.f90	(revision 4783)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! bugfix for reading restart data with MPI-I/O (does not work with blockwise I/O)
+!
+! 4680 2020-09-16 10:20:34Z gronemeier
 ! Add option to fix date or time of the simulation
 !
@@ -393,4 +396,89 @@
 
     CALL location_message( 'reading environment parameters from ENVPAR', 'finished' )
+
+    CALL location_message( 'reading NAMELIST parameters from PARIN', 'start' )
+
+!
+!-- Open the NAMELIST-file which is send with this job
+    CALL check_open( 11 )
+
+!
+!-- Read the control parameters for initialization.
+!-- The namelist "inipar" must be provided in the NAMELIST-file.
+    READ ( 11, initialization_parameters, ERR=10, END=11 )
+    GOTO 14
+
+ 10 BACKSPACE( 11 )
+    READ( 11 , '(A)') line
+    CALL parin_fail_message( 'initialization_parameters', line )
+
+ 11 REWIND ( 11 )
+    READ ( 11, inipar, ERR=12, END=13 )
+
+    message_string = 'namelist inipar is deprecated and will be ' //    &
+                     'removed in near future. & Please use namelist ' // &
+                     'initialization_parameters instead'
+    CALL message( 'parin', 'PA0017', 0, 1, 0, 6, 0 )
+
+    GOTO 14
+
+ 12 BACKSPACE( 11 )
+    READ( 11 , '(A)') line
+    CALL parin_fail_message( 'inipar', line )
+
+ 13 message_string = 'no initialization_parameters-namelist found'
+    CALL message( 'parin', 'PA0272', 1, 2, 0, 6, 0 )
+
+!
+!-- Try to read runtime parameters given by the user for this run
+!-- (namelist "runtime_parameters"). The namelist "runtime_parmeters"
+!-- can be omitted. In that case default values are used for the
+!-- parameters.
+ 14 line = ' '
+
+    REWIND ( 11 )
+    line = ' '
+    DO WHILE ( INDEX( line, '&runtime_parameters' ) == 0 )
+       READ ( 11, '(A)', END=16 )  line
+    ENDDO
+    BACKSPACE ( 11 )
+
+!
+!-- Read namelist
+    READ ( 11, runtime_parameters, ERR = 15 )
+    GOTO 18
+
+ 15 BACKSPACE( 11 )
+    READ( 11 , '(A)') line
+    CALL parin_fail_message( 'runtime_parameters', line )
+
+ 16 REWIND ( 11 )
+    line = ' '
+    DO WHILE ( INDEX( line, '&d3par' ) == 0 )
+       READ ( 11, '(A)', END=18 )  line
+    ENDDO
+    BACKSPACE ( 11 )
+
+!
+!-- Read namelist
+    READ ( 11, d3par, ERR = 17, END = 18 )
+
+    message_string = 'namelist d3par is deprecated and will be ' //      &
+                     'removed in near future. &Please use namelist ' //   &
+                     'runtime_parameters instead'
+    CALL message( 'parin', 'PA0487', 0, 1, 0, 6, 0 )
+
+    GOTO 18
+
+ 17 BACKSPACE( 11 )
+    READ( 11 , '(A)') line
+    CALL parin_fail_message( 'd3par', line )
+
+ 18 CONTINUE
+
+!
+!-- Check for module namelists and read them
+    CALL module_interface_parin
+
 !
 !-- Calculate the number of groups into which parallel I/O is split.
@@ -424,313 +512,236 @@
     io_group  = MOD( global_id+1, io_blocks )
 
-    CALL location_message( 'reading NAMELIST parameters from PARIN', 'start' )
-!
-!-- Data is read in parallel by groups of PEs
-    DO  i = 0, io_blocks-1
-       IF ( i == io_group )  THEN
-
-!
-!--       Open the NAMELIST-file which is send with this job
-          CALL check_open( 11 )
-
-!
-!--       Read the control parameters for initialization.
-!--       The namelist "inipar" must be provided in the NAMELIST-file.
-          READ ( 11, initialization_parameters, ERR=10, END=11 )
-          GOTO 14
-
- 10       BACKSPACE( 11 )
-          READ( 11 , '(A)') line
-          CALL parin_fail_message( 'initialization_parameters', line )
-
- 11       REWIND ( 11 )
-          READ ( 11, inipar, ERR=12, END=13 )
-
-          message_string = 'namelist inipar is deprecated and will be ' //    &
-                          'removed in near future. & Please use namelist ' // &
-                          'initialization_parameters instead'
-          CALL message( 'parin', 'PA0017', 0, 1, 0, 6, 0 )
-
-          GOTO 14
-
- 12       BACKSPACE( 11 )
-          READ( 11 , '(A)') line
-          CALL parin_fail_message( 'inipar', line )
-
- 13       message_string = 'no initialization_parameters-namelist found'
-          CALL message( 'parin', 'PA0272', 1, 2, 0, 6, 0 )
-
-!
-!--       Try to read runtime parameters given by the user for this run
-!--       (namelist "runtime_parameters"). The namelist "runtime_parmeters"
-!--       can be omitted. In that case default values are used for the
-!--       parameters.
- 14       line = ' '
-
-          REWIND ( 11 )
-          line = ' '
-          DO WHILE ( INDEX( line, '&runtime_parameters' ) == 0 )
-             READ ( 11, '(A)', END=16 )  line
+!
+!-- If required, read control parameters from restart file (produced by
+!-- a prior run). All PEs are reading from file created by PE0 (see
+!-- check_open)
+    IF ( TRIM( initializing_actions ) == 'read_restart_data' )  THEN
+
+!
+!--    If not set by the user in the runtime parameters, the data format for restart
+!--    input needs to be set now! This is normally done later in check parameters.
+       IF ( TRIM( restart_data_format ) /= 'fortran_binary'  .AND.                           &
+            TRIM( restart_data_format ) /= 'mpi'             .AND.                           &
+            TRIM( restart_data_format ) /= 'mpi_shared_memory' )  THEN
+          message_string = 'illegal restart data format "' // TRIM( restart_data_format ) // '"'
+          CALL message( 'parin', 'PA0724', 1, 2, 0, 6, 0 )
+       ENDIF
+       IF ( TRIM( restart_data_format_input ) == 'undefined' )  THEN
+          restart_data_format_input = restart_data_format
+       ENDIF
+
+!
+!--    Blockwise I/O does not work together with MPI-I/O
+       IF ( restart_data_format_input(1:3) == 'mpi'  .AND.  io_blocks /= 1 )  THEN
+          CALL rrd_global
+       ELSE
+!
+!--       Data is read in parallel by groups of PEs
+          DO  i = 0, io_blocks-1
+             IF ( i == io_group )  THEN
+                CALL rrd_global
+             ENDIF
+#if defined( __parallel )
+             CALL MPI_BARRIER( comm2d, ierr )
+#endif
           ENDDO
-          BACKSPACE ( 11 )
-
-!
-!--       Read namelist
-          READ ( 11, runtime_parameters, ERR = 15 )
-          GOTO 18
-
- 15       BACKSPACE( 11 )
-          READ( 11 , '(A)') line
-          CALL parin_fail_message( 'runtime_parameters', line )
-
- 16       REWIND ( 11 )
-          line = ' '
-          DO WHILE ( INDEX( line, '&d3par' ) == 0 )
-             READ ( 11, '(A)', END=18 )  line
-          ENDDO
-          BACKSPACE ( 11 )
-
-!
-!--       Read namelist
-          READ ( 11, d3par, ERR = 17, END = 18 )
-
-          message_string = 'namelist d3par is deprecated and will be ' //      &
-                          'removed in near future. &Please use namelist ' //   &
-                          'runtime_parameters instead'
-          CALL message( 'parin', 'PA0487', 0, 1, 0, 6, 0 )
-
-          GOTO 18
-
- 17       BACKSPACE( 11 )
-          READ( 11 , '(A)') line
-          CALL parin_fail_message( 'd3par', line )
-
- 18       CONTINUE
-
-!
-!--       Check for module namelists and read them
-          CALL module_interface_parin
-
-!
-!--       If required, read control parameters from restart file (produced by
-!--       a prior run). All PEs are reading from file created by PE0 (see
-!--       check_open)
-          IF ( TRIM( initializing_actions ) == 'read_restart_data' )  THEN
-
-!
-!--          If not set by the user in the runtime parameters, the data format for restart
-!--          input needs to be set now! This is normally done later in check parameters.
-             IF ( TRIM( restart_data_format ) /= 'fortran_binary'  .AND.                           &
-                  TRIM( restart_data_format ) /= 'mpi'             .AND.                           &
-                  TRIM( restart_data_format ) /= 'mpi_shared_memory' )  THEN
-                message_string = 'illegal restart data format "' // TRIM( restart_data_format ) // '"'
-                CALL message( 'parin', 'PA0724', 1, 2, 0, 6, 0 )
-             ENDIF
-             IF ( TRIM( restart_data_format_input ) == 'undefined' )  THEN
-                restart_data_format_input = restart_data_format
-             ENDIF
-
-             CALL rrd_global
-!
-!--          Increment the run count
-             runnr = runnr + 1
-!
-!--          In case of a restart run, the number of user-defined profiles on
-!--          the restart file (already stored in max_pr_user) has to match the
-!--          one given for the current run. max_pr_user_tmp is calculated in
-!--          user_parin and max_pr_user is read in via rrd_global.
-             IF ( max_pr_user /= max_pr_user_tmp )  THEN
-                WRITE( message_string, * ) 'the number of user-defined ',      &
-                      'profiles given in data_output_pr (', max_pr_user_tmp,   &
-                      ') does not match the one ',                             &
-                      'found in the restart file (', max_pr_user, ')'
-                CALL message( 'user_parin', 'UI0009', 1, 2, 0, 6, 0 )
-             ENDIF
-          ELSE
-             max_pr_user = max_pr_user_tmp
+       ENDIF
+
+
+!
+!--    Increment the run count
+       runnr = runnr + 1
+!
+!--    In case of a restart run, the number of user-defined profiles on
+!--    the restart file (already stored in max_pr_user) has to match the
+!--    one given for the current run. max_pr_user_tmp is calculated in
+!--    user_parin and max_pr_user is read in via rrd_global.
+       IF ( max_pr_user /= max_pr_user_tmp )  THEN
+          WRITE( message_string, * ) 'the number of user-defined ',      &
+                 'profiles given in data_output_pr (', max_pr_user_tmp,   &
+                 ') does not match the one ',                             &
+                 'found in the restart file (', max_pr_user, ')'
+          CALL message( 'user_parin', 'UI0009', 1, 2, 0, 6, 0 )
+       ENDIF
+    ELSE
+       max_pr_user = max_pr_user_tmp
+    ENDIF
+!
+!-- Activate spinup
+    IF ( land_surface .OR. urban_surface )  THEN
+       IF ( spinup_time > 0.0_wp )  THEN
+          coupling_start_time = spinup_time
+          time_since_reference_point = simulated_time - coupling_start_time
+          IF ( spinup_pt_mean == 9999999.9_wp )  THEN
+             spinup_pt_mean = pt_surface
           ENDIF
-!
-!--       Activate spinup
-          IF ( land_surface .OR. urban_surface )  THEN
-             IF ( spinup_time > 0.0_wp )  THEN
-                coupling_start_time = spinup_time
-                time_since_reference_point = simulated_time - coupling_start_time
-                IF ( spinup_pt_mean == 9999999.9_wp )  THEN
-                   spinup_pt_mean = pt_surface
-                ENDIF
-                end_time = end_time + spinup_time
-                IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
-                   spinup = .TRUE.
-                ELSEIF (        TRIM( initializing_actions ) == 'read_restart_data'      &
-                         .AND.  time_since_reference_point > 0.0_wp )  THEN
-                   data_output_during_spinup = .FALSE.  !< required for correct ntdim calculation
-                                                        !< in check_parameters for restart run
-                ENDIF
-             ENDIF
+          end_time = end_time + spinup_time
+          IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
+             spinup = .TRUE.
+          ELSEIF (        TRIM( initializing_actions ) == 'read_restart_data'      &
+                   .AND.  time_since_reference_point > 0.0_wp )  THEN
+             data_output_during_spinup = .FALSE.  !< required for correct ntdim calculation
+                                                  !< in check_parameters for restart run
           ENDIF
-
-!
-!--       In case of nested runs, explicitly set nesting boundary conditions.
-!--       This will overwrite the user settings and basic defaults.
-!--       bc_lr and bc_ns always need to be cyclic for vertical nesting.
-          IF ( nested_run )  THEN
-             IF ( nesting_mode == 'vertical' )  THEN
-                IF (bc_lr /= 'cyclic' .OR. bc_ns /= 'cyclic' )  THEN
-                   WRITE ( message_string, *) 'bc_lr and bc_ns were set to ,', &
-                        'cyclic for vertical nesting'
-                   CALL message( 'parin', 'PA0428', 0, 0, 0, 6, 0 )
-                   bc_lr   = 'cyclic'
-                   bc_ns   = 'cyclic'
-                ENDIF
-                IF ( child_domain )  THEN
-                   bc_uv_t  = 'nested'
-                   bc_pt_t  = 'nested'
-                   bc_q_t   = 'nested'
-                   bc_s_t   = 'nested'
-                   bc_cs_t  = 'nested'
-                   bc_p_t   = 'neumann'
-                ENDIF
-!
-!--          For other nesting modes only set boundary conditions for
-!--          nested domains.
-             ELSE
-                IF ( child_domain )  THEN
-                   bc_lr    = 'nested'
-                   bc_ns    = 'nested'
-                   bc_uv_t  = 'nested'
-                   bc_pt_t  = 'nested'
-                   bc_q_t   = 'nested'
-                   bc_s_t   = 'nested'
-                   bc_cs_t  = 'nested'
-                   bc_p_t   = 'neumann'
-                ENDIF
-             ENDIF
+       ENDIF
+    ENDIF
+
+!
+!-- In case of nested runs, explicitly set nesting boundary conditions.
+!-- This will overwrite the user settings and basic defaults.
+!-- bc_lr and bc_ns always need to be cyclic for vertical nesting.
+    IF ( nested_run )  THEN
+       IF ( nesting_mode == 'vertical' )  THEN
+          IF (bc_lr /= 'cyclic' .OR. bc_ns /= 'cyclic' )  THEN
+             WRITE ( message_string, *) 'bc_lr and bc_ns were set to ,', &
+                     'cyclic for vertical nesting'
+             CALL message( 'parin', 'PA0428', 0, 0, 0, 6, 0 )
+             bc_lr   = 'cyclic'
+             bc_ns   = 'cyclic'
           ENDIF
-!
-!--       Set boundary conditions also in case the model is offline-nested in
-!--       larger-scale models.
-          IF ( nesting_offline )  THEN
-             bc_lr    = 'nesting_offline'
-             bc_ns    = 'nesting_offline'
-             bc_uv_t  = 'nesting_offline'
-             bc_pt_t  = 'nesting_offline'
-             bc_q_t   = 'nesting_offline'
-           !  bc_s_t   = 'nesting_offline'  ! scalar boundary condition is not clear yet
-           !  bc_cs_t  = 'nesting_offline'  ! same for chemical species
+          IF ( child_domain )  THEN
+             bc_uv_t  = 'nested'
+             bc_pt_t  = 'nested'
+             bc_q_t   = 'nested'
+             bc_s_t   = 'nested'
+             bc_cs_t  = 'nested'
              bc_p_t   = 'neumann'
           ENDIF
-
-!
-!--       In case of nested runs, make sure that initializing_actions =
-!--       'set_constant_profiles' even though the constant-profiles
-!--       initializations for the prognostic variables will be overwritten
-!--       by pmci_child_initialize and pmci_parent_initialize. This is,
-!--       however, important e.g. to make sure that diagnostic variables
-!--       are set properly. An exception is made in case of restart runs and
-!--       if user decides to do everything by its own.
-          IF ( child_domain  .AND.  .NOT. (                                    &
-               TRIM( initializing_actions ) == 'read_restart_data'      .OR.   &
-               TRIM( initializing_actions ) == 'set_constant_profiles'  .OR.   &
-               TRIM( initializing_actions ) == 'by_user' ) )  THEN
-             message_string = 'initializing_actions = ' //                     &
-                              TRIM( initializing_actions ) // ' has been ' //  &
-                              'changed to set_constant_profiles in child ' //  &
-                              'domain.'
-             CALL message( 'parin', 'PA0492', 0, 0, 0, 6, 0 )
-
-             initializing_actions = 'set_constant_profiles'
+!
+!--    For other nesting modes only set boundary conditions for
+!--    nested domains.
+       ELSE
+          IF ( child_domain )  THEN
+             bc_lr    = 'nested'
+             bc_ns    = 'nested'
+             bc_uv_t  = 'nested'
+             bc_pt_t  = 'nested'
+             bc_q_t   = 'nested'
+             bc_s_t   = 'nested'
+             bc_cs_t  = 'nested'
+             bc_p_t   = 'neumann'
           ENDIF
-!
-!--       Check validity of lateral boundary conditions. This has to be done
-!--       here because they are already used in init_pegrid and init_grid and
-!--       therefore cannot be check in check_parameters
-          IF ( bc_lr /= 'cyclic'  .AND.  bc_lr /= 'dirichlet/radiation'  .AND. &
-               bc_lr /= 'radiation/dirichlet'  .AND.  bc_lr /= 'nested'  .AND. &
-               bc_lr /= 'nesting_offline' )  THEN
-             message_string = 'unknown boundary condition: bc_lr = "' // &
-                              TRIM( bc_lr ) // '"'
-             CALL message( 'parin', 'PA0049', 1, 2, 0, 6, 0 )
-          ENDIF
-          IF ( bc_ns /= 'cyclic'  .AND.  bc_ns /= 'dirichlet/radiation'  .AND. &
-               bc_ns /= 'radiation/dirichlet'  .AND.  bc_ns /= 'nested'  .AND. &
-               bc_ns /= 'nesting_offline' )  THEN
-             message_string = 'unknown boundary condition: bc_ns = "' // &
-                              TRIM( bc_ns ) // '"'
-             CALL message( 'parin', 'PA0050', 1, 2, 0, 6, 0 )
-          ENDIF
-!
-!--       Set internal variables used for speed optimization in if clauses
-          IF ( bc_lr /= 'cyclic' )               bc_lr_cyc    = .FALSE.
-          IF ( bc_lr == 'dirichlet/radiation' )  bc_lr_dirrad = .TRUE.
-          IF ( bc_lr == 'radiation/dirichlet' )  bc_lr_raddir = .TRUE.
-          IF ( bc_ns /= 'cyclic' )               bc_ns_cyc    = .FALSE.
-          IF ( bc_ns == 'dirichlet/radiation' )  bc_ns_dirrad = .TRUE.
-          IF ( bc_ns == 'radiation/dirichlet' )  bc_ns_raddir = .TRUE.
-!
-!--       Radiation-Dirichlet conditions are allowed along one of the horizontal directions only.
-!--       In general, such conditions along x and y may work, but require a) some code changes
-!--       (e.g. concerning allocation of c_u, c_v ... arrays), and b) a careful model setup by the
-!--       user, in order to guarantee that there is a clearly defined outflow at two sides.
-!--       Otherwise, the radiation condition may produce wrong results.
-          IF ( ( bc_lr_dirrad .OR. bc_lr_raddir )  .AND.  ( bc_ns_dirrad .OR. bc_ns_raddir ) )  THEN
-             message_string = 'bc_lr = "' // TRIM( bc_lr ) // '" and bc_ns = "' //                 &
-                              TRIM( bc_ns ) // '" are not allowed to be set at the same time'
-             CALL message( 'parin', 'PA0589', 1, 2, 0, 6, 0 )
-          ENDIF
-!
-!--       Check in case of initial run, if the grid point numbers are well
-!--       defined and allocate some arrays which are already needed in
-!--       init_pegrid or check_parameters. During restart jobs, these arrays
-!--       will be allocated in rrd_global. All other arrays are allocated
-!--       in init_3d_model.
-          IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
-
-             IF ( nx <= 0 )  THEN
-                WRITE( message_string, * ) 'no value or wrong value given',    &
-                                           ' for nx: nx=', nx
-                CALL message( 'parin', 'PA0273', 1, 2, 0, 6, 0 )
-             ENDIF
-             IF ( ny <= 0 )  THEN
-                WRITE( message_string, * ) 'no value or wrong value given',    &
-                                           ' for ny: ny=', ny
-                CALL message( 'parin', 'PA0274', 1, 2, 0, 6, 0 )
-             ENDIF
-             IF ( nz <= 0 )  THEN
-                WRITE( message_string, * ) 'no value or wrong value given',    &
-                                           ' for nz: nz=', nz
-                CALL message( 'parin', 'PA0275', 1, 2, 0, 6, 0 )
-             ENDIF
-
-!
-!--          As a side condition, routine flow_statistics require at least 14
-!--          vertical grid levels (they are used to store time-series data)
-!>           @todo   Remove this restriction
-             IF ( nz < 14 )  THEN
-                WRITE( message_string, * ) 'nz >= 14 is required'
-                CALL message( 'parin', 'PA0362', 1, 2, 0, 6, 0 )
-             ENDIF
-
-!
-!--          ATTENTION: in case of changes to the following statement please
-!--                  also check the allocate statement in routine rrd_global
-             ALLOCATE( pt_init(0:nz+1), q_init(0:nz+1), s_init(0:nz+1),        &
-                       ref_state(0:nz+1), sa_init(0:nz+1), ug(0:nz+1),         &
-                       u_init(0:nz+1), v_init(0:nz+1), vg(0:nz+1),             &
-                    hom(0:nz+1,2,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:statistic_regions),  &
-                    hom_sum(0:nz+1,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:statistic_regions) )
-
-             hom = 0.0_wp
-
-          ENDIF
-
-!
-!--       NAMELIST-file is not needed anymore
-          CALL close_file( 11 )
-
-       ENDIF
-#if defined( __parallel )
-       CALL MPI_BARRIER( MPI_COMM_WORLD, ierr )
-#endif
-    ENDDO
+       ENDIF
+    ENDIF
+!
+!-- Set boundary conditions also in case the model is offline-nested in
+!-- larger-scale models.
+    IF ( nesting_offline )  THEN
+       bc_lr    = 'nesting_offline'
+       bc_ns    = 'nesting_offline'
+       bc_uv_t  = 'nesting_offline'
+       bc_pt_t  = 'nesting_offline'
+       bc_q_t   = 'nesting_offline'
+     !  bc_s_t   = 'nesting_offline'  ! scalar boundary condition is not clear yet
+     !  bc_cs_t  = 'nesting_offline'  ! same for chemical species
+       bc_p_t   = 'neumann'
+    ENDIF
+
+!
+!-- In case of nested runs, make sure that initializing_actions =
+!-- 'set_constant_profiles' even though the constant-profiles
+!-- initializations for the prognostic variables will be overwritten
+!-- by pmci_child_initialize and pmci_parent_initialize. This is,
+!-- however, important e.g. to make sure that diagnostic variables
+!-- are set properly. An exception is made in case of restart runs and
+!-- if user decides to do everything by its own.
+    IF ( child_domain  .AND.  .NOT. (                                    &
+         TRIM( initializing_actions ) == 'read_restart_data'      .OR.   &
+         TRIM( initializing_actions ) == 'set_constant_profiles'  .OR.   &
+         TRIM( initializing_actions ) == 'by_user' ) )  THEN
+       message_string = 'initializing_actions = ' //                     &
+                        TRIM( initializing_actions ) // ' has been ' //  &
+                        'changed to set_constant_profiles in child ' //  &
+                        'domain.'
+       CALL message( 'parin', 'PA0492', 0, 0, 0, 6, 0 )
+
+       initializing_actions = 'set_constant_profiles'
+    ENDIF
+!
+!-- Check validity of lateral boundary conditions. This has to be done
+!-- here because they are already used in init_pegrid and init_grid and
+!-- therefore cannot be check in check_parameters
+    IF ( bc_lr /= 'cyclic'  .AND.  bc_lr /= 'dirichlet/radiation'  .AND. &
+         bc_lr /= 'radiation/dirichlet'  .AND.  bc_lr /= 'nested'  .AND. &
+         bc_lr /= 'nesting_offline' )  THEN
+       message_string = 'unknown boundary condition: bc_lr = "' // &
+                        TRIM( bc_lr ) // '"'
+       CALL message( 'parin', 'PA0049', 1, 2, 0, 6, 0 )
+    ENDIF
+    IF ( bc_ns /= 'cyclic'  .AND.  bc_ns /= 'dirichlet/radiation'  .AND. &
+         bc_ns /= 'radiation/dirichlet'  .AND.  bc_ns /= 'nested'  .AND. &
+         bc_ns /= 'nesting_offline' )  THEN
+       message_string = 'unknown boundary condition: bc_ns = "' // &
+                        TRIM( bc_ns ) // '"'
+       CALL message( 'parin', 'PA0050', 1, 2, 0, 6, 0 )
+    ENDIF
+!
+!-- Set internal variables used for speed optimization in if clauses
+    IF ( bc_lr /= 'cyclic' )               bc_lr_cyc    = .FALSE.
+    IF ( bc_lr == 'dirichlet/radiation' )  bc_lr_dirrad = .TRUE.
+    IF ( bc_lr == 'radiation/dirichlet' )  bc_lr_raddir = .TRUE.
+    IF ( bc_ns /= 'cyclic' )               bc_ns_cyc    = .FALSE.
+    IF ( bc_ns == 'dirichlet/radiation' )  bc_ns_dirrad = .TRUE.
+    IF ( bc_ns == 'radiation/dirichlet' )  bc_ns_raddir = .TRUE.
+!
+!-- Radiation-Dirichlet conditions are allowed along one of the horizontal directions only.
+!-- In general, such conditions along x and y may work, but require a) some code changes
+!-- (e.g. concerning allocation of c_u, c_v ... arrays), and b) a careful model setup by the
+!-- user, in order to guarantee that there is a clearly defined outflow at two sides.
+!-- Otherwise, the radiation condition may produce wrong results.
+    IF ( ( bc_lr_dirrad .OR. bc_lr_raddir )  .AND.  ( bc_ns_dirrad .OR. bc_ns_raddir ) )  THEN
+       message_string = 'bc_lr = "' // TRIM( bc_lr ) // '" and bc_ns = "' //                 &
+                        TRIM( bc_ns ) // '" are not allowed to be set at the same time'
+       CALL message( 'parin', 'PA0589', 1, 2, 0, 6, 0 )
+    ENDIF
+!
+!-- Check in case of initial run, if the grid point numbers are well
+!-- defined and allocate some arrays which are already needed in
+!-- init_pegrid or check_parameters. During restart jobs, these arrays
+!-- will be allocated in rrd_global. All other arrays are allocated
+!-- in init_3d_model.
+    IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
+
+       IF ( nx <= 0 )  THEN
+          WRITE( message_string, * ) 'no value or wrong value given',    &
+                                     ' for nx: nx=', nx
+          CALL message( 'parin', 'PA0273', 1, 2, 0, 6, 0 )
+       ENDIF
+       IF ( ny <= 0 )  THEN
+          WRITE( message_string, * ) 'no value or wrong value given',    &
+                                     ' for ny: ny=', ny
+          CALL message( 'parin', 'PA0274', 1, 2, 0, 6, 0 )
+       ENDIF
+       IF ( nz <= 0 )  THEN
+          WRITE( message_string, * ) 'no value or wrong value given',    &
+                                     ' for nz: nz=', nz
+          CALL message( 'parin', 'PA0275', 1, 2, 0, 6, 0 )
+       ENDIF
+
+!
+!--    As a side condition, routine flow_statistics require at least 14
+!--    vertical grid levels (they are used to store time-series data)
+!>     @todo   Remove this restriction
+       IF ( nz < 14 )  THEN
+          WRITE( message_string, * ) 'nz >= 14 is required'
+          CALL message( 'parin', 'PA0362', 1, 2, 0, 6, 0 )
+       ENDIF
+
+!
+!--    ATTENTION: in case of changes to the following statement please
+!--               also check the allocate statement in routine rrd_global
+       ALLOCATE( pt_init(0:nz+1), q_init(0:nz+1), s_init(0:nz+1),        &
+                 ref_state(0:nz+1), sa_init(0:nz+1), ug(0:nz+1),         &
+                 u_init(0:nz+1), v_init(0:nz+1), vg(0:nz+1),             &
+                 hom(0:nz+1,2,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:statistic_regions),  &
+                 hom_sum(0:nz+1,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:statistic_regions) )
+
+       hom = 0.0_wp
+
+    ENDIF
+
+!
+!-- NAMELIST-file is not needed anymore
+    CALL close_file( 11 )
 
     CALL location_message( 'reading NAMELIST parameters from PARIN', 'finished' )
Index: /palm/trunk/SOURCE/radiation_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/radiation_model_mod.f90	(revision 4782)
+++ /palm/trunk/SOURCE/radiation_model_mod.f90	(revision 4783)
@@ -23,9 +23,12 @@
 ! Current revisions:
 ! ------------------
-! Albedo parameter list extended - building facades added
+!
 !
 ! Former revisions:
 ! -----------------
 ! $Id$
+! Albedo parameter list extended - building facades added
+!
+! 4780 2020-11-10 11:17:10Z suehring
 ! Enable 3D data output also with 64-bit precision
 !
Index: /palm/trunk/SOURCE/urban_surface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/urban_surface_mod.f90	(revision 4782)
+++ /palm/trunk/SOURCE/urban_surface_mod.f90	(revision 4783)
@@ -22,11 +22,14 @@
 ! Current revisions:
 ! -----------------
+!
+!
+! Former revisions:
+! -----------------
+! $Id$
 ! - Default building parameters updated and extended (responsible: S. Rissmann)
 ! - First and second wall layer initialized with individual building properties rather than with
 !   with the same properties (heat capacity and conductivity)
 !
-! Former revisions:
-! -----------------
-! $Id$
+! 4780 2020-11-10 11:17:10Z suehring
 ! Enable 3D data output also with 64-bit precision
 !
