	subroutine pflemv (newfle)
c **** Subroutine to rename the ps_plot file.
c ---- newfile = new name for file. ----

c Graig McHendrie, USGS, Feb 6, 1985 - original for Houston plotter
c Rex Sanders, USGS, February 1987 - modified for PostScript printers

	external system,getyna
	integer system
	logical lans,lmvit
	character newfle*(*), tcmd*48, mcmd*48, gpif*32
        character*8 pflenm

        pflenm = 'ps_plot'

c ---- Build commands for test and move operations. ----
	tcmd = 'test -s ' // newfle
	mcmd = 'mv ' // pflenm // newfle
	lmvit = .false.

c ---- Perform test command on new name.  If file doesn't exist,
c ---- 'icde' will be 1 and it is ok to rename h_plot.
	icde = system (tcmd)
	if (icde .ne. 0) then
	  lmvit = .true.
c ---- File already exists. ----
	else
	  write(*,100) newfle, pflenm
100	  format(/' ',a, ' already exists.'/
     &' Renaming ''',a,''' to this name will destroy the old version.'/
     &    ' Is that acceptable  (y/n)  ?'$)
	  call getyna(lans)
c ---- Find out if user wants to overwrite the existing file. ----
	  if (lans) then
	    lmvit = .true.
	  else
	    gpif = pflenm
	  end if
	end if
	
c ---- It's ok to rename h_plot to newfile. ----
	if (lmvit) then
	  icde = system (mcmd)
	  if (icde .ne. 0) then
	    write(*,90) mcmd,icde
90	    format(' There was a system problem with the command:'/
     &      ' ',a/
     &      ' The error return code was ',i5)
	    gpif = pflenm
	  else
	    gpif = newfle
	  end if
	end if

c ---- Write to standard_output the final name of the plot file. ----
	write(*,120) gpif
120	format(/' The plot file from this run is: ',a)
	return
	end
