Index: /palm/trunk/SOURCE/nesting_offl_mod.f90
===================================================================
--- /palm/trunk/SOURCE/nesting_offl_mod.f90	(revision 4124)
+++ /palm/trunk/SOURCE/nesting_offl_mod.f90	(revision 4125)
@@ -25,4 +25,9 @@
 ! -----------------
 ! $Id$
+! In order to enable netcdf parallel access, allocate dummy arrays for the 
+! lateral boundary data on cores that actually do not belong to these 
+! boundaries. 
+! 
+! 4079 2019-07-09 18:04:41Z suehring
 ! - Set boundary condition for w at nzt+1 at the lateral boundaries, even 
 !   though these won't enter the numerical solution. However, due to the mass
@@ -1197,6 +1202,8 @@
        ALLOCATE( nest_offl%vg(0:1,1:nzt) )
 !
-!--    Allocate arrays for reading boundary values. Arrays will incorporate 2 
-!--    time levels in order to interpolate in between. 
+!--    Allocate arrays for reading left/right boundary values. Arrays will 
+!--    incorporate 2  time levels in order to interpolate in between. If the core has 
+!--    no boundary, allocate a dummy array, in order to enable netcdf parallel
+!--    access. Dummy arrays will be allocated with dimension length zero.
        IF ( bc_dirichlet_l )  THEN
           ALLOCATE( nest_offl%u_left(0:1,nzb+1:nzt,nys:nyn)  )
@@ -1207,4 +1214,12 @@
           IF ( air_chemistry )  ALLOCATE( nest_offl%chem_left(0:1,nzb+1:nzt,nys:nyn,&
                                           1:UBOUND( chem_species, 1 )) )
+       ELSE
+          ALLOCATE( nest_offl%u_left(1:1,1:1,1:1)  )
+          ALLOCATE( nest_offl%v_left(1:1,1:1,1:1)  )
+          ALLOCATE( nest_offl%w_left(1:1,1:1,1:1)  )
+          IF ( humidity )       ALLOCATE( nest_offl%q_left(1:1,1:1,1:1)  )
+          IF ( .NOT. neutral )  ALLOCATE( nest_offl%pt_left(1:1,1:1,1:1)  )
+          IF ( air_chemistry )  ALLOCATE( nest_offl%chem_left(1:1,1:1,1:1,     &
+                                          1:UBOUND( chem_species, 1 )) )
        ENDIF
        IF ( bc_dirichlet_r )  THEN
@@ -1216,5 +1231,18 @@
           IF ( air_chemistry )  ALLOCATE( nest_offl%chem_right(0:1,nzb+1:nzt,nys:nyn,&
                                           1:UBOUND( chem_species, 1 )) )
-       ENDIF
+       ELSE
+          ALLOCATE( nest_offl%u_right(1:1,1:1,1:1)  )
+          ALLOCATE( nest_offl%v_right(1:1,1:1,1:1)  )
+          ALLOCATE( nest_offl%w_right(1:1,1:1,1:1)  )
+          IF ( humidity )       ALLOCATE( nest_offl%q_right(1:1,1:1,1:1)  )
+          IF ( .NOT. neutral )  ALLOCATE( nest_offl%pt_right(1:1,1:1,1:1)  )
+          IF ( air_chemistry )  ALLOCATE( nest_offl%chem_right(1:1,1:1,1:1,    &
+                                          1:UBOUND( chem_species, 1 )) )
+       ENDIF
+!
+!--    Allocate arrays for reading north/south boundary values. Arrays will 
+!--    incorporate 2  time levels in order to interpolate in between. If the core has 
+!--    no boundary, allocate a dummy array, in order to enable netcdf parallel
+!--    access. Dummy arrays will be allocated with dimension length zero.
        IF ( bc_dirichlet_n )  THEN
           ALLOCATE( nest_offl%u_north(0:1,nzb+1:nzt,nxlu:nxr) )
@@ -1225,4 +1253,12 @@
           IF ( air_chemistry )  ALLOCATE( nest_offl%chem_north(0:1,nzb+1:nzt,nxl:nxr,&
                                           1:UBOUND( chem_species, 1 )) )
+       ELSE
+          ALLOCATE( nest_offl%u_north(1:1,1:1,1:1)  )
+          ALLOCATE( nest_offl%v_north(1:1,1:1,1:1)  )
+          ALLOCATE( nest_offl%w_north(1:1,1:1,1:1)  )
+          IF ( humidity )       ALLOCATE( nest_offl%q_north(1:1,1:1,1:1)  )
+          IF ( .NOT. neutral )  ALLOCATE( nest_offl%pt_north(1:1,1:1,1:1)  )
+          IF ( air_chemistry )  ALLOCATE( nest_offl%chem_north(1:1,1:1,1:1,    &
+                                          1:UBOUND( chem_species, 1 )) )
        ENDIF
        IF ( bc_dirichlet_s )  THEN
@@ -1234,6 +1270,17 @@
           IF ( air_chemistry )  ALLOCATE( nest_offl%chem_south(0:1,nzb+1:nzt,nxl:nxr,&
                                           1:UBOUND( chem_species, 1 )) )
-       ENDIF
-       
+       ELSE
+          ALLOCATE( nest_offl%u_south(1:1,1:1,1:1)  )
+          ALLOCATE( nest_offl%v_south(1:1,1:1,1:1)  )
+          ALLOCATE( nest_offl%w_south(1:1,1:1,1:1)  )
+          IF ( humidity )       ALLOCATE( nest_offl%q_south(1:1,1:1,1:1)  )
+          IF ( .NOT. neutral )  ALLOCATE( nest_offl%pt_south(1:1,1:1,1:1)  )
+          IF ( air_chemistry )  ALLOCATE( nest_offl%chem_south(1:1,1:1,1:1,    &
+                                          1:UBOUND( chem_species, 1 )) )
+       ENDIF
+!
+!--    Allocate arrays for reading data at the top boundary. In contrast to the
+!--    lateral boundaries, every core reads these data so that no dummy
+!--    arrays need to be allocated.
        ALLOCATE( nest_offl%u_top(0:1,nys:nyn,nxlu:nxr) )
        ALLOCATE( nest_offl%v_top(0:1,nysv:nyn,nxl:nxr) )
Index: /palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- /palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4124)
+++ /palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4125)
@@ -25,6 +25,10 @@
 ! -----------------
 ! $Id$
+! To enable netcdf-parallel access for lateral boundary data (dynamic input), 
+! zero number of elements are passed to the respective get_variable routine 
+! for non-boundary cores. 
+! 
+! 4100 2019-07-17 08:11:29Z forkel
 ! Made check for input_pids_dynamic and 'inifor' more general
-! 
 ! 
 ! 4012 2019-05-31 15:19:05Z monakurppa
@@ -3823,190 +3827,302 @@
 !--    quantities the data starts at nys. This is equivalent at the north
 !--    and south domain boundary for the u-component. 
-!--    Further, lateral data is not accessed by parallel IO, indicated by the 
-!--    last passed flag in the subroutine get_variable(). This is because
-!--    not every PE participates in this collective blocking read operation. 
-       IF ( bc_dirichlet_l )  THEN
-          CALL get_variable( id_dynamic, 'ls_forcing_left_u',                  &
-                           nest_offl%u_left(0:1,nzb+1:nzt,nys:nyn),            &
-                           nys+1, nzb+1, nest_offl%tind+1,                     &
-                           nyn-nys+1, nest_offl%nzu, 2, .FALSE. )
+!--    Note, lateral data is also accessed by parallel IO, which is the reason
+!--    why different arguments are passed depending on the boundary control
+!--    flags. Cores that do not belong to the respective boundary just make
+!--    a dummy read with count = 0, just in order to participate the collective
+!--    operation. 
+!--    Read data for western boundary    
+       CALL get_variable( id_dynamic, 'ls_forcing_left_u',                     &
+                          nest_offl%u_left,                                    & ! array to be read
+                          MERGE( nys+1, 1, bc_dirichlet_l),                    & ! start index y direction
+                          MERGE( nzb+1, 1, bc_dirichlet_l),                    & ! start index z direction
+                          MERGE( nest_offl%tind+1, 1, bc_dirichlet_l),         & ! start index time dimension
+                          MERGE( nyn-nys+1, 0, bc_dirichlet_l),                & ! number of elements along y
+                          MERGE( nest_offl%nzu, 0, bc_dirichlet_l),            & ! number of elements alogn z
+                          MERGE( 2, 0, bc_dirichlet_l),                        & ! number of time steps (2 or 0)
+                          .TRUE. )                                               ! parallel IO when compiled accordingly
       
-          CALL get_variable( id_dynamic, 'ls_forcing_left_v',                  &
-                           nest_offl%v_left(0:1,nzb+1:nzt,nysv:nyn),           &
-                           nysv, nzb+1, nest_offl%tind+1,                      &
-                           nyn-nysv+1, nest_offl%nzu, 2, .FALSE. )
-
-          CALL get_variable( id_dynamic, 'ls_forcing_left_w',                  &
-                           nest_offl%w_left(0:1,nzb+1:nzt-1,nys:nyn),          &
-                           nys+1, nzb+1, nest_offl%tind+1,                     &
-                           nyn-nys+1, nest_offl%nzw, 2, .FALSE. )
-
-          IF ( .NOT. neutral )  THEN
-             CALL get_variable( id_dynamic, 'ls_forcing_left_pt',              &
-                           nest_offl%pt_left(0:1,nzb+1:nzt,nys:nyn),           &
-                           nys+1, nzb+1, nest_offl%tind+1,                     &
-                           nyn-nys+1, nest_offl%nzu, 2, .FALSE. )
-          ENDIF
-
-          IF ( humidity )  THEN
-             CALL get_variable( id_dynamic, 'ls_forcing_left_qv',              &
-                           nest_offl%q_left(0:1,nzb+1:nzt,nys:nyn),            &
-                           nys+1, nzb+1, nest_offl%tind+1,                     &
-                           nyn-nys+1, nest_offl%nzu, 2, .FALSE. )
-          ENDIF
-          
-          IF ( air_chemistry )  THEN
-             DO  n = 1, UBOUND(nest_offl%var_names_chem_l, 1)
-                IF ( check_existence( nest_offl%var_names,                     &
-                                      nest_offl%var_names_chem_l(n) ) )        &
-                THEN
-                   CALL get_variable( id_dynamic,                              &
-                              TRIM( nest_offl%var_names_chem_l(n) ),           &
-                              nest_offl%chem_left(0:1,nzb+1:nzt,nys:nyn,n),    &
-                              nys+1, nzb+1, nest_offl%tind+1,                  &
-                              nyn-nys+1, nest_offl%nzu, 2, .FALSE. )
-                   nest_offl%chem_from_file_l(n) = .TRUE.
-                ENDIF
-             ENDDO
-          ENDIF
-
-       ENDIF
-
-       IF ( bc_dirichlet_r )  THEN
-          CALL get_variable( id_dynamic, 'ls_forcing_right_u',                 &
-                           nest_offl%u_right(0:1,nzb+1:nzt,nys:nyn),           &
-                           nys+1, nzb+1, nest_offl%tind+1,                     &
-                           nyn-nys+1, nest_offl%nzu, 2, .FALSE. )
-                           
-          CALL get_variable( id_dynamic, 'ls_forcing_right_v',                 &
-                           nest_offl%v_right(0:1,nzb+1:nzt,nysv:nyn),          &
-                           nysv, nzb+1, nest_offl%tind+1,                      &
-                           nyn-nysv+1, nest_offl%nzu, 2, .FALSE. )
-                           
-          CALL get_variable( id_dynamic, 'ls_forcing_right_w',                 &
-                           nest_offl%w_right(0:1,nzb+1:nzt-1,nys:nyn),         &
-                           nys+1, nzb+1, nest_offl%tind+1,                     &
-                           nyn-nys+1, nest_offl%nzw, 2, .FALSE. )
-                           
-          IF ( .NOT. neutral )  THEN
-             CALL get_variable( id_dynamic, 'ls_forcing_right_pt',             &
-                           nest_offl%pt_right(0:1,nzb+1:nzt,nys:nyn),          &
-                           nys+1, nzb+1, nest_offl%tind+1,                     &
-                           nyn-nys+1, nest_offl%nzu, 2, .FALSE. )
-          ENDIF
-          IF ( humidity )  THEN
-             CALL get_variable( id_dynamic, 'ls_forcing_right_qv',             &
-                           nest_offl%q_right(0:1,nzb+1:nzt,nys:nyn),           &
-                           nys+1, nzb+1, nest_offl%tind+1,                     &
-                           nyn-nys+1, nest_offl%nzu, 2, .FALSE. )
-          ENDIF
-          
-          IF ( air_chemistry )  THEN
-             DO  n = 1, UBOUND(nest_offl%var_names_chem_r, 1)
-                IF ( check_existence( nest_offl%var_names,                     &
-                                      nest_offl%var_names_chem_r(n) ) )        &
-                THEN
-                   CALL get_variable( id_dynamic,                              &
-                              TRIM( nest_offl%var_names_chem_r(n) ),           &
-                              nest_offl%chem_right(0:1,nzb+1:nzt,nys:nyn,n),   &
-                              nys+1, nzb+1, nest_offl%tind+1,                  &
-                              nyn-nys+1, nest_offl%nzu, 2, .FALSE. )
-                   nest_offl%chem_from_file_r(n) = .TRUE.
-                ENDIF
-             ENDDO
-          ENDIF
-       ENDIF
-
-       IF ( bc_dirichlet_n )  THEN
+       CALL get_variable( id_dynamic, 'ls_forcing_left_v',                     &
+                          nest_offl%v_left,                                    &
+                          MERGE( nysv, 1, bc_dirichlet_l),                     &
+                          MERGE( nzb+1, 1, bc_dirichlet_l),                    &
+                          MERGE( nest_offl%tind+1, 1, bc_dirichlet_l),         &
+                          MERGE( nyn-nysv+1, 0, bc_dirichlet_l),               &
+                          MERGE( nest_offl%nzu, 0, bc_dirichlet_l),            &
+                          MERGE( 2, 0, bc_dirichlet_l),                        &
+                          .TRUE. )                                        
+
+       CALL get_variable( id_dynamic, 'ls_forcing_left_w',                     &
+                          nest_offl%w_left,                                    &
+                          MERGE( nys+1, 1, bc_dirichlet_l),                    &
+                          MERGE( nzb+1, 1, bc_dirichlet_l),                    &
+                          MERGE( nest_offl%tind+1, 1, bc_dirichlet_l),         &
+                          MERGE( nyn-nys+1, 0, bc_dirichlet_l),                &
+                          MERGE( nest_offl%nzw, 0, bc_dirichlet_l),            &
+                          MERGE( 2, 0, bc_dirichlet_l),                        &
+                          .TRUE. )   
+
+       IF ( .NOT. neutral )  THEN
+          CALL get_variable( id_dynamic, 'ls_forcing_left_pt',                 &
+                             nest_offl%pt_left,                                &
+                             MERGE( nys+1, 1, bc_dirichlet_l),                 &
+                             MERGE( nzb+1, 1, bc_dirichlet_l),                 &
+                             MERGE( nest_offl%tind+1, 1, bc_dirichlet_l),      &
+                             MERGE( nyn-nys+1, 0, bc_dirichlet_l),             &
+                             MERGE( nest_offl%nzu, 0, bc_dirichlet_l),         &
+                             MERGE( 2, 0, bc_dirichlet_l),                     &
+                             .TRUE. )
+       ENDIF
+
+       IF ( humidity )  THEN
+          CALL get_variable( id_dynamic, 'ls_forcing_left_qv',                 &
+                             nest_offl%q_left,                                 &
+                             MERGE( nys+1, 1, bc_dirichlet_l),                 &
+                             MERGE( nzb+1, 1, bc_dirichlet_l),                 &
+                             MERGE( nest_offl%tind+1, 1, bc_dirichlet_l),      &
+                             MERGE( nyn-nys+1, 0, bc_dirichlet_l),             &
+                             MERGE( nest_offl%nzu, 0, bc_dirichlet_l),         &
+                             MERGE( 2, 0, bc_dirichlet_l),                     &
+                             .TRUE. )
+       ENDIF
        
-          CALL get_variable( id_dynamic, 'ls_forcing_north_u',                 &
-                           nest_offl%u_north(0:1,nzb+1:nzt,nxlu:nxr),          &
-                           nxlu, nzb+1, nest_offl%tind+1,                      &
-                           nxr-nxlu+1, nest_offl%nzu, 2, .FALSE. )
-                           
-          CALL get_variable( id_dynamic, 'ls_forcing_north_v',                 &
-                           nest_offl%v_north(0:1,nzb+1:nzt,nxl:nxr),           &
-                           nxl+1, nzb+1, nest_offl%tind+1,                     &
-                           nxr-nxl+1, nest_offl%nzu, 2, .FALSE. )
-                           
-          CALL get_variable( id_dynamic, 'ls_forcing_north_w',                 &
-                           nest_offl%w_north(0:1,nzb+1:nzt-1,nxl:nxr),         &
-                           nxl+1, nzb+1, nest_offl%tind+1,                     &
-                           nxr-nxl+1, nest_offl%nzw, 2, .FALSE. )
-                           
-          IF ( .NOT. neutral )  THEN
-             CALL get_variable( id_dynamic, 'ls_forcing_north_pt',             &
-                           nest_offl%pt_north(0:1,nzb+1:nzt,nxl:nxr),          &
-                           nxl+1, nzb+1, nest_offl%tind+1,                     &
-                           nxr-nxl+1, nest_offl%nzu, 2, .FALSE. )
-          ENDIF
-          IF ( humidity )  THEN
-             CALL get_variable( id_dynamic, 'ls_forcing_north_qv',             &
-                           nest_offl%q_north(0:1,nzb+1:nzt,nxl:nxr),           &
-                           nxl+1, nzb+1, nest_offl%tind+1,                     &
-                           nxr-nxl+1, nest_offl%nzu, 2, .FALSE. )
-          ENDIF
-          
-          IF ( air_chemistry )  THEN
-             DO  n = 1, UBOUND(nest_offl%var_names_chem_n, 1)
-                IF ( check_existence( nest_offl%var_names,                     &
-                                      nest_offl%var_names_chem_n(n) ) )        &
-                THEN
-                   CALL get_variable( id_dynamic,                              &
-                              TRIM( nest_offl%var_names_chem_n(n) ),           &
-                              nest_offl%chem_north(0:1,nzb+1:nzt,nxl:nxr,n),   &
-                              nxl+1, nzb+1, nest_offl%tind+1,                  &
-                              nxr-nxl+1, nest_offl%nzu, 2, .FALSE. )
-                   nest_offl%chem_from_file_n(n) = .TRUE.
-                ENDIF
-             ENDDO
-          ENDIF
-       ENDIF
-
-       IF ( bc_dirichlet_s )  THEN
-          CALL get_variable( id_dynamic, 'ls_forcing_south_u',                 &
-                           nest_offl%u_south(0:1,nzb+1:nzt,nxlu:nxr),          &
-                           nxlu, nzb+1, nest_offl%tind+1,                      &
-                           nxr-nxlu+1, nest_offl%nzu, 2, .FALSE. )
-
-          CALL get_variable( id_dynamic, 'ls_forcing_south_v',                 &
-                           nest_offl%v_south(0:1,nzb+1:nzt,nxl:nxr),           &
-                           nxl+1, nzb+1, nest_offl%tind+1,                     &
-                           nxr-nxl+1, nest_offl%nzu, 2, .FALSE. )
-                           
-          CALL get_variable( id_dynamic, 'ls_forcing_south_w',                 &
-                           nest_offl%w_south(0:1,nzb+1:nzt-1,nxl:nxr),         &
-                           nxl+1, nzb+1, nest_offl%tind+1,                     &
-                           nxr-nxl+1, nest_offl%nzw, 2, .FALSE. )
-                           
-          IF ( .NOT. neutral )  THEN
-             CALL get_variable( id_dynamic, 'ls_forcing_south_pt',             &
-                           nest_offl%pt_south(0:1,nzb+1:nzt,nxl:nxr),          &
-                           nxl+1, nzb+1, nest_offl%tind+1,                     &
-                           nxr-nxl+1, nest_offl%nzu, 2, .FALSE. )
-          ENDIF
-          IF ( humidity )  THEN
-             CALL get_variable( id_dynamic, 'ls_forcing_south_qv',             &
-                           nest_offl%q_south(0:1,nzb+1:nzt,nxl:nxr),           &
-                           nxl+1, nzb+1, nest_offl%tind+1,                     &
-                           nxr-nxl+1, nest_offl%nzu, 2, .FALSE. )
-          ENDIF
-          
-          IF ( air_chemistry )  THEN
-             DO  n = 1, UBOUND(nest_offl%var_names_chem_s, 1)
-                IF ( check_existence( nest_offl%var_names,                     &
-                                      nest_offl%var_names_chem_s(n) ) )        &
-                THEN
-                   CALL get_variable( id_dynamic,                              &
-                              TRIM( nest_offl%var_names_chem_s(n) ),           &
-                              nest_offl%chem_south(0:1,nzb+1:nzt,nxl:nxr,n),   &
-                              nxl+1, nzb+1, nest_offl%tind+1,                  &
-                              nxr-nxl+1, nest_offl%nzu, 2, .FALSE. )
-                   nest_offl%chem_from_file_s(n) = .TRUE.
-                ENDIF
-             ENDDO
-          ENDIF
-       ENDIF
-
+       IF ( air_chemistry )  THEN
+          DO  n = 1, UBOUND(nest_offl%var_names_chem_l, 1)
+             IF ( check_existence( nest_offl%var_names,                        &
+                                   nest_offl%var_names_chem_l(n) ) )  THEN  
+                CALL get_variable( id_dynamic,                                 &
+                           TRIM( nest_offl%var_names_chem_l(n) ),              &
+                           nest_offl%chem_left(:,:,:,n),                       &
+                           MERGE( nys+1, 1, bc_dirichlet_l),                   &
+                           MERGE( nzb+1, 1, bc_dirichlet_l),                   &
+                           MERGE( nest_offl%tind+1, 1, bc_dirichlet_l),        &
+                           MERGE( nyn-nys+1, 0, bc_dirichlet_l),               &
+                           MERGE( nest_offl%nzu, 0, bc_dirichlet_l),           &
+                           MERGE( 2, 0, bc_dirichlet_l),                       &
+                           .TRUE. )
+                nest_offl%chem_from_file_l(n) = .TRUE.
+             ENDIF
+          ENDDO
+       ENDIF
+!
+!--    Read data for eastern boundary    
+       CALL get_variable( id_dynamic, 'ls_forcing_right_u',                    &
+                          nest_offl%u_right,                                   &
+                          MERGE( nys+1, 1, bc_dirichlet_r),                    &
+                          MERGE( nzb+1, 1, bc_dirichlet_r),                    &
+                          MERGE( nest_offl%tind+1, 1, bc_dirichlet_r),         &
+                          MERGE( nyn-nys+1, 0, bc_dirichlet_r),                &
+                          MERGE( nest_offl%nzu, 0, bc_dirichlet_r),            &
+                          MERGE( 2, 0, bc_dirichlet_r),                        &
+                          .TRUE. )                                             
+      
+       CALL get_variable( id_dynamic, 'ls_forcing_right_v',                    &
+                          nest_offl%v_right,                                   &
+                          MERGE( nysv, 1, bc_dirichlet_r),                     &
+                          MERGE( nzb+1, 1, bc_dirichlet_r),                    &
+                          MERGE( nest_offl%tind+1, 1, bc_dirichlet_r),         &
+                          MERGE( nyn-nysv+1, 0, bc_dirichlet_r),               &
+                          MERGE( nest_offl%nzu, 0, bc_dirichlet_r),            &
+                          MERGE( 2, 0, bc_dirichlet_r),                        &
+                          .TRUE. )                                             
+
+       CALL get_variable( id_dynamic, 'ls_forcing_right_w',                    &
+                          nest_offl%w_right,                                   &
+                          MERGE( nys+1, 1, bc_dirichlet_r),                    &
+                          MERGE( nzb+1, 1, bc_dirichlet_r),                    &
+                          MERGE( nest_offl%tind+1, 1, bc_dirichlet_r),         &
+                          MERGE( nyn-nys+1, 0, bc_dirichlet_r),                &
+                          MERGE( nest_offl%nzw, 0, bc_dirichlet_r),            &
+                          MERGE( 2, 0, bc_dirichlet_r),                        &
+                          .TRUE. )   
+
+       IF ( .NOT. neutral )  THEN
+          CALL get_variable( id_dynamic, 'ls_forcing_right_pt',                &
+                             nest_offl%pt_right,                               &
+                             MERGE( nys+1, 1, bc_dirichlet_r),                 &
+                             MERGE( nzb+1, 1, bc_dirichlet_r),                 &
+                             MERGE( nest_offl%tind+1, 1, bc_dirichlet_r),      &
+                             MERGE( nyn-nys+1, 0, bc_dirichlet_r),             &
+                             MERGE( nest_offl%nzu, 0, bc_dirichlet_r),         &
+                             MERGE( 2, 0, bc_dirichlet_r),                     &
+                             .TRUE. )
+       ENDIF
+
+       IF ( humidity )  THEN
+          CALL get_variable( id_dynamic, 'ls_forcing_right_qv',                &
+                             nest_offl%q_right,                                &
+                             MERGE( nys+1, 1, bc_dirichlet_r),                 &
+                             MERGE( nzb+1, 1, bc_dirichlet_r),                 &
+                             MERGE( nest_offl%tind+1, 1, bc_dirichlet_r),      &
+                             MERGE( nyn-nys+1, 0, bc_dirichlet_r),             &
+                             MERGE( nest_offl%nzu, 0, bc_dirichlet_r),         &
+                             MERGE( 2, 0, bc_dirichlet_r),                     &
+                             .TRUE. )
+       ENDIF
+       
+       IF ( air_chemistry )  THEN
+          DO  n = 1, UBOUND(nest_offl%var_names_chem_r, 1)
+             IF ( check_existence( nest_offl%var_names,                        &
+                                   nest_offl%var_names_chem_r(n) ) )  THEN     
+                CALL get_variable( id_dynamic,                                 &
+                           TRIM( nest_offl%var_names_chem_r(n) ),              &
+                           nest_offl%chem_right(:,:,:,n),                      &
+                           MERGE( nys+1, 1, bc_dirichlet_r),                   &
+                           MERGE( nzb+1, 1, bc_dirichlet_r),                   &
+                           MERGE( nest_offl%tind+1, 1, bc_dirichlet_r),        &
+                           MERGE( nyn-nys+1, 0, bc_dirichlet_r),               &
+                           MERGE( nest_offl%nzu, 0, bc_dirichlet_r),           &
+                           MERGE( 2, 0, bc_dirichlet_r),                       &
+                           .TRUE. )
+                nest_offl%chem_from_file_r(n) = .TRUE.
+             ENDIF
+          ENDDO
+       ENDIF
+!
+!--    Read data for northern boundary
+       CALL get_variable( id_dynamic, 'ls_forcing_north_u',                    & ! array to be read
+                          nest_offl%u_north,                                   & ! start index x direction
+                          MERGE( nxlu, 1, bc_dirichlet_n ),                    & ! start index z direction
+                          MERGE( nzb+1, 1, bc_dirichlet_n ),                   & ! start index time dimension
+                          MERGE( nest_offl%tind+1, 1, bc_dirichlet_n ),        & ! number of elements along x
+                          MERGE( nxr-nxlu+1, 0, bc_dirichlet_n ),              & ! number of elements alogn z 
+                          MERGE( nest_offl%nzu, 0, bc_dirichlet_n ),           & ! number of time steps (2 or 0)
+                          MERGE( 2, 0, bc_dirichlet_n ),                       & ! parallel IO when compiled accordingly
+                          .TRUE. )                                             
+                                                                               
+       CALL get_variable( id_dynamic, 'ls_forcing_north_v',                    & ! array to be read
+                          nest_offl%v_north,                                   & ! start index x direction
+                          MERGE( nxl+1, 1, bc_dirichlet_n ),                   & ! start index z direction
+                          MERGE( nzb+1, 1, bc_dirichlet_n ),                   & ! start index time dimension
+                          MERGE( nest_offl%tind+1, 1, bc_dirichlet_n ),        & ! number of elements along x
+                          MERGE( nxr-nxl+1, 0, bc_dirichlet_n ),               & ! number of elements alogn z 
+                          MERGE( nest_offl%nzu, 0, bc_dirichlet_n ),           & ! number of time steps (2 or 0)
+                          MERGE( 2, 0, bc_dirichlet_n ),                       & ! parallel IO when compiled accordingly
+                          .TRUE. )                                             
+                                                                               
+       CALL get_variable( id_dynamic, 'ls_forcing_north_w',                    & ! array to be read
+                          nest_offl%w_north,                                   & ! start index x direction
+                          MERGE( nxl+1, 1, bc_dirichlet_n ),                   & ! start index z direction
+                          MERGE( nzb+1, 1, bc_dirichlet_n ),                   & ! start index time dimension
+                          MERGE( nest_offl%tind+1, 1, bc_dirichlet_n ),        & ! number of elements along x
+                          MERGE( nxr-nxl+1, 0, bc_dirichlet_n ),               & ! number of elements alogn z 
+                          MERGE( nest_offl%nzw, 0, bc_dirichlet_n ),           & ! number of time steps (2 or 0)
+                          MERGE( 2, 0, bc_dirichlet_n ),                       & ! parallel IO when compiled accordingly
+                          .TRUE. )                                             
+                                                                               
+       IF ( .NOT. neutral )  THEN                                              
+          CALL get_variable( id_dynamic, 'ls_forcing_north_pt',                & ! array to be read
+                             nest_offl%pt_north,                               & ! start index x direction
+                             MERGE( nxl+1, 1, bc_dirichlet_n ),                & ! start index z direction
+                             MERGE( nzb+1, 1, bc_dirichlet_n ),                & ! start index time dimension
+                             MERGE( nest_offl%tind+1, 1, bc_dirichlet_n ),     & ! number of elements along x
+                             MERGE( nxr-nxl+1, 0, bc_dirichlet_n ),            & ! number of elements alogn z 
+                             MERGE( nest_offl%nzu, 0, bc_dirichlet_n ),        & ! number of time steps (2 or 0)
+                             MERGE( 2, 0, bc_dirichlet_n ),                    & ! parallel IO when compiled accordingly
+                             .TRUE. )                                             
+       ENDIF                                                                   
+       IF ( humidity )  THEN                                                   
+          CALL get_variable( id_dynamic, 'ls_forcing_north_qv',                & ! array to be read
+                             nest_offl%q_north,                                & ! start index x direction
+                             MERGE( nxl+1, 1, bc_dirichlet_n ),                & ! start index z direction
+                             MERGE( nzb+1, 1, bc_dirichlet_n ),                & ! start index time dimension
+                             MERGE( nest_offl%tind+1, 1, bc_dirichlet_n ),     & ! number of elements along x
+                             MERGE( nxr-nxl+1, 0, bc_dirichlet_n ),            & ! number of elements alogn z 
+                             MERGE( nest_offl%nzu, 0, bc_dirichlet_n ),        & ! number of time steps (2 or 0)
+                             MERGE( 2, 0, bc_dirichlet_n ),                    & ! parallel IO when compiled accordingly
+                             .TRUE. )                                             
+       ENDIF                                                                   
+                                                                               
+       IF ( air_chemistry )  THEN                                              
+          DO  n = 1, UBOUND(nest_offl%var_names_chem_n, 1)                     
+             IF ( check_existence( nest_offl%var_names,                        &
+                                   nest_offl%var_names_chem_n(n) ) )  THEN     
+                CALL get_variable( id_dynamic,                                 &
+                           TRIM( nest_offl%var_names_chem_n(n) ),              &
+                           nest_offl%chem_north(:,:,:,n),                      &
+                           MERGE( nxl+1, 1, bc_dirichlet_n ),                  &
+                           MERGE( nzb+1, 1, bc_dirichlet_n ),                  &
+                           MERGE( nest_offl%tind+1, 1, bc_dirichlet_n ),       &
+                           MERGE( nxr-nxl+1, 0, bc_dirichlet_n ),              &
+                           MERGE( nest_offl%nzu, 0, bc_dirichlet_n ),          &
+                           MERGE( 2, 0, bc_dirichlet_n ),                      &
+                           .TRUE. )
+                nest_offl%chem_from_file_n(n) = .TRUE.
+             ENDIF
+          ENDDO
+       ENDIF
+!
+!--    Read data for southern boundary
+       CALL get_variable( id_dynamic, 'ls_forcing_south_u',                    & ! array to be read
+                          nest_offl%u_south,                                   & ! start index x direction
+                          MERGE( nxlu, 1, bc_dirichlet_s ),                    & ! start index z direction
+                          MERGE( nzb+1, 1, bc_dirichlet_s ),                   & ! start index time dimension
+                          MERGE( nest_offl%tind+1, 1, bc_dirichlet_s ),        & ! number of elements along x
+                          MERGE( nxr-nxlu+1, 0, bc_dirichlet_s ),              & ! number of elements alogn z 
+                          MERGE( nest_offl%nzu, 0, bc_dirichlet_s ),           & ! number of time steps (2 or 0)
+                          MERGE( 2, 0, bc_dirichlet_s ),                       & ! parallel IO when compiled accordingly
+                          .TRUE. )                                             
+                                                                               
+       CALL get_variable( id_dynamic, 'ls_forcing_south_v',                    & ! array to be read
+                          nest_offl%v_south,                                   & ! start index x direction
+                          MERGE( nxl+1, 1, bc_dirichlet_s ),                   & ! start index z direction
+                          MERGE( nzb+1, 1, bc_dirichlet_s ),                   & ! start index time dimension
+                          MERGE( nest_offl%tind+1, 1, bc_dirichlet_s ),        & ! number of elements along x
+                          MERGE( nxr-nxl+1, 0, bc_dirichlet_s ),               & ! number of elements alogn z 
+                          MERGE( nest_offl%nzu, 0, bc_dirichlet_s ),           & ! number of time steps (2 or 0)
+                          MERGE( 2, 0, bc_dirichlet_s ),                       & ! parallel IO when compiled accordingly
+                          .TRUE. )                                             
+                                                                               
+       CALL get_variable( id_dynamic, 'ls_forcing_south_w',                    & ! array to be read
+                          nest_offl%w_south,                                   & ! start index x direction
+                          MERGE( nxl+1, 1, bc_dirichlet_s ),                   & ! start index z direction
+                          MERGE( nzb+1, 1, bc_dirichlet_s ),                   & ! start index time dimension
+                          MERGE( nest_offl%tind+1, 1, bc_dirichlet_s ),        & ! number of elements along x
+                          MERGE( nxr-nxl+1, 0, bc_dirichlet_s ),               & ! number of elements alogn z 
+                          MERGE( nest_offl%nzw, 0, bc_dirichlet_s ),           & ! number of time steps (2 or 0)
+                          MERGE( 2, 0, bc_dirichlet_s ),                       & ! parallel IO when compiled accordingly
+                          .TRUE. )                                             
+                                                                               
+       IF ( .NOT. neutral )  THEN                                              
+          CALL get_variable( id_dynamic, 'ls_forcing_south_pt',                & ! array to be read
+                             nest_offl%pt_south,                               & ! start index x direction
+                             MERGE( nxl+1, 1, bc_dirichlet_s ),                & ! start index z direction
+                             MERGE( nzb+1, 1, bc_dirichlet_s ),                & ! start index time dimension
+                             MERGE( nest_offl%tind+1, 1, bc_dirichlet_s ),     & ! number of elements along x
+                             MERGE( nxr-nxl+1, 0, bc_dirichlet_s ),            & ! number of elements alogn z 
+                             MERGE( nest_offl%nzu, 0, bc_dirichlet_s ),        & ! number of time steps (2 or 0)
+                             MERGE( 2, 0, bc_dirichlet_s ),                    & ! parallel IO when compiled accordingly
+                             .TRUE. )                                             
+       ENDIF                                                                   
+       IF ( humidity )  THEN                                                   
+          CALL get_variable( id_dynamic, 'ls_forcing_south_qv',                & ! array to be read
+                             nest_offl%q_south,                                & ! start index x direction
+                             MERGE( nxl+1, 1, bc_dirichlet_s ),                & ! start index z direction
+                             MERGE( nzb+1, 1, bc_dirichlet_s ),                & ! start index time dimension
+                             MERGE( nest_offl%tind+1, 1, bc_dirichlet_s ),     & ! number of elements along x
+                             MERGE( nxr-nxl+1, 0, bc_dirichlet_s ),            & ! number of elements alogn z 
+                             MERGE( nest_offl%nzu, 0, bc_dirichlet_s ),        & ! number of time steps (2 or 0)
+                             MERGE( 2, 0, bc_dirichlet_s ),                    & ! parallel IO when compiled accordingly
+                             .TRUE. )                                             
+       ENDIF                                                                   
+                                                                               
+       IF ( air_chemistry )  THEN                                              
+          DO  n = 1, UBOUND(nest_offl%var_names_chem_s, 1)                     
+             IF ( check_existence( nest_offl%var_names,                        &
+                                   nest_offl%var_names_chem_s(n) ) )  THEN     
+                CALL get_variable( id_dynamic,                                 &
+                           TRIM( nest_offl%var_names_chem_s(n) ),              &
+                           nest_offl%chem_south(:,:,:,n),                      &
+                           MERGE( nxl+1, 1, bc_dirichlet_s ),                  &
+                           MERGE( nzb+1, 1, bc_dirichlet_s ),                  &
+                           MERGE( nest_offl%tind+1, 1, bc_dirichlet_s ),       &
+                           MERGE( nxr-nxl+1, 0, bc_dirichlet_s ),              &
+                           MERGE( nest_offl%nzu, 0, bc_dirichlet_s ),          &
+                           MERGE( 2, 0, bc_dirichlet_s ),                      &
+                           .TRUE. )
+                nest_offl%chem_from_file_s(n) = .TRUE.
+             ENDIF
+          ENDDO
+       ENDIF
 !
 !--    Top boundary
