;+
; PROJECT:
;	SDAC
; NAME: 
;       READ_HVFILE
;
; PURPOSE:
;
;
; CATEGORY:
;       BATSE
;
; CALLING SEQUENCE:
;
;
; CALLS:
;	none
;
; INPUTS:
;       none explicit, only through commons;
;
; OPTIONAL INPUTS:
;	none
;
; OUTPUTS:
;       none explicit, only through commons;
;
; OPTIONAL OUTPUTS:
;	none
;
; KEYWORDS:
;	NOREAD - Doesn't read whole file, only reports latest.
;	LATEST - Time of most recent record.
;	
; COMMON BLOCKS:
;	none
;
; SIDE EFFECTS:
;	none
;
; RESTRICTIONS:
;	none
;
; PROCEDURE:
;	none
;
; MODIFICATION HISTORY:
;	Version 1, 1991
;	version 2, ras, 9-dec-1996, generalize to unix with conv_vax_unix
;	Mod. 12/13/96 by RCJ. File hv_file.dat converted to stream.
;	Version 4, richard.schwartz@GSFC.nasa.gov, added noread, 13-mar-1998
; 	Version 5, richard.schwartz@gsfc.nasa.gov, 24-jun-1998, forced old VAX float format on write.
;-
pro read_hvfile, latest=latest, offtimes=offtimes, quiet=quiet, noread=noread
header = {header_str, latest_time:0.d0, spare:0L, numrec:0L}
openr, lun, concat_dir((chklog('BATSE_DATA'))(0),'hv_file.dat'), /get_lun
readu, lun, header
header = conv_vax_unix( use_vax_float(/old2new, header))
latest = header.latest_time
if not(keyword_set(quiet)) then begin
   print,'Latest time in hvoff file: ',atime(latest,/hxr)
   print,'Number of off intervals in hvoff file: ',header.numrec
endif
if keyword_set(noread) then begin
	free_lun, lun
	return
	endif

offtimes = dblarr(2,header.numrec)
readu, lun, offtimes
offtimes = conv_vax_unix( use_vax_float(/old2new,offtimes ))
free_lun, lun
end
