get_volume_average Subroutine

public subroutine get_volume_average(f, favg)

FIXME : Add documentation

Arguments

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

Contents

Source Code


Source Code

  subroutine get_volume_average (f, favg)
    use kt_grids, only: naky, ntheta0, aky
    use warning_helpers, only: is_zero
    implicit none
    real, dimension (:,:), intent (in) :: f
    real, intent (out) :: favg
    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 (is_zero(aky(ik))) fac = 1.0
       do it = 1, ntheta0
          favg = favg + f(it, ik) * fac
       end do
    end do

  end subroutine get_volume_average