pro mdi_summary,starttime,endtime,outdir=outfil
;+
;NAME
;	MDI_SUMMARY
;PURPOSE
;	To create a file that appends the results from mdi_summary_sub1,  seq_run_sum
;	seq_frame_stats, and cam_run_sum.  An executive summary is printed a the top
;	of the file to give a brief description.
;HISTORY
;	27-Feb-96 written by Dan Goldberg
;V1.2	 2-Apr-96 (MDM) - Modified to include the IPERR summary
;			- Added logging when the program was run
;			- Renamed variable "outdir" to "outfil"
;-
if n_elements(outfil) eq 0 then outfil='mdi_summary.txt'
openw,lun,outfil,/get_lun
mnem=['msfdopn','mksqdve1','mksqdve2','mksqdve3','mksqdve4','multpzt1','multpzt2','multpzt3']
oper=[2,0,0,0,0,1,1,1]
mdi_summary_sub1,starttime,endtime,mnem,oper,lun,exec_sum
close,lun
free_lun,lun
old_file=rd_tfile(outfil)
openw,lun,outfil,/get_lun
seq_frame_stats,starttime,endtime,stat_info
iperr_sea,starttime,endtime,iperr_info,/qstrip_rep
printf,lun,'MDI_SUMMARY Ver 1.2     Program Run: ' + ut_time() + ' UT'
printf,lun,'Time span being searched: '+starttime+' through '+endtime
printf,lun,''
prstr,exec_sum,lun
printf,lun,'======================================================================'
prstr,stat_info,lun
printf,lun,'======================================================================'
prstr,iperr_info,lun
printf,lun,'======================================================================'
prstr,old_file,lun
close,lun
file_append,outfil,'======================================================================'
;-----------------------------
temp_outfil='temp_seq_sum.txt'
seq_run_sum, starttime,endtime,outfil=temp_outfil
seq_info=rd_tfile(temp_outfil)
file_append,outfil,seq_info
file_delete,temp_outfil
file_append,outfil,'======================================================================'
;-----------------------------
temp_outfil='temp_cam_sum.txt'
cam_run_sum, starttime,endtime,outfil=temp_outfil
cam_info=rd_tfile(temp_outfil)
file_append,outfil,cam_info
file_delete,temp_outfil

close,lun
free_lun,lun
end