subroutine impose_fine_boundaries(childptr)
!---------------------------------------------------------------------------
! interpolation (on boundary) driver: to be supplied by user
! given existing meshes on coarse (parentptr) and fine (childptr) levels
! data are transferred and interpolated to the fine level boundary for all
! grid functions defined in GF3TL 
!---------------------------------------------------------------------------

! VERSION for W3d

use types
use amr
type(ADAPTIVE_MESH), pointer     :: childptr

!local variables     
integer(I4B)             :: order,dim,rho


! interpolate at time level 1

INTERFACE
      subroutine interpolate_boundary(childgrid,order,dim,refinerat, &
                                      xx,yy,zz,nx,ny,nz)
      use types
      implicit none
     
      real(SP), dimension(:,:,:) :: childgrid
      integer(I4B)               :: order, dim, refinerat,no_of_planes
      integer(I4B)               :: i,j,k,no_of_cols,no_of_rows, err
      real(SP), dimension(:)     :: xx,yy,zz     
      integer(I4B)               :: nx,ny,nz
      end subroutine interpolate_boundary
END INTERFACE



dim=3      ! dimensionality of grid function (:,:,:)
order=1    ! order of interpolation 
rho=rcxshp ! refinement ratio

do i=phi,phiz
! first transfer 'node' data from parent to child
!write(*,*) 'impose_fine_bound: calling coarse_to_fine_boundary'
call coarse_to_fine_boundary(childptr,i,rho)
!write(*,*) 'impose_fine_bound: done with coarse_to_fine_boundary'

!write(*,*) 'impose_fine_bound: calling interpolate_boundary'
call interpolate_boundary(childptr%grid%gfcn(i)%tlev(1)%data,order,dim,rho, &
                  childptr%grid%c(1)%coord,childptr%grid%c(2)%coord, &
                  childptr%grid%c(3)%coord, &
                  childptr%grid%gfcn(i)%tlev(1)%ddim(1), &
                  childptr%grid%gfcn(i)%tlev(1)%ddim(2), &
                  childptr%grid%gfcn(i)%tlev(1)%ddim(3) )
!write(*,*) 'impose_fine_bound: done with interpolate_boundary'

enddo


! write(6,*)  childptr%grid%gfcn(AMPL)%tlev(2)%data(:,:,:), 'end'


! ESTRE does not require interpolation; it is set to zero by ctrest anyway
! there is no more grid functions defined

return
end subroutine impose_fine_boundaries










