pro rd_ssl, sttim, entim, data, infil=infil
;
;+
;NAME: 
;	rd_ssl
;PURPOSE:
;	Read the contents of the SSL data files (SXT Summary Log)
;INPUT:
;	sttim	- start time in any format
;	entim	- end time in any format
;OPTIONAL KEYWORD INPUT:
;	infil	- The user can specify the input file name
;		  instead of the start/end times.  Must be a scalar.
;OUTPUT:
;	data	- an array structure
;HISTORY:
;	Written 24-Apr-92 by M.Morrison
;	 1-May-92 (MDM) - Adjusted to take into account the change
;			  in units of expdur field between version
;			  1.00 and 1.01 of MK_SSL
;	 9-Jul-92 (MDM) - Modified to not return the anomalous data caused
;			  by a "temp" file after REFORMAT2 runs
;-
;
qdebug = 1
;
if (not keyword_set(infil)) then begin
    weeks = week_loop(sttim, entim)
    ;
    qinfil = 0
end else begin
    weeks = -1

    qinfil = 1
end
;
sxt_struct, sxt_sumlog=sumlog
;
qfirst_time = 1
for iweek=0,n_elements(weeks)-1 do begin
    if (not qinfil) then begin
	filnam = string(weeks(iweek).year, weeks(iweek).week, format="('ssl', i2.2, '_', i2.2, 'a.01')")
	infil = concat_dir('$DIR_SXT_SSL', filnam)
    end
    if (qdebug) then print, infil
    ;
    if (not file_exist(infil)) then goto, skip		;sorry - afterthought
    ;
    openr, lun, infil, /get_lun, /block
    rd_fheader, infil, fhead, ndset
    if (ndset eq 0) then goto, skip		;sorry - afterthought
    rd_pointer, infil, pointer

    ibyt = pointer.data_section
    ndatasets = fhead.ndatasets
    data0 = replicate(sumlog, ndatasets)
    rdwrt, 'R', lun, ibyt, 0, data0, 1
    ;
    if (fhead.progverno lt 1.01*1000) then begin
	data0.avg_expdur		= data0.avg_expdur*1000		;old version saved it as millisec
	data0.min_expdur		= data0.min_expdur*1000		;old version saved it as millisec
	data0.max_expdur		= data0.max_expdur*1000		;old version saved it as millisec
	data0.avg_explat_norm		= data0.avg_explat_norm*1000	;old version saved it as millisec
	data0.min_explat_norm		= data0.min_explat_norm*1000	;old version saved it as millisec
	data0.max_explat_norm		= data0.max_explat_norm*1000	;old version saved it as millisec
	data0.avg_explat_dark		= data0.avg_explat_dark*1000	;old version saved it as millisec
	data0.min_explat_dark		= data0.min_explat_dark*1000	;old version saved it as millisec
	data0.max_explat_dark		= data0.max_explat_dark*1000	;old version saved it as millisec
    end
    ;
    if (qfirst_time) then begin
	data = data0
	qfirst_time = 0
    end else begin
	data = [data, data0]
    end
    ;
    free_lun, lun
    skip:
end
;
x = int2secarr(data)
y = deriv_arr(x)
ss = where(y gt 0)
if (ss(0) ne -1) then data = data([0,ss+1])	;added 9-Jul-92
end
