FIXME : Add documentation
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex, | intent(in), | dimension (:,:) | :: | f | ||
complex, | intent(in), | dimension (:,:) | :: | g | ||
complex, | intent(out), | dimension (:) | :: | favg | ||
logical, | intent(in) | :: | distributed |
subroutine average_ky_2_complex_xy (f, g, favg, distributed)
use kt_grids, only: naky, ntheta0, aky
use fields_parallelization, only: field_k_local
use mp, only: sum_allreduce
implicit none
complex, dimension (:,:), intent (in) :: f, g
complex, dimension (:), intent (out) :: favg
logical,intent(in) :: distributed
real :: fac
integer :: ik, it
! ky=0 modes have correct amplitudes; rest must be scaled
! note contrast with scaling factors in FFT routines.
!CMR+GC: 2/9/2013
! fac values here arise because gs2's Fourier coefficients, F_k^gs2, not standard form:
! i.e. f(x) = f_k e^(i k.x)
! With standard Fourier coeffs in gs2, we would instead need: fac=2.0 for ky > 0
! (fac=2.0 would account ky<0 contributions, not stored due to reality condition)
favg = 0.
do ik = 1, naky
fac = 0.5
if (aky(ik) == 0.) fac = 1.0
do it = 1, ntheta0
if (.not. distributed .or. field_k_local(it,ik)) then
favg(it) = favg(it) + conjg(f(it, ik)) * g(it,ik) * fac
end if
end do
end do
if (distributed) call sum_allreduce(favg)
end subroutine average_ky_2_complex_xy