;+
; Project     : HESI
;                   
; Name        : PROCESS_XCOM_GD
;               
; Purpose     : This procedure is used to retrieve X and Gamma-ray 
;               cross-sections.
;               
; Category    : HESI
;               
; Explanation : 
;               
; Use         : 
;    
; Inputs      : Xcom_file - a string specifying a material file
;               used in Xcom, e.g. gold, tungsten, ...
;               If a null string is entered, the user is queried.
;               
; Opt. Inputs : None
;               
; Outputs     : Ox- Array of 7 cross-sections and energy
;          created for the searched substance by XCOM
;          Ox is generally an ~550 x 8 floating point array
;          where:
;          Ox(*,0) = Photon Energy at which coefficients are calculated (MeV)
;          Ox(*,1 & 2) = Coherent and Incoherent Scattering coeff. (cm^2/g) 
;          Ox(*,3) = photoelectric absorption (cm^2/g)
;          Ox(*,4 & 5) = Pair production in nuclear and electron field (cm^2/g)
;          Ox(*,6 & 7) = Total attenuation with and without coherent
;                          scattering (cm^2/g)
;               Dens- Density of material in gm/cm3
;               Subs- String indicating material file found
;
; Opt. Outputs: None
;               
; Keywords    : 
;
; Calls	      :
;
; Common      : None
;               
; Restrictions: 
;               
; Side effects: None.
;               
; Prev. Hist  :
; By Eric Carzon
;
; Modified    : 
; 
;   June 1995, use Richard Schwartz's program Read_mat_xcom to
;   retrieve data from an indexed, xdr, stream file stored in
;   SSWDB_HESI
;   Version 2, ras, 16-apr-1997, added documentation
;-            
;==============================================================================
pro process_xcom_gd,xcom_file,OX,dens,subs

; Get Photon Energy Values and Total Attenuation Coeff.
; with Coherent Scattering produced for selected element XCOM
;

xcom_read:

if (xcom_file eq '') then begin  ; If no substance was specified

  Print, ' Calling IXCOM, Set atomic number of element of interest '
  print, ' and type XCOM.  When program has finished, type EXIT.  '
  print, ' You may use the IXCOM help for further instructions, type ?'

  ixcom,X=OX,dens=dens, subst = subs
  goto,get_out

endif else begin

  If strpos(xcom_file,'.') eq -1 then begin
    subs = strcompress(strupcase(xcom_file),/remove_all)
  endif else begin
    subs = strmid(xcom_file,0,strpos(xcom_file,'.'))
  endelse

  read_mat_xcom,in_mat=subs,dens,subs,OX,finderror=finderror
  if finderror eq 1 then begin
    Print,'Failed to locate your substance in the database'
    Print,'Please respecify or run program IXCOM interactively'
  endif

endelse

goto, get_out

find_error:
Print,'Your XCOM .DAT file was not found, please check the file name'

get_out:

return
end
