	function auto_check_filename(line,partial,onlydir)
	implicit none
c
c  Check function for $outfile (alpha/ia64 version)
c
	include 'auto.inc'
	character*(*) line			!:i: the string to check
	logical*4 partial			!:i: partial check
	logical*4 onlydir			!:i: only directory allowed?
	integer*4 auto_check_filename		!:f: function result
c
	integer*4 istat
c
	include '($fabdef)'
	include '($namdef)'
c
	record /fabdef/ fab
	record /namldef/ naml
c
	integer*4 sys$parse
c
	character*4095 fnam
	integer*4 nk
c
	fnam = line
	nk = len(line)
c
        naml.naml$b_bid = naml$c_bid
        naml.naml$b_bln = naml$c_bln
        naml.naml$l_long_filename_size = nk
        naml.naml$l_long_filename      = %loc(fnam)
c
	naml.naml$b_nop = 0
c
c  If partial check, do a syntax check only
c
	if(partial) naml.naml$b_nop = NAM$M_SYNCHK
c
        fab.fab$b_bln = fab$c_bln
        fab.fab$b_bid = fab$c_bid
        fab.fab$l_nam = %loc(naml)
c
	fab.fab$l_fna = -1
	fab.fab$b_fns = 0
c
	istat = sys$parse(fab,,)
	if(.not. istat) then
	  if(partial) then
	    nk = nk + 2
            naml.naml$l_long_filename_size = nk
	    fnam(nk-1:nk) = '*]'
	    istat = sys$parse(fab,,)
	  endif
	endif
	if(onlydir) then
c
c Only dev/dir present, check if no name,type or version present
c
	  if((iand(naml.naml$l_fnb,nam$m_exp_name) .ne. 0) .or.
     1       (iand(naml.naml$l_fnb,nam$m_exp_type) .ne. 0) .or.
     1       (iand(naml.naml$l_fnb,nam$m_exp_ver) .ne. 0)) then
	    istat = 0
	  endif
	endif
c
	auto_check_filename = istat
	return
	end

