FIXME : Add documentation
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex, | intent(in), | dimension (-ntgrid:,:,g_lo%llim_proc:) | :: | g | ||
real, | intent(inout), | dimension (:) | :: | weights | ||
complex, | intent(out), | dimension (-ntgrid:,:,:) | :: | total |
subroutine integrate_species_original (g, weights, total)
use theta_grid, only: ntgrid
use gs2_layouts, only: g_lo
use gs2_layouts, only: is_idx, ik_idx, it_idx, ie_idx, il_idx
use kt_grids, only: kwork_filter
use mp, only: sum_allreduce
use species, only: tracer_species, spec
use array_utils, only: zero_array
implicit none
complex, dimension (-ntgrid:,:,g_lo%llim_proc:), intent (in) :: g
real, dimension (:), intent (in out) :: weights
complex, dimension (-ntgrid:,:,:), intent (out) :: total
integer :: is, il, ie, ik, it, iglo
!Ensure array is zero to begin
call zero_array(total)
where (spec%type == tracer_species) weights = 0
!Performed integral (weighted sum) over local velocity space and species
if(any(kwork_filter))then
!$OMP PARALLEL DO DEFAULT(none) &
!$OMP PRIVATE(iglo, it, ik, ie, il, is) &
!$OMP SHARED(g_lo, kwork_filter, weights, w, wl, g) &
!$OMP REDUCTION(+ : total) &
!$OMP SCHEDULE(static)
do iglo = g_lo%llim_proc, g_lo%ulim_proc
!Convert from iglo to the separate indices
ik = ik_idx(g_lo,iglo)
it = it_idx(g_lo,iglo)
if(kwork_filter(it,ik)) cycle
is = is_idx(g_lo,iglo)
ie = ie_idx(g_lo,iglo)
il = il_idx(g_lo,iglo)
!Sum up weighted g
total(:, it, ik) = total(:, it, ik) + &
(weights(is)*w(ie,is))*wl(:,il)*(g(:,1,iglo)+g(:,2,iglo))
end do
!$OMP END PARALLEL DO
else
!$OMP PARALLEL DO DEFAULT(none) &
!$OMP PRIVATE(iglo, it, ik, ie, il, is) &
!$OMP SHARED(g_lo, weights, w, wl, g) &
!$OMP REDUCTION(+ : total) &
!$OMP SCHEDULE(static)
do iglo = g_lo%llim_proc, g_lo%ulim_proc
!Convert from iglo to the separate indices
is = is_idx(g_lo,iglo)
ik = ik_idx(g_lo,iglo)
it = it_idx(g_lo,iglo)
ie = ie_idx(g_lo,iglo)
il = il_idx(g_lo,iglo)
!Sum up weighted g
total(:, it, ik) = total(:, it, ik) + &
(weights(is)*w(ie,is))*wl(:,il)*(g(:,1,iglo)+g(:,2,iglo))
end do
!$OMP END PARALLEL DO
endif
!Reduce sum across all procs to make integral over all velocity space and species
call sum_allreduce (total)
end subroutine integrate_species_original