Index: palm/trunk/SOURCE/pmc_interface_mod.f90
===================================================================
--- palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 3696)
+++ palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 3697)
@@ -25,4 +25,10 @@
 ! -----------------
 ! $Id$
+! Bugfix: upper k-bound in the child initialization interpolation 
+! pmci_interp_1sto_all corrected.
+! Copying of the nest boundary values into the redundant 2nd and 3rd ghost-node 
+! layers is added to the pmci_interp_1sto_*-routines.
+! 
+! 3681 2019-01-18 15:06:05Z hellstea
 ! Linear interpolations are replaced by first order interpolations. The linear 
 ! interpolation routines are still included but not called. In the child 
@@ -3970,6 +3976,4 @@
     IF ( air_chemistry  .AND.  nest_chemistry )                                &
        pmc_max_array = pmc_max_array + nspec
-
-
 #endif
  END SUBROUTINE pmci_num_arrays
@@ -4534,9 +4538,9 @@
           DO  l = lb, le
              DO  m = mb, me
-                DO n = 0, kct 
+                DO n = 0, kct + 1 
 
                    DO  i = ifl(l), ifl(l+1)-1
                       DO  j = jfl(m), jfu(m)
-                         DO  k = kfl(n), kfu(n)
+                         DO  k = kfl(n), MIN( kfu(n), nzt+1 )
                             f(k,j,i) = fc(n,m,l)
                          ENDDO
@@ -4552,9 +4556,9 @@
           DO  l = lb, le
              DO  m = mb, me
-                DO n = 0, kct 
+                DO n = 0, kct + 1  
                
                    DO i = ifl(l), ifu(l)
                       DO  j = jfl(m), jfl(m+1)-1
-                         DO  k = kfl(n), kfu(n)
+                         DO  k = kfl(n), MIN( kfu(n), nzt+1 )
                             f(k,j,i) = fc(n,m,l) 
                          ENDDO
@@ -4570,5 +4574,5 @@
           DO  l = lb, le
              DO  m = mb, me
-                DO n = 1, kct + 1   ! It is important to go up to kct+1  
+                DO n = 1, kct + 1  
 
                    DO i = ifl(l), ifu(l)
@@ -4589,9 +4593,9 @@
           DO  l = lb, le
              DO  m = mb, me
-                DO n = 0, kct 
+                DO n = 0, kct + 1
                    
                    DO i = ifl(l), ifu(l)
                       DO  j = jfl(m), jfu(m)
-                         DO  k = kfl(n), kfu(n)
+                         DO  k = kfl(n), MIN( kfu(n), nzt+1 )
                             f(k,j,i) = fc(n,m,l)
                          ENDDO
@@ -5738,5 +5742,7 @@
       INTEGER(iwp) ::  iaw      !< Reduced ia-index for workarr_lr
       INTEGER(iwp) ::  iawbc    !< iaw-index pointing to the boundary-value nodes (either 0 or igsr-1)      
+      INTEGER(iwp) ::  ib       !< Fixed i-index pointing to the node just behind the boundary-value node
       INTEGER(iwp) ::  ibc      !< Fixed i-index pointing to the boundary-value nodes (either i or iend)
+      INTEGER(iwp) ::  ibgp     !< Index running over the redundant boundary ghost points in i-direction
 !AH      INTEGER(iwp) ::  ibeg     !< i-index pointing to the starting point of workarr_lr in the i-direction 
       INTEGER(iwp) ::  iend     !< Upper bound of the running index ia
@@ -5788,14 +5794,16 @@
             i     = nxl
             iend  = nxl
-            ibc   = nxl
+            ibc   = nxl    
+            ib    = ibc - 1
             iawbc = 0
             l     = icl + 2
             lw    = 2
             lbeg  = icl
-            loff  = 0
+            loff  = 0            
          ELSE
             i     = nxl - igsr
             iend  = nxl - 1
             ibc   = nxl - 1
+            ib    = ibc - 1
             iawbc = igsr-1
             l     = icl + 1
@@ -5803,5 +5811,5 @@
             lbeg  = icl
             loff  = 0
-         ENDIF
+         ENDIF        
       ELSEIF ( edge == 'r' )  THEN
          IF ( var == 'u' )  THEN
@@ -5809,4 +5817,5 @@
             iend  = nxr + 1
             ibc   = nxr + 1 
+            ib    = ibc + 1
             iawbc = 0
             l     = icr - 1
@@ -5818,4 +5827,5 @@
             iend  = nxr + igsr
             ibc   = nxr + 1
+            ib    = ibc + 1
             iawbc = 0
             l     = icr - 1
@@ -5823,5 +5833,5 @@
             lbeg  = icr - 2
             loff  = 1
-         ENDIF
+         ENDIF         
       ENDIF
 
@@ -5944,4 +5954,15 @@
 
       ENDIF  ! var
+!
+!--   Fill up also the redundant 2nd and 3rd ghost-node layers
+      IF ( edge == 'l' )  THEN
+         DO  ibgp = -nbgp, ib
+            f(0:nzt+1,nysg:nyng,ibgp) = f(0:nzt+1,nysg:nyng,ibc)
+         ENDDO
+      ELSEIF ( edge == 'r' )  THEN
+         DO  ibgp = ib, nx+nbgp
+            f(0:nzt+1,nysg:nyng,ibgp) = f(0:nzt+1,nysg:nyng,ibc)
+         ENDDO
+      ENDIF
 
    END SUBROUTINE pmci_interp_1sto_lr
@@ -6026,5 +6047,7 @@
       INTEGER(iwp) ::  jawbc    !< jaw-index pointing to the boundary-value nodes (either 0 or jgsr-1)
 !AH      INTEGER(iwp) ::  jbeg     !< j-index pointing to the starting point of workarr_sn in the j-direction
+      INTEGER(iwp) ::  jb       !< Fixed j-index pointing to the node just behind the boundary-value node
       INTEGER(iwp) ::  jbc      !< Fixed j-index pointing to the boundary-value nodes (either j or jend)
+      INTEGER(iwp) ::  jbgp     !< Index running over the redundant boundary ghost points in j-direction
       INTEGER(iwp) ::  jend     !< Upper bound of the running index ja
       INTEGER(iwp) ::  jw       !< j-index for wall_flags_0
@@ -6069,4 +6092,5 @@
             jawbc = 0
             jbc   = nys
+            jb    = jbc - 1
             m     = jcs + 2
             mw    = 2
@@ -6078,4 +6102,5 @@
             jawbc = jgsr - 1
             jbc   = nys - 1
+            jb    = jbc - 1
             m     = jcs + 1
             mw    = 1
@@ -6089,4 +6114,5 @@
             jawbc = 0
             jbc   = nyn + 1
+            jb    = jbc + 1
             m     = jcn - 1
             mw    = 1
@@ -6098,4 +6124,5 @@
             jawbc = 0
             jbc   = nyn + 1
+            jb    = jbc + 1
             m     = jcn - 1
             mw    = 1
@@ -6187,4 +6214,8 @@
                   DO  k = kfl(n), kfu(n) 
                      f(k,jbc,i) = fc(n,m,l) 
+!AH
+!                     write(9,"('sn u: ',6(i3,2x),2(e12.5,2x))") n, m, l, k, jbc, i, fc(n,m,l), f(k,jbc,i)
+!                     flush(9)
+!AH
                   ENDDO
                ENDDO
@@ -6223,4 +6254,15 @@
 
       ENDIF  ! var
+!
+!--   Fill up also the redundant 2nd and 3rd ghost-node layers
+      IF ( edge == 's' )  THEN
+         DO  jbgp = -nbgp, jb
+            f(0:nzt+1,jbgp,nxlg:nxrg) = f(0:nzt+1,jbc,nxlg:nxrg)
+         ENDDO
+      ELSEIF ( edge == 'n' )  THEN
+         DO  jbgp = jb, ny+nbgp
+            f(0:nzt+1,jbgp,nxlg:nxrg) = f(0:nzt+1,jbc,nxlg:nxrg)
+         ENDDO
+      ENDIF
 
    END SUBROUTINE pmci_interp_1sto_sn
@@ -6464,4 +6506,9 @@
 
       ENDIF  ! var
+!
+!--   Just fill up the redundant second ghost-node layer in case of var == w.
+      IF ( var == 'w' )  THEN
+         f(nzt+1,:,:) = f(nzt,:,:)
+      ENDIF
 
    END SUBROUTINE pmci_interp_1sto_t
@@ -7936,5 +7983,4 @@
           ENDIF
           IF ( bc_dirichlet_r )  THEN
-!             icrant = icr - 5
              icrant = icr - 3
           ENDIF
