subroutine imexQ_oc_spreadq0(this, lev, t0, flags, step)
class(pf_imexQ_oc_t), intent(inout) :: this
class(pf_level_t), intent(inout) :: lev
real(pfdp), intent(in ) :: t0
integer, optional, intent(in) :: flags, step
integer :: m, p, which, mystep
which = 3
if(present(flags)) which = flags
if (.not.present(flags)) stop "IMEXQ_OC SPREADQ0 WITHOUT FLAGS"
! print *, "IMEXQ_OC SPREADQ0", which
mystep = 1
if(present(step)) then
mystep = step !needed for sequential version
else
print *, "step not present in spreadq0", which
stop
end if
select case(which)
case(1)
! Stick initial condition into first node slot
call lev%Q(1)%copy(lev%q0, 1)
! Evaluate F at first spot
call lev%ulevel%sweeper%evaluate(lev, t0, 1, 1, mystep)
! Spread F and solution to all nodes
do m = 2, lev%nnodes
call lev%Q(m)%copy(lev%Q(1), 1)
do p = 1, lev%ulevel%sweeper%npieces
call lev%F(m,p)%copy(lev%F(1,p), 1)
end do
end do
case(2)
! Stick terminal condition into last node slot
call lev%Q(lev%nnodes)%copy(lev%qend, 2)
! Evaluate F at first spot
call lev%ulevel%sweeper%evaluate(lev, t0, lev%nnodes, 2, mystep)
! Spread F and solution to all nodes
do m = lev%nnodes-1, 1, -1
call lev%Q(m)%copy(lev%Q(lev%nnodes), 2)
do p = 1, lev%ulevel%sweeper%npieces
call lev%F(m,p)%copy(lev%F(lev%nnodes,p), 2)
end do
end do
case default
print *, "imexQ_oc_spreadq0 needs a flag", which
stop
end select
end subroutine imexQ_oc_spreadq0