      program main
      use types
      use parameters
      real(SP), dimension(119,119,119)::child
      real(SP), dimension(119)    :: xx,yy,zz
      integer(I4B)              :: order, dim, refinerat
      real t1(PX*PY), t2(PX*PY)

!HPF$ PROCESSORS P(PX,PY)
!HPF$ DISTRIBUTE (BLOCK,BLOCK,*) onto P :: child
!HPF$ ALIGN xx(:) with child(:,*,*)
!HPF$ ALIGN yy(:) with child(*,:,*)
!HPF$ ALIGN zz(:) with child(*,*,:)
!HPF$ DISTRIBUTE t1(BLOCK)
!HPF$ DISTRIBUTE t2(BLOCK)

      INTERFACE
      subroutine interpolate(childgrid,order,dim,refinerat,xx,yy,zz)
      use parameters
      use types
      implicit none
      real(SP), dimension(:,:,:) :: childgrid
      integer(I4B)               :: order, dim, refinerat
      real(SP), dimension(:)     :: xx,yy,zz 
!HPF$ PROCESSORS P(PX,PY)
!HPF$ DISTRIBUTE *(BLOCK,BLOCK,*) onto *P :: childgrid
!HPF$ ALIGN xx(:) with *childgrid(:,*,*)
!HPF$ ALIGN yy(:) with *childgrid(*,:,*)
!HPF$ ALIGN zz(:) with *childgrid(*,*,:)
      end subroutine interpolate

      extrinsic(hpf_local) subroutine timer(return_time, initial_time)
      real, dimension(:), intent(in)  :: initial_time
      real, dimension(:), intent(out) :: return_time
!HPF$ DISTRIBUTE *(block) :: initial_time
!HPF$ ALIGN return_time with initial_time
      end subroutine timer

      END INTERFACE

      
      forall(i=1:119) xx(i)=i
      forall(i=1:119) yy(i)=i
      forall(i=1:119) zz(i)=i

      order = 2
      dim = 3
      refinerat = 2
         
c      do k=1,13
c       do i=1,13
c        do j=1,13,3
c      child(i,j,k) = xx(i)*xx(i)*yy(j)*zz(k)
c         enddo
c        enddo
c      enddo

      forall(i=1:119,j=1:119,k=1:119:2) child(i,j,k)=
     &                            xx(i)*xx(i)*yy(j)*zz(k)
       

!      do k=1,13
!       do j=1,13
!        do i=1,13    
!      write(6,*) zz(k),yy(j),xx(i),child(i,j,k)
!        enddo
!       enddo
!      enddo
      
      write(6,*) 'calling interpolate'

      call timer(t2,t1)
      call interpolate(child,order,dim,refinerat,xx,yy,zz)

      call timer(t1,t2)
      print *,'time',t1,' seconds'
  
!      do k=1,10
!       do j=1,10
!        do i=1,10    
!          write(6,*) zz(k),yy(j),xx(i),child(i,j,k)
!        enddo
!       enddo
!      enddo
 
      end program
      

      extrinsic(hpf_local) subroutine timer(return_time, initial_time)
      real, dimension(:), intent(in)  :: initial_time
      real, dimension(:), intent(out) :: return_time

      return_time(lbound(return_time, 1)) =     
     &        secnds(initial_time(lbound(initial_time, 1)))

      end



















