C+
C NAME:
C	iTopFragment
C PURPOSE:
C	Deconstruct file names into components
C CALLING SEQUENCE:
	function iTopFragment(cDir,cOut)
C INPUTS:
C OUTPUTS:
C CALLS:
C	LocFirstLen
C INCLUDE:
	include		'dirspec.h'
C PROCEDURE:
C MODIFICATION HISTORY:
C	JUN-1995, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	    character	cDir*(*)
	    character	cOut*(*)

	iTopFragment = 0

	i2 = itrim(cDir)
	if (i2 .le. iLead+iTrail) then
	    cOut = ' '
	    return
	end if

	i1 = iLead
	if (bNoRoot .and. i2 .gt. iLeadRootDivide .and.
     &	    cDir(:iLeadRootDivide) .eq. cLeadRootDivide) i1 = iLeadRootDivide
	i2 = i2-iTrail

	i2 = i1+LocFirstLen(cDivide,cDir(i1+1:i2))
	if (i2-1 .le. i1) then
	    cOut = cRoot
	    iTopFragment = iRoot
	else
	    cOut = cDir(i1+1:i2-1)
	    iTopFragment = i2-1-i1
	end if

	return
	end
