subroutine rfxqlo_prof_rescale(id,zfactor,ierr)

  ! linear rescale or renormalization of existing 1d XPLASMA profile
  ! managed by rfxqlo

  use rfxqlo_private
  use xplasma_obj_instance
  implicit NONE

  integer, intent(in) :: id   ! profile ID: zero possible; zero => do nothing
  real*8,  intent(in) :: zfactor  ! renormalization factor
  integer, intent(out) :: ierr    ! status code returned, 0=OK

  !-------------------------------
  integer :: itype,irank,idx,iertmp
  character*32 :: profname,units,author
  character*80 :: label
  real*8, dimension(:), allocatable :: zx,zxzc,zf
  real*8 :: xbdy(2),f1bdy(2)
  !-------------------------------

  if(id.eq.0) return

  call xplasma_get_item_info(s,id,ierr, itype=itype)
  if(ierr.ne.0) then
     call xplasma_error(s,ierr,lunmsg)
     return
  endif

  if(itype.ne.xplasma_profType) then
     write(lunmsg,*) ' ?rfxqlo_prof_rescale: ID does not reference a profile.'
     ierr=1
     return
  endif

  call xplasma_prof_info(s,id,ierr, author=author)
  if(ierr.ne.0) then
     call xplasma_error(s,ierr,lunmsg)
     return
  endif

  call xplasma_author_set(s,author,iertmp)

  call xplasma_prof_lintrans(s,id,ierr, factor=zfactor)

  call xplasma_author_clear(s,author,iertmp)

  if(ierr.ne.0) then
     call xplasma_error(s,ierr,lunmsg)
  endif

end subroutine rfxqlo_prof_rescale
