dustem_write_gas.pro 2.03 KB
PRO dustem_write_gas,file,st,help=help

;+
; NAME:
;   dustem_write_gas
;
; PURPOSE:
;   writes information relating to gas properties in the
;   corresponding .DAT file
;
; CATEGORY:
;    DustEMWrap, Distributed, LowLevel, Initialization
;
; CALLING SEQUENCE:
;   dustem_write_gas,file,st
;
; INPUTS:
;    st   : dustem data structure
;    file  : output file to 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_gas'
     goto,the_end
  ENDIF

  
;=== Note about format for DUSTEM_WHICH=RELEASE
;# DUSTEM : Gas quantities from Ysard, Juvela & Verstraete (2011)
;# 
;# Gas temperature (K), hydrogen density, H2 density, CR rate, G0 (if>0 supersedes GRAIN.DAT)
;# number of charge type (electrons, H+, C+, ...)
;# ion density (cm-3), mass (amu), charge, polarizability (A^3)
;# >>>>> 1st line is electron <<<<<<<
;# 
;  3.5550e+03 1e-1 -1e0 5e-17   1.0000e+00 3
;-1e0 5.4858e-04 -1e0 0.00
;0e0  1.00794e0   1e0 0.67
; -1.3000e-05 12.0107e0   1e0 1.54

Ncomments=n_elements(st.comments)

openw,unit,file,/get_lun

FOR i=0,Ncomments-1 DO BEGIN
  printf,unit,st.comments[i]
ENDFOR

frmt='(5E14.6,I4)'
printf,unit,st.Tgas,st.nH,st.nh2,st.CR_rate,st.G0,st.n_charges,format=frmt

frmt='(3E14.6,F5.2)'
FOR i=0L,st.n_charges-1 DO BEGIN
	sst=(*st.charges_props)[i]
  printf,unit,sst.density,sst.mass,sst.charge,sst.polarizability,format=frmt
  ;IF !dustem_verbose EQ 1 THEN BEGIN
  ;  print,unit,sst.density,sst.mass,sst.charge,sst.polarizability,format=frmt
  ;ENDIF
ENDFOR

close,unit
free_lun,unit
;stop

the_end:
END