subroutine trxpl_gs2_path(zlbl,zpath0,zpath)

  ! ** set directory path to file object ** by user input

  implicit NONE

  character*(*), intent(in) :: zlbl   ! label of object for which to set
  !                                     directory path
  character*(*), intent(inout) :: zpath0  ! directory path (untranslated)
  character*(*), intent(inout) :: zpath   ! directory path (translated)

  !--------------------------------------------
  logical lxout,lchar
  integer lnout,ilz,ilu
  character*120 ztmp
  !--------------------------------------------

  ilz=len_trim(zlbl)
  if(lxout(0)) write(lnout(0),*) &
       'trxpl_mkgs2: set directory path for: ',zlbl(1:ilz)

  call unixpath(zpath0,zpath,ilu)
  if(zpath0(1:1).eq.'~') call fixup(zpath0)
  if(zpath(1:1).eq.'~') call fixup(zpath)

contains
  subroutine fixup(zpath1)
    character*(*), intent(inout) :: zpath1

    ! expand leading "~" in pathname

    integer ilt,ilz

    ztmp=' '
    call sget_env('HOME',ztmp)
    ilt=len_trim(ztmp)
    ilz=len_trim(zpath1)
    zpath1 = ztmp(1:ilt)//zpath1(2:ilz)  ! replace leading "~"

  end subroutine fixup

end subroutine trxpl_gs2_path
