ensure_single_val_fields_pass Subroutine

private subroutine ensure_single_val_fields_pass(arr, force_all)

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).

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:,:,:) :: arr
logical, intent(in), optional :: force_all

Contents


Source Code

  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