Used for testing takes as input an array using le_lo and writes it to a .distmp output file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex, | intent(in), | dimension (:,:,le_lo%llim_proc:) | :: | dist | ||
character(len=*), | intent(in) | :: | extension | |||
logical, | intent(in), | optional | :: | last |
subroutine write_mpdist_le (dist, extension, last)
use mp, only: proc0, send, receive
use file_utils, only: open_output_file, close_output_file
use gs2_layouts, only: le_lo, ig_idx, ik_idx, it_idx, is_idx
use gs2_layouts, only: idx_local, proc_id
use theta_grid, only: bmag, theta
implicit none
complex, dimension (:,:,le_lo%llim_proc:), intent (in) :: dist
! real, dimension (:,:,le_lo%llim_proc:), intent (in) :: dist
character (*), intent (in) :: extension
logical, intent (in), optional :: last
integer :: ile, ixi, nxi, ik, it, is, ie, il, ig, isgn
integer, save :: unit
logical :: done = .false.
real :: vpa1
complex :: gtmp
! real :: gtmp
if (.not. done) then
if (proc0) call open_output_file (unit, trim(extension))
nxi = max(2*nlambda-1, 2*ng2)
do ile=le_lo%llim_world, le_lo%ulim_world
ig = ig_idx(le_lo, ile)
ik = ik_idx(le_lo, ile)
it = it_idx(le_lo, ile)
is = is_idx(le_lo, ile)
do ie = 1, negrid
do ixi = 1, nxi
il = ixi_to_il(ixi, ig)
isgn = ixi_to_isgn(ixi, ig)
if (idx_local (le_lo, ig, ik, it, is)) then
if (proc0) then
gtmp = dist(ixi,ie,ile)
else
call send (dist(ixi,ie,ile), 0)
end if
else if (proc0) then
call receive (gtmp, proc_id(le_lo, ile))
end if
if (proc0) then
if (.not. forbid(ig,il)) then
vpa1 = sqrt(energy_maxw(ie)*max(0.0,1.0-al(il)*bmag(ig)))
write (unit,'(5e14.5)') theta(ig), sgn(isgn)*vpa1, energy_maxw(ie), &
real(gtmp), aimag(gtmp)
! write (unit,'(5e14.5)') theta(ig), vpa1, energy(ie), gtmp(1), gtmp(2)
end if
end if
end do
end do
end do
if (proc0) call close_output_file (unit)
if (present(last)) done = .true.
end if
end subroutine write_mpdist_le