pro rd_castelli,filin,lam,nmod,teff,logg,logz,flux,fluxc
; This routine reads one of Castelli's flux model files, returning
; arrays containing wavelength = lam, flux (erg/cm^2-s-hz-ster),
; continuum flux (?) in same units.
; Also returned are the teff, logg, (but not vturb) values associated
; with each model.
; Output dimensions are:
; lam = (1221)
; flux,fluxc = (1221,500)
; teff,logg,vturb = (500)

tt=fltarr(1221)
f1='(8f10.2)'
f2='(8e10.4)'
f3='(4x,f8.0,9x,f8.5,4x,f3.1)'

lam=fltarr(1221)
flux=fltarr(1221,500)
fluxc=fltarr(1221,500)
teff=fltarr(500)
logg=fltarr(500)
logz=fltarr(500)
vturb=fltarr(500)

openr,iun,filin,/get_lun
ss=''
for i=0,21 do begin
  readf,iun,ss
endfor

readf,iun,tt,format=f1
lam=tt

i=0
while(not eof(iun)) do begin
; readf,iun,v1,v2,v3,format=f3
; teff(i)=v1
; logg(i)=v2
; logz(i)=v3
  sss=''
  readf,iun,sss
  words=get_words(sss)
  teff(i)=float(words(1))
  logg(i)=float(words(3))
  nc=strlen(words(4))
  w4=strmid(words(4),1,nc-2)
  logz(i)=float(w4)

  readf,iun,tt,format=f2
  flux(*,i)=tt
  readf,iun,tt,format=f2
  fluxc(*,i)=tt
  i=i+1
endwhile

flux=flux(*,0:i-1)
fluxc=fluxc(*,0:i-1)
teff=teff(0:i-1)
logg=logg(0:i-1)
logz=logz(0:i-1)
vturb=vturb(0:i-1)
nmod=i

close,iun
free_lun,iun

end

;TEFF   3500.  GRAVITY 0.00000   [-0.5] N(He)/Ntot=0.0784 VTURB=2.0  L/H=1.25 NOV