subroutine plot_fp_ei(n1,tvec1,fvec1)

  ! plot EI data from fpreact
  use iso_c_binding, only: fp => c_double
  use adas_mod, only : adas_sigvte_ioniz
  use fpreact_parameters

  implicit NONE

  ! data buffers -- uninitialized!

  integer, intent(in) :: n1     ! dimension info

  real(fp) :: fvec1(n1)             ! for f(T) plot
  real(fp) :: fvec1_adas(n1)             ! for f(T) plot
  real(fp) :: tvec1(n1)             ! T-vector for f(T) plot
 !----------------------------------
  integer luntrm,lnout
  logical lxout,lchar

  integer izneut,ihandle,idum1,idum2,ierr

  real(fp) :: trange1,trange2

  character*60 zlbl1,zlbl2,zlbl3

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

  zlbl1='preact/fpreact "EI" database'
  zlbl2='Maxwellian averaged <sigma*v>'

  luntrm=lnout(0)
  write(luntrm,1001)
1001 format(/ &
          'plot of electron-impact ionization of selected neutral specie'/ &
          'as a function of electron temperature (hit "," to exit)'/)

  if(lxout(0)) write(luntrm,*) &
       ' A -- ADAS [sigma*v](E/A,T/A,Ne) impurity stopping rate coefficient' 
  if(lxout(0)) write(luntrm,*) &
       ' P -- PREACT [sigma*v](E/A) impurity stopping rate coefficient' 
  if(lxout(0)) write(luntrm,*) &
       ' C -- COMPARE ADAS and PREACT impurity stopping rate coefficient' 
  if(lxout(0)) write(luntrm,*) &
       ' X -- ADAS/Excited state [sigma*v](E/A,T/A,Ne) impurity stopping rate coefficient' 
  if(lxout(0)) write(luntrm,*) &
       ' hit "," to exit' 
  call uread('select option:$')

  if(lchar('P')) then !PREACT DATA
     zlbl1='PREACT "EI" database'
     do
        izneut=0
        call ureadi('select neutral specie: 1 for H, 2 for He:$',izneut)
        if(izneut.eq.0) exit

        izneut=max(1,min(2,izneut))
      
        call sigvte_ioniz_handle(izneut,ihandle)
        call ei_sigvte_trange(ihandle,trange1,trange2,idum1,idum2)

        call plot_fp_mkvec(trange1,trange2,n1,tvec1)

        call sigvte_ioniz(izneut,tvec1,n1,fvec1)

        if(izneut.eq.fpreact_Z_H) then
           zlbl3='ionization of H0 by e- impact, vs. Te(KeV)'
        else
           zlbl3='ionization of He0 by e- impact, vs. Te(KeV)'
        endif

        call gaxspc(3) ! log-log
        call r8_grafx1(tvec1,fvec1,n1,'KeV','m**3/sec',zlbl1,zlbl2,zlbl3)
        call gaxspc(1) ! restore default
        
     enddo
  elseif(lchar('A')) then !ADAS DATA
     zlbl1='ADAS "EI" database'
     do
        izneut=0
        call ureadi('select neutral specie: 1 for H, 2 for He:$',izneut)
        if(izneut.eq.0) exit
        
        izneut=max(1,min(2,izneut))
        
        trange1=1.0e-3_fp ![KeV]
        trange2=200.0_fp  ![KeV]
        call plot_fp_mkvec(trange1,trange2,n1,tvec1)
        call adas_sigvte_ioniz(izneut,tvec1,n1,fvec1,ierr)
        if(izneut.eq.fpreact_Z_H) then
           zlbl3='ionization of H0 by e- impact, vs. Te(KeV)'
        else
           zlbl3='ionization of He0 by e- impact, vs. Te(KeV)'
        endif
        call gaxspc(3) ! log-log
        call r8_grafx1(tvec1,fvec1,n1,'KeV','m**3/sec',zlbl1,zlbl2,zlbl3)
        call gaxspc(1) ! restore default
     enddo
  elseif(lchar('C')) then !ADAS vs PREACT  DATA
     zlbl1='PREACT/ADAS "EI" database'
     fvec1=0.0_fp
     fvec1_adas=0.0_fp
     do
        izneut=0
        call ureadi('select neutral specie: 1 for H, 2 for He:$',izneut)
        if(izneut.eq.0) exit

        izneut=max(1,min(2,izneut))
      
        trange1=1.0e-3_fp ![KeV]
        trange2=200.0_fp  ![KeV]
        call plot_fp_mkvec(trange1,trange2,n1,tvec1)
        call sigvte_ioniz(izneut,tvec1,n1,fvec1)
        call adas_sigvte_ioniz(izneut,tvec1,n1,fvec1_adas,ierr)
        
        if(izneut.eq.fpreact_Z_H) then
           zlbl3='ionization of H0 by e- impact, vs. Te(KeV)'
        else
           zlbl3='ionization of He0 by e- impact, vs. Te(KeV)'
        endif
        call gaxspc(3) ! log-log
        call r8_grafx2(tvec1,fvec1,fvec1_adas,n1,'KeV','m**3/sec',zlbl1,zlbl2,zlbl3)
        call gaxspc(1) ! restore default
     enddo
  endif

end subroutine plot_fp_ei
