PRO dustem_write_size_lv,dir,st Ncomments=10 c=strarr(Ncomments) c(0)='# Size distribution of grain species' c(1)='#' c(2)='# Nbr of bulk materials' c(3)='# Bulk densities in g/cm3' c(4)='# Mass fractions for each bulk' c(5)='# Nbr of size bins' c(6)='# [ a (cm), dloga, a^4*dn/da, f_mix, f_pol, rho_eff, fv ]' c(7)='# fmix mixing function for SED' c(8)='# fv: volume fraction of bulks, rho_eff: volume mean density' c(9)='#' Nst=n_elements(st) ;stop frmt='(7E14.6)' ; ;frmt='(7E10.2)' FOR i=0L,Nst-1 DO BEGIN IF ptr_valid(st(i)) THEN BEGIN ffile=(*st(i)).file fv=str_sep(ffile,'/') file=dir+fv(n_elements(fv)-1) openw,unit,file,/get_lun FOR ii=0,Ncomments-1 DO BEGIN printf,unit,c(ii) ENDFOR printf,unit,(*st(i)).Nbulk printf,unit,(*st(i)).density printf,unit,(*st(i)).mass_frac printf,unit,(*st(i)).nsize FOR k=0L,(*st(i)).nsize-1 DO BEGIN printf,unit,((*st(i)).size_st.a)(k),((*st(i)).size_st.dloga)(k),((*st(i)).size_st.a4dnda)(k),((*st(i)).size_st.f_mix)(k), $ ((*st(i)).size_st.f_pol)(k),((*st(i)).size_st.rho_eff)(k),((*st(i)).size_st.fv)(k),format=frmt ENDFOR close,unit free_lun,unit ENDIF ENDFOR END