!--------------------------------------------------------------------
      subroutine trxpl_get_profile(zname)
 
      implicit NONE
!
      INTEGER, PARAMETER :: R8=SELECTED_REAL_KIND(12,100)
!
      include 'trxpl.blk'
      character*10, intent(inout) :: zname   ! name of profile
 
      ! get a profile; add it to the list.
 
      !----------------------------
      logical lxout,lyes
      integer lnout
      character*1 yesno(0:1)
      !----------------------------
      yesno(0)='N'
      yesno(1)='Y'
 
      if(lxout(0)) then
         write(lnout(0),*) ' interpolation order: ',iordr
         write(lnout(0),*) ' [R,Z] extend option: ',yesno(ixtnd)
         if(ixtnd.eq.1) write(lnout(0),*) '    scrape-off length: ',
     >      zlamda,' m.'
         write(lnout(0),*) ' enter ".M" to modify option settings.'
      endif
 
      do
         if(lxout(0)) write(lnout(0),*) ' enter ".Q" to exit.'
         call ureadw('trxpl:  enter name of TRANSP/RPLOT profile:$',
     >      zname)
 
         if(zname.eq.'.Q') exit
 
         if(zname.eq.'.M') then
            if(lxout(0)) then
               write(lnout(0),1010)
 1010          format(/
     >      ' TRANSP profile interpolation can be:'/
     >      '    order 0:  piecewise linear'/
     >      '    order 1:  Hermite piecewise cubic'/
     >      '    order 2:  cubic spline.'/
     >      ' Profile functions of flux surface label "x" with interp-'/
     >      ' polation order 1 or 2 can optionally be extended'/
     >      ' beyond the plasma boundary to cover the (R,Z) grid.'/
     >      ' The extrapolation is set by specifying a scrape-off'/
     >      ' distance parameter lamda, then the function outside'/
     >      ' the core plasma obeys '/
     >      '    f=f(bdy)*exp(-d/lamda),'/
     >      ' where d=[distance to nearest boundary point].'/
     >      ' For flat extrapolation choose lamda = 0.0;'/
     >      ' Profile functions of major radius will not be extended.')
            endif
 
            call ureadi(
     >         'trxpl:  interpolation order:  0 or 1 or 2:$',iordr)
            iordr=max(0,min(2,iordr))
 
            if(iordr.gt.0) then
               call uread('trxpl: invoke profile extension? (Y/N):$')
               if(lyes(0)) then
                  ixtnd=1
                  call ureadr8('trxpl: extension scrape-off length:$',
     >               zlamda)
               else
                  ixtnd=0
               endif
            endif
 
         else
 
            call trxpl_add_profile(zname)
            if(lxout(0)) write(lnout(0),*) 
     >         '  Use ".Q" then "D" option to examine data.'
 
         endif
 
      enddo
 
      return
      end
