gradl Subroutine

private pure subroutine gradl(ltheta, f, dfdl, ext, n)

Compute df / dltheta using a periodic central difference. The input ext can be used to control the effective jump in f between both ends of the "periodic" grid.

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension (-ntgrid:) :: ltheta
real, intent(in), dimension (-ntgrid:) :: f
real, intent(out), dimension (-ntgrid:) :: dfdl
real, intent(in) :: ext
integer, intent(in) :: n

Contents

Source Code


Source Code

  pure subroutine gradl (ltheta, f, dfdl, ext, n)
    implicit none
    real, dimension (-ntgrid:), intent(in) :: ltheta, f
    real, dimension (-ntgrid:), intent(out) :: dfdl
    real, intent(in) :: ext
    integer, intent(in) :: n
    integer :: i
    dfdl(-n) = (f(n-1) + ext - f(-n+1)) / &
         (ltheta(n-1) - ltheta(-n+1) - ltheta(n) + ltheta(-n))
    do i = -n+1, n-1
       dfdl(i) = (f(i+1) - f(i-1)) / (ltheta(i+1) - ltheta(i-1))
    end do
    dfdl(n) = dfdl(-n)
  end subroutine gradl