Index: palm/trunk/SOURCE/pmc_interface.f90
===================================================================
--- palm/trunk/SOURCE/pmc_interface.f90	(revision 1782)
+++ palm/trunk/SOURCE/pmc_interface.f90	(revision 1783)
@@ -20,5 +20,6 @@
 ! Current revisions:
 ! ------------------
-!
+! calculation of nest top area simplified,
+! interpolation and anterpolation moved to seperate wrapper subroutines
 !
 ! Former revisions:
@@ -678,5 +679,4 @@
     INTEGER(iwp), DIMENSION(5) ::  val        !:
     
-    REAL(wp)                   ::  area_t_l   !:
     REAL(wp), DIMENSION(1)     ::  fval       !:
     REAL(wp)                   ::  xcs        !:
@@ -684,6 +684,4 @@
     REAL(wp)                   ::  ycs        !:
     REAL(wp)                   ::  yce        !:
-    REAL(wp)                   ::  zct        !:
-    REAL(wp), DIMENSION(4)     ::  ztt        !:
                                              
 
@@ -830,11 +828,5 @@
 !--    Finally, compute the total area of the top-boundary face of the domain.
 !--    This is needed in the pmc_ensure_nest_mass_conservation      
-       area_t_l = ( nxr + 1 - nxl ) * ( nyn + 1 - nys ) * dx * dy
-       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
-       CALL MPI_ALLREDUCE( area_t_l, area_t, 1, MPI_REAL, MPI_SUM, comm2d, ierr )
-
-!
-!--    TO_DO: Why not just simply? test this!
-       !area_t_l = ( nx + 1 ) * (ny + 1 ) * dx * dy            
+       area_t = ( nx + 1 ) * (ny + 1 ) * dx * dy
 
     ENDIF
@@ -1079,5 +1071,4 @@
 
       REAL(wp), ALLOCATABLE, DIMENSION(:) ::  lcr   !:
-      LOGICAL  ::  more             !:
 
 !
@@ -2399,139 +2390,10 @@
           CALL cpu_log( log_point_s(73), 'PMC Client Recv', 'stop' )
 
-!
-!--       The interpolation. Add IF-condition here: IF not vertical nesting
-          IF ( nest_bound_l )  THEN   !  Left border pe
-             CALL pmci_interp_tril_lr( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo, r2yo, r1zo, r2zo,          &
-                                       nzb_u_inner, logc_u_l, logc_ratio_u_l, nzt_topo_nestbc_l, 'l', 'u' )
-             CALL pmci_interp_tril_lr( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv, r2yv, r1zo, r2zo,          &
-                                       nzb_v_inner, logc_v_l, logc_ratio_v_l, nzt_topo_nestbc_l, 'l', 'v' )
-             CALL pmci_interp_tril_lr( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo, r2yo, r1zw, r2zw,          &
-                                       nzb_w_inner, logc_w_l, logc_ratio_w_l, nzt_topo_nestbc_l, 'l', 'w' )
-             CALL pmci_interp_tril_lr( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,          &
-                                       nzb_s_inner, logc_u_l, logc_ratio_u_l, nzt_topo_nestbc_l, 'l', 'e' )
-             CALL pmci_interp_tril_lr( pt, ptc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,          &
-                                       nzb_s_inner, logc_u_l, logc_ratio_u_l, nzt_topo_nestbc_l, 'l', 's' )
-             IF ( humidity  .OR.  passive_scalar )  THEN
-                CALL pmci_interp_tril_lr( q, qc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,         &
-                                          nzb_s_inner, logc_u_l, logc_ratio_u_l, nzt_topo_nestbc_l, 'l', 's' )
-             ENDIF
-             IF ( nesting_mode == 'one-way' )  THEN
-                CALL pmci_extrap_ifoutflow_lr( u, nzb_u_inner, 'l', 'u' )
-                CALL pmci_extrap_ifoutflow_lr( v, nzb_v_inner, 'l', 'v' )
-                CALL pmci_extrap_ifoutflow_lr( w, nzb_w_inner, 'l', 'w' )
-                CALL pmci_extrap_ifoutflow_lr( e, nzb_s_inner, 'l', 'e' )
-                CALL pmci_extrap_ifoutflow_lr( pt,nzb_s_inner, 'l', 's' )
-                IF ( humidity  .OR.  passive_scalar )  THEN
-                   CALL pmci_extrap_ifoutflow_lr( q, nzb_s_inner, 'l', 's' )
-                ENDIF
-             ENDIF
-          ENDIF
-          IF ( nest_bound_r )  THEN   !  Right border pe
-             CALL pmci_interp_tril_lr( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo, r2yo, r1zo, r2zo,          &
-                                       nzb_u_inner, logc_u_r, logc_ratio_u_r, nzt_topo_nestbc_r, 'r', 'u' )
-             CALL pmci_interp_tril_lr( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv, r2yv, r1zo, r2zo,          &
-                                       nzb_v_inner, logc_v_r, logc_ratio_v_r, nzt_topo_nestbc_r, 'r', 'v' )
-             CALL pmci_interp_tril_lr( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo, r2yo, r1zw, r2zw,          &
-                                       nzb_w_inner, logc_w_r, logc_ratio_w_r, nzt_topo_nestbc_r, 'r', 'w' )
-             CALL pmci_interp_tril_lr( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,          &
-                                       nzb_s_inner, logc_u_r, logc_ratio_u_r, nzt_topo_nestbc_r, 'r', 'e' )
-             CALL pmci_interp_tril_lr( pt, ptc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,          &
-                                       nzb_s_inner, logc_u_r, logc_ratio_u_r, nzt_topo_nestbc_r, 'r', 's' )
-             IF ( humidity  .OR.  passive_scalar )  THEN
-                CALL pmci_interp_tril_lr( q, qc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,         &
-                                          nzb_s_inner, logc_u_r, logc_ratio_u_r, nzt_topo_nestbc_r, 'r', 's' )
-             ENDIF
-             IF ( nesting_mode == 'one-way' )  THEN
-                CALL pmci_extrap_ifoutflow_lr( u, nzb_u_inner, 'r', 'u' )
-                CALL pmci_extrap_ifoutflow_lr( v, nzb_v_inner, 'r', 'v' )
-                CALL pmci_extrap_ifoutflow_lr( w, nzb_w_inner, 'r', 'w' )
-                CALL pmci_extrap_ifoutflow_lr( e, nzb_s_inner, 'r', 'e' )
-                CALL pmci_extrap_ifoutflow_lr( pt,nzb_s_inner, 'r', 's' )
-                IF ( humidity  .OR.  passive_scalar )  THEN
-                   CALL pmci_extrap_ifoutflow_lr( q, nzb_s_inner, 'r', 's' )
-                ENDIF
-             ENDIF
-          ENDIF
-          IF ( nest_bound_s )  THEN   !  South border pe
-             CALL pmci_interp_tril_sn( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo, r2yo, r1zo, r2zo,          &
-                                       nzb_u_inner, logc_u_s, logc_ratio_u_s, nzt_topo_nestbc_s, 's', 'u' )
-             CALL pmci_interp_tril_sn( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv, r2yv, r1zo, r2zo,          &
-                                       nzb_v_inner, logc_v_s, logc_ratio_v_s, nzt_topo_nestbc_s, 's', 'v' )
-             CALL pmci_interp_tril_sn( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo, r2yo, r1zw, r2zw,          &
-                                       nzb_w_inner, logc_w_s, logc_ratio_w_s, nzt_topo_nestbc_s, 's', 'w' )
-             CALL pmci_interp_tril_sn( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,          &
-                                       nzb_s_inner, logc_u_s, logc_ratio_u_s, nzt_topo_nestbc_s, 's', 'e' )
-             CALL pmci_interp_tril_sn( pt, ptc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,          &
-                                       nzb_s_inner, logc_u_s, logc_ratio_u_s, nzt_topo_nestbc_s, 's', 's' )
-             IF ( humidity  .OR.  passive_scalar )  THEN
-                CALL pmci_interp_tril_sn( q, qc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,         &
-                                          nzb_s_inner, logc_u_s, logc_ratio_u_s, nzt_topo_nestbc_s, 's', 's' )
-             ENDIF
-             IF ( nesting_mode == 'one-way' )  THEN
-                CALL pmci_extrap_ifoutflow_sn( u, nzb_u_inner, 's', 'u' )
-                CALL pmci_extrap_ifoutflow_sn( v, nzb_v_inner, 's', 'v' )
-                CALL pmci_extrap_ifoutflow_sn( w, nzb_w_inner, 's', 'w' )
-                CALL pmci_extrap_ifoutflow_sn( e, nzb_s_inner, 's', 'e' )
-                CALL pmci_extrap_ifoutflow_sn( pt,nzb_s_inner, 's', 's' )
-                IF ( humidity  .OR.  passive_scalar )  THEN
-                   CALL pmci_extrap_ifoutflow_sn( q, nzb_s_inner, 's', 's' )
-                ENDIF
-             ENDIF
-          ENDIF
-          IF ( nest_bound_n )  THEN   !  North border pe
-             CALL pmci_interp_tril_sn( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo, r2yo, r1zo, r2zo,          &
-                                       nzb_u_inner, logc_u_n, logc_ratio_u_n, nzt_topo_nestbc_n, 'n', 'u' )
-             CALL pmci_interp_tril_sn( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv, r2yv, r1zo, r2zo,          &
-                                       nzb_v_inner, logc_v_n, logc_ratio_v_n, nzt_topo_nestbc_n, 'n', 'v' )
-             CALL pmci_interp_tril_sn( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo, r2yo, r1zw, r2zw,          &
-                                       nzb_w_inner, logc_w_n, logc_ratio_w_n, nzt_topo_nestbc_n, 'n', 'w' )
-             CALL pmci_interp_tril_sn( e,  ec,  ico,jco,kco,r1xo,r2xo,r1yo,r2yo,r1zo,r2zo,                  &
-                                       nzb_s_inner, logc_u_n, logc_ratio_u_n, nzt_topo_nestbc_n, 'n', 'e' )
-             CALL pmci_interp_tril_sn( pt, ptc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,          &
-                                       nzb_s_inner, logc_u_n, logc_ratio_u_n, nzt_topo_nestbc_n, 'n', 's' )
-             IF ( humidity  .OR.  passive_scalar )  THEN
-                CALL pmci_interp_tril_sn( q, qc, ico,jco,kco,r1xo,r2xo,r1yo,r2yo,r1zo,r2zo,                 &
-                                          nzb_s_inner, logc_u_n, logc_ratio_u_n, nzt_topo_nestbc_n, 'n', 's' )
-             ENDIF
-             IF ( nesting_mode == 'one-way' )  THEN             
-                CALL pmci_extrap_ifoutflow_sn( u, nzb_u_inner, 'n', 'u' )
-                CALL pmci_extrap_ifoutflow_sn( v, nzb_v_inner, 'n', 'v' )
-                CALL pmci_extrap_ifoutflow_sn( w, nzb_w_inner, 'n', 'w' )
-                CALL pmci_extrap_ifoutflow_sn( e, nzb_s_inner, 'n', 'e' )
-                CALL pmci_extrap_ifoutflow_sn( pt,nzb_s_inner, 'n', 's' )
-                IF ( humidity  .OR.  passive_scalar )  THEN
-                   CALL pmci_extrap_ifoutflow_sn( q, nzb_s_inner, 'n', 's' )
-                ENDIF
-             ENDIF
-          ENDIF
-
-!
-!--       All PEs are top-border PEs
-          CALL pmci_interp_tril_t( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo, r2yo, r1zo, r2zo, 'u' )
-          CALL pmci_interp_tril_t( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv, r2yv, r1zo, r2zo, 'v' )
-          CALL pmci_interp_tril_t( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo, r2yo, r1zw, r2zw, 'w' )
-          CALL pmci_interp_tril_t( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo, 'e' )
-          CALL pmci_interp_tril_t( pt, ptc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo, 's' )
-          IF ( humidity  .OR.  passive_scalar )  THEN
-             CALL pmci_interp_tril_t( q, qc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo, 's' )
-          ENDIF
-          IF ( nesting_mode == 'one-way' )  THEN
-             CALL pmci_extrap_ifoutflow_t( u,  'u' )
-             CALL pmci_extrap_ifoutflow_t( v,  'v' )
-             CALL pmci_extrap_ifoutflow_t( w,  'w' )
-             CALL pmci_extrap_ifoutflow_t( e,  'e' )
-             CALL pmci_extrap_ifoutflow_t( pt, 's' )
-             IF ( humidity  .OR.  passive_scalar )  THEN
-                CALL pmci_extrap_ifoutflow_t( q, 's' )
-             ENDIF
-          ENDIF
-       ELSE    !  IF ( direction == server_to_client ) 
-          CALL pmci_anterp_tophat( u,  uc,  kceu, iflu, ifuu, jflo, jfuo, kflo, kfuo, nzb_u_inner, 'u' )
-          CALL pmci_anterp_tophat( v,  vc,  kceu, iflo, ifuo, jflv, jfuv, kflo, kfuo, nzb_v_inner, 'v' )
-          CALL pmci_anterp_tophat( w,  wc,  kcew, iflo, ifuo, jflo, jfuo, kflw, kfuw, nzb_w_inner, 'w' )
-          CALL pmci_anterp_tophat( pt, ptc, kceu, iflo, ifuo, jflo, jfuo, kflo, kfuo, nzb_s_inner, 's' )
-          IF ( humidity  .OR.  passive_scalar )  THEN
-             CALL pmci_anterp_tophat( q, qc, kceu, iflo, ifuo, jflo, jfuo, kflo, kfuo, nzb_s_inner, 's' )
-          ENDIF
+          CALL pmci_interpolation
+
+       ELSE    !  IF ( direction == server_to_client )
+
+          CALL pmci_anterpolation
+
           CALL cpu_log( log_point_s(74), 'PMC Client Send', 'start' )
           CALL pmc_c_putbuffer( WaitTime = WaitTime )
@@ -2539,6 +2401,160 @@
        ENDIF
     ENDIF
-    
+
  CONTAINS
+
+
+   SUBROUTINE pmci_interpolation
+
+!
+!--   A wrapper routine for all interpolation and extrapolation actions.
+      IMPLICIT NONE
+
+!
+!--   Add IF-condition here: IF not vertical nesting
+      IF ( nest_bound_l )  THEN   !  Left border pe
+         CALL pmci_interp_tril_lr( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo, r2yo, r1zo, r2zo,          &
+                                   nzb_u_inner, logc_u_l, logc_ratio_u_l, nzt_topo_nestbc_l, 'l', 'u' )
+         CALL pmci_interp_tril_lr( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv, r2yv, r1zo, r2zo,          &
+                                   nzb_v_inner, logc_v_l, logc_ratio_v_l, nzt_topo_nestbc_l, 'l', 'v' )
+         CALL pmci_interp_tril_lr( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo, r2yo, r1zw, r2zw,          &
+                                   nzb_w_inner, logc_w_l, logc_ratio_w_l, nzt_topo_nestbc_l, 'l', 'w' )
+         CALL pmci_interp_tril_lr( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,          &
+                                   nzb_s_inner, logc_u_l, logc_ratio_u_l, nzt_topo_nestbc_l, 'l', 'e' )
+         CALL pmci_interp_tril_lr( pt, ptc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,          &
+                                   nzb_s_inner, logc_u_l, logc_ratio_u_l, nzt_topo_nestbc_l, 'l', 's' )
+         IF ( humidity  .OR.  passive_scalar )  THEN
+            CALL pmci_interp_tril_lr( q, qc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,         &
+                                      nzb_s_inner, logc_u_l, logc_ratio_u_l, nzt_topo_nestbc_l, 'l', 's' )
+         ENDIF
+         IF ( nesting_mode == 'one-way' )  THEN
+            CALL pmci_extrap_ifoutflow_lr( u, nzb_u_inner, 'l', 'u' )
+            CALL pmci_extrap_ifoutflow_lr( v, nzb_v_inner, 'l', 'v' )
+            CALL pmci_extrap_ifoutflow_lr( w, nzb_w_inner, 'l', 'w' )
+            CALL pmci_extrap_ifoutflow_lr( e, nzb_s_inner, 'l', 'e' )
+            CALL pmci_extrap_ifoutflow_lr( pt,nzb_s_inner, 'l', 's' )
+            IF ( humidity  .OR.  passive_scalar )  THEN
+               CALL pmci_extrap_ifoutflow_lr( q, nzb_s_inner, 'l', 's' )
+            ENDIF
+         ENDIF
+      ENDIF
+      IF ( nest_bound_r )  THEN   !  Right border pe
+         CALL pmci_interp_tril_lr( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo, r2yo, r1zo, r2zo,          &
+                                   nzb_u_inner, logc_u_r, logc_ratio_u_r, nzt_topo_nestbc_r, 'r', 'u' )
+         CALL pmci_interp_tril_lr( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv, r2yv, r1zo, r2zo,          &
+                                   nzb_v_inner, logc_v_r, logc_ratio_v_r, nzt_topo_nestbc_r, 'r', 'v' )
+         CALL pmci_interp_tril_lr( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo, r2yo, r1zw, r2zw,          &
+                                   nzb_w_inner, logc_w_r, logc_ratio_w_r, nzt_topo_nestbc_r, 'r', 'w' )
+         CALL pmci_interp_tril_lr( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,          &
+                                   nzb_s_inner, logc_u_r, logc_ratio_u_r, nzt_topo_nestbc_r, 'r', 'e' )
+         CALL pmci_interp_tril_lr( pt, ptc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,          &
+                                   nzb_s_inner, logc_u_r, logc_ratio_u_r, nzt_topo_nestbc_r, 'r', 's' )
+         IF ( humidity  .OR.  passive_scalar )  THEN
+            CALL pmci_interp_tril_lr( q, qc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,         &
+                                      nzb_s_inner, logc_u_r, logc_ratio_u_r, nzt_topo_nestbc_r, 'r', 's' )
+         ENDIF
+         IF ( nesting_mode == 'one-way' )  THEN
+            CALL pmci_extrap_ifoutflow_lr( u, nzb_u_inner, 'r', 'u' )
+             CALL pmci_extrap_ifoutflow_lr( v, nzb_v_inner, 'r', 'v' )
+             CALL pmci_extrap_ifoutflow_lr( w, nzb_w_inner, 'r', 'w' )
+             CALL pmci_extrap_ifoutflow_lr( e, nzb_s_inner, 'r', 'e' )
+             CALL pmci_extrap_ifoutflow_lr( pt,nzb_s_inner, 'r', 's' )
+             IF ( humidity  .OR.  passive_scalar )  THEN
+                CALL pmci_extrap_ifoutflow_lr( q, nzb_s_inner, 'r', 's' )
+             ENDIF
+          ENDIF
+       ENDIF
+       IF ( nest_bound_s )  THEN   !  South border pe
+          CALL pmci_interp_tril_sn( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo, r2yo, r1zo, r2zo,          &
+                                    nzb_u_inner, logc_u_s, logc_ratio_u_s, nzt_topo_nestbc_s, 's', 'u' )
+          CALL pmci_interp_tril_sn( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv, r2yv, r1zo, r2zo,          &
+                                    nzb_v_inner, logc_v_s, logc_ratio_v_s, nzt_topo_nestbc_s, 's', 'v' )
+          CALL pmci_interp_tril_sn( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo, r2yo, r1zw, r2zw,          &
+                                    nzb_w_inner, logc_w_s, logc_ratio_w_s, nzt_topo_nestbc_s, 's', 'w' )
+          CALL pmci_interp_tril_sn( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,          &
+                                    nzb_s_inner, logc_u_s, logc_ratio_u_s, nzt_topo_nestbc_s, 's', 'e' )
+          CALL pmci_interp_tril_sn( pt, ptc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,          &
+                                    nzb_s_inner, logc_u_s, logc_ratio_u_s, nzt_topo_nestbc_s, 's', 's' )
+          IF ( humidity  .OR.  passive_scalar )  THEN
+             CALL pmci_interp_tril_sn( q, qc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,         &
+                                       nzb_s_inner, logc_u_s, logc_ratio_u_s, nzt_topo_nestbc_s, 's', 's' )
+          ENDIF
+          IF ( nesting_mode == 'one-way' )  THEN
+             CALL pmci_extrap_ifoutflow_sn( u, nzb_u_inner, 's', 'u' )
+             CALL pmci_extrap_ifoutflow_sn( v, nzb_v_inner, 's', 'v' )
+             CALL pmci_extrap_ifoutflow_sn( w, nzb_w_inner, 's', 'w' )
+             CALL pmci_extrap_ifoutflow_sn( e, nzb_s_inner, 's', 'e' )
+             CALL pmci_extrap_ifoutflow_sn( pt,nzb_s_inner, 's', 's' )
+             IF ( humidity  .OR.  passive_scalar )  THEN
+                CALL pmci_extrap_ifoutflow_sn( q, nzb_s_inner, 's', 's' )
+             ENDIF
+          ENDIF
+       ENDIF
+       IF ( nest_bound_n )  THEN   !  North border pe
+          CALL pmci_interp_tril_sn( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo, r2yo, r1zo, r2zo,          &
+                                    nzb_u_inner, logc_u_n, logc_ratio_u_n, nzt_topo_nestbc_n, 'n', 'u' )
+          CALL pmci_interp_tril_sn( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv, r2yv, r1zo, r2zo,          &
+                                    nzb_v_inner, logc_v_n, logc_ratio_v_n, nzt_topo_nestbc_n, 'n', 'v' )
+          CALL pmci_interp_tril_sn( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo, r2yo, r1zw, r2zw,          &
+                                    nzb_w_inner, logc_w_n, logc_ratio_w_n, nzt_topo_nestbc_n, 'n', 'w' )
+          CALL pmci_interp_tril_sn( e,  ec,  ico,jco,kco,r1xo,r2xo,r1yo,r2yo,r1zo,r2zo,                  &
+                                    nzb_s_inner, logc_u_n, logc_ratio_u_n, nzt_topo_nestbc_n, 'n', 'e' )
+          CALL pmci_interp_tril_sn( pt, ptc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo,          &
+                                    nzb_s_inner, logc_u_n, logc_ratio_u_n, nzt_topo_nestbc_n, 'n', 's' )
+          IF ( humidity  .OR.  passive_scalar )  THEN
+             CALL pmci_interp_tril_sn( q, qc, ico,jco,kco,r1xo,r2xo,r1yo,r2yo,r1zo,r2zo,                 &
+                                       nzb_s_inner, logc_u_n, logc_ratio_u_n, nzt_topo_nestbc_n, 'n', 's' )
+          ENDIF
+          IF ( nesting_mode == 'one-way' )  THEN
+             CALL pmci_extrap_ifoutflow_sn( u, nzb_u_inner, 'n', 'u' )
+             CALL pmci_extrap_ifoutflow_sn( v, nzb_v_inner, 'n', 'v' )
+             CALL pmci_extrap_ifoutflow_sn( w, nzb_w_inner, 'n', 'w' )
+             CALL pmci_extrap_ifoutflow_sn( e, nzb_s_inner, 'n', 'e' )
+             CALL pmci_extrap_ifoutflow_sn( pt,nzb_s_inner, 'n', 's' )
+             IF ( humidity  .OR.  passive_scalar )  THEN
+                CALL pmci_extrap_ifoutflow_sn( q, nzb_s_inner, 'n', 's' )
+             ENDIF
+          ENDIF
+      ENDIF
+
+!
+!--   All PEs are top-border PEs
+       CALL pmci_interp_tril_t( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo, r2yo, r1zo, r2zo, 'u' )
+       CALL pmci_interp_tril_t( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv, r2yv, r1zo, r2zo, 'v' )
+       CALL pmci_interp_tril_t( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo, r2yo, r1zw, r2zw, 'w' )
+       CALL pmci_interp_tril_t( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo, 'e' )
+       CALL pmci_interp_tril_t( pt, ptc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo, 's' )
+       IF ( humidity  .OR.  passive_scalar )  THEN
+          CALL pmci_interp_tril_t( q, qc, ico, jco, kco, r1xo, r2xo, r1yo, r2yo, r1zo, r2zo, 's' )
+       ENDIF
+       IF ( nesting_mode == 'one-way' )  THEN
+          CALL pmci_extrap_ifoutflow_t( u,  'u' )
+          CALL pmci_extrap_ifoutflow_t( v,  'v' )
+          CALL pmci_extrap_ifoutflow_t( w,  'w' )
+          CALL pmci_extrap_ifoutflow_t( e,  'e' )
+          CALL pmci_extrap_ifoutflow_t( pt, 's' )
+          IF ( humidity  .OR.  passive_scalar )  THEN
+             CALL pmci_extrap_ifoutflow_t( q, 's' )
+          ENDIF
+      ENDIF
+   END SUBROUTINE pmci_interpolation
+
+
+
+   SUBROUTINE pmci_anterpolation
+
+!
+!--   A wrapper routine for all anterpolation actions.
+      IMPLICIT NONE
+
+      CALL pmci_anterp_tophat( u,  uc,  kceu, iflu, ifuu, jflo, jfuo, kflo, kfuo, nzb_u_inner, 'u' )
+      CALL pmci_anterp_tophat( v,  vc,  kceu, iflo, ifuo, jflv, jfuv, kflo, kfuo, nzb_v_inner, 'v' )
+      CALL pmci_anterp_tophat( w,  wc,  kcew, iflo, ifuo, jflo, jfuo, kflw, kfuw, nzb_w_inner, 'w' )
+      CALL pmci_anterp_tophat( pt, ptc, kceu, iflo, ifuo, jflo, jfuo, kflo, kfuo, nzb_s_inner, 's' )
+      IF ( humidity  .OR.  passive_scalar )  THEN
+         CALL pmci_anterp_tophat( q, qc, kceu, iflo, ifuo, jflo, jfuo, kflo, kfuo, nzb_s_inner, 's' )
+      ENDIF
+
+   END SUBROUTINE pmci_anterpolation
 
 
