
llstr=['S','P','D','F','G','H']

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

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

conf=''
conflist=''

WHILE eof(lin) NE 1 DO BEGIN
  readf,lin,format='(13x,e12.0,f5.0,19x,i2,i2,5x,i2,7x,a6)',en,jj,ss,ll,ii,conf
  e_cm=en*8065.54
  e_ryd=en/13.605698
 ;
  conf=str_replace(conf,'.',' ')
  chck=where(conf EQ conflist,n)
  IF n EQ 0 THEN BEGIN
    conflist=[conflist,conf]
    iconf=n_elements(conflist)-1
  ENDIF ELSE BEGIN
    iconf=chck
  ENDELSE
 ;
  printf,lout,format='(i3,i6,a15,2i3,a2,f5.1,i3,f15.3,f15.6,f15.3,f15.6)', ii,iconf, $
         conf,ss,ll,llstr[ll],(float(jj)-1)/2.,jj,e_cm,e_ryd,e_cm,e_ryd
ENDWHILE

printf,lout,' -1'
printf,lout,'%file:  ca_2.elvlc'
printf,lout,' -1'

free_lun,lin,lout

END
