function rd_gbe_raw, infil=infil, original_log=original_log
;
;+
;NAME:
;	rd_gbe_raw
;PURPOSE:
;	To read the raw BATSE event log file
;HISTORY:
;	Written 13-Apr-93 by M.Morrison
;	18-May-93 (MDM) - Modified to be able to read the FTPed file.
;	 6-Oct-93 (MDM) - 18-May-93 patch was not needed any more.
;-
;
;
; Structure for records in the BATSE flare log file.
;
batlog = {BAT_INDEX3,$            ; 256 bytes  
          flare_num:0L,$          ; flare number
          start_secs:0.d0,$       ; start time of flare in seconds relative to
                                  ; 79/1/1,0000
          peak_secs:0.d0,$        ; peak time of flare in seconds relative to
                                  ; 79/1/1,0000
          duration:0L,$           ; duration of flare in seconds
          peak_rate:0.0,$         ; peak rate of flare in counts/s/(2000cm**2)
                                  ; above background
          total_counts:0.0,$      ; counts/2000cm**2 for the flare above
                                  ; background
          bkg1_start_secs:0.d0,$  ; start of first background in seconds
                                  ; relative to 79/1/1,0000
          bkg1_duration:0L,$      ; duration of first background interval
                                  ; in seconds
          bkg2_start_secs:0.d0,$  ; start of second background in seconds
                                  ; relative to 79/1/1,0000
          bkg2_duration:0L,$      ; duration of second background interval
                                  ; in seconds
          burst_num:0,$           ; burst trigger number 
          burst_tjd:0,$           ; burst truncated Julian day
          burst_trig_secs:0L,$    ; burst triggertime in seconds relative to
                                  ; the start of the day
          spare_log:intarr(96)}

;;	  ftp_junk: 0b		}
;
if (n_elements(infil) eq 0) then infil = '$ydb_raw/batse_raw/batse_flare.cat'
openr, lun, infil, /get_lun
num_flares = 0L
junk = intarr(126)
ftp_junk = 0b
;;readu, lun, num_flares, junk, ftp_junk
readu, lun, num_flares, junk
;
original_log = replicate(batlog,num_flares)
readu, lun, original_log
yoh_vax2ieee, original_log
;
gbo_struct, batse_event=out0
out = replicate(out0, num_flares)
;
for i=0,num_flares-1 do begin
    tim = original_log(i).start_secs

    ;out(i).time	= ((tim mod 86400)-60)*1000	;less 60 seconds because of some discrepancy !!!
    out(i).time		= (tim mod 86400)*1000
    out(i).day		= fix(tim/86400)+1
    out(i).peak		= original_log(i).peak_secs - original_log(i).start_secs
    out(i).duration	= original_log(i).duration

    out(i).event	= original_log(i).flare_num
    out(i).cnts_peak	= original_log(i).peak_rate/4.		;/4 because of discrapancy !!
    out(i).cnts_total	= original_log(i).total_counts/4.	;/4 because of discrapancy !!
    out(i).bkg1_start	= original_log(i).bkg1_start_secs - original_log(i).start_secs
    out(i).bkg1_duration= original_log(i).bkg1_duration
    out(i).bkg2_start	= original_log(i).bkg2_start_secs - original_log(i).start_secs
    out(i).bkg2_duration= original_log(i).bkg2_duration
end
;
free_lun, lun
return, out
end
