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 ;st={file:file, $ ; Tgas:0.D0,nH:0.D0,nh2:0.D0,CR_rate:0.D0,G0:0.D0,n_charges:0L, $ ; charges_props:ptr_new(), $ ; comments:strarr(Ncomments)} ;one_charge_st={density:0.D0,mass:0.D0,charge:0.D0,polarizability:0.D0} 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 the_end: END ; ;==== LEFT OVERS ; ; PRO dustem_write_gas,dir,st ; ; ; ;Writes ALL the GAS_xxx.DAT files ; ;stop ; ; comments=st.comments ; Ncomments=n_elements(comments) ; ; frmt='(A)' ; ; ;Get filename ; ffile=st.file ; fv=str_sep(ffile,'/') ; file=dir+fv(n_elements(fv)-1) ; ;Open file ; message,'Will write GAS file '+file,/continue ; openw,unit,file,/get_lun ; ;Print comments ; IF Ncomments NE 0 THEN BEGIN ; FOR ii=0,Ncomments-1 DO BEGIN ; printf,unit,comments[ii] ; ENDFOR ; ENDIF ; ;print data ; FOR k=0L,n_elements(st.fgas)-1 DO BEGIN ; printf,unit,(st.fgas)[k],format=frmt ; ENDFOR ; close,unit ; free_lun,unit ; ; END ;