Ensure that linked boundary values of passed complex field are single valued (e.g. kperp2(ntgrid,ikx,iky) is equal to kperp2(-ntgrid,ikx_link,iky) as these correspond to the same location).
itright(it, ik) == it for ky == 0 modes in the flux tube setup so this routine will also copy one periodic boundary value into the other one.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex, | intent(inout), | dimension (-ntgrid:,:,:) | :: | arr | ||
logical, | intent(in), | optional | :: | force_all |
subroutine ensure_single_val_fields_pass(arr, force_all)
use theta_grid, only: ntgrid
use gs2_layouts, only: g_lo
use optionals, only: get_option_with_default
use kt_grids, only: naky, ntheta0
implicit none
integer :: it, ik, link_it, ik_min, ik_max, it_min, it_max
complex, dimension (-ntgrid:,:,:), intent (in out) :: arr
logical, intent(in), optional :: force_all
logical :: force
if (boundary_option_switch /= boundary_option_linked) return
force = get_option_with_default(force_all, .false.)
if (force) then
ik_min = 1; ik_max = naky ; it_min = 1 ; it_max = ntheta0
else
ik_min = g_lo%ik_min; ik_max = g_lo%ik_max
it_min = g_lo%it_min; it_max = g_lo%it_max
end if
do ik = ik_min, ik_max
do it = it_min, it_max
link_it = itright(it, ik)
if (link_it < 0) cycle
arr(-ntgrid, link_it, ik) = arr(ntgrid, it, ik)
end do
end do
end subroutine ensure_single_val_fields_pass