next up previous contents
Next: Printing your graph. Up: Importing data Previous: Importing data   Contents

Writing data

Writing data is very similar to reading it. The program below can be used to write a variable called ``data'' to a file (with it's name defined by a variable called ``output_file''). E.g. it could be called (if you have read some data into ``data'' already, for example using modtran.pro) using:
write_data,data,'~lecjm/outputdata.dat'}

--------------

pro write_data, data, output_file, binary=binary

;+
;pro write_data, data, output_file, binary=binary
;Writes data to output file in  ascii, unless keyword(binary) set
;John Marsham (18/04/2005)
;-

; Openw for write instead of openr for read
openw,1,output_file

if not keyword_Set(binary) then begin 
 ; printf to print ascii to file (print to screen)
 printf,1,data
endif else begin
 ; writeu to write binary to file (readu to read it)
 writeu,1,data
endelse

;Close the file 
close,1

end



lecjm 2008-11-06