FIXME : Add documentation
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(diagnostics_type), | intent(in) | :: | gnostics |
subroutine write_jext(gnostics)
use kt_grids, only: ntheta0, naky
use diagnostics_config, only: diagnostics_type
use mp, only: proc0
use warning_helpers, only: is_not_zero
#ifdef NETCDF
use neasyf, only: neasyf_write
#endif
use gs2_io, only: starts, kx_dim, ky_dim, time_dim
implicit none
type(diagnostics_type), intent(in) :: gnostics
real:: t
integer:: ik, it
!GGH J_external
real, dimension(:,:), allocatable :: j_ext
allocate (j_ext(ntheta0, naky)); j_ext=0.
!Get z-centered j_ext at current time
call calc_jext(gnostics,j_ext)
!Write to netcdf
#ifdef NETCDF
if (proc0) call neasyf_write(gnostics%file_id, "antenna_j_ext", j_ext, &
dim_names=[kx_dim, ky_dim, time_dim], start=starts(3, gnostics%nout), &
long_name="Time averaged external current in the antenna, real(kperp^2 A_antenna)", units="radians")
#endif
!Write to ascii
if (proc0 .and. gnostics%ascii_files%write_to_jext .and. (.not. gnostics%create)) then
t = gnostics%user_time
do ik = 1, naky
do it = 1, ntheta0
if (is_not_zero(j_ext(it, ik))) then
write (unit=gnostics%ascii_files%jext, fmt="(es12.4,i4,i4,es12.4)") &
t,it,ik,j_ext(it,ik)
end if
end do
end do
end if
deallocate(j_ext)
end subroutine write_jext