FIXME : Add documentation
returns results to PE 0 [or to all processors if 'all' is present in input arg list] NOTE: Takes f = f(x, y, z, sigma, lambda, E, species) and returns int f, where the integral is over x-y space
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex, | intent(in), | dimension (-ntgrid:,:,g_lo%llim_proc:) | :: | g | ||
complex, | intent(out), | dimension (-ntgrid:,:,:,:,:) | :: | total | ||
integer, | intent(in), | optional | :: | all |
subroutine integrate_volume_c (g, total, all)
use theta_grid, only: ntgrid
use kt_grids, only: aky
use gs2_layouts, only: g_lo, is_idx, ik_idx, ie_idx, il_idx
use mp, only: nproc, sum_reduce, sum_allreduce
use warning_helpers, only: is_zero
implicit none
complex, dimension (-ntgrid:,:,g_lo%llim_proc:), intent (in) :: g
complex, dimension (-ntgrid:,:,:,:,:), intent (out) :: total
integer, optional, intent(in) :: all
real :: fac
integer :: is, il, ie, ik, iglo, isgn
!Initialise to zero
total = 0.
!Do integral over local x-y space
do iglo = g_lo%llim_proc, g_lo%ulim_proc
ik = ik_idx(g_lo,iglo)
ie = ie_idx(g_lo,iglo)
is = is_idx(g_lo,iglo)
il = il_idx(g_lo,iglo)
!Pick the weighting factor
if (is_zero(aky(ik))) then
fac = 1.0
else
fac = 0.5
end if
!For both signs of vpar do sum
!May be more efficient to move ign loop above iglo loop (good for total but bad for g memory access)
do isgn = 1, 2
total(:, il, ie, isgn, is) = total(:, il, ie, isgn, is) + &
fac*g(:,isgn,iglo)
end do
end do
!Do we really need this if statement?
if (nproc > 1) then
if (present(all)) then
call sum_allreduce (total)
else
call sum_reduce (total, 0)
end if
end if
end subroutine integrate_volume_c