Write out the fields, normalized to their value at theta=0
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(diagnostics_type), | intent(in) | :: | gnostics |
subroutine write_eigenfunc(gnostics)
use mp, only: proc0
use file_utils, only: open_output_file, close_output_file
use fields_arrays, only: phi, apar, bpar
use kt_grids, only: ntheta0, naky, theta0, aky
use theta_grid, only: theta, nperiod, ntheta
use diagnostics_config, only: diagnostics_type
use gs2_io, only: nc_eigenfunc
implicit none
type(diagnostics_type), intent(in) :: gnostics
complex, dimension (ntheta0, naky) :: phi0
integer :: it, ik, ig, ntg_out
if (.not. proc0) return
phi0 = get_phi0()
!Do ascii output
if (proc0 .and. gnostics%ascii_files%write_to_eigenfunc .and. (.not. gnostics%create)) then
ntg_out = ntheta/2 + (nperiod-1)*ntheta
do ik = 1, naky
do it = 1, ntheta0
do ig = -ntg_out, ntg_out
write (unit=gnostics%ascii_files%eigenfunc, fmt="(9(1x,e12.5))") &
theta(ig), theta0(it,ik), aky(ik), &
phi(ig,it,ik)/phi0(it,ik), &
apar(ig,it,ik)/phi0(it,ik), &
bpar(ig,it,ik)/phi0(it,ik)
end do
write (unit=gnostics%ascii_files%eigenfunc, fmt="()")
end do
end do
end if
call nc_eigenfunc(gnostics%file_id, phi0)
end subroutine write_eigenfunc