subroutine rfxqlo_rfbasic(freq,power,nphi,ksym,ierr)

  use rfxqlo_private
  implicit NONE

  !---------------------------------------------------------------
  ! return the frequency, power, and currently selected Nphi
  ! of the currently selected antenna
  !---------------------------------------------------------------
  real(r8qlo), intent(out) :: freq    ! RF frequency (Hz).
  real(r8qlo), intent(out) :: power   ! power in this Nphi (watts).
  integer, intent(out) :: Nphi        ! Nphi
  integer, intent(out) :: ksym        ! =2 if called for +/-symmetric nphi
                                      ! =1 otherwise
  integer, intent(out) :: ierr        ! 0=OK; 1=error.
  !---------------------------------------------------------------

  !---------------------------------------------------------------
  ierr=0
  if(.not.ready) then
     write(lunmsg,*) &
          ' ?rfxqlo module: not ready to give RF frequency/power/Nphi data.'
     ierr=ierr+1
  endif

  if(selected_antenna.eq.0) then
     write(lunmsg,*) ' ?rfxqlo_rfbasic: antenna not selected.'
     ierr=ierr+1
  endif

  if(selected_nphi.eq.0) then
     write(lunmsg,*) ' ?rfxqlo_rfbasic: Nphi spectrum index not selected.'
     ierr=ierr+1
  endif

  if(ierr.eq.0) then

     freq=antenna_array(selected_antenna)%freq
     nphi=antenna_array(selected_antenna)%nphi(selected_nphi)
     power=antenna_array(selected_antenna)%power * &
          antenna_array(selected_antenna)%wnphi_vac(selected_nphi)
     if(antenna_array(selected_antenna)%sym_nphi) then

        ksym=2          ! symmetrized spectrum; no current drive

        power=power/2   ! half the power in each +/-Nphi branch
     else

        ! the QLO will symmetrize all Nphi contributions to +/- Nphi
        ! per stability requirements for the Fokker Planck code

        power=power/2   ! half the power in each +/-Nphi branch

        ! **** this may be a limitation of the fppmod solver ****
        ! however it is the recommendation of the TORIC experts w.r.t.
        ! use of the Kennel-Engelmann QLO to couple TORIC & fppmod

        ksym=1          ! asymmetric nphi; current drive possible.

     endif

  else

     freq=0
     nphi=0
     power=0

  endif

end subroutine rfxqlo_rfbasic

subroutine rfxqlo_rfbasic_lbl(zlbl)
  use rfxqlo_private
  implicit NONE

  character*(*), intent(out) :: zlbl

  !  return the string "Annn_mmm" where nnn is the antenna number and
  !  mmm is the Nphi value

  character*6 ztmp
  integer :: i,ilbl

  !-----------------

  ilbl=1
  zlbl='A'

  write(ztmp,'(I6)') selected_antenna

  do i=1,len(ztmp)
     if(ztmp(i:i).ne.' ') then
        ilbl=ilbl+1
        zlbl(ilbl:ilbl)=ztmp(i:i)
     endif
  enddo

  ilbl=ilbl+1
  zlbl(ilbl:ilbl)='_'

  write(ztmp,'(I6)') antenna_array(selected_antenna)%nphi(selected_nphi)

  do i=1,len(ztmp)
     if(ztmp(i:i).ne.' ') then
        ilbl=ilbl+1
        if(ztmp(i:i).eq.'-') then
           zlbl(ilbl:ilbl)='m'
        else
           zlbl(ilbl:ilbl)=ztmp(i:i)
        endif
     endif
  enddo

end subroutine rfxqlo_rfbasic_lbl
