Index: palm/trunk/SOURCE/pmc_interface_mod.f90
===================================================================
--- palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 2310)
+++ palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 2311)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Set bottom boundary condition after anterpolation.
+! Some variable description added.
+! 
+! 2293 2017-06-22 12:59:12Z suehring
 ! In anterpolation, exclude grid points which are used for interpolation. 
 ! This avoids the accumulation of numerical errors leading to increased 
@@ -422,4 +426,7 @@
     TYPE(coarsegrid_def), SAVE ::  cg   !:
 
+    INTERFACE pmci_boundary_conds
+       MODULE PROCEDURE pmci_boundary_conds
+    END INTERFACE pmci_boundary_conds
 
     INTERFACE pmci_check_setting_mismatches
@@ -464,4 +471,6 @@
            cpl_id, nested_run, nesting_datatransfer_mode, nesting_mode,         &
            parent_to_child
+
+    PUBLIC pmci_boundary_conds
     PUBLIC pmci_child_initialize
     PUBLIC pmci_datatrans
@@ -4482,5 +4491,5 @@
       IF ( .NOT. neutral )  THEN
          CALL pmci_anterp_tophat( pt, ptc, kctu, iflo, ifuo, jflo, jfuo, kflo, &
-                                  kfuo, ijfc_s, kfc_s, 's' )
+                                  kfuo, ijfc_s, kfc_s, 'pt' )
       ENDIF
 
@@ -4488,13 +4497,13 @@
 
          CALL pmci_anterp_tophat( q, q_c, kctu, iflo, ifuo, jflo, jfuo, kflo,  &
-                                  kfuo, ijfc_s, kfc_s, 's' )
+                                  kfuo, ijfc_s, kfc_s, 'q' )
 
          IF ( cloud_physics  .AND.  microphysics_morrison )  THEN
 
             CALL pmci_anterp_tophat( qc, qcc, kctu, iflo, ifuo, jflo, jfuo,    &
-                                     kflo, kfuo, ijfc_s, kfc_s, 's' )
+                                     kflo, kfuo, ijfc_s, kfc_s, 'qc' )
 
             CALL pmci_anterp_tophat( nc, ncc, kctu, iflo, ifuo, jflo, jfuo,    &
-                                     kflo, kfuo, ijfc_s, kfc_s,  's' )
+                                     kflo, kfuo, ijfc_s, kfc_s,  'nc' )
 
          ENDIF
@@ -4503,8 +4512,8 @@
 
             CALL pmci_anterp_tophat( qr, qrc, kctu, iflo, ifuo, jflo, jfuo,    &
-                                     kflo, kfuo, ijfc_s, kfc_s, 's' )
+                                     kflo, kfuo, ijfc_s, kfc_s, 'qr' )
 
             CALL pmci_anterp_tophat( nr, nrc, kctu, iflo, ifuo, jflo, jfuo,    &
-                                     kflo, kfuo, ijfc_s, kfc_s, 's' )
+                                     kflo, kfuo, ijfc_s, kfc_s, 'nr' )
 
          ENDIF
@@ -5382,36 +5391,36 @@
        IMPLICIT NONE
 
-       CHARACTER(LEN=1), INTENT(IN) ::  var   !:
-
-       INTEGER(iwp) ::  i         !: Fine-grid index
-       INTEGER(iwp) ::  ii        !: Coarse-grid index
-       INTEGER(iwp) ::  iclp      !:
-       INTEGER(iwp) ::  icrm      !:
-       INTEGER(iwp) ::  j         !: Fine-grid index
-       INTEGER(iwp) ::  jj        !: Coarse-grid index
-       INTEGER(iwp) ::  jcnm      !:
-       INTEGER(iwp) ::  jcsp      !:
-       INTEGER(iwp) ::  k         !: Fine-grid index       
-       INTEGER(iwp) ::  kk        !: Coarse-grid index
-       INTEGER(iwp) ::  kcb = 0   !:
-       INTEGER(iwp) ::  nfc       !:
-
-       INTEGER(iwp), INTENT(IN) ::  kct   !:
-
-       INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) ::  ifl         !:
-       INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) ::  ifu         !:
-       INTEGER(iwp), DIMENSION(jcs:jcn,icl:icr), INTENT(IN) :: ijfc !:
-       INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) ::  jfl         !:
-       INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) ::  jfu         !:
-       INTEGER(iwp), DIMENSION(0:kct), INTENT(IN)   ::  kfc         !:
-       INTEGER(iwp), DIMENSION(0:kct), INTENT(IN)   ::  kfl         !:
-       INTEGER(iwp), DIMENSION(0:kct), INTENT(IN)   ::  kfu         !:
-
-       REAL(wp) ::  cellsum   !:
-       REAL(wp) ::  f1f       !:
-       REAL(wp) ::  fra       !:
-
-       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg), INTENT(IN) ::  f   !:
-       REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(INOUT)  ::  fc  !:
+       CHARACTER(LEN=*), INTENT(IN) ::  var   !< identifyer for treated variable
+
+       INTEGER(iwp) ::  i         !< Running index x-direction - fine-grid
+       INTEGER(iwp) ::  ii        !< Running index x-direction - coarse grid
+       INTEGER(iwp) ::  iclp      !< Left boundary index for anterpolation along x
+       INTEGER(iwp) ::  icrm      !< Right boundary index for anterpolation along x
+       INTEGER(iwp) ::  j         !< Running index y-direction - fine-grid
+       INTEGER(iwp) ::  jj        !< Running index y-direction - coarse grid
+       INTEGER(iwp) ::  jcnm      !< North boundary index for anterpolation along y
+       INTEGER(iwp) ::  jcsp      !< South boundary index for anterpolation along y
+       INTEGER(iwp) ::  k         !< Running index z-direction - fine-grid     
+       INTEGER(iwp) ::  kk        !< Running index z-direction - coarse grid
+       INTEGER(iwp) ::  kcb = 0   !< Bottom boundary index for anterpolation along z
+       INTEGER(iwp) ::  m         !< Running index surface type
+       INTEGER(iwp) ::  nfc       !<
+
+       INTEGER(iwp), INTENT(IN) ::  kct   !< Top boundary index for anterpolation along z
+
+       INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) ::  ifl         !< Indicates start index of child cells belonging to certain parent cell - x direction
+       INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) ::  ifu         !< Indicates end index of child cells belonging to certain parent cell - x direction
+       INTEGER(iwp), DIMENSION(jcs:jcn,icl:icr), INTENT(IN) :: ijfc !<
+       INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) ::  jfl         !< Indicates start index of child cells belonging to certain parent cell - y direction
+       INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) ::  jfu         !< Indicates start index of child cells belonging to certain parent cell - y direction
+       INTEGER(iwp), DIMENSION(0:kct), INTENT(IN)   ::  kfc         !<
+       INTEGER(iwp), DIMENSION(0:kct), INTENT(IN)   ::  kfl         !< Indicates start index of child cells belonging to certain parent cell - z direction
+       INTEGER(iwp), DIMENSION(0:kct), INTENT(IN)   ::  kfu         !< Indicates start index of child cells belonging to certain parent cell - z direction
+
+       REAL(wp) ::  cellsum   !< sum of respective child cells belonging to parent cell 
+       REAL(wp) ::  fra       !< relaxation faction
+
+       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg), INTENT(IN) ::  f   !< Treated variable - child domain
+       REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(INOUT)  ::  fc  !< Treated variable - parent domain
   
 
@@ -5501,8 +5510,164 @@
        ENDDO
 
+
     END SUBROUTINE pmci_anterp_tophat
 
 #endif
+
  END SUBROUTINE pmci_child_datatrans
 
+! Description:
+! ------------
+!> Set boundary conditions for the prognostic quantities after interpolation 
+!> and anterpolation at upward- and downward facing surfaces.  
+!> @todo: add Dirichlet boundary conditions for pot. temperature, humdidity and
+!> passive scalar.
+!------------------------------------------------------------------------------!
+ SUBROUTINE pmci_boundary_conds
+
+    USE control_parameters,                                                    &
+        ONLY:  ibc_pt_b, ibc_q_b, ibc_s_b, ibc_uv_b
+
+    USE surface_mod,                                                           &
+        ONLY:  bc_h
+
+    IMPLICIT NONE
+
+    INTEGER(iwp) ::  i  !< Index along x-direction
+    INTEGER(iwp) ::  j  !< Index along y-direction
+    INTEGER(iwp) ::  k  !< Index along z-direction
+    INTEGER(iwp) ::  m  !< Running index for surface type
+    
+!
+!-- Set Dirichlet boundary conditions for horizontal velocity components
+    IF ( ibc_uv_b == 0 )  THEN
+!
+!--    Upward-facing surfaces
+       DO  m = 1, bc_h(0)%ns
+          i = bc_h(0)%i(m)            
+          j = bc_h(0)%j(m)
+          k = bc_h(0)%k(m)
+          u(k-1,j,i) = 0.0_wp
+          v(k-1,j,i) = 0.0_wp
+       ENDDO
+!
+!--    Downward-facing surfaces
+       DO  m = 1, bc_h(1)%ns
+          i = bc_h(1)%i(m)            
+          j = bc_h(1)%j(m)
+          k = bc_h(1)%k(m)
+          u(k+1,j,i) = 0.0_wp
+          v(k+1,j,i) = 0.0_wp
+       ENDDO
+    ENDIF
+!
+!-- Set Dirichlet boundary conditions for vertical velocity component
+!-- Upward-facing surfaces
+    DO  m = 1, bc_h(0)%ns
+       i = bc_h(0)%i(m)            
+       j = bc_h(0)%j(m)
+       k = bc_h(0)%k(m)
+       w(k-1,j,i) = 0.0_wp
+    ENDDO
+!
+!-- Downward-facing surfaces
+    DO  m = 1, bc_h(1)%ns
+       i = bc_h(1)%i(m)            
+       j = bc_h(1)%j(m)
+       k = bc_h(1)%k(m)
+       w(k+1,j,i) = 0.0_wp
+    ENDDO
+!
+!-- Set Neumann boundary conditions for potential temperature
+    IF ( .NOT. neutral )  THEN
+       IF ( ibc_pt_b == 1 )  THEN
+          DO  m = 1, bc_h(0)%ns
+             i = bc_h(0)%i(m)            
+             j = bc_h(0)%j(m)
+             k = bc_h(0)%k(m)
+             pt(k-1,j,i) = pt(k,j,i)
+          ENDDO
+          DO  m = 1, bc_h(1)%ns
+             i = bc_h(1)%i(m)            
+             j = bc_h(1)%j(m)
+             k = bc_h(1)%k(m)
+             pt(k+1,j,i) = pt(k,j,i)
+          ENDDO   
+       ENDIF
+    ENDIF
+
+!
+!-- Set Neumann boundary conditions for humidity and cloud-physical quantities
+    IF ( humidity )  THEN
+       IF ( ibc_q_b == 1 )  THEN
+          DO  m = 1, bc_h(0)%ns
+             i = bc_h(0)%i(m)            
+             j = bc_h(0)%j(m)
+             k = bc_h(0)%k(m)
+             q(k-1,j,i) = q(k,j,i)
+          ENDDO  
+          DO  m = 1, bc_h(1)%ns
+             i = bc_h(1)%i(m)            
+             j = bc_h(1)%j(m)
+             k = bc_h(1)%k(m)
+             q(k+1,j,i) = q(k,j,i)
+          ENDDO  
+       ENDIF
+       IF ( cloud_physics  .AND.  microphysics_morrison )  THEN
+          DO  m = 1, bc_h(0)%ns
+             i = bc_h(0)%i(m)            
+             j = bc_h(0)%j(m)
+             k = bc_h(0)%k(m)
+             nc(k-1,j,i) = 0.0_wp
+             qc(k-1,j,i) = 0.0_wp
+          ENDDO  
+          DO  m = 1, bc_h(1)%ns
+             i = bc_h(1)%i(m)            
+             j = bc_h(1)%j(m)
+             k = bc_h(1)%k(m)
+
+             nc(k+1,j,i) = 0.0_wp
+             qc(k+1,j,i) = 0.0_wp
+          ENDDO  
+       ENDIF
+
+       IF ( cloud_physics  .AND.  microphysics_seifert )  THEN
+          DO  m = 1, bc_h(0)%ns
+             i = bc_h(0)%i(m)            
+             j = bc_h(0)%j(m)
+             k = bc_h(0)%k(m)
+             nr(k-1,j,i) = 0.0_wp
+             qr(k-1,j,i) = 0.0_wp
+          ENDDO  
+          DO  m = 1, bc_h(1)%ns
+             i = bc_h(1)%i(m)            
+             j = bc_h(1)%j(m)
+             k = bc_h(1)%k(m)
+             nr(k+1,j,i) = 0.0_wp
+             qr(k+1,j,i) = 0.0_wp
+          ENDDO  
+       ENDIF
+
+    ENDIF
+!
+!-- Set Neumann boundary conditions for passive scalar
+    IF ( passive_scalar )  THEN
+       IF ( ibc_s_b == 1 )  THEN
+          DO  m = 1, bc_h(0)%ns
+             i = bc_h(0)%i(m)            
+             j = bc_h(0)%j(m)
+             k = bc_h(0)%k(m)
+             s(k-1,j,i) = s(k,j,i)
+          ENDDO 
+          DO  m = 1, bc_h(1)%ns
+             i = bc_h(1)%i(m)            
+             j = bc_h(1)%j(m)
+             k = bc_h(1)%k(m)
+             s(k-1,j,i) = s(k,j,i)
+          ENDDO  
+       ENDIF
+    ENDIF
+
+ END SUBROUTINE pmci_boundary_conds
+
 END MODULE pmc_interface
Index: palm/trunk/SOURCE/time_integration.f90
===================================================================
--- palm/trunk/SOURCE/time_integration.f90	(revision 2310)
+++ palm/trunk/SOURCE/time_integration.f90	(revision 2311)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Set bottom boundary conditions after nesting interpolation and anterpolation
+! 
+! 2299 2017-06-29 10:14:38Z maronga
 ! Call of soil model adjusted
 ! 
@@ -356,5 +359,5 @@
 
     USE pmc_interface,                                                         &
-        ONLY:  nested_run, nesting_mode, pmci_datatrans,                       &
+        ONLY:  nested_run, nesting_mode, pmci_boundary_conds, pmci_datatrans,  &
                pmci_ensure_nest_mass_conservation, pmci_synchronize
 
@@ -664,4 +667,7 @@
                 IF ( .NOT. constant_diffusion )  CALL exchange_horiz( e, nbgp )
              ENDIF
+!
+!--          Set boundary conditions again after interpolation and anterpolation.
+             CALL pmci_boundary_conds
 !
 !--          Correct the w top-BC in nest domains to ensure mass conservation.
