Write at ik=it=is=1, ig=0
to text file <runname>.dist
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | unit |
subroutine do_write_f (unit)
use mp, only: proc0, send, receive
use gs2_layouts, only: g_lo, ik_idx, it_idx, is_idx, il_idx, ie_idx, idx_local, proc_id
use le_grids, only: al, energy, forbid, negrid, nlambda, speed
use theta_grid, only: bmag
use dist_fn_arrays, only: gnew
use species, only: nspec
integer, intent(in) :: unit
integer :: iglo, ik, it, is
integer :: ie, il, ig
real :: vpa, vpe
complex, dimension(2) :: gtmp
real, dimension (:,:), allocatable, save :: xpts
real, dimension (:), allocatable, save :: ypts
!> Change argument of bmag depending on which theta you want to write out
integer, parameter :: ig_index = 0
if (.not. allocated(xpts)) then
allocate(xpts(negrid,nspec))
allocate(ypts(nlambda))
! should really just get rid of xpts and ypts
xpts = speed
ypts = 0.0
do il=1,nlambda
ypts(il) = sqrt(max(0.0,1.0-al(il)*bmag(ig_index)))
end do
if (proc0) then
write(unit, *) negrid*nlambda
end if
endif
do iglo = g_lo%llim_world, g_lo%ulim_world
ik = ik_idx(g_lo, iglo) ; if (ik /= 1) cycle
it = it_idx(g_lo, iglo) ; if (it /= 1) cycle
is = is_idx(g_lo, iglo) ; if (is /= 1) cycle
ie = ie_idx(g_lo, iglo)
ig = ig_index
il = il_idx(g_lo, iglo)
if (idx_local (g_lo, ik, it, il, ie, is)) then
if (proc0) then
gtmp = gnew(ig, :, iglo)
else
call send (gnew(ig,:,iglo), 0)
endif
else if (proc0) then
call receive (gtmp, proc_id(g_lo, iglo))
endif
if (proc0) then
if (.not. forbid(ig, il)) then
vpa = sqrt(energy(ie,is)*max(0.0, 1.0-al(il)*bmag(ig)))
vpe = sqrt(energy(ie,is)*al(il)*bmag(ig))
write (unit, "(8(1x,e13.6))") vpa, vpe, energy(ie,is), al(il), &
xpts(ie,is), ypts(il), real(gtmp(1)), real(gtmp(2))
end if
end if
end do
if (proc0) write (unit, *)
end subroutine do_write_f