subroutine set_up_coarse_grid(npath,otl,params,sort_orderi,cabc,sortpayoff, &
                              sortpayoffc,sort_orderc,sort_orderci,etac)
  use PATHS
  use MOD_INT
  use input_params
  implicit none


  real*8,dimension(:)                            :: params
  integer,intent(IN)                             :: npath, otl
  integer,dimension(:,:),intent(OUT)             :: sort_orderi
  integer,dimension(:,:),intent(OUT)             :: sort_orderci,sort_orderc
  real*8,dimension(:,:),intent(IN)               :: sortpayoff
  real*8,dimension(:,:),intent(OUT)              :: sortpayoffc
  real*8,dimension(:),intent(IN)                 :: cabc
  type (PATH),dimension(:,:),intent(INOUT)       :: etac



  integer,dimension(:),allocatable               :: index
  integer                                        :: i,ic,j



  index = sort_orderi(otl,:)

! all of the other times before otl will not matter for the payoff!
  do j = otl, int(params(P_NTIME))
    ic = 0
     do i = 1, npath, 2 !npath is the number of paths on the fine grid
      ic = ic + 1
      sortpayoffc(j,ic) = sortpayoff(j,index(i))
      sort_orderc(j,ic) = index(i)
      sort_orderci(j,sort_orderc(j,ic)) =  ic
    end do !i
  end do !j
! now work on the eta's 
! note: I do not know how to set the eta's since I might set it from the
! fine grid, or I might set it from previous coarse grids, but I must
! set the etas on all time slices above the otl

  do j = otl+1,int(params(P_NTIME))
    etac(j,:)%spin = 0
    do i = 1, int((1+npath)/2)
      if (sortpayoffc(j,i).ge.cabc(j)) then
        etac(j,i)%spin = 1
      end if
    end do!j
  end do !j

end subroutine set_up_coarse_grid
