
; Marcio sent me revised upsilons on 12-Mar-2009. This routine
; processes the new file.

read_elvlc,'ca_2.elvlc_nist',l1,term,conf,ss,ll,jj,ecm,eryd,ecmth,erydth,ref

read_wgfa,'ca_2.wgfa_melendez',lvl1,lvl2,wvl,gf,a_value,ref

openr,lin,'ca2_upsilons_new.txt',/get_lun

openw,lout,'ca_2.upsdat_melendez',/get_lun

t=[3.0,4.0,5.0,6.0,7.0,8.0,9.0,10,11,12,13,14,15,20,30,40]*1e3
nt=n_elements(t)

printf,lout,format='(i3)',n_elements(t)

ups=fltarr(nt)

WHILE eof(lin) NE 1 DO BEGIN
  readf,lin,i,j,ups
 ;
  chck=where(ups EQ 0.,nchck)
  IF nchck GT 0 THEN print,'**Problem, ',i,j
 ;
  de=abs(eryd[j-1]-eryd[i-1])
 ;
  printf,lout,format='(2i5,f10.6,16e10.3)',i,j,de,t
  printf,lout,format='(2i5,f10.6,16e10.3)',i,j,gf[i-1,j-1],ups
ENDWHILE 

printf,lout,' -1'
printf,lout,'%file: ca_2.upsdat'
printf,lout,'%prepared for the CHIANTI atomic database by Peter Young, Jan 2009'
printf,lout,'%Upsilons:  Melendez, Bautista, & Badnell, 2007, A&A, 469, 1203'
printf,lout,'%Theoretical energies: observed energies from .elvlc file used.'
printf,lout,'%gf-values: taken from .wgfa file.'
printf,lout,'%Comment:'
printf,lout,'   Melendez et al. did not give theoretical energies or gf-values. I have used'
printf,lout,'   observed energies in place of theoretical energies, and the gf-values have'
printf,lout,'   been calculated from the A-values calculated by Melendez et al. - see the .wgfa'
printf,lout,' file.'
printf,lout,' -1'

free_lun,lin,lout

END
