pro rd_roadmap, lun_filnam, roadmap, ndset, recsize, filidx=filidx
;	---------------------------------------------------------
;+
;NAME:
;	Rd_Roadmap
;PURPOSE:
;	Read and extract the entire roadmap from any of 
;	the reformatted data base files.
;CALLING SEQUENCE:
;	Rd_Roadmap, code, lun_filnam, roadmap, ndset, recsize
;INPUT:
;	lun_filnam	input file specification. It can be a
;			scalar or a vector.  NOTE: They must all
;			be for the same instrument!!
;				OR 
;			the unit number of an openned
;			data base file. scalar or vector
;Output:
;	roadmap		summary of data-index logical records 
;	ndset		number of roadmap records/image blocks
;			If "lun_filnam" is an array, ndset is an
;			array
;	recsize		VMS record size			
;OPTIONAL OUTPUT:
;	filidx		a vector the same length as the roadmap
;			with the index of the file associated with that entry
;			(ie: 0,0,0,0,1,1,1,1,2,2,2,2,...)
;History:
;	written by Mons Morrison, Fall 90.
;	7-Dec-91 (MDM) - Added option of passing multiple file names
;-
;       
hxt_struct
sxt_struct
gen_struct
bcs_struct
wbs_struct
att_struct
cba_struct
;
siz = size(lun_filnam)
vtyp = siz(siz(0)+1)
nfiles = 1
if (siz(0) ne 0) then nfiles = siz(1)	;not a scalar
;
ndset_out = intarr(nfiles)
for ifil=0,nfiles-1 do begin
    if (vtyp eq 7) then begin		;passed file name
	get_lun, lun
	openr, lun, lun_filnam(ifil), /block
    end else begin
	lun = lun_filnam(ifil)
    end
    ;
    rd_pointer, lun, pointer, recsize
    rd_fheader, lun, fheader, ndset
    ndset_out(ifil) = ndset
    ;
    if (ndset eq 0) then begin
	print, 'No datasets - Returning'
	return
    end
    ;
    case strupcase(string(fheader.st$instrument)) of
	'ATT': roadmap0 = replicate({att_roadmap_rec}, ndset)
	'CBA': roadmap0 = replicate({cba_roadmap_rec}, ndset)

	'BCS': roadmap0 = replicate({bcs_roadmap_rec}, ndset)
	'HXT': roadmap0 = replicate({hxt_roadmap_rec}, ndset)
	'SXT': roadmap0 = replicate({sxt_roadmap_rec}, ndset)
	'WBS': roadmap0 = replicate({wbs_roadmap_rec}, ndset)

	else: begin
	    print, 'RD_ROADMAP: '
	    print, 'Invalid Instrument Code: ', strupcase(string(fheader.st$instrument))
	    stop
	end
    endcase
    ;
    ibyt = pointer.map_section
    rdwrt, 'R', lun, ibyt, 0, roadmap0
    ;
    if (ifil eq 0) then begin
	roadmap = roadmap0
	filidx = bytarr(ndset) + ifil		;only one file being read
    end else begin
	roadmap = str_concat(roadmap, roadmap0)
	filidx = [filidx, bytarr(ndset) + ifil]
    end
    ;
    if (vtyp eq 7) then free_lun, lun
end
;
ndset = ndset_out
if (nfiles eq 1) then ndset = ndset(0)	; turn it into a scalar
;
end
