
! written by plasma_cwrite.py
! input: plasma_state_spec.dat   version 2.055
! *** do not edit *** (use code generator instead)


  subroutine ccps_getset_p3_dummy
     return
  end subroutine ccps_getset_p3_dummy

subroutine psget_psi_to_machine_axis(iobj, data, ierr)
    !! delta(Psi) from magnetic axis to machine axis, subtract this
    !! from Psi(R,Z) to get a Psi value, that approaches zero as R->
    !! zero: Psi ~ R*A_phi, (as in the EFIT free boundary
    !! representation)., Note: prescribed boundary code runs (e.g.,
    !! traditional TRANSP runs) cannot know this, number; so Plasma
    !! States created from such run, data will leave this at zero. 
    !! Plasma States, using free boundary MHD equilibrium information,
    !! will always have a non-zero value here.
    use plasma_state_mod, only : plasma_state_container, plasma_state, &
                                & load_ps_container, rspec
    implicit NONE
    integer, intent(in) :: iobj(*)  ! object handle
     ! list of dimensions (if any)
    REAL(KIND=rspec), intent(out)  :: data ! to read to/write from
    integer, intent(out) :: ierr ! error code (0=OK)
    ! local
    type (plasma_state_container) :: ptr
    type (plasma_state), pointer  :: ss

    ierr = 0
    call ccps_argcheck('psget_psi_to_machine_axis', iobj, ierr)
    if(ierr.ne.0) return
    ! proceed...
    call load_ps_container(iobj,ptr)
    ss => ptr % ps_ptr
    ! set
    data = ss % Psi_to_machine_axis
end subroutine psget_psi_to_machine_axis


subroutine psset_psi_to_machine_axis(iobj, data, ierr)
    !! delta(Psi) from magnetic axis to machine axis, subtract this
    !! from Psi(R,Z) to get a Psi value, that approaches zero as R->
    !! zero: Psi ~ R*A_phi, (as in the EFIT free boundary
    !! representation)., Note: prescribed boundary code runs (e.g.,
    !! traditional TRANSP runs) cannot know this, number; so Plasma
    !! States created from such run, data will leave this at zero. 
    !! Plasma States, using free boundary MHD equilibrium information,
    !! will always have a non-zero value here.
    use plasma_state_mod, only : plasma_state_container, plasma_state, &
                                & load_ps_container, rspec
    implicit NONE
    integer, intent(in) :: iobj(*)  ! object handle
     ! list of dimensions (if any)
    REAL(KIND=rspec), intent(in)  :: data ! to read to/write from
    integer, intent(out) :: ierr ! error code (0=OK)
    ! local
    type (plasma_state_container) :: ptr
    type (plasma_state), pointer  :: ss

    ierr = 0
    call ccps_argcheck('psset_psi_to_machine_axis', iobj, ierr)
    if(ierr.ne.0) return
    ! proceed...
    call load_ps_container(iobj,ptr)
    ss => ptr % ps_ptr
    ! set
    ss % Psi_to_machine_axis = data
end subroutine psset_psi_to_machine_axis


subroutine psget_picrf_srcs(iobj, n1, n2, n3, data, ierr)
    !! direct ICRF power deposition, (sum over nphi)
    use plasma_state_mod, only : plasma_state_container, plasma_state, &
                                & load_ps_container, rspec
    implicit NONE
    integer, intent(in) :: iobj(*)  ! object handle
    integer, intent(in) :: n1, n2, n3 ! list of dimensions (if any)
    REAL(KIND=rspec), intent(out)  :: data(n1, n2, n3) ! to read to/write from
    integer, intent(out) :: ierr ! error code (0=OK)
    ! local
    type (plasma_state_container) :: ptr
    type (plasma_state), pointer  :: ss

    ierr = 0
    call ccps_argcheck('psget_picrf_srcs', iobj, ierr)
    if(ierr.ne.0) return
    ! proceed...
    call load_ps_container(iobj,ptr)
    ss => ptr % ps_ptr
    ! set
    data(1:n1, 1: n2, 1: n3) = ss % picrf_srcs
end subroutine psget_picrf_srcs


subroutine psset_picrf_srcs(iobj, n1, n2, n3, data, ierr)
    !! direct ICRF power deposition, (sum over nphi)
    use plasma_state_mod, only : plasma_state_container, plasma_state, &
                                & load_ps_container, rspec
    implicit NONE
    integer, intent(in) :: iobj(*)  ! object handle
    integer, intent(in) :: n1, n2, n3 ! list of dimensions (if any)
    REAL(KIND=rspec), intent(in)  :: data(n1, n2, n3) ! to read to/write from
    integer, intent(out) :: ierr ! error code (0=OK)
    ! local
    type (plasma_state_container) :: ptr
    type (plasma_state), pointer  :: ss

    ierr = 0
    call ccps_argcheck('psset_picrf_srcs', iobj, ierr)
    if(ierr.ne.0) return
    ! proceed...
    call load_ps_container(iobj,ptr)
    ss => ptr % ps_ptr
    ! set
    ss % picrf_srcs = data(1:n1, 1: n2, 1: n3)
end subroutine psset_picrf_srcs


subroutine psgetrnk_picrf_srcs(iobj, ndims, ierr)
    !! direct ICRF power deposition, (sum over nphi)
    use plasma_state_mod, only :  plasma_state_container, plasma_state, rspec
    implicit NONE
    integer, intent(in) :: iobj(*) ! object handle
    integer, intent(out) :: ndims  ! number of dimensions
    integer, intent(out) :: ierr   ! error code (0=OK)
    ! local
    type (plasma_state_container) :: ptr
    type (plasma_state), pointer  :: ss

    ierr = 0
    ndims = 3
end subroutine psgetrnk_picrf_srcs


subroutine psgetdim_picrf_srcs(iobj, ndims, dims, ierr)
    !! direct ICRF power deposition, (sum over nphi)
    use plasma_state_mod, only :  plasma_state_container, plasma_state, &
                                & load_ps_container, rspec
    implicit NONE
    integer, intent(in) :: iobj(*) ! object handle
    integer, intent(in) :: ndims   ! number of dimensions
    integer, intent(out) :: dims(ndims) ! sizes
    integer, intent(out) :: ierr ! error code (0=OK)
    ! local
    type (plasma_state_container) :: ptr
    type (plasma_state), pointer  :: ss

    ierr = 0
    if (ndims /= 3) ierr = 1
    call ccps_argcheck('psgetdim_picrf_srcs', iobj, ierr)
    if(ierr.ne.0) return
    ! proceed...
    call load_ps_container(iobj,ptr)
    ss => ptr % ps_ptr
    dims = 0
    if (allocated( ss % picrf_srcs ) ) then
        ! can only call 'shape' on allocated/associated arrays
        dims = shape(ss % picrf_srcs)
    endif
end subroutine psgetdim_picrf_srcs


subroutine psget_pb0_halo(iobj, n1, data, ierr)
    !! power in halo neutral source, (loss from thermal ions)
    use plasma_state_mod, only : plasma_state_container, plasma_state, &
                                & load_ps_container, rspec
    implicit NONE
    integer, intent(in) :: iobj(*)  ! object handle
    integer, intent(in) :: n1 ! list of dimensions (if any)
    REAL(KIND=rspec), intent(out)  :: data(n1) ! to read to/write from
    integer, intent(out) :: ierr ! error code (0=OK)
    ! local
    type (plasma_state_container) :: ptr
    type (plasma_state), pointer  :: ss

    ierr = 0
    call ccps_argcheck('psget_pb0_halo', iobj, ierr)
    if(ierr.ne.0) return
    ! proceed...
    call load_ps_container(iobj,ptr)
    ss => ptr % ps_ptr
    ! set
    data(1:n1) = ss % pb0_halo
end subroutine psget_pb0_halo


subroutine psset_pb0_halo(iobj, n1, data, ierr)
    !! power in halo neutral source, (loss from thermal ions)
    use plasma_state_mod, only : plasma_state_container, plasma_state, &
                                & load_ps_container, rspec
    implicit NONE
    integer, intent(in) :: iobj(*)  ! object handle
    integer, intent(in) :: n1 ! list of dimensions (if any)
    REAL(KIND=rspec), intent(in)  :: data(n1) ! to read to/write from
    integer, intent(out) :: ierr ! error code (0=OK)
    ! local
    type (plasma_state_container) :: ptr
    type (plasma_state), pointer  :: ss

    ierr = 0
    call ccps_argcheck('psset_pb0_halo', iobj, ierr)
    if(ierr.ne.0) return
    ! proceed...
    call load_ps_container(iobj,ptr)
    ss => ptr % ps_ptr
    ! set
    ss % pb0_halo = data(1:n1)
end subroutine psset_pb0_halo


subroutine psgetrnk_pb0_halo(iobj, ndims, ierr)
    !! power in halo neutral source, (loss from thermal ions)
    use plasma_state_mod, only :  plasma_state_container, plasma_state, rspec
    implicit NONE
    integer, intent(in) :: iobj(*) ! object handle
    integer, intent(out) :: ndims  ! number of dimensions
    integer, intent(out) :: ierr   ! error code (0=OK)
    ! local
    type (plasma_state_container) :: ptr
    type (plasma_state), pointer  :: ss

    ierr = 0
    ndims = 1
end subroutine psgetrnk_pb0_halo


subroutine psgetdim_pb0_halo(iobj, ndims, dims, ierr)
    !! power in halo neutral source, (loss from thermal ions)
    use plasma_state_mod, only :  plasma_state_container, plasma_state, &
                                & load_ps_container, rspec
    implicit NONE
    integer, intent(in) :: iobj(*) ! object handle
    integer, intent(in) :: ndims   ! number of dimensions
    integer, intent(out) :: dims(ndims) ! sizes
    integer, intent(out) :: ierr ! error code (0=OK)
    ! local
    type (plasma_state_container) :: ptr
    type (plasma_state), pointer  :: ss

    ierr = 0
    if (ndims /= 1) ierr = 1
    call ccps_argcheck('psgetdim_pb0_halo', iobj, ierr)
    if(ierr.ne.0) return
    ! proceed...
    call load_ps_container(iobj,ptr)
    ss => ptr % ps_ptr
    dims = 0
    if (allocated( ss % pb0_halo ) ) then
        ! can only call 'shape' on allocated/associated arrays
        dims = shape(ss % pb0_halo)
    endif
end subroutine psgetdim_pb0_halo


subroutine psget_p0_reco(iobj, n1, data, ierr)
    !! power in recombination neutral source, (loss from thermal
    !! ions)
    use plasma_state_mod, only : plasma_state_container, plasma_state, &
                                & load_ps_container, rspec
    implicit NONE
    integer, intent(in) :: iobj(*)  ! object handle
    integer, intent(in) :: n1 ! list of dimensions (if any)
    REAL(KIND=rspec), intent(out)  :: data(n1) ! to read to/write from
    integer, intent(out) :: ierr ! error code (0=OK)
    ! local
    type (plasma_state_container) :: ptr
    type (plasma_state), pointer  :: ss

    ierr = 0
    call ccps_argcheck('psget_p0_reco', iobj, ierr)
    if(ierr.ne.0) return
    ! proceed...
    call load_ps_container(iobj,ptr)
    ss => ptr % ps_ptr
    ! set
    data(1:n1) = ss % p0_reco
end subroutine psget_p0_reco


subroutine psset_p0_reco(iobj, n1, data, ierr)
    !! power in recombination neutral source, (loss from thermal
    !! ions)
    use plasma_state_mod, only : plasma_state_container, plasma_state, &
                                & load_ps_container, rspec
    implicit NONE
    integer, intent(in) :: iobj(*)  ! object handle
    integer, intent(in) :: n1 ! list of dimensions (if any)
    REAL(KIND=rspec), intent(in)  :: data(n1) ! to read to/write from
    integer, intent(out) :: ierr ! error code (0=OK)
    ! local
    type (plasma_state_container) :: ptr
    type (plasma_state), pointer  :: ss

    ierr = 0
    call ccps_argcheck('psset_p0_reco', iobj, ierr)
    if(ierr.ne.0) return
    ! proceed...
    call load_ps_container(iobj,ptr)
    ss => ptr % ps_ptr
    ! set
    ss % p0_reco = data(1:n1)
end subroutine psset_p0_reco


subroutine psgetrnk_p0_reco(iobj, ndims, ierr)
    !! power in recombination neutral source, (loss from thermal
    !! ions)
    use plasma_state_mod, only :  plasma_state_container, plasma_state, rspec
    implicit NONE
    integer, intent(in) :: iobj(*) ! object handle
    integer, intent(out) :: ndims  ! number of dimensions
    integer, intent(out) :: ierr   ! error code (0=OK)
    ! local
    type (plasma_state_container) :: ptr
    type (plasma_state), pointer  :: ss

    ierr = 0
    ndims = 1
end subroutine psgetrnk_p0_reco


subroutine psgetdim_p0_reco(iobj, ndims, dims, ierr)
    !! power in recombination neutral source, (loss from thermal
    !! ions)
    use plasma_state_mod, only :  plasma_state_container, plasma_state, &
                                & load_ps_container, rspec
    implicit NONE
    integer, intent(in) :: iobj(*) ! object handle
    integer, intent(in) :: ndims   ! number of dimensions
    integer, intent(out) :: dims(ndims) ! sizes
    integer, intent(out) :: ierr ! error code (0=OK)
    ! local
    type (plasma_state_container) :: ptr
    type (plasma_state), pointer  :: ss

    ierr = 0
    if (ndims /= 1) ierr = 1
    call ccps_argcheck('psgetdim_p0_reco', iobj, ierr)
    if(ierr.ne.0) return
    ! proceed...
    call load_ps_container(iobj,ptr)
    ss => ptr % ps_ptr
    dims = 0
    if (allocated( ss % p0_reco ) ) then
        ! can only call 'shape' on allocated/associated arrays
        dims = shape(ss % p0_reco)
    endif
end subroutine psgetdim_p0_reco

