subroutine get_vec_advect(igrid,x,tloc,var,ibeg,iend)
use mod_global_parameters
integer,intent(in) :: igrid, ibeg, iend
double precision,dimension(ndir), intent(in) :: x
double precision, intent(in) :: tloc
double precision,dimension(iend-ibeg+1), intent(out) :: var
double precision,dimension(iend-ibeg+1) :: e1, e2
integer :: ivar, iloc
double precision :: td
if(.not.time_advance) then
do ivar=ibeg,iend
iloc = ivar-ibeg+1
call interpolate_var(igrid,ixGlo1,ixGlo2,ixGlo3,ixGhi1,ixGhi2,ixGhi3,&
ixMlo1,ixMlo2,ixMlo3,ixMhi1,ixMhi2,ixMhi3,&
gridvars(igrid)%w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,ivar),&
ps(igrid)%x(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,1:ndim),x,&
var(iloc))
end do
else
td = (tloc - global_time) / dt
do ivar=ibeg,iend
iloc = ivar-ibeg+1
call interpolate_var(igrid,ixGlo1,ixGlo2,ixGlo3,ixGhi1,ixGhi2,ixGhi3,&
ixMlo1,ixMlo2,ixMlo3,ixMhi1,ixMhi2,ixMhi3,&
gridvars(igrid)%wold(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,&
ivar),ps(igrid)%x(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,1:ndim),&
x,e1(iloc))
call interpolate_var(igrid,ixGlo1,ixGlo2,ixGlo3,ixGhi1,ixGhi2,ixGhi3,&
ixMlo1,ixMlo2,ixMlo3,ixMhi1,ixMhi2,ixMhi3,&
gridvars(igrid)%w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,ivar),&
ps(igrid)%x(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,1:ndim),x,&
e2(iloc))
var(iloc) = e1(iloc) * (1.0d0 - td) + e2(iloc) * td
end do
end if
end subroutine get_vec_advect