Index: palm/trunk/SOURCE/pmc_interface_mod.f90
===================================================================
--- palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 1879)
+++ palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 1882)
@@ -20,5 +20,6 @@
 ! Current revisions:
 ! ------------------
-! 
+! The factor ijfc for nfc used in anterpolation is redefined as 2-D array 
+! and precomputed in pmci_init_anterp_tophat. 
 ! 
 ! Former revisions:
@@ -27,5 +28,5 @@
 !
 ! 1878 2016-04-19 12:30:36Z hellstea
-! Synchronization rewritten, logc-array index order changed for cache optimization 
+! Synchronization rewritten, logc-array index order changed for cache optimization
 !
 ! 1850 2016-04-08 13:29:27Z maronga
@@ -308,4 +309,11 @@
     INTEGER(iwp), SAVE, ALLOCATABLE, DIMENSION(:) ::  kfuo   !:
 
+!
+!-- Number of fine-grid nodes inside coarse-grid ij-faces
+!-- to be precomputed for anterpolation.
+    INTEGER(iwp), SAVE, ALLOCATABLE, DIMENSION(:,:) ::  ijfc_u        !:
+    INTEGER(iwp), SAVE, ALLOCATABLE, DIMENSION(:,:) ::  ijfc_v        !:
+    INTEGER(iwp), SAVE, ALLOCATABLE, DIMENSION(:,:) ::  ijfc_s        !:
+    
     INTEGER(iwp), DIMENSION(3)          ::  define_coarse_grid_int    !:
     REAL(wp), DIMENSION(7)              ::  define_coarse_grid_real   !:
@@ -2005,4 +2013,6 @@
 
        INTEGER(iwp) ::  i        !: Fine-grid index
+       INTEGER(iwp) ::  ifc_o    !:
+       INTEGER(iwp) ::  ifc_u    !:
        INTEGER(iwp) ::  ii       !: Coarse-grid index
        INTEGER(iwp) ::  istart   !:
@@ -2063,4 +2073,8 @@
        ALLOCATE( kfuo(0:kctu) )
 
+       ALLOCATE( ijfc_u(jcs:jcn,icl:icr) )
+       ALLOCATE( ijfc_v(jcs:jcn,icl:icr) )
+       ALLOCATE( ijfc_s(jcs:jcn,icl:icr) )
+
 !
 !--    i-indices of u for each ii-index value
@@ -2174,5 +2188,19 @@
           kstart = kflo(kk)
        ENDDO
-     
+ 
+!
+!--    Precomputation of number of fine-grid nodes inside coarse-grid ij-faces.
+!--    Note that ii, jj, and kk are coarse-grid indices. 
+!--    This information is needed in anterpolation.
+       DO  ii = icl, icr
+          ifc_u = ifuu(ii) - iflu(ii) + 1
+          ifc_o = ifuo(ii) - iflo(ii) + 1
+          DO  jj = jcs, jcn
+             ijfc_u(jj,ii) = ifc_u * ( jfuo(jj) - jflo(jj) + 1 )
+             ijfc_v(jj,ii) = ifc_o * ( jfuv(jj) - jflv(jj) + 1 )
+             ijfc_s(jj,ii) = ifc_o * ( jfuo(jj) - jflo(jj) + 1 )             
+          ENDDO
+       ENDDO
+    
 !
 !--    Spatial under-relaxation coefficients
@@ -3022,6 +3050,11 @@
  SUBROUTINE pmci_datatrans( local_nesting_mode )
 !
-!-- Althoug nesting_mode is a variable of this model, pass it as an argument to
-!-- allow for example to force one-way initialization phase
+!-- This subroutine controls the nesting according to the nestpar 
+!-- parameter nesting_mode (two-way (default) or one-way) and the 
+!-- order of anterpolations according to the nestpar parameter 
+!-- nesting_datatransfer_mode (cascade, overlap or mixed (default)).
+!-- Although nesting_mode is a variable of this model, pass it as 
+!-- an argument to allow for example to force one-way initialization 
+!-- phase.
 
     IMPLICIT NONE
@@ -3402,17 +3435,18 @@
 !
 !--   A wrapper routine for all anterpolation actions.
+!--   Note that TKE is not anterpolated.
       IMPLICIT NONE
 
       CALL pmci_anterp_tophat( u,  uc,  kctu, iflu, ifuu, jflo, jfuo, kflo,    &
-                               kfuo, 'u' )
+                               kfuo, ijfc_u, 'u' )
       CALL pmci_anterp_tophat( v,  vc,  kctu, iflo, ifuo, jflv, jfuv, kflo,    &
-                               kfuo, 'v' )
+                               kfuo, ijfc_v, 'v' )
       CALL pmci_anterp_tophat( w,  wc,  kctw, iflo, ifuo, jflo, jfuo, kflw,    &
-                               kfuw, 'w' )
+                               kfuw, ijfc_s, 'w' )
       CALL pmci_anterp_tophat( pt, ptc, kctu, iflo, ifuo, jflo, jfuo, kflo,    &
-                               kfuo, 's' )
+                               kfuo, ijfc_s, 's' )
       IF ( humidity  .OR.  passive_scalar )  THEN
          CALL pmci_anterp_tophat( q, qc, kctu, iflo, ifuo, jflo, jfuo, kflo,   &
-                                  kfuo, 's' )
+                                  kfuo, ijfc_s, 's' )
       ENDIF
 
@@ -4118,5 +4152,5 @@
 
     SUBROUTINE pmci_anterp_tophat( f, fc, kct, ifl, ifu, jfl, jfu, kfl, kfu,   &
-                                   var )
+                                   ijfc, var )
 !
 !--    Anterpolation of internal-node values to be used as the server-domain
@@ -4133,6 +4167,4 @@
        INTEGER(iwp) ::  iclp      !:
        INTEGER(iwp) ::  icrm      !:
-       INTEGER(iwp) ::  ifc       !:
-       INTEGER(iwp) ::  ijfc      !:
        INTEGER(iwp) ::  j         !: Fine-grid index
        INTEGER(iwp) ::  jj        !: Coarse-grid index
@@ -4153,4 +4185,5 @@
        INTEGER(iwp), DIMENSION(0:kct), INTENT(IN)   ::  kfu   !:
 
+       INTEGER(iwp), DIMENSION(jcs:jcn,icl:icr), INTENT(IN) ::  ijfc !:
 
        REAL(wp) ::  cellsum   !:
@@ -4197,14 +4230,14 @@
 
 !
-!--    Note that l,m, and n are coarse-grid indices and i,j, and k are fine-grid
-!--    indices.
+!--    Note that ii, jj, and kk are coarse-grid indices and i,j, and k 
+!--    are fine-grid indices.
        DO  ii = iclp, icrm
-          ifc = ifu(ii) - ifl(ii) + 1
           DO  jj = jcsp, jcnm
-             ijfc = ifc * ( jfu(jj) - jfl(jj) + 1 )
 !
 !--          For simplicity anterpolate within buildings too
              DO  kk = kcb, kct
-                nfc =  ijfc * ( kfu(kk) - kfl(kk) + 1 )
+!
+!--             ijfc is precomputed in pmci_init_anterp_tophat
+                nfc =  ijfc(jj,ii) * ( kfu(kk) - kfl(kk) + 1 )
                 cellsum = 0.0_wp
                 DO  i = ifl(ii), ifu(ii)
@@ -4225,7 +4258,5 @@
                    ENDIF
                 ENDIF
-!
-!--             TO DO: introduce 3-d coarse grid array for precomputed
-!--             1/REAL(nfc) values
+
                 fc(kk,jj,ii) = ( 1.0_wp - fra ) * fc(kk,jj,ii) +               &
                                fra * cellsum / REAL( nfc, KIND = wp )
