subroutine ps_frantic_wdb(ss_plasma,ss_out,ilun_msgs,iwall,ihalo,ireco, &
     workpath,ierr)

  ! use FRANTIC to evaluate neutral transport as indicated, using
  ! input data from two state objects:
  !   ss_plasma: MHD equilibrium, thermal plasma temperatures & densities, etc.
  !   ss_out: NUBEAM output: halo neutral source, nb*<sigma*v> thermal neutral
  !           stopping rate coefficients

  ! output data: (a) profiles in state GAS component are updated in ss_out;
  !              (b) (if ihalo .TRUE.) complete the partice source profiles
  !                  for the NBI component, in ss_out.

  ! this routine has "workpath" argument to control option for debug file
  ! output from frantic: if value is non-blank, write debug output.

  ! SEE: ps_frantic subroutine

  use plasma_state_mod
  implicit NONE

  INTEGER, PARAMETER :: R8=SELECTED_REAL_KIND(12,100)
  type (plasma_state) :: ss_plasma ! state containing plasma & equilibrium
  type (plasma_state) :: ss_out    ! state to contains GAS NBI & FUS component
  ! updates.  NOTE: ss_plasma & ss_out could be the same object.  If they are
  ! not, it is assumed that the dimensioning of species lists are consistent.

  integer, intent(in) :: ilun_msgs

  integer, intent(in) :: iwall  ! .ne.0: compute wall source neutral transport
  integer, intent(in) :: ihalo  ! .ne.0: compute halo source neutral transport
  integer, intent(in) :: ireco  ! .ne.0: compute recombination source transport

  character*(*), intent(in) :: workpath  ! directory for file output
  ! (blank for no debug output)

  integer, intent(out) :: ierr     ! status code returned, 0=OK

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

  ierr = 0

  if(workpath.eq.' ') then

     call ps_frantic_nodebug

  else

     call ps_frantic_debug(workpath)

  endif

  call ps_frantic(ss_plasma,ss_out,ilun_msgs,iwall,ihalo,ireco,ierr)

end subroutine ps_frantic_wdb
