This generates a field line average of phi_in and writes it to phi_average. If ik_only is supplied, it will only calculate the field line average for that ky, leaving the rest of phi_avg unchanged. EGH
It replaces the routines fieldlineavgphi_loc and fieldlineavgphi_tot, in fields.f90, which I think are defunct, as phi is always on every processor.
This calculation is fairly generic so should perhaps be moved out into a more accessible module to allow reuse (or replaced with such a method).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex, | intent(in), | dimension (-ntgrid:,:,:) | :: | phi_in | ||
complex, | intent(out), | dimension (-ntgrid:,:,:) | :: | phi_average | ||
integer, | intent(in), | optional | :: | ik_only |
subroutine fieldline_average_phi (phi_in, phi_average, ik_only)
use theta_grid, only: ntgrid, field_line_average
use kt_grids, only: ntheta0, naky
use optionals, only: get_option_with_default
implicit none
complex, dimension (-ntgrid:,:,:), intent (in) :: phi_in
complex, dimension (-ntgrid:,:,:), intent (out) :: phi_average
integer, intent (in), optional :: ik_only
complex :: phi_avg_line
integer :: it, ik, ik_only_actual
ik_only_actual = get_option_with_default(ik_only, -1)
if (ik_only_actual > 0) then
phi_average = 0.
do it = 1,ntheta0
phi_avg_line = field_line_average(phi_in(:,it,ik_only_actual))
phi_average(:, it, ik_only_actual) = phi_avg_line
end do
else
do it = 1,ntheta0
do ik = 1,naky
phi_average(:, it, ik) = field_line_average(phi_in(:, it, ik))
end do
end do
end if
end subroutine fieldline_average_phi