;+
; PROJECT: SDAC
;
; NAME: SPEX_ENV
;	
; PURPOSE: install the SPEX environmentals and path locally, 
;	Two software directories needed are installed at the top of the path.	
; CALLING SEQUENCE:
;	Spex_env [,old_path=old_path]
;
; MODIFICATION HISTORY:
;	ras, 21-apr-94
;	RAS, 14-OCT-94	
;	ras, 13-jan-96, installation at ISAS
;	RAS, 15-jan-96, support ISAS and SSL from same script
;	RAS, 16-May-1997, change SSL paths.  Soon to be obsolete, use SSW site setups!
;-
;
pro spex_env, ps_queue=ps_queue


;Are we at ISASS?

setenv,'SPEX_HOME=/0p/schwartz/3p'

if  (findfile('$SPEX_HOME'))(0) ne '' then begin
; support the installation of SPEX

	spexhome=(chklog('SPEX_HOME'))(0)
	setenv,'SSWDB_SPEX='+concat_dir( spexhome,'perm_data')
	setenv,'SPEX_SITE=ISAS'
	setenv,'BATSE_DATA='+concat_dir( spexhome,'batse_data')
	bdata = (chklog('BATSE_DATA'))(0)
	setenv,'BATSE_CONT='+concat_dir(bdata,'cont')
	setenv,'BATSE_DISCSP='+concat_dir(bdata,'discsp')

	setenv,'BATSE_FDB='+concat_dir(bdata,'fdb')
	setenv,'batse_data=$SPEX_HOME/batse_data'
	setenv,'BATSE_FLARE_CATALOG='+concat_dir(bdata,'batse_flare.cat')

	;Modify the software path

	old_path = !path
	delim = ':'
	a=expand_path('+/0p/schwartz/3p/soft')
	a=str_sep(a,delim)
	wtop=where(strpos(a,'spex') ne -1 or strpos(a,'batse') ne -1, ntop)
	atop=a(wtop)
	wnew = where(strpos(atop, 'newspex') ne -1, nnew)
	if nnew ge 1 then begin
		itop = indgen(ntop)
		itop(wnew) = -1
		
		atop = atop(sort( itop))

	endif

	wbot=where(strpos(a,'spex') eq -1 and strpos(a,'batse') eq -1)

	abot=a(wbot)
	!path = arr2str(del=delim,[atop,str_sep(!path,delim),abot])
endif else begin

;Are we at SSL?

setenv,'SPEX_HOME=/disks/solar/data/e/batse/wspex_data'
if  (findfile('$SPEX_HOME'))(0) ne '' then begin

	setenv,'SSWDB_SPEX=$SPEX_HOME/perm_data'
	setenv,'SPEX_SITE=SPEX_REMOTE'


	ldir = chklog('SPEX_HOME')
	bdir = concat_dir(ldir,'batse_data')
	setenv,'BATSE_DATA='+bdir
	setenv,'batse_data='+bdir
	setenv,'BATSE_FLARE_CATALOG='+concat_dir(bdir,'batse_flare.cat')

	setenv,'PS_QUEUE='+fcheck(ps_queue,'sp1')

; SSL Data directories, jmm 1-5-95, changed 15-may-1997, jmm
	setenv, 'BATSE_CONT=/disks/solar/data/e/batse/cont'
	setenv, 'BATSE_DISCSP=/disks/solar/data/e/batse/discsp'

;Modify the software path

	old_path = !path
	!path = '/disks/solar/progs/src/idl/wspex:' + $
        '/disks/solar/progs/src/idl/wspex/nonsite:' +!path
endif
endelse

end
