FIXME : Add documentation
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | ig | |||
integer, | intent(in) | :: | ifield | |||
complex, | intent(inout), | dimension(:,f_lo(ic)%llim_proc:) | :: | am | ||
integer, | intent(in) | :: | ic | |||
integer, | intent(in) | :: | n |
subroutine init_response_row (ig, ifield, am, ic, n)
use fields_arrays, only: phi, apar, bpar, phinew, aparnew, bparnew
use theta_grid, only: ntgrid
use dist_fn, only: getfieldeq, timeadv
use dist_fn_arrays, only: fieldeq, fieldeqa, fieldeqp
use run_parameters, only: has_phi, has_apar, has_bpar
use gs2_layouts, only: f_lo, idx, idx_local
implicit none
integer, intent (in) :: ig, ifield, ic, n
complex, dimension(:,f_lo(ic)%llim_proc:), intent (in out) :: am
integer :: irow, istart, iflo, ik, it, ifin, m, nn
!Find response to delta function fields
!NOTE:Timeadv will loop over all iglo even though only one ik
!has any amplitude, this is quite a waste. Should ideally do all
!ik at once
!NOTE:We currently do each independent supercell of the same length
!together, this may not be so easy if we do all the ik together but it should
!be possible.
call timeadv (phi, apar, bpar, phinew, aparnew, bparnew, 0)
call getfieldeq (phinew, aparnew, bparnew, fieldeq, fieldeqa, fieldeqp)
!Loop over 2pi domains / cells
do nn = 1, N_class(ic)
!Loop over members of the current class (separate supercells/connected domains)
do m = 1, M_class(ic)
!Get corresponding it and ik indices
it = f_lo(ic)%it(m,nn)
ik = f_lo(ic)%ik(m,nn)
!Work out which row of the matrix we're looking at
!corresponds to iindex, i.e. which of the nindex points in the
!supercell we're looking at.
irow = ifield + nfield*((ig+ntgrid) + (2*ntgrid+1)*(n-1))
!Convert iindex and m to iflo index
iflo = idx (f_lo(ic), irow, m)
!If this is part of our local iflo range then store
!the response data
if (idx_local(f_lo(ic), iflo)) then
!Where abouts in the supercell does this 2pi*nfield section start
istart = 0 + nidx*(nn-1)
if (has_phi) then
ifin = istart + nidx
istart = istart + 1
am(istart:ifin:nfield,iflo) = fieldeq(:,it,ik)
end if
if (has_apar) then
ifin = istart + nidx
istart = istart + 1
am(istart:ifin:nfield,iflo) = fieldeqa(:,it,ik)
end if
if (has_bpar) then
ifin = istart + nidx
istart = istart + 1
am(istart:ifin:nfield,iflo) = fieldeqp(:,it,ik)
end if
end if
end do
end do
end subroutine init_response_row