      program adaptive_mesh
      use amr
      use dinterface

      type(LEVEL_INFO), dimension(maxlev) :: lp 
      type(GF3TL),pointer    :: grid
      character(200)         :: grid_name = 'test grid'
      real, dimension(3)   :: gmin,gmax,gd
      integer gid,curlev,finlev
      real  t
      integer, parameter     :: nsteps = 10 ! was 5
      real t3(1), t1(1), t2(1)

      INTERFACE 
      subroutine initialize_grid_functions(lp,level,t)
      use amr
      type(LEVEL_INFO), dimension(maxlev) :: lp 
      integer                             :: level
      real                              :: t 
      end subroutine initialize_grid_functions

      subroutine initialize_base_grid(lp,grid_name)
      use amr
      type(LEVEL_INFO), dimension(maxlev) :: lp 
      character(200)                      :: grid_name 
      end subroutine initialize_base_grid

      subroutine regrid(lp,curlev,finlev,first)
      use amr
      type(LEVEL_INFO), dimension(maxlev) :: lp
      integer curlev,finlev
      logical first
      end subroutine regrid       

      subroutine propagate(lp,crsstp,finlev)
      use amr
      type(LEVEL_INFO),dimension(maxlev) :: lp     
      integer crsstp,finlev    
      end subroutine propagate

      END INTERFACE 

!     start_timer
      t1(1) =secnds( 0.0)

      gid=get_g(-1)
      t=t_init
      curlev=1
      finlev=1  
      call initialize_level_info(lp)

!     test
      call print_level_info(lp)
 
      call initialize_base_grid(lp,grid_name)
      call initialize_grid_functions(lp,curlev,t)
cc      call regrid(lp,curlev,finlev,.true.)

      write(6,*) ' =========== END OF INITIALIZATION ============'

      call propagate(lp,nsteps,finlev)

      write(6,*) 'END OF PROGRAM'
!     stop_timer
      t2(1) = secnds(0.0)
       t3(1) = t2(1)-t1(1)
      print *,'time',t3(1),'seconds'
      stop
      end program

      subroutine initialize_base_grid(lp,grid_name)
      use amr
      type(LEVEL_INFO), dimension(maxlev) :: lp 
      character(200)                      :: grid_name 
   
      type(ADAPTIVE_MESH),pointer         :: ptr
      real xmin,xmax,ymin,ymax,zmin,zmax
      xmin=gxmin
      xmax=gxmax
      ymin=gymin
      ymax=gymax
      zmin=gzmin
      zmax=gzmax 
      level=1
      nullify(ptr)
      call initialize_grid(ptr,level,grid_name,xmin,ymin,zmin,
     &  xmax,ymax,zmax,lp(level)%ldr)
      lp(level)%ml=>ptr
      return
      end subroutine initialize_base_grid
 
























