!--------------------------------------------------------------------
      subroutine trxpl_add_profile(zname)
 
      implicit NONE
!
      INTEGER, PARAMETER :: R8=SELECTED_REAL_KIND(12,100)
!
      include 'trxpl.blk'
      character*10, intent(inout) :: zname   ! name of profile
 
      ! add profile to the list.
 
      !----------------------------
      integer ilz,ierr,lnout,ident,i,idup,istat,ixid,inum
      !----------------------------
 
      ilz=len_trim(zname)
 
      idup=0
      do i=1,numpro
         if(prolabs(1,i)//prolabs(2,i).eq.zname) then
            idup=i
            write(lnout(0),*) ' %caution: duplicate name: ',zname
            exit
         endif
      enddo
 
      if(idup.gt.0) then
         inum=idup
      else
         numpro=numpro+1
         prolabs(1,numpro)=zname
         prolabs(2,numpro)=' '
         inum=numpro
      endif
 
      call trx_prof(zname,prolabs(3,inum),iordr,ident,ierr)
      if((ierr.eq.0).and.(ixtnd.eq.1)) then
         call eqm_rzfun(ident,zlamda,1,0.0_R8,ierr)
         if(ierr.ne.0) then
            write(lnout(0),*)
     >         ' %trxpl:  (R,Z) grid extrapolation failed, ',
     >         'ierr = ',ierr,' zname = ',zname
            write(lnout(0),*) ' profile accepted anyway.'
            ierr=0
         endif
      endif
      if(ierr.eq.0) then
         call trx_uget(ident,ixid,
     >      prolabs(1,inum),prolabs(3,inum),
     >      istat,ierr)
         if(ierr.ne.0) then
            write(lnout(0),*)
     >         ' %trxpl: MKS conversion error detected (trx_uget)'
            ierr=0
         else
            id_xaxis(inum)=ixid
         endif
      endif
 
      if(ierr.ne.0) then
         write(lnout(0),*)
     >      ' %trxpl:  profile ',zname(1:ilz),' not added.'
         if(idup.eq.0) numpro=numpro-1
      else
         id_pros(numpro)=ident
         write(lnout(0),*) ' %trxpl: ',zname,' OK.'
         write(lnout(0),*) '  Units: ',prolabs(3,numpro),'.'
      endif
 
      return
      end
