subroutine interpolate_data(childptr,drc)
!---------------------------------------------------------------------------
! interpolation 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 for all
! grid functions defined in GF3TL 
!---------------------------------------------------------------------------

! VERSION for TRANSPORT demo

use types
use amr
type(ADAPTIVE_MESH), pointer     :: childptr
real(SP), dimension(3)           :: drc   !dr of child

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


! interpolate amplitudes at time level 1
! even though ampl is defined on two levels, we do not have to
! interpolate the retarded values

INTERFACE
      subroutine interpolate(childgrid,order,dim,refinerat,xx,yy,zz)
      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     
      end subroutine interpolate
END INTERFACE



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

! first transfer 'node' data from parent to child

!only tlev=1 is implemented
do nfunc=1,ninterp
 call coarse_to_fine(childptr,what(i),rho)
 call interpolate(childptr%grid%gfcn(what(i))%tlev(1)%data,order,dim,rho, &
                  childptr%grid%c(1)%coord,childptr%grid%c(2)%coord, &
                  childptr%grid%c(3)%coord)
enddo

write(6,*) childptr%grid%gfcn(AMPL)%tlev(1)%data(2,1:9,1)
! ESTRE does not require interpolation; it is set to zero by ctrest anyway
! there is no more grind functions defined

return
end subroutine interpolate_data






