subroutine trxpl_gs2_file(zlbl,zpath0,zpath,zfile)

  implicit NONE

  character*(*), intent(in) :: zlbl   ! label for file being asked about
  character*(*), intent(inout) :: zpath0  ! untranslated path
  character*(*), intent(inout) :: zpath   ! translated path
  character*(*), intent(out) :: zfile ! full filename

  integer ilz,ilp,ipre
  integer ilpre,ilsuf
  integer lnout
  character*120 zcwd
  logical lxout

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

  ilz=len_trim(zlbl)

  if(lxout(0)) then
     if(zpath0.ne.' ') then
        ilp=len_trim(zpath)
        write(lnout(0),*) 'current path setting: ',zpath(1:ilp)
     else
        write(lnout(0),*) 'current path setting: current working directory.'
     endif
     write(lnout(0),*) 'enter "P" to set directory path first.'
     write(lnout(0),*) 'otherwise enter filename:'
  endif

  if(zlbl(1:8).eq.'TEMPLATE') then
     zfile(1:)='template.dat'
  else if(zlbl(1:6).eq.'OUTPUT') then
     call trxpl_gs2_oname(zfile)
  else
     zfile(1:)='file.dat'
  endif

  do
     call unixfile(zlbl,zfile)
     if(zfile.eq.'P') then
        call trxpl_gs2_path(zlbl,zpath0,zpath)
     else
        exit
     endif
  enddo

  if(len_trim(zfile).gt.1) then
     !  assume real filename.  prepend path, unless overridden.
     ipre=0
     if((zfile(1:1).ne.'/').and.(zfile(1:1).ne.'~')) ipre=1
     if(ipre.eq.1) then
        if(zpath.eq.' ') then
           zcwd=' '
           call sget_cwd(zcwd)
        else
           zcwd=zpath
        endif
        ilp=len_trim(zcwd)
        if(zcwd(ilp:ilp).ne.'/') then
           ilp=ilp+1
           zcwd(ilp:ilp)='/'
        endif
        ilz=len_trim(zfile)
        zfile = zcwd(1:ilp)//zfile(1:ilz)
     endif
  endif

end subroutine trxpl_gs2_file
