periodic_copy Subroutine

private pure subroutine periodic_copy(a, ext, nperiod)

Copy the [-nth,nth] = [-pi,pi] section of the passed array into the theta > +/- pi parts, adding on k * ext (with k an integer labelling the sections/periods). Here we expect ext == array(nth) - array(-nth).

Arguments

Type IntentOptional Attributes Name
real, intent(inout), dimension(-ntgrid:) :: a
real, intent(in) :: ext
integer, intent(in) :: nperiod

Contents

Source Code


Source Code

  pure subroutine periodic_copy(a, ext, nperiod)
    implicit none
    real, dimension(-ntgrid:), intent(in out) :: a
    real, intent(in) :: ext
    integer, intent(in) :: nperiod
    integer :: i, k, itot, ntheta
    if (nperiod <= 1) return
    ! Note we end up enforcing a(nth)-a(-nth) = ext, but we should probably check this is
    ! also true on input to the routine
    ntheta = 2 * nth
    do k = -nperiod + 1, -1
       do i = -nth, nth
          itot = i + k * ntheta
          a(itot) = a(i) + k * ext
       end do
    end do

    do k = 1, nperiod - 1
       do i = -nth, nth
          itot = i + k * ntheta
          a(itot) = a(i) + k * ext
       end do
    end do
  end subroutine periodic_copy