integrate Subroutine

private pure subroutine integrate(arg, grid, ans, n)

Integrates arg(grid) from i = 0 (generally theta = 0) to either ends of the grid (usually +/- pi) storing the cumulative integral in the output ans.

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension(-ntgrid:) :: arg
real, intent(in), dimension(-ntgrid:) :: grid
real, intent(out), dimension(-ntgrid:) :: ans
integer, intent(in) :: n

Contents

Source Code


Source Code

  pure subroutine integrate(arg, grid, ans, n)
    real, dimension(-ntgrid:), intent (in) :: arg, grid
    real, dimension(-ntgrid:), intent (out) :: ans
    integer, intent(in) :: n
    integer :: i
    ans = 0.
    do i = 1, n
       ans(i) = ans(i-1) + 0.5 * (grid(i) - grid(i-1)) * (arg(i) + arg(i-1))
    end do
    do i = -1, -n, -1
       ans(i) = ans(i+1) + 0.5 * (grid(i) - grid(i+1)) * (arg(i) + arg(i+1))
    end do
  end subroutine integrate