	PROGRAM PERP
C
C
C
	IMPLICIT INTEGER(A-Z)
C
	INCLUDE 'PERP.INC/list'
C
	INTEGER*4 submit_lth, file_lth, comp_lth, local_lth, global_lth
	INTEGER*4 beg_pos
	INTEGER global_quals(qual_count)
	CHARACTER comp_date*17, file*512, time*5, space*1, qual_type*1
	CHARACTER submit_line*512, global_line*512, local_line*512
	LOGICAL days(7), dates(31), delta_time, too_long
C
	DATA space /' '/
C
	too_long = .false.
	file =' '
	submit_line=' '
	comp_date=' '
	time=' '
C
C	Get DATE, DAYS, and TIME to run from user.
C

	CALL DAYPARSE(days)
	CALL DATEPARSE(dates,comp_date)
	CALL TIMEPARSE(time)

C
C	Compute the date to run.
C

	CALL COMPDATE(comp_date,days,dates,time)
	icode = STR$TRIM(comp_date, comp_date, comp_lth)

C
C	Get other switches and filenames.
C

	CALL CHECK_QUALS(global_quals,qual_values)
	qual_type = 'G'
	CALL BUILD_LINE( global_line, global_lth, global_quals, qual_values,
     &			qual_type)
C
	CALL GET_FILE(file)
	icode = STR$TRIM(file, file, file_lth)
C
C
C	Make SUBMIT string.
C

	beg_pos = 1
	if(comp_date(1:1).EQ.space) beg_pos = 2
	if(quals_end.LE.0) quals_end = 1
	if(file_end.LE.0) file_end = 1

	if (global_lth.NE.1) then
	submit_line = 'SUBMIT' // global_line(1:global_lth) // '/AFTER="'
     &  //  comp_date(beg_pos:comp_lth) // '" ' // file(1:file_lth)
	else
	submit_line = 'SUBMIT'  // '/AFTER="'
     &  //  comp_date(beg_pos:comp_lth) // '" ' // file(1:file_lth)
	endif
C
	icode = STR$TRIM(submit_line, submit_line, submit_lth)
C
	CALL CHECK_SUBMIT(submit_line,submit_lth,too_long)
C
C	Call SUBMIT program.
C
	open(unit=7,file='sys$output',recl=1024,status='unknown')
	write(7,100)
 100	format(/,' PERP Version 2.7  6-Aug-1985',/)
	type *,'Submitted As: [',submit_line(1:submit_lth),']'

	if (.not. too_long) then
	icode = LIB$DO_COMMAND(submit_line(1:submit_lth))
	else
	icode = LIB$DO_COMMAND('@PERP.tmp')
	endif
C
C	End of Program PERP.
C

	end
