Index: palm/trunk/SOURCE/advec_ws.f90
===================================================================
--- palm/trunk/SOURCE/advec_ws.f90	(revision 3178)
+++ palm/trunk/SOURCE/advec_ws.f90	(revision 3182)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! ------------------
-! 
+! Rename variables for boundary-condition flags and for offline nesting mode 
 ! 
 ! Former revisions:
@@ -460,8 +460,7 @@
 
        USE control_parameters,                                                 &
-           ONLY:  force_bound_l, force_bound_n, force_bound_r, force_bound_s,  &
-                  inflow_l, inflow_n, inflow_r, inflow_s, momentum_advec,      &
-                  nest_bound_l, nest_bound_n, nest_bound_r, nest_bound_s,      &
-                  outflow_l, outflow_n, outflow_r, outflow_s, scalar_advec
+           ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,              &
+                  bc_dirichlet_s, bc_radiation_l, bc_radiation_n,              &
+                  bc_radiation_r, bc_radiation_s, momentum_advec, scalar_advec
 
        USE indices,                                                            &
@@ -501,9 +500,7 @@
                     .OR.  .NOT. BTEST(wall_flags_0(k,j,i+2),0)                 &   
                     .OR.  .NOT. BTEST(wall_flags_0(k,j,i-1),0) )               &
-                      .OR.  ( ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.&
-                                force_bound_l )                                &
+                      .OR.  ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
                             .AND.  i == nxl   )                                &
-                      .OR.  ( ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.&
-                                force_bound_r )                                &
+                      .OR.  ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
                             .AND.  i == nxr   ) )                              &
                    THEN
@@ -520,9 +517,7 @@
                             )                                                  &
                                                     .OR.                       &
-                            ( ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.&
-                                force_bound_r )                                &
+                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
                               .AND. i == nxr-1 )    .OR.                       &
-                            ( ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.&
-                                force_bound_l )                                &
+                            ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
                               .AND. i == nxlu  ) )                             & ! why not nxl+1
                    THEN
@@ -542,9 +537,7 @@
                     .OR.  .NOT. BTEST(wall_flags_0(k,j+2,i),0)                 &   
                     .OR.  .NOT. BTEST(wall_flags_0(k,j-1,i),0))                &
-                      .OR.  ( ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.&
-                                force_bound_s )                                &
+                      .OR.  ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
                             .AND.  j == nys   )                                &
-                      .OR.  ( ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.&
-                                force_bound_n )                                &
+                      .OR.  ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
                             .AND.  j == nyn   ) )                              &
                    THEN
@@ -563,9 +556,7 @@
                             )                                                  &
                                                     .OR.                       &
-                            ( ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.&
-                                force_bound_s )                                &
+                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
                               .AND. j == nysv  )    .OR.                       & ! why not nys+1
-                            ( ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.&
-                                force_bound_n )                                &
+                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
                               .AND. j == nyn-1 ) )                             &          
                    THEN
@@ -655,9 +646,7 @@
 !--                WS1 (9), WS3 (10), WS5 (11)
                    IF ( .NOT. BTEST(wall_flags_0(k,j,i+1),1)  .OR.             &
-                            ( ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.&
-                                force_bound_l )                                &
+                            ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
                               .AND. i <= nxlu  )    .OR.                       &
-                            ( ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.&
-                                force_bound_r )                                &
+                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
                               .AND. i == nxr   ) )                             &
                    THEN
@@ -667,9 +656,7 @@
                               .NOT. BTEST(wall_flags_0(k,j,i-1),1) )           &
                                                         .OR.                   &
-                            ( ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.&
-                                force_bound_r )                                &
+                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
                               .AND. i == nxr-1 )    .OR.                       &
-                            ( ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.&
-                                force_bound_l )                                &
+                            ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
                               .AND. i == nxlu+1) )                             &
                    THEN
@@ -691,9 +678,7 @@
 !--                WS1 (12), WS3 (13), WS5 (14)
                    IF ( .NOT. BTEST(wall_flags_0(k,j+1,i),1)   .OR.            &
-                            ( ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.&
-                                force_bound_s )                                &
+                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
                               .AND. j == nys   )    .OR.                       &
-                            ( ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.&
-                                force_bound_n )                                &
+                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
                               .AND. j == nyn   ) )                             &
                    THEN
@@ -703,9 +688,7 @@
                               .NOT. BTEST(wall_flags_0(k,j-1,i),1) )           &
                                                         .OR.                   &
-                            ( ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.&
-                                force_bound_s )                                &
+                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
                               .AND. j == nysv  )    .OR.                       &
-                            ( ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.&
-                                force_bound_n )                                &
+                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
                               .AND. j == nyn-1 ) )                             &
                    THEN
@@ -789,9 +772,7 @@
 !--                WS1 (18), WS3 (19), WS5 (20)
                    IF ( .NOT. BTEST(wall_flags_0(k,j,i+1),2)  .OR.             &
-                            ( ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.&
-                                force_bound_l )                                &
+                            ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
                               .AND. i == nxl   )    .OR.                       &
-                            ( ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.&
-                                force_bound_r )                                &
+                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
                               .AND. i == nxr   ) )                             &
                   THEN
@@ -803,9 +784,7 @@
                               .NOT. BTEST(wall_flags_0(k,j,i-1),2)             &
                                                     .OR.                       &
-                            ( ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.&
-                                force_bound_r )                                &
+                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
                               .AND. i == nxr-1 )    .OR.                       &
-                            ( ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.&
-                                force_bound_l )                                &
+                            ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
                               .AND. i == nxlu  ) )                             &
                    THEN
@@ -827,9 +806,7 @@
 !--                WS1 (21), WS3 (22), WS5 (23)
                    IF ( .NOT. BTEST(wall_flags_0(k,j+1,i),2) .OR.              &
-                            ( ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.&
-                                force_bound_s )                                &
+                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
                               .AND. j <= nysv  )    .OR.                       &
-                            ( ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.&
-                                force_bound_n )                                &
+                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
                               .AND. j == nyn   ) )                             &
                    THEN
@@ -839,9 +816,7 @@
                               .NOT. BTEST(wall_flags_0(k,j-1,i),2) )           &
                                                         .OR.                   &
-                            ( ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.&
-                                force_bound_s )                                &
+                            ( (  bc_dirichlet_s .OR. bc_radiation_s )          &
                               .AND. j == nysv+1)    .OR.                       &
-                            ( ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.&
-                                force_bound_n )                                &
+                            ( (  bc_dirichlet_n .OR. bc_radiation_n )          &
                               .AND. j == nyn-1 ) )                             &
                    THEN
@@ -924,9 +899,7 @@
 !--                WS1 (27), WS3 (28), WS5 (29)
                    IF ( .NOT. BTEST(wall_flags_0(k,j,i+1),3) .OR.              &
-                            ( ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.&
-                                force_bound_l )                                &
+                            ( (  bc_dirichlet_l .OR. bc_radiation_l )          &
                               .AND. i == nxl   )    .OR.                       &
-                            ( ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.&
-                                force_bound_r )                                &
+                            ( (  bc_dirichlet_r .OR. bc_radiation_r )          &
                               .AND. i == nxr   ) )                             &
                    THEN
@@ -936,9 +909,7 @@
                               .NOT. BTEST(wall_flags_0(k,j,i-1),3) )           &
                                                         .OR.                   &
-                            ( ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.&
-                                force_bound_r )                                &
+                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
                               .AND. i == nxr-1 )    .OR.                       &
-                            ( ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.&
-                                force_bound_l )                                &
+                            ( ( bc_dirichlet_l .OR.  bc_radiation_l )          &
                               .AND. i == nxlu  ) )                             &
                    THEN
@@ -960,9 +931,7 @@
 !--                WS1 (30), WS3 (31), WS5 (32)
                    IF ( .NOT. BTEST(wall_flags_0(k,j+1,i),3) .OR.              &
-                            ( ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.&
-                                force_bound_s )                                &
+                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
                               .AND. j == nys   )    .OR.                       &
-                            ( ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.&
-                                force_bound_n )                                &
+                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
                               .AND. j == nyn   ) )                             &
                    THEN
@@ -972,9 +941,7 @@
                               .NOT. BTEST(wall_flags_0(k,j-1,i),3) )           &
                                                         .OR.                   &
-                            ( ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.&
-                                force_bound_s )                                &
+                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
                               .AND. j == nysv  )    .OR.                       &
-                            ( ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.&
-                                force_bound_n )                                &
+                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
                               .AND. j == nyn-1 ) )                             &
                    THEN
@@ -1067,24 +1034,20 @@
 !--       Set boundary flags at inflow and outflow boundary in case of 
 !--       non-cyclic boundary conditions.
-          IF ( inflow_l      .OR.  outflow_l  .OR.                             &
-               nest_bound_l  .OR.  force_bound_l )  THEN
+          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
              advc_flags_1(:,:,nxl-1) = advc_flags_1(:,:,nxl)
              advc_flags_2(:,:,nxl-1) = advc_flags_2(:,:,nxl)
           ENDIF
 
-          IF ( inflow_r      .OR.  outflow_r  .OR.                             &
-               nest_bound_r  .OR.  force_bound_r )  THEN
+          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
             advc_flags_1(:,:,nxr+1) = advc_flags_1(:,:,nxr)
             advc_flags_2(:,:,nxr+1) = advc_flags_2(:,:,nxr)
           ENDIF
 
-          IF ( inflow_n      .OR.  outflow_n  .OR.                             &
-               nest_bound_n  .OR.  force_bound_n )  THEN
+          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
              advc_flags_1(:,nyn+1,:) = advc_flags_1(:,nyn,:)
              advc_flags_2(:,nyn+1,:) = advc_flags_2(:,nyn,:)
           ENDIF
 
-          IF ( inflow_s      .OR.  outflow_s  .OR.                             &
-               nest_bound_s  .OR.  force_bound_s )  THEN
+          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
              advc_flags_1(:,nys-1,:) = advc_flags_1(:,nys,:)
              advc_flags_2(:,nys-1,:) = advc_flags_2(:,nys,:)
Index: palm/trunk/SOURCE/boundary_conds.f90
===================================================================
--- palm/trunk/SOURCE/boundary_conds.f90	(revision 3178)
+++ palm/trunk/SOURCE/boundary_conds.f90	(revision 3182)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Rename some variables concerning LES-LES as well as offline nesting
 ! 
 ! Former revisions:
@@ -186,5 +186,6 @@
     USE arrays_3d,                                                             &
         ONLY:  c_u, c_u_m, c_u_m_l, c_v, c_v_m, c_v_m_l, c_w, c_w_m, c_w_m_l,  &
-               diss, diss_p, dzu, e_p, nc_p, nr_p, pt, pt_p, q, q_p, qc_p, qr_p, s,  & 
+               diss, diss_p, dzu, e_p, nc_p, nr_p, pt, pt_p, q, q_p, qc_p,     &
+               qr_p, s,                                                        & 
                s_p, sa, sa_p, u, ug, u_init, u_m_l, u_m_n, u_m_r, u_m_s, u_p,  &
                v, vg, v_init, v_m_l, v_m_n, v_m_r, v_m_s, v_p,                 &
@@ -195,14 +196,14 @@
               
     USE control_parameters,                                                    &
-        ONLY:  air_chemistry, bc_pt_t_val, bc_q_t_val, bc_s_t_val,             &
-               constant_diffusion, cloud_physics, coupling_mode, dt_3d,        &
-               force_bound_l, force_bound_s, forcing, humidity,                &
-               ibc_pt_b, ibc_pt_t, ibc_q_b, ibc_q_t, ibc_s_b, ibc_s_t,         &
-               ibc_sa_t, ibc_uv_b, ibc_uv_t, inflow_l, inflow_n, inflow_r,     &
-               inflow_s, intermediate_timestep_count, kappa,                   &
-               microphysics_morrison, microphysics_seifert, nest_domain,       &
-               nest_bound_l, nest_bound_n, nest_bound_r, nest_bound_s, nudging,&
-               ocean, outflow_l, outflow_n, outflow_r, outflow_s,              &
-               passive_scalar, rans_mode, rans_tke_e, tsc, use_cmax
+        ONLY:  air_chemistry, bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,  &
+               bc_dirichlet_s, bc_radiation_l, bc_radiation_n, bc_radiation_r, &
+               bc_radiation_s, bc_pt_t_val, bc_q_t_val, bc_s_t_val,            &
+               child_domain, constant_diffusion, cloud_physics, coupling_mode, &
+               dt_3d, humidity, ibc_pt_b, ibc_pt_t, ibc_q_b, ibc_q_t, ibc_s_b, &
+               ibc_s_t,ibc_sa_t, ibc_uv_b, ibc_uv_t,                           &
+               intermediate_timestep_count, kappa,                             &
+               microphysics_morrison, microphysics_seifert,                    &
+               nesting_offline, nudging,                                       &
+               ocean, passive_scalar, rans_mode, rans_tke_e, tsc, use_cmax
 
     USE grid_variables,                                                        &
@@ -275,5 +276,5 @@
 !
 !-- Vertical nesting: Vertical velocity not zero at the top of the fine grid
-    IF (  .NOT.  nest_domain  .AND.                                            &
+    IF (  .NOT.  child_domain  .AND.                                           &
                  TRIM(coupling_mode) /= 'vnested_fine' )  THEN
        w_p(nzt:nzt+1,:,:) = 0.0_wp  !< nzt is not a prognostic level (but cf. pres)
@@ -409,5 +410,5 @@
        ENDIF
 
-       IF ( .NOT. nest_domain )  THEN
+       IF ( .NOT. child_domain )  THEN
           e_p(nzt+1,:,:) = e_p(nzt,:,:)
 !
@@ -421,11 +422,9 @@
           IF ( rans_mode_parent  .AND.  .NOT. rans_mode )  THEN
 
-
-
              e_p(nzt+1,:,:) = e_p(nzt,:,:)
-             IF ( nest_bound_l )  e_p(:,:,nxl-1) = e_p(:,:,nxl)
-             IF ( nest_bound_r )  e_p(:,:,nxr+1) = e_p(:,:,nxr)
-             IF ( nest_bound_s )  e_p(:,nys-1,:) = e_p(:,nys,:)
-             IF ( nest_bound_n )  e_p(:,nyn+1,:) = e_p(:,nyn,:)
+             IF ( bc_dirichlet_l )  e_p(:,:,nxl-1) = e_p(:,:,nxl)
+             IF ( bc_dirichlet_r )  e_p(:,:,nxr+1) = e_p(:,:,nxr)
+             IF ( bc_dirichlet_s )  e_p(:,nys-1,:) = e_p(:,nys,:)
+             IF ( bc_dirichlet_n )  e_p(:,nyn+1,:) = e_p(:,nyn,:)
 
           ENDIF
@@ -510,5 +509,5 @@
        ENDDO
 
-       IF ( .NOT. nest_domain )  THEN
+       IF ( .NOT. child_domain )  THEN
           diss_p(nzt+1,:,:) = diss_p(nzt,:,:)
        ENDIF
@@ -697,13 +696,13 @@
 !-- have to be restored here.
 !-- For the SGS-TKE, Neumann boundary conditions are used at the inflow.
-    IF ( inflow_s )  THEN
+    IF ( bc_dirichlet_s )  THEN
        v_p(:,nys,:) = v_p(:,nys-1,:)
        IF ( .NOT. constant_diffusion ) e_p(:,nys-1,:) = e_p(:,nys,:)
-    ELSEIF ( inflow_n )  THEN
+    ELSEIF ( bc_dirichlet_n )  THEN
        IF ( .NOT. constant_diffusion ) e_p(:,nyn+1,:) = e_p(:,nyn,:)
-    ELSEIF ( inflow_l ) THEN
+    ELSEIF ( bc_dirichlet_l ) THEN
        u_p(:,:,nxl) = u_p(:,:,nxl-1)
        IF ( .NOT. constant_diffusion ) e_p(:,:,nxl-1) = e_p(:,:,nxl)
-    ELSEIF ( inflow_r )  THEN
+    ELSEIF ( bc_dirichlet_r )  THEN
        IF ( .NOT. constant_diffusion ) e_p(:,:,nxr+1) = e_p(:,:,nxr)
     ENDIF
@@ -712,10 +711,12 @@
 !-- The same restoration for u at i=nxl and v at j=nys as above must be made
 !-- in case of nest boundaries. This must not be done in case of vertical nesting 
-!-- mode as in that case the lateral boundaries are actually cyclic.
-    IF ( nesting_mode /= 'vertical'  .OR.  forcing )  THEN
-       IF ( nest_bound_s  .OR.  force_bound_s )  THEN
+!-- mode as in that case the lateral boundaries are actually cyclic. 
+!-- @todo: Is this really needed? Boundary values will be overwritten in 
+!--        coupler or by Inifor data.
+    IF ( nesting_mode /= 'vertical'  .OR.  nesting_offline )  THEN
+       IF ( bc_dirichlet_s )  THEN
           v_p(:,nys,:) = v_p(:,nys-1,:)
        ENDIF
-       IF ( nest_bound_l  .OR.  force_bound_l )  THEN
+       IF ( bc_dirichlet_l )  THEN
           u_p(:,:,nxl) = u_p(:,:,nxl-1)
        ENDIF
@@ -724,5 +725,5 @@
 !
 !-- Lateral boundary conditions for scalar quantities at the outflow
-    IF ( outflow_s )  THEN
+    IF ( bc_radiation_s )  THEN
        pt_p(:,nys-1,:)     = pt_p(:,nys,:)
        IF ( .NOT. constant_diffusion )  e_p(:,nys-1,:) = e_p(:,nys,:)
@@ -740,5 +741,5 @@
        ENDIF
        IF ( passive_scalar )  s_p(:,nys-1,:) = s_p(:,nys,:)
-    ELSEIF ( outflow_n )  THEN
+    ELSEIF ( bc_radiation_n )  THEN
        pt_p(:,nyn+1,:)     = pt_p(:,nyn,:)
        IF ( .NOT. constant_diffusion )  e_p(:,nyn+1,:) = e_p(:,nyn,:)
@@ -756,5 +757,5 @@
        ENDIF
        IF ( passive_scalar )  s_p(:,nyn+1,:) = s_p(:,nyn,:)
-    ELSEIF ( outflow_l )  THEN
+    ELSEIF ( bc_radiation_l )  THEN
        pt_p(:,:,nxl-1)     = pt_p(:,:,nxl)
        IF ( .NOT. constant_diffusion )  e_p(:,:,nxl-1) = e_p(:,:,nxl)
@@ -772,5 +773,5 @@
        ENDIF
        IF ( passive_scalar )  s_p(:,:,nxl-1) = s_p(:,:,nxl)
-    ELSEIF ( outflow_r )  THEN
+    ELSEIF ( bc_radiation_r )  THEN
        pt_p(:,:,nxr+1)     = pt_p(:,:,nxr)
        IF ( .NOT. constant_diffusion )  e_p(:,:,nxr+1) = e_p(:,:,nxr)
@@ -799,5 +800,5 @@
 !-- ensures numerical stability (CFL-condition) or calculated after
 !-- Orlanski(1976) and averaged along the outflow boundary.
-    IF ( outflow_s )  THEN
+    IF ( bc_radiation_s )  THEN
 
        IF ( use_cmax )  THEN
@@ -938,5 +939,5 @@
     ENDIF
 
-    IF ( outflow_n )  THEN
+    IF ( bc_radiation_n )  THEN
 
        IF ( use_cmax )  THEN
@@ -1077,5 +1078,5 @@
     ENDIF
 
-    IF ( outflow_l )  THEN
+    IF ( bc_radiation_l )  THEN
 
        IF ( use_cmax )  THEN
@@ -1216,5 +1217,5 @@
     ENDIF
 
-    IF ( outflow_r )  THEN
+    IF ( bc_radiation_r )  THEN
 
        IF ( use_cmax )  THEN
Index: palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- palm/trunk/SOURCE/check_parameters.f90	(revision 3178)
+++ palm/trunk/SOURCE/check_parameters.f90	(revision 3182)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Rename boundary conditions in offline nesting
 ! 
 ! Former revisions:
@@ -1069,4 +1069,5 @@
 !-- Check turbulence closure setup
     CALL tcm_check_parameters
+
 !
 !-- Check approximation
@@ -1437,4 +1438,5 @@
        CALL MPI_ALLREDUCE( dt_spinup,   dt_spinup_max,   1, MPI_REAL,          &
                            MPI_MAX, MPI_COMM_WORLD, ierr )
+
        IF ( spinup_time /= spinup_time_max  .OR.  dt_spinup /= dt_spinup_max ) &
        THEN
@@ -1781,5 +1783,5 @@
 !
 !-- Overwrite latitude if necessary and compute Coriolis parameter. 
-!-- To do - move initialization of f and fs to coriolis_mod.
+!-- @todo - move initialization of f and fs to coriolis_mod.
     IF ( input_pids_static )  THEN
        latitude  = init_model%latitude
@@ -1976,5 +1978,5 @@
 !-- TO_DO: later set bc_p_t to neumann before, in case of nested domain
     ELSEIF ( bc_p_t == 'neumann' .OR. bc_p_t == 'nested'  .OR.                 &
-             bc_p_t == 'forcing'  )  THEN
+             bc_p_t == 'nesting_offline'  )  THEN
        ibc_p_t = 1
     ELSE
@@ -2006,5 +2008,5 @@
     ELSEIF ( bc_pt_t == 'initial_gradient' )  THEN
        ibc_pt_t = 2
-    ELSEIF ( bc_pt_t == 'nested'  .OR.  bc_pt_t == 'forcing' )  THEN
+    ELSEIF ( bc_pt_t == 'nested'  .OR.  bc_pt_t == 'nesting_offline' )  THEN
        ibc_pt_t = 3
     ELSE
@@ -2234,5 +2236,5 @@
        ELSEIF ( bc_uv_t == 'neumann' )  THEN
           ibc_uv_t = 1
-       ELSEIF ( bc_uv_t == 'nested'  .OR.  bc_uv_t == 'forcing' )  THEN
+       ELSEIF ( bc_uv_t == 'nested'  .OR.  bc_uv_t == 'nesting_offline' )  THEN
           ibc_uv_t = 3
        ELSE
@@ -3926,5 +3928,5 @@
           dist_nxl    = MAX( inflow_disturbance_begin, nxl )
           dist_nxr(1) = MIN( inflow_disturbance_end, nxr )
-       ELSEIF ( bc_lr == 'nested'  .OR.  bc_lr == 'forcing' )  THEN
+       ELSEIF ( bc_lr == 'nested'  .OR.  bc_lr == 'nesting_offline' )  THEN
           dist_nxl    = MAX( inflow_disturbance_begin, nxl )
           dist_nxr    = MIN( nx - inflow_disturbance_begin, nxr )
@@ -3936,5 +3938,5 @@
           dist_nys    = MAX( inflow_disturbance_begin, nys )
           dist_nyn(1) = MIN( inflow_disturbance_end, nyn )
-       ELSEIF ( bc_ns == 'nested'  .OR.  bc_ns == 'forcing' )  THEN
+       ELSEIF ( bc_ns == 'nested'  .OR.  bc_ns == 'nesting_offline' )  THEN
           dist_nys    = MAX( inflow_disturbance_begin, nys )
           dist_nyn    = MIN( ny - inflow_disturbance_begin, nyn )
@@ -3949,5 +3951,5 @@
           dist_nxl    = inflow_disturbance_begin
           dist_nxr(1) = inflow_disturbance_end
-       ELSEIF ( bc_lr == 'nested'  .OR.  bc_lr == 'forcing' )  THEN
+       ELSEIF ( bc_lr == 'nested'  .OR.  bc_lr == 'nesting_offline' )  THEN
           dist_nxr    = nx - inflow_disturbance_begin
           dist_nxl    = inflow_disturbance_begin
@@ -3959,5 +3961,5 @@
           dist_nys    = inflow_disturbance_begin
           dist_nyn(1) = inflow_disturbance_end
-       ELSEIF ( bc_ns == 'nested'  .OR.  bc_ns == 'forcing' )  THEN
+       ELSEIF ( bc_ns == 'nested'  .OR.  bc_ns == 'nesting_offline' )  THEN
           dist_nyn    = ny - inflow_disturbance_begin
           dist_nys    = inflow_disturbance_begin
@@ -4403,5 +4405,5 @@
        ELSEIF ( bc_t == 'initial_gradient' )  THEN
           ibc_t = 2
-       ELSEIF ( bc_t == 'nested'  .OR.  bc_t == 'forcing' )  THEN
+       ELSEIF ( bc_t == 'nested'  .OR.  bc_t == 'nesting_offline' )  THEN
           ibc_t = 3
        ELSE
Index: palm/trunk/SOURCE/chemistry_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 3178)
+++ palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 3182)
@@ -22,5 +22,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Rename flags indicating outflow boundary conditions
 ! 
 ! Former revisions:
@@ -291,14 +291,15 @@
                                                                                   
     USE control_parameters,                                                    &  
-        ONLY: air_chemistry, outflow_l, outflow_n, outflow_r, outflow_s                 
+        ONLY:  air_chemistry, bc_radiation_l, bc_radiation_n, bc_radiation_r,  &
+               bc_radiation_s                
     USE indices,                                                               &  
-        ONLY: nxl, nxr,  nxlg, nxrg, nyng, nysg, nzt                              
+        ONLY:  nxl, nxr,  nxlg, nxrg, nyng, nysg, nzt                              
                                                                                   
 !    USE prognostic_equations_mod,                                             &
 
     USE arrays_3d,                                                             &     
-        ONLY: dzu                                                
+        ONLY:  dzu                                                
     USE surface_mod,                                                           &
-        ONLY: bc_h                                                           
+        ONLY:  bc_h                                                           
 
     CHARACTER (len=*), INTENT(IN) :: mode
@@ -420,17 +421,17 @@
 !--          Lateral boundary conditions for chem species at outflow boundary 
 
-          IF ( outflow_s )  THEN
+          IF ( bc_radiation_s )  THEN
              DO lsp = 1, nspec
                 chem_species(lsp)%conc_p(:,nys-1,:) = chem_species(lsp)%conc_p(:,nys,:)
              ENDDO
-          ELSEIF ( outflow_n )  THEN
+          ELSEIF ( bc_radiation_n )  THEN
              DO lsp = 1, nspec
                 chem_species(lsp)%conc_p(:,nyn+1,:) = chem_species(lsp)%conc_p(:,nyn,:)
              ENDDO
-          ELSEIF ( outflow_l )  THEN
+          ELSEIF ( bc_radiation_l )  THEN
              DO lsp = 1, nspec
                 chem_species(lsp)%conc_p(:,:,nxl-1) = chem_species(lsp)%conc_p(:,:,nxl)
              ENDDO
-          ELSEIF ( outflow_r )  THEN
+          ELSEIF ( bc_radiation_r )  THEN
              DO lsp = 1, nspec
                 chem_species(lsp)%conc_p(:,:,nxr+1) = chem_species(lsp)%conc_p(:,:,nxr)
Index: palm/trunk/SOURCE/coriolis.f90
===================================================================
--- palm/trunk/SOURCE/coriolis.f90	(revision 3178)
+++ palm/trunk/SOURCE/coriolis.f90	(revision 3182)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Remove masking of geostrophic wind forcing in offline nesting case
 ! 
 ! Former revisions:
@@ -109,5 +109,5 @@
            
        USE control_parameters,                                                 &
-           ONLY:  f, forcing, fs, message_string
+           ONLY:  f, fs, message_string, nesting_offline
            
        USE indices,                                                            &
@@ -123,8 +123,6 @@
        INTEGER(iwp) ::  k          !< running index z direction 
 
-       REAL(wp)     ::  flag       !< flag to mask topography
-       REAL(wp)     ::  flag_force !< flag to mask large-scale pressure gradient in case larger-scale forcing is applied
-
-       flag_force = MERGE( 0.0_wp, 1.0_wp, forcing )
+       REAL(wp)     ::  flag           !< flag to mask topography
+
 !
 !--    Compute Coriolis terms for the three velocity components
@@ -144,6 +142,5 @@
                       tend(k,j,i) = tend(k,j,i) + f  *    ( 0.25_wp *          &
                                    ( v(k,j,i-1) + v(k,j,i) + v(k,j+1,i-1) +    &
-                                     v(k,j+1,i) ) - vg(k) * flag_force         &
-                                                          ) * flag           &
+                                     v(k,j+1,i) ) - vg(k) ) * flag             &
                                                 - fs *    ( 0.25_wp *          &
                                    ( w(k-1,j,i-1) + w(k-1,j,i) + w(k,j,i-1) +  &
@@ -167,6 +164,5 @@
                       tend(k,j,i) = tend(k,j,i) - f *     ( 0.25_wp *          &
                                    ( u(k,j-1,i) + u(k,j,i) + u(k,j-1,i+1) +    &
-                                     u(k,j,i+1) ) - ug(k) * flag_force         &
-                                                          ) * flag
+                                     u(k,j,i+1) ) - ug(k) ) * flag
                    ENDDO
                 ENDDO
@@ -212,5 +208,5 @@
            
        USE control_parameters,                                                 &
-           ONLY:  f, forcing, fs, message_string
+           ONLY:  f, fs, message_string, nesting_offline
            
        USE indices,                                                            &
@@ -227,7 +223,5 @@
 
        REAL(wp)     ::  flag       !< flag to mask topography
-       REAL(wp)     ::  flag_force !< flag to mask large-scale pressure gradient in case larger-scale forcing is applied
-
-       flag_force = MERGE( 0.0_wp, 1.0_wp, forcing )
+
 !
 !--    Compute Coriolis terms for the three velocity components
@@ -244,5 +238,5 @@
                 tend(k,j,i) = tend(k,j,i) + f  *     ( 0.25_wp *               &
                                 ( v(k,j,i-1) + v(k,j,i) + v(k,j+1,i-1) +       &
-                                  v(k,j+1,i) ) - vg(k) * flag_force            &
+                                  v(k,j+1,i) ) - vg(k)                         &
                                                      ) * flag                  &
                                           - fs *     ( 0.25_wp *               &
@@ -261,6 +255,5 @@
                 tend(k,j,i) = tend(k,j,i) - f *        ( 0.25_wp *             &
                                 ( u(k,j-1,i) + u(k,j,i) + u(k,j-1,i+1) +       &
-                                  u(k,j,i+1) ) - ug(k)   * flag_force          &
-                                                       ) * flag
+                                  u(k,j,i+1) ) - ug(k) ) * flag
              ENDDO
 
Index: palm/trunk/SOURCE/exchange_horiz_2d.f90
===================================================================
--- palm/trunk/SOURCE/exchange_horiz_2d.f90	(revision 3178)
+++ palm/trunk/SOURCE/exchange_horiz_2d.f90	(revision 3182)
@@ -20,5 +20,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! Rename variables in offline nesting mode and flags indicating lateral
+! boundary conditions
 ! 
 ! Former revisions:
@@ -84,9 +85,7 @@
 
     USE control_parameters,                                                    &
-        ONLY :  bc_lr_cyc, bc_ns_cyc, force_bound_l, force_bound_n,            &
-                force_bound_r, force_bound_s,                                  &
-                inflow_l, inflow_n, inflow_r, inflow_s,                        &
-                nest_bound_l, nest_bound_n, nest_bound_r, nest_bound_s,        &
-                outflow_l, outflow_n, outflow_r, outflow_s
+        ONLY :  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,                &
+                bc_dirichlet_s, bc_lr_cyc, bc_ns_cyc, bc_radiation_l,          &
+                bc_radiation_n, bc_radiation_r, bc_radiation_s 
                 
     USE cpulog,                                                                &
@@ -184,24 +183,20 @@
 !-- Neumann-conditions at inflow/outflow/nested boundaries
     IF ( nesting_mode /= 'vertical' )  THEN
-       IF ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.  force_bound_l )   &
-       THEN
+       IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
           DO  i = nbgp, 1, -1
              ar(:,nxl-i) = ar(:,nxl)
           ENDDO
        ENDIF
-       IF ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.  force_bound_r )   &
-       THEN
+       IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
           DO  i = 1, nbgp
              ar(:,nxr+i) = ar(:,nxr)
           ENDDO
        ENDIF
-       IF ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.  force_bound_s )   &
-       THEN
+       IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
           DO  i = nbgp, 1, -1
              ar(nys-i,:) = ar(nys,:)
           ENDDO
        ENDIF
-       IF ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.  force_bound_n )   &
-       THEN
+       IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
           DO  i = 1, nbgp
              ar(nyn+i,:) = ar(nyn,:)
@@ -227,7 +222,7 @@
 
     USE control_parameters,                                                    &
-        ONLY:  bc_lr_cyc, bc_ns_cyc, grid_level, force_bound_l, force_bound_n, &
-               force_bound_r, force_bound_s, nest_bound_l, nest_bound_n,       &
-               nest_bound_r, nest_bound_s
+        ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,                 &
+               bc_dirichlet_s, bc_lr_cyc, bc_ns_cyc, bc_radiation_l,           &
+               bc_radiation_n, bc_radiation_r, bc_radiation_s, grid_level
         
     USE cpulog,                                                                &
@@ -326,20 +321,20 @@
 !
 !-- Neumann-conditions at inflow/outflow/nested boundaries
-    IF ( nest_bound_l  .OR.  force_bound_l )  THEN
+    IF ( bc_dirichlet_l )  THEN
        DO  i = nbgp_local, 1, -1
          ar(:,nxl_l-i) = ar(:,nxl_l)
        ENDDO
     ENDIF
-    IF ( nest_bound_r  .OR.  force_bound_r )  THEN
+    IF ( bc_dirichlet_r )  THEN
        DO  i = 1, nbgp_local
           ar(:,nxr_l+i) = ar(:,nxr_l)
        ENDDO
     ENDIF
-    IF ( nest_bound_s  .OR.  force_bound_s )  THEN
+    IF ( bc_dirichlet_s )  THEN
        DO  i = nbgp_local, 1, -1
          ar(nys_l-i,:) = ar(nys_l,:)
        ENDDO
     ENDIF
-    IF ( nest_bound_n  .OR.  force_bound_n )  THEN
+    IF ( bc_dirichlet_n )  THEN
        DO  i = 1, nbgp_local
          ar(nyn_l+i,:) = ar(nyn_l,:)
Index: palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- palm/trunk/SOURCE/init_3d_model.f90	(revision 3178)
+++ palm/trunk/SOURCE/init_3d_model.f90	(revision 3182)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! ------------------
-! 
+! Revise Inifor initialization
 ! 
 ! Former revisions:
@@ -535,5 +535,5 @@
 
     USE netcdf_data_input_mod,                                                 &
-        ONLY:  init_3d, netcdf_data_input_interpolate, netcdf_data_input_init_3d
+        ONLY:  init_3d, netcdf_data_input_init_3d
     
     USE particle_attributes,                                                   &
@@ -611,4 +611,5 @@
     REAL(wp)     ::  t_surface !< air temperature at the surface
 
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  init_l        !< dummy array used for averaging 3D data to obtain inital profiles 
     REAL(wp), DIMENSION(:), ALLOCATABLE ::  p_hydrostatic !< hydrostatic pressure
 
@@ -1006,33 +1007,34 @@
 !-- Arrays to store velocity data from t-dt and the phase speeds which
 !-- are needed for radiation boundary conditions
-    IF ( outflow_l )  THEN
+    IF ( bc_radiation_l )  THEN
        ALLOCATE( u_m_l(nzb:nzt+1,nysg:nyng,1:2),                               &
                  v_m_l(nzb:nzt+1,nysg:nyng,0:1),                               &
                  w_m_l(nzb:nzt+1,nysg:nyng,0:1) )
     ENDIF
-    IF ( outflow_r )  THEN
+    IF ( bc_radiation_r )  THEN
        ALLOCATE( u_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx),                           &
                  v_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx),                           &
                  w_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx) )
     ENDIF
-    IF ( outflow_l  .OR.  outflow_r )  THEN
+    IF ( bc_radiation_l  .OR.  bc_radiation_r )  THEN
        ALLOCATE( c_u(nzb:nzt+1,nysg:nyng), c_v(nzb:nzt+1,nysg:nyng),           &
                  c_w(nzb:nzt+1,nysg:nyng) )
     ENDIF
-    IF ( outflow_s )  THEN
+    IF ( bc_radiation_s )  THEN
        ALLOCATE( u_m_s(nzb:nzt+1,0:1,nxlg:nxrg),                               &
                  v_m_s(nzb:nzt+1,1:2,nxlg:nxrg),                               &
                  w_m_s(nzb:nzt+1,0:1,nxlg:nxrg) )
     ENDIF
-    IF ( outflow_n )  THEN
+    IF ( bc_radiation_n )  THEN
        ALLOCATE( u_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg),                           &
                  v_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg),                           &
                  w_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg) )
     ENDIF
-    IF ( outflow_s  .OR.  outflow_n )  THEN
+    IF ( bc_radiation_s  .OR.  bc_radiation_n )  THEN
        ALLOCATE( c_u(nzb:nzt+1,nxlg:nxrg), c_v(nzb:nzt+1,nxlg:nxrg),           &
                  c_w(nzb:nzt+1,nxlg:nxrg) )
     ENDIF
-    IF ( outflow_l  .OR.  outflow_r  .OR.  outflow_s  .OR.  outflow_n )  THEN
+    IF ( bc_radiation_l  .OR.  bc_radiation_r  .OR.  bc_radiation_s  .OR.      &
+         bc_radiation_n )  THEN
        ALLOCATE( c_u_m_l(nzb:nzt+1), c_v_m_l(nzb:nzt+1), c_w_m_l(nzb:nzt+1) )                   
        ALLOCATE( c_u_m(nzb:nzt+1), c_v_m(nzb:nzt+1), c_w_m(nzb:nzt+1) )
@@ -1152,7 +1154,5 @@
     sums_l_l           = 0.0_wp
     sums_wsts_bc_l     = 0.0_wp
-
-
-
+    
 !
 !-- Initialize model variables
@@ -1169,53 +1169,91 @@
           CALL netcdf_data_input_init_3d
 !
-!--       Please note, at the moment INIFOR assumes only an equidistant vertical
-!--       grid. In case of vertical grid stretching, input of inital data 
-!--       need to be inter- and/or extrapolated. 
-!--       Therefore, check if zu grid on file is identical to numeric zw grid. 
-!--       Please note  
-          IF ( ANY( zu(1:nzt+1) /= init_3d%zu_atmos(1:init_3d%nzu) ) )  THEN
-
-             IF( init_3d%lod_u == 1 )                                          &
-                CALL netcdf_data_input_interpolate(                            &
-                                                 init_3d%u_init(nzb+1:nzt+1),  &
-                                                 zu(nzb+1:nzt+1),              &
-                                                 init_3d%zu_atmos )
-                                                 
-             IF( init_3d%lod_v == 1 )                                          &
-                CALL netcdf_data_input_interpolate(                            &
-                                                 init_3d%v_init(nzb+1:nzt+1),  &
-                                                 zu(nzb+1:nzt+1),              &
-                                                 init_3d%zu_atmos )
-                                                 
-!              CALL netcdf_data_input_interpolate( init_3d%w_init(nzb+1:nzt),    &
-!                                                  zw(nzb+1:nzt),                &
-!                                                  init_3d%zw_atmos )
-
-             IF ( .NOT. neutral  .AND.  init_3d%lod_pt == 1 )                  &
-                CALL netcdf_data_input_interpolate(                            &
-                                             init_3d%pt_init(nzb+1:nzt+1),     &
-                                             zu(nzb+1:nzt+1),                  &
-                                             init_3d%zu_atmos )
-                                             
-             IF ( humidity  .AND.  init_3d%lod_q == 1 )                        &
-                CALL netcdf_data_input_interpolate(                            &
-                                             init_3d%q_init(nzb+1:nzt+1),      &
-                                             zu(nzb+1:nzt+1),                  &
-                                             init_3d%zu_atmos )
-          ENDIF
-!
-!--       In case of LOD=1, initialize 1D profiles and 3D data.  
-          IF( init_3d%lod_u == 1 )  u_init = init_3d%u_init
-          IF( init_3d%lod_v == 1 )  v_init = init_3d%v_init    
-          IF( .NOT. neutral  .AND.  init_3d%lod_pt == 1 )                      &
-             pt_init = init_3d%pt_init
-          IF( humidity  .AND.  init_3d%lod_q == 1 )                            &
-             q_init  = init_3d%q_init
-
-!
-!--       Please note, Inifor provides data from nzb+1 to nzt+1. 
-!--       Initialize pt and q with Neumann condition at nzb.
-          IF( .NOT. neutral )  pt_init(nzb) = pt_init(nzb+1)
-          IF( humidity      )  q_init(nzb)  = q_init(nzb+1)
+!--       Please note, Inifor provides data from nzb+1 to nzt. 
+!--       Bottom and top boundary conditions for Inifor profiles are already 
+!--       set (just after reading), so that this is not necessary here.
+!--       Depending on the provided level-of-detail, initial Inifor data is
+!--       either stored on data type (lod=1), or directly on 3D arrays (lod=2). 
+!--       In order to obtain also initial profiles in case of lod=2 (which 
+!--       is required for e.g. damping), average over 3D data.
+          IF( init_3d%lod_u == 1 )  THEN
+             u_init = init_3d%u_init
+          ELSEIF( init_3d%lod_u == 2 )  THEN 
+             ALLOCATE( init_l(nzb:nzt+1) ) 
+             DO  k = nzb, nzt+1
+                init_l(k) = SUM( u(k,nys:nyn,nxl:nxr) )
+             ENDDO
+             init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp )
+
+#if defined( __parallel )
+             CALL MPI_ALLREDUCE( init_l, u_init, nzt+1-nzb+1,                  &
+                                 MPI_REAL, MPI_SUM, comm2d, ierr )
+#else
+             u_init = init_l
+#endif
+             DEALLOCATE( init_l )
+
+          ENDIF
+           
+          IF( init_3d%lod_v == 1 )  THEN  
+             v_init = init_3d%v_init
+          ELSEIF( init_3d%lod_v == 2 )  THEN 
+             ALLOCATE( init_l(nzb:nzt+1) ) 
+             DO  k = nzb, nzt+1
+                init_l(k) = SUM( v(k,nys:nyn,nxl:nxr) )
+             ENDDO
+             init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp )
+
+#if defined( __parallel )
+             CALL MPI_ALLREDUCE( init_l, v_init, nzt+1-nzb+1,                  &
+                                 MPI_REAL, MPI_SUM, comm2d, ierr )
+#else
+             v_init = init_l
+#endif
+             DEALLOCATE( init_l )
+          ENDIF
+          IF( .NOT. neutral )  THEN
+             IF( init_3d%lod_pt == 1 )  THEN
+                pt_init = init_3d%pt_init
+             ELSEIF( init_3d%lod_pt == 2 )  THEN 
+                ALLOCATE( init_l(nzb:nzt+1) ) 
+                DO  k = nzb, nzt+1
+                   init_l(k) = SUM( pt(k,nys:nyn,nxl:nxr) )
+                ENDDO
+                init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp )
+
+#if defined( __parallel )
+                CALL MPI_ALLREDUCE( init_l, pt_init, nzt+1-nzb+1,               &
+                                    MPI_REAL, MPI_SUM, comm2d, ierr )
+#else
+                pt_init = init_l
+#endif
+                DEALLOCATE( init_l )
+             ENDIF
+          ENDIF
+
+
+          IF( humidity )  THEN
+             IF( init_3d%lod_q == 1 )  THEN
+                q_init = init_3d%q_init
+             ELSEIF( init_3d%lod_q == 2 )  THEN 
+                ALLOCATE( init_l(nzb:nzt+1) ) 
+                DO  k = nzb, nzt+1
+                   init_l(k) = SUM( q(k,nys:nyn,nxl:nxr) )
+                ENDDO
+                init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp )
+
+#if defined( __parallel )
+                CALL MPI_ALLREDUCE( init_l, q_init, nzt+1-nzb+1,               &
+                                    MPI_REAL, MPI_SUM, comm2d, ierr )
+#else
+                q_init = init_l
+#endif
+                DEALLOCATE( init_l )
+             ENDIF
+          ENDIF
+
+!
+!--       Write initial profiles onto 3D arrays. Note, only in case of lod = 1, 
+!--       for lod = 2 data is already on 3D arrays.   
           DO  i = nxlg, nxrg
              DO  j = nysg, nyng
@@ -1224,12 +1262,18 @@
                 IF( .NOT. neutral  .AND.  init_3d%lod_pt == 1 )                &
                    pt(:,j,i) = pt_init(:)
-                IF( humidity  .AND.  init_3d%lod_q == 1 )                      &
-                   q(:,j,i)  = q_init(:)
+                IF( humidity  .AND.  init_3d%lod_q == 1 )  q(:,j,i) = q_init(:)
              ENDDO
           ENDDO
 !
-!--       MS: What about the geostrophic wind profiles? Actually these
-!--           are not identical to the initial wind profiles in this case. 
-!--           This need to be further revised.
+!--       Exchange ghost points in case of level-of-detail = 2
+          IF( init_3d%lod_u == 2 )   CALL exchange_horiz( u, nbgp )
+          IF( init_3d%lod_v == 2 )   CALL exchange_horiz( v, nbgp )
+          IF( init_3d%lod_w == 2 )   CALL exchange_horiz( w, nbgp )
+          IF( .NOT. neutral  .AND.  init_3d%lod_pt == 2 )                      &
+             CALL exchange_horiz( pt, nbgp )
+          IF( humidity  .AND.  init_3d%lod_q == 2 )                            &
+             CALL exchange_horiz( q, nbgp )
+!
+!--       Set geostrophic wind components.  
           IF ( init_3d%from_file_ug )  THEN
              ug(:) = init_3d%ug_init(:)
@@ -1238,8 +1282,7 @@
              vg(:) = init_3d%vg_init(:)
           ENDIF
-
+          
           ug(nzt+1) = ug(nzt)
           vg(nzt+1) = vg(nzt)
-
 !
 !--       Set inital w to 0
@@ -1815,5 +1858,5 @@
 !--       Use these mean profiles at the inflow (provided that Dirichlet
 !--       conditions are used)
-          IF ( inflow_l )  THEN
+          IF ( bc_dirichlet_l )  THEN
              DO  j = nysg, nyng
                 DO  k = nzb, nzt+1
@@ -1963,20 +2006,20 @@
 !
 !--    Initialize old timelevels needed for radiation boundary conditions
-       IF ( outflow_l )  THEN
+       IF ( bc_radiation_l )  THEN
           u_m_l(:,:,:) = u(:,:,1:2)
           v_m_l(:,:,:) = v(:,:,0:1)
           w_m_l(:,:,:) = w(:,:,0:1)
        ENDIF
-       IF ( outflow_r )  THEN
+       IF ( bc_radiation_r )  THEN
           u_m_r(:,:,:) = u(:,:,nx-1:nx)
           v_m_r(:,:,:) = v(:,:,nx-1:nx)
           w_m_r(:,:,:) = w(:,:,nx-1:nx)
        ENDIF
-       IF ( outflow_s )  THEN
+       IF ( bc_radiation_s )  THEN
           u_m_s(:,:,:) = u(:,0:1,:)
           v_m_s(:,:,:) = v(:,1:2,:)
           w_m_s(:,:,:) = w(:,0:1,:)
        ENDIF
-       IF ( outflow_n )  THEN
+       IF ( bc_radiation_n )  THEN
           u_m_n(:,:,:) = u(:,ny-1:ny,:)
           v_m_n(:,:,:) = v(:,ny-1:ny,:)
@@ -2301,10 +2344,8 @@
 !-- Initialize nudging if required
     IF ( nudging )  CALL nudge_init
-
 !
 !-- Initialize 1D/3D offline-nesting with COSMO model and read data from 
 !-- external file.
-    IF ( large_scale_forcing  .OR.  forcing )  CALL lsf_init
-    
+    IF ( large_scale_forcing  .OR.  nesting_offline )  CALL lsf_init
 !
 !-- Initialize surface forcing corresponding to large-scale forcing. Therein, 
Index: palm/trunk/SOURCE/init_grid.f90
===================================================================
--- palm/trunk/SOURCE/init_grid.f90	(revision 3178)
+++ palm/trunk/SOURCE/init_grid.f90	(revision 3182)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Rename variables in mesoscale-offline nesting mode
 ! 
 ! Former revisions:
@@ -342,5 +342,8 @@
         
     USE control_parameters,                                                    &
-        ONLY:  bc_lr_cyc, bc_ns_cyc, building_height, building_length_x,       &
+        ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,                 &
+               bc_dirichlet_s, bc_lr_cyc, bc_ns_cyc, bc_radiation_l,           &
+               bc_radiation_n, bc_radiation_r, bc_radiation_s,                 &
+               building_height, building_length_x,                             &
                building_length_y, building_wall_left, building_wall_south,     &
                canyon_height, canyon_wall_left, canyon_wall_south,             &
@@ -350,13 +353,9 @@
                dz_stretch_level_end_index, dz_stretch_level_start_index,       &
                dz_stretch_level_start, grid_level,                             &
-               force_bound_l, force_bound_r, force_bound_n, force_bound_s,     &
-               ibc_uv_b, inflow_l, inflow_n, inflow_r, inflow_s,               &
-               masking_method, maximum_grid_level, message_string,             &
-               momentum_advec, nest_domain, nest_bound_l,                      &
-               nest_bound_n, nest_bound_r, nest_bound_s,                       &
-               number_stretch_level_end, number_stretch_level_start, ocean,    &
-               outflow_l, outflow_n, outflow_r, outflow_s, psolver,            & 
-               scalar_advec, topography, topography_grid_convention,           &
-               tunnel_height, tunnel_length, tunnel_width_x, tunnel_width_y,   &
+               ibc_uv_b, masking_method, maximum_grid_level, message_string,   &
+               momentum_advec, number_stretch_level_end,                       &
+               number_stretch_level_start,ocean, psolver, scalar_advec,        &
+               topography, topography_grid_convention, tunnel_height,          &
+               tunnel_length, tunnel_width_x, tunnel_width_y,                  &
                tunnel_wall_depth, use_surface_fluxes, use_top_fluxes,          &
                wall_adjustment_factor
@@ -386,12 +385,13 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  i                           !< index variable along x 
-    INTEGER(iwp) ::  j                           !< index variable along y
-    INTEGER(iwp) ::  k                           !< index variable along z
-    INTEGER(iwp) ::  k_top                       !< topography top index on local PE
-    INTEGER(iwp) ::  n                           !< loop variable for stretching
-    INTEGER(iwp) ::  number_dz                   !< number of user-specified dz values       
-    INTEGER(iwp) ::  nzb_local_max               !< vertical grid index of maximum topography height
-    INTEGER(iwp) ::  nzb_local_min               !< vertical grid index of minimum topography height
+    INTEGER(iwp) ::  i             !< index variable along x 
+    INTEGER(iwp) ::  j             !< index variable along y
+    INTEGER(iwp) ::  k             !< index variable along z
+    INTEGER(iwp) ::  k_top         !< topography top index on local PE
+    INTEGER(iwp) ::  l             !< loop variable 
+    INTEGER(iwp) ::  n             !< loop variable for stretching
+    INTEGER(iwp) ::  number_dz     !< number of user-specified dz values       
+    INTEGER(iwp) ::  nzb_local_max !< vertical grid index of maximum topography height
+    INTEGER(iwp) ::  nzb_local_min !< vertical grid index of minimum topography height
                                       
     INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_local  !< index for topography top at cell-center
@@ -834,12 +834,12 @@
     nzb_max = k_top + 1
 #endif
-    IF ( inflow_l  .OR.  outflow_l  .OR.  force_bound_l  .OR.  nest_bound_l  .OR.&
-         inflow_r  .OR.  outflow_r  .OR.  force_bound_r  .OR.  nest_bound_r  .OR.&
-         inflow_n  .OR.  outflow_n  .OR.  force_bound_n  .OR.  nest_bound_n  .OR.&
-         inflow_s  .OR.  outflow_s  .OR.  force_bound_s  .OR.  nest_bound_s )    &
+    IF ( bc_dirichlet_l  .OR.  bc_radiation_l     .OR.                         &
+         bc_dirichlet_r  .OR.  bc_radiation_r     .OR.                         &
+         bc_dirichlet_n  .OR.  bc_radiation_n     .OR.                         &
+         bc_dirichlet_s  .OR.  bc_radiation_s )                                &
          nzb_max = nzt
 !   
 !-- Finally, if topography extents up to the model top, limit nzb_max to nzt.
-    nzb_max = MIN( nzb_max, nzt )
+    nzb_max = MIN( nzb_max, nzt ) 
 !
 !-- Determine minimum index of topography. Usually, this will be nzb. In case
@@ -857,4 +857,5 @@
 !-- Initialize boundary conditions via surface type
     CALL init_bc
+
 !
 !-- Allocate and set topography height arrays required for data output
@@ -926,5 +927,5 @@
 #if defined( __parallel )
        CALL MPI_ALLREDUCE( MAXVAL( get_topography_top_index( 's' ) ),          &
-                           nzb_local_max, 1, MPI_INTEGER, MPI_MAX, comm2d, ierr )             
+                           nzb_local_max, 1, MPI_INTEGER, MPI_MAX, comm2d, ierr )               
 #else
        nzb_local_max = MAXVAL( get_topography_top_index( 's' ) )
Index: palm/trunk/SOURCE/init_pegrid.f90
===================================================================
--- palm/trunk/SOURCE/init_pegrid.f90	(revision 3178)
+++ palm/trunk/SOURCE/init_pegrid.f90	(revision 3182)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! ------------------
-! 
+! Rename variables and boundary conditions in mesoscale-offline nesting mode
 ! 
 ! Former revisions:
@@ -239,13 +239,11 @@
 
     USE control_parameters,                                                    &
-        ONLY:  bc_lr, bc_ns, coupling_mode, coupling_mode_remote,              &
-               coupling_topology, force_bound_l, force_bound_n, force_bound_r, &
-               force_bound_s, gathered_size, grid_level,                       &
-               grid_level_count, inflow_l, inflow_n, inflow_r, inflow_s,       &
-               maximum_grid_level, message_string,                             &
-               mg_switch_to_pe0_level, momentum_advec, nest_bound_l,           &
-               nest_bound_n, nest_bound_r, nest_bound_s, nest_domain, neutral, &
-               psolver, outflow_l, outflow_n, outflow_r, outflow_s,            &
-               outflow_source_plane, recycling_width, scalar_advec,            &
+        ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r, bc_dirichlet_s, &
+               bc_lr, bc_ns, bc_radiation_l, bc_radiation_n, bc_radiation_r,   &
+               bc_radiation_s, coupling_mode, coupling_mode_remote,            &
+               coupling_topology, gathered_size, grid_level,                   &
+               grid_level_count, maximum_grid_level, message_string,           &
+               mg_switch_to_pe0_level, momentum_advec, neutral,                &
+               psolver, outflow_source_plane, recycling_width, scalar_advec,   &
                subdomain_size, turbulent_outflow, y_shift
 
@@ -1232,12 +1230,9 @@
 !-- Setting of flags for inflow/outflow/nesting conditions.
     IF ( pleft == MPI_PROC_NULL )  THEN
-       IF ( bc_lr == 'dirichlet/radiation' )  THEN
-          inflow_l  = .TRUE.
+       IF ( bc_lr == 'dirichlet/radiation'  .OR.  bc_lr == 'nested'  .OR.      &
+            bc_lr == 'nesting_offline' )  THEN
+          bc_dirichlet_l  = .TRUE.
        ELSEIF ( bc_lr == 'radiation/dirichlet' )  THEN
-          outflow_l = .TRUE.
-       ELSEIF ( bc_lr == 'nested' )  THEN
-          nest_bound_l = .TRUE.
-       ELSEIF ( bc_lr == 'forcing' )  THEN
-          force_bound_l = .TRUE.
+          bc_radiation_l = .TRUE.
        ENDIF
     ENDIF
@@ -1245,11 +1240,8 @@
     IF ( pright == MPI_PROC_NULL )  THEN
        IF ( bc_lr == 'dirichlet/radiation' )  THEN
-          outflow_r = .TRUE.
-       ELSEIF ( bc_lr == 'radiation/dirichlet' )  THEN
-          inflow_r  = .TRUE.
-       ELSEIF ( bc_lr == 'nested' )  THEN
-          nest_bound_r = .TRUE.
-       ELSEIF ( bc_lr == 'forcing' )  THEN
-          force_bound_r = .TRUE.
+          bc_radiation_r = .TRUE.
+       ELSEIF ( bc_lr == 'radiation/dirichlet'  .OR.  bc_lr == 'nested'  .OR.  &
+                bc_lr == 'nesting_offline' )  THEN
+          bc_dirichlet_r  = .TRUE.
        ENDIF
     ENDIF
@@ -1257,23 +1249,17 @@
     IF ( psouth == MPI_PROC_NULL )  THEN
        IF ( bc_ns == 'dirichlet/radiation' )  THEN
-          outflow_s = .TRUE.
+          bc_radiation_s = .TRUE.
+       ELSEIF ( bc_ns == 'radiation/dirichlet'  .OR.  bc_ns == 'nested'  .OR.  &
+                bc_ns == 'nesting_offline' )  THEN
+          bc_dirichlet_s  = .TRUE.
+       ENDIF
+    ENDIF
+
+    IF ( pnorth == MPI_PROC_NULL )  THEN
+       IF ( bc_ns == 'dirichlet/radiation'  .OR.  bc_ns == 'nested'  .OR.      &
+            bc_ns == 'nesting_offline' )  THEN
+          bc_dirichlet_n  = .TRUE.
        ELSEIF ( bc_ns == 'radiation/dirichlet' )  THEN
-          inflow_s  = .TRUE.
-       ELSEIF ( bc_ns == 'nested' )  THEN
-          nest_bound_s = .TRUE.
-       ELSEIF ( bc_ns == 'forcing' )  THEN
-          force_bound_s = .TRUE.
-       ENDIF
-    ENDIF
-
-    IF ( pnorth == MPI_PROC_NULL )  THEN
-       IF ( bc_ns == 'dirichlet/radiation' )  THEN
-          inflow_n  = .TRUE.
-       ELSEIF ( bc_ns == 'radiation/dirichlet' )  THEN
-          outflow_n = .TRUE.
-       ELSEIF ( bc_ns == 'nested' )  THEN
-          nest_bound_n = .TRUE.
-       ELSEIF ( bc_ns == 'forcing' )  THEN
-          force_bound_n = .TRUE.
+          bc_radiation_n = .TRUE.
        ENDIF
     ENDIF
@@ -1283,20 +1269,20 @@
 !-- only at the left lateral boundary.
     IF ( use_syn_turb_gen )  THEN
-       IF ( force_bound_l  .OR.  nest_bound_l  .OR.  inflow_l )  THEN
+       IF ( bc_dirichlet_l )  THEN
           id_stg_left_l = myidx
        ELSE
           id_stg_left_l = 0
        ENDIF
-       IF ( force_bound_r  .OR.  nest_bound_r )  THEN
+       IF ( bc_dirichlet_r )  THEN
           id_stg_right_l = myidx
        ELSE
           id_stg_right_l = 0
        ENDIF
-       IF ( force_bound_s  .OR.  nest_bound_s )  THEN
+       IF ( bc_dirichlet_s )  THEN
           id_stg_south_l = myidy
        ELSE
           id_stg_south_l = 0
        ENDIF
-       IF ( force_bound_n  .OR.  nest_bound_n )  THEN
+       IF ( bc_dirichlet_n )  THEN
           id_stg_north_l = myidy
        ELSE
@@ -1324,5 +1310,5 @@
 !
 !-- Broadcast the id of the inflow PE
-    IF ( inflow_l )  THEN
+    IF ( bc_dirichlet_l )  THEN
        id_inflow_l = myidx
     ELSE
@@ -1350,5 +1336,5 @@
     IF ( turbulent_outflow )  THEN
 
-       IF ( outflow_r )  THEN
+       IF ( bc_radiation_r )  THEN
           id_outflow_l = myidx
        ELSE
@@ -1375,17 +1361,17 @@
 #else
     IF ( bc_lr == 'dirichlet/radiation' )  THEN
-       inflow_l  = .TRUE.
-       outflow_r = .TRUE.
+       bc_dirichlet_l = .TRUE.
+       bc_radiation_r = .TRUE.
     ELSEIF ( bc_lr == 'radiation/dirichlet' )  THEN
-       outflow_l = .TRUE.
-       inflow_r  = .TRUE.
+       bc_radiation_l = .TRUE.
+       bc_dirichlet_r = .TRUE.
     ENDIF
 
     IF ( bc_ns == 'dirichlet/radiation' )  THEN
-       inflow_n  = .TRUE.
-       outflow_s = .TRUE.
+       bc_dirichlet_n = .TRUE.
+       bc_radiation_s = .TRUE.
     ELSEIF ( bc_ns == 'radiation/dirichlet' )  THEN
-       outflow_n = .TRUE.
-       inflow_s  = .TRUE.
+       bc_radiation_n = .TRUE.
+       bc_dirichlet_s = .TRUE.
     ENDIF
 #endif
@@ -1394,10 +1380,10 @@
 !-- At the inflow or outflow, u or v, respectively, have to be calculated for
 !-- one more grid point.
-    IF ( inflow_l .OR. outflow_l .OR. nest_bound_l .OR. force_bound_l )  THEN
+    IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
        nxlu = nxl + 1
     ELSE
        nxlu = nxl
     ENDIF
-    IF ( inflow_s .OR. outflow_s .OR. nest_bound_s .OR. force_bound_s )  THEN
+    IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
        nysv = nys + 1
     ELSE
Index: palm/trunk/SOURCE/large_scale_forcing_nudging_mod.f90
===================================================================
--- palm/trunk/SOURCE/large_scale_forcing_nudging_mod.f90	(revision 3178)
+++ palm/trunk/SOURCE/large_scale_forcing_nudging_mod.f90	(revision 3182)
@@ -20,5 +20,9 @@
 ! Current revisions:
 ! ------------------
-! 
+! * Adjustment to new Inifor version: 
+!   - No vertical interpolation/extrapolation of lateral boundary data required
+!     any more (Inifor can treat grid stretching now
+!   - Revise initialization in case of COSMO forcing 
+! * Rename variables and subroutines for offline nesting
 ! 
 ! Former revisions:
@@ -69,24 +73,22 @@
 
     USE arrays_3d,                                                             &
-        ONLY:  dzw, e, heatflux_input_conversion, pt, pt_init, q, q_init, s,   &
-               tend, u, u_init, ug, v, v_init, vg, w, w_subs,                  &
+        ONLY:  dzw, e, diss, heatflux_input_conversion, pt, pt_init, q,        &
+               q_init, s, tend, u, u_init, ug, v, v_init, vg, w, w_subs,       &
                waterflux_input_conversion, zu, zw                  
 
     USE control_parameters,                                                    &
-        ONLY:  bc_lr, bc_ns, bc_pt_b, bc_q_b, constant_diffusion,              &
+        ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r, bc_dirichlet_s, &
+               bc_lr, bc_ns, bc_pt_b, bc_q_b, constant_diffusion,              &
                constant_heatflux, constant_waterflux,                          &
-               data_output_pr, dt_3d, end_time, forcing,                       &
-               force_bound_l, force_bound_n, force_bound_r, force_bound_s,     &  
+               data_output_pr, dt_3d, end_time,                                &
                humidity, initializing_actions, intermediate_timestep_count,    &
                ibc_pt_b, ibc_q_b,                                              &
                large_scale_forcing, large_scale_subsidence, lsf_surf, lsf_vert,&
-               lsf_exception, message_string, neutral, nudging, passive_scalar,&
-               pt_surface, ocean, q_surface, surface_heatflux,                 &
-               surface_pressure, surface_waterflux, topography,                &
-               use_subsidence_tendencies
+               lsf_exception, message_string, nesting_offline, neutral,        &
+               nudging, passive_scalar, pt_surface, ocean, q_surface,          &
+               surface_heatflux, surface_pressure, surface_waterflux,          &
+               topography, use_subsidence_tendencies
 
     USE grid_variables
-
-    USE pegrid
 
     USE indices,                                                               &
@@ -96,4 +98,9 @@
     USE kinds
 
+    USE netcdf_data_input_mod,                                                 &
+        ONLY:  nest_offl
+
+    USE pegrid
+
     USE surface_mod,                                                           &
         ONLY:  surf_def_h, surf_lsm_h, surf_usm_h
@@ -101,7 +108,4 @@
     USE statistics,                                                            &
         ONLY:  hom, statistic_regions, sums_ls_l, weight_substep
-
-    USE netcdf_data_input_mod,                                                 &
-        ONLY:  force, netcdf_data_input_interpolate
 
     INTEGER(iwp) ::  nlsf = 1000                       !< maximum number of profiles in LSF_DATA (large scale forcing)
@@ -140,13 +144,14 @@
 !
 !-- Public subroutines
-    PUBLIC ls_forcing_surf, ls_forcing_vert, ls_advec, lsf_init,               &
+    PUBLIC calc_tnudge, ls_forcing_surf, ls_forcing_vert, ls_advec, lsf_init,  &
            lsf_nudging_check_parameters, nudge_init,                           &
            lsf_nudging_check_data_output_pr, lsf_nudging_header,               &
-           calc_tnudge, nudge, nudge_ref, forcing_bc_mass_conservation,        &
-           forcing_bc
+           lsf_nesting_offline, lsf_nesting_offline_mass_conservation,         & 
+           nudge, nudge_ref
+           
 !
 !-- Public variables
     PUBLIC qsws_surf, shf_surf, td_lsa_lpt, td_lsa_q, td_sub_lpt,              &
-           td_sub_q, time_vert, force
+           td_sub_q, time_vert
 
 
@@ -167,7 +172,12 @@
 ! Description:
 ! ------------
-!> @todo Missing subroutine description.
-!------------------------------------------------------------------------------!
-    SUBROUTINE forcing_bc_mass_conservation
+!> In this subroutine a constant mass within the model domain is guaranteed. 
+!> Larger-scale models may be based on a compressible equation system, which is
+!> not consistent with PALMs incompressible equation system. In order to avoid
+!> a decrease or increase of mass during the simulation, non-divergent flow
+!> through the lateral and top boundaries is compensated by the vertical wind 
+!> component at the top boundary. 
+!------------------------------------------------------------------------------!
+    SUBROUTINE lsf_nesting_offline_mass_conservation
 
        USE control_parameters,                                                 &
@@ -176,10 +186,10 @@
        IMPLICIT NONE
 
-       INTEGER(iwp) ::  i !<
-       INTEGER(iwp) ::  j !<
-       INTEGER(iwp) ::  k !<
-
-       REAL(wp) ::  w_correct !< 
-       REAL(wp), DIMENSION(1:3) ::  volume_flow_l   !<
+       INTEGER(iwp) ::  i !< grid index in x-direction
+       INTEGER(iwp) ::  j !< grid index in y-direction
+       INTEGER(iwp) ::  k !< grid index in z-direction
+
+       REAL(wp) ::  w_correct                       !< vertical velocity increment required to compensate non-divergent flow through the boundaries
+       REAL(wp), DIMENSION(1:3) ::  volume_flow_l   !< local volume flow
 
        volume_flow   = 0.0_wp
@@ -188,5 +198,5 @@
        d_area_t = 1.0_wp / ( ( nx + 1 ) * dx * ( ny + 1 ) * dy )
 
-       IF ( force_bound_l )  THEN
+       IF ( bc_dirichlet_l )  THEN
           i = nxl
           DO  j = nys, nyn
@@ -198,5 +208,5 @@
           ENDDO
        ENDIF
-       IF ( force_bound_r )  THEN
+       IF ( bc_dirichlet_r )  THEN
           i = nxr+1
           DO  j = nys, nyn
@@ -208,5 +218,5 @@
           ENDDO
        ENDIF
-       IF ( force_bound_s )  THEN
+       IF ( bc_dirichlet_s )  THEN
           j = nys
           DO  i = nxl, nxr
@@ -218,5 +228,5 @@
           ENDDO
        ENDIF
-       IF ( force_bound_n )  THEN
+       IF ( bc_dirichlet_n )  THEN
           j = nyn+1
           DO  i = nxl, nxr
@@ -255,8 +265,5 @@
        ENDDO
 
-write(9,*) "w correction", w_correct
-flush(9)
-
-    END SUBROUTINE forcing_bc_mass_conservation
+    END SUBROUTINE lsf_nesting_offline_mass_conservation
 
 
@@ -264,14 +271,13 @@
 ! Description:
 ! ------------
-!> @todo Missing subroutine description.
-!------------------------------------------------------------------------------!
-    SUBROUTINE forcing_bc
+!> Set the lateral and top boundary conditions in case the PALM domain is 
+!> nested offline in a mesoscale model. 
+!------------------------------------------------------------------------------!
+    SUBROUTINE lsf_nesting_offline
 
        USE control_parameters,                                                 &
-           ONLY:  force_bound_l, force_bound_n, force_bound_r, force_bound_s,  &
-                  humidity, neutral, passive_scalar, simulated_time
-
-       USE netcdf_data_input_mod,                                              &
-           ONLY:  force                              
+           ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,              &
+                  bc_dirichlet_s, humidity, neutral, passive_scalar, rans_mode,&
+                  rans_tke_e, time_since_reference_point                      
 
        IMPLICIT NONE
@@ -284,133 +290,44 @@
        REAL(wp) ::  ddt_lsf !< inverse value of time resolution of forcing data
        REAL(wp) ::  t_ref   !< time past since last reference step
-
-!
-!--    If required, interpolate and/or extrapolate data vertically. This is 
-!--    required as Inifor outputs only equidistant vertical data.
-       IF ( ANY( zu(1:nzt+1) /= force%zu_atmos(1:force%nzu) ) )  THEN
-          IF ( .NOT. force%interpolated )  THEN
-
-             DO  t = 0, 1
-                IF ( force_bound_l )  THEN
-                   CALL netcdf_data_input_interpolate( force%u_left(t,:,:),    &
-                                                       zu(nzb+1:nzt+1),        &
-                                                       force%zu_atmos )
-                   CALL netcdf_data_input_interpolate( force%v_left(t,:,:),    &
-                                                       zu(nzb+1:nzt+1),        &
-                                                       force%zu_atmos )
-                   CALL netcdf_data_input_interpolate( force%w_left(t,:,:),    &
-                                                       zw(nzb+1:nzt+1),        &
-                                                       force%zw_atmos )
-                   IF ( .NOT. neutral )                                        &
-                      CALL netcdf_data_input_interpolate( force%pt_left(t,:,:),&
-                                                          zu(nzb+1:nzt+1),     &
-                                                          force%zu_atmos )
-                   IF ( humidity )                                             &
-                      CALL netcdf_data_input_interpolate( force%q_left(t,:,:), &
-                                                          zu(nzb+1:nzt+1),     &
-                                                          force%zu_atmos )
-                ENDIF
-                IF ( force_bound_r )  THEN
-                   CALL netcdf_data_input_interpolate( force%u_right(t,:,:),   &
-                                                       zu(nzb+1:nzt+1),        &
-                                                       force%zu_atmos )
-                   CALL netcdf_data_input_interpolate( force%v_right(t,:,:),   &
-                                                       zu(nzb+1:nzt+1),        &
-                                                       force%zu_atmos )
-                   CALL netcdf_data_input_interpolate( force%w_right(t,:,:),   &
-                                                       zw(nzb+1:nzt+1),        &
-                                                       force%zw_atmos )
-                   IF ( .NOT. neutral )                                        &
-                      CALL netcdf_data_input_interpolate( force%pt_right(t,:,:),&
-                                                          zu(nzb+1:nzt+1),     &
-                                                          force%zu_atmos )
-                   IF ( humidity )                                             &
-                      CALL netcdf_data_input_interpolate( force%q_right(t,:,:),&
-                                                          zu(nzb+1:nzt+1),     &
-                                                          force%zu_atmos )
-                ENDIF
-                IF ( force_bound_n )  THEN
-                   CALL netcdf_data_input_interpolate( force%u_north(t,:,:),   &
-                                                       zu(nzb+1:nzt+1),        &
-                                                       force%zu_atmos )
-                   CALL netcdf_data_input_interpolate( force%v_north(t,:,:),   &
-                                                       zu(nzb+1:nzt+1),        &
-                                                       force%zu_atmos )
-                   CALL netcdf_data_input_interpolate( force%w_north(t,:,:),   &
-                                                       zw(nzb+1:nzt+1),        &
-                                                       force%zw_atmos )
-                   IF ( .NOT. neutral )                                        &
-                      CALL netcdf_data_input_interpolate( force%pt_north(t,:,:),&
-                                                          zu(nzb+1:nzt+1),     &
-                                                          force%zu_atmos )
-                   IF ( humidity )                                             &
-                      CALL netcdf_data_input_interpolate( force%q_north(t,:,:),&
-                                                          zu(nzb+1:nzt+1),     &
-                                                          force%zu_atmos )
-                ENDIF
-                IF ( force_bound_s )  THEN
-                   CALL netcdf_data_input_interpolate( force%u_south(t,:,:),   &
-                                                       zu(nzb+1:nzt+1),        &
-                                                       force%zu_atmos )
-                   CALL netcdf_data_input_interpolate( force%v_south(t,:,:),   &
-                                                       zu(nzb+1:nzt+1),        &
-                                                       force%zu_atmos )
-                   CALL netcdf_data_input_interpolate( force%w_south(t,:,:),   &
-                                                       zw(nzb+1:nzt+1),        &
-                                                       force%zw_atmos )
-                   IF ( .NOT. neutral )                                        &
-                      CALL netcdf_data_input_interpolate( force%pt_south(t,:,:),&
-                                                          zu(nzb+1:nzt+1),     &
-                                                          force%zu_atmos )
-                   IF ( humidity )                                             &
-                      CALL netcdf_data_input_interpolate( force%q_south(t,:,:),&
-                                                          zu(nzb+1:nzt+1),     &
-                                                          force%zu_atmos )
-                ENDIF
-             ENDDO
-!
-!--          Note, no interpolation of top boundary. Just use initial value. 
-!--          No physical meaningful extrapolation possible if only one layer is
-!--          given. 
-
-             force%interpolated = .TRUE. 
-          ENDIF
-       ENDIF
-      
+     
 !
 !--    Calculate time interval of forcing data       
-       ddt_lsf = 1.0_wp / ( force%time(force%tind_p) - force%time(force%tind) )
+       ddt_lsf = 1.0_wp / ( nest_offl%time(nest_offl%tind_p) -                 &
+                            nest_offl%time(nest_offl%tind) )
 !
 !--    Calculate reziproke time past since last reference step. Please note, 
-!--    as simulated time is still not updated, the actual time here is 
-!--    simulated time + dt_3d
-       t_ref = simulated_time + dt_3d - force%time(force%tind)
-
-       IF ( force_bound_l )  THEN
-
-          DO  j = nys, nyn
-             DO  k = nzb+1, nzt+1
-                u(k,j,nxlg:nxl) = force%u_left(0,k,j) + ddt_lsf * t_ref *      &
-                         ( force%u_left(1,k,j) - force%u_left(0,k,j) ) *       &
-                           MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_0(k,j,nxlg:nxl), 1 ) )
-             ENDDO
-          ENDDO
+!--    the time coordinate is still not updated, so that the actual time need
+!--    to be incremented by dt_3d. Moreover, note that the simulation time
+!--    passed since simulation start is time_since_reference_point, not 
+!--    simulated_time!
+       t_ref = time_since_reference_point + dt_3d -                            &
+                                            nest_offl%time(nest_offl%tind)
+                                            
+       IF ( bc_dirichlet_l )  THEN
 
           DO  j = nys, nyn
              DO  k = nzb+1, nzt
-                w(k,j,nxlg:nxl-1) = force%w_left(0,k,j) + ddt_lsf * t_ref *    &
-                         ( force%w_left(1,k,j) - force%w_left(0,k,j) ) *       &
-                           MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_0(k,j,nxlg:nxl-1), 3 ) )
+                u(k,j,nxlg:nxl) = nest_offl%u_left(0,k,j) + ddt_lsf * t_ref  * &
+                       ( nest_offl%u_left(1,k,j) - nest_offl%u_left(0,k,j) ) * &
+                         MERGE( 1.0_wp, 0.0_wp,                                &
+                                BTEST( wall_flags_0(k,j,nxlg:nxl), 1 ) )
+             ENDDO
+          ENDDO
+
+          DO  j = nys, nyn
+             DO  k = nzb+1, nzt-1
+                w(k,j,nxlg:nxl-1) = nest_offl%w_left(0,k,j) + ddt_lsf * t_ref *&
+                       ( nest_offl%w_left(1,k,j) - nest_offl%w_left(0,k,j) )  *&
+                         MERGE( 1.0_wp, 0.0_wp,                                &
+                                BTEST( wall_flags_0(k,j,nxlg:nxl-1), 3 ) )
              ENDDO
           ENDDO
 
           DO  j = nysv, nyn
-             DO  k = nzb+1, nzt+1
-                v(k,j,nxlg:nxl-1) = force%v_left(0,k,j) + ddt_lsf * t_ref *    &
-                         ( force%v_left(1,k,j) - force%v_left(0,k,j) ) *       &
-                           MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_0(k,j,nxlg:nxl-1), 2 ) )
+             DO  k = nzb+1, nzt
+                v(k,j,nxlg:nxl-1) = nest_offl%v_left(0,k,j) + ddt_lsf * t_ref *&
+                       ( nest_offl%v_left(1,k,j) - nest_offl%v_left(0,k,j) )  *&
+                         MERGE( 1.0_wp, 0.0_wp,                                &
+                                BTEST( wall_flags_0(k,j,nxlg:nxl-1), 2 ) )
              ENDDO
           ENDDO
@@ -418,8 +335,8 @@
           IF ( .NOT. neutral )  THEN
              DO  j = nys, nyn
-                DO  k = nzb+1, nzt+1
-                   pt(k,j,nxlg:nxl-1) = force%pt_left(0,k,j) + ddt_lsf *       &
-                                                                  t_ref   *    &
-                       ( force%pt_left(1,k,j) - force%pt_left(0,k,j) )
+                DO  k = nzb+1, nzt
+                   pt(k,j,nxlg:nxl-1) = nest_offl%pt_left(0,k,j) + ddt_lsf *   &
+                                                                   t_ref   *   &
+                       ( nest_offl%pt_left(1,k,j) - nest_offl%pt_left(0,k,j) )
  
                 ENDDO
@@ -429,8 +346,8 @@
           IF ( humidity )  THEN
              DO  j = nys, nyn
-                DO  k = nzb+1, nzt+1
-                   q(k,j,nxlg:nxl-1) = force%q_left(0,k,j) + ddt_lsf   *       &
-                                                                  t_ref   *    &
-                       ( force%q_left(1,k,j) - force%q_left(0,k,j) )
+                DO  k = nzb+1, nzt
+                   q(k,j,nxlg:nxl-1) = nest_offl%q_left(0,k,j) + ddt_lsf   *   &
+                                                                 t_ref     *   &
+                       ( nest_offl%q_left(1,k,j) - nest_offl%q_left(0,k,j) )
  
                 ENDDO
@@ -440,30 +357,30 @@
        ENDIF
 
-       IF ( force_bound_r )  THEN
-
-          DO  j = nys, nyn
-             DO  k = nzb+1, nzt+1
-                u(k,j,nxr+1:nxrg) = force%u_right(0,k,j) + ddt_lsf * t_ref *   &
-                        ( force%u_right(1,k,j) - force%u_right(0,k,j) ) *      &
-                           MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_0(k,j,nxr+1:nxrg), 1 ) )
-
-             ENDDO
-          ENDDO
+       IF ( bc_dirichlet_r )  THEN
+
           DO  j = nys, nyn
              DO  k = nzb+1, nzt
-                w(k,j,nxr+1:nxrg) = force%w_right(0,k,j) + ddt_lsf * t_ref *   &
-                        ( force%w_right(1,k,j) - force%w_right(0,k,j) ) *      &
-                           MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_0(k,j,nxr+1:nxrg), 3 ) )
+                u(k,j,nxr+1:nxrg) = nest_offl%u_right(0,k,j) + ddt_lsf * t_ref *&
+                      ( nest_offl%u_right(1,k,j) - nest_offl%u_right(0,k,j) )  *&
+                         MERGE( 1.0_wp, 0.0_wp,                                 &
+                                BTEST( wall_flags_0(k,j,nxr+1:nxrg), 1 ) )
+
+             ENDDO
+          ENDDO
+          DO  j = nys, nyn
+             DO  k = nzb+1, nzt-1
+                w(k,j,nxr+1:nxrg) = nest_offl%w_right(0,k,j) + ddt_lsf * t_ref *&
+                      ( nest_offl%w_right(1,k,j) - nest_offl%w_right(0,k,j) )  *&
+                         MERGE( 1.0_wp, 0.0_wp,                                 &
+                                BTEST( wall_flags_0(k,j,nxr+1:nxrg), 3 ) )
              ENDDO
           ENDDO
 
           DO  j = nysv, nyn
-             DO  k = nzb+1, nzt+1
-                v(k,j,nxr+1:nxrg) = force%v_right(0,k,j) + ddt_lsf * t_ref *   &
-                        ( force%v_right(1,k,j) - force%v_right(0,k,j) ) *      &
-                           MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_0(k,j,nxr+1:nxrg), 2 ) )
+             DO  k = nzb+1, nzt
+                v(k,j,nxr+1:nxrg) = nest_offl%v_right(0,k,j) + ddt_lsf * t_ref *&
+                      ( nest_offl%v_right(1,k,j) - nest_offl%v_right(0,k,j) )  *&
+                         MERGE( 1.0_wp, 0.0_wp,                                 &
+                                BTEST( wall_flags_0(k,j,nxr+1:nxrg), 2 ) )
              ENDDO
           ENDDO
@@ -471,8 +388,8 @@
           IF ( .NOT. neutral )  THEN
              DO  j = nys, nyn
-                DO  k = nzb+1, nzt+1
-                   pt(k,j,nxr+1:nxrg) = force%pt_right(0,k,j) + ddt_lsf *      &
-                                                                  t_ref   *    &
-                     ( force%pt_right(1,k,j) - force%pt_right(0,k,j) )
+                DO  k = nzb+1, nzt
+                   pt(k,j,nxr+1:nxrg) = nest_offl%pt_right(0,k,j) + ddt_lsf *  &
+                                                                    t_ref   *  &
+                     ( nest_offl%pt_right(1,k,j) - nest_offl%pt_right(0,k,j) )
  
                 ENDDO
@@ -482,8 +399,8 @@
           IF ( humidity )  THEN
              DO  j = nys, nyn
-                DO  k = nzb+1, nzt+1
-                   q(k,j,nxr+1:nxrg) = force%q_right(0,k,j) + ddt_lsf   *      &
-                                                                  t_ref   *    &
-                       ( force%q_right(1,k,j) - force%q_right(0,k,j) )
+                DO  k = nzb+1, nzt
+                   q(k,j,nxr+1:nxrg) = nest_offl%q_right(0,k,j) + ddt_lsf   *  &
+                                                                    t_ref   *  &
+                       ( nest_offl%q_right(1,k,j) - nest_offl%q_right(0,k,j) )
  
                 ENDDO
@@ -493,20 +410,20 @@
        ENDIF
 
-       IF ( force_bound_s )  THEN
-
-          DO  i = nxl, nxr
-             DO  k = nzb+1, nzt+1
-                v(k,nysg:nys,i)   = force%v_south(0,k,i) + ddt_lsf * t_ref *   &
-                        ( force%v_south(1,k,i) - force%v_south(0,k,i) ) *      &
-                           MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_0(k,nysg:nys,i), 2 ) )
-             ENDDO
-          ENDDO
+       IF ( bc_dirichlet_s )  THEN
 
           DO  i = nxl, nxr
              DO  k = nzb+1, nzt
-                w(k,nysg:nys-1,i) = force%w_south(0,k,i) + ddt_lsf * t_ref *   &
-                        ( force%w_south(1,k,i) - force%w_south(0,k,i) ) *      &
-                           MERGE( 1.0_wp, 0.0_wp,                              &
+                v(k,nysg:nys,i)   = nest_offl%v_south(0,k,i) + ddt_lsf * t_ref *&
+                      ( nest_offl%v_south(1,k,i) - nest_offl%v_south(0,k,i) )  *&
+                         MERGE( 1.0_wp, 0.0_wp,                                 &
+                                BTEST( wall_flags_0(k,nysg:nys,i), 2 ) )
+             ENDDO
+          ENDDO
+
+          DO  i = nxl, nxr
+             DO  k = nzb+1, nzt-1
+                w(k,nysg:nys-1,i) = nest_offl%w_south(0,k,i) + ddt_lsf * t_ref  *&
+                        ( nest_offl%w_south(1,k,i) - nest_offl%w_south(0,k,i) ) *&
+                           MERGE( 1.0_wp, 0.0_wp,                                &
                                   BTEST( wall_flags_0(k,nysg:nys-1,i), 3 ) )
              ENDDO
@@ -514,8 +431,8 @@
 
           DO  i = nxlu, nxr
-             DO  k = nzb+1, nzt+1
-                u(k,nysg:nys-1,i) = force%u_south(0,k,i) + ddt_lsf * t_ref *   &
-                        ( force%u_south(1,k,i) - force%u_south(0,k,i) ) *      &
-                           MERGE( 1.0_wp, 0.0_wp,                              &
+             DO  k = nzb+1, nzt
+                u(k,nysg:nys-1,i) = nest_offl%u_south(0,k,i) + ddt_lsf * t_ref  *&
+                        ( nest_offl%u_south(1,k,i) - nest_offl%u_south(0,k,i) ) *&
+                           MERGE( 1.0_wp, 0.0_wp,                                &
                                   BTEST( wall_flags_0(k,nysg:nys-1,i), 1 ) )
              ENDDO
@@ -524,8 +441,8 @@
           IF ( .NOT. neutral )  THEN
              DO  i = nxl, nxr
-                DO  k = nzb+1, nzt+1
-                   pt(k,nysg:nys-1,i) = force%pt_south(0,k,i) + ddt_lsf *      &
-                                                                  t_ref   *    &
-                     ( force%pt_south(1,k,i) - force%pt_south(0,k,i) )
+                DO  k = nzb+1, nzt
+                   pt(k,nysg:nys-1,i) = nest_offl%pt_south(0,k,i) + ddt_lsf *  &
+                                                                    t_ref   *  &
+                     ( nest_offl%pt_south(1,k,i) - nest_offl%pt_south(0,k,i) )
  
                 ENDDO
@@ -535,8 +452,8 @@
           IF ( humidity )  THEN
              DO  i = nxl, nxr
-                DO  k = nzb+1, nzt+1
-                   q(k,nysg:nys-1,i) = force%q_south(0,k,i) + ddt_lsf   *      &
-                                                                  t_ref   *    &
-                       ( force%q_south(1,k,i) - force%q_south(0,k,i) )
+                DO  k = nzb+1, nzt
+                   q(k,nysg:nys-1,i) = nest_offl%q_south(0,k,i) + ddt_lsf   *  &
+                                                                    t_ref   *  &
+                       ( nest_offl%q_south(1,k,i) - nest_offl%q_south(0,k,i) )
  
                 ENDDO
@@ -546,19 +463,19 @@
        ENDIF
 
-       IF ( force_bound_n )  THEN
-
-          DO  i = nxl, nxr
-             DO  k = nzb+1, nzt+1
-                v(k,nyn+1:nyng,i)   = force%v_north(0,k,i) + ddt_lsf * t_ref * &
-                        ( force%v_north(1,k,i) - force%v_north(0,k,i) ) *      &
-                           MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_0(k,nyn+1:nyng,i), 2 ) )
-             ENDDO
-          ENDDO
+       IF ( bc_dirichlet_n )  THEN
+
           DO  i = nxl, nxr
              DO  k = nzb+1, nzt
-                w(k,nyn+1:nyng,i) = force%w_north(0,k,i) + ddt_lsf * t_ref *   &
-                        ( force%w_north(1,k,i) - force%w_north(0,k,i) ) *      &
-                           MERGE( 1.0_wp, 0.0_wp,                              &
+                v(k,nyn+1:nyng,i)   = nest_offl%v_north(0,k,i) + ddt_lsf * t_ref *&
+                        ( nest_offl%v_north(1,k,i) - nest_offl%v_north(0,k,i) )  *&
+                           MERGE( 1.0_wp, 0.0_wp,                                 &
+                                  BTEST( wall_flags_0(k,nyn+1:nyng,i), 2 ) )
+             ENDDO
+          ENDDO
+          DO  i = nxl, nxr
+             DO  k = nzb+1, nzt-1
+                w(k,nyn+1:nyng,i) = nest_offl%w_north(0,k,i) + ddt_lsf * t_ref  *&
+                        ( nest_offl%w_north(1,k,i) - nest_offl%w_north(0,k,i) ) *&
+                           MERGE( 1.0_wp, 0.0_wp,                                &
                                   BTEST( wall_flags_0(k,nyn+1:nyng,i), 3 ) )
              ENDDO
@@ -566,8 +483,8 @@
 
           DO  i = nxlu, nxr
-             DO  k = nzb+1, nzt+1
-                u(k,nyn+1:nyng,i) = force%u_north(0,k,i) + ddt_lsf * t_ref *   &
-                        ( force%u_north(1,k,i) - force%u_north(0,k,i) ) *      &
-                           MERGE( 1.0_wp, 0.0_wp,                              &
+             DO  k = nzb+1, nzt
+                u(k,nyn+1:nyng,i) = nest_offl%u_north(0,k,i) + ddt_lsf * t_ref  *&
+                        ( nest_offl%u_north(1,k,i) - nest_offl%u_north(0,k,i) ) *&
+                           MERGE( 1.0_wp, 0.0_wp,                                &
                                   BTEST( wall_flags_0(k,nyn+1:nyng,i), 1 ) )
 
@@ -577,8 +494,8 @@
           IF ( .NOT. neutral )  THEN
              DO  i = nxl, nxr
-                DO  k = nzb+1, nzt+1
-                   pt(k,nyn+1:nyng,i) = force%pt_north(0,k,i) + ddt_lsf *      &
-                                                                  t_ref   *    &
-                     ( force%pt_north(1,k,i) - force%pt_north(0,k,i) )
+                DO  k = nzb+1, nzt
+                   pt(k,nyn+1:nyng,i) = nest_offl%pt_north(0,k,i) + ddt_lsf *  &
+                                                                    t_ref   *  &
+                     ( nest_offl%pt_north(1,k,i) - nest_offl%pt_north(0,k,i) )
  
                 ENDDO
@@ -588,8 +505,8 @@
           IF ( humidity )  THEN
              DO  i = nxl, nxr
-                DO  k = nzb+1, nzt+1
-                   q(k,nyn+1:nyng,i) = force%q_north(0,k,i) + ddt_lsf   *      &
-                                                                  t_ref   *    &
-                       ( force%q_north(1,k,i) - force%q_north(0,k,i) )
+                DO  k = nzb+1, nzt
+                   q(k,nyn+1:nyng,i) = nest_offl%q_north(0,k,i) + ddt_lsf   *  &
+                                                                    t_ref   *  &
+                       ( nest_offl%q_north(1,k,i) - nest_offl%q_north(0,k,i) )
  
                 ENDDO
@@ -600,12 +517,9 @@
 !
 !--    Top boundary. 
-!--    Please note, only map Inifor data on model top in case the numeric is
-!--    identical to the Inifor grid. At the top boundary an extrapolation is 
-!--    not possible. 
        DO  i = nxlu, nxr
           DO  j = nys, nyn
-             u(nzt+1,j,i) = force%u_top(0,j,i) + ddt_lsf * t_ref *             &
-                        ( force%u_top(1,j,i) - force%u_top(0,j,i) ) *          &
-                           MERGE( 1.0_wp, 0.0_wp,                             &
+             u(nzt+1,j,i) = nest_offl%u_top(0,j,i) + ddt_lsf * t_ref *         &
+                        ( nest_offl%u_top(1,j,i) - nest_offl%u_top(0,j,i) ) *  &
+                           MERGE( 1.0_wp, 0.0_wp,                              &
                                   BTEST( wall_flags_0(nzt+1,j,i), 1 ) )
           ENDDO
@@ -614,6 +528,6 @@
        DO  i = nxl, nxr
           DO  j = nysv, nyn
-             v(nzt+1,j,i) = force%v_top(0,j,i) + ddt_lsf * t_ref *             &
-                        ( force%v_top(1,j,i) - force%v_top(0,j,i) ) *          &
+             v(nzt+1,j,i) = nest_offl%v_top(0,j,i) + ddt_lsf * t_ref *         &
+                        ( nest_offl%v_top(1,j,i) - nest_offl%v_top(0,j,i) ) *  &
                            MERGE( 1.0_wp, 0.0_wp,                              &
                                   BTEST( wall_flags_0(nzt+1,j,i), 2 ) )
@@ -623,6 +537,6 @@
        DO  i = nxl, nxr
           DO  j = nys, nyn
-             w(nzt:nzt+1,j,i) = force%w_top(0,j,i) + ddt_lsf * t_ref *         &
-                        ( force%w_top(1,j,i) - force%w_top(0,j,i) ) *          &
+             w(nzt:nzt+1,j,i) = nest_offl%w_top(0,j,i) + ddt_lsf * t_ref *     &
+                        ( nest_offl%w_top(1,j,i) - nest_offl%w_top(0,j,i) ) *  &
                            MERGE( 1.0_wp, 0.0_wp,                              &
                                   BTEST( wall_flags_0(nzt:nzt+1,j,i), 3 ) )
@@ -634,6 +548,6 @@
           DO  i = nxl, nxr
              DO  j = nys, nyn
-                pt(nzt+1,j,i) = force%pt_top(0,j,i) + ddt_lsf * t_ref *        &
-                        ( force%pt_top(1,j,i) - force%pt_top(0,j,i) )
+                pt(nzt+1,j,i) = nest_offl%pt_top(0,j,i) + ddt_lsf * t_ref *    &
+                        ( nest_offl%pt_top(1,j,i) - nest_offl%pt_top(0,j,i) )
              ENDDO
           ENDDO
@@ -643,6 +557,6 @@
           DO  i = nxl, nxr
              DO  j = nys, nyn
-                q(nzt+1,j,i) = force%q_top(0,j,i) + ddt_lsf * t_ref *          &
-                        ( force%q_top(1,j,i) - force%q_top(0,j,i) )
+                q(nzt+1,j,i) = nest_offl%q_top(0,j,i) + ddt_lsf * t_ref *      &
+                        ( nest_offl%q_top(1,j,i) - nest_offl%q_top(0,j,i) )
              ENDDO
           ENDDO
@@ -651,10 +565,10 @@
 !--    At the edges( left-south, left-north, right-south and right-north) set 
 !--    data on ghost points. 
-       IF ( force_bound_l  .AND.  force_bound_s )  THEN
+       IF ( bc_dirichlet_l  .AND.  bc_dirichlet_s )  THEN
           DO  i = 1, nbgp
              u(:,nys-i,nxlg:nxl)   = u(:,nys,nxlg:nxl)
              w(:,nys-i,nxlg:nxl-1) = w(:,nys,nxlg:nxl-1)
              IF ( .NOT. neutral )  pt(:,nys-i,nxlg:nxl-1) = pt(:,nys,nxlg:nxl-1)
-             IF ( humidity )       q(:,nys-i,nxlg:nxl-1)  = q(:,nys,nxlg:nxl-1)
+             IF ( humidity      )  q(:,nys-i,nxlg:nxl-1)  = q(:,nys,nxlg:nxl-1)
           ENDDO
           DO  i = 1, nbgp+1
@@ -662,5 +576,5 @@
           ENDDO
        ENDIF
-       IF ( force_bound_l  .AND.  force_bound_n )  THEN
+       IF ( bc_dirichlet_l  .AND.  bc_dirichlet_n )  THEN
           DO  i = 1, nbgp
              u(:,nyn+i,nxlg:nxl)   = u(:,nyn,nxlg:nxl)
@@ -668,13 +582,13 @@
              w(:,nyn+i,nxlg:nxl-1) = w(:,nyn,nxlg:nxl-1)
              IF ( .NOT. neutral )  pt(:,nyn+i,nxlg:nxl-1) = pt(:,nyn,nxlg:nxl-1)
-             IF ( humidity )       q(:,nyn+i,nxlg:nxl-1)  = q(:,nyn,nxlg:nxl-1)
-          ENDDO
-       ENDIF
-       IF ( force_bound_r  .AND.  force_bound_s )  THEN
+             IF ( humidity      )  q(:,nyn+i,nxlg:nxl-1)  = q(:,nyn,nxlg:nxl-1)
+          ENDDO
+       ENDIF
+       IF ( bc_dirichlet_r  .AND.  bc_dirichlet_s )  THEN
           DO  i = 1, nbgp
              u(:,nys-i,nxr+1:nxrg) = u(:,nys,nxr+1:nxrg)
              w(:,nys-i,nxr+1:nxrg) = w(:,nys,nxr+1:nxrg)
              IF ( .NOT. neutral )  pt(:,nys-i,nxr+1:nxrg) = pt(:,nys,nxr+1:nxrg)
-             IF ( humidity )       q(:,nys-i,nxr+1:nxrg)  = q(:,nys,nxr+1:nxrg)
+             IF ( humidity      )  q(:,nys-i,nxr+1:nxrg)  = q(:,nys,nxr+1:nxrg)
           ENDDO
           DO  i = 1, nbgp+1
@@ -682,5 +596,5 @@
           ENDDO
        ENDIF
-       IF ( force_bound_r  .AND.  force_bound_n )  THEN
+       IF ( bc_dirichlet_r  .AND.  bc_dirichlet_n )  THEN
           DO  i = 1, nbgp
              u(:,nyn+i,nxr+1:nxrg) = u(:,nyn,nxr+1:nxrg)
@@ -688,23 +602,30 @@
              w(:,nyn+i,nxr+1:nxrg) = w(:,nyn,nxr+1:nxrg)
              IF ( .NOT. neutral )  pt(:,nyn+i,nxr+1:nxrg) = pt(:,nyn,nxr+1:nxrg)
-             IF ( humidity )       q(:,nyn+i,nxr+1:nxrg)  = q(:,nyn,nxr+1:nxrg)
-          ENDDO
-       ENDIF
-!
-!--    Moreover, set Neumann boundary condition for subgrid-scale TKE and 
-!--    passive scalar
+             IF ( humidity      )  q(:,nyn+i,nxr+1:nxrg)  = q(:,nyn,nxr+1:nxrg)
+          ENDDO
+       ENDIF
+!
+!--    Moreover, set Neumann boundary condition for subgrid-scale TKE, 
+!--    passive scalar, dissipation, and chemical species if required
+       IF ( rans_mode  .AND.  rans_tke_e )  THEN
+          IF (  bc_dirichlet_l )  diss(:,:,nxl-1) = diss(:,:,nxl)
+          IF (  bc_dirichlet_r )  diss(:,:,nxr+1) = diss(:,:,nxr)
+          IF (  bc_dirichlet_s )  diss(:,nys-1,:) = diss(:,nys,:)
+          IF (  bc_dirichlet_n )  diss(:,nyn+1,:) = diss(:,nyn,:)
+       ENDIF
        IF ( .NOT. constant_diffusion )  THEN
-          IF (  force_bound_l )  e(:,:,nxl-1) = e(:,:,nxl)
-          IF (  force_bound_r )  e(:,:,nxr+1) = e(:,:,nxr)
-          IF (  force_bound_s )  e(:,nys-1,:) = e(:,nys,:)
-          IF (  force_bound_n )  e(:,nyn+1,:) = e(:,nyn,:)
+          IF (  bc_dirichlet_l )  e(:,:,nxl-1) = e(:,:,nxl)
+          IF (  bc_dirichlet_r )  e(:,:,nxr+1) = e(:,:,nxr)
+          IF (  bc_dirichlet_s )  e(:,nys-1,:) = e(:,nys,:)
+          IF (  bc_dirichlet_n )  e(:,nyn+1,:) = e(:,nyn,:)
           e(nzt+1,:,:) = e(nzt,:,:)
        ENDIF
        IF ( passive_scalar )  THEN
-          IF (  force_bound_l )  s(:,:,nxl-1) = s(:,:,nxl)
-          IF (  force_bound_r )  s(:,:,nxr+1) = s(:,:,nxr)
-          IF (  force_bound_s )  s(:,nys-1,:) = s(:,nys,:)
-          IF (  force_bound_n )  s(:,nyn+1,:) = s(:,nyn,:)
-       ENDIF
+          IF (  bc_dirichlet_l )  s(:,:,nxl-1) = s(:,:,nxl)
+          IF (  bc_dirichlet_r )  s(:,:,nxr+1) = s(:,:,nxr)
+          IF (  bc_dirichlet_s )  s(:,nys-1,:) = s(:,nys,:)
+          IF (  bc_dirichlet_n )  s(:,nyn+1,:) = s(:,nyn,:)
+       ENDIF
+
 
 
@@ -720,10 +641,10 @@
 !--    treatment of fluxes. 
 !--    For the moment, comment this out! 
-!      surface_pressure = force%surface_pressure(force%tind) +                 &
+!      surface_pressure = nest_offl%surface_pressure(nest_offl%tind) +                 &
 !                                                      ddt_lsf * t_ref *       &
-!                                    ( force%surface_pressure(force%tind_p)    &
-!                                    - force%surface_pressure(force%tind) )
-
-    END SUBROUTINE forcing_bc
+!                                    ( nest_offl%surface_pressure(nest_offl%tind_p)    &
+!                                    - nest_offl%surface_pressure(nest_offl%tind) )
+
+    END SUBROUTINE lsf_nesting_offline
 
 !------------------------------------------------------------------------------!
@@ -1040,5 +961,5 @@
        REAL(wp) ::  r_dummy           !<
 
-       IF ( forcing )  THEN
+       IF ( nesting_offline )  THEN
 !
 !--       Allocate arrays for geostrophic wind components. Arrays will 
@@ -1047,180 +968,54 @@
 !--       case of cyclic boundary conditions.
           IF ( bc_lr_cyc  .AND.  bc_ns_cyc )  THEN
-             ALLOCATE( force%ug(0:1,nzb:nzt+1) )
-             ALLOCATE( force%vg(0:1,nzb:nzt+1) )
+             ALLOCATE( nest_offl%ug(0:1,nzb:nzt+1) )
+             ALLOCATE( nest_offl%vg(0:1,nzb:nzt+1) )
           ENDIF
 !
 !--       Allocate arrays for reading boundary values. Arrays will incorporate 2 
 !--       time levels in order to interpolate in between. 
-          IF ( force_bound_l )  THEN
-             ALLOCATE( force%u_left(0:1,nzb+1:nzt+1,nys:nyn)  )
-             ALLOCATE( force%v_left(0:1,nzb+1:nzt+1,nysv:nyn) )
-             ALLOCATE( force%w_left(0:1,nzb+1:nzt,nys:nyn)    )
-             IF ( humidity )      ALLOCATE( force%q_left(0:1,nzb+1:nzt+1,nys:nyn)  )
-             IF ( .NOT. neutral ) ALLOCATE( force%pt_left(0:1,nzb+1:nzt+1,nys:nyn) )
-          ENDIF
-          IF ( force_bound_r )  THEN
-             ALLOCATE( force%u_right(0:1,nzb+1:nzt+1,nys:nyn)  )
-             ALLOCATE( force%v_right(0:1,nzb+1:nzt+1,nysv:nyn) )
-             ALLOCATE( force%w_right(0:1,nzb+1:nzt,nys:nyn)    )
-             IF ( humidity )      ALLOCATE( force%q_right(0:1,nzb+1:nzt+1,nys:nyn)  )
-             IF ( .NOT. neutral ) ALLOCATE( force%pt_right(0:1,nzb+1:nzt+1,nys:nyn) )
-          ENDIF
-          IF ( force_bound_n )  THEN
-             ALLOCATE( force%u_north(0:1,nzb+1:nzt+1,nxlu:nxr) )
-             ALLOCATE( force%v_north(0:1,nzb+1:nzt+1,nxl:nxr)  )
-             ALLOCATE( force%w_north(0:1,nzb+1:nzt,nxl:nxr)    )
-             IF ( humidity )      ALLOCATE( force%q_north(0:1,nzb+1:nzt+1,nxl:nxr)  )
-             IF ( .NOT. neutral ) ALLOCATE( force%pt_north(0:1,nzb+1:nzt+1,nxl:nxr) )
-          ENDIF
-          IF ( force_bound_s )  THEN
-             ALLOCATE( force%u_south(0:1,nzb+1:nzt+1,nxlu:nxr) )
-             ALLOCATE( force%v_south(0:1,nzb+1:nzt+1,nxl:nxr)  )
-             ALLOCATE( force%w_south(0:1,nzb+1:nzt,nxl:nxr)    )
-             IF ( humidity )      ALLOCATE( force%q_south(0:1,nzb+1:nzt+1,nxl:nxr)  )
-             IF ( .NOT. neutral ) ALLOCATE( force%pt_south(0:1,nzb+1:nzt+1,nxl:nxr) )
+          IF ( bc_dirichlet_l )  THEN
+             ALLOCATE( nest_offl%u_left(0:1,nzb+1:nzt,nys:nyn)  )
+             ALLOCATE( nest_offl%v_left(0:1,nzb+1:nzt,nysv:nyn) )
+             ALLOCATE( nest_offl%w_left(0:1,nzb+1:nzt-1,nys:nyn) )
+             IF ( humidity )      ALLOCATE( nest_offl%q_left(0:1,nzb+1:nzt,nys:nyn)  )
+             IF ( .NOT. neutral ) ALLOCATE( nest_offl%pt_left(0:1,nzb+1:nzt,nys:nyn) )
+          ENDIF
+          IF ( bc_dirichlet_r )  THEN
+             ALLOCATE( nest_offl%u_right(0:1,nzb+1:nzt,nys:nyn)  )
+             ALLOCATE( nest_offl%v_right(0:1,nzb+1:nzt,nysv:nyn) )
+             ALLOCATE( nest_offl%w_right(0:1,nzb+1:nzt-1,nys:nyn) )
+             IF ( humidity )      ALLOCATE( nest_offl%q_right(0:1,nzb+1:nzt,nys:nyn)  )
+             IF ( .NOT. neutral ) ALLOCATE( nest_offl%pt_right(0:1,nzb+1:nzt,nys:nyn) )
+          ENDIF
+          IF ( bc_dirichlet_n )  THEN
+             ALLOCATE( nest_offl%u_north(0:1,nzb+1:nzt,nxlu:nxr) )
+             ALLOCATE( nest_offl%v_north(0:1,nzb+1:nzt,nxl:nxr)  )
+             ALLOCATE( nest_offl%w_north(0:1,nzb+1:nzt-1,nxl:nxr) )
+             IF ( humidity )      ALLOCATE( nest_offl%q_north(0:1,nzb+1:nzt,nxl:nxr)  )
+             IF ( .NOT. neutral ) ALLOCATE( nest_offl%pt_north(0:1,nzb+1:nzt,nxl:nxr) )
+          ENDIF
+          IF ( bc_dirichlet_s )  THEN
+             ALLOCATE( nest_offl%u_south(0:1,nzb+1:nzt,nxlu:nxr) )
+             ALLOCATE( nest_offl%v_south(0:1,nzb+1:nzt,nxl:nxr)  )
+             ALLOCATE( nest_offl%w_south(0:1,nzb+1:nzt-1,nxl:nxr)    )
+             IF ( humidity )      ALLOCATE( nest_offl%q_south(0:1,nzb+1:nzt,nxl:nxr)  )
+             IF ( .NOT. neutral ) ALLOCATE( nest_offl%pt_south(0:1,nzb+1:nzt,nxl:nxr) )
           ENDIF
           
-          ALLOCATE( force%u_top(0:1,nys:nyn,nxlu:nxr) )
-          ALLOCATE( force%v_top(0:1,nysv:nyn,nxl:nxr) )
-          ALLOCATE( force%w_top(0:1,nys:nyn,nxl:nxr)  )
-          IF ( humidity )      ALLOCATE( force%q_top(0:1,nys:nyn,nxl:nxr)  )
-          IF ( .NOT. neutral ) ALLOCATE( force%pt_top(0:1,nys:nyn,nxl:nxr) )
-
-!
-!--       Initial call of input. Time array, initial 3D data of u, v, w, 
-!--       potential temperature, as well as mixing ratio, will be read. 
-!--       Moreover, data at lateral and top boundary will be read.  
+          ALLOCATE( nest_offl%u_top(0:1,nys:nyn,nxlu:nxr) )
+          ALLOCATE( nest_offl%v_top(0:1,nysv:nyn,nxl:nxr) )
+          ALLOCATE( nest_offl%w_top(0:1,nys:nyn,nxl:nxr)  )
+          IF ( humidity )      ALLOCATE( nest_offl%q_top(0:1,nys:nyn,nxl:nxr)  )
+          IF ( .NOT. neutral ) ALLOCATE( nest_offl%pt_top(0:1,nys:nyn,nxl:nxr) )
+
+!
+!--       Read COSMO data at lateral and top boundaries
           CALL netcdf_data_input_lsf
 !
-!--       Please note, at the moment INIFOR assumes only an equidistant vertical
-!--       grid. In case of vertical grid stretching, input of inital 3D data 
-!--       need to be inter- and/or extrapolated. 
-!--       Therefore, check if zw grid on file is identical to numeric zw grid.   
-          IF ( ANY( zu(1:nzt+1) /= force%zu_atmos(1:force%nzu) ) )  THEN
-!
-!--          Also data at the boundaries need to be inter/extrapolated at both
-!--          time levels
-             DO  t = 0, 1
-                IF ( force_bound_l )  THEN
-                   CALL netcdf_data_input_interpolate( force%u_left(t,:,:),    &
-                                                       zu(1:nzt+1),            &
-                                                       force%zu_atmos )
-                   CALL netcdf_data_input_interpolate( force%v_left(t,:,:),    &
-                                                       zu(1:nzt+1),            &
-                                                       force%zu_atmos )
-                   CALL netcdf_data_input_interpolate( force%w_left(t,:,:),    &
-                                                       zw(1:nzt+1),            &
-                                                       force%zw_atmos )
-                   IF ( .NOT. neutral )                                        &
-                      CALL netcdf_data_input_interpolate( force%pt_left(t,:,:),&
-                                                          zu(1:nzt+1),         &
-                                                          force%zu_atmos )
-                   IF ( humidity )                                             &
-                      CALL netcdf_data_input_interpolate( force%q_left(t,:,:), &
-                                                          zu(1:nzt+1),         &
-                                                          force%zu_atmos )
-                ENDIF
-                IF ( force_bound_r )  THEN
-                   CALL netcdf_data_input_interpolate( force%u_right(t,:,:),   &
-                                                       zu(1:nzt+1),            &
-                                                       force%zu_atmos )
-                   CALL netcdf_data_input_interpolate( force%v_right(t,:,:),   &
-                                                       zu(1:nzt+1),            &
-                                                       force%zu_atmos )
-                   CALL netcdf_data_input_interpolate( force%w_right(t,:,:),   &
-                                                       zw(1:nzt+1),            &
-                                                       force%zw_atmos )
-                   IF ( .NOT. neutral )                                        &
-                      CALL netcdf_data_input_interpolate( force%pt_right(t,:,:),&
-                                                          zu(1:nzt+1),          &
-                                                          force%zu_atmos )
-                   IF ( humidity )                                             &
-                      CALL netcdf_data_input_interpolate( force%q_right(t,:,:),&
-                                                          zu(1:nzt+1),         &
-                                                          force%zu_atmos )
-                ENDIF
-                IF ( force_bound_n )  THEN
-                   CALL netcdf_data_input_interpolate( force%u_north(t,:,:),   &
-                                                       zu(1:nzt+1),            &
-                                                       force%zu_atmos )
-                   CALL netcdf_data_input_interpolate( force%v_north(t,:,:),   &
-                                                       zu(1:nzt+1),            &
-                                                       force%zu_atmos )
-                   CALL netcdf_data_input_interpolate( force%w_north(t,:,:),   &
-                                                       zw(1:nzt+1),            &
-                                                       force%zw_atmos )
-                   IF ( .NOT. neutral )                                        &
-                      CALL netcdf_data_input_interpolate( force%pt_north(t,:,:),&
-                                                          zu(1:nzt+1),          &
-                                                          force%zu_atmos )
-                   IF ( humidity )                                             &
-                      CALL netcdf_data_input_interpolate( force%q_north(t,:,:),&
-                                                          zu(1:nzt+1),         &
-                                                          force%zu_atmos )
-                ENDIF
-                IF ( force_bound_s )  THEN
-                   CALL netcdf_data_input_interpolate( force%u_south(t,:,:),   &
-                                                       zu(1:nzt+1),            &
-                                                       force%zu_atmos )
-                   CALL netcdf_data_input_interpolate( force%v_south(t,:,:),   &
-                                                       zu(1:nzt+1),            &
-                                                       force%zu_atmos )
-                   CALL netcdf_data_input_interpolate( force%w_south(t,:,:),   &
-                                                       zw(1:nzt+1),            &
-                                                       force%zw_atmos )
-                   IF ( .NOT. neutral )                                        &
-                      CALL netcdf_data_input_interpolate( force%pt_south(t,:,:),&
-                                                          zu(1:nzt+1),          &
-                                                          force%zu_atmos )
-                   IF ( humidity )                                             &
-                      CALL netcdf_data_input_interpolate( force%q_south(t,:,:),&
-                                                          zu(1:nzt+1),         &
-                                                          force%zu_atmos )
-                ENDIF
-             ENDDO
-          ENDIF
-
-!
-!--       Exchange ghost points
-          CALL exchange_horiz( u, nbgp )
-          CALL exchange_horiz( v, nbgp )
-          CALL exchange_horiz( w, nbgp )
-          IF ( .NOT. neutral )  CALL exchange_horiz( pt, nbgp )
-          IF ( humidity      )  CALL exchange_horiz( q,  nbgp )
-!
-!--       At lateral boundaries, set also initial boundary conditions
-          IF ( force_bound_l )  THEN
-             u(:,:,nxl)   = u(:,:,nxlu)
-             v(:,:,nxl-1) = v(:,:,nxl)
-             w(:,:,nxl-1) = w(:,:,nxl)
-             IF ( .NOT. neutral )  pt(:,:,nxl-1) = pt(:,:,nxl)
-             IF ( humidity      )  q(:,:,nxl-1)  = q(:,:,nxl)
-          ENDIF
-          IF ( force_bound_r )  THEN
-             u(:,:,nxr+1) = u(:,:,nxr)
-             v(:,:,nxr+1) = v(:,:,nxr)
-             w(:,:,nxr+1) = w(:,:,nxr)
-             IF ( .NOT. neutral )  pt(:,:,nxr+1) = pt(:,:,nxr)
-             IF ( humidity      )  q(:,:,nxr+1)  = q(:,:,nxr)
-          ENDIF
-          IF ( force_bound_s )  THEN
-             u(:,nys-1,:) = u(:,nys,:)
-             v(:,nys,:)   = v(:,nysv,:)
-             w(:,nys-1,:) = w(:,nys,:)
-             IF ( .NOT. neutral )  pt(:,nys-1,:) = pt(:,nys,:)
-             IF ( humidity      )  q(:,nys-1,:)  = q(:,nys,:)
-          ENDIF
-          IF ( force_bound_n )  THEN
-             u(:,nyn+1,:) = u(:,nyn,:)
-             v(:,nyn+1,:) = v(:,nyn,:)
-             w(:,nyn+1,:) = w(:,nyn,:)
-             IF ( .NOT. neutral )  pt(:,nyn+1,:) = pt(:,nyn,:)
-             IF ( humidity      )  q(:,nyn+1,:)  = q(:,nyn,:)
-          ENDIF
-
+!--       Write COSMO data at lateral and top boundaries
+          CALL lsf_nesting_offline
 !
 !--       After 3D data is initialized, ensure mass conservation
-          CALL forcing_bc_mass_conservation
+          CALL lsf_nesting_offline_mass_conservation
 !
 !--       Initialize surface pressure. Please note, time-dependent surface
@@ -1228,5 +1023,5 @@
 !--       treatment of fluxes. 
 !--       For the moment, comment this out! 
-!         surface_pressure = force%surface_pressure(0)
+!         surface_pressure = nest_offl%surface_pressure(0)
 
        ELSE
Index: palm/trunk/SOURCE/modules.f90
===================================================================
--- palm/trunk/SOURCE/modules.f90	(revision 3178)
+++ palm/trunk/SOURCE/modules.f90	(revision 3182)
@@ -20,5 +20,12 @@
 ! Current revisions:
 ! ------------------
-! 
+! Rename offline nesting variables:
+! -inflow_l, inflow_n, inflow_r, inflow_s, 
+!  nest_bound_l, nest_bound_n, nest_bound_r, nest_bound_s, nest_domain, forcing, 
+!  force_bound_l, force_bound_n, force_bound_r, force_bound_s, outflow_l, 
+!  outflow_n, outflow_r, outflow_s
+! +bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_n, bc_dirichlet_r, 
+!  bc_radiation_l, bc_radiation_n, bc_radiation_n, bc_radiation_r, child_domain 
+!  nesting_offline
 ! 
 ! Former revisions:
@@ -1272,4 +1279,8 @@
     LOGICAL ::  agent_time_unlimited = .FALSE.                   !< namelist parameter
     LOGICAL ::  air_chemistry = .FALSE.                          !< chemistry model switch
+    LOGICAL ::  bc_dirichlet_l                                   !< flag indicating dirichlet boundary condition on left model boundary
+    LOGICAL ::  bc_dirichlet_n                                   !< flag indicating dirichlet boundary condition on north model boundary
+    LOGICAL ::  bc_dirichlet_r                                   !< flag indicating dirichlet boundary condition on right model boundary
+    LOGICAL ::  bc_dirichlet_s                                   !< flag indicating dirichlet boundary condition on south model boundary
     LOGICAL ::  bc_lr_cyc =.TRUE.                                !< left-right boundary condition cyclic?
     LOGICAL ::  bc_lr_dirrad = .FALSE.                           !< left-right boundary condition dirichlet/radiation?
@@ -1278,7 +1289,12 @@
     LOGICAL ::  bc_ns_dirrad = .FALSE.                           !< north-south boundary condition dirichlet/radiation?
     LOGICAL ::  bc_ns_raddir = .FALSE.                           !< north-south boundary condition radiation/dirichlet?
+    LOGICAL ::  bc_radiation_l = .FALSE.                         !< radiation boundary condition for outflow at left domain boundary
+    LOGICAL ::  bc_radiation_n = .FALSE.                         !< radiation boundary condition for outflow at north domain boundary
+    LOGICAL ::  bc_radiation_r = .FALSE.                         !< radiation boundary condition for outflow at right domain boundary
+    LOGICAL ::  bc_radiation_s = .FALSE.                         !< radiation boundary condition for outflow at south domain boundary
     LOGICAL ::  calc_soil_moisture_during_spinup = .FALSE.       !< namelist parameter
     LOGICAL ::  call_microphysics_at_all_substeps = .FALSE.      !< namelist parameter
     LOGICAL ::  call_psolver_at_all_substeps = .TRUE.            !< namelist parameter
+    LOGICAL ::  child_domain  = .FALSE.                          !< flag indicating that model is nested in a parent domain
     LOGICAL ::  cloud_droplets = .FALSE.                         !< namelist parameter
     LOGICAL ::  cloud_physics = .FALSE.                          !< namelist parameter
@@ -1310,16 +1326,7 @@
     LOGICAL ::  first_call_mas = .TRUE.                          !< call mas only once per timestep
     LOGICAL ::  force_print_header = .FALSE.                     !< namelist parameter
-    LOGICAL ::  force_bound_l = .FALSE.                          !< flag indicating domain boundary on left side to set forcing boundary conditions
-    LOGICAL ::  force_bound_n = .FALSE.                          !< flag indicating domain boundary on north side to set forcing boundary conditions
-    LOGICAL ::  force_bound_r = .FALSE.                          !< flag indicating domain boundary on right side to set forcing boundary conditions
-    LOGICAL ::  force_bound_s = .FALSE.                          !< flag indicating domain boundary on south side to set forcing boundary conditions
-    LOGICAL ::  forcing = .FALSE.                                !< flag controlling forcing from large-scale model     
     LOGICAL ::  galilei_transformation = .FALSE.                 !< namelist parameter
     LOGICAL ::  humidity = .FALSE.                               !< namelist parameter
     LOGICAL ::  humidity_remote = .FALSE.                        !< switch for receiving near-surface humidity flux (atmosphere-ocean coupling)
-    LOGICAL ::  inflow_l = .FALSE.                               !< left domain boundary has non-cyclic inflow?
-    LOGICAL ::  inflow_n = .FALSE.                               !< north domain boundary has non-cyclic inflow?
-    LOGICAL ::  inflow_r = .FALSE.                               !< right domain boundary has non-cyclic inflow?
-    LOGICAL ::  inflow_s = .FALSE.                               !< south domain boundary has non-cyclic inflow?
     LOGICAL ::  large_scale_forcing = .FALSE.                    !< namelist parameter
     LOGICAL ::  large_scale_subsidence = .FALSE.                 !< namelist parameter
@@ -1336,16 +1343,8 @@
     LOGICAL ::  microphysics_seifert = .FALSE.                   !< use 2-moment Seifert and Beheng scheme
     LOGICAL ::  mg_switch_to_pe0 = .FALSE.                       !< internal multigrid switch for steering the ghost point exchange in case that data has been collected on PE0
-    LOGICAL ::  nest_bound_l = .FALSE.                           !< flag indicating nested domain boundary on left side
-    LOGICAL ::  nest_bound_n = .FALSE.                           !< flag indicating nested domain boundary on north side
-    LOGICAL ::  nest_bound_r = .FALSE.                           !< flag indicating nested domain boundary on right side
-    LOGICAL ::  nest_bound_s = .FALSE.                           !< flag indicating nested domain boundary on south side
-    LOGICAL ::  nest_domain  = .FALSE.                           !< domain is nested into a parent domain?
+    LOGICAL ::  nesting_offline = .FALSE.                        !< flag controlling offline nesting in COSMO model  
     LOGICAL ::  neutral = .FALSE.                                !< namelist parameter
     LOGICAL ::  nudging = .FALSE.                                !< namelist parameter
     LOGICAL ::  ocean = .FALSE.                                  !< namelist parameter
-    LOGICAL ::  outflow_l = .FALSE.                              !< left domain boundary has non-cyclic outflow?
-    LOGICAL ::  outflow_n = .FALSE.                              !< north domain boundary has non-cyclic outflow?
-    LOGICAL ::  outflow_r = .FALSE.                              !< right domain boundary has non-cyclic outflow?
-    LOGICAL ::  outflow_s = .FALSE.                              !< south domain boundary has non-cyclic outflow?
     LOGICAL ::  passive_scalar = .FALSE.                         !< namelist parameter
     LOGICAL ::  plant_canopy = .FALSE.                           !< switch for use of plant canopy model
Index: palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 3178)
+++ palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 3182)
@@ -20,5 +20,7 @@
 ! Current revisions:
 ! -----------------
-! 
+! Adjust input of dynamic driver according to revised Inifor version. 
+! Replace simulated_time by time_since_reference_point.
+! Rename variables in mesoscale-offline nesting mode.
 ! 
 ! Former revisions:
@@ -199,5 +201,5 @@
 !-- Define data type for nesting in larger-scale models like COSMO.
 !-- Data type comprises u, v, w, pt, and q at lateral and top boundaries.
-    TYPE force_type
+    TYPE nest_offl_type
 
        CHARACTER(LEN=100), DIMENSION(:), ALLOCATABLE ::  var_names
@@ -206,9 +208,8 @@
        INTEGER(iwp) ::  nzu    !< number of vertical levels on scalar grid in dynamic input file
        INTEGER(iwp) ::  nzw    !< number of vertical levels on w grid in dynamic input file
-       INTEGER(iwp) ::  tind   !< time index for reference time in large-scale forcing data
-       INTEGER(iwp) ::  tind_p !< time index for following time in large-scale forcing data
+       INTEGER(iwp) ::  tind   !< time index for reference time in mesoscale-offline nesting
+       INTEGER(iwp) ::  tind_p !< time index for following time in mesoscale-offline nesting
 
        LOGICAL      ::  init         = .FALSE.
-       LOGICAL      ::  interpolated = .FALSE.
        LOGICAL      ::  from_file    = .FALSE.
 
@@ -251,5 +252,5 @@
        REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  pt_top   !< potentital temperautre at top boundary
 
-    END TYPE force_type
+    END TYPE nest_offl_type
 
     TYPE init_type
@@ -474,5 +475,5 @@
     TYPE(dims_xy)    ::  dim_static  !< data structure for x, y-dimension in static input file
 
-    TYPE(force_type) ::  force     !< data structure for data input at lateral and top boundaries (provided by Inifor)
+    TYPE(nest_offl_type) ::  nest_offl  !< data structure for data input at lateral and top boundaries (provided by Inifor)  
 
     TYPE(init_type) ::  init_3d    !< data structure for the initialization of the 3D flow and soil fields
@@ -606,7 +607,7 @@
 !-- Public variables
     PUBLIC albedo_pars_f, albedo_type_f, basal_area_density_f, buildings_f,    &
-           building_id_f, building_pars_f, building_type_f, force, init_3d,    &
+           building_id_f, building_pars_f, building_type_f, init_3d,           &
            init_model, input_file_static, input_pids_static,                   &
-           input_pids_dynamic, leaf_area_density_f,                            &
+           input_pids_dynamic, leaf_area_density_f, nest_offl,                 &
            pavement_pars_f, pavement_subsurface_pars_f, pavement_type_f,       &
            root_area_density_lad_f, root_area_density_lsm_f, soil_pars_f,      &
@@ -719,5 +720,5 @@
 !--    sun-zenith angles. To avoid this, longitude and latitude in each model
 !--    domain will be set to the values of the root model. Please note, this
-!--    synchronization is required already here.
+!--    synchronization is required already here. 
 #if defined( __parallel )
        CALL MPI_BCAST( init_model%latitude,  1, MPI_REAL, 0,                   &
@@ -726,5 +727,4 @@
                        MPI_COMM_WORLD, ierr )
 #endif
-
 
     END SUBROUTINE netcdf_data_input_init
@@ -2057,9 +2057,9 @@
 
        USE arrays_3d,                                                          &
-           ONLY:  q, pt, u, v, w
+           ONLY:  q, pt, u, v, w, zu, zw
 
        USE control_parameters,                                                 &
-           ONLY:  bc_lr_cyc, bc_ns_cyc, forcing, humidity, land_surface,       &
-                  message_string, neutral, surface_pressure
+           ONLY:  bc_lr_cyc, bc_ns_cyc, humidity, land_surface, message_string,&
+                  nesting_offline, neutral, surface_pressure
 
        USE indices,                                                            &
@@ -2119,5 +2119,5 @@
        CALL get_dimension_length( id_dynamic, init_3d%nzu, 'z'     )
        CALL get_dimension_length( id_dynamic, init_3d%nzw, 'zw'    )
-       CALL get_dimension_length( id_dynamic, init_3d%nzs, 'depth' )
+       CALL get_dimension_length( id_dynamic, init_3d%nzs, 'zsoil' )
 !
 !--    Read also the horizontal dimensions. These are used just used fo
@@ -2142,5 +2142,5 @@
        ENDIF
 
-       IF ( init_3d%nzu-1 /= nz )  THEN
+       IF ( init_3d%nzu /= nz )  THEN
           message_string = 'Number of inifor vertical grid points ' //         &
                            'does not match the number of numeric grid '//      &
@@ -2159,28 +2159,51 @@
           CALL get_variable( id_dynamic, 'zw', init_3d%zw_atmos )
        ENDIF
-       IF ( check_existence( var_names, 'depth' ) )  THEN
+       IF ( check_existence( var_names, 'zsoil' ) )  THEN
           ALLOCATE( init_3d%z_soil(1:init_3d%nzs) )
-          CALL get_variable( id_dynamic, 'depth', init_3d%z_soil )
-       ENDIF
-!
-!--    Read initial geostrophic wind components at t = 0 (index 1 in file).
-!        IF ( check_existence( var_names, 'tend_ug' ) )  THEN
+          CALL get_variable( id_dynamic, 'zsoil', init_3d%z_soil )
+       ENDIF
+!
+!--    Check for consistency between vertical coordinates in dynamic 
+!--    driver and numeric grid. 
+!--    Please note, depending on compiler options both may be 
+!--    equal up to a certain threshold, and differences between
+!--    the numeric grid and vertical coordinate in the driver can built-
+!--    up to 10E-1-10E-0 m. For this reason, the check is performed not
+!--    for exactly matching values. 
+       IF ( ANY( ABS( zu(1:nzt)   - init_3d%zu_atmos(1:init_3d%nzu) )    &
+                      > 10E-1 )  .OR.                                    &
+            ANY( ABS( zw(1:nzt-1) - init_3d%zw_atmos(1:init_3d%nzw) )    &
+                      > 10E-1 ) )  THEN
+          message_string = 'Vertical grid in dynamic driver does not '// &
+                           'match the numeric grid.'
+          CALL message( 'netcdf_data_input_mod', 'NDI003', 1, 2, 0, 6, 0 )
+       ENDIF
+!
+!--    Read initial geostrophic wind components at 
+!--    t = 0 (index 1 in file). 
        IF ( check_existence( var_names, 'ls_forcing_ug' ) )  THEN
           ALLOCATE( init_3d%ug_init(nzb:nzt+1) )
-!           CALL get_variable_pr( id_dynamic, 'tend_ug', 1,                      &
-!                                 init_3d%ug_init )
-          CALL get_variable_pr( id_dynamic, 'ls_forcing_ug', 1,                &
-                                init_3d%ug_init )
+          init_3d%ug_init = 0.0_wp
+
+          CALL get_variable_pr( id_dynamic, 'ls_forcing_ug', 1,          &
+                                init_3d%ug_init(1:nzt) )
+!
+!--       Set top-boundary condition (Neumann)
+          init_3d%ug_init(nzt+1) = init_3d%ug_init(nzt)
+
           init_3d%from_file_ug = .TRUE.
        ELSE
           init_3d%from_file_ug = .FALSE.
        ENDIF
-!        IF ( check_existence( var_names, 'tend_vg' ) )  THEN
        IF ( check_existence( var_names, 'ls_forcing_vg' ) )  THEN
           ALLOCATE( init_3d%vg_init(nzb:nzt+1) )
-!           CALL get_variable_pr( id_dynamic, 'tend_vg', 1,                      &
-!                                 init_3d%vg_init )
-          CALL get_variable_pr( id_dynamic, 'ls_forcing_vg', 1,                &
-                                init_3d%vg_init )
+          init_3d%vg_init = 0.0_wp
+
+          CALL get_variable_pr( id_dynamic, 'ls_forcing_vg', 1,          &
+                                init_3d%vg_init(1:nzt) )
+!
+!--       Set top-boundary condition (Neumann)
+          init_3d%vg_init(nzt+1) = init_3d%vg_init(nzt)
+
           init_3d%from_file_vg = .TRUE.
        ELSE
@@ -2195,11 +2218,11 @@
 !--    into separate loops.  
 !--    Read u-component
-       IF ( check_existence( var_names, 'init_u' ) )  THEN
+       IF ( check_existence( var_names, 'init_atmosphere_u' ) )  THEN
 !
 !--       Read attributes for the fill value and level-of-detail
           CALL get_attribute( id_dynamic, char_fill, init_3d%fill_u,           &
-                              .FALSE., 'init_u' )
+                              .FALSE., 'init_atmosphere_u' )
           CALL get_attribute( id_dynamic, char_lod, init_3d%lod_u,             &
-                              .FALSE., 'init_u' )
+                              .FALSE., 'init_atmosphere_u' )
 !
 !--       level-of-detail 1 - read initialization profile
@@ -2208,15 +2231,28 @@
              init_3d%u_init = 0.0_wp
 
-             CALL get_variable( id_dynamic, 'init_u',                          &
-                                init_3d%u_init(nzb+1:nzt+1) )
+             CALL get_variable( id_dynamic, 'init_atmosphere_u',               &
+                                init_3d%u_init(nzb+1:nzt) )
+!
+!--          Set top-boundary condition (Neumann)
+             init_3d%u_init(nzt+1) = init_3d%u_init(nzt)
 !
 !--       level-of-detail 2 - read 3D initialization data
           ELSEIF ( init_3d%lod_u == 2 )  THEN
-
-             CALL get_variable( id_dynamic, 'init_u',                          &
-                                u(nzb+1:nzt+1,nys:nyn,nxlu:nxr),               &
+             CALL get_variable( id_dynamic, 'init_atmosphere_u',               &
+                                u(nzb+1:nzt,nys:nyn,nxlu:nxr),                 &
                                 nxlu, nys+1, nzb+1,                            &
                                 nxr-nxlu+1, nyn-nys+1, init_3d%nzu,            &
                                 dynamic_3d )
+!
+!--          Set value at leftmost model grid point nxl = 0. This is because
+!--          Inifor provides data only from 1:nx-1 since it assumes non-cyclic
+!--          conditions.
+             IF ( nxl == 0 )                                                   &
+                u(nzb+1:nzt,nys:nyn,nxl) = u(nzb+1:nzt,nys:nyn,nxlu)
+!
+!--          Set bottom and top-boundary
+             u(nzb,:,:)   = u(nzb+1,:,:)
+             u(nzt+1,:,:) = u(nzt,:,:)
+             
           ENDIF
           init_3d%from_file_u = .TRUE.
@@ -2224,11 +2260,11 @@
 !
 !--    Read v-component
-       IF ( check_existence( var_names, 'init_v' ) )  THEN
+       IF ( check_existence( var_names, 'init_atmosphere_v' ) )  THEN
 !
 !--       Read attributes for the fill value and level-of-detail
           CALL get_attribute( id_dynamic, char_fill, init_3d%fill_v,           &
-                              .FALSE., 'init_v' )
+                              .FALSE., 'init_atmosphere_v' )
           CALL get_attribute( id_dynamic, char_lod, init_3d%lod_v,             &
-                              .FALSE., 'init_v' )
+                              .FALSE., 'init_atmosphere_v' )
 !
 !--       level-of-detail 1 - read initialization profile
@@ -2237,16 +2273,28 @@
              init_3d%v_init = 0.0_wp
 
-             CALL get_variable( id_dynamic, 'init_v',                          &
-                                init_3d%v_init(nzb+1:nzt+1) )
-
+             CALL get_variable( id_dynamic, 'init_atmosphere_v',               &
+                                init_3d%v_init(nzb+1:nzt) )
+!
+!--          Set top-boundary condition (Neumann)
+             init_3d%v_init(nzt+1) = init_3d%v_init(nzt)
 !
 !--       level-of-detail 2 - read 3D initialization data
           ELSEIF ( init_3d%lod_v == 2 )  THEN
-
-             CALL get_variable( id_dynamic, 'init_v',                          &
-                                v(nzb+1:nzt+1,nysv:nyn,nxl:nxr),               &
+          
+             CALL get_variable( id_dynamic, 'init_atmosphere_v',               &
+                                v(nzb+1:nzt,nysv:nyn,nxl:nxr),                 &
                                 nxl+1, nysv, nzb+1,                            &
                                 nxr-nxl+1, nyn-nysv+1, init_3d%nzu,            &
                                 dynamic_3d )
+!
+!--          Set value at southmost model grid point nys = 0. This is because
+!--          Inifor provides data only from 1:ny-1 since it assumes non-cyclic
+!--          conditions.
+             IF ( nys == 0 )                                                   &
+                v(nzb+1:nzt,nys,nxl:nxr) = v(nzb+1:nzt,nysv,nxl:nxr)                                
+!
+!--          Set bottom and top-boundary
+             v(nzb,:,:)   = v(nzb+1,:,:)
+             v(nzt+1,:,:) = v(nzt,:,:)
              
           ENDIF
@@ -2255,11 +2303,11 @@
 !
 !--    Read w-component
-       IF ( check_existence( var_names, 'init_w' ) )  THEN
+       IF ( check_existence( var_names, 'init_atmosphere_w' ) )  THEN
 !
 !--       Read attributes for the fill value and level-of-detail
           CALL get_attribute( id_dynamic, char_fill, init_3d%fill_w,           &
-                              .FALSE., 'init_w' )
+                              .FALSE., 'init_atmosphere_w' )
           CALL get_attribute( id_dynamic, char_lod, init_3d%lod_w,             &
-                              .FALSE., 'init_w' )
+                              .FALSE., 'init_atmosphere_w' )
 !
 !--       level-of-detail 1 - read initialization profile
@@ -2268,16 +2316,23 @@
              init_3d%w_init = 0.0_wp
 
-             CALL get_variable( id_dynamic, 'init_w',                          &
-                                init_3d%w_init(nzb+1:nzt) )
-
+             CALL get_variable( id_dynamic, 'init_atmosphere_w',               &
+                                init_3d%w_init(nzb+1:nzt-1) )
+!
+!--          Set top-boundary condition (Neumann)
+             init_3d%w_init(nzt:nzt+1) = init_3d%w_init(nzt-1)
 !
 !--       level-of-detail 2 - read 3D initialization data
           ELSEIF ( init_3d%lod_w == 2 )  THEN
 
-             CALL get_variable( id_dynamic, 'init_w',                           &
-                                w(nzb+1:nzt,nys:nyn,nxl:nxr),                   &
+             CALL get_variable( id_dynamic, 'init_atmosphere_w',                &
+                                w(nzb+1:nzt-1,nys:nyn,nxl:nxr),                 &
                                 nxl+1, nys+1, nzb+1,                            &
                                 nxr-nxl+1, nyn-nys+1, init_3d%nzw,              &
                                 dynamic_3d )
+!
+!--          Set bottom and top-boundary                                
+             w(nzb,:,:)   = 0.0_wp  
+             w(nzt,:,:)   = w(nzt-1,:,:)
+             w(nzt+1,:,:) = w(nzt-1,:,:)
 
           ENDIF
@@ -2287,11 +2342,11 @@
 !--    Read potential temperature
        IF ( .NOT. neutral )  THEN
-          IF ( check_existence( var_names, 'init_pt' ) )  THEN
+          IF ( check_existence( var_names, 'init_atmosphere_pt' ) )  THEN
 !
 !--          Read attributes for the fill value and level-of-detail
              CALL get_attribute( id_dynamic, char_fill, init_3d%fill_pt,       &
-                                 .FALSE., 'init_pt' )
+                                 .FALSE., 'init_atmosphere_pt' )
              CALL get_attribute( id_dynamic, char_lod, init_3d%lod_pt,         &
-                                 .FALSE., 'init_pt' )
+                                 .FALSE., 'init_atmosphere_pt' )
 !
 !--          level-of-detail 1 - read initialization profile
@@ -2299,19 +2354,25 @@
                 ALLOCATE( init_3d%pt_init(nzb:nzt+1) )
 
-                CALL get_variable( id_dynamic, 'init_pt',                      &
-                                   init_3d%pt_init(nzb+1:nzt+1) )
-!
-!--             Set Neumann surface boundary condition for initial profil
-                init_3d%pt_init(nzb) = init_3d%pt_init(nzb+1)
+                CALL get_variable( id_dynamic, 'init_atmosphere_pt',           &
+                                   init_3d%pt_init(nzb+1:nzt) )
+!
+!--             Set Neumann top and surface boundary condition for initial 
+!--             profil
+                init_3d%pt_init(nzb)   = init_3d%pt_init(nzb+1)
+                init_3d%pt_init(nzt+1) = init_3d%pt_init(nzt)
 !
 !--          level-of-detail 2 - read 3D initialization data
              ELSEIF ( init_3d%lod_pt == 2 )  THEN
 
-                CALL get_variable( id_dynamic, 'init_pt',                      &
-                                   pt(nzb+1:nzt+1,nys:nyn,nxl:nxr),            &
+                CALL get_variable( id_dynamic, 'init_atmosphere_pt',           &
+                                   pt(nzb+1:nzt,nys:nyn,nxl:nxr),              &
                                    nxl+1, nys+1, nzb+1,                        &
                                    nxr-nxl+1, nyn-nys+1, init_3d%nzu,          &
                                    dynamic_3d )
-
+                                   
+!
+!--             Set bottom and top-boundary
+                pt(nzb,:,:)   = pt(nzb+1,:,:)
+                pt(nzt+1,:,:) = pt(nzt,:,:)             
 
              ENDIF
@@ -2322,11 +2383,11 @@
 !--    Read mixing ratio
        IF ( humidity )  THEN
-          IF ( check_existence( var_names, 'init_qv' ) )  THEN
+          IF ( check_existence( var_names, 'init_atmosphere_qv' ) )  THEN
 !
 !--          Read attributes for the fill value and level-of-detail
              CALL get_attribute( id_dynamic, char_fill, init_3d%fill_q,        &
-                                 .FALSE., 'init_qv' )
+                                 .FALSE., 'init_atmosphere_qv' )
              CALL get_attribute( id_dynamic, char_lod, init_3d%lod_q,          &
-                                 .FALSE., 'init_qv' )
+                                 .FALSE., 'init_atmosphere_qv' )
 !
 !--          level-of-detail 1 - read initialization profile
@@ -2334,22 +2395,25 @@
                 ALLOCATE( init_3d%q_init(nzb:nzt+1) )
 
-                CALL get_variable( id_dynamic, 'init_qv',                      &
-                                   init_3d%q_init(nzb+1:nzt+1) )
-!
-!--             Set Neumann surface boundary condition for initial profil
-                init_3d%q_init(nzb) = init_3d%q_init(nzb+1)
-
+                CALL get_variable( id_dynamic, 'init_atmosphere_qv',           &
+                                    init_3d%q_init(nzb+1:nzt) )
+!
+!--             Set bottom and top boundary condition (Neumann)
+                init_3d%q_init(nzb)   = init_3d%q_init(nzb+1)
+                init_3d%q_init(nzt+1) = init_3d%q_init(nzt)
 !
 !--          level-of-detail 2 - read 3D initialization data
              ELSEIF ( init_3d%lod_q == 2 )  THEN
              
-                CALL get_variable( id_dynamic, 'init_qv',                      &
-                                   q(nzb+1:nzt+1,nys:nyn,nxl:nxr),             &
+                CALL get_variable( id_dynamic, 'init_atmosphere_qv',           &
+                                   q(nzb+1:nzt,nys:nyn,nxl:nxr),               &
                                    nxl+1, nys+1, nzb+1,                        &
                                    nxr-nxl+1, nyn-nys+1, init_3d%nzu,          &
                                    dynamic_3d )
-
-
-
+                                   
+!
+!--             Set bottom and top-boundary
+                q(nzb,:,:)   = q(nzb+1,:,:)
+                q(nzt+1,:,:) = q(nzt,:,:)
+                
              ENDIF
              init_3d%from_file_q = .TRUE.
@@ -2382,6 +2446,6 @@
 
                CALL get_variable( id_dynamic, 'init_soil_m',                   &   
-                                  init_3d%msoil(0:init_3d%nzs-1,nys:nyn,nxl:nxr),&
-                                  nxl, nxr, nys, nyn, 0, init_3d%nzs-1 )
+                                init_3d%msoil(0:init_3d%nzs-1,nys:nyn,nxl:nxr),&
+                                nxl, nxr, nys, nyn, 0, init_3d%nzs-1 )
 
              ENDIF
@@ -2413,6 +2477,6 @@
                 
                 CALL get_variable( id_dynamic, 'init_soil_t',                  &   
-                                  init_3d%tsoil(0:init_3d%nzs-1,nys:nyn,nxl:nxr),&
-                                  nxl, nxr, nys, nyn, 0, init_3d%nzs-1 )
+                                init_3d%tsoil(0:init_3d%nzs-1,nys:nyn,nxl:nxr),&
+                                nxl, nxr, nys, nyn, 0, init_3d%nzs-1 )
              ENDIF
              init_3d%from_file_tsoil = .TRUE.
@@ -2439,6 +2503,6 @@
           ENDIF
           IF ( .NOT. check_passed )  THEN
-             message_string = 'NetCDF input for u_init must not contain ' //   &
-                              'any _FillValues'
+             message_string = 'NetCDF input for init_atmosphere_u must ' //    &
+                              'not contain any _FillValues'
              CALL message( 'netcdf_data_input_mod', 'NDI004', 2, 2, 0, 6, 0 )
           ENDIF
@@ -2455,6 +2519,6 @@
           ENDIF
           IF ( .NOT. check_passed )  THEN
-             message_string = 'NetCDF input for v_init must not contain ' //   &
-                              'any _FillValues'
+             message_string = 'NetCDF input for init_atmosphere_v must ' //    &
+                              'not contain any _FillValues'
              CALL message( 'netcdf_data_input_mod', 'NDI005', 2, 2, 0, 6, 0 )
           ENDIF
@@ -2471,6 +2535,6 @@
           ENDIF
           IF ( .NOT. check_passed )  THEN
-             message_string = 'NetCDF input for w_init must not contain ' //   &
-                              'any _FillValues'
+             message_string = 'NetCDF input for init_atmosphere_w must ' //    &
+                              'not contain any _FillValues'
              CALL message( 'netcdf_data_input_mod', 'NDI006', 2, 2, 0, 6, 0 )
           ENDIF
@@ -2487,6 +2551,6 @@
           ENDIF
           IF ( .NOT. check_passed )  THEN
-             message_string = 'NetCDF input for pt_init must not contain ' //  &
-                              'any _FillValues'
+             message_string = 'NetCDF input for init_atmosphere_pt must ' //   &
+                              'not contain any _FillValues'
              CALL message( 'netcdf_data_input_mod', 'NDI007', 2, 2, 0, 6, 0 )
           ENDIF
@@ -2503,6 +2567,6 @@
           ENDIF
           IF ( .NOT. check_passed )  THEN
-             message_string = 'NetCDF input for q_init must not contain ' //   &
-                              'any _FillValues'
+             message_string = 'NetCDF input for init_atmosphere_q must ' //    &
+                              'not contain any _FillValues'
              CALL message( 'netcdf_data_input_mod', 'NDI008', 2, 2, 0, 6, 0 )
           ENDIF
@@ -2524,8 +2588,8 @@
 
        USE control_parameters,                                                 &
-           ONLY:  bc_lr_cyc, bc_ns_cyc, force_bound_l, force_bound_n,          &
-                  force_bound_r, force_bound_s,                                &
-                  forcing, humidity, message_string, neutral, simulated_time
-
+           ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,              &
+                  bc_dirichlet_s, bc_lr_cyc, bc_ns_cyc, humidity,              &
+                  message_string, neutral, nesting_offline,                    &
+                  time_since_reference_point
 
        USE indices,                                                            &
@@ -2533,6 +2597,4 @@
 
        IMPLICIT NONE
-
-       LOGICAL      ::  dynamic_3d = .TRUE. !< flag indicating that 3D data is read from dynamic file
        
        INTEGER(iwp) ::  i          !< running index along x-direction
@@ -2545,8 +2607,8 @@
        REAL(wp) ::  dum           !< dummy variable to skip columns while reading topography file
 
-       force%from_file = MERGE( .TRUE., .FALSE., input_pids_dynamic )
+       nest_offl%from_file = MERGE( .TRUE., .FALSE., input_pids_dynamic ) 
 !
 !--    Skip input if no forcing from larger-scale models is applied.
-       IF ( .NOT. forcing )  RETURN
+       IF ( .NOT. nesting_offline )  RETURN
 
 !
@@ -2560,6 +2622,6 @@
                             TRIM( coupling_char ), id_dynamic )
 !
-!--    Initialize INIFOR forcing.
-       IF ( .NOT. force%init )  THEN
+!--    Initialize INIFOR forcing. 
+       IF ( .NOT. nest_offl%init )  THEN
 !
 !--       At first, inquire all variable names.
@@ -2567,40 +2629,40 @@
 !
 !--       Allocate memory to store variable names.
-          ALLOCATE( force%var_names(1:num_vars) )
-          CALL inquire_variable_names( id_dynamic, force%var_names )
+          ALLOCATE( nest_offl%var_names(1:num_vars) )
+          CALL inquire_variable_names( id_dynamic, nest_offl%var_names )
 !
 !--       Read time dimension, allocate memory and finally read time array
-          CALL get_dimension_length( id_dynamic, force%nt, 'time' )
-
-          IF ( check_existence( force%var_names, 'time' ) )  THEN
-             ALLOCATE( force%time(0:force%nt-1) )
-             CALL get_variable( id_dynamic, 'time', force%time )
+          CALL get_dimension_length( id_dynamic, nest_offl%nt, 'time' )
+
+          IF ( check_existence( nest_offl%var_names, 'time' ) )  THEN
+             ALLOCATE( nest_offl%time(0:nest_offl%nt-1) )
+             CALL get_variable( id_dynamic, 'time', nest_offl%time )
           ENDIF
 !
 !--       Read vertical dimension of scalar und w grid
-          CALL get_dimension_length( id_dynamic, force%nzu, 'z' )
-          CALL get_dimension_length( id_dynamic, force%nzw, 'zw' )
-
-          IF ( check_existence( force%var_names, 'z' ) )  THEN
-             ALLOCATE( force%zu_atmos(1:force%nzu) )
-             CALL get_variable( id_dynamic, 'z', force%zu_atmos )
-          ENDIF
-          IF ( check_existence( force%var_names, 'zw' ) )  THEN
-             ALLOCATE( force%zw_atmos(1:force%nzw) )
-             CALL get_variable( id_dynamic, 'zw', force%zw_atmos )
+          CALL get_dimension_length( id_dynamic, nest_offl%nzu, 'z' )
+          CALL get_dimension_length( id_dynamic, nest_offl%nzw, 'zw' )
+
+          IF ( check_existence( nest_offl%var_names, 'z' ) )  THEN
+             ALLOCATE( nest_offl%zu_atmos(1:nest_offl%nzu) )
+             CALL get_variable( id_dynamic, 'z', nest_offl%zu_atmos )
+          ENDIF
+          IF ( check_existence( nest_offl%var_names, 'zw' ) )  THEN
+             ALLOCATE( nest_offl%zw_atmos(1:nest_offl%nzw) )
+             CALL get_variable( id_dynamic, 'zw', nest_offl%zw_atmos )
           ENDIF
 
 !
 !--       Read surface pressure
-          IF ( check_existence( force%var_names,                               &
-                            'surface_forcing_surface_pressure' ) )  THEN
-             ALLOCATE( force%surface_pressure(0:force%nt-1) )
+          IF ( check_existence( nest_offl%var_names,                           &
+                                'surface_forcing_surface_pressure' ) )  THEN
+             ALLOCATE( nest_offl%surface_pressure(0:nest_offl%nt-1) )
              CALL get_variable( id_dynamic,                                    &
                                 'surface_forcing_surface_pressure',            &
-                                force%surface_pressure )
+                                nest_offl%surface_pressure )
           ENDIF
 !
 !--       Set control flag to indicate that initialization is already done
-          force%init = .TRUE.
+          nest_offl%init = .TRUE.
 
        ENDIF
@@ -2610,20 +2672,21 @@
 !--    @todo: At the moment time, in INIFOR and simulated time correspond
 !--           to each other. If required, adjust to daytime.
-       force%tind = MINLOC( ABS( force%time - simulated_time ), DIM = 1 )      &
-                    - 1
-       force%tind_p = force%tind + 1       
+       nest_offl%tind = MINLOC( ABS( nest_offl%time -                          &
+                                     time_since_reference_point ), DIM = 1 )   &
+                        - 1
+       nest_offl%tind_p = nest_offl%tind + 1       
 !
 !--    Read geostrophic wind components. In case of forcing, this is only
 !--    required if cyclic boundary conditions are applied.
        IF ( bc_lr_cyc  .AND.  bc_ns_cyc )  THEN
-          DO  t = force%tind, force%tind_p
+          DO  t = nest_offl%tind, nest_offl%tind_p
 !              CALL get_variable_pr( id_dynamic, 'tend_ug', t+1,           &
-!                                    force%ug(t-force%tind,:) )
+!                                    nest_offl%ug(t-nest_offl%tind,:) )
 !              CALL get_variable_pr( id_dynamic, 'tend_vg', t+1,           &
-!                                    force%ug(t-force%tind,:) )
+!                                    nest_offl%ug(t-nest_offl%tind,:) )
              CALL get_variable_pr( id_dynamic, 'ls_forcing_ug', t+1,           &
-                                   force%ug(t-force%tind,:) )
+                                   nest_offl%ug(t-nest_offl%tind,:) )
              CALL get_variable_pr( id_dynamic, 'ls_forcing_vg', t+1,           &
-                                   force%ug(t-force%tind,:) )
+                                   nest_offl%ug(t-nest_offl%tind,:) )
           ENDDO
        ENDIF
@@ -2633,153 +2696,159 @@
 !--    For the v-component, the data starts at nysv, while for the other
 !--    quantities the data starts at nys. This is equivalent at the north
-!--    and south domain boundary for the u-component.
-       IF ( force_bound_l )  THEN
+!--    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',                  &
-                           force%u_left(0:1,nzb+1:nzt+1,nys:nyn),              &
-                           nys+1, nzb+1, force%tind+1,                         &
-                           nyn-nys+1, force%nzu, 2, dynamic_3d )
-          
+                           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. )
+      
           CALL get_variable( id_dynamic, 'ls_forcing_left_v',                  &
-                           force%v_left(0:1,nzb+1:nzt+1,nysv:nyn),             &
-                           nysv, nzb+1, force%tind+1,                          &
-                           nyn-nysv+1, force%nzu, 2, dynamic_3d )
+                           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',                  &
-                           force%w_left(0:1,nzb+1:nzt,nys:nyn),                &
-                           nys+1, nzb+1, force%tind+1,                         &
-                           nyn-nys+1, force%nzw, 2, dynamic_3d )
+                           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',              &
-                           force%pt_left(0:1,nzb+1:nzt+1,nys:nyn),             &
-                           nys+1, nzb+1, force%tind+1,                         &
-                           nyn-nys+1, force%nzu, 2, dynamic_3d )
-          ENDIF
+                           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',              &
-                           force%q_left(0:1,nzb+1:nzt+1,nys:nyn),              &
-                           nys+1, nzb+1, force%tind+1,                         &
-                           nyn-nys+1, force%nzu, 2, dynamic_3d )
-          ENDIF
-       ENDIF
-
-       IF ( force_bound_r )  THEN
+                           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
+
+       ENDIF
+
+       IF ( bc_dirichlet_r )  THEN
           CALL get_variable( id_dynamic, 'ls_forcing_right_u',                 &
-                           force%u_right(0:1,nzb+1:nzt+1,nys:nyn),             &
-                           nys+1, nzb+1, force%tind+1,                         &
-                           nyn-nys+1, force%nzu, 2, dynamic_3d )
+                           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',                 &
-                           force%v_right(0:1,nzb+1:nzt+1,nysv:nyn),            &
-                           nysv, nzb+1, force%tind+1,                          &
-                           nyn-nysv+1, force%nzu, 2, dynamic_3d )
+                           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',                 &
-                           force%w_right(0:1,nzb+1:nzt,nys:nyn),               &
-                           nys+1, nzb+1, force%tind+1,                         &
-                           nyn-nys+1, force%nzw, 2, dynamic_3d )
+                           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',             &
-                           force%pt_right(0:1,nzb+1:nzt+1,nys:nyn),            &
-                           nys+1, nzb+1, force%tind+1,                         &
-                           nyn-nys+1, force%nzu, 2, dynamic_3d )
+                           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',             &
-                           force%q_right(0:1,nzb+1:nzt+1,nys:nyn),             &
-                           nys+1, nzb+1, force%tind+1,                         &
-                           nyn-nys+1, force%nzu, 2, dynamic_3d )
-          ENDIF
-       ENDIF
-
-       IF ( force_bound_n )  THEN
+                           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
+       ENDIF
+
+       IF ( bc_dirichlet_n )  THEN
        
           CALL get_variable( id_dynamic, 'ls_forcing_north_u',                 &
-                           force%u_north(0:1,nzb+1:nzt+1,nxlu:nxr),            &
-                           nxlu, nzb+1, force%tind+1,                          &
-                           nxr-nxlu+1, force%nzu, 2, dynamic_3d )
-
+                           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',                 &
-                           force%v_north(0:1,nzb+1:nzt+1,nxl:nxr),             &
-                           nxl+1, nzb+1, force%tind+1,                         &
-                           nxr-nxl+1, force%nzu, 2, dynamic_3d )
+                           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',                 &
-                           force%w_north(0:1,nzb+1:nzt,nxl:nxr),               &
-                           nxl+1, nzb+1, force%tind+1,                         &
-                           nxr-nxl+1, force%nzw, 2, dynamic_3d )
+                           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',             &
-                           force%pt_north(0:1,nzb+1:nzt+1,nxl:nxr),            &
-                           nxl+1, nzb+1, force%tind+1,                         &
-                           nxr-nxl+1, force%nzu, 2, dynamic_3d )
+                           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',             &
-                           force%q_north(0:1,nzb+1:nzt+1,nxl:nxr),             &
-                           nxl+1, nzb+1, force%tind+1,                         &
-                           nxr-nxl+1, force%nzu, 2, dynamic_3d )
-          ENDIF
-       ENDIF
-
-       IF ( force_bound_s )  THEN
+                           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
+       ENDIF
+
+       IF ( bc_dirichlet_s )  THEN
           CALL get_variable( id_dynamic, 'ls_forcing_south_u',                 &
-                           force%u_south(0:1,nzb+1:nzt+1,nxlu:nxr),            &
-                           nxlu, nzb+1, force%tind+1,                          &
-                           nxr-nxlu+1, force%nzu, 2, dynamic_3d )
+                           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',                 &
-                           force%v_south(0:1,nzb+1:nzt+1,nxl:nxr),             &
-                           nxl+1, nzb+1, force%tind+1,                         &
-                           nxr-nxl+1, force%nzu, 2, dynamic_3d )
+                           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',                 &
-                           force%w_south(0:1,nzb+1:nzt,nxl:nxr),               &
-                           nxl+1, nzb+1, force%tind+1,                         &
-                           nxr-nxl+1, force%nzw, 2, dynamic_3d )
+                           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',             &
-                           force%pt_south(0:1,nzb+1:nzt+1,nxl:nxr),            &
-                           nxl+1, nzb+1, force%tind+1,                         &
-                           nxr-nxl+1, force%nzu, 2, dynamic_3d )
+                           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',             &
-                           force%q_south(0:1,nzb+1:nzt+1,nxl:nxr),             &
-                           nxl+1, nzb+1, force%tind+1,                         &
-                           nxr-nxl+1, force%nzu, 2, dynamic_3d )
-          ENDIF
-       ENDIF
+                           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
+       ENDIF
+
 !
 !--    Top boundary
        CALL get_variable( id_dynamic, 'ls_forcing_top_u',                      &
-                             force%u_top(0:1,nys:nyn,nxlu:nxr),                &
-                             nxlu, nys+1, force%tind+1,                        &
-                             nxr-nxlu+1, nyn-nys+1, 2, dynamic_3d )
+                             nest_offl%u_top(0:1,nys:nyn,nxlu:nxr),            &
+                             nxlu, nys+1, nest_offl%tind+1,                    &
+                             nxr-nxlu+1, nyn-nys+1, 2, .TRUE. )
 
        CALL get_variable( id_dynamic, 'ls_forcing_top_v',                      &
-                             force%v_top(0:1,nysv:nyn,nxl:nxr),                &
-                             nxl+1, nysv, force%tind+1,                        &
-                             nxr-nxl+1, nyn-nysv+1, 2, dynamic_3d )
+                             nest_offl%v_top(0:1,nysv:nyn,nxl:nxr),            &
+                             nxl+1, nysv, nest_offl%tind+1,                    &
+                             nxr-nxl+1, nyn-nysv+1, 2, .TRUE. )
                              
        CALL get_variable( id_dynamic, 'ls_forcing_top_w',                      &
-                             force%w_top(0:1,nys:nyn,nxl:nxr),                 &
-                             nxl+1, nys+1, force%tind+1,                       &
-                             nxr-nxl+1, nyn-nys+1, 2, dynamic_3d )
+                             nest_offl%w_top(0:1,nys:nyn,nxl:nxr),             &
+                             nxl+1, nys+1, nest_offl%tind+1,                   &
+                             nxr-nxl+1, nyn-nys+1, 2, .TRUE. )
                              
        IF ( .NOT. neutral )  THEN
           CALL get_variable( id_dynamic, 'ls_forcing_top_pt',                  &
-                                force%pt_top(0:1,nys:nyn,nxl:nxr),             &
-                                nxl+1, nys+1, force%tind+1,                    &
-                                nxr-nxl+1, nyn-nys+1, 2, dynamic_3d )
+                                nest_offl%pt_top(0:1,nys:nyn,nxl:nxr),         &
+                                nxl+1, nys+1, nest_offl%tind+1,                &
+                                nxr-nxl+1, nyn-nys+1, 2, .TRUE. )
        ENDIF
        IF ( humidity )  THEN
           CALL get_variable( id_dynamic, 'ls_forcing_top_qv',                  &
-                                force%q_top(0:1,nys:nyn,nxl:nxr),              &
-                                nxl+1, nys+1, force%tind+1,                    &
-                                nxr-nxl+1, nyn-nys+1, 2, dynamic_3d )
+                                nest_offl%q_top(0:1,nys:nyn,nxl:nxr),          &
+                                nxl+1, nys+1, nest_offl%tind+1,                &
+                                nxr-nxl+1, nyn-nys+1, 2, .TRUE. )
        ENDIF
 
@@ -2792,11 +2861,4 @@
        CALL cpu_log( log_point_s(86), 'NetCDF input forcing', 'stop' )
 
-!
-!--    Finally, after data input set control flag indicating that vertical
-!--    inter- and/or extrapolation is required.
-!--    Please note, inter/extrapolation of INIFOR data is only a workaroud,
-!--    as long as INIFOR delivers vertically equidistant data.
-       force%interpolated = .FALSE.
-
     END SUBROUTINE netcdf_data_input_lsf
 
@@ -2810,5 +2872,5 @@
 
        USE control_parameters,                                                 &
-           ONLY:  initializing_actions, forcing, message_string
+           ONLY:  initializing_actions, message_string, nesting_offline 
 
        IMPLICIT NONE
@@ -2816,6 +2878,7 @@
 !
 !--    In case of forcing, check whether dynamic input file is present
-       IF ( .NOT. input_pids_dynamic  .AND.  forcing )  THEN
-          message_string = 'forcing = .TRUE. requires dynamic input file ' //  &
+       IF ( .NOT. input_pids_dynamic  .AND.  nesting_offline  )  THEN
+          message_string = 'nesting_offline = .TRUE. requires dynamic '  //    &
+                            'input file ' //                                   &
                             TRIM( input_file_dynamic ) // TRIM( coupling_char )
           CALL message( 'netcdf_data_input_mod', 'NDI009', 1, 2, 0, 6, 0 )
@@ -4514,5 +4577,7 @@
 !------------------------------------------------------------------------------!
     SUBROUTINE get_variable_3d_real_dynamic( id, variable_name, var,           &
-                            i1s, i2s, i3s, count_1, count_2, count_3, dynamic)
+                                             i1s, i2s, i3s,                    &
+                                             count_1, count_2, count_3,        &
+                                             par_access )
                                 
        USE indices
@@ -4523,5 +4588,5 @@
        CHARACTER(LEN=*)              ::  variable_name   !< variable name
 
-       LOGICAL                       ::  dynamic         !< additional flag just used to select correct overloaded routine from interface block 
+       LOGICAL                       ::  par_access      !< additional flag indicating whether parallel read operations should be performed or not 
        
        INTEGER(iwp)                  ::  count_1         !< number of elements to be read along 1st dimension (with respect to file)
@@ -4550,10 +4615,14 @@
 #if defined( __netcdf )
 !
-!--    Inquire variable id
+!--    Inquire variable id.
        nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var )
 !
 !--    Check for collective read-operation and set respective NetCDF flags if
 !--    required. 
-       IF ( collective_read )  THEN
+!--    Please note, in contrast to the other input routines where each PEs 
+!--    reads its subdomain data, dynamic input data not by all PEs, only
+!--    by those which encompass lateral model boundaries. Hence, collective
+!--    read operations are only enabled for top-boundary data.
+       IF ( collective_read  .AND.  par_access )  THEN
           nc_stat = NF90_VAR_PAR_ACCESS (id, id_var, NF90_COLLECTIVE)
        ENDIF    
Index: palm/trunk/SOURCE/palm.f90
===================================================================
--- palm/trunk/SOURCE/palm.f90	(revision 3178)
+++ palm/trunk/SOURCE/palm.f90	(revision 3182)
@@ -238,9 +238,10 @@
     USE control_parameters,                                                    &
         ONLY:  air_chemistry,                                                  &
-               cloud_physics, constant_diffusion, coupling_char, coupling_mode,&
+               cloud_physics, constant_diffusion, child_domain, coupling_char, &
+               coupling_mode,                                                  &
                do2d_at_begin, do3d_at_begin, humidity, initializing_actions,   &
                io_blocks, io_group, large_scale_forcing,                       &
                message_string, microphysics_morrison, microphysics_seifert,    &
-               nest_domain, neutral, nudging, passive_scalar, runnr,           &
+               neutral, nudging, passive_scalar, runnr,                        &
                simulated_time, simulated_time_chr, spinup,                     &
                time_since_reference_point,                                     &
@@ -428,5 +429,5 @@
 !
 !--    Exchange_horiz is needed after the nest initialization
-          IF ( nest_domain )  THEN
+          IF ( child_domain )  THEN
              CALL exchange_horiz( u, nbgp )
              CALL exchange_horiz( v, nbgp )
Index: palm/trunk/SOURCE/parin.f90
===================================================================
--- palm/trunk/SOURCE/parin.f90	(revision 3178)
+++ palm/trunk/SOURCE/parin.f90	(revision 3182)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Rename variables and boundary conditions in mesoscale-offline nesting mode
 ! 
 ! Former revisions:
@@ -529,5 +529,5 @@
              dz_stretch_factor, dz_stretch_level, dz_stretch_level_start,      &
              dz_stretch_level_end, end_time_1d, ensemble_member_nr, e_init,    &
-             e_min, fft_method, flux_input_mode, flux_output_mode, forcing,    &
+             e_min, fft_method, flux_input_mode, flux_output_mode,             &
              galilei_transformation, humidity,                                 &
              inflow_damping_height, inflow_damping_width,                      &
@@ -538,5 +538,6 @@
              loop_optimization, lsf_exception, masking_method, mg_cycles,      &
              mg_switch_to_pe0_level, mixing_length_1d, momentum_advec,         &
-             most_method, na_init, nc_const, netcdf_precision, neutral, ngsrb, &
+             most_method, na_init, nc_const, nesting_offline,                  &
+             netcdf_precision, neutral, ngsrb,                                 &
              nsor, nsor_ini, nudging, nx, ny, nz, ocean, omega, omega_sor,     &
              outflow_source_plane, passive_scalar,                             &
@@ -601,5 +602,5 @@
              dz_stretch_factor, dz_stretch_level, dz_stretch_level_start,      &
              dz_stretch_level_end, end_time_1d, ensemble_member_nr, e_init,    &
-             e_min, fft_method, flux_input_mode, flux_output_mode, forcing,    &
+             e_min, fft_method, flux_input_mode, flux_output_mode,             &
              galilei_transformation, humidity,                                 &
              inflow_damping_height, inflow_damping_width,                      &
@@ -610,5 +611,6 @@
              loop_optimization, lsf_exception, masking_method, mg_cycles,      &
              mg_switch_to_pe0_level, mixing_length_1d, momentum_advec,         &
-             most_method, na_init, nc_const, netcdf_precision, neutral, ngsrb, &
+             most_method, na_init, nc_const, nesting_offline,                  &
+             netcdf_precision, neutral, ngsrb,                                 &
              nsor, nsor_ini, nudging, nx, ny, nz, ocean, omega, omega_sor,     &
              outflow_source_plane, passive_scalar,                             &
@@ -924,5 +926,5 @@
                    bc_ns   = 'cyclic'
                 ENDIF
-                IF ( nest_domain )  THEN
+                IF ( child_domain )  THEN
                    bc_uv_t  = 'nested'
                    bc_pt_t  = 'nested'
@@ -936,5 +938,5 @@
 !--          nested domains.
              ELSE 
-                IF ( nest_domain )  THEN
+                IF ( child_domain )  THEN
                    bc_lr    = 'nested'
                    bc_ns    = 'nested'
@@ -948,13 +950,15 @@
              ENDIF
           ENDIF
-
-          IF ( forcing )  THEN
-             bc_lr    = 'forcing'
-             bc_ns    = 'forcing'
-             bc_uv_t  = 'forcing'
-             bc_pt_t  = 'forcing'
-             bc_q_t   = 'forcing'
-             bc_s_t   = 'forcing'  ! scalar boundary condition is not clear
-             bc_cs_t  = 'forcing'  ! same for chemical species
+!
+!--       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
+             bc_cs_t  = 'nesting_offline'  ! same for chemical species
              bc_p_t   = 'neumann'
           ENDIF
@@ -968,5 +972,5 @@
 !--       are set properly. An exception is made in case of restart runs and
 !--       if user decides to do everything by its own.
-          IF ( nest_domain  .AND.  .NOT. (                                     &
+          IF ( child_domain  .AND.  .NOT. (                                    &
                TRIM( initializing_actions ) == 'read_restart_data'      .OR.   &
                TRIM( initializing_actions ) == 'set_constant_profiles'  .OR.   &
@@ -979,6 +983,5 @@
 
              initializing_actions = 'set_constant_profiles'
-          ENDIF
-            
+          ENDIF            
 !
 !--       Check validity of lateral boundary conditions. This has to be done
@@ -987,5 +990,5 @@
           IF ( bc_lr /= 'cyclic'  .AND.  bc_lr /= 'dirichlet/radiation'  .AND. &
                bc_lr /= 'radiation/dirichlet'  .AND.  bc_lr /= 'nested'  .AND. &
-               bc_lr /= 'forcing' )  THEN
+               bc_lr /= 'nesting_offline' )  THEN
              message_string = 'unknown boundary condition: bc_lr = "' // &
                               TRIM( bc_lr ) // '"'
@@ -994,5 +997,5 @@
           IF ( bc_ns /= 'cyclic'  .AND.  bc_ns /= 'dirichlet/radiation'  .AND. &
                bc_ns /= 'radiation/dirichlet'  .AND.  bc_ns /= 'nested'  .AND. &
-               bc_ns /= 'forcing' )  THEN
+               bc_ns /= 'nesting_offline' )  THEN
              message_string = 'unknown boundary condition: bc_ns = "' // &
                               TRIM( bc_ns ) // '"'
Index: palm/trunk/SOURCE/pmc_interface_mod.f90
===================================================================
--- palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 3178)
+++ palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 3182)
@@ -20,5 +20,6 @@
 ! Current revisions:
 ! ------------------
-! 
+! Variable names for nest_bound_x replaced by bc_dirichlet_x.
+! Remove commented prints into debug files.
 ! 
 ! Former revisions:
@@ -306,15 +307,15 @@
    USE arrays_3d,                                                              &
         ONLY:  diss, diss_2, dzu, dzw, e, e_p, e_2, nc, nc_2, nc_p, nr, nr_2,  &
-               pt, pt_2, q, q_2, qc, qc_2, qr, qr_2, s, s_2,                       &
+               pt, pt_2, q, q_2, qc, qc_2, qr, qr_2, s, s_2,                   &
                u, u_p, u_2, v, v_p, v_2, w, w_p, w_2, zu, zw
 #endif
 
     USE control_parameters,                                                    &
-        ONLY:  air_chemistry, cloud_physics,                                   &
+        ONLY:  air_chemistry, bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,  &
+               bc_dirichlet_s, cloud_physics, child_domain,                    &
                constant_diffusion, constant_flux_layer,                        &
                coupling_char, dt_3d, dz, humidity, message_string,             &
                microphysics_morrison, microphysics_seifert,                    &
-               nest_bound_l, nest_bound_r, nest_bound_s, nest_bound_n,         &
-               nest_domain, neutral, passive_scalar, rans_mode, rans_tke_e,    &
+               neutral, passive_scalar, rans_mode, rans_tke_e,                 &
                roughness_length, simulated_time, topography, volume_flow
 
@@ -743,5 +744,5 @@
 !-- course the root domain (cpl_id = 1) is not nested)
     IF ( cpl_id >= 2 )  THEN
-       nest_domain = .TRUE.
+       child_domain = .TRUE.
        WRITE( coupling_char, '(A2,I2.2)') '_N', cpl_id
     ENDIF
@@ -1192,14 +1193,4 @@
         childgrid(m)%uz_coord   = zmax_coarse(2)
         childgrid(m)%uz_coord_b = zmax_coarse(1)
-
-!         WRITE(9,*)                 'edge coordinates for child id ',child_id,m
-!         WRITE(9,*)                 'Number of Boundray cells lpm  ',nbgp_lpm
-!         WRITE(9,'(a,3i7,2f10.2)') ' model size                    ', nx_cl, ny_cl, nz_cl, dx_cl, dy_cl
-!          WRITE(9,'(a,5f10.2)')     ' model edge                    ', childgrid(m)%lx_coord,  &
-!                                childgrid(m)%rx_coord, childgrid(m)%sy_coord,                  &
-!                                childgrid(m)%ny_coord,childgrid(m)%uz_coord
-!          WRITE(9,'(a,4f10.2)')     ' model edge with Boundary      ', childgrid(m)%lx_coord_b,& 
-!                                childgrid(m)%rx_coord_b, childgrid(m)%sy_coord_b,              &
-!                                childgrid(m)%ny_coord_b
 
      END SUBROUTINE set_child_edge_coords
@@ -1714,5 +1705,5 @@
 !--    interpolation routines.
        nzt_topo_nestbc_l = nzb
-       IF ( nest_bound_l )  THEN
+       IF ( bc_dirichlet_l )  THEN
           DO  i = nxl-1, nxl
              DO  j = nys, nyn
@@ -1740,5 +1731,5 @@
       
        nzt_topo_nestbc_r = nzb
-       IF ( nest_bound_r )  THEN
+       IF ( bc_dirichlet_r )  THEN
           i = nxr + 1
           DO  j = nys, nyn
@@ -1765,5 +1756,5 @@
 
        nzt_topo_nestbc_s = nzb
-       IF ( nest_bound_s )  THEN
+       IF ( bc_dirichlet_s )  THEN
           DO  j = nys-1, nys
              DO  i = nxl, nxr
@@ -1791,5 +1782,5 @@
 
        nzt_topo_nestbc_n = nzb
-       IF ( nest_bound_n )  THEN
+       IF ( bc_dirichlet_n )  THEN
           j = nyn + 1
           DO  i = nxl, nxr
@@ -1862,5 +1853,5 @@
 !--    logc_kbounds_* need to be allocated and initialized here.
 !--    Left boundary
-       IF ( nest_bound_l )  THEN
+       IF ( bc_dirichlet_l )  THEN
 
           ALLOCATE( logc_u_l(1:2,nzb:nzt_topo_nestbc_l,nys:nyn) )
@@ -1923,5 +1914,5 @@
 !
 !--    Right boundary
-       IF ( nest_bound_r )  THEN
+       IF ( bc_dirichlet_r )  THEN
            
           ALLOCATE( logc_u_r(1:2,nzb:nzt_topo_nestbc_r,nys:nyn) )
@@ -1985,5 +1976,5 @@
 !
 !--    South boundary
-       IF ( nest_bound_s )  THEN
+       IF ( bc_dirichlet_s )  THEN
 
           ALLOCATE( logc_u_s(1:2,nzb:nzt_topo_nestbc_s,nxl:nxr) )
@@ -2044,5 +2035,5 @@
 !
 !--    North boundary
-       IF ( nest_bound_n )  THEN
+       IF ( bc_dirichlet_n )  THEN
 
           ALLOCATE( logc_u_n(1:2,nzb:nzt_topo_nestbc_n,nxl:nxr) )
@@ -2116,5 +2107,5 @@
 !        
 !--       Left boundary
-          IF ( nest_bound_l )  THEN
+          IF ( bc_dirichlet_l )  THEN
              logc_kbounds_u_l(1:2,nys:nyn) = 0
              logc_kbounds_v_l(1:2,nys:nyn) = 0             
@@ -2255,8 +2246,8 @@
              ENDDO
 
-          ENDIF   !  IF ( nest_bound_l )
+          ENDIF   !  IF ( bc_dirichlet_l )
 !        
 !--       Right boundary
-          IF ( nest_bound_r )  THEN
+          IF ( bc_dirichlet_r )  THEN
              logc_kbounds_u_r(1:2,nys:nyn) = 0
              logc_kbounds_v_r(1:2,nys:nyn) = 0             
@@ -2395,8 +2386,8 @@
              ENDDO
              
-          ENDIF   !  IF ( nest_bound_r )
+          ENDIF   !  IF ( bc_dirichlet_r )
 !        
 !--       South boundary
-          IF ( nest_bound_s )  THEN
+          IF ( bc_dirichlet_s )  THEN
              logc_kbounds_u_s(1:2,nxl:nxr) = 0
              logc_kbounds_v_s(1:2,nxl:nxr) = 0
@@ -2537,8 +2528,8 @@
              ENDDO
 
-          ENDIF   !  IF (nest_bound_s )
+          ENDIF   !  IF (bc_dirichlet_s )
 !        
 !--       North boundary
-          IF ( nest_bound_n )  THEN
+          IF ( bc_dirichlet_n )  THEN
              logc_kbounds_u_n(1:2,nxl:nxr) = 0             
              logc_kbounds_v_n(1:2,nxl:nxr) = 0
@@ -2678,5 +2669,5 @@
              ENDDO
 
-          ENDIF   !  IF ( nest_bound_n )
+          ENDIF   !  IF ( bc_dirichlet_n )
 
        ENDIF   !  IF ( topography /= 'flat' )
@@ -2786,7 +2777,4 @@
 
        END SELECT
-          
-       !write(9,"('pmci_define_loglaw_correction_parameters: ', 6(i3,2x))")    &
-       !     direction, ij, k, wall_index, inc, lc
 
     END SUBROUTINE pmci_define_loglaw_correction_parameters
@@ -3325,5 +3313,5 @@
 !
        IF ( .NOT. rans_mode  .AND.  .NOT. rans_mode_parent )  THEN 
-          IF ( nest_bound_l )  THEN
+          IF ( bc_dirichlet_l )  THEN
              ALLOCATE( tkefactor_l(nzb:nzt+1,nysg:nyng) )
              tkefactor_l = 0.0_wp
@@ -3345,5 +3333,5 @@
           ENDIF
 
-          IF ( nest_bound_r )  THEN
+          IF ( bc_dirichlet_r )  THEN
              ALLOCATE( tkefactor_r(nzb:nzt+1,nysg:nyng) )
              tkefactor_r = 0.0_wp
@@ -3365,5 +3353,5 @@
           ENDIF
 
-          IF ( nest_bound_s )  THEN
+          IF ( bc_dirichlet_s )  THEN
              ALLOCATE( tkefactor_s(nzb:nzt+1,nxlg:nxrg) )
              tkefactor_s = 0.0_wp
@@ -3386,5 +3374,5 @@
           ENDIF
 
-          IF ( nest_bound_n )  THEN
+          IF ( bc_dirichlet_n )  THEN
              ALLOCATE( tkefactor_n(nzb:nzt+1,nxlg:nxrg) )
              tkefactor_n = 0.0_wp
@@ -3428,17 +3416,17 @@
 !--    RANS mode
        ELSE
-          IF ( nest_bound_l )  THEN
+          IF ( bc_dirichlet_l )  THEN
              ALLOCATE( tkefactor_l(nzb:nzt+1,nysg:nyng) )
              tkefactor_l = 1.0_wp
           ENDIF
-          IF ( nest_bound_r )  THEN
+          IF ( bc_dirichlet_r )  THEN
              ALLOCATE( tkefactor_r(nzb:nzt+1,nysg:nyng) )
              tkefactor_r = 1.0_wp
           ENDIF
-          IF ( nest_bound_s )  THEN
+          IF ( bc_dirichlet_s )  THEN
              ALLOCATE( tkefactor_s(nzb:nzt+1,nxlg:nxrg) )
              tkefactor_s = 1.0_wp
           ENDIF
-          IF ( nest_bound_n )  THEN
+          IF ( bc_dirichlet_n )  THEN
              ALLOCATE( tkefactor_n(nzb:nzt+1,nxlg:nxrg) )
              tkefactor_n = 1.0_wp
@@ -3980,5 +3968,5 @@
        je = nyn
        IF ( nesting_mode /= 'vertical' )  THEN
-          IF ( nest_bound_l )  THEN
+          IF ( bc_dirichlet_l )  THEN
              ib = nxl - 1
 !
@@ -3988,5 +3976,5 @@
              ENDIF
           ENDIF
-          IF ( nest_bound_s )  THEN
+          IF ( bc_dirichlet_s )  THEN
              jb = nys - 1
 !
@@ -3996,8 +3984,8 @@
              ENDIF
           ENDIF
-          IF ( nest_bound_r )  THEN
+          IF ( bc_dirichlet_r )  THEN
              ie = nxr + 1
           ENDIF
-          IF ( nest_bound_n )  THEN
+          IF ( bc_dirichlet_n )  THEN
              je = nyn + 1
           ENDIF
@@ -4201,5 +4189,5 @@
     volume_flow_l(1) = 0.0_wp
 
-    IF ( nest_bound_l )  THEN
+    IF ( bc_dirichlet_l )  THEN
        i = 0
        innor = dy
@@ -4213,5 +4201,5 @@
     ENDIF
 
-    IF ( nest_bound_r )  THEN
+    IF ( bc_dirichlet_r )  THEN
        i = nx + 1
        innor = -dy
@@ -4238,5 +4226,5 @@
     volume_flow_l(2) = 0.0_wp
 
-    IF ( nest_bound_s )  THEN
+    IF ( bc_dirichlet_s )  THEN
        j = 0
        innor = dx
@@ -4250,5 +4238,5 @@
     ENDIF
 
-    IF ( nest_bound_n )  THEN
+    IF ( bc_dirichlet_n )  THEN
        j = ny + 1
        innor = -dx
@@ -4549,5 +4537,5 @@
 !
 !--       Left border pe:
-          IF ( nest_bound_l )  THEN
+          IF ( bc_dirichlet_l )  THEN
              
              CALL pmci_interp_tril_lr( u,  uc,  icu, jco, kco, r1xu, r2xu,     &
@@ -4656,5 +4644,5 @@
 !
 !--       Right border pe
-          IF ( nest_bound_r )  THEN
+          IF ( bc_dirichlet_r )  THEN
              
              CALL pmci_interp_tril_lr( u,  uc,  icu, jco, kco, r1xu, r2xu,     &
@@ -4769,5 +4757,5 @@
 !
 !--       South border pe
-          IF ( nest_bound_s )  THEN
+          IF ( bc_dirichlet_s )  THEN
 
              CALL pmci_interp_tril_sn( u,  uc,  icu, jco, kco, r1xu, r2xu,     &
@@ -4880,5 +4868,5 @@
 !
 !--       North border pe
-          IF ( nest_bound_n )  THEN
+          IF ( bc_dirichlet_n )  THEN
              
              CALL pmci_interp_tril_sn( u,  uc,  icu, jco, kco, r1xu, r2xu,     &
@@ -5748,18 +5736,18 @@
 !--    comprehensive explanation for this is still pending.
        IF ( nesting_mode == 'vertical' )  THEN
-          IF ( nest_bound_l )  THEN
+          IF ( bc_dirichlet_l )  THEN
              iclp = icl + nhll
           ENDIF
-          IF ( nest_bound_r ) THEN
+          IF ( bc_dirichlet_r ) THEN
              icrm = icr - nhlr
           ENDIF
-          IF ( nest_bound_s )  THEN
+          IF ( bc_dirichlet_s )  THEN
              jcsp = jcs + nhls
           ENDIF
-          IF ( nest_bound_n )  THEN
+          IF ( bc_dirichlet_n )  THEN
              jcnm = jcn - nhln
           ENDIF
        ELSE
-          IF ( nest_bound_l )  THEN
+          IF ( bc_dirichlet_l )  THEN
              IF ( var == 'u' )  THEN
                 iclp = icl + nhll + 1 + 1
@@ -5768,9 +5756,9 @@
              ENDIF
           ENDIF
-          IF ( nest_bound_r )  THEN
+          IF ( bc_dirichlet_r )  THEN
              icrm = icr - nhlr - 1
           ENDIF
 
-          IF ( nest_bound_s )  THEN
+          IF ( bc_dirichlet_s )  THEN
              IF ( var == 'v' )  THEN
                 jcsp = jcs + nhls + 1 + 1
@@ -5779,5 +5767,5 @@
              ENDIF
           ENDIF
-          IF ( nest_bound_n )  THEN
+          IF ( bc_dirichlet_n )  THEN
              jcnm = jcn - nhln - 1
           ENDIF
Index: palm/trunk/SOURCE/pmc_parent_mod.f90
===================================================================
--- palm/trunk/SOURCE/pmc_parent_mod.f90	(revision 3178)
+++ palm/trunk/SOURCE/pmc_parent_mod.f90	(revision 3182)
@@ -203,5 +203,4 @@
     INTEGER(iwp) ::  istat     !<
 
-
     DO  i = 1, SIZE( pmc_parent_for_child )-1
 
@@ -219,5 +218,4 @@
        CALL MPI_COMM_REMOTE_SIZE( children(childid)%inter_comm,                &
                                   children(childid)%inter_npes, istat )
-
 !
 !--    Intra communicator is used for MPI_GET
@@ -228,5 +226,4 @@
 
        ALLOCATE( children(childid)%pes(children(childid)%inter_npes))
-
 !
 !--    Allocate array of TYPE arraydef for all child PEs to store information
@@ -865,5 +862,7 @@
     DO
        CALL pmc_bcast( myname%couple_index, 0, comm=m_to_child_comm(childid) )
+
        IF ( myname%couple_index == -1 )  EXIT
+
        CALL pmc_bcast( myname%parentdesc,   0, comm=m_to_child_comm(childid) )
        CALL pmc_bcast( myname%nameonparent, 0, comm=m_to_child_comm(childid) )
Index: palm/trunk/SOURCE/poismg_mod.f90
===================================================================
--- palm/trunk/SOURCE/poismg_mod.f90	(revision 3178)
+++ palm/trunk/SOURCE/poismg_mod.f90	(revision 3182)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Rename variables in mesoscale-offline nesting mode
 ! 
 ! Former revisions:
@@ -26,5 +26,5 @@
 ! $Id$
 ! Set lateral boundary conditions for divergence
-! 
+!
 ! 2937 2018-03-27 14:58:33Z suehring
 ! Corrected "Former revisions" section
@@ -107,8 +107,7 @@
  
     USE control_parameters,                                                    &
-        ONLY:  grid_level, force_bound_l, force_bound_n, force_bound_r,        &
-               force_bound_s, forcing, inflow_l, inflow_n, inflow_r, inflow_s, &
-               nest_bound_l, nest_bound_n, nest_bound_r, nest_bound_s,         &
-               outflow_l, outflow_n, outflow_r, outflow_s
+        ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,                 &
+               bc_dirichlet_s, bc_radiation_l, bc_radiation_n, bc_radiation_r, &
+               bc_radiation_s, grid_level, nesting_offline
 
     USE cpulog,                                                                &
@@ -206,13 +205,13 @@
 !--    Set lateral boundary conditions in non-cyclic case
        IF ( .NOT. bc_lr_cyc )  THEN
-          IF ( inflow_l .OR. outflow_l .OR. nest_bound_l .OR. force_bound_l )  &
+          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )                          &
              d(:,:,nxl-1) = d(:,:,nxl)
-          IF ( inflow_r .OR. outflow_r .OR. nest_bound_r .OR. force_bound_r )  &
+          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )                          &
              d(:,:,nxr+1) = d(:,:,nxr)
        ENDIF
        IF ( .NOT. bc_ns_cyc )  THEN
-          IF ( inflow_n .OR. outflow_n .OR. nest_bound_n .OR. force_bound_n )  &
+          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )                          &
              d(:,nyn+1,:) = d(:,nyn,:)
-          IF ( inflow_s .OR. outflow_s .OR. nest_bound_s .OR. force_bound_s )  &
+          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )                          &
              d(:,nys-1,:) = d(:,nys,:)
        ENDIF
@@ -375,10 +374,8 @@
 
        IF ( .NOT. bc_lr_cyc )  THEN
-          IF ( inflow_l  .OR.  outflow_l  .OR.  nest_bound_l  .OR.             &
-               force_bound_l )  THEN
+          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
              r(:,:,nxl_mg(l)-1) = r(:,:,nxl_mg(l))
           ENDIF
-          IF ( inflow_r  .OR.  outflow_r  .OR.  nest_bound_r  .OR.             &
-               force_bound_r )  THEN
+          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
              r(:,:,nxr_mg(l)+1) = r(:,:,nxr_mg(l))
           ENDIF
@@ -386,10 +383,8 @@
 
        IF ( .NOT. bc_ns_cyc )  THEN
-          IF ( inflow_n  .OR.  outflow_n  .OR.  nest_bound_n  .OR.             &
-               force_bound_n )  THEN
+          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
              r(:,nyn_mg(l)+1,:) = r(:,nyn_mg(l),:)
           ENDIF
-          IF ( inflow_s  .OR.  outflow_s  .OR.  nest_bound_s  .OR.             &
-               force_bound_s )  THEN
+          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
              r(:,nys_mg(l)-1,:) = r(:,nys_mg(l),:)
           ENDIF
@@ -510,10 +505,8 @@
 !--    Horizontal boundary conditions
        IF ( .NOT. bc_lr_cyc )  THEN
-          IF ( inflow_l  .OR.  outflow_l  .OR.  nest_bound_l  .OR.             &
-               force_bound_l )  THEN
+          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
              f_mg(:,:,nxl_mg(l)-1) = f_mg(:,:,nxl_mg(l))
           ENDIF
-          IF ( inflow_r  .OR.  outflow_r  .OR.  nest_bound_r  .OR.             &
-               force_bound_r )  THEN
+          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
              f_mg(:,:,nxr_mg(l)+1) = f_mg(:,:,nxr_mg(l))
           ENDIF
@@ -521,10 +514,8 @@
 
        IF ( .NOT. bc_ns_cyc )  THEN
-          IF ( inflow_n  .OR.  outflow_n  .OR.  nest_bound_n  .OR.             &
-               force_bound_n )  THEN
+          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
              f_mg(:,nyn_mg(l)+1,:) = f_mg(:,nyn_mg(l),:)
           ENDIF
-          IF ( inflow_s  .OR.  outflow_s  .OR.  nest_bound_s  .OR.             &
-               force_bound_s )  THEN
+          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
              f_mg(:,nys_mg(l)-1,:) = f_mg(:,nys_mg(l),:)
           ENDIF
@@ -681,10 +672,8 @@
 
        IF ( .NOT. bc_lr_cyc )  THEN
-          IF ( inflow_l  .OR.  outflow_l  .OR.  nest_bound_l  .OR.             &
-               force_bound_l )  THEN
+          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
              temp(:,:,nxl_mg(l)-1) = temp(:,:,nxl_mg(l))
           ENDIF
-          IF ( inflow_r  .OR.  outflow_r  .OR.  nest_bound_r  .OR.             &
-               force_bound_r )  THEN
+          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
              temp(:,:,nxr_mg(l)+1) = temp(:,:,nxr_mg(l))
           ENDIF
@@ -692,10 +681,8 @@
 
        IF ( .NOT. bc_ns_cyc )  THEN
-          IF ( inflow_n  .OR.  outflow_n  .OR.  nest_bound_n  .OR.             &
-               force_bound_n )  THEN
+          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
              temp(:,nyn_mg(l)+1,:) = temp(:,nyn_mg(l),:)
           ENDIF
-          IF ( inflow_s  .OR.  outflow_s  .OR.  nest_bound_s  .OR.             &
-               force_bound_s )  THEN
+          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
              temp(:,nys_mg(l)-1,:) = temp(:,nys_mg(l),:)
           ENDIF
@@ -991,10 +978,8 @@
 
              IF ( .NOT. bc_lr_cyc )  THEN
-                IF ( inflow_l  .OR.  outflow_l  .OR.  nest_bound_l  .OR.       &
-                     force_bound_l )  THEN
+                IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
                    p_mg(:,:,nxl_mg(l)-1) = p_mg(:,:,nxl_mg(l))
                 ENDIF
-                IF ( inflow_r  .OR.  outflow_r  .OR.  nest_bound_r  .OR.       &
-                     force_bound_r )  THEN
+                IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
                    p_mg(:,:,nxr_mg(l)+1) = p_mg(:,:,nxr_mg(l))
                 ENDIF
@@ -1002,10 +987,8 @@
 
              IF ( .NOT. bc_ns_cyc )  THEN
-                IF ( inflow_n  .OR.  outflow_n  .OR.  nest_bound_n  .OR.       &
-                     force_bound_n )  THEN
+                IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
                    p_mg(:,nyn_mg(l)+1,:) = p_mg(:,nyn_mg(l),:)
                 ENDIF
-                IF ( inflow_s  .OR.  outflow_s  .OR.  nest_bound_s  .OR.       &
-                     force_bound_s )  THEN
+                IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
                    p_mg(:,nys_mg(l)-1,:) = p_mg(:,nys_mg(l),:)
                 ENDIF
@@ -1423,7 +1406,7 @@
        USE control_parameters,                                                 &
            ONLY:  bc_lr_dirrad, bc_lr_raddir, bc_ns_dirrad, bc_ns_raddir,      &
-                  gamma_mg, grid_level_count, ibc_p_b, ibc_p_t,                &
+                  child_domain, gamma_mg, grid_level_count, ibc_p_b, ibc_p_t,  &
                   maximum_grid_level,  mg_switch_to_pe0_level,                 &
-                  mg_switch_to_pe0, nest_domain, ngsrb 
+                  mg_switch_to_pe0, ngsrb 
 
        USE indices,                                                            &
@@ -1564,37 +1547,31 @@
 !--          because then they have the total domain.
              IF ( bc_lr_dirrad )  THEN
-                inflow_l  = .TRUE.
-                inflow_r  = .FALSE.
-                outflow_l = .FALSE.
-                outflow_r = .TRUE.
+                bc_dirichlet_l  = .TRUE.
+                bc_dirichlet_r  = .FALSE.
+                bc_radiation_l = .FALSE.
+                bc_radiation_r = .TRUE.
              ELSEIF ( bc_lr_raddir )  THEN
-                inflow_l  = .FALSE.
-                inflow_r  = .TRUE.
-                outflow_l = .TRUE.
-                outflow_r = .FALSE.
-             ELSEIF ( nest_domain )  THEN
-                nest_bound_l = .TRUE.
-                nest_bound_r = .TRUE.
-             ELSEIF ( forcing )  THEN
-                force_bound_l = .TRUE.
-                force_bound_r = .TRUE.
+                bc_dirichlet_l  = .FALSE.
+                bc_dirichlet_r  = .TRUE.
+                bc_radiation_l = .TRUE.
+                bc_radiation_r = .FALSE.
+             ELSEIF ( child_domain  .OR.  nesting_offline )  THEN
+                bc_dirichlet_l = .TRUE.
+                bc_dirichlet_r = .TRUE.
              ENDIF
 
              IF ( bc_ns_dirrad )  THEN
-                inflow_n  = .TRUE.
-                inflow_s  = .FALSE.
-                outflow_n = .FALSE.
-                outflow_s = .TRUE.
+                bc_dirichlet_n  = .TRUE.
+                bc_dirichlet_s  = .FALSE.
+                bc_radiation_n = .FALSE.
+                bc_radiation_s = .TRUE.
              ELSEIF ( bc_ns_raddir )  THEN
-                inflow_n  = .FALSE.
-                inflow_s  = .TRUE.
-                outflow_n = .TRUE.
-                outflow_s = .FALSE.
-             ELSEIF ( nest_domain )  THEN
-                nest_bound_s = .TRUE.
-                nest_bound_n = .TRUE.
-             ELSEIF ( forcing )  THEN
-                force_bound_s = .TRUE.
-                force_bound_n = .TRUE.
+                bc_dirichlet_n  = .FALSE.
+                bc_dirichlet_s  = .TRUE.
+                bc_radiation_n = .TRUE.
+                bc_radiation_s = .FALSE.
+             ELSEIF ( child_domain  .OR.  nesting_offline)  THEN
+                bc_dirichlet_s = .TRUE.
+                bc_dirichlet_n = .TRUE.
              ENDIF
 
@@ -1659,32 +1636,15 @@
 !--          For non-cyclic lateral boundary conditions and in case of nesting, 
 !--          restore the in-/outflow conditions. 
-             inflow_l  = .FALSE.;  inflow_r  = .FALSE.
-             inflow_n  = .FALSE.;  inflow_s  = .FALSE.
-             outflow_l = .FALSE.;  outflow_r = .FALSE.
-             outflow_n = .FALSE.;  outflow_s = .FALSE.
-!
-!--          In case of nesting or forcing, restore lateral boundary conditions
-             IF ( nest_domain )  THEN
-                nest_bound_l = .FALSE.
-                nest_bound_r = .FALSE.
-                nest_bound_s = .FALSE.
-                nest_bound_n = .FALSE.      
-             ENDIF
-             IF ( forcing )  THEN
-                force_bound_l = .FALSE.
-                force_bound_r = .FALSE.
-                force_bound_s = .FALSE.
-                force_bound_n = .FALSE.      
-             ENDIF
+             bc_dirichlet_l = .FALSE.;  bc_dirichlet_r = .FALSE.
+             bc_dirichlet_n = .FALSE.;  bc_dirichlet_s = .FALSE.
+             bc_radiation_l = .FALSE.;  bc_radiation_r = .FALSE.
+             bc_radiation_n = .FALSE.;  bc_radiation_s = .FALSE.
 
              IF ( pleft == MPI_PROC_NULL )  THEN
-                IF ( bc_lr_dirrad )  THEN
-                   inflow_l  = .TRUE.
+                IF ( bc_lr_dirrad  .OR.  child_domain  .OR.  nesting_offline ) &
+                THEN
+                   bc_dirichlet_l = .TRUE.
                 ELSEIF ( bc_lr_raddir )  THEN
-                   outflow_l = .TRUE.
-                ELSEIF ( nest_domain )  THEN
-                   nest_bound_l = .TRUE.
-                ELSEIF ( forcing )  THEN
-                   force_bound_l = .TRUE.
+                   bc_radiation_l = .TRUE.
                 ENDIF
              ENDIF
@@ -1692,11 +1652,8 @@
              IF ( pright == MPI_PROC_NULL )  THEN
                 IF ( bc_lr_dirrad )  THEN
-                   outflow_r = .TRUE.
-                ELSEIF ( bc_lr_raddir )  THEN
-                   inflow_r  = .TRUE.
-                ELSEIF ( nest_domain )  THEN
-                   nest_bound_r = .TRUE.
-                ELSEIF ( forcing )  THEN
-                   force_bound_r = .TRUE.
+                   bc_radiation_r = .TRUE.
+                ELSEIF ( bc_lr_raddir  .OR.  child_domain  .OR.                &
+                         nesting_offline )  THEN
+                   bc_dirichlet_r = .TRUE.
                 ENDIF
              ENDIF
@@ -1704,23 +1661,17 @@
              IF ( psouth == MPI_PROC_NULL )  THEN
                 IF ( bc_ns_dirrad )  THEN
-                   outflow_s = .TRUE.
+                   bc_radiation_s = .TRUE.
+                ELSEIF ( bc_ns_raddir  .OR.  child_domain  .OR.                &
+                         nesting_offline )  THEN
+                   bc_dirichlet_s = .TRUE.
+                ENDIF
+             ENDIF
+
+             IF ( pnorth == MPI_PROC_NULL )  THEN
+                IF ( bc_ns_dirrad  .OR.  child_domain  .OR.  nesting_offline ) &
+                THEN
+                   bc_dirichlet_n = .TRUE.
                 ELSEIF ( bc_ns_raddir )  THEN
-                   inflow_s  = .TRUE.
-                ELSEIF ( nest_domain )  THEN
-                   nest_bound_s = .TRUE.
-                ELSEIF ( forcing )  THEN
-                   force_bound_s = .TRUE.
-                ENDIF
-             ENDIF
-
-             IF ( pnorth == MPI_PROC_NULL )  THEN
-                IF ( bc_ns_dirrad )  THEN
-                   inflow_n  = .TRUE.
-                ELSEIF ( bc_ns_raddir )  THEN
-                   outflow_n = .TRUE.
-                ELSEIF ( nest_domain )  THEN
-                   nest_bound_n = .TRUE.
-                ELSEIF ( forcing )  THEN
-                   force_bound_n = .TRUE.
+                   bc_radiation_n = .TRUE.
                 ENDIF
              ENDIF
Index: palm/trunk/SOURCE/poismg_noopt_mod.f90
===================================================================
--- palm/trunk/SOURCE/poismg_noopt_mod.f90	(revision 3178)
+++ palm/trunk/SOURCE/poismg_noopt_mod.f90	(revision 3182)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Rename variables in mesoscale-offline nesting mode
 ! 
 ! Former revisions:
@@ -165,8 +165,7 @@
  
     USE control_parameters,                                                    &
-        ONLY:  grid_level, force_bound_l, force_bound_n, force_bound_r,        &
-               force_bound_s, forcing, inflow_l, inflow_n, inflow_r, inflow_s, &
-               nest_bound_l, nest_bound_n, nest_bound_r, nest_bound_s,         &
-               outflow_l, outflow_n, outflow_r, outflow_s
+        ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,                 &
+               bc_dirichlet_s, bc_radiation_l, bc_radiation_n, bc_radiation_r, &
+               bc_radiation_s, child_domain, grid_level, nesting_offline
 
     USE cpulog,                                                                &
@@ -261,13 +260,13 @@
 !--    Set lateral boundary conditions in non-cyclic case
        IF ( .NOT. bc_lr_cyc )  THEN
-          IF ( inflow_l .OR. outflow_l .OR. nest_bound_l .OR. force_bound_l )  &
+          IF ( bc_dirichlet_l   .OR.  bc_radiation_l )                         &
              d(:,:,nxl-1) = d(:,:,nxl)
-          IF ( inflow_r .OR. outflow_r .OR. nest_bound_r .OR. force_bound_r )  &
+          IF ( bc_dirichlet_r   .OR.  bc_radiation_r )                         &
              d(:,:,nxr+1) = d(:,:,nxr)
        ENDIF
        IF ( .NOT. bc_ns_cyc )  THEN
-          IF ( inflow_n .OR. outflow_n .OR. nest_bound_n .OR. force_bound_n )  &
+          IF ( bc_dirichlet_n   .OR.  bc_radiation_n )                         &
              d(:,nyn+1,:) = d(:,nyn,:)
-          IF ( inflow_s .OR. outflow_s .OR. nest_bound_s .OR. force_bound_s )  &
+          IF ( bc_dirichlet_s   .OR.  bc_radiation_s )                         &
              d(:,nys-1,:) = d(:,nys,:)
        ENDIF
@@ -442,8 +441,8 @@
 
        IF ( .NOT. bc_lr_cyc )  THEN
-          IF ( inflow_l .OR. outflow_l .OR. nest_bound_l .OR. force_bound_l )  THEN
+          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
              r(:,:,nxl_mg(l)-1) = r(:,:,nxl_mg(l))
           ENDIF
-          IF ( inflow_r .OR. outflow_r .OR. nest_bound_r .OR. force_bound_r )  THEN
+          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
              r(:,:,nxr_mg(l)+1) = r(:,:,nxr_mg(l))
           ENDIF
@@ -451,8 +450,8 @@
 
        IF ( .NOT. bc_ns_cyc )  THEN
-          IF ( inflow_n .OR. outflow_n .OR. nest_bound_n .OR. force_bound_n )  THEN
+          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
              r(:,nyn_mg(l)+1,:) = r(:,nyn_mg(l),:)
           ENDIF
-          IF ( inflow_s .OR. outflow_s .OR. nest_bound_s .OR. force_bound_s )  THEN
+          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
              r(:,nys_mg(l)-1,:) = r(:,nys_mg(l),:)
           ENDIF
@@ -657,8 +656,8 @@
 
        IF ( .NOT. bc_lr_cyc )  THEN
-          IF ( inflow_l .OR. outflow_l .OR. nest_bound_l .OR. force_bound_l )  THEN
+          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
              f_mg(:,:,nxl_mg(l)-1) = f_mg(:,:,nxl_mg(l))
           ENDIF
-          IF ( inflow_r .OR. outflow_r .OR. nest_bound_r .OR. force_bound_r )  THEN
+          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
              f_mg(:,:,nxr_mg(l)+1) = f_mg(:,:,nxr_mg(l))
           ENDIF
@@ -666,8 +665,8 @@
 
        IF ( .NOT. bc_ns_cyc )  THEN
-          IF ( inflow_n .OR. outflow_n .OR. nest_bound_n .OR. force_bound_n )  THEN
+          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
              f_mg(:,nyn_mg(l)+1,:) = f_mg(:,nyn_mg(l),:)
           ENDIF
-          IF ( inflow_s .OR. outflow_s .OR. nest_bound_s .OR. force_bound_s )  THEN
+          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
              f_mg(:,nys_mg(l)-1,:) = f_mg(:,nys_mg(l),:)
           ENDIF
@@ -770,8 +769,8 @@
 
     IF ( .NOT. bc_lr_cyc )  THEN
-       IF ( inflow_l .OR. outflow_l .OR. nest_bound_l .OR. force_bound_l )  THEN
+       IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
           temp(:,:,nxl_mg(l)-1) = temp(:,:,nxl_mg(l))
        ENDIF
-       IF ( inflow_r .OR. outflow_r .OR. nest_bound_r .OR. force_bound_r )  THEN
+       IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
           temp(:,:,nxr_mg(l)+1) = temp(:,:,nxr_mg(l))
        ENDIF
@@ -779,8 +778,8 @@
 
     IF ( .NOT. bc_ns_cyc )  THEN
-       IF ( inflow_n .OR. outflow_n .OR. nest_bound_n .OR. force_bound_n )  THEN
+       IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
           temp(:,nyn_mg(l)+1,:) = temp(:,nyn_mg(l),:)
        ENDIF
-       IF ( inflow_s .OR. outflow_s .OR. nest_bound_s .OR. force_bound_s )  THEN
+       IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
           temp(:,nys_mg(l)-1,:) = temp(:,nys_mg(l),:)
        ENDIF
@@ -1200,8 +1199,8 @@
 
              IF ( .NOT. bc_lr_cyc )  THEN
-                IF ( inflow_l .OR. outflow_l .OR. nest_bound_l .OR. force_bound_l )  THEN
+                IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
                    p_mg(:,:,nxl_mg(l)-1) = p_mg(:,:,nxl_mg(l))
                 ENDIF
-                IF ( inflow_r .OR. outflow_r .OR. nest_bound_r .OR. force_bound_r )  THEN
+                IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
                    p_mg(:,:,nxr_mg(l)+1) = p_mg(:,:,nxr_mg(l))
                 ENDIF
@@ -1209,8 +1208,8 @@
 
              IF ( .NOT. bc_ns_cyc )  THEN
-                IF ( inflow_n .OR. outflow_n .OR. nest_bound_n .OR. force_bound_n )  THEN
+                IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
                    p_mg(:,nyn_mg(l)+1,:) = p_mg(:,nyn_mg(l),:)
                 ENDIF
-                IF ( inflow_s .OR. outflow_s .OR. nest_bound_s .OR. force_bound_s )  THEN
+                IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
                    p_mg(:,nys_mg(l)-1,:) = p_mg(:,nys_mg(l),:)
                 ENDIF
@@ -1422,5 +1421,5 @@
                   gamma_mg, grid_level_count, ibc_p_b, ibc_p_t,                &
                   maximum_grid_level,                                          &
-                  mg_switch_to_pe0_level, mg_switch_to_pe0, nest_domain, ngsrb
+                  mg_switch_to_pe0_level, mg_switch_to_pe0, ngsrb
 
 
@@ -1562,37 +1561,31 @@
 !--          because then they have the total domain.
              IF ( bc_lr_dirrad )  THEN
-                inflow_l  = .TRUE.
-                inflow_r  = .FALSE.
-                outflow_l = .FALSE.
-                outflow_r = .TRUE.
+                bc_dirichlet_l  = .TRUE.
+                bc_dirichlet_r  = .FALSE.
+                bc_radiation_l = .FALSE.
+                bc_radiation_r = .TRUE.
              ELSEIF ( bc_lr_raddir )  THEN
-                inflow_l  = .FALSE.
-                inflow_r  = .TRUE.
-                outflow_l = .TRUE.
-                outflow_r = .FALSE.
-             ELSEIF ( nest_domain )  THEN
-                nest_bound_l = .TRUE.
-                nest_bound_r = .TRUE.
-             ELSEIF ( forcing )  THEN
-                force_bound_l = .TRUE.
-                force_bound_r = .TRUE.
+                bc_dirichlet_l  = .FALSE.
+                bc_dirichlet_r  = .TRUE.
+                bc_radiation_l = .TRUE.
+                bc_radiation_r = .FALSE.
+             ELSEIF ( child_domain  .OR.  nesting_offline )  THEN
+                bc_dirichlet_l = .TRUE.
+                bc_dirichlet_r = .TRUE.
              ENDIF
 
              IF ( bc_ns_dirrad )  THEN
-                inflow_n  = .TRUE.
-                inflow_s  = .FALSE.
-                outflow_n = .FALSE.
-                outflow_s = .TRUE.
+                bc_dirichlet_n  = .TRUE.
+                bc_dirichlet_s  = .FALSE.
+                bc_radiation_n = .FALSE.
+                bc_radiation_s = .TRUE.
              ELSEIF ( bc_ns_raddir )  THEN
-                inflow_n  = .FALSE.
-                inflow_s  = .TRUE.
-                outflow_n = .TRUE.
-                outflow_s = .FALSE.
-             ELSEIF ( nest_domain )  THEN
-                nest_bound_s = .TRUE.
-                nest_bound_n = .TRUE.
-             ELSEIF ( forcing )  THEN
-                force_bound_s = .TRUE.
-                force_bound_n = .TRUE.
+                bc_dirichlet_n  = .FALSE.
+                bc_dirichlet_s  = .TRUE.
+                bc_radiation_n = .TRUE.
+                bc_radiation_s = .FALSE.
+             ELSEIF ( child_domain  .OR.  nesting_offline )  THEN
+                bc_dirichlet_s = .TRUE.
+                bc_dirichlet_n = .TRUE.
              ENDIF
 
@@ -1655,32 +1648,15 @@
 !--          For non-cyclic lateral boundary conditions and in case of nesting, 
 !--          restore the in-/outflow conditions. 
-             inflow_l  = .FALSE.;  inflow_r  = .FALSE.
-             inflow_n  = .FALSE.;  inflow_s  = .FALSE.
-             outflow_l = .FALSE.;  outflow_r = .FALSE.
-             outflow_n = .FALSE.;  outflow_s = .FALSE.
-!
-!--          In case of nesting, restore lateral boundary conditions
-             IF ( nest_domain )  THEN
-                nest_bound_l = .FALSE.
-                nest_bound_r = .FALSE.
-                nest_bound_s = .FALSE.
-                nest_bound_n = .FALSE.      
-             ENDIF
-             IF ( forcing )  THEN
-                force_bound_l = .FALSE.
-                force_bound_r = .FALSE.
-                force_bound_s = .FALSE.
-                force_bound_n = .FALSE.      
-             ENDIF
+             bc_dirichlet_l = .FALSE.;  bc_dirichlet_r = .FALSE.
+             bc_dirichlet_n = .FALSE.;  bc_dirichlet_s = .FALSE.
+             bc_radiation_l = .FALSE.;  bc_radiation_r = .FALSE.
+             bc_radiation_n = .FALSE.;  bc_radiation_s = .FALSE.
 
              IF ( pleft == MPI_PROC_NULL )  THEN
-                IF ( bc_lr_dirrad )  THEN
-                   inflow_l  = .TRUE.
+                IF ( bc_lr_dirrad  .OR.  child_domain  .OR.  nesting_offline )  &
+                THEN
+                   bc_dirichlet_l = .TRUE.
                 ELSEIF ( bc_lr_raddir )  THEN
-                   outflow_l = .TRUE.
-                ELSEIF ( nest_domain )  THEN
-                   nest_bound_l = .TRUE.
-                ELSEIF ( forcing )  THEN
-                   force_bound_l = .TRUE.
+                   bc_radiation_l = .TRUE.
                 ENDIF
              ENDIF
@@ -1688,11 +1664,8 @@
              IF ( pright == MPI_PROC_NULL )  THEN
                 IF ( bc_lr_dirrad )  THEN
-                   outflow_r = .TRUE.
-                ELSEIF ( bc_lr_raddir )  THEN
-                   inflow_r  = .TRUE.
-                ELSEIF ( nest_domain )  THEN
-                   nest_bound_r = .TRUE.
-                ELSEIF ( forcing )  THEN
-                   force_bound_r = .TRUE.
+                   bc_radiation_r = .TRUE.
+                ELSEIF ( bc_lr_raddir  .OR.  child_domain  .OR.                 &
+                         nesting_offline )  THEN
+                   bc_dirichlet_r = .TRUE.
                 ENDIF
              ENDIF
@@ -1700,23 +1673,17 @@
              IF ( psouth == MPI_PROC_NULL )  THEN
                 IF ( bc_ns_dirrad )  THEN
-                   outflow_s = .TRUE.
-                ELSEIF ( bc_ns_raddir )  THEN
-                   inflow_s  = .TRUE.
-                ELSEIF ( nest_domain )  THEN
-                   nest_bound_s = .TRUE.
-                ELSEIF ( forcing )  THEN
-                   force_bound_s = .TRUE.
+                   bc_radiation_s = .TRUE.
+                ELSEIF ( bc_ns_raddir  .OR.  child_domain  .OR.                 &
+                         nesting_offline )  THEN
+                   bc_dirichlet_s = .TRUE.
                 ENDIF
              ENDIF
 
              IF ( pnorth == MPI_PROC_NULL )  THEN
-                IF ( bc_ns_dirrad )  THEN
-                   inflow_n  = .TRUE.
+                IF ( bc_ns_dirrad  .OR.  child_domain  .OR.  nesting_offline )  &
+                THEN
+                   bc_dirichlet_n = .TRUE.
                 ELSEIF ( bc_ns_raddir )  THEN
-                   outflow_n = .TRUE.
-                ELSEIF ( nest_domain )  THEN
-                   nest_bound_n = .TRUE.
-                ELSEIF ( forcing )  THEN
-                   force_bound_n = .TRUE.
+                   bc_radiation_n = .TRUE.
                 ENDIF
              ENDIF
@@ -1897,11 +1864,9 @@
 !--          Set non-cyclic boundary conditions on respective multigrid level
              IF ( .NOT. bc_ns_cyc )  THEN
-                IF ( inflow_s  .OR.  outflow_s  .OR.  nest_bound_s  .OR.       &
-                     force_bound_s )  THEN
+                IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
 !                    topo_tmp(:,-2,:) = topo_tmp(:,0,:)
                    topo_tmp(:,-1,:) = topo_tmp(:,0,:)
                 ENDIF
-                IF ( inflow_n  .OR.  outflow_n  .OR.  nest_bound_n  .OR.       &
-                     force_bound_n )  THEN
+                IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
 !                    topo_tmp(:,nyn_l+2,:) = topo_tmp(:,nyn_l,:)
                    topo_tmp(:,nyn_l+1,:) = topo_tmp(:,nyn_l,:)
@@ -1909,11 +1874,9 @@
              ENDIF
              IF ( .NOT. bc_lr_cyc )  THEN
-                IF ( inflow_l  .OR.  outflow_l  .OR.  nest_bound_l  .OR.       &
-                     force_bound_l )  THEN
+                IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
 !                    topo_tmp(:,:,-2) = topo_tmp(:,:,0)
                    topo_tmp(:,:,-1) = topo_tmp(:,:,0)
                 ENDIF
-                IF ( inflow_r  .OR.  outflow_r  .OR.  nest_bound_r  .OR.       &
-                     force_bound_r )  THEN
+                IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
 !                    topo_tmp(:,:,nxr_l+2) = topo_tmp(:,:,nxr_l)      
                    topo_tmp(:,:,nxr_l+1) = topo_tmp(:,:,nxr_l)    
Index: palm/trunk/SOURCE/pres.f90
===================================================================
--- palm/trunk/SOURCE/pres.f90	(revision 3178)
+++ palm/trunk/SOURCE/pres.f90	(revision 3182)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! ------------------
-! 
+! Rename variables for boundary flags and nesting
 ! 
 ! Former revisions:
@@ -161,10 +161,11 @@
 
     USE control_parameters,                                                    &
-        ONLY:  bc_lr_cyc, bc_ns_cyc, conserve_volume_flow, coupling_mode,      &
+        ONLY:  bc_lr_cyc, bc_ns_cyc, bc_radiation_l, bc_radiation_n,           &
+               bc_radiation_r, bc_radiation_s, child_domain,                   &
+               conserve_volume_flow, coupling_mode,                            &
                dt_3d, gathered_size, ibc_p_b, ibc_p_t,                         &
                intermediate_timestep_count, intermediate_timestep_count_max,   &
-               mg_switch_to_pe0_level, nest_domain, outflow_l, outflow_n,      &
-               outflow_r, outflow_s, psolver, subdomain_size, topography,      &
-               volume_flow, volume_flow_area, volume_flow_initial
+               mg_switch_to_pe0_level, psolver, subdomain_size,                &
+               topography, volume_flow, volume_flow_area, volume_flow_initial
 
     USE cpulog,                                                                &
@@ -219,5 +220,5 @@
     REAL(wp), DIMENSION(1:nzt) ::  w_l_l               !<
 
-    LOGICAL :: nest_domain_nvn      !<
+    LOGICAL :: child_domain_nvn      !<
 
 
@@ -280,12 +281,13 @@
 !
 !-- Left/right
-    IF ( conserve_volume_flow  .AND.  ( outflow_l .OR. outflow_r ) )  THEN
+    IF ( conserve_volume_flow  .AND.  ( bc_radiation_l .OR.                    &
+                                        bc_radiation_r ) )  THEN
 
        volume_flow(1)   = 0.0_wp
        volume_flow_l(1) = 0.0_wp
 
-       IF ( outflow_l )  THEN
+       IF ( bc_radiation_l )  THEN
           i = 0
-       ELSEIF ( outflow_r )  THEN
+       ELSEIF ( bc_radiation_r )  THEN
           i = nx+1
        ENDIF
@@ -325,12 +327,12 @@
 !
 !-- South/north
-    IF ( conserve_volume_flow  .AND.  ( outflow_n .OR. outflow_s ) )  THEN
+    IF ( conserve_volume_flow  .AND.  ( bc_radiation_n .OR. bc_radiation_s ) )  THEN
 
        volume_flow(2)   = 0.0_wp
        volume_flow_l(2) = 0.0_wp
 
-       IF ( outflow_s )  THEN
+       IF ( bc_radiation_s )  THEN
           j = 0
-       ELSEIF ( outflow_n )  THEN
+       ELSEIF ( bc_radiation_n )  THEN
           j = ny+1
        ENDIF
@@ -372,15 +374,15 @@
 !-- used both at bottom and top boundary, and if not a nested domain in a 
 !-- normal nesting run. In case of vertical nesting, this must be done.
-!-- Therefore an auxiliary logical variable nest_domain_nvn is used here, and 
+!-- Therefore an auxiliary logical variable child_domain_nvn is used here, and 
 !-- nvn stands for non-vertical nesting. 
 !-- This cannot be done before the first initial time step because ngp_2dh_outer
 !-- is not yet known then.
-    nest_domain_nvn = nest_domain
-    IF ( nest_domain .AND. nesting_mode == 'vertical' )  THEN
-       nest_domain_nvn = .FALSE.
+    child_domain_nvn = child_domain
+    IF ( child_domain .AND. nesting_mode == 'vertical' )  THEN
+       child_domain_nvn = .FALSE.
     ENDIF
 
     IF ( ibc_p_b == 1  .AND.  ibc_p_t == 1  .AND.                               &
-         .NOT. nest_domain_nvn  .AND. intermediate_timestep_count /= 0 )        &
+         .NOT. child_domain_nvn  .AND. intermediate_timestep_count /= 0 )       &
     THEN
        w_l = 0.0_wp;  w_l_l = 0.0_wp
@@ -758,5 +760,5 @@
 !-- height nzt after above modifications. Hint: w level nzt+1 does not impact
 !-- results. 
-    IF (nest_domain .OR. coupling_mode == 'vnested_fine') THEN
+    IF ( child_domain  .OR.  coupling_mode == 'vnested_fine' ) THEN
        w(nzt+1,:,:) = w(nzt,:,:)
     ENDIF
Index: palm/trunk/SOURCE/prognostic_equations.f90
===================================================================
--- palm/trunk/SOURCE/prognostic_equations.f90	(revision 3178)
+++ palm/trunk/SOURCE/prognostic_equations.f90	(revision 3182)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! ------------------
-! 
+! Remove unused variables from USE statements
 ! 
 ! Former revisions:
@@ -297,10 +297,9 @@
                cloud_physics, cloud_top_radiation, constant_diffusion,         &
                dp_external, dp_level_ind_b, dp_smooth_factor, dpdxy, dt_3d,    &
-               humidity,                                                       &
-               inflow_l, intermediate_timestep_count,                          &
+               humidity, intermediate_timestep_count,                          &
                intermediate_timestep_count_max, large_scale_forcing,           &
                large_scale_subsidence, microphysics_morrison,                  &
                microphysics_seifert, microphysics_sat_adjust, neutral, nudging,&
-               ocean, outflow_l, outflow_s, passive_scalar, plant_canopy,      &
+               ocean, passive_scalar, plant_canopy,                            &
                prho_reference, prho_reference,                                 &
                prho_reference, pt_reference, pt_reference, pt_reference,       &
Index: palm/trunk/SOURCE/read_restart_data_mod.f90
===================================================================
--- palm/trunk/SOURCE/read_restart_data_mod.f90	(revision 3178)
+++ palm/trunk/SOURCE/read_restart_data_mod.f90	(revision 3182)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Rename variables for boundary flags
 ! 
 ! Former revisions:
@@ -1765,5 +1765,5 @@
                       READ ( 13 )  tmp_3dwul
                    ENDIF
-                   IF ( outflow_l )  THEN
+                   IF ( bc_radiation_l )  THEN
                       u_m_l(:,nysc-nbgp:nync+nbgp,:) =                         & 
                          tmp_3dwul(:,nysf-nbgp:nynf+nbgp,:)
@@ -1776,5 +1776,5 @@
                       READ ( 13 )  tmp_3dwun
                    ENDIF
-                   IF ( outflow_n )  THEN
+                   IF ( bc_radiation_n )  THEN
                       u_m_n(:,:,nxlc-nbgp:nxrc+nbgp) =                         & 
                          tmp_3dwun(:,:,nxlf-nbgp:nxrf+nbgp)
@@ -1787,5 +1787,5 @@
                       READ ( 13 )  tmp_3dwur
                    ENDIF
-                   IF ( outflow_r )  THEN
+                   IF ( bc_radiation_r )  THEN
                       u_m_r(:,nysc-nbgp:nync+nbgp,:) =                         & 
                          tmp_3dwur(:,nysf-nbgp:nynf+nbgp,:)
@@ -1798,5 +1798,5 @@
                       READ ( 13 )  tmp_3dwus
                    ENDIF
-                   IF ( outflow_s )  THEN
+                   IF ( bc_radiation_s )  THEN
                       u_m_s(:,:,nxlc-nbgp:nxrc+nbgp) =                         &
                          tmp_3dwus(:,:,nxlf-nbgp:nxrf+nbgp)
@@ -1830,5 +1830,5 @@
                       READ ( 13 )  tmp_3dwvl
                    ENDIF
-                   IF ( outflow_l )  THEN
+                   IF ( bc_radiation_l )  THEN
                       v_m_l(:,nysc-nbgp:nync+nbgp,:) =                         & 
                          tmp_3dwvl(:,nysf-nbgp:nynf+nbgp,:)
@@ -1841,5 +1841,5 @@
                       READ ( 13 )  tmp_3dwvn
                    ENDIF
-                   IF ( outflow_n )  THEN
+                   IF ( bc_radiation_n )  THEN
                       v_m_n(:,:,nxlc-nbgp:nxrc+nbgp) =                         &
                          tmp_3dwvn(:,:,nxlf-nbgp:nxrf+nbgp)
@@ -1852,5 +1852,5 @@
                       READ ( 13 )  tmp_3dwvr
                    ENDIF
-                   IF ( outflow_r )  THEN
+                   IF ( bc_radiation_r )  THEN
                       v_m_r(:,nysc-nbgp:nync+nbgp,:) =                         &
                          tmp_3dwvr(:,nysf-nbgp:nynf+nbgp,:)
@@ -1863,5 +1863,5 @@
                       READ ( 13 )  tmp_3dwvs
                    ENDIF
-                   IF ( outflow_s )  THEN
+                   IF ( bc_radiation_s )  THEN
                       v_m_s(:,:,nxlc-nbgp:nxrc+nbgp) =                         &
                          tmp_3dwvs(:,:,nxlf-nbgp:nxrf+nbgp)
@@ -1900,5 +1900,5 @@
                       READ ( 13 )  tmp_3dwwl
                    ENDIF
-                   IF ( outflow_l )  THEN
+                   IF ( bc_radiation_l )  THEN
                       w_m_l(:,nysc-nbgp:nync+nbgp,:) =                         & 
                          tmp_3dwwl(:,nysf-nbgp:nynf+nbgp,:)
@@ -1911,5 +1911,5 @@
                       READ ( 13 )  tmp_3dwwn
                    ENDIF
-                   IF ( outflow_n )  THEN
+                   IF ( bc_radiation_n )  THEN
                       w_m_n(:,:,nxlc-nbgp:nxrc+nbgp) =                         &
                          tmp_3dwwn(:,:,nxlf-nbgp:nxrf+nbgp)
@@ -1922,5 +1922,5 @@
                       READ ( 13 )  tmp_3dwwr
                    ENDIF
-                   IF ( outflow_r )  THEN
+                   IF ( bc_radiation_r )  THEN
                       w_m_r(:,nysc-nbgp:nync+nbgp,:) =                         & 
                          tmp_3dwwr(:,nysf-nbgp:nynf+nbgp,:)
@@ -1933,5 +1933,5 @@
                       READ ( 13 )  tmp_3dwws
                    ENDIF
-                   IF ( outflow_s )  THEN
+                   IF ( bc_radiation_s )  THEN
                       w_m_s(:,:,nxlc-nbgp:nxrc+nbgp) =                         & 
                          tmp_3dwws(:,:,nxlf-nbgp:nxrf+nbgp)
Index: palm/trunk/SOURCE/sor.f90
===================================================================
--- palm/trunk/SOURCE/sor.f90	(revision 3178)
+++ palm/trunk/SOURCE/sor.f90	(revision 3182)
@@ -20,9 +20,12 @@
 ! Current revisions:
 ! -----------------
-! 
+! Rename variables in mesoscale-offline nesting mode
 ! 
 ! Former revisions:
 ! -----------------
 ! $Id$
+! Corrected "Former revisions" section
+! 
+! 2718 2018-01-02 08:49:38Z maronga
 ! Corrected "Former revisions" section
 ! 
@@ -82,9 +85,8 @@
 
     USE control_parameters,                                                    &
-        ONLY:  bc_lr_cyc, bc_ns_cyc, force_bound_l, force_bound_n,             &
-               force_bound_r, force_bound_s, ibc_p_b, ibc_p_t, inflow_l,       &
-               inflow_n, inflow_r, inflow_s, nest_bound_l, nest_bound_n,       &
-               nest_bound_r, nest_bound_s, n_sor, omega_sor, outflow_l,        &
-               outflow_n, outflow_r, outflow_s
+        ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,                 &
+               bc_dirichlet_s, bc_lr_cyc, bc_ns_cyc, bc_radiation_l,           &
+               bc_radiation_n, bc_radiation_r, bc_radiation_s, ibc_p_b,        &
+               ibc_p_t, n_sor, omega_sor
 
     IMPLICIT NONE
@@ -175,14 +177,10 @@
 !--    Horizontal (Neumann) boundary conditions in case of non-cyclic boundaries
        IF ( .NOT. bc_lr_cyc )  THEN
-          IF ( inflow_l      .OR.  outflow_l  .OR.                                 &
-               nest_bound_l  .OR.  force_bound_l )  p(:,:,nxl-1) = p(:,:,nxl)
-          IF ( inflow_r      .OR.  outflow_r  .OR.                                 &
-               nest_bound_r  .OR.  force_bound_r )  p(:,:,nxr+1) = p(:,:,nxr)
+          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  p(:,:,nxl-1) = p(:,:,nxl)
+          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  p(:,:,nxr+1) = p(:,:,nxr)
        ENDIF
        IF ( .NOT. bc_ns_cyc )  THEN
-          IF ( inflow_n      .OR.  outflow_n  .OR.                                 &
-               nest_bound_n  .OR.  force_bound_n )  p(:,nyn+1,:) = p(:,nyn,:)
-          IF ( inflow_s      .OR.  outflow_s  .OR.                                 &
-               nest_bound_s  .OR.  force_bound_s )  p(:,nys-1,:) = p(:,nys,:)
+          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  p(:,nyn+1,:) = p(:,nyn,:)
+          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  p(:,nys-1,:) = p(:,nys,:)
        ENDIF
 
@@ -241,14 +239,10 @@
 !--    Horizontal (Neumann) boundary conditions in case of non-cyclic boundaries
        IF ( .NOT. bc_lr_cyc )  THEN
-          IF ( inflow_l      .OR.  outflow_l  .OR.                             &
-               nest_bound_l  .OR.  force_bound_l )  p(:,:,nxl-1) = p(:,:,nxl)
-          IF ( inflow_r      .OR.  outflow_r  .OR.                             &
-               nest_bound_r  .OR.  force_bound_r )  p(:,:,nxr+1) = p(:,:,nxr)
+          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  p(:,:,nxl-1) = p(:,:,nxl)
+          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  p(:,:,nxr+1) = p(:,:,nxr)
        ENDIF
        IF ( .NOT. bc_ns_cyc )  THEN
-          IF ( inflow_n      .OR.  outflow_n  .OR.                             &
-               nest_bound_n  .OR.  force_bound_n )  p(:,nyn+1,:) = p(:,nyn,:)
-          IF ( inflow_s      .OR.  outflow_s  .OR.                             &
-               nest_bound_s  .OR.  force_bound_s )  p(:,nys-1,:) = p(:,nys,:)
+          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  p(:,nyn+1,:) = p(:,nyn,:)
+          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  p(:,nys-1,:) = p(:,nys,:)
        ENDIF
 
Index: palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90
===================================================================
--- palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90	(revision 3178)
+++ palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90	(revision 3182)
@@ -20,5 +20,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! Rename variables and extend error message
+! Enable geneartor also for stretched grids
 ! 
 ! Former revisions:
@@ -119,6 +120,4 @@
 !> @bug  Height information from input file is not used. Profiles from input
 !>       must match with current PALM grid.
-!>       Transformation of length scales to number of gridpoints does not
-!>       consider grid stretching.
 !>       In case of restart, velocity seeds differ from precursor run if a11,
 !>       a22, or a33 are zero.
@@ -160,4 +159,5 @@
     INCLUDE "mpif.h"
 #endif
+
 
     LOGICAL :: velocity_seed_initialized = .FALSE.  !< true after first call of stg_main
@@ -317,6 +317,6 @@
 
     USE control_parameters,                                                    &
-        ONLY:  bc_lr, bc_ns, forcing, nest_domain, number_stretch_level_start, &
-               rans_mode, turbulent_inflow
+        ONLY:  bc_lr, bc_ns, child_domain, nesting_offline,                    &
+               number_stretch_level_start, rans_mode, turbulent_inflow
 
     USE pmc_interface,                                                         &
@@ -326,11 +326,16 @@
     IMPLICIT NONE
 
-    IF ( .NOT. use_syn_turb_gen  .AND.  .NOT. rans_mode  .AND.  forcing )  THEN
-       message_string = 'Synthetic turbulence generator has to be applied ' // &
-                        'when forcing is used and model operates in LES mode.'
-       CALL message( 'stg_check_parameters', 'PA0000', 1, 2, 0, 6, 0 )
+    IF ( .NOT. use_syn_turb_gen  .AND.  .NOT. rans_mode  .AND.                 &
+          nesting_offline )  THEN
+       message_string = 'No synthetic turbulence generator is applied. ' //    &
+                        'In case PALM operates in LES mode and lateral ' //    &
+                        'boundary conditions are provided by COSMO model, ' // &
+                        'turbulence may require large adjustment lenght at ' //&
+                        'the lateral inflow boundaries. Please check your ' // &
+                        'results carefully.' 
+       CALL message( 'stg_check_parameters', 'PA0000', 0, 0, 0, 6, 0 )
     ENDIF
 
-    IF ( .NOT. use_syn_turb_gen  .AND.  nest_domain                            &
+    IF ( .NOT. use_syn_turb_gen  .AND.  child_domain                           &
          .AND. rans_mode_parent  .AND.  .NOT. rans_mode )  THEN
        message_string = 'Synthetic turbulence generator has to be applied ' // &
@@ -342,6 +347,6 @@
     IF ( use_syn_turb_gen )  THEN
 
-       IF ( .NOT. forcing  .AND.  .NOT. nest_domain )  THEN
-
+       IF ( .NOT. nesting_offline  .AND.  .NOT. child_domain )  THEN 
+       
           IF ( INDEX( initializing_actions, 'set_constant_profiles' ) == 0     &
         .AND.  INDEX( initializing_actions, 'read_restart_data' ) == 0 )  THEN
@@ -371,10 +376,4 @@
           CALL message( 'stg_check_parameters', 'PA0039', 1, 2, 0, 6, 0 )
        ENDIF
-       
-       IF ( number_stretch_level_start > 0 )  THEN
-          message_string = 'Using synthetic turbulence generator ' //          &
-                           'in combination with stretching is not allowed'
-          CALL message( 'stg_check_parameters', 'PA0420', 1, 2, 0, 6, 0 )
-       ENDIF
 
     ENDIF
@@ -424,5 +423,6 @@
 
     USE control_parameters,                                                    &
-        ONLY:  coupling_char, dz, e_init, forcing, nest_domain, rans_mode
+        ONLY:  child_domain, coupling_char, dz, e_init, nesting_offline,       &
+               rans_mode
 
     USE grid_variables,                                                        &
@@ -512,6 +512,6 @@
 !        nzt_x_stg = myidx * nnz + MOD( nz , pdims(1) )
 
-    IF ( forcing  .OR.  ( nest_domain .AND.  rans_mode_parent  .AND.           &
-                   .NOT.  rans_mode ) )  THEN
+    IF ( nesting_offline   .OR.  ( child_domain  .AND.  rans_mode_parent       &
+                            .AND.  .NOT.  rans_mode ) )  THEN
        nnz = nz / pdims(2)
        nzb_y_stg = 1 + myidy * INT( nnz )
@@ -558,6 +558,6 @@
 !-- layer
 !-- stg_type_xz: xz-slice with vertical bounds nzb:nzt+1
-    IF ( forcing  .OR.  ( nest_domain .AND.  rans_mode_parent  .AND.           &
-                   .NOT.  rans_mode ) )  THEN
+    IF ( nesting_offline  .OR.  ( child_domain .AND.  rans_mode_parent         &
+                           .AND.  .NOT.  rans_mode ) )  THEN
        CALL MPI_TYPE_CREATE_SUBARRAY( 2, [nzt-nzb+2,nxrg-nxlg+1],              &
                [1,nxrg-nxlg+1], [0,0], MPI_ORDER_FORTRAN, MPI_REAL, newtype, ierr )
@@ -612,5 +612,5 @@
        READ( 90, * )
 
-       DO  k = nzb, nzt+1
+       DO  k = nzb+1, nzt+1
           READ( 90, * ) zz, luy, luz, tu(k), lvy, lvz, tv(k), lwy, lwz, tw(k), &
                         r11(k), r21(k), r22(k), r31(k), r32(k), r33(k),        &
@@ -618,12 +618,11 @@
 
 !
-!--       Convert length scales from meter to number of grid points. Attention:
-!--       Does not work if grid stretching is used
+!--       Convert length scales from meter to number of grid points. 
           nuy(k) = INT( luy * ddy )
-          nuz(k) = INT( luz / dz(1)  )
+          nuz(k) = INT( luz * ddzw(k) )
           nvy(k) = INT( lvy * ddy )
-          nvz(k) = INT( lvz / dz(1)  )
+          nvz(k) = INT( lvz * ddzw(k) )
           nwy(k) = INT( lwy * ddy )
-          nwz(k) = INT( lwz / dz(1)  )
+          nwz(k) = INT( lwz * ddzw(k) )
 !
 !--       Workaround, assume isotropic turbulence
@@ -640,5 +639,13 @@
           ENDIF
        ENDDO
-
+!
+!--    Set lenght scales at surface grid point
+       nuy(nzb) = nuy(nzb+1) 
+       nuz(nzb) = nuz(nzb+1)
+       nvy(nzb) = nvy(nzb+1)
+       nvz(nzb) = nvz(nzb+1)
+       nwy(nzb) = nwy(nzb+1)
+       nwz(nzb) = nwz(nzb+1)
+       
        CLOSE( 90 )
 
@@ -710,5 +717,5 @@
 !
 !-- Assign initial profiles
-    IF ( .NOT. forcing  .AND.  .NOT.  nest_domain )  THEN
+    IF ( .NOT. nesting_offline  .AND.  .NOT.  child_domain )  THEN 
        u_init = mean_inflow_profiles(:,1)
        v_init = mean_inflow_profiles(:,2)
@@ -1042,6 +1049,6 @@
 
     USE control_parameters,                                                    &
-        ONLY:  dt_3d, forcing, intermediate_timestep_count,  nest_domain,      &
-               rans_mode, simulated_time, volume_flow_initial
+        ONLY:  child_domain, dt_3d, intermediate_timestep_count,               &
+               nesting_offline, rans_mode, simulated_time, volume_flow_initial
 
     USE grid_variables,                                                        &
@@ -1086,6 +1093,6 @@
        CALL stg_generate_seed_yz( nwy, nwz, bwy, bwz, fw_yz, id_stg_left )
 
-       IF ( forcing  .OR.  ( nest_domain .AND.  rans_mode_parent  .AND.        &
-                      .NOT.  rans_mode ) )  THEN
+       IF ( nesting_offline  .OR.  ( child_domain .AND.  rans_mode_parent      &
+                                .AND.  .NOT.  rans_mode ) )  THEN
 !
 !--       Generate turbulence at right boundary
@@ -1112,6 +1119,6 @@
     CALL stg_generate_seed_yz( nwy, nwz, bwy, bwz, fwo_yz, id_stg_left )
 
-    IF ( forcing  .OR.  ( nest_domain .AND.  rans_mode_parent  .AND.           &
-                   .NOT.  rans_mode ) )  THEN
+    IF ( nesting_offline  .OR.  ( child_domain .AND.  rans_mode_parent         &
+                             .AND.  .NOT.  rans_mode ) )  THEN
 !
 !--       Generate turbulence at right boundary
@@ -1191,5 +1198,5 @@
 !--    This correction factor insures that the mass flux is preserved at the
 !--    inflow boundary
-       IF ( .NOT. forcing  .AND.  .NOT. nest_domain )  THEN
+       IF ( .NOT. nesting_offline  .AND.  .NOT. child_domain )  THEN 
           mc_factor_l = 0.0_wp
           mc_factor   = 0.0_wp
Index: palm/trunk/SOURCE/time_integration.f90
===================================================================
--- palm/trunk/SOURCE/time_integration.f90	(revision 3178)
+++ palm/trunk/SOURCE/time_integration.f90	(revision 3182)
@@ -20,5 +20,6 @@
 ! Current revisions:
 ! ------------------
-! 
+! Replace simulated_time by time_since_reference_point in COSMO nesting mode. 
+! Rename subroutines and variables in COSMO nesting mode
 ! 
 ! Former revisions:
@@ -368,6 +369,6 @@
         ONLY:  advected_distance_x, advected_distance_y, air_chemistry,        &
                average_count_3d, averaging_interval, averaging_interval_pr,    &
-               bc_lr_cyc, bc_ns_cyc, bc_pt_t_val,                              &
-               bc_q_t_val, call_psolver_at_all_substeps, cloud_droplets,       &
+               bc_lr_cyc, bc_ns_cyc, bc_pt_t_val, bc_q_t_val,                  &
+               call_psolver_at_all_substeps,  child_domain, cloud_droplets,    &
                cloud_physics, constant_flux_layer, constant_heatflux,          &
                create_disturbances, dopr_n, constant_diffusion, coupling_mode, &
@@ -378,10 +379,11 @@
                dt_do2d_xz, dt_do2d_yz, dt_do3d, dt_domask,dt_dopts, dt_dopr,   &
                dt_dopr_listing, dt_dots, dt_dvrp, dt_run_control, end_time,    &
-               first_call_lpm, first_call_mas, forcing, galilei_transformation,&
+               first_call_lpm, first_call_mas, galilei_transformation,         &
                humidity, intermediate_timestep_count,                          &
-               intermediate_timestep_count_max, land_surface,                  &
-               large_scale_forcing, loop_optimization, lsf_surf, lsf_vert,     &
-               masks, microphysics_morrison, microphysics_seifert, mid,        &
-               nest_domain, neutral, nr_timesteps_this_run, nudging,           &
+               intermediate_timestep_count_max,                                &
+               land_surface, large_scale_forcing,                              &
+               loop_optimization, lsf_surf, lsf_vert, masks,                   &
+               microphysics_morrison, microphysics_seifert, mid,               &
+               nesting_offline, neutral, nr_timesteps_this_run, nudging,       &
                ocean, passive_scalar, prho_reference, pt_reference,            &
                pt_slope_offset, random_heatflux, rans_mode,                    &
@@ -426,11 +428,11 @@
     USE lsf_nudging_mod,                                                       &
         ONLY:  calc_tnudge, ls_forcing_surf, ls_forcing_vert, nudge_ref,       &
-               forcing_bc, forcing_bc_mass_conservation
-
-    USE netcdf_data_input_mod,                                                 &
-        ONLY:  force, netcdf_data_input_lsf
+               lsf_nesting_offline, lsf_nesting_offline_mass_conservation
 
     USE microphysics_mod,                                                      &
         ONLY: collision_turbulence
+
+    USE netcdf_data_input_mod,                                                 &
+        ONLY:  nest_offl, netcdf_data_input_lsf
 
     USE multi_agent_system_mod,                                                &
@@ -594,6 +596,6 @@
 !--    If forcing by larger-scale models is applied, check if new data
 !--    at domain boundaries need to be read.
-       IF ( forcing )  THEN
-          IF ( force%time(force%tind_p) <= simulated_time )                    &
+       IF ( nesting_offline )  THEN
+          IF ( nest_offl%time(nest_offl%tind_p) <= time_since_reference_point )&
              CALL netcdf_data_input_lsf
        ENDIF
@@ -843,7 +845,8 @@
 !--          Commented out April 18, 2018 as seemingly unnecessary. 
 !--          Will later be completely removed.
-!--             IF ( nest_domain )  THEN
+!--             IF ( child_domain )  THEN
 !--                CALL pmci_ensure_nest_mass_conservation
 !--             ENDIF
+
 
              CALL cpu_log( log_point(60), 'nesting', 'stop' )
@@ -888,5 +891,6 @@
                    CALL disturb_field( 'v', tend, v )
                 ELSEIF ( ( .NOT. bc_lr_cyc  .OR.  .NOT. bc_ns_cyc )            &
-                     .AND. .NOT. nest_domain  .AND.  .NOT.  forcing )  THEN
+                     .AND. .NOT. child_domain  .AND.  .NOT.  nesting_offline )  &
+                THEN
 !
 !--                Runs with a non-cyclic lateral wall need perturbations
@@ -904,10 +908,10 @@
 !--       Map forcing data derived from larger scale model onto domain 
 !--       boundaries. 
-          IF ( forcing  .AND.  intermediate_timestep_count ==                  &
-                               intermediate_timestep_count_max  )  THEN
-             CALL forcing_bc
+          IF ( nesting_offline  .AND.  intermediate_timestep_count ==          &
+                                       intermediate_timestep_count_max  )  THEN
+             CALL lsf_nesting_offline
 !
 !--          Moreover, ensure mass conservation
-             CALL forcing_bc_mass_conservation
+             CALL lsf_nesting_offline_mass_conservation
           ENDIF
 
Index: palm/trunk/SOURCE/turbulence_closure_mod.f90
===================================================================
--- palm/trunk/SOURCE/turbulence_closure_mod.f90	(revision 3178)
+++ palm/trunk/SOURCE/turbulence_closure_mod.f90	(revision 3182)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Rename variables and remove unused variable from USE statement
 ! 
 ! Former revisions:
@@ -149,5 +149,5 @@
 
     USE control_parameters,                                                    &
-        ONLY:  constant_diffusion, dt_3d, e_init, humidity, inflow_l,          &
+        ONLY:  constant_diffusion, dt_3d, e_init, humidity,                    &
                initializing_actions, intermediate_timestep_count,              &
                intermediate_timestep_count_max, kappa, km_constant,            &
@@ -212,4 +212,5 @@
 
     REAL(wp), DIMENSION(:), ALLOCATABLE ::  l_black    !< mixing length according to Blackadar
+
     REAL(wp), DIMENSION(:), ALLOCATABLE ::  l_grid     !< geometric mean of grid sizes dx, dy, dz 
 
@@ -378,6 +379,5 @@
 
     USE control_parameters,                                                    &
-        ONLY:  message_string, nest_domain, neutral, turbulent_inflow,         &
-               turbulent_outflow
+        ONLY:  message_string, neutral, turbulent_inflow, turbulent_outflow
 
     IMPLICIT NONE
@@ -1049,5 +1049,5 @@
 
     USE control_parameters,                                                    &
-        ONLY:  complex_terrain, dissipation_1d, topography
+        ONLY:  bc_dirichlet_l, complex_terrain, dissipation_1d, topography
 
     USE model_1d_mod,                                                          &
@@ -1252,5 +1252,5 @@
 !--       Use these mean profiles at the inflow (provided that Dirichlet
 !--       conditions are used)
-          IF ( inflow_l )  THEN
+          IF ( bc_dirichlet_l )  THEN
              DO  j = nysg, nyng
                 DO  k = nzb, nzt+1
@@ -4613,5 +4613,6 @@
 
     USE control_parameters,                                                    &
-        ONLY:  e_min, outflow_l, outflow_n, outflow_r, outflow_s
+        ONLY:  bc_radiation_l, bc_radiation_n, bc_radiation_r, bc_radiation_s, &
+               e_min
 
     USE surface_layer_fluxes_mod,                                              &
@@ -4772,17 +4773,17 @@
 !-- Set Neumann boundary conditions at the outflow boundaries in case of
 !-- non-cyclic lateral boundaries
-    IF ( outflow_l )  THEN
+    IF ( bc_radiation_l )  THEN
        km(:,:,nxl-1) = km(:,:,nxl)
        kh(:,:,nxl-1) = kh(:,:,nxl)
     ENDIF
-    IF ( outflow_r )  THEN
+    IF ( bc_radiation_r )  THEN
        km(:,:,nxr+1) = km(:,:,nxr)
        kh(:,:,nxr+1) = kh(:,:,nxr)
     ENDIF
-    IF ( outflow_s )  THEN
+    IF ( bc_radiation_s )  THEN
        km(:,nys-1,:) = km(:,nys,:)
        kh(:,nys-1,:) = kh(:,nys,:)
     ENDIF
-    IF ( outflow_n )  THEN
+    IF ( bc_radiation_n )  THEN
        km(:,nyn+1,:) = km(:,nyn,:)
        kh(:,nyn+1,:) = kh(:,nyn,:)
Index: palm/trunk/SOURCE/virtual_flight_mod.f90
===================================================================
--- palm/trunk/SOURCE/virtual_flight_mod.f90	(revision 3178)
+++ palm/trunk/SOURCE/virtual_flight_mod.f90	(revision 3182)
@@ -978,5 +978,4 @@
 
        IMPLICIT NONE
-
  
        CALL wrd_write_string( 'u_agl' )
@@ -984,4 +983,5 @@
 
        CALL wrd_write_string( 'v_agl' )
+
        WRITE ( 14 )  v_agl
 
@@ -997,5 +997,4 @@
        CALL wrd_write_string( 'z_pos' )
        WRITE ( 14 )  z_pos
-
        
     END SUBROUTINE flight_wrd_global    
Index: palm/trunk/SOURCE/wind_turbine_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/wind_turbine_model_mod.f90	(revision 3178)
+++ palm/trunk/SOURCE/wind_turbine_model_mod.f90	(revision 3182)
@@ -1565,4 +1565,5 @@
 !--          Interpolation of lift and drag coefficiencts on fine grid of radius 
 !--          segments and angles of attack
+
              turb_cl_tab(iialpha,iir) = ( alpha_attack_tab(ialpha) -           &
                                           alpha_attack_i ) /                   &
Index: palm/trunk/UTIL/inifor/Makefile
===================================================================
--- palm/trunk/UTIL/inifor/Makefile	(revision 3178)
+++ palm/trunk/UTIL/inifor/Makefile	(revision 3182)
@@ -20,4 +20,5 @@
 # Current revisions:
 # -----------------
+# Added __netcdf4 preprocessor flag
 # 
 # 
@@ -51,5 +52,5 @@
 		  -Wline-truncation -fbacktrace -fcheck=all -pedantic \
 		  -ffpe-trap=invalid,zero,underflow,overflow
-FFLAGS  = -fdefault-real-8 -Og -g $(WRNGS)
+FFLAGS  = -fdefault-real-8 -Og -g $(WRNGS) -cpp -D__netcdf4
 INCLUDE = -I/home/ekadasch/local/include
 LIBRARY = -L/home/ekadasch/local/lib64 -lnetcdff
Index: palm/trunk/UTIL/inifor/Makefile.gnu
===================================================================
--- palm/trunk/UTIL/inifor/Makefile.gnu	(revision 3178)
+++ palm/trunk/UTIL/inifor/Makefile.gnu	(revision 3182)
@@ -20,5 +20,7 @@
 # Current revisions:
 # -----------------
-# 
+# Added __netcdf4 preprocessor flag
+# Corrected compilation order
+#
 # 
 # Former revisions:
@@ -43,5 +45,5 @@
 TEST_PATH = $(PROJECT_PATH)/tests
 
-MODULES = $(SRC_PATH)/defs.mod $(SRC_PATH)/control.mod $(SRC_PATH)/util.mod $(SRC_PATH)/types.mod $(SRC_PATH)/transform.mod $(SRC_PATH)/io.mod $(SRC_PATH)/grid.mod
+MODULES = $(SRC_PATH)/defs.mod $(SRC_PATH)/util.mod $(SRC_PATH)/control.mod $(SRC_PATH)/types.mod $(SRC_PATH)/transform.mod $(SRC_PATH)/io.mod $(SRC_PATH)/grid.mod
 SOURCES = $(MODULES:%.mod=%.f90) $(SRC_PATH)/$(PROJECT).f90
 OBJECTS = $(SOURCES:%.f90=%.o)
@@ -51,5 +53,5 @@
 		  -Wline-truncation -fbacktrace -fcheck=all -pedantic \
 		  -ffpe-trap=invalid,zero,underflow,overflow
-FFLAGS  = -fdefault-real-8 -Og -g $(WRNGS)
+FFLAGS  = -fdefault-real-8 -Og -g $(WRNGS) -cpp -D__netcdf4
 INCLUDE = -I/home/ekadasch/local/include
 LIBRARY = -L/home/ekadasch/local/lib64 -lnetcdff
@@ -57,5 +59,5 @@
 .PHONY: all clean doc run tags test test-verbose $(PROJECT)
 
-$(PROJECT): $(OBJECTS) $(MODULES)
+$(PROJECT): $(OBJECTS) $(MODULES) tags
 	@echo ""
 	mkdir -p $(BIN_PATH)
@@ -78,6 +80,4 @@
 	rm -rf ./doc/latex ./doc/html
 	rm -f $(SRC_PATH)/tags
-	rm -f *.files
-	rm -f palm-hsurf.nc
 	$(MAKE) -C $(TEST_PATH) clean
 	$(MAKE) -C $(SRC_PATH) clean
Index: palm/trunk/UTIL/inifor/Makefile.ifort
===================================================================
--- palm/trunk/UTIL/inifor/Makefile.ifort	(revision 3178)
+++ palm/trunk/UTIL/inifor/Makefile.ifort	(revision 3182)
@@ -20,5 +20,7 @@
 # Current revisions:
 # -----------------
-# 
+# Added __netcdf4 preprocessor flag
+# Corrected compilation order
+#
 # 
 # Former revisions:
@@ -43,10 +45,10 @@
 TEST_PATH = $(PROJECT_PATH)/tests
 
-MODULES = $(SRC_PATH)/defs.mod $(SRC_PATH)/control.mod $(SRC_PATH)/util.mod $(SRC_PATH)/types.mod $(SRC_PATH)/transform.mod $(SRC_PATH)/io.mod $(SRC_PATH)/grid.mod
+MODULES = $(SRC_PATH)/defs.mod $(SRC_PATH)/util.mod $(SRC_PATH)/control.mod $(SRC_PATH)/types.mod $(SRC_PATH)/transform.mod $(SRC_PATH)/io.mod $(SRC_PATH)/grid.mod
 SOURCES = $(MODULES:%.mod=%.f90) $(SRC_PATH)/$(PROJECT).f90
 OBJECTS = $(SOURCES:%.f90=%.o)
 
 FC      = ifort
-FFLAGS  = -g -real-size 64 -no-wrap-margin
+FFLAGS  = -g -real-size 64 -no-wrap-margin -cpp -D__netcdf4
 INCLUDE = -I/usr/local/pkg/netcdf/4.3.2/include
 LIBRARY = -L/usr/local/pkg/netcdf/4.3.2/lib -lnetcdff
@@ -54,5 +56,5 @@
 .PHONY: all clean doc run tags test test-verbose $(PROJECT)
 
-$(PROJECT): $(OBJECTS) $(MODULES)
+$(PROJECT): $(OBJECTS) $(MODULES) tags
 	@echo ""
 	mkdir -p $(BIN_PATH)
@@ -75,8 +77,6 @@
 	rm -rf ./doc/latex ./doc/html
 	rm -f $(SRC_PATH)/tags
-	rm -f *.files
-	rm -f palm-hsurf.nc
 	$(MAKE) -C $(TEST_PATH) clean
-	$(MAKE) -C $(SRC_PATH) tags
+	$(MAKE) -C $(SRC_PATH) clean
 
 doc:
Index: palm/trunk/UTIL/inifor/README
===================================================================
--- palm/trunk/UTIL/inifor/README	(revision 3178)
+++ palm/trunk/UTIL/inifor/README	(revision 3182)
@@ -1,3 +1,3 @@
-INIFOR - Initialization and Forcing of PALM-4U (v1.1.5)
+# INIFOR - Mesoscale Interface for Initializing and Forcing PALM-4U (v1.3.0)
 
 INIFOR provides the meteorological fields required to initialize and drive the
@@ -5,54 +5,123 @@
 interpolated from output data of the meso-scale model COSMO.
 
-COMPILATION
+
+## COMPILATION
 
 1. Customize ./Makefile and ./tests/Makefile (netCDF library location, compiler
    and parameters, use Makefile.ifort as a template if you want to use the Intel
    Fortran compiler)
-2. $ make
+2. Run `make`
 
-USAGE
 
-1. Customize ./namelist (number or grid points and spacings, end_time)
-2. $ ./bin/inifor -path <scenario path> -date <YYYYMMDD> -clat <latitude> -clon <longitude>
+## USAGE
 
-All COMMAND-LINE PARAMETERS
+1. Customize `./namelist` (number or grid points and spacings, end_time)
+2. Run `current_version/trunk/SCRIPTS/inifor -path <scenario path> -date <YYYYMMDD>`
 
--date <date>: Start date of the simulation in the form YYYMMDD. Currently,
-    INIFOR assumes that the simulation starts at O UTC on that day.
-    Default: 20130721
 
--hhl <netCDF file>: Location of the netCDF file containing the vertical COSMO-DE
-    grid (hhh = height of half layers, i.e. vertical cell faces).
-    Default: <scenario path>/hhl.nc
+## AVAILABLE NAMELIST PARAMETERS
 
--mode profile: Produce average profiles instead of three-dimensional fields as 
-    initial conditions.
+INIFOR mirrors a subset of the PALM-4U's Fortran namelists `inipar` and `d3par`
+and supports the following parameters:
 
--n <namelist file>: Location of the PALM-4U namelist file. INIFOR expects the
-    file to contain two namelists, inipar and d3par, from which it will read
-    grid parameters and the simulation time. Default: ./namelist
 
--o <ouput file>: Name of the INIFOR output file. Default: ./palm-4u-input.nc
+### inipar
 
--p0 <pressure>: Surface pressure at z=0 in the PALM-4U domain [Pa].
-    Default: 1e5 Pa = 1000 hPa
+    nx, ny, nz - number of PALM-4U grid points in x, y, and z direction
+    dx, dy, dz(10) - PALM-4U grid spacings in x, y, and z direction [m]
+    dz_stretch_level - height above which the grid will be stretched [m]
+    dz_stretch_factor - factor by which the grid will be stretched
+    dz_max - maximum vertical grid spacing [m]
+    dz_stretch_level_start(9) - array of height levels above which the grid is
+    to be stretched vertically [m]
+    dz_stretch_level_end(9) - array of height levels until which the grid is to
+    be stretched vertically [m]
+    longitude, latitude - geographical coordinates of the PALM-4U origin [deg]
 
--path <scenario path>: Scenario path, i.e. the path of the meteorological input
-    data. Default: ./
 
--soil <netCDF file>: Location of the netCDF file containing the COSMO-DE soil type
-    map.
-    Default: <scenario path>/soil.nc
+### d3par
 
--static <static driver file>: Location of the netCDF file containing the static
-    driver file for the case to be simulated with PALM-4U. Optional parameter.
-    Default: None
+    end_time - PALM-4U simulation time. INIFOR will produce hourly forcing data
+        from the start date (see -d command-line option) to end_time seconds
+        thereafter. [s]
 
--ug <velocity>: Specifies the geostrophic wind in x direction [m/s]. Default: 0
 
--vg <velocity>: Specifies the geostrophic wind in y direction [m/s]. Default: 0
+### EXAMPLE NAMELIST FILE
 
--z0 <height>: Specifies the elevation of the the PALM-4U domain above sea level [m].
-    Default: 35 m
+    &inipar nx = 4679, ny = 3939, nz = 360
+            dx = 10., dy = 10., dz = 10.
+            dz_stretch_level = 2500.0, dz_stretch_factor = 1.08, dz_max = 100.0
+            longitude = 13.082744, latitude = 52.325079
+    /
+    
+    &d3par  end_time = 86400.0
+    /
 
+
+## AVAILABLE COMMAND-LINE PARAMETERS
+
+    -d, --date, -date <date>:
+        Start date of the simulation in the form YYYYMMDD of YYYYMMDDHH. If no
+        hours (HH) are given, INIFOR assumes that the simulation starts at O UTC
+        on that day. Default: 20130721
+        
+    -i, --init-mode, -mode <mode>:
+        Set the PALM-4U initialization mode. INIFOR can provide initial conditions
+        as either profiles or three-dimensional fields. The corresponding modes
+        are 'profile' and 'volume'. Default: volume
+
+    -l, --hhl-file, -hhl <netCDF file>:
+        Location of the netCDF file containing the vertical COSMO-DE grid levels,
+        specifically the heights of half levels (hhl, i.e. vertical cell faces).
+        Default: <scenario path>/hhl.nc
+
+    -n, --namelist <namelist file>:
+        Location of the PALM-4U namelist file. INIFOR expects the file to contain
+        two namelists, inipar and d3par, from which it will read grid parameters
+        and the simulation time. Default: ./namelist
+
+    -o, --output <output file>:
+        Name of the INIFOR output file, i.e. the PALM-4U dynamic driver.
+        Default: ./palm-4u-input.nc
+
+    -p, --path, -path <scenario path>:
+        Scenario path, i.e. the path of the meteorological input data. Default: ./
+
+    -r, --surface-pressure, -p0 <pressure>:
+        Surface pressure at z=0 in the PALM-4U domain [Pa].
+        Default: 1e5
+
+    -s, --soil-file, -soil <netCDF file>:
+        Location of the netCDF file containing the COSMO-DE soil type map.
+        Default: <scenario path>/soil.nc
+
+    -t, --static-driver, -static <netCDF file>:
+        Location of the netCDF file containing the static driver file for the case
+        to be simulated with PALM-4U. Optional parameter. Default: None
+
+    -u, --geostrophic-u, -ug <velocity>:
+        Specifies the geostrophic wind in x direction [m/s]. Default: 0
+
+    -v, --geostrophic-v, -vg <velocity>:
+        Specifies the geostrophic wind in y direction [m/s]. Default: 0
+
+    --version:
+        Output version number and exit.
+
+    -z, --elevation, -z0 <height>: Specifies the elevation of the PALM-4U domain
+        above sea level [m]. Default: 35
+
+
+## ADDITIONAL COMMAND-LINE OPTIONS
+
+    --flow-prefix <prefix>:
+        Set the file prefix of flow input files. Default: laf
+
+    --radiation-prefix <prefix>:
+        Set the file prefix of radiation input files. Default: laf
+
+    --soil-prefix <prefix>:
+        Set the file prefix of soil input files. Default: laf
+
+    --soilmoisture-prefix <prefix>:
+        Set the file prefix of soil moisture input files. Default: laf
Index: palm/trunk/UTIL/inifor/src/control.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/control.f90	(revision 3178)
+++ palm/trunk/UTIL/inifor/src/control.f90	(revision 3182)
@@ -21,4 +21,5 @@
 ! Current revisions:
 ! -----------------
+! Added version and copyright output
 ! 
 ! 
@@ -42,5 +43,5 @@
 
     USE defs,                                                                  &
-        ONLY:  LNAME, dp
+        ONLY:  LNAME, dp, VERSION, COPYRIGHT
 
     USE util,                                                                  &
@@ -95,4 +96,10 @@
 
     END SUBROUTINE abort
+
+
+    SUBROUTINE print_version()
+       PRINT *, "INIFOR " // VERSION
+       PRINT *, COPYRIGHT
+    END SUBROUTINE print_version
 
 
Index: palm/trunk/UTIL/inifor/src/defs.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/defs.f90	(revision 3178)
+++ palm/trunk/UTIL/inifor/src/defs.f90	(revision 3182)
@@ -21,4 +21,8 @@
 ! Current revisions:
 ! -----------------
+! Updated defaults for soil extrapolation steps and nudging time-scale
+! Improved handling of the start date string
+! Added gas constant for water vapor
+! Bumped INIFOR version number
 ! 
 ! 
@@ -62,5 +66,6 @@
  REAL(dp), PARAMETER ::  T_SL = 288.15_dp                     !< Reference temperature for computation of COSMO-DE's basic state pressure [K]
  REAL(dp), PARAMETER ::  BETA = 42.0_dp                       !< logarithmic lapse rate, dT / d ln(p), for computation of COSMO-DE's basic state pressure [K]
- REAL(dp), PARAMETER ::  RD   = 287.05_dp                     !< specific gar constant of dry air, used in computation of COSMO-DE's basic state [J/kg/K]
+ REAL(dp), PARAMETER ::  RD   = 287.05_dp                     !< specific gas constant of dry air, used in computation of COSMO-DE's basic state [J/kg/K]
+ REAL(dp), PARAMETER ::  RV   = 461.51_dp                     !< specific gas constant of water vapor [J/kg/K]
  REAL(dp), PARAMETER ::  G    = 9.80665_dp                    !< acceleration of Earth's gravity, used in computation of COSMO-DE's basic state [m/s/s]
  REAL(dp), PARAMETER ::  RHO_L = 1e3_dp                       !< density of liquid water, used to convert W_SO from [kg/m^2] to [m^3/m^3], in [kg/m^3]
@@ -72,7 +77,10 @@
 
  ! INIFOR parameters
- INTEGER, PARAMETER          ::  FILL_ITERATIONS = 10         !< Number of iterations for extrapolating soil data into COSMO-DE water cells [-]
- REAL(dp), PARAMETER         ::  FORCING_FREQ = 3600.0_dp     !< Reference pressure for potential temperature [Pa]
- CHARACTER(LEN=*), PARAMETER ::  VERSION = '1.1.4'            !< path to script for generating input file names
+ INTEGER, PARAMETER          ::  FILL_ITERATIONS = 5          !< Number of iterations for extrapolating soil data into COSMO-DE water cells [-]
+ INTEGER, PARAMETER          ::  FORCING_STEP = 1             !< Number of hours between forcing time steps [h]
+ REAL(dp), PARAMETER         ::  NUDGING_TAU = 21600.0_dp     !< Nudging relaxation time scale [s]
+ CHARACTER(LEN=*), PARAMETER ::  VERSION = '1.3.0'            !< INIFOR version number
+ CHARACTER(LEN=*), PARAMETER ::  COPYRIGHT = 'Copyright 2017-2018 Leibniz Universitaet Hannover' // &
+     NEW_LINE(' ') // ' Copyright 2017-2018 Deutscher Wetterdienst Offenbach' !< Copyright notice
 
  END MODULE defs
Index: palm/trunk/UTIL/inifor/src/get_netcdf_variable.inc
===================================================================
--- palm/trunk/UTIL/inifor/src/get_netcdf_variable.inc	(revision 3182)
+++ palm/trunk/UTIL/inifor/src/get_netcdf_variable.inc	(revision 3182)
@@ -0,0 +1,115 @@
+!> @file src/get_netcdf_variable.inc
+!------------------------------------------------------------------------------!
+! This file is part of the PALM model system.
+!
+! PALM is free software: you can redistribute it and/or modify it under the
+! terms of the GNU General Public License as published by the Free Software
+! Foundation, either version 3 of the License, or (at your option) any later
+! version.
+!
+! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
+! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along with
+! PALM. If not, see <http://www.gnu.org/licenses/>.
+!
+! Copyright 2017-2018 Leibniz Universitaet Hannover
+! Copyright 2017-2018 Deutscher Wetterdienst Offenbach
+!------------------------------------------------------------------------------!
+!
+! Current revisions:
+! -----------------
+! Initial revision
+! 
+! 
+! Former revisions:
+! -----------------
+! $Id$
+!
+! 
+!
+! Authors:
+! --------
+! @author Eckhard Kadasch
+!
+! Description:
+! ------------
+!> This file provides the implementation of the io.f90 subroutines
+!> get_netcdf_variable_int() and get_netcdf_variable_real(). Both routines
+!> differ only in the type of the netCDF variable to be read and otherwise share
+!> their functionality. In order to avoid duplicating code, both routines source
+!> the implementation below using Fortran's INCLUDE statement.
+!> 
+!------------------------------------------------------------------------------!
+ INTEGER ::  i, ncid, start(3)
+
+ ! Read in_var NetCDF attributes
+ IF ( nf90_open( TRIM(in_file), NF90_NOWRITE, ncid ) .EQ. NF90_NOERR .AND. &
+      nf90_inq_varid( ncid, in_var % name, in_var % varid ) .EQ. NF90_NOERR )  THEN
+
+    CALL check(nf90_get_att(ncid, in_var % varid, "long_name", in_var % long_name))
+    CALL check(nf90_get_att(ncid, in_var % varid, "units", in_var % units))
+
+    ! Read in_var NetCDF dimensions
+    CALL check(nf90_inquire_variable( ncid, in_var % varid,              &
+                                      ndims  = in_var % ndim,            &
+                                      dimids = in_var % dimids ))
+                                  
+    DO i = 1, in_var % ndim
+       CALL check(nf90_inquire_dimension( ncid, in_var % dimids(i),      &
+                                          name = in_var % dimname(i),    &
+                                          len  = in_var % dimlen(i) ))
+    END DO
+
+    start = (/ 1, 1, 1 /)
+    IF ( TRIM(in_var % name) .EQ. 'T_SO' )  THEN
+       ! Skip depth = 0.0 for T_SO and reduce number of depths from 9 to 8
+       in_var % dimlen(3) = in_var % dimlen(3) - 1
+
+       ! Start reading from second level, e.g. depth = 0.005 instead of 0.0
+       start(3) = 2
+    END IF
+
+    SELECT CASE(in_var % ndim)
+
+    CASE (2)
+
+       ALLOCATE( buffer( in_var % dimlen(1),                             &
+                         in_var % dimlen(2),                             &
+                         1 ) )
+
+    CASE (3, 4)
+
+       ALLOCATE( buffer( in_var % dimlen(1),                             &
+                         in_var % dimlen(2),                             &
+                         in_var % dimlen(3) ) )
+
+    CASE DEFAULT
+
+       message = "Failed reading NetCDF variable " //                    &
+          TRIM(in_var % name) // " with " // TRIM(str(in_var%ndim)) //   &
+          " dimensions because only two- and and three-dimensional" //   &
+          " variables are supported."
+       CALL abort('get_netcdf_variable', message) 
+
+    END SELECT
+ CALL run_control('time', 'alloc')
+          
+    ! TODO: Check for matching dimensions of buffer and var
+    CALL check(nf90_get_var( ncid, in_var % varid, buffer,               &
+                             start = start,                              &
+                             count = in_var % dimlen(1:3) ) )
+
+ CALL run_control('time', 'read')
+ ELSE
+
+    message = "Failed to read '" // TRIM(in_var % name) // &
+       "' from file '" // TRIM(in_file) // "'."
+    CALL report('get_netcdf_variable', message)
+
+ END IF
+
+ CALL check(nf90_close(ncid))
+
+ CALL run_control('time', 'read')
Index: palm/trunk/UTIL/inifor/src/grid.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/grid.f90	(revision 3178)
+++ palm/trunk/UTIL/inifor/src/grid.f90	(revision 3182)
@@ -21,5 +21,15 @@
 ! Current revisions:
 ! -----------------
-! 
+! Introduced new PALM grid stretching
+! Updated variable names and metadata for PIDS v1.9 compatibility
+! Better compatibility with older Intel compilers:
+! - avoiding implicit array allocation with new get_netcdf_variable()
+!   subroutine instead of function
+! Improved command line interface:
+! - Produce forcing variables when '-mode profile' is being used
+! - Renamend initial-condition mode variable 'mode' to 'ic_mode'
+! - Improved handling of the start date string
+! Removed unnecessary variables and routines
+!
 ! 
 ! Former revisions:
@@ -47,9 +57,9 @@
     USE defs,                                                                  &
         ONLY:  DATE, EARTH_RADIUS, TO_RADIANS, TO_DEGREES, PI, dp, hp, sp,     &
-               SNAME, LNAME, PATH, FORCING_FREQ, WATER_ID, FILL_ITERATIONS,    &
+               SNAME, LNAME, PATH, FORCING_STEP, WATER_ID, FILL_ITERATIONS,    &
                BETA, P_SL, T_SL, BETA, RD, G, P_REF, RD_PALM, CP_PALM, RHO_L
     USE io,                                                                    &
         ONLY:  get_netcdf_variable, get_netcdf_attribute,                      &
-               parse_command_line_arguments
+               parse_command_line_arguments, validate_config
     USE netcdf,                                                                &
         ONLY:  NF90_MAX_NAME, NF90_MAX_VAR_DIMS
@@ -67,36 +77,44 @@
     SAVE
     
-    REAL(dp) ::  phi_equat = 0.0_dp    !< latitude of rotated equator of COSMO-DE grid [rad]
-    REAL(dp) ::  phi_n     = 0.0_dp    !< latitude of rotated pole of COSMO-DE grid [rad]
-    REAL(dp) ::  lambda_n  = 0.0_dp    !< longitude of rotaded pole of COSMO-DE grid [rad]
-    REAL(dp) ::  phi_c     = 0.0_dp    !< rotated-grid latitude of the center of the PALM domain [rad]
-    REAL(dp) ::  lambda_c  = 0.0_dp    !< rotated-grid longitude of the centre of the PALM domain [rad]
-    REAL(dp) ::  phi_cn    = 0.0_dp    !< latitude of the rotated pole relative to the COSMO-DE grid [rad]
-    REAL(dp) ::  lambda_cn = 0.0_dp    !< longitude of the rotated pole relative to the COSMO-DE grid [rad]
-    REAL(dp) ::  gam       = 0.0_dp    !< angle for working around phirot2phi/rlarot2rla bug
-    REAL(dp) ::  dx        = 0.0_dp    !< PALM-4U grid spacing in x direction [m]
-    REAL(dp) ::  dy        = 0.0_dp    !< PALM-4U grid spacing in y direction [m]
-    REAL(dp) ::  dz        = 0.0_dp    !< PALM-4U grid spacing in z direction [m]
-    REAL(dp) ::  dxi       = 0.0_dp    !< inverse PALM-4U grid spacing in x direction [m^-1]
-    REAL(dp) ::  dyi       = 0.0_dp    !< inverse PALM-4U grid spacing in y direction [m^-1]
-    REAL(dp) ::  dzi       = 0.0_dp    !< inverse PALM-4U grid spacing in z direction [m^-1]
-    REAL(dp) ::  lx        = 0.0_dp    !< PALM-4U domain size in x direction [m]
-    REAL(dp) ::  ly        = 0.0_dp    !< PALM-4U domain size in y direction [m]
-    REAL(dp) ::  lz        = 0.0_dp    !< PALM-4U domain size in z direction [m]
-    REAL(dp) ::  ug        = 0.0_dp    !< geostrophic wind in x direction [m/s]
-    REAL(dp) ::  vg        = 0.0_dp    !< geostrophic wind in y direction [m/s]
-    REAL(dp) ::  p0        = 0.0_dp    !< PALM-4U surface pressure, at z0 [Pa]
-    REAL(dp) ::  x0        = 0.0_dp    !< x coordinate of PALM-4U Earth tangent [m] 
-    REAL(dp) ::  y0        = 0.0_dp    !< y coordinate of PALM-4U Earth tangent [m] 
-    REAL(dp) ::  z0        = 0.0_dp    !< Elevation of the PALM-4U domain above sea level [m]
-    REAL(dp) ::  lonmin    = 0.0_dp    !< Minimunm longitude of COSMO-DE's rotated-pole grid
-    REAL(dp) ::  lonmax    = 0.0_dp    !< Maximum longitude of COSMO-DE's rotated-pole grid
-    REAL(dp) ::  latmin    = 0.0_dp    !< Minimunm latitude of COSMO-DE's rotated-pole grid
-    REAL(dp) ::  latmax    = 0.0_dp    !< Maximum latitude of COSMO-DE's rotated-pole grid
-    REAL(dp) ::  latitude  = 0.0_dp    !< geograpohical latitude of the PALM-4U origin, from inipar namelist [deg]
-    REAL(dp) ::  longitude = 0.0_dp    !< geograpohical longitude of the PALM-4U origin, from inipar namelist [deg]
-    REAL(dp) ::  origin_lat= 0.0_dp    !< geograpohical latitude of the PALM-4U origin, from static driver netCDF file [deg]
-    REAL(dp) ::  origin_lon= 0.0_dp    !< geograpohical longitude of the PALM-4U origin, from static driver netCDF file [deg]
-    REAL(dp) ::  end_time  = 0.0_dp    !< PALM-4U simulation time [s]
+    REAL(dp) ::  phi_equat         = 0.0_dp       !< latitude of rotated equator of COSMO-DE grid [rad]
+    REAL(dp) ::  phi_n             = 0.0_dp       !< latitude of rotated pole of COSMO-DE grid [rad]
+    REAL(dp) ::  lambda_n          = 0.0_dp       !< longitude of rotaded pole of COSMO-DE grid [rad]
+    REAL(dp) ::  phi_c             = 0.0_dp       !< rotated-grid latitude of the center of the PALM domain [rad]
+    REAL(dp) ::  lambda_c          = 0.0_dp       !< rotated-grid longitude of the centre of the PALM domain [rad]
+    REAL(dp) ::  phi_cn            = 0.0_dp       !< latitude of the rotated pole relative to the COSMO-DE grid [rad]
+    REAL(dp) ::  lambda_cn         = 0.0_dp       !< longitude of the rotated pole relative to the COSMO-DE grid [rad]
+    REAL(dp) ::  gam               = 0.0_dp       !< angle for working around phirot2phi/rlarot2rla bug
+    REAL(dp) ::  dx                = 0.0_dp       !< PALM-4U grid spacing in x direction [m]
+    REAL(dp) ::  dy                = 0.0_dp       !< PALM-4U grid spacing in y direction [m]
+    REAL(dp) ::  dz(10)            = -1.0_dp      !< PALM-4U grid spacing in z direction [m]
+    REAL(dp) ::  dz_max            = 1000.0_dp    !< maximum vertical grid spacing [m]
+    REAL(dp) ::  dz_stretch_factor = 1.08_dp      !< factor for vertical grid stretching [m]
+    REAL(dp) ::  dz_stretch_level  = -9999999.9_dp!< height above which the vertical grid will be stretched [m]
+    REAL(dp) ::  dz_stretch_level_start(9) = -9999999.9_dp !< namelist parameter
+    REAL(dp) ::  dz_stretch_level_end(9) = 9999999.9_dp !< namelist parameter
+    REAL(dp) ::  dz_stretch_factor_array(9) = 1.08_dp !< namelist parameter
+    REAL(dp) ::  dxi               = 0.0_dp       !< inverse PALM-4U grid spacing in x direction [m^-1]
+    REAL(dp) ::  dyi               = 0.0_dp       !< inverse PALM-4U grid spacing in y direction [m^-1]
+    REAL(dp) ::  dzi               = 0.0_dp       !< inverse PALM-4U grid spacing in z direction [m^-1]
+    REAL(dp) ::  lx                = 0.0_dp       !< PALM-4U domain size in x direction [m]
+    REAL(dp) ::  ly                = 0.0_dp       !< PALM-4U domain size in y direction [m]
+    REAL(dp) ::  ug                = 0.0_dp       !< geostrophic wind in x direction [m/s]
+    REAL(dp) ::  vg                = 0.0_dp       !< geostrophic wind in y direction [m/s]
+    REAL(dp) ::  p0                = 0.0_dp       !< PALM-4U surface pressure, at z0 [Pa]
+    REAL(dp) ::  x0                = 0.0_dp       !< x coordinate of PALM-4U Earth tangent [m] 
+    REAL(dp) ::  y0                = 0.0_dp       !< y coordinate of PALM-4U Earth tangent [m] 
+    REAL(dp) ::  z0                = 0.0_dp       !< Elevation of the PALM-4U domain above sea level [m]
+    REAL(dp) ::  z_top             = 0.0_dp       !< height of the scalar top boundary [m]
+    REAL(dp) ::  zw_top            = 0.0_dp       !< height of the vertical velocity top boundary [m]
+    REAL(dp) ::  lonmin            = 0.0_dp       !< Minimunm longitude of COSMO-DE's rotated-pole grid
+    REAL(dp) ::  lonmax            = 0.0_dp       !< Maximum longitude of COSMO-DE's rotated-pole grid
+    REAL(dp) ::  latmin            = 0.0_dp       !< Minimunm latitude of COSMO-DE's rotated-pole grid
+    REAL(dp) ::  latmax            = 0.0_dp       !< Maximum latitude of COSMO-DE's rotated-pole grid
+    REAL(dp) ::  latitude          = 0.0_dp       !< geographical latitude of the PALM-4U origin, from inipar namelist [deg]
+    REAL(dp) ::  longitude         = 0.0_dp       !< geographical longitude of the PALM-4U origin, from inipar namelist [deg]
+    REAL(dp) ::  origin_lat        = 0.0_dp       !< geographical latitude of the PALM-4U origin, from static driver netCDF file [deg]
+    REAL(dp) ::  origin_lon        = 0.0_dp       !< geographical longitude of the PALM-4U origin, from static driver netCDF file [deg]
+    REAL(dp) ::  rotation_angle    = 0.0_dp       !< clockwise angle the PALM-4U north is rotated away from geographical north [deg]
+    REAL(dp) ::  end_time          = 0.0_dp       !< PALM-4U simulation time [s]
 
     REAL(dp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  hhl             !< heights of half layers (cell faces) above sea level in COSMO-DE, read in from external file
@@ -106,9 +124,19 @@
     REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  rlon            !< longitudes of COSMO-DE's rotated-pole grid
     REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  rlat            !< latitudes of COSMO-DE's rotated-pole grid
-    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  time
+    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  time            !< output times 
+    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  x               !< base palm grid x coordinate vector pointed to by grid_definitions
+    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  xu              !< base palm grid xu coordinate vector pointed to by grid_definitions
+    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  y               !< base palm grid y coordinate vector pointed to by grid_definitions
+    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  yv              !< base palm grid yv coordinate vector pointed to by grid_definitions
+    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  z_column        !< base palm grid z coordinate vector including the top boundary coordinate (entire column)
+    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  zw_column       !< base palm grid zw coordinate vector including the top boundary coordinate (entire column)
+    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  z               !< base palm grid z coordinate vector pointed to by grid_definitions
+    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  zw              !< base palm grid zw coordinate vector pointed to by grid_definitions
 
     INTEGER(hp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  soiltyp      !< COSMO-DE soil type map
+    INTEGER ::  dz_stretch_level_end_index(9)               !< vertical grid level index until which the vertical grid spacing is stretched
+    INTEGER ::  dz_stretch_level_start_index(9)             !< vertical grid level index above which the vertical grid spacing is stretched
     INTEGER ::  i     !< indexing variable
-    INTEGER ::  imin, imax, jmin, jmax !< index ranges for profile averaging
+    INTEGER ::  average_imin, average_imax, average_jmin, average_jmax !< index ranges for profile averaging
     INTEGER ::  k     !< indexing variable
     INTEGER ::  nt    !< number of output time steps
@@ -130,4 +158,6 @@
     LOGICAL ::  init_variables_required
     LOGICAL ::  boundary_variables_required
+    LOGICAL ::  ls_forcing_variables_required
+    LOGICAL ::  profile_grids_required
 
     INTEGER ::  n_invar = 0 !< number of variables in the input variable table
@@ -193,14 +223,10 @@
     TYPE(io_group), ALLOCATABLE, TARGET ::  io_group_list(:)  !< List of I/O groups, which group together output variables that share the same input variable
  
-    NAMELIST /inipar/ nx, ny, nz, dx, dy, dz, longitude, latitude
+    NAMELIST /inipar/ nx, ny, nz, dx, dy, dz, longitude, latitude,             &
+                      dz_max, dz_stretch_factor, dz_stretch_level,             & !< old grid stretching parameters
+                      dz_stretch_level_start, dz_stretch_level_end               !< new grid stretching parameters
     NAMELIST /d3par/  end_time
     
     CHARACTER(LEN=LNAME) ::  nc_source_text     = ''  !< Text describing the source of the output data, e.g. 'COSMO-DE analysis from ...'
-    CHARACTER(LEN=DATE)  ::  start_date         = ''  !< String of the FORMAT YYYYMMDDHH indicating the start of the intended PALM-4U simulation
-    CHARACTER(LEN=PATH)  ::  hhl_file           = ''  !< Path to the file containing the COSMO-DE HHL variable (height of half layers, i.e. vertical cell faces)
-    CHARACTER(LEN=PATH)  ::  namelist_file      = ''  !< Path to the PALM-4U namelist file
-    CHARACTER(LEN=PATH)  ::  static_driver_file = ''  !< Path to the file containing the COSMO-DE SOILTYP variable (map of COSMO-DE soil types)
-    CHARACTER(LEN=PATH)  ::  soiltyp_file       = ''  !< Path to the file containing the COSMO-DE SOILTYP variable (map of COSMO-DE soil types)
-    CHARACTER(LEN=PATH)  ::  input_path         = ''  !< Path to the input data file directory
     CHARACTER(LEN=PATH), ALLOCATABLE, DIMENSION(:) ::  flow_files
     CHARACTER(LEN=PATH), ALLOCATABLE, DIMENSION(:) ::  soil_moisture_files
@@ -212,7 +238,8 @@
     CHARACTER(LEN=SNAME) ::  radiation_suffix     !< Suffix of radiation input files, e.g. 'radiation'
     CHARACTER(LEN=SNAME) ::  soilmoisture_suffix  !< Suffix of input files for soil moisture spin-up, e.g. 'soilmoisture'
-    CHARACTER(LEN=SNAME) ::  mode                 !< INIFOR's initialization mode, 'profile' or 'volume'
                           
     TYPE(nc_file) ::  output_file
+
+    TYPE(inifor_config) ::  cfg !< Container of INIFOR configuration
 
  CONTAINS
@@ -224,5 +251,5 @@
 ! Section 1: Define default parameters
 !------------------------------------------------------------------------------
-       start_date = '2013072100'
+       cfg % start_date = '2013072100'
        end_hour = 2
        start_hour_soil = -2
@@ -249,10 +276,10 @@
        origin_lat = 52.325079_dp * TO_RADIANS ! south-west of Berlin, origin used for the Dec 2017 showcase simulation
        origin_lon = 13.082744_dp * TO_RADIANS
-       z0 = 35.0_dp
+       cfg % z0 = 35.0_dp
 
        ! Default atmospheric parameters
        ug = 0.0_dp
        vg = 0.0_dp
-       p0 = P_SL
+       cfg % p0 = P_SL
 
        ! Parameters for file names
@@ -262,6 +289,12 @@
        start_hour_soilmoisture = start_hour_flow - 2
        end_hour_soilmoisture = start_hour_flow
-       step_hour = 1
+       step_hour = FORCING_STEP
+
        input_prefix = 'laf'  ! 'laf' for COSMO-DE analyses
+       cfg % flow_prefix = input_prefix
+       cfg % soil_prefix = input_prefix
+       cfg % radiation_prefix = input_prefix
+       cfg % soilmoisture_prefix  = input_prefix
+
        flow_suffix = '-flow'
        soil_suffix = '-soil'
@@ -273,32 +306,48 @@
 !------------------------------------------------------------------------------
 
-       ! Set default paths
-       input_path         = './'
-       hhl_file           = ''
-       soiltyp_file       = ''
-       namelist_file      = './namelist'
-       output_file % name = './palm-4u-input.nc'
+       ! Set default paths and modes
+       cfg % input_path         = './'
+       cfg % hhl_file           = ''
+       cfg % soiltyp_file       = ''
+       cfg % namelist_file      = './namelist'
+       cfg % static_driver_file = ''
+       cfg % output_file = './palm-4u-input.nc'
+       cfg % ic_mode = 'volume'
+       cfg % bc_mode = 'real'
 
        ! Update default file names and domain centre
-       CALL parse_command_line_arguments( start_date, hhl_file, soiltyp_file,  &
-               static_driver_file, input_path, output_file % name,             &
-               namelist_file, ug, vg, p0, z0, mode )
-
-       init_variables_required     = .TRUE.
-       boundary_variables_required = (TRIM(mode) .NE. 'profile')
-
-       CALL normalize_path(input_path)
-       IF (TRIM(hhl_file) == '')  hhl_file = TRIM(input_path) // 'hhl.nc'
-       IF (TRIM(soiltyp_file) == '')  soiltyp_file = TRIM(input_path) // 'soil.nc'
-
-       CALL report('setup_parameters', "       data path: " // TRIM(input_path))
-       CALL report('setup_parameters', "        hhl file: " // TRIM(hhl_file))
-       CALL report('setup_parameters', "    soiltyp file: " // TRIM(soiltyp_file))
-       CALL report('setup_parameters', "   namelist file: " // TRIM(namelist_file))
-       CALL report('setup_parameters', "output data file: " // TRIM(output_file % name))
+       CALL parse_command_line_arguments( cfg )
+
+       output_file % name = cfg % output_file
+       z0 = cfg % z0
+       p0 = cfg % p0
+
+       init_variables_required = .TRUE.
+       boundary_variables_required = TRIM( cfg % bc_mode ) == 'real'
+       ls_forcing_variables_required = TRIM( cfg % bc_mode ) == 'ideal'
+
+       IF ( ls_forcing_variables_required )  THEN
+          message = "Averaging of large-scale forcing profiles " //            &
+                    "has not been implemented, yet."
+          CALL abort('setup_parameters', message)
+       END IF
+
+       CALL normalize_path(cfg % input_path)
+       IF (TRIM(cfg % hhl_file) == '')  cfg % hhl_file = TRIM(cfg % input_path) // 'hhl.nc'
+       IF (TRIM(cfg % soiltyp_file) == '')  cfg % soiltyp_file = TRIM(cfg % input_path) // 'soil.nc'
+
+       CALL validate_config( cfg ) 
+
+       CALL report('setup_parameters', "initialization mode: " // TRIM(cfg % ic_mode))
+       CALL report('setup_parameters', "       forcing mode: " // TRIM(cfg % bc_mode))
+       CALL report('setup_parameters', "          data path: " // TRIM(cfg % input_path))
+       CALL report('setup_parameters', "           hhl file: " // TRIM(cfg % hhl_file))
+       CALL report('setup_parameters', "       soiltyp file: " // TRIM(cfg % soiltyp_file))
+       CALL report('setup_parameters', "      namelist file: " // TRIM(cfg % namelist_file))
+       CALL report('setup_parameters', "   output data file: " // TRIM(output_file % name))
 
  CALL run_control('time', 'init')
        ! Read in namelist parameters
-       OPEN(10, FILE=namelist_file)
+       OPEN(10, FILE=cfg % namelist_file)
        READ(10, NML=inipar) ! nx, ny, nz, dx, dy, dz
        READ(10, NML=d3par)  ! end_time
@@ -306,15 +355,15 @@
  CALL run_control('time', 'read')
 
-       end_hour = CEILING(end_time / FORCING_FREQ)
+       end_hour = CEILING( end_time / 3600.0 * step_hour )
 
        ! Generate input file lists
-       CALL input_file_list(start_date, start_hour_flow, end_hour, step_hour,  &
-          input_path, input_prefix, flow_suffix, flow_files)
-       CALL input_file_list(start_date, start_hour_soil, end_hour, step_hour,  &
-          input_path, input_prefix, soil_suffix, soil_files)
-       CALL input_file_list(start_date, start_hour_radiation, end_hour, step_hour, &
-          input_path, input_prefix, radiation_suffix, radiation_files)
-       CALL input_file_list(start_date, start_hour_soilmoisture, end_hour_soilmoisture, step_hour, &
-          input_path, input_prefix, soilmoisture_suffix, soil_moisture_files)
+       CALL get_input_file_list(cfg % start_date, start_hour_flow, end_hour, step_hour,  &
+          cfg % input_path, cfg % flow_prefix, flow_suffix, flow_files)
+       CALL get_input_file_list(cfg % start_date, start_hour_soil, end_hour, step_hour,  &
+          cfg % input_path, cfg % soil_prefix, soil_suffix, soil_files)
+       CALL get_input_file_list(cfg % start_date, start_hour_radiation, end_hour, step_hour, &
+          cfg % input_path, cfg % radiation_prefix, radiation_suffix, radiation_files)
+       CALL get_input_file_list(cfg % start_date, start_hour_soilmoisture, end_hour_soilmoisture, step_hour, &
+          cfg % input_path, cfg % soilmoisture_prefix, soilmoisture_suffix, soil_moisture_files)
 
 !
@@ -322,9 +371,5 @@
 ! Section 3: Check for consistency
 !------------------------------------------------------------------------------
-       IF (dx*dy*dz .EQ. 0.0_dp)  THEN
-          message = "Grid cells have zero volume. Grid spacings are probably"//&
-             " set incorrectly in namelist file '" // TRIM(namelist_file) // "'."
-          CALL abort('setup_parameters', message) 
-       END IF
+
 !
 !------------------------------------------------------------------------------
@@ -339,14 +384,14 @@
        ! Read COSMO-DE soil type map
        cosmo_var % name = 'SOILTYP'
-       soiltyp = NINT(get_netcdf_variable(soiltyp_file, cosmo_var), hp)
+       CALL get_netcdf_variable(cfg % soiltyp_file, cosmo_var, soiltyp)
 
        message = 'Reading PALM-4U origin from'
-       IF (TRIM(static_driver_file) .NE. '')  THEN
-
-          origin_lon = get_netcdf_attribute(static_driver_file, 'origin_lon')
-          origin_lat = get_netcdf_attribute(static_driver_file, 'origin_lat')
+       IF (TRIM(cfg % static_driver_file) .NE. '')  THEN
+
+          origin_lon = get_netcdf_attribute(cfg % static_driver_file, 'origin_lon')
+          origin_lat = get_netcdf_attribute(cfg % static_driver_file, 'origin_lat')
 
           message = TRIM(message) // " static driver file '"                   &
-                                  // TRIM(static_driver_file) // "'"
+                                  // TRIM(cfg % static_driver_file) // "'"
 
 
@@ -357,5 +402,5 @@
 
           message = TRIM(message) // " namlist file '"                         &
-                                  // TRIM(namelist_file) // "'"
+                                  // TRIM(cfg % namelist_file) // "'"
 
        END IF
@@ -368,5 +413,5 @@
        ! Read in COSMO-DE heights of half layers (vertical cell faces)
        cosmo_var % name = 'HHL'
-       hhl = get_netcdf_variable(hhl_file, cosmo_var)
+       CALL get_netcdf_variable(cfg % hhl_file, cosmo_var, hhl)
  CALL run_control('time', 'read')
 
@@ -392,5 +437,4 @@
        lx = (nx+1) * dx
        ly = (ny+1) * dy
-       lz = (nz+1) * dz
        
        ! PALM-4U point of Earth tangency
@@ -399,5 +443,5 @@
 
        ! time vector
-       nt = CEILING(end_time / FORCING_FREQ) + 1
+       nt = CEILING(end_time / (step_hour * 3600.0_dp)) + 1
        ALLOCATE( time(nt) )
        CALL linspace(0.0_dp, 3600.0_dp * (nt-1), time)
@@ -463,13 +507,42 @@
     SUBROUTINE setup_grids() ! setup_grids(inifor_settings(with nx, ny, nz,...))
        CHARACTER ::  interp_mode
-        
+
 !------------------------------------------------------------------------------
-! Section 1: Define model and initialization grids
+! Section 0: Define base PALM-4U grid coordinate vectors
+!------------------------------------------------------------------------------
+       ! palm x y z, we allocate the column to nz+1 in order to include the top
+       ! scalar boundary. The interpolation grids will be associated with
+       ! a shorter column that omits the top element.
+       
+       ALLOCATE( x(0:nx), y(0:ny), z(1:nz), z_column(1:nz+1) )
+       CALL linspace(0.5_dp * dx, lx - 0.5_dp * dx, x)
+       CALL linspace(0.5_dp * dy, ly - 0.5_dp * dy, y)
+       CALL stretched_z(z_column, dz, dz_max=dz_max,                           &
+                        dz_stretch_factor=dz_stretch_factor,                   &
+                        dz_stretch_level=dz_stretch_level,                     &
+                        dz_stretch_level_start=dz_stretch_level_start,         &
+                        dz_stretch_level_end=dz_stretch_level_end,             &
+                        dz_stretch_factor_array=dz_stretch_factor_array)
+       z(1:nz) = z_column(1:nz)
+       z_top = z_column(nz+1)
+
+       ! palm xu yv zw, compared to the scalar grid, velocity coordinates
+       ! contain one element less.
+       ALLOCATE( xu(1:nx),  yv(1:ny), zw(1:nz-1), zw_column(1:nz))
+       CALL linspace(dx, lx - dx, xu)
+       CALL linspace(dy, ly - dy, yv)
+       CALL midpoints(z_column, zw_column)
+       zw(1:nz-1) = zw_column(1:nz-1)
+       zw_top     = zw_column(nz)
+
+
+!------------------------------------------------------------------------------
+! Section 1: Define initialization and boundary grids
 !------------------------------------------------------------------------------
        CALL init_grid_definition('palm', grid=palm_grid,                       &
                xmin=0.0_dp, xmax=lx,                                           &
                ymin=0.0_dp, ymax=ly,                                           &
-               zmin=0.0_dp, zmax=lz, x0=x0, y0=y0, z0=z0,                      &
-               nx=nx, ny=ny, nz=nz, mode=mode)
+               x0=x0, y0=y0, z0=z0,                      &
+               nx=nx, ny=ny, nz=nz, z=z, zw=zw, ic_mode=cfg % ic_mode)
 
        ! Subtracting 1 because arrays will be allocated with nlon + 1 elements.
@@ -477,5 +550,5 @@
                xmin=lonmin, xmax=lonmax,                                       &
                ymin=latmin, ymax=latmax,                                       &
-               zmin=0.0_dp, zmax=51.0_dp, x0=x0, y0=y0, z0=0.0_dp,             &
+               x0=x0, y0=y0, z0=0.0_dp,             &
                nx=nlon-1, ny=nlat-1, nz=nlev-1)
 
@@ -487,5 +560,5 @@
                xmin=0.0_dp, xmax=lx,                                           &
                ymin=0.0_dp, ymax=ly,                                           &
-               zmin=0.0_dp, zmax=lz, x0=x0, y0=y0, z0=z0,                      &
+               x0=x0, y0=y0, z0=z0,                      &
                nx=nx, ny=ny, nz=nlev-2)
 
@@ -493,48 +566,39 @@
                xmin = dx, xmax = lx - dx,                                      &
                ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
-               zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
                x0=x0, y0=y0, z0 = z0,                                          &
                nx = nx-1, ny = ny, nz = nz,                                    &
-               dx = dx, dy = dy, dz = dz, mode=mode)
+               z=z, ic_mode=cfg % ic_mode)
 
        CALL init_grid_definition('boundary', grid=v_initial_grid,              &
                xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
                ymin = dy, ymax = ly - dy,                                      &
-               zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
                x0=x0, y0=y0, z0 = z0,                                          &
                nx = nx, ny = ny-1, nz = nz,                                    &
-               dx = dx, dy = dy, dz = dz, mode=mode)
+               z=z, ic_mode=cfg % ic_mode)
 
        CALL init_grid_definition('boundary', grid=w_initial_grid,              &
                xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
                ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
-               zmin = dz, zmax = lz - dz,                                      &
                x0=x0, y0=y0, z0 = z0,                                          &
                nx = nx, ny = ny, nz = nz-1,                                    &
-               dx = dx, dy = dy, dz = dz, mode=mode)
+               z=zw, ic_mode=cfg % ic_mode)
 
        CALL init_grid_definition('boundary intermediate', grid=u_initial_intermediate,      &
                xmin = dx, xmax = lx - dx,                                      &
                ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
-               zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
                x0=x0, y0=y0, z0 = z0,                                          &
-               nx = nx-1, ny = ny, nz = nlev - 2,                              &
-               dx = dx, dy = dy, dz = dz)
+               nx = nx-1, ny = ny, nz = nlev - 2)
 
        CALL init_grid_definition('boundary intermediate', grid=v_initial_intermediate,      &
                xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
                ymin = dy, ymax = ly - dy,                                      &
-               zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
                x0=x0, y0=y0, z0 = z0,                                          &
-               nx = nx, ny = ny-1, nz = nlev - 2,                              &
-               dx = dx, dy = dy, dz = dz)
+               nx = nx, ny = ny-1, nz = nlev - 2)
 
        CALL init_grid_definition('boundary intermediate', grid=w_initial_intermediate,      &
                xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
                ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
-               zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
                x0=x0, y0=y0, z0 = z0,                                          &
-               nx = nx, ny = ny, nz = nlev - 2,                                &
-               dx = dx, dy = dy, dz = dz)
+               nx = nx, ny = ny, nz = nlev - 2)
 
       IF (boundary_variables_required)  THEN
@@ -546,320 +610,240 @@
                   xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx,               &
                   ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
-                  zmin =  0.5_dp * dz, zmax = lz - 0.5_dp * dz,                   &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = 0, ny = ny, nz = nz,                                       &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = 0, ny = ny, nz = nz, z=z)
 
           CALL init_grid_definition('boundary', grid=scalars_west_grid,           &
                   xmin = -0.5_dp * dx, xmax = -0.5_dp * dx,                       &
                   ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
-                  zmin =  0.5_dp * dz, zmax = lz - 0.5_dp * dz,                   &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = 0, ny = ny, nz = nz,                                       &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = 0, ny = ny, nz = nz, z=z)
 
           CALL init_grid_definition('boundary', grid=scalars_north_grid,          &
                   xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
                   ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy,               &
-                  zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = 0, nz = nz,                                       &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = 0, nz = nz, z=z)
 
           CALL init_grid_definition('boundary', grid=scalars_south_grid,          &
                   xmin =  0.5_dp * dx, xmax = lx - 0.5_dp * dx,                   &
                   ymin = -0.5_dp * dy, ymax = -0.5_dp * dy,                       &
-                  zmin =  0.5_dp * dz, zmax = lz - 0.5_dp * dz,                   &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = 0, nz = nz,                                       &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = 0, nz = nz, z=z)
 
           CALL init_grid_definition('boundary', grid=scalars_top_grid,            &
                   xmin =  0.5_dp * dx, xmax = lx - 0.5_dp * dx,                   &
                   ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
-                  zmin =  lz + 0.5_dp * dz, zmax = lz + 0.5_dp * dz,              &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = ny, nz = 0,                                       &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = ny, nz = 1, z=(/z_top/))
 
           CALL init_grid_definition('boundary', grid=u_east_grid,                 &
                   xmin = lx, xmax = lx,                                           &
                   ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
-                  zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = 0, ny = ny, nz = nz,                                       &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = 0, ny = ny, nz = nz, z=z)
 
           CALL init_grid_definition('boundary', grid=u_west_grid,                 &
                   xmin = 0.0_dp, xmax = 0.0_dp,                                   &
                   ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
-                  zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = 0, ny = ny, nz = nz,                                       &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = 0, ny = ny, nz = nz, z=z)
 
           CALL init_grid_definition('boundary', grid=u_north_grid,                &
                   xmin = dx, xmax = lx - dx,                                      &
                   ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy,               &
-                  zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx-1, ny = 0, nz = nz,                                     &
-                  dx = dx, dy = dy, dz = dz)
-
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx-1, ny = 0, nz = nz, z=z)
+    
           CALL init_grid_definition('boundary', grid=u_south_grid,                &
                   xmin = dx, xmax = lx - dx,                                      &
                   ymin = -0.5_dp * dy, ymax = -0.5_dp * dy,                       &
-                  zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx-1, ny = 0, nz = nz,                                     &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx-1, ny = 0, nz = nz, z=z)
 
           CALL init_grid_definition('boundary', grid=u_top_grid,                  &
                   xmin = dx, xmax = lx - dx,                                      &
                   ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
-                  zmin = lz + 0.5_dp * dz, zmax = lz + 0.5_dp * dz,               &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx-1, ny = ny, nz = 0,                                     &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx-1, ny = ny, nz = 1, z=(/z_top/))
 
           CALL init_grid_definition('boundary', grid=v_east_grid,                 &
                   xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx,               &
                   ymin = dy, ymax = ly - dy,                                      &
-                  zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = 0, ny = ny-1, nz = nz,                                     &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = 0, ny = ny-1, nz = nz, z=z)
 
           CALL init_grid_definition('boundary', grid=v_west_grid,                 &
                   xmin = -0.5_dp * dx, xmax = -0.5_dp * dx,                       &
                   ymin = dy, ymax = ly - dy,                                      &
-                  zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = 0, ny = ny-1, nz = nz,                                     &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = 0, ny = ny-1, nz = nz, z=z)
 
           CALL init_grid_definition('boundary', grid=v_north_grid,                &
                   xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
                   ymin = ly, ymax = ly,                                           &
-                  zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = 0, nz = nz,                                       &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = 0, nz = nz, z=z)
 
           CALL init_grid_definition('boundary', grid=v_south_grid,                &
                   xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
                   ymin = 0.0_dp, ymax = 0.0_dp,                                   &
-                  zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = 0, nz = nz,                                       &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = 0, nz = nz, z=z)
 
           CALL init_grid_definition('boundary', grid=v_top_grid,                  &
                   xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
                   ymin = dy, ymax = ly - dy,                                      &
-                  zmin = lz + 0.5_dp * dz, zmax = lz + 0.5_dp * dz,               &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = ny-1, nz = 0,                                     &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = ny-1, nz = 1, z=(/z_top/))
 
           CALL init_grid_definition('boundary', grid=w_east_grid,                 &
                   xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx,               &
                   ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
-                  zmin =  dz, zmax = lz - dz,                                     &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = 0, ny = ny, nz = nz - 1,                                   &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = 0, ny = ny, nz = nz - 1, z=zw)
 
           CALL init_grid_definition('boundary', grid=w_west_grid,                 &
                   xmin = -0.5_dp * dx, xmax = -0.5_dp * dx,                       &
                   ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
-                  zmin = dz, zmax = lz - dz,                                      &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = 0, ny = ny, nz = nz - 1,                                   &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = 0, ny = ny, nz = nz - 1, z=zw)
 
           CALL init_grid_definition('boundary', grid=w_north_grid,                &
                   xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
                   ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy,               &
-                  zmin = dz, zmax = lz - dz,                                      &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = 0, nz = nz - 1,                                   &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = 0, nz = nz - 1, z=zw)
 
           CALL init_grid_definition('boundary', grid=w_south_grid,                &
                   xmin =  0.5_dp * dx, xmax = lx - 0.5_dp * dx,                   &
                   ymin = -0.5_dp * dy, ymax = -0.5_dp * dy,                       &
-                  zmin = dz, zmax = lz - dz,                                      &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = 0, nz = nz - 1,                                   &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = 0, nz = nz - 1, z=zw)
 
           CALL init_grid_definition('boundary', grid=w_top_grid,                  &
                   xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
                   ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
-                  zmin = lz, zmax = lz,                                           &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = ny, nz = 0,                                       &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = ny, nz = 1, z=(/zw_top/))
 
           CALL init_grid_definition('boundary intermediate', grid=scalars_east_intermediate,   &
                   xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx,               &
                   ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = 0, ny = ny, nz = nlev - 2,                                 &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = 0, ny = ny, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=scalars_west_intermediate,   &
                   xmin = -0.5_dp * dx, xmax = -0.5_dp * dx,                       &
                   ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = 0, ny = ny, nz = nlev - 2,                                 &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = 0, ny = ny, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=scalars_north_intermediate,  &
                   xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
                   ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy,               &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = 0, nz = nlev - 2,                                 &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = 0, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=scalars_south_intermediate,  &
                   xmin =  0.5_dp * dx, xmax = lx - 0.5_dp * dx,                   &
                   ymin = -0.5_dp * dy, ymax = -0.5_dp * dy,                       &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = 0, nz = nlev - 2,                                 &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = 0, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=scalars_top_intermediate,    &
                   xmin =  0.5_dp * dx, xmax = lx - 0.5_dp * dx,                   &
                   ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = ny, nz = nlev - 2,                                &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = ny, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=u_east_intermediate,         &
                   xmin = lx, xmax = lx,                                           &
                   ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = 0, ny = ny, nz = nlev - 2,                                 &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = 0, ny = ny, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=u_west_intermediate,         &
                   xmin = 0.0_dp, xmax = 0.0_dp,                                   &
                   ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = 0, ny = ny, nz = nlev - 2,                                 &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = 0, ny = ny, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=u_north_intermediate,        &
                   xmin = dx, xmax = lx - dx,                                      &
                   ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy,               &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx-1, ny = 0, nz = nlev - 2,                               &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx-1, ny = 0, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=u_south_intermediate,        &
                   xmin = dx, xmax = lx - dx,                                      &
                   ymin = -0.5_dp * dy, ymax = -0.5_dp * dy,                       &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx-1, ny = 0, nz = nlev - 2,                               &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx-1, ny = 0, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=u_top_intermediate,          &
                   xmin = dx, xmax = lx - dx,                                      &
                   ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx-1, ny = ny, nz = nlev - 2,                              &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx-1, ny = ny, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=v_east_intermediate,         &
                   xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx,               &
                   ymin = dy, ymax = ly - dy,                                      &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = 0, ny = ny-1, nz = nlev - 2,                               &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = 0, ny = ny-1, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=v_west_intermediate,         &
                   xmin = -0.5_dp * dx, xmax = -0.5_dp * dx,                       &
                   ymin = dy, ymax = ly - dy,                                      &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = 0, ny = ny-1, nz = nlev - 2,                               &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = 0, ny = ny-1, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=v_north_intermediate,        &
                   xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
                   ymin = ly, ymax = ly,                                           &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = 0, nz = nlev - 2,                                 &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = 0, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=v_south_intermediate,        &
                   xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
                   ymin = 0.0_dp, ymax = 0.0_dp,                                   &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = 0, nz = nlev - 2,                                 &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = 0, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=v_top_intermediate,          &
                   xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
                   ymin = dy, ymax = ly - dy,                                      &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = ny-1, nz = nlev - 2,                              &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = ny-1, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=w_east_intermediate,         &
                   xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx,               &
                   ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = 0, ny = ny, nz = nlev - 2,                                 &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = 0, ny = ny, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=w_west_intermediate,         &
                   xmin = -0.5_dp * dx, xmax = -0.5_dp * dx,                       &
                   ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = 0, ny = ny, nz = nlev - 2,                                 &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = 0, ny = ny, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=w_north_intermediate,        &
                   xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
                   ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy,               &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = 0, nz = nlev - 2,                                 &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = 0, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=w_south_intermediate,        &
                   xmin =  0.5_dp * dx, xmax = lx - 0.5_dp * dx,                   &
                   ymin = -0.5_dp * dy, ymax = -0.5_dp * dy,                       &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = 0, nz = nlev - 2,                                 &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = 0, nz = nlev - 2)
 
           CALL init_grid_definition('boundary intermediate', grid=w_top_intermediate,          &
                   xmin =  0.5_dp * dx, xmax = lx - 0.5_dp * dx,                   &
                   ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
-                  zmin =  0.0_dp, zmax = 0.0_dp,                                  &
-                  x0=x0, y0=y0, z0 = z0,                                          &
-                  nx = nx, ny = ny, nz = nlev - 2,                                &
-                  dx = dx, dy = dy, dz = dz)
+                  x0=x0, y0=y0, z0 = z0,                                          &
+                  nx = nx, ny = ny, nz = nlev - 2)
        END IF
 
@@ -869,36 +853,31 @@
 !------------------------------------------------------------------------------
 
-       IF (TRIM(mode) == 'profile')  THEN
+       profile_grids_required = ( TRIM(cfg % ic_mode) == 'profile' .OR.              &
+                                  TRIM(cfg % bc_mode) == 'ideal' )
+
+       IF (profile_grids_required)  THEN
           CALL init_grid_definition('boundary', grid=scalar_profile_grid,      &
                   xmin = 0.5_dp * lx, xmax = 0.5_dp * lx,                      &
                   ymin = 0.5_dp * ly, ymax = 0.5_dp * ly,                      &
-                  zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                 &
                   x0=x0, y0=y0, z0 = z0,                                       &
-                  nx = 0, ny = 0, nz = nz,                                     &
-                  dx = dx, dy = dy, dz = dz)
+                  nx = 0, ny = 0, nz = nz, z=z)
 
           CALL init_grid_definition('boundary', grid=w_profile_grid,           &
                   xmin = 0.5_dp * lx, xmax = 0.5_dp * lx,                      &
                   ymin = 0.5_dp * ly, ymax = 0.5_dp * ly,                      &
-                  zmin = dz, zmax = lz - dz,                                   &
                   x0=x0, y0=y0, z0 = z0,                                       &
-                  nx = 0, ny = 0, nz = nz - 1,                                 &
-                  dx = dx, dy = dy, dz = dz)
+                  nx = 0, ny = 0, nz = nz - 1, z=zw)
 
           CALL init_grid_definition('boundary', grid=scalar_profile_intermediate,&
                   xmin = 0.5_dp * lx, xmax = 0.5_dp * lx,                      &
                   ymin = 0.5_dp * ly, ymax = 0.5_dp * ly,                      &
-                  zmin = 0.0_dp, zmax = 0.0_dp,                                &
                   x0=x0, y0=y0, z0 = z0,                                       &
-                  nx = 0, ny = 0, nz = nlev - 2,                               &
-                  dx = dx, dy = dy, dz = dz)
+                  nx = 0, ny = 0, nz = nlev - 2, z=z)
 
           CALL init_grid_definition('boundary', grid=w_profile_intermediate,   &
                   xmin = 0.5_dp * lx, xmax = 0.5_dp * lx,                      &
                   ymin = 0.5_dp * ly, ymax = 0.5_dp * ly,                      &
-                  zmin = 0.0_dp, zmax = 0.0_dp,                                &
                   x0=x0, y0=y0, z0 = z0,                                       &
-                  nx = 0, ny = 0, nz = nlev - 2,                               &
-                  dx = dx, dy = dy, dz = dz)
+                  nx = 0, ny = 0, nz = nlev - 2, z=zw)
        END IF
 
@@ -908,5 +887,5 @@
 !------------------------------------------------------------------------------
        interp_mode = 's'
-       CALL setup_interpolation(cosmo_grid, palm_grid, palm_intermediate, interp_mode, mode=mode)
+       CALL setup_interpolation(cosmo_grid, palm_grid, palm_intermediate, interp_mode, ic_mode=cfg % ic_mode)
        IF (boundary_variables_required)  THEN
           CALL setup_interpolation(cosmo_grid, scalars_east_grid, scalars_east_intermediate, interp_mode)
@@ -918,5 +897,5 @@
 
        interp_mode = 'u'
-       CALL setup_interpolation(cosmo_grid, u_initial_grid, u_initial_intermediate, interp_mode, mode=mode)
+       CALL setup_interpolation(cosmo_grid, u_initial_grid, u_initial_intermediate, interp_mode, ic_mode=cfg % ic_mode)
        IF (boundary_variables_required)  THEN
           CALL setup_interpolation(cosmo_grid, u_east_grid, u_east_intermediate, interp_mode)
@@ -928,5 +907,5 @@
 
        interp_mode = 'v'
-       CALL setup_interpolation(cosmo_grid, v_initial_grid, v_initial_intermediate, interp_mode, mode=mode)
+       CALL setup_interpolation(cosmo_grid, v_initial_grid, v_initial_intermediate, interp_mode, ic_mode=cfg % ic_mode)
        IF (boundary_variables_required)  THEN
           CALL setup_interpolation(cosmo_grid, v_east_grid, v_east_intermediate, interp_mode)
@@ -938,5 +917,5 @@
 
        interp_mode = 'w'
-       CALL setup_interpolation(cosmo_grid, w_initial_grid, w_initial_intermediate, interp_mode, mode=mode)
+       CALL setup_interpolation(cosmo_grid, w_initial_grid, w_initial_intermediate, interp_mode, ic_mode=cfg % ic_mode)
        IF (boundary_variables_required)  THEN
           CALL setup_interpolation(cosmo_grid, w_east_grid, w_east_intermediate, interp_mode)
@@ -947,6 +926,7 @@
        END IF
 
-       IF (TRIM(mode) == 'profile')  THEN
-           CALL setup_averaging(cosmo_grid, palm_intermediate, imin, imax, jmin, jmax) 
+       IF (TRIM(cfg % ic_mode) == 'profile')  THEN
+           CALL setup_averaging(cosmo_grid, palm_intermediate,                 &
+                average_imin, average_imax, average_jmin, average_jmax) 
        END IF
         
@@ -955,10 +935,10 @@
 
 
-    SUBROUTINE setup_interpolation(cosmo_grid, palm_grid, palm_intermediate, kind, mode)
+    SUBROUTINE setup_interpolation(cosmo_grid, palm_grid, palm_intermediate, kind, ic_mode)
 
        TYPE(grid_definition), INTENT(IN), TARGET    ::  cosmo_grid
        TYPE(grid_definition), INTENT(INOUT), TARGET ::  palm_grid, palm_intermediate
        CHARACTER, INTENT(IN)                        ::  kind
-       CHARACTER(LEN=*), INTENT(IN), OPTIONAL       ::  mode
+       CHARACTER(LEN=*), INTENT(IN), OPTIONAL       ::  ic_mode
 
        TYPE(grid_definition), POINTER      ::  grid
@@ -966,10 +946,9 @@
        REAL(dp), DIMENSION(:,:,:), POINTER ::  h
 
-       LOGICAL :: setup_vertical = .TRUE.
-
-       IF (PRESENT(mode))  THEN
-          IF (TRIM(mode) == 'profile')  setup_vertical = .FALSE.
-       ELSE
-          setup_vertical = .TRUE.
+       LOGICAL :: setup_vertical
+
+       setup_vertical = .TRUE.
+       IF (PRESENT(ic_mode))  THEN
+          IF (TRIM(ic_mode) == 'profile')  setup_vertical = .FALSE.
        END IF
 
@@ -1006,5 +985,5 @@
        CASE DEFAULT
 
-          message = "Interpolation mode '" // mode // "' is not supported."
+          message = "Interpolation quantity '" // kind // "' is not supported."
           CALL abort('setup_interpolation', message)
 
@@ -1014,10 +993,8 @@
 
        CALL find_horizontal_neighbours(lat, lon,                               &
-          cosmo_grid % dxi, cosmo_grid % dyi, grid % clat,                     &
-          grid % clon, grid % ii, grid % jj)
+          grid % clat, grid % clon, grid % ii, grid % jj)
 
        CALL compute_horizontal_interp_weights(lat, lon,                        &
-          cosmo_grid % dxi, cosmo_grid % dyi, grid % clat,                     &
-          grid % clon, grid % ii, grid % jj, grid % w_horiz)
+          grid % clat, grid % clon, grid % ii, grid % jj, grid % w_horiz)
 
 !------------------------------------------------------------------------------
@@ -1044,11 +1021,15 @@
 
        TYPE(grid_definition), POINTER    ::  grid
-       REAL ::  lonmin_pos,lonmax_pos, latmin_pos, latmax_pos
+       REAL(dp)                          ::  lonmin_pos,lonmax_pos, latmin_pos, latmax_pos
+       REAL(dp)                          ::  cosmo_dxi, cosmo_dyi
+
+       cosmo_dxi = 1.0_dp / (cosmo_grid % lon(1) - cosmo_grid % lon(0))
+       cosmo_dyi = 1.0_dp / (cosmo_grid % lat(1) - cosmo_grid % lat(0))
 
        ! find horizontal index ranges for profile averaging
-       lonmin_pos = (MINVAL(palm_intermediate % clon(:,:)) - cosmo_grid % lon(0)) * cosmo_grid % dxi
-       lonmax_pos = (MAXVAL(palm_intermediate % clon(:,:)) - cosmo_grid % lon(0)) * cosmo_grid % dxi
-       latmin_pos = (MINVAL(palm_intermediate % clat(:,:)) - cosmo_grid % lat(0)) * cosmo_grid % dyi
-       latmax_pos = (MAXVAL(palm_intermediate % clat(:,:)) - cosmo_grid % lat(0)) * cosmo_grid % dyi
+       lonmin_pos = (MINVAL(palm_intermediate % clon(:,:)) - cosmo_grid % lon(0)) * cosmo_dxi
+       lonmax_pos = (MAXVAL(palm_intermediate % clon(:,:)) - cosmo_grid % lon(0)) * cosmo_dxi
+       latmin_pos = (MINVAL(palm_intermediate % clat(:,:)) - cosmo_grid % lat(0)) * cosmo_dyi
+       latmax_pos = (MAXVAL(palm_intermediate % clat(:,:)) - cosmo_grid % lat(0)) * cosmo_dyi
 
        imin = FLOOR(lonmin_pos)
@@ -1076,33 +1057,10 @@
 ! Description:
 ! ------------
-!> Helper function that computes horizontal domain extend in x or y direction
-!> such that the centres of a boundary grid fall at -dx/2 or lx + dx/2.
-!> 
-!> Input parameters:
-!> -----------------
-!> dxy : grid spacing in x or y direction
-!> lxy : domain length in dxy direction
-!> 
-!> Output parameters:
-!> ------------------
-!> boundary_extent : Domain minimum xymin (maximum xymax) if dxy < 0 (> 0)
-!------------------------------------------------------------------------------!
-    REAL(dp) FUNCTION boundary_extent(dxy, lxy)
-        REAL(dp), INTENT(IN) ::  dxy, lxy
-
-        boundary_extent = 0.5_dp * lxy + SIGN(lxy + ABS(dxy), dxy)
-
-    END FUNCTION boundary_extent
-
-
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
 !> Initializes grid_definition-type variables.
 !> 
 !> Input parameters:
 !> -----------------
-!> mode : Initialization mode, distinguishes between PALM-4U and COSMO-DE grids
-!>    as well as grids covering the boundary surfaces. Valid modes are:
+!> kind : Grid kind, distinguishes between PALM-4U and COSMO-DE grids
+!>    as well as grids covering the boundary surfaces. Valid kinds are:
 !>       - 'palm'
 !>       - 'cosmo-de'
@@ -1114,5 +1072,5 @@
 !>    PALM-4U computational domain (i.e. the outer cell faces). The coordinates
 !>    of the generated grid will be inferred from this information taking into
-!>    account the initialization mode. For example, the coordinates of a
+!>    account the initialization mode ic_mode. For example, the coordinates of a
 !>    boundary grid initialized using mode 'eastwest-scalar' will be located in
 !>    planes one half grid point outwards of xmin and xmax.
@@ -1126,12 +1084,13 @@
 !> grid : Grid variable to be initialized.
 !------------------------------------------------------------------------------!
-    SUBROUTINE init_grid_definition(kind, xmin, xmax, ymin, ymax, zmin, zmax,  &
-                                    x0, y0, z0, nx, ny, nz, dx, dy, dz, grid, mode)
+    SUBROUTINE init_grid_definition(kind, xmin, xmax, ymin, ymax,              &
+                                    x0, y0, z0, nx, ny, nz, z, zw, grid, ic_mode)
         CHARACTER(LEN=*), INTENT(IN)           ::  kind
-        CHARACTER(LEN=*), INTENT(IN), OPTIONAL ::  mode
+        CHARACTER(LEN=*), INTENT(IN), OPTIONAL ::  ic_mode
         INTEGER, INTENT(IN)                    ::  nx, ny, nz
-        REAL(dp), INTENT(IN)                   ::  xmin, xmax, ymin, ymax, zmin, zmax
+        REAL(dp), INTENT(IN)                   ::  xmin, xmax, ymin, ymax
         REAL(dp), INTENT(IN)                   ::  x0, y0, z0
-        REAL(dp), OPTIONAL, INTENT(IN)         ::  dx, dy, dz
+        REAL(dp), INTENT(IN), TARGET, OPTIONAL ::  z(:)
+        REAL(dp), INTENT(IN), TARGET, OPTIONAL ::  zw(:)
         TYPE(grid_definition), INTENT(INOUT)   ::  grid
 
@@ -1142,5 +1101,4 @@
         grid % lx = xmax - xmin
         grid % ly = ymax - ymin
-        grid % lz = zmax - zmin
 
         grid % x0 = x0
@@ -1151,27 +1109,9 @@
 
         CASE('boundary')
-           IF (.NOT. PRESENT(dx))  THEN
-              message = "dx is not present but needed for 'eastwest-scalar' "//&
-                        "initializaton."
+
+           IF (.NOT.PRESENT(z))  THEN
+              message = "z has not been passed but is required for 'boundary' grids"
               CALL abort('init_grid_definition', message)
            END IF
-           IF (.NOT. PRESENT(dy))  THEN
-              message = "dy is not present but needed for 'eastwest-scalar' "//&
-                        "initializaton."
-              CALL abort('init_grid_definition', message)
-           END IF
-           IF (.NOT. PRESENT(dz))  THEN
-              message = "dz is not present but needed for 'eastwest-scalar' "//&
-                        "initializaton."
-              CALL abort('init_grid_definition', message)
-           END IF
-
-           grid % dx  = dx
-           grid % dy  = dy
-           grid % dz  = dz
-
-           grid % dxi = 1.0_dp / grid % dx
-           grid % dyi = 1.0_dp / grid % dy
-           grid % dzi = 1.0_dp / grid % dz
 
            ALLOCATE( grid % x(0:nx) )
@@ -1181,40 +1121,16 @@
            CALL linspace(ymin, ymax, grid % y)
 
-           ALLOCATE( grid % z(0:nz) )
-           CALL linspace(zmin, zmax, grid % z)
+           grid % z => z
 
            ! Allocate neighbour indices and weights
-           IF (TRIM(mode) .NE. 'profile')  THEN
-              ALLOCATE( grid % kk(0:nx, 0:ny, 0:nz, 2) )
+           IF (TRIM(ic_mode) .NE. 'profile')  THEN
+              ALLOCATE( grid % kk(0:nx, 0:ny, 1:nz, 2) )
               grid % kk(:,:,:,:) = -1
 
-              ALLOCATE( grid % w_verti(0:nx, 0:ny, 0:nz, 2) )
+              ALLOCATE( grid % w_verti(0:nx, 0:ny, 1:nz, 2) )
               grid % w_verti(:,:,:,:) = 0.0_dp
            END IF
         
         CASE('boundary intermediate')
-           IF (.NOT. PRESENT(dx))  THEN
-              message = "dx is not present but needed for 'eastwest-scalar' "//&
-                        "initializaton."
-              CALL abort('init_grid_definition', message)
-           END IF
-           IF (.NOT. PRESENT(dy))  THEN
-              message = "dy is not present but needed for 'eastwest-scalar' "//&
-                        "initializaton."
-              CALL abort('init_grid_definition', message)
-           END IF
-           IF (.NOT. PRESENT(dz))  THEN
-              message = "dz is not present but needed for 'eastwest-scalar' "//&
-                        "initializaton."
-              CALL abort('init_grid_definition', message)
-           END IF
-
-           grid % dx  = dx
-           grid % dy  = dy
-           grid % dz  = dz
-
-           grid % dxi = 1.0_dp / grid % dx
-           grid % dyi = 1.0_dp / grid % dy
-           grid % dzi = 1.0_dp / grid % dz
 
            ALLOCATE( grid % x(0:nx) )
@@ -1224,11 +1140,9 @@
            CALL linspace(ymin, ymax, grid % y)
 
-           ALLOCATE( grid % z(0:nz) )
-           CALL linspace(zmin, zmax, grid % z)
-
            ALLOCATE( grid % clon(0:nx, 0:ny), grid % clat(0:nx, 0:ny)  )
+
            CALL rotate_to_cosmo(                                               &
-              phir = project( grid % y, y0, EARTH_RADIUS ) , & ! = plate-carree latitude
-              lamr = project( grid % x, x0, EARTH_RADIUS ) , & ! = plate-carree longitude
+              phir = project( grid % y, y0, EARTH_RADIUS ) ,                   & ! = plate-carree latitude
+              lamr = project( grid % x, x0, EARTH_RADIUS ) ,                   & ! = plate-carree longitude
               phip = phi_cn, lamp = lambda_cn,                                 &
               phi  = grid % clat,                                              &
@@ -1249,57 +1163,55 @@
         ! corresponding latitudes and longitudes of the rotated pole grid.
         CASE('palm')
+
+           IF (.NOT.PRESENT(z))  THEN
+              message = "z has not been passed but is required for 'palm' grids"
+              CALL abort('init_grid_definition', message)
+           END IF
+
+           IF (.NOT.PRESENT(zw))  THEN
+              message = "zw has not been passed but is required for 'palm' grids"
+              CALL abort('init_grid_definition', message)
+           END IF
+
            grid % name(1) = 'x and lon'
            grid % name(2) = 'y and lat'
            grid % name(3) = 'z'
 
-           grid % dx  = grid % lx / (nx + 1)
-           grid % dy  = grid % ly / (ny + 1)
-           grid % dz  = grid % lz / (nz + 1)
-
-           grid % dxi = 1.0_dp / grid % dx
-           grid % dyi = 1.0_dp / grid % dy
-           grid % dzi = 1.0_dp / grid % dz
-
-           ALLOCATE( grid % x(0:nx),   grid % y(0:ny),  grid % z(0:nz)  )
-           ALLOCATE( grid % xu(1:nx),  grid % yv(1:ny), grid % zw(1:nz) )
-           CALL linspace(xmin + 0.5_dp*grid % dx, xmax - 0.5_dp*grid % dx, grid % x)
-           CALL linspace(ymin + 0.5_dp*grid % dy, ymax - 0.5_dp*grid % dy, grid % y)
-           CALL linspace(zmin + 0.5_dp*grid % dz, zmax - 0.5_dp*grid % dz, grid % z)
-           CALL linspace(xmin + grid % dx, xmax - grid % dx, grid % xu)
-           CALL linspace(ymin + grid % dy, ymax - grid % dy, grid % yv)
-           CALL linspace(zmin + grid % dz, zmax - grid % dz, grid % zw)
+           !TODO: Remove use of global dx, dy, dz variables. Consider
+           !TODO:   associating global x,y, and z arrays.
+           ALLOCATE( grid % x(0:nx),   grid % y(0:ny) )
+           ALLOCATE( grid % xu(1:nx),  grid % yv(1:ny) )
+           CALL linspace(xmin + 0.5_dp* dx, xmax - 0.5_dp* dx, grid % x)
+           CALL linspace(ymin + 0.5_dp* dy, ymax - 0.5_dp* dy, grid % y)
+           grid % z => z
+           CALL linspace(xmin +  dx, xmax -  dx, grid % xu)
+           CALL linspace(ymin +  dy, ymax -  dy, grid % yv)
+           grid % zw => zw
 
            grid % depths => depths
 
            ! Allocate neighbour indices and weights
-           IF (TRIM(mode) .NE. 'profile')  THEN
-              ALLOCATE( grid % kk(0:nx, 0:ny, 0:nz, 2) )
+           IF (TRIM(ic_mode) .NE. 'profile')  THEN
+              ALLOCATE( grid % kk(0:nx, 0:ny, 1:nz, 2) )
               grid % kk(:,:,:,:) = -1
 
-              ALLOCATE( grid % w_verti(0:nx, 0:ny, 0:nz, 2) )
+              ALLOCATE( grid % w_verti(0:nx, 0:ny, 1:nz, 2) )
               grid % w_verti(:,:,:,:) = 0.0_dp
            END IF
 
         CASE('palm intermediate')
+
            grid % name(1) = 'x and lon'
            grid % name(2) = 'y and lat'
-           grid % name(3) = 'z'
-
-           grid % dx  = grid % lx / (nx + 1)
-           grid % dy  = grid % ly / (ny + 1)
-           grid % dz  = grid % lz / (nz + 1)
-
-           grid % dxi = 1.0_dp / grid % dx
-           grid % dyi = 1.0_dp / grid % dy
-           grid % dzi = 1.0_dp / grid % dz
-
-           ALLOCATE( grid % x(0:nx),   grid % y(0:ny),  grid % z(0:nz)  )
-           ALLOCATE( grid % xu(1:nx),  grid % yv(1:ny), grid % zw(1:nz) )
-           CALL linspace(xmin + 0.5_dp*grid % dx, xmax - 0.5_dp*grid % dx, grid % x)
-           CALL linspace(ymin + 0.5_dp*grid % dy, ymax - 0.5_dp*grid % dy, grid % y)
-           CALL linspace(zmin + 0.5_dp*grid % dz, zmax - 0.5_dp*grid % dz, grid % z)
-           CALL linspace(xmin + grid % dx, xmax - grid % dx, grid % xu)
-           CALL linspace(ymin + grid % dy, ymax - grid % dy, grid % yv)
-           CALL linspace(zmin + grid % dz, zmax - grid % dz, grid % zw)
+           grid % name(3) = 'interpolated hhl or hfl'
+
+           !TODO: Remove use of global dx, dy, dz variables. Consider
+           !TODO:   associating global x,y, and z arrays.
+           ALLOCATE( grid % x(0:nx),   grid % y(0:ny) )
+           ALLOCATE( grid % xu(1:nx),  grid % yv(1:ny) )
+           CALL linspace(xmin + 0.5_dp*dx, xmax - 0.5_dp*dx, grid % x)
+           CALL linspace(ymin + 0.5_dp*dy, ymax - 0.5_dp*dy, grid % y)
+           CALL linspace(xmin + dx, xmax - dx, grid % xu)
+           CALL linspace(ymin + dy, ymax - dy, grid % yv)
 
            grid % depths => depths
@@ -1355,19 +1267,11 @@
            grid % name(3) = 'height'
 
-           grid % dx  = grid % lx / nx     ! = 0.025 deg, stored in radians
-           grid % dy  = grid % ly / ny     ! = 0.025 deg, stored in radians
-           grid % dz  = 0.0_dp             ! not defined yet
-
-           grid % dxi = 1.0_dp / grid % dx ! [rad^-1]
-           grid % dyi = 1.0_dp / grid % dy ! [rad^-1]
-           grid % dzi = 0.0_dp             ! not defined yet
-
-           ALLOCATE( grid % lon(0:nx),   grid % lat(0:ny),  grid % z(0:nz)  )
-           ALLOCATE( grid % lonu(0:nx),  grid % latv(0:ny), grid % zw(0:nz) )
+           ALLOCATE( grid % lon(0:nx),   grid % lat(0:ny)  )
+           ALLOCATE( grid % lonu(0:nx),  grid % latv(0:ny) )
 
            CALL linspace(xmin, xmax, grid % lon)
            CALL linspace(ymin, ymax, grid % lat)
-           grid % lonu(:) = grid % lon + 0.5_dp * grid % dx
-           grid % latv(:) = grid % lat + 0.5_dp * grid % dy
+           grid % lonu(:) = grid % lon + 0.5_dp * (grid % lx / grid % nx)
+           grid % latv(:) = grid % lat + 0.5_dp * (grid % ly / grid % ny)
 
            ! Point to heights of half levels (hhl) and compute heights of full
@@ -1384,4 +1288,406 @@
 
     END SUBROUTINE init_grid_definition
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> PALM's stretched vertical grid generator. Forked from PALM revision 3139, see
+!> https://palm.muk.uni-hannover.de/trac/browser/palm/trunk/SOURCE/init_grid.f90?rev=3139
+!> 
+!> This routine computes the levels of scalar points. The levels of the velocity
+!> points are then obtained as the midpoints inbetween using the INIFOR routine
+!> 'modpoints'.
+!------------------------------------------------------------------------------!
+    SUBROUTINE stretched_z(z, dz, dz_max, dz_stretch_factor, dz_stretch_level, &
+                           dz_stretch_level_start, dz_stretch_level_end,       &
+                           dz_stretch_factor_array)
+
+       REAL(dp), DIMENSION(:), INTENT(INOUT) ::  z, dz, dz_stretch_factor_array
+       REAL(dp), DIMENSION(:), INTENT(INOUT) ::  dz_stretch_level_start, dz_stretch_level_end
+       REAL(dp), INTENT(IN) ::  dz_max, dz_stretch_factor, dz_stretch_level
+
+       INTEGER ::  number_stretch_level_start        !< number of user-specified start levels for stretching
+       INTEGER ::  number_stretch_level_end          !< number of user-specified end levels for stretching
+
+       REAL(dp), DIMENSION(:), ALLOCATABLE ::  min_dz_stretch_level_end
+       REAL(dp) ::  dz_level_end, dz_stretched
+
+       INTEGER ::  dz_stretch_level_end_index(9)               !< vertical grid level index until which the vertical grid spacing is stretched
+       INTEGER ::  dz_stretch_level_start_index(9)             !< vertical grid level index above which the vertical grid spacing is stretched
+       INTEGER ::  dz_stretch_level_index = 0
+       INTEGER ::  k, n, number_dz
+!
+!-- Compute height of u-levels from constant grid length and dz stretch factors
+       IF ( dz(1) == -1.0_dp )  THEN
+          message = 'missing dz'
+          CALL abort( 'stretched_z', message)
+       ELSEIF ( dz(1) <= 0.0_dp )  THEN
+          WRITE( message, * ) 'dz=', dz(1),' <= 0.0'
+          CALL abort( 'stretched_z', message)
+       ENDIF
+
+!
+!-- Initialize dz_stretch_level_start with the value of dz_stretch_level
+!-- if it was set by the user
+       IF ( dz_stretch_level /= -9999999.9_dp ) THEN
+          dz_stretch_level_start(1) = dz_stretch_level
+       ENDIF
+       
+!
+!-- Determine number of dz values and stretching levels specified by the
+!-- user to allow right controlling of the stretching mechanism and to
+!-- perform error checks. The additional requirement that dz /= dz_max
+!-- for counting number of user-specified dz values is necessary. Otherwise
+!-- restarts would abort if the old stretching mechanism with dz_stretch_level
+!-- is used (Attention: The user is not allowed to specify a dz value equal
+!-- to the default of dz_max = 999.0). 
+       number_dz = COUNT( dz /= -1.0_dp .AND. dz /= dz_max )
+       number_stretch_level_start = COUNT( dz_stretch_level_start /=           &
+                                           -9999999.9_dp )
+       number_stretch_level_end = COUNT( dz_stretch_level_end /=               &
+                                         9999999.9_dp )
+
+!
+!-- The number of specified end levels +1 has to be the same than the number 
+!-- of specified dz values
+       IF ( number_dz /= number_stretch_level_end + 1 ) THEN
+          WRITE( message, * ) 'The number of values for dz = ',                &
+                              number_dz, 'has to be the same than ',           &
+                              'the number of values for ',                     &
+                              'dz_stretch_level_end + 1 = ',                   &
+                              number_stretch_level_end+1
+          CALL abort( 'stretched_z', message)
+       ENDIF
+    
+!
+!--    The number of specified start levels has to be the same or one less than 
+!--    the number of specified dz values
+       IF ( number_dz /= number_stretch_level_start + 1 .AND.                  &
+            number_dz /= number_stretch_level_start ) THEN
+          WRITE( message, * ) 'The number of values for dz = ',         &
+                              number_dz, 'has to be the same or one ', &
+                              'more than& the number of values for ',  &
+                              'dz_stretch_level_start = ',             &
+                              number_stretch_level_start
+          CALL abort( 'stretched_z', message)
+       ENDIF
+    
+!--    The number of specified start levels has to be the same or one more than 
+!--    the number of specified end levels
+       IF ( number_stretch_level_start /= number_stretch_level_end + 1 .AND.   &
+            number_stretch_level_start /= number_stretch_level_end ) THEN
+          WRITE( message, * ) 'The number of values for ',              &
+                              'dz_stretch_level_start = ',              &
+                              dz_stretch_level_start, 'has to be the ',&
+                              'same or one more than& the number of ', &
+                              'values for dz_stretch_level_end = ',    &
+                              number_stretch_level_end
+          CALL abort( 'stretched_z', message)
+       ENDIF
+
+!
+!-- Initialize dz for the free atmosphere with the value of dz_max
+       IF ( dz(number_stretch_level_start+1) == -1.0_dp .AND.                     &
+            number_stretch_level_start /= 0 ) THEN 
+          dz(number_stretch_level_start+1) = dz_max
+       ENDIF
+       
+!
+!-- Initialize the stretching factor if (infinitely) stretching in the free 
+!-- atmosphere is desired (dz_stretch_level_end was not specified for the 
+!-- free atmosphere)
+       IF ( number_stretch_level_start == number_stretch_level_end + 1 ) THEN 
+          dz_stretch_factor_array(number_stretch_level_start) =                   &
+          dz_stretch_factor
+       ENDIF
+
+!-- Allocation of arrays for stretching
+       ALLOCATE( min_dz_stretch_level_end(number_stretch_level_start) )
+
+!
+!--    The stretching region has to be large enough to allow for a smooth
+!--    transition between two different grid spacings
+       DO n = 1, number_stretch_level_start
+          min_dz_stretch_level_end(n) = dz_stretch_level_start(n) +            &
+                                        4 * MAX( dz(n),dz(n+1) )
+       ENDDO
+
+       IF ( ANY( min_dz_stretch_level_end(1:number_stretch_level_start) >      &
+                 dz_stretch_level_end(1:number_stretch_level_start) ) ) THEN
+       !IF ( ANY( min_dz_stretch_level_end >      &
+       !          dz_stretch_level_end ) ) THEN
+             message = 'Each dz_stretch_level_end has to be larger '  // &
+                       'than its corresponding value for ' //            &
+                       'dz_stretch_level_start + 4*MAX(dz(n),dz(n+1)) '//&
+                       'to allow for smooth grid stretching'
+             CALL abort('stretched_z', message)
+       ENDIF
+       
+!
+!--    Stretching must not be applied within the prandtl_layer 
+!--    (first two grid points). For the default case dz_stretch_level_start 
+!--    is negative. Therefore the absolut value is checked here.
+       IF ( ANY( ABS( dz_stretch_level_start ) < dz(1) * 1.5_dp ) ) THEN
+          WRITE( message, * ) 'Eeach dz_stretch_level_start has to be ',&
+                              'larger than ', dz(1) * 1.5
+             CALL abort( 'stretched_z', message)
+       ENDIF
+
+!
+!--    The stretching has to start and end on a grid level. Therefore 
+!--    user-specified values have to ''interpolate'' to the next lowest level
+       IF ( number_stretch_level_start /= 0 ) THEN
+          dz_stretch_level_start(1) = INT( (dz_stretch_level_start(1) -        &
+                                            dz(1)/2.0) / dz(1) )               &
+                                      * dz(1) + dz(1)/2.0
+       ENDIF
+       
+       IF ( number_stretch_level_start > 1 ) THEN
+          DO n = 2, number_stretch_level_start
+             dz_stretch_level_start(n) = INT( dz_stretch_level_start(n) /      &
+                                              dz(n) ) * dz(n)
+          ENDDO
+       ENDIF
+       
+       IF ( number_stretch_level_end /= 0 ) THEN
+          DO n = 1, number_stretch_level_end
+             dz_stretch_level_end(n) = INT( dz_stretch_level_end(n) /          &
+                                            dz(n+1) ) * dz(n+1)
+          ENDDO
+       ENDIF
+ 
+!
+!--    Determine stretching factor if necessary
+       IF ( number_stretch_level_end >= 1 ) THEN 
+          CALL calculate_stretching_factor( number_stretch_level_end, dz,      & 
+                                            dz_stretch_factor,                 &
+                                            dz_stretch_factor_array,           &   
+                                            dz_stretch_level_end,              &
+                                            dz_stretch_level_start )
+       ENDIF
+
+       z(1) = dz(1) * 0.5_dp
+!
+       dz_stretch_level_index = n
+       dz_stretched = dz(1)
+       DO  k = 2, n
+
+          IF ( dz_stretch_level <= z(k-1)  .AND.  dz_stretched < dz_max )  THEN
+
+             dz_stretched = dz_stretched * dz_stretch_factor
+             dz_stretched = MIN( dz_stretched, dz_max )
+
+             IF ( dz_stretch_level_index == n ) dz_stretch_level_index = k-1
+
+          ENDIF
+
+          z(k) = z(k-1) + dz_stretched
+
+       ENDDO
+!--    Determine u and v height levels considering the possibility of grid
+!--    stretching in several heights.
+       n = 1
+       dz_stretch_level_start_index(:) = UBOUND(z, 1)
+       dz_stretch_level_end_index(:) = UBOUND(z, 1)
+       dz_stretched = dz(1)
+
+!--    The default value of dz_stretch_level_start is negative, thus the first
+!--    condition is always true. Hence, the second condition is necessary.
+       DO  k = 2, UBOUND(z, 1)
+          IF ( dz_stretch_level_start(n) <= z(k-1) .AND.                      &
+               dz_stretch_level_start(n) /= -9999999.9_dp ) THEN
+             dz_stretched = dz_stretched * dz_stretch_factor_array(n)
+             
+             IF ( dz(n) > dz(n+1) ) THEN
+                dz_stretched = MAX( dz_stretched, dz(n+1) ) !Restrict dz_stretched to the user-specified (higher) dz
+             ELSE
+                dz_stretched = MIN( dz_stretched, dz(n+1) ) !Restrict dz_stretched to the user-specified (lower) dz
+             ENDIF
+             
+             IF ( dz_stretch_level_start_index(n) == UBOUND(z, 1) )            &
+             dz_stretch_level_start_index(n) = k-1
+             
+          ENDIF
+          
+          z(k) = z(k-1) + dz_stretched
+          
+!
+!--       Make sure that the stretching ends exactly at dz_stretch_level_end 
+          dz_level_end = ABS( z(k) - dz_stretch_level_end(n) ) 
+          
+          IF ( dz_level_end < dz(n+1)/3.0 ) THEN
+             z(k) = dz_stretch_level_end(n)
+             dz_stretched = dz(n+1)
+             dz_stretch_level_end_index(n) = k
+             n = n + 1             
+          ENDIF
+       ENDDO
+
+       DEALLOCATE( min_dz_stretch_level_end )
+
+    END SUBROUTINE stretched_z
+
+
+! Description: [PALM subroutine]
+! -----------------------------------------------------------------------------!
+!> Calculation of the stretching factor through an iterative method. Ideas were 
+!> taken from the paper "Regional stretched grid generation and its application
+!> to the NCAR RegCM (1999)". Normally, no analytic solution exists because the
+!> system of equations has two variables (r,l) but four requirements 
+!> (l=integer, r=[0,88;1,2], Eq(6), Eq(5) starting from index j=1) which
+!> results into an overdetermined system. 
+!------------------------------------------------------------------------------!
+ SUBROUTINE calculate_stretching_factor( number_end, dz, dz_stretch_factor,    &
+                                         dz_stretch_factor_array,              &   
+                                         dz_stretch_level_end,                 &
+                                         dz_stretch_level_start )
+ 
+    REAL(dp), DIMENSION(:), INTENT(IN)    ::  dz
+    REAL(dp), DIMENSION(:), INTENT(INOUT) ::  dz_stretch_factor_array
+    REAL(dp), DIMENSION(:), INTENT(IN)    ::  dz_stretch_level_end, dz_stretch_level_start
+    REAL(dp)                              ::  dz_stretch_factor
+  
+    INTEGER ::  iterations  !< number of iterations until stretch_factor_lower/upper_limit is reached  
+    INTEGER ::  l_rounded   !< after l_rounded grid levels dz(n) is strechted to dz(n+1) with stretch_factor_2 
+    INTEGER ::  n           !< loop variable for stretching
+    
+    INTEGER, INTENT(IN) ::  number_end !< number of user-specified end levels for stretching
+        
+    REAL(dp) ::  delta_l               !< absolute difference between l and l_rounded
+    REAL(dp) ::  delta_stretch_factor  !< absolute difference between stretch_factor_1 and stretch_factor_2
+    REAL(dp) ::  delta_total_new       !< sum of delta_l and delta_stretch_factor for the next iteration (should be as small as possible) 
+    REAL(dp) ::  delta_total_old       !< sum of delta_l and delta_stretch_factor for the last iteration 
+    REAL(dp) ::  distance              !< distance between dz_stretch_level_start and dz_stretch_level_end (stretching region)
+    REAL(dp) ::  l                     !< value that fulfil Eq. (5) in the paper mentioned above together with stretch_factor_1 exactly
+    REAL(dp) ::  numerator             !< numerator of the quotient
+    REAL(dp) ::  stretch_factor_1      !< stretching factor that fulfil Eq. (5) togehter with l exactly
+    REAL(dp) ::  stretch_factor_2      !< stretching factor that fulfil Eq. (6) togehter with l_rounded exactly
+    
+    REAL(dp) ::  dz_stretch_factor_array_2(9) = 1.08_dp  !< Array that contains all stretch_factor_2 that belongs to stretch_factor_1 
+    
+    REAL(dp), PARAMETER ::  stretch_factor_interval = 1.0E-06  !< interval for sampling possible stretching factors
+    REAL(dp), PARAMETER ::  stretch_factor_lower_limit = 0.88  !< lowest possible stretching factor
+    REAL(dp), PARAMETER ::  stretch_factor_upper_limit = 1.12  !< highest possible stretching factor
+ 
+ 
+    l = 0
+    DO  n = 1, number_end
+    
+       iterations = 1
+       stretch_factor_1 = 1.0 
+       stretch_factor_2 = 1.0
+       delta_total_old = 1.0
+       
+       IF ( dz(n) > dz(n+1) ) THEN
+          DO WHILE ( stretch_factor_1 >= stretch_factor_lower_limit ) 
+             
+             stretch_factor_1 = 1.0 - iterations * stretch_factor_interval
+             distance = ABS( dz_stretch_level_end(n) -                   &
+                        dz_stretch_level_start(n) ) 
+             numerator = distance*stretch_factor_1/dz(n) +               &
+                         stretch_factor_1 - distance/dz(n)
+             
+             IF ( numerator > 0.0 ) THEN
+                l = LOG( numerator ) / LOG( stretch_factor_1 ) - 1.0
+                l_rounded = NINT( l )
+                delta_l = ABS( l_rounded - l ) / l
+             ENDIF
+             
+             stretch_factor_2 = EXP( LOG( dz(n+1)/dz(n) ) / (l_rounded) )
+             
+             delta_stretch_factor = ABS( stretch_factor_1 -              &
+                                         stretch_factor_2 ) /            &
+                                    stretch_factor_2
+             
+             delta_total_new = delta_l + delta_stretch_factor
+
+!
+!--                stretch_factor_1 is taken to guarantee that the stretching
+!--                procedure ends as close as possible to dz_stretch_level_end.
+!--                stretch_factor_2 would guarantee that the stretched dz(n) is
+!--                equal to dz(n+1) after l_rounded grid levels.
+             IF (delta_total_new < delta_total_old) THEN
+                dz_stretch_factor_array(n) = stretch_factor_1
+                dz_stretch_factor_array_2(n) = stretch_factor_2
+                delta_total_old = delta_total_new
+             ENDIF
+             
+             iterations = iterations + 1
+            
+          ENDDO
+             
+       ELSEIF ( dz(n) < dz(n+1) ) THEN 
+          DO WHILE ( stretch_factor_1 <= stretch_factor_upper_limit )
+                     
+             stretch_factor_1 = 1.0 + iterations * stretch_factor_interval
+             distance = ABS( dz_stretch_level_end(n) -                      &
+                        dz_stretch_level_start(n) ) 
+             numerator = distance*stretch_factor_1/dz(n) +                  &
+                         stretch_factor_1 - distance/dz(n)
+             
+             l = LOG( numerator ) / LOG( stretch_factor_1 ) - 1.0
+             l_rounded = NINT( l )
+             delta_l = ABS( l_rounded - l ) / l
+             
+             stretch_factor_2 = EXP( LOG( dz(n+1)/dz(n) ) / (l_rounded) )
+
+             delta_stretch_factor = ABS( stretch_factor_1 -                 &
+                                        stretch_factor_2 ) /                &
+                                        stretch_factor_2
+             
+             delta_total_new = delta_l + delta_stretch_factor
+             
+!
+!--                stretch_factor_1 is taken to guarantee that the stretching
+!--                procedure ends as close as possible to dz_stretch_level_end.
+!--                stretch_factor_2 would guarantee that the stretched dz(n) is
+!--                equal to dz(n+1) after l_rounded grid levels.
+             IF (delta_total_new < delta_total_old) THEN
+                dz_stretch_factor_array(n) = stretch_factor_1
+                dz_stretch_factor_array_2(n) = stretch_factor_2
+                delta_total_old = delta_total_new
+             ENDIF
+             
+             iterations = iterations + 1
+          ENDDO
+          
+       ELSE
+          message = 'Two adjacent values of dz must be different'
+          CALL abort( 'calculate_stretching_factor', message)
+       ENDIF
+
+!
+!--    Check if also the second stretching factor fits into the allowed
+!--    interval. If not, print a warning for the user.
+       IF ( dz_stretch_factor_array_2(n) < stretch_factor_lower_limit .OR.     & 
+            dz_stretch_factor_array_2(n) > stretch_factor_upper_limit ) THEN
+          WRITE( message, * ) 'stretch_factor_2 = ',                    &
+                                     dz_stretch_factor_array_2(n), ' which is',&
+                                     ' responsible for exactly reaching& dz =',&
+                                      dz(n+1), 'after a specific amount of',   & 
+                                     ' grid levels& exceeds the upper',        &
+                                     ' limit =', stretch_factor_upper_limit,   &
+                                     ' &or lower limit = ',                    &
+                                     stretch_factor_lower_limit
+          CALL abort( 'calculate_stretching_factor', message )
+            
+       ENDIF
+    ENDDO
+        
+ END SUBROUTINE calculate_stretching_factor
+
+    SUBROUTINE midpoints(z, zw)
+
+        REAL(dp), INTENT(IN)  ::  z(0:)
+        REAL(dp), INTENT(OUT) ::  zw(1:)
+
+        INTEGER ::  k
+
+        DO k = 1, UBOUND(zw, 1)
+           zw(k) = 0.5_dp * (z(k-1) + z(k))
+        END DO
+
+    END SUBROUTINE midpoints
 
 
@@ -1409,16 +1715,17 @@
        )
 
-       !potential temperature, surface pressure
+       !potential temperature, surface pressure, including nudging and subsidence
        io_group_list(3) = init_io_group(                                       &
           in_files = flow_files,                                               &
-          out_vars = [output_var_table(3:8), output_var_table(42:42)],         &
+          out_vars = [output_var_table(3:8), output_var_table(42:42),          &
+                      output_var_table(49:51)],                                &
           in_var_list = (/input_var_table(3), input_var_table(17)/),           &
           kind = 'temperature'                                                 &
        )
 
-       !specific humidity
+       !specific humidity including nudging and subsidence
        io_group_list(4) = init_io_group(                                       &
           in_files = flow_files,                                               &
-          out_vars = output_var_table(9:14),                                   &
+          out_vars = [output_var_table(9:14), output_var_table(52:54)],        &
           in_var_list = input_var_table(4:4),                                  &
           kind = 'scalar'                                                      &
@@ -1428,5 +1735,5 @@
        io_group_list(5) = init_io_group(                                       &
           in_files = flow_files,                                               &
-          out_vars = [output_var_table(15:26), output_var_table(43:44)],       &
+          out_vars = [output_var_table(15:26), output_var_table(43:46)],       &
           !out_vars = output_var_table(15:20),                                  &
           in_var_list = input_var_table(5:6),                                  &
@@ -1444,8 +1751,8 @@
        !io_group_list(6) % to_be_processed = .FALSE.
    
-       !w velocity
+       !w velocity and subsidence and w nudging
        io_group_list(7) = init_io_group(                                       &
           in_files = flow_files,                                               &
-          out_vars = output_var_table(27:32),                                  &
+          out_vars = [output_var_table(27:32), output_var_table(47:48)],       &
           in_var_list = input_var_table(7:7),                                  &
           kind = 'scalar'                                                      &
@@ -1459,4 +1766,5 @@
           kind = 'accumulated'                                                 &
        )
+       io_group_list(8) % to_be_processed = .FALSE.
 
        !snow
@@ -1467,4 +1775,5 @@
           kind = 'accumulated'                                                 &
        )
+       io_group_list(9) % to_be_processed = .FALSE.
 
        !graupel
@@ -1475,4 +1784,5 @@
           kind = 'accumulated'                                                 &
        )
+       io_group_list(10) % to_be_processed = .FALSE.
 
        !evapotranspiration
@@ -1483,4 +1793,5 @@
           kind = 'accumulated'                                                 &
        )
+       io_group_list(11) % to_be_processed = .FALSE.
 
        !2m air temperature
@@ -1517,4 +1828,5 @@
           kind = 'running average'                                             &
        )
+       io_group_list(15) % to_be_processed = .FALSE.
 
        !lw radiation balance
@@ -1525,4 +1837,5 @@
           kind = 'running average'                                             &
        )
+       io_group_list(16) % to_be_processed = .FALSE.
 
     END SUBROUTINE setup_io_groups
@@ -1562,4 +1875,6 @@
        CALL report('fini_grids', 'Deallocating grids')
        
+       DEALLOCATE(x, y, z, xu, yv, zw, z_column, zw_column)
+
        DEALLOCATE(palm_grid%x,  palm_grid%y,  palm_grid%z,                     &
                   palm_grid%xu, palm_grid%yv, palm_grid%zw,                    &
@@ -1572,6 +1887,6 @@
                   palm_intermediate%clonu, palm_intermediate%clatu)
 
-       DEALLOCATE(cosmo_grid%lon,  cosmo_grid%lat,  cosmo_grid%z,              &
-                  cosmo_grid%lonu, cosmo_grid%latv, cosmo_grid%zw,             &
+       DEALLOCATE(cosmo_grid%lon,  cosmo_grid%lat,                             &
+                  cosmo_grid%lonu, cosmo_grid%latv,                            &
                   cosmo_grid%hfl)
 
@@ -1584,17 +1899,17 @@
 !> Initializes the the variable list.
 !------------------------------------------------------------------------------!
-    SUBROUTINE setup_variable_tables(mode)
-       CHARACTER(LEN=*), INTENT(IN) ::  mode
+    SUBROUTINE setup_variable_tables(ic_mode)
+       CHARACTER(LEN=*), INTENT(IN) ::  ic_mode
        TYPE(nc_var), POINTER        ::  var
 
-       IF (TRIM(start_date) == '')  THEN
+       IF (TRIM(cfg % start_date) == '')  THEN
           message = 'Simulation start date has not been set.'
           CALL abort('setup_variable_tables', message)
        END IF
 
-       nc_source_text = 'COSMO-DE analysis from ' // TRIM(start_date)
+       nc_source_text = 'COSMO-DE analysis from ' // TRIM(cfg % start_date)
 
        n_invar = 17
-       n_outvar = 44
+       n_outvar = 55
        ALLOCATE( input_var_table(n_invar) )
        ALLOCATE( output_var_table(n_outvar) )
@@ -1693,4 +2008,8 @@
 !- Section 2: NetCDF output variables
 !------------------------------------------------------------------------------
+!
+!------------------------------------------------------------------------------
+! Section 2.1: Realistic forcings, i.e. 3D initial and boundary conditions
+!------------------------------------------------------------------------------
        output_var_table(1) = init_nc_var(                                      &
           name              = 'init_soil_t',                                   &
@@ -1718,5 +2037,5 @@
 
        output_var_table(3) = init_nc_var(                                      &
-          name              = 'init_pt',                                       &
+          name              = 'init_atmosphere_pt',                            &
           std_name          = "",                                              &
           long_name         = "initial potential temperature",                 &
@@ -1727,7 +2046,7 @@
           grid              = palm_grid,                                       &
           intermediate_grid = palm_intermediate,                               &
-          is_profile = (TRIM(mode) == 'profile')                               &
-       )
-       IF (TRIM(mode) == 'profile')  THEN
+          is_profile = (TRIM(ic_mode) == 'profile')                            &
+       )
+       IF (TRIM(ic_mode) == 'profile')  THEN
           output_var_table(3) % grid => scalar_profile_grid
           output_var_table(3) % intermediate_grid => scalar_profile_intermediate
@@ -1795,5 +2114,5 @@
 
        output_var_table(9) = init_nc_var(                                      &
-          name              = 'init_qv',                                       &
+          name              = 'init_atmosphere_qv',                            &
           std_name          = "",                                              &
           long_name         = "initial specific humidity",                     &
@@ -1804,7 +2123,7 @@
           grid              = palm_grid,                                       &
           intermediate_grid = palm_intermediate,                               &
-          is_profile = (TRIM(mode) == 'profile')                               &
-       )
-       IF (TRIM(mode) == 'profile')  THEN
+          is_profile = (TRIM(ic_mode) == 'profile')                            &
+       )
+       IF (TRIM(ic_mode) == 'profile')  THEN
           output_var_table(9) % grid => scalar_profile_grid
           output_var_table(9) % intermediate_grid => scalar_profile_intermediate
@@ -1872,5 +2191,5 @@
 
        output_var_table(15) = init_nc_var(                                     &
-          name              = 'init_u',                                        &
+          name              = 'init_atmosphere_u',                             &
           std_name          = "",                                              &
           long_name         = "initial wind component in x direction",         &
@@ -1881,7 +2200,7 @@
           grid              = u_initial_grid,                                  &
           intermediate_grid = u_initial_intermediate,                          &
-          is_profile = (TRIM(mode) == 'profile')                               &
-       )
-       IF (TRIM(mode) == 'profile')  THEN
+          is_profile = (TRIM(ic_mode) == 'profile')                            &
+       )
+       IF (TRIM(ic_mode) == 'profile')  THEN
           output_var_table(15) % grid => scalar_profile_grid
           output_var_table(15) % intermediate_grid => scalar_profile_intermediate
@@ -1949,5 +2268,5 @@
 
        output_var_table(21) = init_nc_var(                                     &
-          name              = 'init_v',                                        &
+          name              = 'init_atmosphere_v',                             &
           std_name          = "",                                              &
           long_name         = "initial wind component in y direction",         &
@@ -1958,7 +2277,7 @@
           grid              = v_initial_grid,                                  &
           intermediate_grid = v_initial_intermediate,                          &
-          is_profile = (TRIM(mode) == 'profile')                               &
-       )
-       IF (TRIM(mode) == 'profile')  THEN
+          is_profile = (TRIM(ic_mode) == 'profile')                            &
+       )
+       IF (TRIM(ic_mode) == 'profile')  THEN
           output_var_table(21) % grid => scalar_profile_grid
           output_var_table(21) % intermediate_grid => scalar_profile_intermediate
@@ -2026,5 +2345,5 @@
 
        output_var_table(27) = init_nc_var(                                     &
-          name              = 'init_w',                                        &
+          name              = 'init_atmosphere_w',                             &
           std_name          = "",                                              &
           long_name         = "initial wind component in z direction",         &
@@ -2035,7 +2354,7 @@
           grid              = w_initial_grid,                                  &
           intermediate_grid = w_initial_intermediate,                          &
-          is_profile = (TRIM(mode) == 'profile')                               &
-       )
-       IF (TRIM(mode) == 'profile')  THEN
+          is_profile = (TRIM(ic_mode) == 'profile')                            &
+       )
+       IF (TRIM(ic_mode) == 'profile')  THEN
           output_var_table(27) % grid => w_profile_grid
           output_var_table(27) % intermediate_grid => w_profile_intermediate
@@ -2209,5 +2528,8 @@
           intermediate_grid = palm_intermediate                                &
        )
-
+!
+!------------------------------------------------------------------------------
+! Section 2.2: Idealized large-scale forcings
+!------------------------------------------------------------------------------
        output_var_table(42) = init_nc_var(                                     &
           name              = 'surface_forcing_surface_pressure',              &
@@ -2227,9 +2549,9 @@
           long_name         = "geostrophic wind (u component)",                &
           units             = "m/s",                                           &
-          kind              = "profile",                                       &
-          input_id          = 1,                                               &
-          output_file       = output_file,                                     &
-          grid              = palm_grid,                                       &
-          intermediate_grid = palm_intermediate                                &
+          kind              = "constant scalar profile",                       &
+          input_id          = 1,                                               &
+          output_file       = output_file,                                     &
+          grid              = scalar_profile_grid,                             &
+          intermediate_grid = scalar_profile_intermediate                      &
        )
 
@@ -2239,13 +2561,160 @@
           long_name         = "geostrophic wind (v component)",                &
           units             = "m/s",                                           &
-          kind              = "profile",                                       &
-          input_id          = 1,                                               &
-          output_file       = output_file,                                     &
-          grid              = palm_grid,                                       &
-          intermediate_grid = palm_intermediate                                &
-       )
+          kind              = "constant scalar profile",                       &
+          input_id          = 1,                                               &
+          output_file       = output_file,                                     &
+          grid              = scalar_profile_grid,                             &
+          intermediate_grid = scalar_profile_intermediate                      &
+       )
+
+       output_var_table(45) = init_nc_var(                                     &
+          name              = 'nudging_u',                                     &
+          std_name          = "",                                              &
+          long_name         = "wind component in x direction",                 &
+          units             = "m/s",                                           &
+          kind              = "large-scale scalar forcing",                    &
+          input_id          = 1,                                               &
+          output_file       = output_file,                                     &
+          grid              = scalar_profile_grid,                             &
+          intermediate_grid = scalar_profile_intermediate                      &
+       )
+       output_var_table(45) % to_be_processed = ls_forcing_variables_required
+
+       output_var_table(46) = init_nc_var(                                     &
+          name              = 'nudging_v',                                     &
+          std_name          = "",                                              &
+          long_name         = "wind component in y direction",                 &
+          units             = "m/s",                                           &
+          kind              = "large-scale scalar forcing",                    &
+          input_id          = 1,                                               &
+          output_file       = output_file,                                     &
+          grid              = scalar_profile_grid,                             &
+          intermediate_grid = scalar_profile_intermediate                      &
+       )
+       output_var_table(46) % to_be_processed = ls_forcing_variables_required
+
+       output_var_table(47) = init_nc_var(                                     &
+          name              = 'ls_forcing_sub_w',                              &
+          std_name          = "",                                              &
+          long_name         = "subsidence velocity of w",                      &
+          units             = "m/s",                                           &
+          kind              = "large-scale w forcing",                         &
+          input_id          = 1,                                               &
+          output_file       = output_file,                                     &
+          grid              = w_profile_grid,                                  &
+          intermediate_grid = w_profile_intermediate                           &
+       )
+       output_var_table(47) % to_be_processed = ls_forcing_variables_required
+
+       output_var_table(48) = init_nc_var(                                     &
+          name              = 'nudging_w',                                     &
+          std_name          = "",                                              &
+          long_name         = "wind component in w direction",                 &
+          units             = "m/s",                                           &
+          kind              = "large-scale w forcing",                         &
+          input_id          = 1,                                               &
+          output_file       = output_file,                                     &
+          grid              = w_profile_grid,                                  &
+          intermediate_grid = w_profile_intermediate                           &
+       )
+       output_var_table(48) % to_be_processed = ls_forcing_variables_required
+
+
+       output_var_table(49) = init_nc_var(                                     &
+          name              = 'ls_forcing_adv_pt',                             &
+          std_name          = "",                                              &
+          long_name         = "advection of potential temperature",            &
+          units             = "K/s",                                           &
+          kind              = "large-scale scalar forcing",                    &
+          input_id          = 1,                                               &
+          output_file       = output_file,                                     &
+          grid              = scalar_profile_grid,                             &
+          intermediate_grid = scalar_profile_intermediate                      &
+       )
+       output_var_table(49) % to_be_processed = ls_forcing_variables_required
+
+       output_var_table(50) = init_nc_var(                                     &
+          name              = 'ls_forcing_sub_pt',                             &
+          std_name          = "",                                              &
+          long_name         = "subsidence velocity of potential temperature",  &
+          units             = "K/s",                                           &
+          kind              = "large-scale scalar forcing",                    &
+          input_id          = 1,                                               &
+          output_file       = output_file,                                     &
+          grid              = scalar_profile_grid,                             &
+          intermediate_grid = scalar_profile_intermediate                      &
+       )
+       output_var_table(50) % to_be_processed = ls_forcing_variables_required
+
+       output_var_table(51) = init_nc_var(                                     &
+          name              = 'nudging_pt',                                    &
+          std_name          = "",                                              &
+          long_name         = "potential temperature",                         &
+          units             = "K",                                             &
+          kind              = "large-scale scalar forcing",                    &
+          input_id          = 1,                                               &
+          output_file       = output_file,                                     &
+          grid              = scalar_profile_grid,                             &
+          intermediate_grid = scalar_profile_intermediate                      &
+       )
+       output_var_table(51) % to_be_processed = ls_forcing_variables_required
+
+       output_var_table(52) = init_nc_var(                                     &
+          name              = 'ls_forcing_adv_qv',                             &
+          std_name          = "",                                              &
+          long_name         = "advection of specific humidity",                &
+          units             = "kg/kg/s",                                       &
+          kind              = "large-scale scalar forcing",                    &
+          input_id          = 1,                                               &
+          output_file       = output_file,                                     &
+          grid              = scalar_profile_grid,                             &
+          intermediate_grid = scalar_profile_intermediate                      &
+       )
+       output_var_table(52) % to_be_processed = ls_forcing_variables_required
+
+
+       output_var_table(53) = init_nc_var(                                     &
+          name              = 'ls_forcing_sub_qv',                             &
+          std_name          = "",                                              &
+          long_name         = "subsidence velocity of specific humidity",      &
+          units             = "kg/kg/s",                                       &
+          kind              = "large-scale scalar forcing",                    &
+          input_id          = 1,                                               &
+          output_file       = output_file,                                     &
+          grid              = scalar_profile_grid,                             &
+          intermediate_grid = scalar_profile_intermediate                      &
+       )
+       output_var_table(53) % to_be_processed = ls_forcing_variables_required
+
+       output_var_table(54) = init_nc_var(                                     &
+          name              = 'nudging_qv',                                    &
+          std_name          = "",                                              &
+          long_name         = "specific humidity",                             &
+          units             = "kg/kg",                                         &
+          kind              = "large-scale scalar forcing",                    &
+          input_id          = 1,                                               &
+          output_file       = output_file,                                     &
+          grid              = scalar_profile_grid,                             &
+          intermediate_grid = scalar_profile_intermediate                      &
+       )
+       output_var_table(54) % to_be_processed = ls_forcing_variables_required
+
+       output_var_table(55) = init_nc_var(                                     &
+          name              = 'nudging_tau',                                   &
+          std_name          = "",                                              &
+          long_name         = "nudging relaxation time scale",                 &
+          units             = "s",                                             &
+          kind              = "constant scalar profile",                       &
+          input_id          = 1,                                               &
+          output_file       = output_file,                                     &
+          grid              = scalar_profile_grid,                             &
+          intermediate_grid = scalar_profile_intermediate                      &
+       )
+       output_var_table(55) % to_be_processed = ls_forcing_variables_required
+
 
        ! Attributes shared among all variables
        output_var_table(:) % source = nc_source_text
+
 
     END SUBROUTINE setup_variable_tables
@@ -2260,5 +2729,6 @@
 !------------------------------------------------------------------------------!
     FUNCTION init_nc_var(name, std_name, long_name, units, kind, input_id,     &
-                         grid, intermediate_grid, output_file, is_profile) RESULT(var)
+                         grid, intermediate_grid, output_file, is_profile      &
+             ) RESULT(var)
 
        CHARACTER(LEN=*), INTENT(IN)      ::  name, std_name, long_name, units, kind
@@ -2367,6 +2837,6 @@
           var % task            = "average profile"
 
-       CASE ( 'surface forcing' )
-          var % lod             = 1
+       CASE( 'surface forcing' )
+          var % lod             = -1
           var % ndim            = 3
           var % dimids(3)       = output_file % dimid_time
@@ -2377,6 +2847,6 @@
           var % task            = "interpolate_2d"
 
-       CASE ( 'left scalar', 'right scalar') ! same as right
-          var % lod             = 2
+       CASE( 'left scalar', 'right scalar') ! same as right
+          var % lod             = -1
           var % ndim            = 3
           var % dimids(3)       = output_file % dimid_time
@@ -2389,6 +2859,6 @@
           var % task            = "interpolate_3d"
 
-       CASE ( 'north scalar', 'south scalar') ! same as south
-          var % lod             = 2
+       CASE( 'north scalar', 'south scalar') ! same as south
+          var % lod             = -1
           var % ndim            = 3
           var % dimids(3)       = output_file % dimid_time
@@ -2401,6 +2871,6 @@
           var % task            = "interpolate_3d"
 
-       CASE ( 'top scalar', 'top w' )
-          var % lod             = 2
+       CASE( 'top scalar', 'top w' )
+          var % lod             = -1
           var % ndim            = 3
           var % dimids(3)       = output_file % dimid_time
@@ -2413,6 +2883,6 @@
           var % task            = "interpolate_3d"
 
-       CASE ( 'left u', 'right u' )
-          var % lod             = 2
+       CASE( 'left u', 'right u' )
+          var % lod             = -1
           var % ndim            = 3
           var % dimids(3)       = output_file % dimid_time
@@ -2425,6 +2895,6 @@
           var % task            = "interpolate_3d"
 
-       CASE ( 'north u', 'south u' )
-          var % lod             = 2
+       CASE( 'north u', 'south u' )
+          var % lod             = -1
           var % ndim            = 3
           var % dimids(3)       = output_file % dimid_time    !t
@@ -2437,6 +2907,6 @@
           var % task            = "interpolate_3d"
 
-       CASE ( 'top u' )
-          var % lod             = 2
+       CASE( 'top u' )
+          var % lod             = -1
           var % ndim            = 3
           var % dimids(3)       = output_file % dimid_time    !t
@@ -2449,6 +2919,6 @@
           var % task            = "interpolate_3d"
 
-       CASE ( 'left v', 'right v' )
-          var % lod             = 2
+       CASE( 'left v', 'right v' )
+          var % lod             = -1
           var % ndim            = 3
           var % dimids(3)       = output_file % dimid_time
@@ -2461,6 +2931,6 @@
           var % task            = "interpolate_3d"
 
-       CASE ( 'north v', 'south v' )
-          var % lod             = 2
+       CASE( 'north v', 'south v' )
+          var % lod             = -1
           var % ndim            = 3
           var % dimids(3)       = output_file % dimid_time    !t
@@ -2473,6 +2943,6 @@
           var % task            = "interpolate_3d"
 
-       CASE ( 'top v' )
-          var % lod             = 2
+       CASE( 'top v' )
+          var % lod             = -1
           var % ndim            = 3
           var % dimids(3)       = output_file % dimid_time    !t
@@ -2485,6 +2955,6 @@
           var % task            = "interpolate_3d"
 
-       CASE ( 'left w', 'right w')
-          var % lod             = 2
+       CASE( 'left w', 'right w')
+          var % lod             = -1
           var % ndim            = 3
           var % dimids(3)       = output_file % dimid_time
@@ -2497,6 +2967,6 @@
           var % task            = "interpolate_3d"
 
-       CASE ( 'north w', 'south w' )
-          var % lod             = 2
+       CASE( 'north w', 'south w' )
+          var % lod             = -1
           var % ndim            = 3
           var % dimids(3)       = output_file % dimid_time    !t
@@ -2509,5 +2979,5 @@
           var % task            = "interpolate_3d"
 
-       CASE ( 'time series' )
+       CASE( 'time series' )
           var % lod             = 0
           var % ndim            = 1
@@ -2517,6 +2987,6 @@
           var % task            = "average scalar"
 
-       CASE ( 'profile' )
-          var % lod             = 2
+       CASE( 'constant scalar profile' )
+          var % lod             = -1
           var % ndim            = 2
           var % dimids(2)       = output_file % dimid_time    !t
@@ -2525,5 +2995,25 @@
           var % dimvarids(1)    = output_file % dimvarids_scl(3)
           var % to_be_processed = .TRUE.
-          var % task            = "profile"
+          var % task            = "set profile"
+
+       CASE( 'large-scale scalar forcing' )
+          var % lod             = -1
+          var % ndim            = 2
+          var % dimids(2)       = output_file % dimid_time    !t
+          var % dimids(1)       = output_file % dimids_scl(3) !z
+          var % dimvarids(2)    = output_file % dimvarid_time
+          var % dimvarids(1)    = output_file % dimvarids_scl(3)
+          var % to_be_processed = ls_forcing_variables_required
+          var % task            = "average large-scale profile"
+
+       CASE( 'large-scale w forcing' )
+          var % lod             = -1
+          var % ndim            = 2
+          var % dimids(2)       = output_file % dimid_time    !t
+          var % dimids(1)       = output_file % dimids_vel(3) !z
+          var % dimvarids(2)    = output_file % dimvarid_time
+          var % dimvarids(1)    = output_file % dimvarids_vel(3)
+          var % to_be_processed = ls_forcing_variables_required
+          var % task            = "average large-scale profile"
 
        CASE DEFAULT
@@ -2560,6 +3050,6 @@
 
 
-    SUBROUTINE input_file_list(start_date_string, start_hour, end_hour,        &
-                               step_hour, path, prefix, suffix, file_list)
+    SUBROUTINE get_input_file_list(start_date_string, start_hour, end_hour,        &
+                                   step_hour, path, prefix, suffix, file_list)
 
        CHARACTER (LEN=DATE), INTENT(IN) ::  start_date_string
@@ -2568,22 +3058,21 @@
        CHARACTER(LEN=*), ALLOCATABLE, INTENT(INOUT) ::  file_list(:)
 
-       INTEGER             ::  number_of_files, hour, i
+       INTEGER             ::  number_of_intervals, hour, i
        CHARACTER(LEN=DATE) ::  date_string
 
-       number_of_files = end_hour - start_hour + 1
-
-       ALLOCATE( file_list(number_of_files) )
-
-       DO i = 1, number_of_files
-          hour = start_hour + (i-1) * step_hour
+       number_of_intervals = CEILING( REAL(end_hour - start_hour) / step_hour )
+       ALLOCATE( file_list(number_of_intervals + 1) )
+
+       DO i = 0, number_of_intervals
+          hour = start_hour + i * step_hour
           date_string = add_hours_to(start_date_string, hour)
 
-          file_list(i) = TRIM(path) // TRIM(prefix) // TRIM(date_string) //    &
-                         TRIM(suffix) // '.nc'
-          message = "Set up input file name '" // TRIM(file_list(i)) //"'"
+          file_list(i+1) = TRIM(path) // TRIM(prefix) // TRIM(date_string) //    &
+                           TRIM(suffix) // '.nc'
+          message = "Set up input file name '" // TRIM(file_list(i+1)) //"'"
           CALL report('input_file_list', message)
        END DO
 
-    END SUBROUTINE input_file_list
+    END SUBROUTINE get_input_file_list
 
 
@@ -2607,5 +3096,5 @@
        
        REAL(dp), ALLOCATABLE                       ::  basic_state_pressure(:)
-       TYPE(container), ALLOCATABLE                ::  compute_buffer(:)
+       TYPE(container), ALLOCATABLE                ::  preprocess_buffer(:)
        INTEGER                                     ::  hour, dt
        INTEGER                                     ::  i, j, k
@@ -2617,6 +3106,6 @@
        
        CASE( 'velocities' )
-          ! Allocate a compute puffer with the same number of arrays as the input
-          ALLOCATE( compute_buffer( SIZE(input_buffer) ) )
+          ! Allocate a compute buffer with the same number of arrays as the input
+          ALLOCATE( preprocess_buffer( SIZE(input_buffer) ) )
 
           ! Allocate u and v arrays with scalar dimensions
@@ -2624,6 +3113,6 @@
           ny = SIZE(input_buffer(1) % array, 2)
           nz = SIZE(input_buffer(1) % array, 3)
-          ALLOCATE( compute_buffer(1) % array(nx, ny, nz) ) ! u buffer
-          ALLOCATE( compute_buffer(2) % array(nx, ny, nz) ) ! v buffer
+          ALLOCATE( preprocess_buffer(1) % array(nx, ny, nz) ) ! u buffer
+          ALLOCATE( preprocess_buffer(2) % array(nx, ny, nz) ) ! v buffer
 
  CALL run_control('time', 'alloc')
@@ -2632,23 +3121,36 @@
           CALL centre_velocities( u_face = input_buffer(1) % array,            &
                                   v_face = input_buffer(2) % array,            &
-                                  u_centre = compute_buffer(1) % array,        &
-                                  v_centre = compute_buffer(2) % array )
+                                  u_centre = preprocess_buffer(1) % array,     &
+                                  v_centre = preprocess_buffer(2) % array )
           
-          ! rotate U and V to PALM-4U orientation and overwrite U and V with
-          ! rotated velocities
-          DO k = 1, nz
-          DO j = 2, ny
-          DO i = 2, nx
-             CALL uv2uvrot( urot = compute_buffer(1) % array(i,j,k),           &
-                            vrot = compute_buffer(2) % array(i,j,k),           &
-                            rlat = cosmo_grid % lat(j-1),                      &
-                            rlon = cosmo_grid % lon(i-1),                      &
-                            pollat = phi_cn,                                   &
-                            pollon = lambda_cn,                                &
-                            u = input_buffer(1) % array(i,j,k),                &
-                            v = input_buffer(2) % array(i,j,k) )
-          END DO
-          END DO
-          END DO
+          cfg % rotation_method = 'rotated-pole'
+          SELECT CASE(cfg % rotation_method)
+
+          CASE('rotated-pole')
+             ! rotate U and V to PALM-4U orientation and overwrite U and V with
+             ! rotated velocities
+             DO k = 1, nz
+             DO j = 2, ny
+             DO i = 2, nx
+                CALL uv2uvrot( urot = preprocess_buffer(1) % array(i,j,k),     &
+                               vrot = preprocess_buffer(2) % array(i,j,k),     &
+                               rlat = cosmo_grid % lat(j-1),                   &
+                               rlon = cosmo_grid % lon(i-1),                   &
+                               pollat = phi_cn,                                &
+                               pollon = lambda_cn,                             &
+                               u = input_buffer(1) % array(i,j,k),             &
+                               v = input_buffer(2) % array(i,j,k) )
+             END DO
+             END DO
+             END DO
+
+          CASE DEFAULT
+             message = "Rotation method '" // TRIM(cfg % rotation_method) //   &
+                "' not recognized."
+             CALL abort('preprocess', message)
+
+          END SELECT
+
+          ! set values 
           input_buffer(1) % array(1,:,:) = 0.0_dp
           input_buffer(2) % array(1,:,:) = 0.0_dp
@@ -2659,5 +3161,5 @@
  CALL run_control('time', 'comp')
 
-          DEALLOCATE( compute_buffer )
+          DEALLOCATE( preprocess_buffer )
  CALL run_control('time', 'alloc')
 
Index: palm/trunk/UTIL/inifor/src/inifor.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/inifor.f90	(revision 3178)
+++ palm/trunk/UTIL/inifor/src/inifor.f90	(revision 3182)
@@ -21,4 +21,7 @@
 ! Current revisions:
 ! -----------------
+! Introduced new PALM grid stretching
+! Renamend initial-condition mode variable 'mode' to 'ic_mode'
+! Improved log messages
 ! 
 ! 
@@ -48,8 +51,8 @@
         ONLY:  setup_parameters, setup_grids, setup_variable_tables,           &
                setup_io_groups, fini_grids, fini_variables, fini_io_groups,    &
-               fini_file_lists, preprocess,                                    &
+               fini_file_lists, preprocess, origin_lon, origin_lat,            &
                output_file, io_group_list, output_var_table,                   &
-               cosmo_grid, palm_grid, nx, ny, nz, ug, vg, p0, mode,            &
-               imin, imax, jmin, jmax
+               cosmo_grid, palm_grid, nx, ny, nz, ug, vg, p0, cfg,             &
+               average_imin, average_imax, average_jmin, average_jmax
 
     USE io
@@ -84,10 +87,11 @@
 
     ! Initialize the netCDF output file and define dimensions
-    CALL setup_netcdf_dimensions(output_file, palm_grid)
+    CALL setup_netcdf_dimensions(output_file, palm_grid, cfg % start_date,    &
+                                 origin_lon, origin_lat)
  CALL run_control('time', 'write')
 
     ! Set up the tables containing the input and output variables and set
     ! the corresponding netCDF dimensions for each output variable
-    CALL setup_variable_tables(mode)
+    CALL setup_variable_tables(cfg % ic_mode)
  CALL run_control('time', 'write')
 
@@ -95,5 +99,5 @@
     CALL setup_netcdf_variables(output_file % name, output_var_table)
 
-    CALL setup_io_groups() 
+    CALL setup_io_groups()
  CALL run_control('time', 'init')
 
@@ -118,4 +122,5 @@
  CALL run_control('time', 'comp')
 
+             !TODO: move this assertion into 'preprocess'.
              IF ( .NOT. ALL(input_buffer(:) % is_preprocessed .AND. .TRUE.) )  THEN
                 message = "Input buffers for group '" // TRIM(group % kind) // &
@@ -159,5 +164,6 @@
                       CASE DEFAULT
 
-                          CALL abort("main loop", 'Not a soil variable')
+                          message = "'" // TRIM(output_var % kind) // "' is not a soil variable"
+                          CALL abort("main loop", message)
 
                       END SELECT
@@ -173,5 +179,5 @@
                       ALLOCATE( output_arr( 0:output_var % grid % nx,          &
                                             0:output_var % grid % ny,          &
-                                            0:output_var % grid % nz ) )
+                                            1:output_var % grid % nz ) )
 
  CALL run_control('time', 'alloc')
@@ -187,5 +193,5 @@
                       ALLOCATE( output_arr( 0:output_var % grid % nx,          &
                                             0:output_var % grid % ny,          &
-                                            0:output_var % grid % nz ) )
+                                            1:output_var % grid % nz ) )
  CALL run_control('time', 'alloc')
                       
@@ -193,5 +199,6 @@
                       CALL average_profile(                                    &
                          input_buffer(output_var % input_id) % array(:,:,:),   &
-                         output_arr(:,:,:), imin, imax, jmin, jmax,            &
+                         output_arr(:,:,:), average_imin, average_imax,        &
+                         average_jmin, average_jmax,                           &
                          output_var % intermediate_grid,                       &
                          output_var % grid)
@@ -205,7 +212,7 @@
  CALL run_control('time', 'comp')
 
-                   CASE ( 'profile' )
+                   CASE ( 'set profile' )
                       
-                      ALLOCATE( output_arr( 1, 1, 0:nz ) )
+                      ALLOCATE( output_arr( 1, 1, 1:nz ) )
  CALL run_control('time', 'alloc')
 
@@ -217,4 +224,7 @@
                       CASE('ls_forcing_vg')
                           output_arr(1, 1, :) = vg
+
+                      CASE('nudging_tau')
+                          output_arr(1, 1, :) = NUDGING_TAU
 
                       CASE DEFAULT
@@ -225,4 +235,10 @@
                       END SELECT
  CALL run_control('time', 'comp')
+
+                   CASE('average large-scale profile')
+                      message = "Averaging of large-scale forcing profiles " //&
+                                "has not been implemented, yet."
+                      CALL abort('main loop', message)
+                      !ALLOCATE( output_arr( 1, 1, 1:nz ) )
 
                    CASE DEFAULT
@@ -269,5 +285,5 @@
        ELSE 
 
-          message = "Skipping IO group '" // TRIM(group % kind) // "'"
+          message = "Skipping IO group " // TRIM(str(igroup)) // " '" // TRIM(group % kind) // "'"
           IF ( ALLOCATED(group % in_var_list) )  THEN
               message = TRIM(message) // " with input variable '" //           &
@@ -291,5 +307,5 @@
  CALL run_control('report', 'void')
 
-    message = "Finished writing forcing file '" // TRIM(output_file % name) // &
+    message = "Finished writing dynamic driver '" // TRIM(output_file % name) // &
               "' successfully."
     CALL report('main loop', message)
Index: palm/trunk/UTIL/inifor/src/io.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/io.f90	(revision 3178)
+++ palm/trunk/UTIL/inifor/src/io.f90	(revision 3182)
@@ -21,6 +21,17 @@
 ! Current revisions:
 ! -----------------
+! Introduced new PALM grid stretching
+! Updated variable names and metadata for PIDS v1.9 compatibility
+! Improved handling of the start date string
+! Better compatibility with older Intel compilers:
+! - avoiding implicit array allocation with new get_netcdf_variable()
+!   subroutine instead of function
+! Improved command line interface:
+! - Added configuration validation
+! - New options to configure input file prefixes
+! - GNU-style short and long option names
+! - Added version and copyright output
 ! 
-! 
+!
 ! Former revisions:
 ! -----------------
@@ -43,13 +54,42 @@
     USE control
     USE defs,                                                                  &
-        ONLY:  DATE, SNAME, PATH, PI, dp, TO_RADIANS, TO_DEGREES, VERSION
+        ONLY:  DATE, SNAME, PATH, PI, dp, hp, TO_RADIANS, TO_DEGREES, VERSION
     USE netcdf
     USE types
     USE util,                                                                  &
-        ONLY:  reverse, str
+        ONLY:  reverse, str, real_to_str
 
     IMPLICIT NONE
 
+    INTERFACE get_netcdf_variable
+        MODULE PROCEDURE get_netcdf_variable_int
+        MODULE PROCEDURE get_netcdf_variable_real
+    END INTERFACE get_netcdf_variable
+
+    PRIVATE ::  get_netcdf_variable_int, get_netcdf_variable_real
+
  CONTAINS
+
+    SUBROUTINE get_netcdf_variable_int(in_file, in_var, buffer)
+
+       CHARACTER(LEN=PATH), INTENT(IN)         ::  in_file
+       TYPE(nc_var), INTENT(INOUT)             ::  in_var
+       INTEGER(hp), ALLOCATABLE, INTENT(INOUT) ::  buffer(:,:,:)
+
+       INCLUDE 'get_netcdf_variable.inc'
+
+    END SUBROUTINE get_netcdf_variable_int
+
+
+    SUBROUTINE get_netcdf_variable_real(in_file, in_var, buffer)
+
+       CHARACTER(LEN=PATH), INTENT(IN)      ::  in_file
+       TYPE(nc_var), INTENT(INOUT)          ::  in_var
+       REAL(dp), ALLOCATABLE, INTENT(INOUT) ::  buffer(:,:,:)
+
+       INCLUDE 'get_netcdf_variable.inc'
+
+    END SUBROUTINE get_netcdf_variable_real
+
 
     SUBROUTINE netcdf_define_variable(var, ncid)
@@ -59,8 +99,9 @@
 
         CALL check(nf90_def_var(ncid, var % name, NF90_FLOAT,       var % dimids(1:var % ndim), var % varid))
-        CALL check(nf90_put_att(ncid, var % varid, "standard_name", var % standard_name))
         CALL check(nf90_put_att(ncid, var % varid, "long_name",     var % long_name))
         CALL check(nf90_put_att(ncid, var % varid, "units",         var % units))
-        CALL check(nf90_put_att(ncid, var % varid, "lod",           var % lod))
+        IF ( var % lod .GE. 0 )  THEN
+           CALL check(nf90_put_att(ncid, var % varid, "lod",           var % lod))
+        END IF 
         CALL check(nf90_put_att(ncid, var % varid, "source",        var % source))
         CALL check(nf90_put_att(ncid, var % varid, "_FillValue",    NF90_FILL_REAL))
@@ -94,16 +135,10 @@
 !> parameters for the PALM-4U computational grid.
 !------------------------------------------------------------------------------!
-    SUBROUTINE parse_command_line_arguments( start_date, hhl_file,             &
-       soiltyp_file, static_driver_file, input_path, output_file,              &
-       namelist_file, ug, vg, p0, z0, mode )
-
-       CHARACTER(LEN=PATH), INTENT(INOUT)  ::  hhl_file, soiltyp_file,         &
-           static_driver_file, input_path, output_file, namelist_file
-       CHARACTER(LEN=SNAME), INTENT(INOUT) ::  mode
-       REAL(dp), INTENT(INOUT)             ::  ug, vg, p0, z0
-       CHARACTER(LEN=DATE), INTENT(INOUT)  ::  start_date
-
-       CHARACTER(LEN=PATH)     ::  option, arg
-       INTEGER                 ::  arg_count, i
+    SUBROUTINE parse_command_line_arguments( cfg )
+
+       TYPE(inifor_config), INTENT(INOUT) ::  cfg
+
+       CHARACTER(LEN=PATH)                ::  option, arg
+       INTEGER                            ::  arg_count, i
 
        arg_count = COMMAND_ARGUMENT_COUNT()
@@ -111,92 +146,121 @@
 
           ! Every option should have an argument.
-          IF ( MOD(arg_count, 2) .NE. 0 )  THEN
-             message = "Syntax error in command line."
-             CALL abort('parse_command_line_arguments', message)
-          END IF
+          !IF ( MOD(arg_count, 2) .NE. 0 )  THEN
+          !   message = "Syntax error in command line."
+          !   CALL abort('parse_command_line_arguments', message)
+          !END IF
           
           message = "The -clon and -clat command line options are depricated. " // &
              "Please remove them form your inifor command and specify the " // &
              "location of the PALM-4U origin either" // NEW_LINE(' ') // &
-             "   - by setting the namelist parameters 'origin_lon' and 'origin_lat, or'" // NEW_LINE(' ') // &
+             "   - by setting the namelist parameters 'longitude' and 'latitude', or" // NEW_LINE(' ') // &
              "   - by providing a static driver netCDF file via the -static command-line option."
 
-          ! Loop through option/argument pairs.
-          DO i = 1, arg_count, 2
+          i = 1
+          DO WHILE (i .LE. arg_count)
 
              CALL GET_COMMAND_ARGUMENT( i, option )
-             CALL GET_COMMAND_ARGUMENT( i+1, arg )
 
              SELECT CASE( TRIM(option) )
 
-             CASE( '-date' )
-                start_date = TRIM(arg)
+             CASE( '-date', '-d', '--date' )
+                CALL get_option_argument( i, arg )
+                cfg % start_date = TRIM(arg)
 
              ! Elevation of the PALM-4U domain above sea level
-             CASE( '-z0' )
-                READ(arg, *) z0
+             CASE( '-z0', '-z', '--elevation' )
+                CALL get_option_argument( i, arg )
+                READ(arg, *) cfg % z0
 
              ! surface pressure, at z0
-             CASE( '-p0' )
-                READ(arg, *) p0
-
-             ! surface pressure, at z0
-             CASE( '-ug' )
-                READ(arg, *) ug
-
-             ! surface pressure, at z0
-             CASE( '-vg' )
-                READ(arg, *) vg
-
-             ! Domain centre geographical longitude
-             CASE( '-clon' )
+             CASE( '-p0', '-r', '--surface-pressure' )
+                CALL get_option_argument( i, arg )
+                READ(arg, *) cfg % p0
+
+             ! geostrophic wind in x direction
+             CASE( '-ug', '-u', '--geostrophic-u' )
+                CALL get_option_argument( i, arg )
+                READ(arg, *) cfg % ug
+
+             ! geostrophic wind in y direction
+             CASE( '-vg', '-v', '--geostrophic-v' )
+                CALL get_option_argument( i, arg )
+                READ(arg, *) cfg % vg
+
+             ! domain centre geographical longitude and latitude
+             CASE( '-clon', '-clat' )
                 CALL abort('parse_command_line_arguments', message)          
                 !READ(arg, *) lambda_cg
                 !lambda_cg = lambda_cg * TO_RADIANS
-
-             ! Domain centre geographical latitude
-             CASE( '-clat' )
-                CALL abort('parse_command_line_arguments', message)          
                 !READ(arg, *) phi_cg
                 !phi_cg = phi_cg * TO_RADIANS
 
-             CASE( '-path' )
-                 input_path = TRIM(arg)
-
-             CASE( '-hhl' )
-                 hhl_file = TRIM(arg)
-
-             CASE( '-static' )
-                 static_driver_file = TRIM(arg)
-
-             CASE( '-soil' )
-                 soiltyp_file = TRIM(arg)
-
-             CASE( '-o' )
-                output_file = TRIM(arg)
-
-             CASE( '-n' )
-                namelist_file = TRIM(arg)
-
-             ! Initialization mode: 'profile' / 'volume'
-             CASE( '-mode' )
-                mode = TRIM(arg)
-
-                SELECT CASE( TRIM(mode) )
-
-                CASE( 'profile' )
-
-                CASE DEFAULT
-                   message = "Mode '" // TRIM(mode) // "' is not supported. " //&
-                             "Currently, '-mode profile' is the only supported option. " //&
-                             "Select this one or omit the -mode option entirely."
-                   CALL abort( 'parse_command_line_arguments', message ) 
-                END SELECT
+             CASE( '-path', '-p', '--path' )
+                CALL get_option_argument( i, arg )
+                 cfg % input_path = TRIM(arg)
+
+             CASE( '-hhl', '-l', '--hhl-file' )
+                CALL get_option_argument( i, arg )
+                 cfg % hhl_file = TRIM(arg)
+
+             CASE( '-static', '-t', '--static-driver' )
+                CALL get_option_argument( i, arg )
+                 cfg % static_driver_file = TRIM(arg)
+
+             CASE( '-soil', '-s', '--soil-file')
+                CALL get_option_argument( i, arg )
+                 cfg % soiltyp_file = TRIM(arg)
+
+             CASE( '--flow-prefix')
+                CALL get_option_argument( i, arg )
+                 cfg % flow_prefix = TRIM(arg)
+
+             CASE( '--radiation-prefix')
+                CALL get_option_argument( i, arg )
+                 cfg % radiation_prefix = TRIM(arg)
+
+             CASE( '--soil-prefix')
+                CALL get_option_argument( i, arg )
+                 cfg % soil_prefix = TRIM(arg)
+
+             CASE( '--soilmoisture-prefix')
+                CALL get_option_argument( i, arg )
+                 cfg % soilmoisture_prefix = TRIM(arg)
+
+             CASE( '-o', '--output' )
+                CALL get_option_argument( i, arg )
+                cfg % output_file = TRIM(arg)
+
+             CASE( '-n', '--namelist' )
+                CALL get_option_argument( i, arg )
+                cfg % namelist_file = TRIM(arg)
+
+             ! initial condition mode: 'profile' / 'volume'
+             CASE( '-mode', '-i', '--init-mode' )
+                CALL get_option_argument( i, arg )
+                cfg % ic_mode = TRIM(arg)
+
+             ! boundary conditions / forcing mode: 'ideal' / 'real'
+             CASE( '-f', '--forcing-mode' )
+                CALL get_option_argument( i, arg )
+                cfg % bc_mode = TRIM(arg)
+
+             CASE( '--version' )
+                CALL print_version()
+                STOP
+
+             CASE( '--help' )
+                CALL print_version()
+                PRINT *, ""
+                PRINT *, "For a list of command-line options have a look at the README file."
+                STOP
 
              CASE DEFAULT
-                message = "unknown option '" // TRIM(option(2:)) // "'."
+                message = "unknown option '" // TRIM(option) // "'."
                 CALL abort('parse_command_line_arguments', message)
 
              END SELECT
+
+             i = i + 1
 
           END DO
@@ -210,4 +274,75 @@
 
    END SUBROUTINE parse_command_line_arguments
+
+   
+   SUBROUTINE get_option_argument(i, arg)
+      CHARACTER(LEN=PATH), INTENT(INOUT) ::  arg
+      INTEGER, INTENT(INOUT)             ::  i
+
+      i = i + 1
+      CALL GET_COMMAND_ARGUMENT(i, arg)
+
+   END SUBROUTINE
+
+
+   SUBROUTINE validate_config(cfg)
+      TYPE(inifor_config), INTENT(IN) ::  cfg
+      LOGICAL                         ::  all_files_present
+
+      all_files_present = .TRUE.
+      all_files_present = all_files_present .AND. file_present(cfg % hhl_file)
+      all_files_present = all_files_present .AND. file_present(cfg % namelist_file)
+      all_files_present = all_files_present .AND. file_present(cfg % output_file)
+      all_files_present = all_files_present .AND. file_present(cfg % soiltyp_file)
+
+      ! Only check optional static driver file name, if it has been given.
+      IF (TRIM(cfg % static_driver_file) .NE. '')  THEN
+         all_files_present = all_files_present .AND. file_present(cfg % static_driver_file)
+      END IF
+
+      IF (.NOT. all_files_present)  THEN
+         message = "INIFOR configuration invalid; some input files are missing."
+         CALL abort( 'validate_config', message ) 
+      END IF
+      
+      
+      SELECT CASE( TRIM(cfg % ic_mode) )
+      CASE( 'profile', 'volume')
+      CASE DEFAULT
+         message = "Initialization mode '" // TRIM(cfg % ic_mode) //&
+                   "' is not supported. " //&
+                   "Please select either 'profile' or 'volume', " //&
+                   "or omit the -i/--init-mode/-mode option entirely, which corresponds "//&
+                   "to the latter."
+         CALL abort( 'validate_config', message ) 
+      END SELECT
+
+
+      SELECT CASE( TRIM(cfg % bc_mode) )
+      CASE( 'real', 'ideal')
+      CASE DEFAULT
+         message = "Forcing mode '" // TRIM(cfg % bc_mode) //& 
+                   "' is not supported. " //&
+                   "Please select either 'real' or 'ideal', " //&
+                   "or omit the -f/--forcing-mode option entirely, which corresponds "//&
+                   "to the latter."
+         CALL abort( 'validate_config', message ) 
+      END SELECT
+
+
+   END SUBROUTINE validate_config
+
+
+   LOGICAL FUNCTION file_present(filename)
+      CHARACTER(LEN=PATH), INTENT(IN) ::  filename
+
+      INQUIRE(FILE=filename, EXIST=file_present)
+
+      IF (.NOT. file_present)  THEN
+         message = "The given file '" // "' does not exist."
+         CALL report('file_present', message)
+      END IF
+
+   END FUNCTION file_present
 
 
@@ -222,15 +357,29 @@
 !> writes the actual data.
 !------------------------------------------------------------------------------!
-    SUBROUTINE setup_netcdf_dimensions(output_file, palm_grid)
+   SUBROUTINE setup_netcdf_dimensions(output_file, palm_grid,                  &
+                                      start_date_string, origin_lon, origin_lat)
 
        TYPE(nc_file), INTENT(INOUT)      ::  output_file
        TYPE(grid_definition), INTENT(IN) ::  palm_grid
-
-       CHARACTER (LEN=SNAME) ::  date
+       CHARACTER (LEN=DATE), INTENT(IN)  ::  start_date_string
+       REAL(dp), INTENT(IN)              ::  origin_lon, origin_lat
+
+       CHARACTER (LEN=8)     ::  date_string
+       CHARACTER (LEN=10)    ::  time_string
+       CHARACTER (LEN=5)     ::  zone_string
+       CHARACTER (LEN=SNAME) ::  history_string
        INTEGER               ::  ncid, nx, ny, nz, nt, dimids(3), dimvarids(3)
        REAL(dp)              ::  z0
 
+       message = "Initializing PALM-4U dynamic driver file '" //               &
+                 TRIM(output_file % name) // "' and setting up dimensions."
+       CALL report('setup_netcdf_dimensions', message)
+
        ! Create the NetCDF file. NF90_CLOBBER selects overwrite mode.
+#if defined( __netcdf4 )
        CALL check(nf90_create(TRIM(output_file % name), OR(NF90_CLOBBER, NF90_HDF5), ncid))
+#else
+       CALL check(nf90_create(TRIM(output_file % name), NF90_CLOBBER, ncid))
+#endif
 
 !
@@ -238,13 +387,18 @@
 !- Section 1: Write global NetCDF attributes
 !------------------------------------------------------------------------------
-       CALL date_and_time(date)
+       CALL date_and_time(DATE=date_string, TIME=time_string, ZONE=zone_string)
+       history_string =                                                        &
+           'Created on '// date_string      //                                 &
+           ' at '       // time_string(1:2) // ':' // time_string(3:4) //      &
+           ' (UTC'      // zone_string // ')'
+
        CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'title',          'PALM input file for scenario ...'))
        CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'institution',    'Deutscher Wetterdienst, Offenbach'))
        CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'author',         'Eckhard Kadasch, eckhard.kadasch@dwd.de'))
-       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'history',        'Created on '//date))
+       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'history',        TRIM(history_string)))
        CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'references',     '--'))
        CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'comment',        '--'))
-       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'origin_lat',     '--'))
-       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'origin_lon',     '--'))
+       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'origin_lat',     TRIM(real_to_str(origin_lat*TO_DEGREES, '(F18.13)'))))
+       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'origin_lon',     TRIM(real_to_str(origin_lon*TO_DEGREES, '(F18.13)'))))
        CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'inifor_version', TRIM(VERSION)))
        CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'palm_version',   '--'))
@@ -267,5 +421,5 @@
           CALL check( nf90_def_dim(ncid, "x", nx+1, dimids(1)) )
           CALL check( nf90_def_dim(ncid, "y", ny+1, dimids(2)) )
-          CALL check( nf90_def_dim(ncid, "z", nz+1, dimids(3)) )
+          CALL check( nf90_def_dim(ncid, "z", nz, dimids(3)) )
           output_file % dimids_scl = dimids ! save dimids for later
 
@@ -285,9 +439,9 @@
 
        ! overwrite third dimid with the one of depth
-       CALL check(nf90_def_dim(ncid, "depth", SIZE(palm_grid % depths), dimids(3)) )
+       CALL check(nf90_def_dim(ncid, "zsoil", SIZE(palm_grid % depths), dimids(3)) )
        output_file % dimids_soil = dimids ! save dimids for later
 
        ! overwrite third dimvarid with the one of depth
-       CALL check(nf90_def_var(ncid, "depth", NF90_FLOAT, output_file % dimids_soil(3), dimvarids(3)))
+       CALL check(nf90_def_var(ncid, "zsoil", NF90_FLOAT, output_file % dimids_soil(3), dimvarids(3)))
        CALL check(nf90_put_att(ncid, dimvarids(3), "standard_name", "depth_below_land"))
        CALL check(nf90_put_att(ncid, dimvarids(3), "positive", "down"))
@@ -301,5 +455,5 @@
           CALL check(nf90_def_dim(ncid, "xu", nx, dimids(1)) )
           CALL check(nf90_def_dim(ncid, "yv", ny, dimids(2)) )
-          CALL check(nf90_def_dim(ncid, "zw", nz, dimids(3)) )
+          CALL check(nf90_def_dim(ncid, "zw", nz-1, dimids(3)) )
        output_file % dimids_vel = dimids ! save dimids for later
 
@@ -328,5 +482,6 @@
        CALL check(nf90_put_att(ncid, output_file % dimvarid_time, "standard_name", "time"))
        CALL check(nf90_put_att(ncid, output_file % dimvarid_time, "long_name", "time"))
-       CALL check(nf90_put_att(ncid, output_file % dimvarid_time, "units", "seconds since..."))
+       CALL check(nf90_put_att(ncid, output_file % dimvarid_time, "units",     &
+                               "seconds since " // start_date_string // " UTC"))
 
        CALL check(nf90_enddef(ncid))
@@ -363,5 +518,5 @@
        INTEGER                              ::  i, ncid
 
-       message = "Initializing PALM-4U forcing file '" // TRIM(filename) // "'."
+       message = "Defining variables in dynamic driver '" // TRIM(filename) // "'."
        CALL report('setup_netcdf_variables', message)
 
@@ -374,5 +529,5 @@
 
           IF ( var % to_be_processed )  THEN
-             message = "Defining variable #" // TRIM(str(i)) // " '" // TRIM(var%name) // "'."
+             message = "  variable #" // TRIM(str(i)) // " '" // TRIM(var%name) // "'."
              CALL report('setup_netcdf_variables', message)
 
@@ -386,5 +541,5 @@
        CALL check(nf90_close(ncid))
 
-       message = "Forcing file '" // TRIM(filename) // "' initialized successfully."
+       message = "Dynamic driver '" // TRIM(filename) // "' initialized successfully."
        CALL report('setup_netcdf_variables', message)
 
@@ -447,5 +602,5 @@
 
           input_var => group % in_var_list(1)
-          buffer(buf_id) % array = get_netcdf_variable( input_file, input_var )  
+          CALL get_netcdf_variable(input_file, input_var, buffer(buf_id) % array)
           CALL report('read_input_variables', "Read accumulated " // TRIM(group % in_var_list(1) % name)) 
 
@@ -472,5 +627,5 @@
              END IF
 
-             buffer(ivar) % array = get_netcdf_variable( input_file, input_var )  
+             CALL get_netcdf_variable(input_file, input_var, buffer(ivar) % array)
 
              IF ( input_var % is_upside_down )  CALL reverse(buffer(ivar) % array)
@@ -545,4 +700,5 @@
 
           CALL check(nf90_get_att(ncid, NF90_GLOBAL, TRIM(attribute), attribute_value))
+          CALL check(nf90_close(ncid))
 
        ELSE
@@ -555,90 +711,4 @@
 
     END FUNCTION get_netcdf_attribute
-
-
-
-    FUNCTION get_netcdf_variable(in_file, in_var) RESULT(buffer)
-
-       CHARACTER(LEN=PATH), INTENT(IN)      ::  in_file
-       TYPE(nc_var), INTENT(INOUT)          ::  in_var
-       REAL(dp), ALLOCATABLE                ::  buffer(:,:,:)
-       INTEGER                              ::  i, ncid, start(3)
-
-
-       ! Read in_var NetCDF attributes
-       IF ( nf90_open( TRIM(in_file), NF90_NOWRITE, ncid ) .EQ. NF90_NOERR .AND. &
-            nf90_inq_varid( ncid, in_var % name, in_var % varid ) .EQ. NF90_NOERR )  THEN
-
-          CALL check(nf90_get_att(ncid, in_var % varid, "long_name", in_var % long_name))
-          CALL check(nf90_get_att(ncid, in_var % varid, "units", in_var % units))
-
-          ! Read in_var NetCDF dimensions
-          CALL check(nf90_inquire_variable( ncid, in_var % varid,              &
-                                            ndims  = in_var % ndim,            &
-                                            dimids = in_var % dimids ))
-                                        
-          DO i = 1, in_var % ndim
-             CALL check(nf90_inquire_dimension( ncid, in_var % dimids(i),      &
-                                                name = in_var % dimname(i),    &
-                                                len  = in_var % dimlen(i) ))
-          END DO
-
-          start = (/ 1, 1, 1 /)
-          IF ( TRIM(in_var % name) .EQ. 'T_SO' )  THEN
-             ! Skip depth = 0.0 for T_SO and reduce number of depths from 9 to 8
-             in_var % dimlen(3) = in_var % dimlen(3) - 1
-
-             ! Start reading from second level, e.g. depth = 0.005 instead of 0.0
-             start(3) = 2
-          END IF
-
-          SELECT CASE(in_var % ndim)
-
-          CASE (2)
-
-             ALLOCATE( buffer( in_var % dimlen(1),                             &
-                               in_var % dimlen(2),                             &
-                               1 ) )
-
-          CASE (3)
-
-             ALLOCATE( buffer( in_var % dimlen(1),                             &
-                               in_var % dimlen(2),                             &
-                               in_var % dimlen(3) ) )
-          CASE (4)
-
-             ALLOCATE( buffer( in_var % dimlen(1),                             &
-                               in_var % dimlen(2),                             &
-                               in_var % dimlen(3) ) )
-          CASE DEFAULT
-
-             message = "Failed reading NetCDF variable " //                    &
-                TRIM(in_var % name) // " with " // TRIM(str(in_var%ndim)) //   &
-                " dimensions because only two- and and three-dimensional" //   &
-                " variables are supported."
-             CALL abort('get_netcdf_variable', message) 
-
-          END SELECT
- CALL run_control('time', 'alloc')
-          
-          ! TODO: Check for matching dimensions of buffer and var
-          CALL check(nf90_get_var( ncid, in_var % varid, buffer,               &
-                                   start = start,                              &
-                                   count = in_var % dimlen(1:3) ) )
-
- CALL run_control('time', 'read')
-       ELSE
-
-          message = "Failed to read '" // TRIM(in_var % name) // &
-             "' from file '" // TRIM(in_file) // "'."
-          CALL report('get_netcdf_variable', message)
-
-       END IF
-
-       CALL check(nf90_close(ncid))
-
- CALL run_control('time', 'read')
-
-    END FUNCTION get_netcdf_variable
 
 
@@ -657,9 +727,6 @@
 
        ! Skip time dimension for output
-       IF ( var_is_time_dependent )  THEN
-          ndim = var % ndim - 1
-       ELSE 
-          ndim = var % ndim
-       END IF
+       ndim = var % ndim
+       IF ( var_is_time_dependent )  ndim = var % ndim - 1
 
        start(:)      = (/1,1,1,1/)
@@ -733,9 +800,14 @@
                                    start=start(1:ndim+1) ) )
 
-       CASE ( 'profile' )
+       CASE ( 'constant scalar profile' )
 
           CALL check(nf90_put_var( ncid, var%varid, array(1,1,:),              &
                                    start=start(1:ndim+1),                      &
                                    count=count(1:ndim) ) )
+
+       CASE ( 'large-scale scalar forcing', 'large-scale w forcing' )
+
+           message = "Doing nothing in terms of writing large-scale forings."
+           CALL report('update_output', message)
 
        CASE DEFAULT
Index: palm/trunk/UTIL/inifor/src/transform.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/transform.f90	(revision 3178)
+++ palm/trunk/UTIL/inifor/src/transform.f90	(revision 3182)
@@ -21,4 +21,7 @@
 ! Current revisions:
 ! -----------------
+! Introduced new PALM grid stretching
+! Removed unnecessary subroutine parameters
+! Renamed kcur to k_intermediate
 ! 
 ! 
@@ -80,15 +83,13 @@
        TYPE(grid_definition), INTENT(IN) ::  outgrid
        REAL(dp), INTENT(IN)              ::  in_arr(0:,0:,0:)
-       REAL(dp), INTENT(OUT)             ::  out_arr(0:,0:,0:)
-
-       INTEGER :: i, j, k, l, nx, ny, nz
-
-       nx = UBOUND(out_arr, 1)
-       ny = UBOUND(out_arr, 2)
+       REAL(dp), INTENT(OUT)             ::  out_arr(0:,0:,:)
+
+       INTEGER :: i, j, k, l, nz
+
        nz = UBOUND(out_arr, 3)
 
-       DO j = 0, ny
-       DO i = 0, nx
-       DO k = nz, 0, -1
+       DO j = LBOUND(out_arr, 2), UBOUND(out_arr, 2)
+       DO i = LBOUND(out_arr, 1), UBOUND(out_arr, 1)
+       DO k = nz, LBOUND(out_arr, 3), -1
 
           ! TODO: Remove IF clause and extrapolate based on a critical vertical
@@ -101,6 +102,6 @@
              out_arr(i,j,k) = 0.0_dp
              DO l = 1, 2
-                out_arr(i,j,k) = out_arr(i,j,k) +                                 &
-                    outgrid % w_verti(i,j,k,l) *                                  &
+                out_arr(i,j,k) = out_arr(i,j,k) +                              &
+                    outgrid % w_verti(i,j,k,l) *                               &
                     in_arr(i,j,outgrid % kk(i,j,k, l) )
              END DO
@@ -139,7 +140,7 @@
     ! I index 0-based for the indices of the outvar to be consistent with the
     ! outgrid indices and interpolation weights.
-       TYPE(grid_definition), INTENT(IN) ::  outgrid
-       REAL(dp), INTENT(IN)              ::  invar(0:,0:,0:)
-       REAL(dp), INTENT(OUT)             ::  outvar(0:,0:,0:)
+       TYPE(grid_definition), INTENT(IN)  ::  outgrid
+       REAL(dp), INTENT(IN)               ::  invar(0:,0:,0:)
+       REAL(dp), INTENT(OUT)              ::  outvar(0:,0:,0:)
        TYPE(nc_var), INTENT(IN), OPTIONAL ::  ncvar
 
@@ -413,4 +414,5 @@
 
     END SUBROUTINE rotate_to_cosmo
+       
 
 
@@ -427,6 +429,6 @@
 !>                     -------------
 !>           jj, lat
-!>              ^      j
-!>              |       \          i
+!>              ^        j
+!>              |         \          i
 !>  jj(i,j,2/3) + ... 2 ---\--------/------ 3
 !>              |     | ^   \      /        |
@@ -459,10 +461,11 @@
 !> 
 !------------------------------------------------------------------------------!
-    SUBROUTINE find_horizontal_neighbours(cosmo_lat, cosmo_lon, cosmo_dxi,     &
-       cosmo_dyi, palm_clat, palm_clon, palm_ii, palm_jj)
+    SUBROUTINE find_horizontal_neighbours(cosmo_lat, cosmo_lon,                &
+                                          palm_clat, palm_clon,                &
+                                          palm_ii, palm_jj)
 
        REAL(dp), DIMENSION(0:), INTENT(IN)        ::  cosmo_lat, cosmo_lon
        REAL(dp), DIMENSION(0:,0:), INTENT(IN)     ::  palm_clat, palm_clon
-       REAL(dp), INTENT(IN)                       ::  cosmo_dxi, cosmo_dyi
+       REAL(dp)                                   ::  cosmo_dxi, cosmo_dyi
        INTEGER, DIMENSION(0:,0:,1:), INTENT(OUT)  ::  palm_ii, palm_jj
 
@@ -472,4 +475,6 @@
        lon0 = cosmo_lon(0)
        lat0 = cosmo_lat(0)
+       cosmo_dxi = 1.0_dp / (cosmo_lon(1) - cosmo_lon(0))
+       cosmo_dyi = 1.0_dp / (cosmo_lat(1) - cosmo_lat(0))
 
        DO j = 0, UBOUND(palm_clon, 2)!palm_grid % ny
@@ -508,5 +513,5 @@
        TYPE(grid_definition), INTENT(IN)    ::  palm_intermediate
 
-       INTEGER  ::  i, j, k, nx, ny, nz, nlev, kcur
+       INTEGER  ::  i, j, k, nx, ny, nz, nlev, k_intermediate
        LOGICAL  ::  point_is_below_grid, point_is_above_grid,                  &
                     point_is_in_current_cell
@@ -523,5 +528,5 @@
        DO j = 0, ny
 
-          kcur = 0
+          k_intermediate = 0
 
           column_base = palm_intermediate % h(i,j,0)
@@ -532,11 +537,11 @@
           ! cell, or above column_top. Keep increasing current cell index until
           ! the current cell overlaps with the current_height.
-          DO k = 0, nz
+          DO k = 1, nz
 
              ! Memorize the top and bottom boundaries of the coarse cell and the
              ! current height within it
              current_height = palm_grid % z(k) + palm_grid % z0
-             h_top    = palm_intermediate % h(i,j,kcur+1)
-             h_bottom = palm_intermediate % h(i,j,kcur)
+             h_top    = palm_intermediate % h(i,j,k_intermediate+1)
+             h_bottom = palm_intermediate % h(i,j,k_intermediate)
 
              point_is_above_grid = (current_height > column_top) !22000m, very unlikely
@@ -556,4 +561,7 @@
                 palm_grid % w_verti(i,j,k,1:2) = - 2.0_dp
 
+                message = "PALM-4U grid extends above COSMO-DE model top."
+                CALL abort('find_vertical_neighbours_and_weights', message)
+
              ELSE IF (point_is_below_grid)  THEN
 
@@ -564,9 +572,9 @@
                 ! cycle through intermediate levels until current
                 ! intermediate-grid cell overlaps with current_height
-                DO WHILE (.NOT. point_is_in_current_cell .AND. kcur <= nlev-1)
-                   kcur = kcur + 1
-
-                   h_top    = palm_intermediate % h(i,j,kcur+1)
-                   h_bottom = palm_intermediate % h(i,j,kcur)
+                DO WHILE (.NOT. point_is_in_current_cell .AND. k_intermediate <= nlev-1)
+                   k_intermediate = k_intermediate + 1
+
+                   h_top    = palm_intermediate % h(i,j,k_intermediate+1)
+                   h_bottom = palm_intermediate % h(i,j,k_intermediate)
                    point_is_in_current_cell = (                                &
                       current_height >= h_bottom .AND.                         &
@@ -575,13 +583,14 @@
                 END DO
 
-                ! kcur = 48 indicates the last section (indices 48 and 49), i.e.
-                ! kcur = 49 is not the beginning of a valid cell.
-                IF (kcur > nlev-1)  THEN
-                   message = "Index " // TRIM(str(kcur)) // " is above intermediate grid range."
+                ! k_intermediate = 48 indicates the last section (indices 48 and 49), i.e.
+                ! k_intermediate = 49 is not the beginning of a valid cell.
+                IF (k_intermediate > nlev-1)  THEN
+                   message = "Index " // TRIM(str(k_intermediate)) //          &
+                             " is above intermediate grid range."
                    CALL abort('find_vertical_neighbours', message)
                 END IF
    
-                palm_grid % kk(i,j,k,1) = kcur
-                palm_grid % kk(i,j,k,2) = kcur + 1
+                palm_grid % kk(i,j,k,1) = k_intermediate
+                palm_grid % kk(i,j,k,2) = k_intermediate + 1
 
                 ! copmute vertical weights
@@ -643,8 +652,8 @@
 !          
     SUBROUTINE compute_horizontal_interp_weights(cosmo_lat, cosmo_lon,         &
-       cosmo_dxi, cosmo_dyi, palm_clat, palm_clon, palm_ii, palm_jj, palm_w_horiz)
+       palm_clat, palm_clon, palm_ii, palm_jj, palm_w_horiz)
        
        REAL(dp), DIMENSION(0:), INTENT(IN)        ::  cosmo_lat, cosmo_lon
-       REAL(dp), INTENT(IN)                       ::  cosmo_dxi, cosmo_dyi
+       REAL(dp)                                   ::  cosmo_dxi, cosmo_dyi
        REAL(dp), DIMENSION(0:,0:), INTENT(IN)     ::  palm_clat, palm_clon
        INTEGER, DIMENSION(0:,0:,1:), INTENT(IN)   ::  palm_ii, palm_jj
@@ -654,4 +663,7 @@
        REAL(dp) ::  wl, wp
        INTEGER  ::  i, j
+
+       cosmo_dxi = 1.0_dp / (cosmo_lon(1) - cosmo_lon(0))
+       cosmo_dyi = 1.0_dp / (cosmo_lat(1) - cosmo_lat(0))
 
        DO j = 0, UBOUND(palm_clon, 2)
Index: palm/trunk/UTIL/inifor/src/types.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/types.f90	(revision 3178)
+++ palm/trunk/UTIL/inifor/src/types.f90	(revision 3182)
@@ -21,4 +21,9 @@
 ! Current revisions:
 ! -----------------
+! Introduced new PALM grid stretching:
+! - Converted vertical grid_definition coordinte variables to pointers
+! Improved command line interface:
+! - Moved INIFOR configuration into a new derived data type
+! Removed unnecessary variables 
 ! 
 ! 
@@ -41,9 +46,34 @@
  
  USE defs,                                                                     &
-    ONLY:  dp, PATH, SNAME, LNAME
+    ONLY:  dp, DATE, PATH, SNAME, LNAME
  USE netcdf,                                                                   &
     ONLY:  NF90_MAX_VAR_DIMS, NF90_MAX_NAME
 
  IMPLICIT NONE
+
+ TYPE inifor_config
+    CHARACTER(LEN=DATE)  ::  start_date           !< String of the FORMAT YYYYMMDDHH indicating the start of the intended PALM-4U simulation
+
+    CHARACTER(LEN=PATH)  ::  input_path           !< Path to the input data file directory
+    CHARACTER(LEN=PATH)  ::  hhl_file             !< Path to the file containing the COSMO-DE HHL variable (height of half layers, i.e. vertical cell faces)
+    CHARACTER(LEN=PATH)  ::  namelist_file        !< Path to the PALM-4U namelist file
+    CHARACTER(LEN=PATH)  ::  output_file          !< Path to the INIFOR output file (i.e. PALM-4U dynamic driver')
+    CHARACTER(LEN=PATH)  ::  soiltyp_file         !< Path to the file containing the COSMO-DE SOILTYP variable (map of COSMO-DE soil types)
+    CHARACTER(LEN=PATH)  ::  static_driver_file   !< Path to the file containing the COSMO-DE SOILTYP variable (map of COSMO-DE soil types)
+
+    CHARACTER(LEN=SNAME) ::  flow_prefix          !< Prefix of flow input files, e.g. 'laf' for COSMO-DE analyses
+    CHARACTER(LEN=SNAME) ::  soil_prefix          !< Prefix of soil input files, e.g. 'laf' for COSMO-DE analyses
+    CHARACTER(LEN=SNAME) ::  radiation_prefix     !< Prefix of radiation input files, e.g 'laf' for COSMO-DE analyses
+    CHARACTER(LEN=SNAME) ::  soilmoisture_prefix  !< Prefix of input files for soil moisture spin-up, e.g 'laf' for COSMO-DE analyses
+
+    CHARACTER(LEN=SNAME) ::  bc_mode
+    CHARACTER(LEN=SNAME) ::  ic_mode
+    CHARACTER(LEN=SNAME) ::  rotation_method
+
+    REAL(dp)             ::  p0
+    REAL(dp)             ::  ug
+    REAL(dp)             ::  vg
+    REAL(dp)             ::  z0 !< Elevation of the PALM-4U domain above sea level [m]
+ END TYPE inifor_config
 
  TYPE grid_definition
@@ -55,13 +85,6 @@
     INTEGER, ALLOCATABLE  ::  jj(:,:,:)     !< Given a point (i,j,k) in the PALM-4U grid, jj(i,j,l) gives the y index of the l'th horizontl neighbour on the COSMO-DE grid.
     INTEGER, ALLOCATABLE  ::  kk(:,:,:,:)   !< Given a point (i,j,k) in the PALM-4U grid, kk(i,j,k,l) gives the z index of the l'th vertical neighbour in the intermediate grid.
-    REAL(dp)              ::  dx            !< grid spacing in the first dimension [m]
-    REAL(dp)              ::  dy            !< grid spacing in the second dimension [m]
-    REAL(dp)              ::  dz            !< grid spacing in the third dimension [m]
-    REAL(dp)              ::  dxi           !< inverse grid spacing in the first dimension [m^-1]
-    REAL(dp)              ::  dyi           !< inverse grid spacing in the second dimension [m^-1]
-    REAL(dp)              ::  dzi           !< inverse grid spacing in the third dimension [m^-1]
     REAL(dp)              ::  lx            !< domain length in the first dimension [m]
     REAL(dp)              ::  ly            !< domain length in the second dimension [m]
-    REAL(dp)              ::  lz            !< domain length in the third dimension [m]
     REAL(dp)              ::  x0            !< x coordinate of PALM-4U domain projection centre, i.e. location of zero distortion
     REAL(dp)              ::  y0            !< y coordinate of PALM-4U domain projection centre, i.e. location of zwro distortion
@@ -69,5 +92,5 @@
     REAL(dp), ALLOCATABLE ::  x(:)          !< coordinates of cell centers in x direction [m]
     REAL(dp), ALLOCATABLE ::  y(:)          !< coordinates of cell centers in y direction [m]
-    REAL(dp), ALLOCATABLE ::  z(:)          !< coordinates of cell centers in z direction [m]
+    REAL(dp), POINTER     ::  z(:)          !< coordinates of cell centers in z direction [m]
     REAL(dp), ALLOCATABLE ::  h(:,:,:)      !< heights grid point for intermediate grids [m]
     REAL(dp), POINTER     ::  hhl(:,:,:)    !< heights of half layers (cell faces) above sea level in COSMO-DE, read in from 
@@ -76,5 +99,5 @@
     REAL(dp), ALLOCATABLE ::  xu(:)         !< coordinates of cell faces in x direction [m]
     REAL(dp), ALLOCATABLE ::  yv(:)         !< coordinates of cell faces in y direction [m]
-    REAL(dp), ALLOCATABLE ::  zw(:)         !< coordinates of cell faces in z direction [m]
+    REAL(dp), POINTER     ::  zw(:)         !< coordinates of cell faces in z direction [m]
     REAL(dp), ALLOCATABLE ::  lat(:)        !< rotated-pole latitudes of scalars (cell centers) of the COSMO-DE grid [rad]
     REAL(dp), ALLOCATABLE ::  lon(:)        !< rotated-pole longitudes of scalars (cell centres) of the COSMO-DE grid [rad]
@@ -89,5 +112,5 @@
     REAL(dp), ALLOCATABLE ::  w_horiz(:,:,:)   !< weights for bilinear horizontal interpolation
     REAL(dp), ALLOCATABLE ::  w_verti(:,:,:,:) !< weights for linear vertical interpolation
- END TYPE
+ END TYPE grid_definition
 
 
@@ -103,5 +126,5 @@
     INTEGER               ::  dimvarids_soil(3)!< NetCDF IDs of the grid coordinates for soil points x, y, depth 
     REAL(dp), POINTER     ::  time(:)       ! vector of output time steps
- END TYPE
+ END TYPE nc_file
 
 
@@ -123,7 +146,7 @@
     CHARACTER(LEN=SNAME)                  ::  kind                      !< Kind of grid
     CHARACTER(LEN=SNAME)                  ::  task                      !< Processing task that generates this variable, e.g. 'interpolate_2d' or 'average profile'
-    LOGICAL                               ::  to_be_processed = .FALSE. !< Inifor flag indicating whether variable shall be processed
-    LOGICAL                               ::  is_read = .FALSE.         !< Inifor flag indicating whether variable has been read
-    LOGICAL                               ::  is_upside_down  = .FALSE. !< Inifor flag indicating whether variable shall be processed
+    LOGICAL                               ::  to_be_processed = .FALSE. !< INIFOR flag indicating whether variable shall be processed
+    LOGICAL                               ::  is_read = .FALSE.         !< INIFOR flag indicating whether variable has been read
+    LOGICAL                               ::  is_upside_down  = .FALSE. !< INIFOR flag indicating whether variable shall be processed
     TYPE(grid_definition), POINTER        ::  grid                      !< Pointer to the corresponding output grid
     TYPE(grid_definition), POINTER        ::  intermediate_grid         !< Pointer to the corresponding intermediate grid
Index: palm/trunk/UTIL/inifor/src/util.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/util.f90	(revision 3178)
+++ palm/trunk/UTIL/inifor/src/util.f90	(revision 3182)
@@ -21,4 +21,5 @@
 ! Current revisions:
 ! -----------------
+! Improved real-to-string conversion
 ! 
 ! 
@@ -43,5 +44,5 @@
         ONLY :  C_CHAR, C_INT, C_PTR, C_SIZE_T
     USE defs,                                                                  &
-        ONLY :  dp, PI, DATE
+        ONLY :  dp, PI, DATE, SNAME
 
     IMPLICIT NONE
@@ -279,5 +280,5 @@
     ! Convert a real number to a string in scientific notation
     ! showing four significant digits.
-    CHARACTER(LEN=11) FUNCTION real_to_str(val, format)
+    CHARACTER(LEN=SNAME) FUNCTION real_to_str(val, format)
 
         REAL(dp), INTENT(IN)                   ::  val
@@ -285,9 +286,9 @@
 
         IF (PRESENT(format))  THEN
-           WRITE(real_to_str, TRIM(format)) val
+           WRITE(real_to_str, format) val
         ELSE
            WRITE(real_to_str, '(E11.4)') val
-           real_to_str = ADJUSTL(real_to_str)
         END IF
+        real_to_str = ADJUSTL(real_to_str)
 
     END FUNCTION real_to_str
Index: palm/trunk/UTIL/inifor/tests/test-boundaries.f90
===================================================================
--- palm/trunk/UTIL/inifor/tests/test-boundaries.f90	(revision 3178)
+++ palm/trunk/UTIL/inifor/tests/test-boundaries.f90	(revision 3182)
@@ -21,4 +21,5 @@
 ! Current revisions:
 ! -----------------
+! Updated test for new PALM grid strechting
 ! 
 ! 
@@ -54,5 +55,6 @@
     TYPE(grid_definition)           ::  boundary_grid
 
-    REAL ::  dx, dy, dz, lx, ly, lz, x(2), y(10), z(10)
+    REAL ::  dx, dy, dz, lx, ly, lz, x(2), y(10)
+    REAL, TARGET :: z(10)
 
     CALL begin_test(title, res)
@@ -79,8 +81,7 @@
           xmin = x(i), xmax = x(i),                                            &
           ymin =  0.5 * dy, ymax = ly - 0.5 * dy,                              &
-          zmin =  0.5 * dz, zmax = lz - 0.5 * dz,                              &
           x0 = 0.0, y0 = 0.0, z0 = 0.0,                                        &
-          nx = 0, ny = ny, nz = nz,                                            &
-          dx = dx, dy = dy, dz = dz )
+          nx = 0, ny = ny, nz = nz, z = z)
+          
    
        ! Assert
@@ -103,5 +104,5 @@
     TYPE(grid_definition), INTENT(INOUT) ::  grid
 
-    DEALLOCATE( grid % x, grid % y, grid % z )
+    DEALLOCATE( grid % x, grid % y )
     DEALLOCATE( grid % kk )
     DEALLOCATE( grid % w_verti )
Index: palm/trunk/UTIL/inifor/tests/test-grid.f90
===================================================================
--- palm/trunk/UTIL/inifor/tests/test-grid.f90	(revision 3178)
+++ palm/trunk/UTIL/inifor/tests/test-grid.f90	(revision 3182)
@@ -21,4 +21,5 @@
 ! Current revisions:
 ! -----------------
+! Updated test for new PALM grid strechting
 ! 
 ! 
@@ -41,5 +42,5 @@
  PROGRAM test_grid
 
-    USE grid, ONLY :  grid_definition, init_grid_definition
+    USE grid, ONLY :  grid_definition, init_grid_definition, dx, dy, dz
     USE test_utils
     
@@ -49,35 +50,41 @@
     LOGICAL                     ::  res
 
-    TYPE(grid_definition) ::  mygrid
-    INTEGER               ::  i
-    INTEGER, PARAMETER    ::  nx = 9,   ny = 19,   nz = 29
-    REAL, PARAMETER       ::  lx = 100., ly = 200., lz = 300.
-    REAL, DIMENSION(0:nx) ::  x, xu
-    REAL, DIMENSION(0:ny) ::  y, yv
-    REAL, DIMENSION(0:nz) ::  z, zw
+    TYPE(grid_definition)   ::  mygrid
+    INTEGER                 ::  i
+    INTEGER, PARAMETER      ::  nx = 9,   ny = 19,   nz = 29
+    REAL, PARAMETER         ::  lx = 100., ly = 200., lz = 300.
+    REAL, DIMENSION(0:nx)   ::  x, xu
+    REAL, DIMENSION(0:ny)   ::  y, yv
+    REAL, DIMENSION(1:nz)   ::  z
+    REAL, DIMENSION(1:nz-1) ::  zw
 
     CALL begin_test(title, res)
 
     ! Arange
+    dx = lx / (nx + 1)
+    DO i = 0, nx
+       xu(i) = real(i) / (nx+1) * lx
+       x(i)  = 0.5*dx + xu(i)
+    END DO
+
+    dy = ly / (ny + 1)
+    DO i = 0, ny
+       yv(i) = real(i) / (ny+1) * ly
+       y(i)  = 0.5*dy + yv(i)
+    END DO
+
+    dz(:) = lz / (nz + 1)
+    DO i = 1, nz
+       IF (i < nz)  zw(i) = real(i) / (nz+1) * lz
+       z(i) = 0.5*dz(1) + zw(i)
+    END DO
+
+    ! Act
     CALL init_grid_definition('palm', grid = mygrid,                           &
                               xmin = 0., xmax = lx,                            &
                               ymin = 0., ymax = ly,                            &
-                              zmin = 0., zmax = lz,                            &
                               x0 = 0.0, y0 = 0.0, z0 = 0.0,                    &
-                              nx = nx, ny = ny, nz = nz)
-
-    ! Act
-    DO i = 0, nx
-       xu(i) = real(i) / (nx+1) * lx
-       x(i)  = 0.5*mygrid%dx + xu(i)
-    END DO
-    DO i = 0, ny
-       yv(i) = real(i) / (ny+1) * ly
-       y(i)  = 0.5*mygrid%dy + yv(i)
-    END DO
-    DO i = 0, nz
-       zw(i) = real(i) / (nz+1) * lz
-       z(i)  = 0.5*mygrid%dz + zw(i)
-    END DO
+                              nx = nx, ny = ny, nz = nz,                       &
+                              z = z, zw = zw)
 
     ! Assert coordinates match
@@ -85,7 +92,7 @@
     res = res .AND. assert_equal(xu(1:), mygrid%xu, "xu")
     res = res .AND. assert_equal(y,      mygrid%y,  "y" )
-    res = res .AND. assert_equal(yv(1:), mygrid%yv, "yu")
+    res = res .AND. assert_equal(yv(1:), mygrid%yv, "yv")
     res = res .AND. assert_equal(z,      mygrid%z,  "z" )
-    res = res .AND. assert_equal(zw(1:), mygrid%zw, "zu")
+    res = res .AND. assert_equal(zw(1:), mygrid%zw, "zw")
 
     CALL end_test(title, res)
Index: palm/trunk/UTIL/inifor/tests/test-input-files.f90
===================================================================
--- palm/trunk/UTIL/inifor/tests/test-input-files.f90	(revision 3178)
+++ palm/trunk/UTIL/inifor/tests/test-input-files.f90	(revision 3182)
@@ -21,5 +21,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! New test for negative start_hour and greater-than-one step_hour
+!
 ! 
 ! Former revisions:
@@ -44,13 +45,13 @@
         ONLY :  PATH
     USE grid,                                                                  & 
-        ONLY :  input_file_list
+        ONLY :  get_input_file_list
     USE test_utils
     
     IMPLICIT NONE
 
-    CHARACTER(LEN=50)                              ::  title
+    CHARACTER(LEN=60)                              ::  title
     CHARACTER(LEN=PATH), ALLOCATABLE, DIMENSION(:) ::  file_list, ref_list
     LOGICAL                                        ::  res
-    INTEGER                                        ::  i     
+    INTEGER                                        ::  i
 
     title = "input files - daylight saving to standard time"
@@ -70,8 +71,8 @@
 
     ! Act
-    CALL input_file_list(start_date_string='2017102823',                       &
-                         start_hour=0, end_hour=5, step_hour=1,                &
-                         path='./', prefix="laf", suffix='-test',              &
-                         file_list=file_list)
+    CALL get_input_file_list(start_date_string='2017102823',                   &
+                             start_hour=0, end_hour=5, step_hour=1,            &
+                             path='./', prefix="laf", suffix='-test',          &
+                             file_list=file_list)
 
     ! Assert
@@ -95,8 +96,38 @@
 
     ! Act
-    CALL input_file_list(start_date_string='2016022823',                       &
-                         start_hour=0, end_hour=1, step_hour=1,                &
-                         path='./', prefix="laf", suffix='-test',              &
-                         file_list=file_list)
+    CALL get_input_file_list(start_date_string='2016022823',                   &
+                             start_hour=0, end_hour=1, step_hour=1,            &
+                             path='./', prefix="laf", suffix='-test',          &
+                             file_list=file_list)
+
+    ! Assert
+    DO i = 1, 2
+       res = res .AND. (TRIM(ref_list(i)) .EQ. TRIM(file_list(i)))
+    END DO
+
+    DEALLOCATE( ref_list, file_list )
+    CALL end_test(title, res)
+
+
+
+    title = "input files - negative start_hour and step_hour > 1 hour"
+    CALL begin_test(title, res)
+
+    ! Arange
+    ! ...a date range that inlcudes a leap day (29. Feb. 2016) which should be
+    ! inlcuded in UTC time stamps.
+    ALLOCATE( ref_list(4) )
+    ref_list(1)  = './laf2017102823-test.nc'
+    ref_list(2)  = './laf2017102901-test.nc'
+    ref_list(3)  = './laf2017102903-test.nc'
+    ref_list(4)  = './laf2017102904-test.nc'
+
+    ! Act
+    CALL get_input_file_list(start_date_string='2017102901',                   &
+                             start_hour=-2, end_hour=3, step_hour=2,           &
+                             path='./', prefix="laf", suffix='-test',          &
+                             file_list=file_list)
+
+    PRINT *, file_list
 
     ! Assert
Index: palm/trunk/UTIL/inifor/tests/test-interpolation.f90
===================================================================
--- palm/trunk/UTIL/inifor/tests/test-interpolation.f90	(revision 3178)
+++ palm/trunk/UTIL/inifor/tests/test-interpolation.f90	(revision 3182)
@@ -21,5 +21,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! Updated test for new grid_definition
+!
 ! 
 ! Former revisions:
@@ -76,5 +77,4 @@
                               xmin = -5.0 * TO_RADIANS, xmax = 5.5 * TO_RADIANS, &
                               ymin = -5.0 * TO_RADIANS, ymax = 6.5 * TO_RADIANS, &
-                              zmin =  0.0, zmax = 10.0,                        &
                               x0 = 0.0, y0 = 0.0, z0 = 0.0,                    &
                               nx = nlon-1, ny = nlat-1, nz = nlev-1)
@@ -86,5 +86,6 @@
     res = assert_equal( (/cosmo_grid%lat(0), cosmo_grid % lon(0),              &
                           cosmo_grid%lat(2), cosmo_grid % lon(2),              &
-                          cosmo_grid%dx*TO_DEGREES, cosmo_grid%dy*TO_DEGREES/),&
+                          (cosmo_grid%lon(1) - cosmo_grid%lon(0))*TO_DEGREES,  &
+                          (cosmo_grid%lat(1) - cosmo_grid%lat(0))*TO_DEGREES/),&
                         (/-5.0 * TO_RADIANS, -5.0 * TO_RADIANS,                &
                            6.5 * TO_RADIANS,  5.5 * TO_RADIANS,                &
@@ -97,5 +98,4 @@
                               xmin = 0.0, xmax = 1.0,                          &
                               ymin = 0.0, ymax = 1.0,                          &
-                              zmin = 0.0, zmax = 1.0,                          &
                               x0 = 0.0, y0 = 0.0, z0 = 0.0,                    &
                               nx = 1, ny = 1, nz = 1)
@@ -127,6 +127,6 @@
     ! Act
     CALL find_horizontal_neighbours(cosmo_grid % lat, cosmo_grid % lon,        &
-       cosmo_grid % dxi, cosmo_grid % dyi, palm_grid % clat, palm_grid % clon, &
-       palm_grid % ii, palm_grid % jj)
+                                    palm_grid % clat, palm_grid % clon,        &
+                                    palm_grid % ii, palm_grid % jj)
 
     ! Assert
@@ -178,10 +178,11 @@
     ! Act
     CALL find_horizontal_neighbours(cosmo_grid % lat, cosmo_grid % lon,        &
-       cosmo_grid % dxi, cosmo_grid % dyi, palm_grid % clat, palm_grid % clon, &
-       palm_grid % ii, palm_grid % jj)
+                                    palm_grid % clat, palm_grid % clon,        &
+                                    palm_grid % ii, palm_grid % jj)
 
     CALL compute_horizontal_interp_weights(cosmo_grid % lat, cosmo_grid % lon, &
-       cosmo_grid % dxi, cosmo_grid % dyi, palm_grid % clat,                   &
-       palm_grid % clon, palm_grid % ii, palm_grid % jj, palm_grid % w_horiz)
+                                           palm_grid % clat, palm_grid % clon, &
+                                           palm_grid % ii, palm_grid % jj,     &
+                                           palm_grid % w_horiz)
 
     ! Assert
Index: palm/trunk/UTIL/inifor/tests/test-prototype.f90
===================================================================
--- palm/trunk/UTIL/inifor/tests/test-prototype.f90	(revision 3178)
+++ palm/trunk/UTIL/inifor/tests/test-prototype.f90	(revision 3182)
@@ -21,5 +21,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Added usage hints
 ! 
 ! Former revisions:
@@ -51,8 +51,11 @@
 
     ! Arange
+    !define parameters and reference values
 
     ! Act
+    !compute result
 
     ! Assert
+    !res = res .AND. assert_equal(<result_array>, <reference_array>, 'description')
 
     CALL end_test(title, res)
Index: palm/trunk/UTIL/inifor/tests/test-stretching.f90
===================================================================
--- palm/trunk/UTIL/inifor/tests/test-stretching.f90	(revision 3182)
+++ palm/trunk/UTIL/inifor/tests/test-stretching.f90	(revision 3182)
@@ -0,0 +1,97 @@
+!> @file tests/test-stretching.f90
+!------------------------------------------------------------------------------!
+! This file is part of the PALM model system.
+!
+! PALM is free software: you can redistribute it and/or modify it under the
+! terms of the GNU General Public License as published by the Free Software
+! Foundation, either version 3 of the License, or (at your option) any later
+! version.
+!
+! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
+! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along with
+! PALM. If not, see <http://www.gnu.org/licenses/>.
+!
+! Copyright 2017-2018 Leibniz Universitaet Hannover
+! Copyright 2017-2018 Deutscher Wetterdienst Offenbach
+!------------------------------------------------------------------------------!
+!
+! Current revisions:
+! -----------------
+! Initial revision
+! 
+! 
+! Former revisions:
+! -----------------
+! $Id$
+! 
+!
+! Authors:
+! --------
+! @author Eckhard Kadasch
+!
+! Description:
+! ------------
+!> This program tests INIFOR's implementation of PALM's grid stretching.
+!> 
+!------------------------------------------------------------------------------!
+ PROGRAM test_stretching
+
+    USE defs, &
+        ONLY :  dp
+
+    USE grid, &
+        ONLY :  stretched_z
+
+    USE test_utils
+    
+    IMPLICIT NONE
+
+    CHARACTER(LEN=*), PARAMETER ::  title = "stretched grid"
+    LOGICAL                     ::  res
+
+    INTEGER, PARAMETER ::  nz = 9
+    INTEGER            ::  k  = nz - 2
+
+    REAL(dp) ::  z(1:nz)
+    REAL(dp) ::  dz(10)            = -1.0_dp
+    REAL(dp) ::  dz_max            = 1000.0_dp
+    REAL(dp) ::  dz_stretch_factor = 1.08_dp
+    REAL(dp) ::  dz_stretch_level  = 2.0_dp
+    REAL(dp) ::  dz_stretch_level_start(9) = -9999999.9_dp
+    REAL(dp) ::  dz_stretch_level_end(9) = 9999999.9_dp
+    REAL(dp) ::  dz_stretch_factor_array(9) = 1.08_dp
+
+    CALL begin_test(title, res)
+
+    ! Arange
+    z(:)   = 0.0_dp
+    dz(1)  = 1.0_dp
+
+    ! Act
+    CALL stretched_z(z, dz, dz_max=dz_max, &
+                     dz_stretch_factor=dz_stretch_factor,                   &
+                     dz_stretch_level=dz_stretch_level,                     &
+                     dz_stretch_level_start=dz_stretch_level_start,         &
+                     dz_stretch_level_end=dz_stretch_level_end,             &
+                     dz_stretch_factor_array=dz_stretch_factor_array)
+
+    ! Assert, that the total distance covered by the stretched region 
+    ! matches the therotetial distance, i.e. the sum over the finite
+    ! exponential series
+    !
+    !          Sum_{i=0}^n( dz[i] ) = dz[0] * Sum_{i=0}^n( f^i )
+    !                               = dz[0] * (1 - f^(i+1)) / (1-f)
+    !
+    ! with f being the stretch factor.
+    res = res .AND. &
+          assert_equal( (/ z(UBOUND(z, 1)) - z(1)              /),             &
+                        (/ (1.0_dp - dz_stretch_factor**(k+1)) /               &
+                           (1.0_dp - dz_stretch_factor)        /),             &
+                        'length of stretched grid' )
+
+    CALL end_test(title, res)
+
+ END PROGRAM test_stretching
Index: palm/trunk/UTIL/inifor/tests/util.f90
===================================================================
--- palm/trunk/UTIL/inifor/tests/util.f90	(revision 3178)
+++ palm/trunk/UTIL/inifor/tests/util.f90	(revision 3182)
@@ -21,4 +21,5 @@
 ! Current revisions:
 ! -----------------
+! Expose error measure as parameter in assert_equal()
 ! 
 ! 
@@ -74,9 +75,15 @@
     END SUBROUTINE end_test
 
-    LOGICAL FUNCTION assert_equal(a, b, msg)
+    LOGICAL FUNCTION assert_equal(a, b, msg, ratio)
+       REAL, OPTIONAL, INTENT(IN)     ::  ratio
        REAL, DIMENSION(:), INTENT(IN) ::  a, b
-       CHARACTER(LEN=*), INTENT(IN)   :: msg
+       CHARACTER(LEN=*), INTENT(IN)   ::  msg
 
-       assert_equal = assert(a, b, 'eq')
+       IF ( PRESENT(ratio) )  THEN
+           assert_equal = assert(a, b, 'eq', ratio)
+       ELSE
+           assert_equal = assert(a, b, 'eq')
+       END IF
+
        IF (assert_equal .eqv. .TRUE.)  THEN
            PRINT *, "Equality assertion for ", msg, " was successful."
@@ -88,8 +95,8 @@
     END FUNCTION assert_equal
 
-    LOGICAL FUNCTION assert(a, b, mode, eps)
+    LOGICAL FUNCTION assert(a, b, mode, ratio)
 
        REAL, DIMENSION(:), INTENT(IN) ::  a, b
-       REAL, OPTIONAL, INTENT(IN)     ::  eps
+       REAL, OPTIONAL, INTENT(IN)     ::  ratio
        CHARACTER(LEN=*), INTENT(IN)   ::  mode
 
@@ -98,5 +105,5 @@
 
        max_rel_diff = 10 * EPSILON(1.0)
-       IF (PRESENT(eps)) max_rel_diff = eps
+       IF (PRESENT(ratio)) max_rel_diff = ratio
 
        SELECT CASE( TRIM(mode) )
