# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"
module causint
! causal integration
  use adj_mod
implicit none
  contains
  function causint_lop ( adj, add, xx, yy) result(stat)
    integer :: stat
    logical,intent(in) :: adj,add
    real,dimension(:) :: xx,yy
    call adjnull (adj,add,xx,yy )
    call causint_lop2(adj,add,xx,yy )
    stat=0
  end function
  subroutine causint_lop2(adj,add,xx,yy)
    logical,intent(in) :: adj,add
    real, dimension (:) :: xx
    real, dimension (:) :: yy
    integer i, n
    real t
    n = size (xx)
    t = 0.
    if ( adj) then
      do i= n, 1, -1
        t = t + yy(i)
        xx(i) = xx(i) + t
      end do
    else
      do i= 1, n
        t = t + xx(i)
        yy(i) = yy(i) + t
      end do
    end if
  end subroutine
  subroutine causint_close()
  end subroutine
end module
