dustem_write_size_lv.pro 2.17 KB
PRO dustem_write_size_lv,dir,st,help=help

;+
; NAME:
;   dustem_write_size_lv
;
; PURPOSE:
;   writes information relating to size distribution parameters in the .DAT files 
;
; CATEGORY:
;    DustEMWrap, Distributed, LowLevel, Initialization
;
; CALLING SEQUENCE:
;   dustem_write_size_lv,dir,st
;
; INPUTS:
;    st   : dustem data structure
;    dir  : output directory where file will be written
;
; OPTIONAL INPUT PARAMETERS:
;    None
;
; OUTPUTS:
;    None
;
; OPTIONAL OUTPUT PARAMETERS:
;    None
;
; ACCEPTED KEY-WORDS:
;    help     : writes this help
;
; COMMON BLOCKS:
;    None
;
; SIDE EFFECTS:
;    Files are written
;
; RESTRICTIONS:
;    The DustEM fortran code must be installed
;    The DustEMWrap IDL code must be installed
;
; PROCEDURES AND SUBROUTINES USED:  
;
; EXAMPLES:
;
; MODIFICATION HISTORY:
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
;-
  IF keyword_set(help) THEN BEGIN
     doc_library,'dustem_write_size_lv'
     goto,the_end
  ENDIF

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

the_end:
END