is this a bug in IDL? [message #37378] |
Tue, 16 December 2003 02:31 |
aramisgm
Messages: 4 Registered: December 2003
|
Junior Member |
|
|
OK, so I was hanging with a friend who is doing some work with
satellite data. She was having trouble getting a program to compile.
After fixing some bugs and rewriting some code, we got the program to
run as desired. I suggested that she add a counter for data
verification. This generated a small surprise and two questions.
Here's the part of the program causing the fuss (please excuse the
hard-coded indexing, it's "quick-and-dirty" code):
k=0
for i=0,8759 do begin
x=vbs(2,i)
if x gt 0.0 then k=k+1 & x=0 & vbs(2,i)=x
endfor
print, k
k=0
for i=0,8759 do begin
x=vbs(2,i)
;; version A
if x gt 0.0 then x=0 & k=k+1 & vbs(2,i)=x
;; version B
if x gt 0.0 then k=k+1 & x=0 & vbs(2,i)=x
endfor
print, k
1) How would you vectorize this? I tried a few things that I could
remember from my work this summer, but four months of quantum
mechanics wipes a lot from memory :)
2) At first, we only had version A of the second loop, which output
the value k==8760 (meaning the entire data set gets zeroed out). After
examining the data set and the output, I knew something weird was
going on -- the negative values in the data were not being altered, so
the counter was not behaving correctly. We added the first loop to see
exactly how many values should be altered, yielding k==4167. We then
discovered the following behavior:
Using the if marked version A generates the output
4167
8670
while the if marked version B generates
4167
4167.
Is this a bug? as far as I can tell, the statements are logically
identical since an &'s behavior should never vary, so what in the guts
of IDL would make these statements be different? Is there some rule
kicking in here that's not so obvious but makes this behavior to be
expected? Would parenthesis around the THEN block make these identical
in IDL? The environment is either IDL 6 on Red Hat 9 or IDL 5.1 on
Red Hat 8.1.
Thanks for any enlightenment you folks can share.
Aramis Martinez
|
|
|