polystethylene writes:
> I've run into a strange problem with this:
>
> FOR i=0,nfiles-1 do begin
> infile = string(filefolder)+string(i+1,format='("/",i3.3,".dump")')
> OPENR,lun,infile,/GET_LUN
> rows = FILE_LINES(infile)
> data = fltarr(10,nstar,nfiles)
> framearray = fltarr(10,rows)
> READF,lun,format ='(I2,1x,I2,1x,I2,2x,F0,2x,I0,5F0.3)',framearray
> close,lun
> free_lun,lun
> data[0,0,i] = framearray
> print,i
> print,data[*,*,i]
> ENDFOR
> print,data
> RETURN
> END
>
> I've stuck a print statement within the loop to check that each 2-d
> array is being written to the 3-d array with each pass of the loop,
> and it seemed to be working fine.
> However, when I came to pass the variable 'data' out to another
> procedure, I noticed it was (mainly) full of zeros. A quick print
> statement outside the loop within the above procedure revealed that I
> had zeros throughout the entireity of 'data', except for the final
> value of i.
>
> I.e. there were only values for data[*,*,124], where 124 is the last
> value of the loop index.
>
> Has anyone come across such behaviour before?
Humm. Well, now that you mention it, maybe I tried
that array[0,0,I] = something trick before and it didn't
work. I was afraid of this, but I didn't have time (nor
do I today) to test it. :-(
I think you are going to have to explicitly figure out
how big the thing on the right-hand side is, and set
your subscripts on the left-hand side to reflect what you
are trying to store there.
I guess the other choice would be to have a 2D "frame" that you
stuffed each right-hand side into, using the trick above (which
*will* work). Then stuff that "frame" into your 3D array.
Sort of ugly, I guess.
Cheers,
David
--
David Fanning, Ph.D.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|