average_ky_xys Subroutine

private subroutine average_ky_xys(f, favg, distributed)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension (:,:,:) :: f
real, intent(out), dimension (:,:) :: favg
logical, intent(in) :: distributed

Contents

Source Code


Source Code

  subroutine average_ky_xys (f, favg, distributed)
    use kt_grids, only: naky, ntheta0, aky
    use species, only: nspec
    use fields_parallelization, only: field_k_local
    use mp, only: sum_allreduce
    implicit none
    real, dimension (:,:,:), intent (in) :: f
    real, dimension (:,:), intent (out) :: favg
    logical,intent(in) :: distributed
    real :: fac
    integer :: ik, it, is

! 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 is = 1, nspec
       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,is) = favg(it,is) + f(it, ik,is) * fac
             end if
          end do
       end do
    end do
    if (distributed) call sum_allreduce(favg)
  end subroutine average_ky_xys