write_jext Subroutine

public subroutine write_jext(gnostics)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
type(diagnostics_type), intent(in) :: gnostics

Contents

Source Code


Source Code

  subroutine write_jext(gnostics)
    use kt_grids, only: ntheta0, naky
    use diagnostics_config, only: diagnostics_type
    use mp, only: proc0
    use neasyf, only: neasyf_write
    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
    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")

    !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 (j_ext(it,ik) .ne. 0.) then
                write (unit=gnostics%ascii_files%jext, fmt="(es12.4,i4,i4,es12.4)")  &
                     t,it,ik,j_ext(it,ik)
             endif
          enddo
       enddo
    end if

    deallocate(j_ext)
  end subroutine write_jext