pro wr_opasc,fileout,event,orbit_params=orbit_params,			$
		comment=comment, op_rules=op_rules,			$
		filein_rules=filein_rules,dsn_str_select=dsn_str_select,$
   		KSC_tim1=KSC_tim1, KSC_tim2=KSC_tim2,		        $
		ksc_str_remove = ksc_str_remove,pass_sum = pass_sum,	$
		start_time=start_time,end_time=end_time,		$
		term_max=term_max,qrate_change=qrate_change,	    	$
		qbdr_opt=qbdr_opt,terminator=terminator 
;+
;  Name:
;     wr_opasc
;
;  Purpose:
;     Write ascii file output for op_first_guess
;
;  History:
;     19-oct-91, Written, J. Lemen
;     10-dec-91, Updated, J. Lemen, Add KSC and DSN summary information
;      6-jul-92, Updated, J. Lemen, Force a Form-Feed before station summary.
;      5-aug-92, Updated, J. Lemen, Don't print blank Station summary lines.
;     27-apr-93, JRL  Changed the way the system time was being calculated.
;     14-oct-93, JRL, Added the terminator keyword.
;     30-jul-94, JRL, Changed the KSC pass elimination message.
;      7-mar-97, JRL, Added info about BDR optimization and terminator requests
;-

FF = string(12B)                ; Form-feed character
openw,lun,fileout,/get_lun
printf,lun,        'Output file            : ',fileout
printf,lun,        'File written on        : ',!stime
if n_elements(orbit_params) ne 0 then 	$
	printf,lun,'Orbital Parameters from: ',orbit_params
printf,lun,'Start time             : ',fmt_tim(event(0).timarr)
printf,lun,        'Comment                : ',comment
printf,lun,' ' & printf,lun,' '

; - - - - - - - - - - - - - - - - -
;  Print the events:
; - - - - - - - - - - - - - - - - -
str_event = fmt_og(event)
for i=0,n_elements(event)-1 do begin
  if i mod 16 eq 0 then printf,lun,' '
  printf,lun,str_event(i)
endfor

; - - - - - - - - - - - - - - - - -
; Print op rules information:
; - - - - - - - - - - - - - - - - -
if n_elements(op_rules) ne 0 then begin
 	printf,lun,' ' & printf,lun,' '
	print_op_rules,lun,op_rules,filein_rules=filein_rules
endif

; - - - - - - - - - - - - - - - - -
; Print Start/stop times and BDR optimization
; - - - - - - - - - - - - - - - - -

        printf,lun,' ' & printf,lun,' '
        printf,lun,'  Start time     : ',fmt_tim(start_time)
        printf,lun,'  End time       : ',fmt_tim(end_time)
	printf,lun,'  Add terms.     : ',strtrim(term_max,2)
        printf,lun,'  SAA rate change: ',(['N','Y'])(qrate_change)
        printf,lun,'  BDR optimize   : ',qbdr_opt,format='(a,i1)'
; - - - - - - - - - - - - - - - - -
; Print eliminated KSC passes
; - - - - - - - - - - - - - - - - -
if n_elements(KSC_str_remove) ne 0 then begin
  if KSC_str_remove(0) ne '-1' then begin
        printf,lun,' '
        if total(ksc_tim1) eq 0. or total(ksc_tim2) eq 0. then $
	  printf,lun,'  KSC passes eliminated: ' 	  else $
          printf,lun,'  KSC passes eliminated between ',fmt_tim(KSC_tim1),  $
		   ' and ', fmt_tim(KSC_tim2)
	printf,lun,' '
        printf,lun,ksc_str_remove,format='(x,a)'
  endif
endif

; - - - - - - - - - - - - - - - - -
; Print Pass summary information
; - - - - - - - - - - - - - - - - -

if n_elements(pass_sum) ne 0 then begin
  printf,lun,FF,' ',format='(2a)'	; Throw a form-feed
  printf,lun,'----------------------------------------- '
  printf,lun,' Summary of Station Contacts  JST in ( )'
  printf,lun,'----------------------------------------- '
  for i=0,n_elements(pass_sum(0,*))-1 do 	$
	for j=0,n_elements(pass_sum(*,0))-1 do 	$
	  if strlen(strtrim(pass_sum(j,i))) gt 0 then printf,lun,pass_sum(j,i)
endif

; ----------- Add terminator image information -----------
if n_elements(terminator) gt 0 then begin
  printf,lun,' '				; Blank line
  for i=0,n_elements(terminator)-1 do printf,lun,terminator(i),format='(a)'
endif

free_lun,lun
return
end
