C+
C NAME:
C	smei_frm_getlist
C CALLING SEQUENCE:
	integer function smei_frm_getlist(TBeg,TEnd,icam,mode,bdig,cBase,cList)
C INCLUDE:
	include		'openfile.h'
	include		'dirspec.h'
	include		'filparts.h'
	include		'smei_frm_layout.h'
C CALLS:
C	Int2Str, Str2Str, Time2Str, iFilePath, bOpenFile, smei_frm_get
C	itrim, iSetFileSpec, iGetFileSpec, bOpenFile, iFreeLun
C MODIFICATION HISTORY:
C	JUN-2004, Paul Hick (UCSD/CASS)
C	MAR-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C	   Mode argument was there already, but was not doing anything.
C	   Now it does.
C-
	    integer	TBeg(2)
	    integer	TEnd(2)
	    integer	icam
	    integer	mode
	    logical	bdig
	    character	cBase*(*)
	    character	cList*(*)

	logical		bOpenFile
	logical 	smei_frm_get
	character	cFile*(FIL__LENGTH)
	character	cName*(FIL__LENGTH)
	integer		Str2Str
	integer		Time2Str
	integer		getpid

	i = 0
	i = i+Str2Str('c' , cFile(i+1:))
	i = i+Int2Str(icam, cFile(i+1:))
	i = i+Str2Str('m' , cFile(i+1:))
	i = i+Int2Str(mode, cFile(i+1:))
	i = i+Str2Str('_' , cFile(i+1:))
	i = i+Time2Str(SMEI__UT_FORMAT, TBeg, cFile(i+1:))
	i = i+Str2Str('_' , cFile(i+1:))
	i = i+Time2Str(SMEI__UT_FORMAT, TEnd, cFile(i+1:))
	i = i+Str2Str('_' , cFile(i+1:))
	i = i+Int2Str(getpid(), cFile(i+1:))	! Make sure file name is unique to process.
	i = i+Str2Str('.lst', cFile(i+1:))

	i = iFilePath(cEnvi(:iEnvi)//'TUB',0,' ',cFile,cList)

	smei_frm_getlist = 0

	iRecl  = 0
	if (bOpenFile(OPN__TEXT+OPN__TRYINPUT+OPN__UNKNOWN+OPN__ONEPASS+OPN__STOP+OPN__NOMESSAGE,iU,cList,iRecl)) then

	    iFirst = 1
	    do while (smei_frm_get(iFirst,TBeg,TEnd,icam,mode,bdig,cBase,cFile))

		i = iSetFileSpec(cFile)
		i = iGetFileSpec(FIL__NAME,FIL__NAME,cName)
		read (cName(4:4),'(I1)') i

		if (i .eq. mode) then
		    smei_frm_getlist = smei_frm_getlist+1
		    write (iU,'(A)') cFile(:itrim(cFile))
		end if

	    end do

	    if (smei_frm_getlist .eq. 0) then
		iU = iFreeLun(-iU)
	    else
		iU = iFreeLun(iU)
	    end if

	end if

	return
	end
