subroutine grid_step(grid,dt,dr,nr,gflb,gfrb)
!----------------------------------------------------------------
! this is a wrapper routine to user supplied update functions
! 
!NOTE: user routines in this context require explicit interface
!      this is meant to be provided in the form of the f90
!      module called u_interface
!
!AUTHOR: Tom Haupt, NPAC at Syracusse University, haupt@npac.syr.edu
!-----------------------------------------------------------------

use types
use coord_param
use amr
use u_interface
type(GF3TL), pointer :: grid
real(SP)             :: dt
real(SP), dimension(3) :: dr
integer(I4B), dimension(3):: nr,gflb,gfrb

integer(I4B) igf,it 
real(SP) newt

!shift time levels: 1 is the most advanced
DO igf=1,grid%n_gfcn
   IF(grid%gfcn(igf)%n_t.eq.1) cycle
   DO it=grid%gfcn(igf)%n_t,2,-1
     grid%gfcn(igf)%tlev(it)%data=grid%gfcn(igf)%tlev(it-1)%data
     grid%gfcn(igf)%t(it)=grid%gfcn(igf)%t(it-1)
   ENDDO
ENDDO

t=grid%gfcn(1)%t(1) 
newt=grid%gfcn(1)%t(1)+dt

DO igf=1,grid%n_gfcn
   grid%gfcn(igf)%t(1)=newt
ENDDO




! driver for updates

! in TRANSPORT only AMPL grid function is to be updated

call update(grid%gfcn(ampl)%tlev(1)%data(:,:,1), &
            grid%gfcn(ampl)%tlev(2)%data(:,:,1), &
            t,dt,dr(1:2),nr(1),nr(2))

!  set boundaries 

call boundaries(grid%gfcn(ampl)%tlev(1)%data(:,:,1),gflb(1:2),gfrb(1:2),& 
                t,nr(1),nr(2))

return
end

