;-------------------------------------------------------------- ; read_tf - read a ascii file into an array. Number of column ; must be known, but the number of rows are variable. ; Rdata - data stored here, as data(c,r). Function resizes ; array based on numbers of rows read in. ; filename - filename to read. ; nc - number of columns ; maxr - limit on the number of row ; ; example: readin the history data (19 columns) can be done like so, ; read_tf, data, 'in.dat', 18, 1000 ;-------------------------------------------------------------- PRO read_tf, Rdata, filename, nc, maxr get_lun, lun openr, lun, filename data = dblArr(nc, maxr ) rows = 0 d =dblarr(nc) while( not eof(lun)) do begin readf, lun, d for c=0, nc-1 do begin data(c,rows) = d(c) endfor rows = rows + 1 endwhile ;print, "read nc=", nc, " maxr=", maxr, " r=", r rdata = dblArr(nc, rows ) for r=0, rows-1 do begin rdata(*,r) = data(*,r) endfor free_lun, lun end