;+
; NAME:
;	RD_CPU_DTB
; PURPOSE:
;	Reads a BCS CPU database file
; CATEGORY:
; CALLING SEQUENCE:
;	rd_cpu_dtb,type,database,ierror
; INPUTS:
;	type		string specifying list type; allowed values are:
;			'SEQN', 'FLOP', 'PLAN'
; OPTIONAL INPUT PARAMETERS:
; KEYWORD PARAMETERS:
; OUTPUTS:
;	database	database for specified type
;	ierror		sety to -1 if error occured, otherwise zero
; OPTIONAL OUTPUT PARAMETERS:
; COMMON BLOCKS:
; SIDE EFFECTS:
; RESTRICTIONS:
; PROCEDURE:
; MODIFICATION HISTORY:
;	RDB  Autumn-91
;	RDB  17-May-94	Added call to concat_dir; this ducumentation
;			Made files /xdr
;-

pro	rd_cpu_dtb,type,database,ierror

utype = strupcase(type)
ierror = 0

case utype of
'SEQN':	begin
	database = replicate({sequence_rec},256)
	filnam = 'bcs_seqdtb.dat'
	end

'FLOP':	begin
	database = replicate({flare_option_rec},256)
	filnam = 'bcs_flpdtb.dat'
	end

'PLAN':	begin
	database = replicate({grouper_plan_rec},190)
	filnam = 'bcs_grpdtb.dat'
	end

else:	begin
	print,'*** Unknown database type ***'
	ierror = -1
	return
	end
endcase



;	  read the database in
filename = concat_dir('$DIR_BCS_MICRO',filnam)
print,'Reading in the ' + utype + ' Database from:   ',filename

openr,lundtb,filename,/get_lun,/xdr
readu,lundtb,database
free_lun,lundtb

end
