comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: readf help!
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: readf help! [message #47511] Tue, 14 February 2006 11:14 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Jonathan Wolfe wrote:
> Thank you Paul! That was my problem. I didn't define the variable as
> a long to begin with. Actually, I rarely define them first... A habit I
> will start from now on! Thanks again! Jon

BTW, if you want the code to run even faster, then you may want to read all the data into
a correctly sized array rather than use a for or while loop, e.g. instead of

while not eof(lun) do begin
readf, lun, a, b, c, d, e, f, g, h
.....
endwhile

do something like

pro test_read
openr,lun,'data.asc',/get_lun
nvar=8 ; No of variables in a line
nlin=3 ; No of lines to read
a=dblarr(nvar,nlin) ; Note it's DBL for the "b" time value
readf, lun, a
print, a, format='(8(1x,e16.9))'
free_lun, lun
end

IDL> test_read
1.000000000e+00 1.137369600e+09 0.000000000e+00 0.000000000e+00 2.220000000e+00
-3.000000000e-01 9.300000000e+00 9.400000000e+00
1.000000000e+00 1.137369601e+09 0.000000000e+00 0.000000000e+00 2.220000000e+00
-3.000000000e-01 9.200000000e+00 9.400000000e+00
1.000000000e+00 1.137369602e+09 0.000000000e+00 0.000000000e+00 2.320000000e+00
-3.000000000e-01 9.300000000e+00 9.400000000e+00

The only downside is that you have to know how many lines there are in your data files to
correctly set the "nlin" dimension of "a", but your original post suggested that you do
(the "vs" variable).

paulv

--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: cmlib
Next Topic: tv and tvscl problems

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 21:12:16 PDT 2025

Total time taken to generate the page: 0.24245 seconds