At 01:18 PM 2/5/2003 -0500, Xiaogang Wang wrote:
>I found the following program 1 and 2 give different binary files.
>Could anyone explain why?
Richard has already explained why. I will suggest one other
workaround. If you have a file that was written by
write(11) A
you could read it with
read(11) A(:,1)
backspace 11
read(11) A(:,2),A(:,2)
The first READ statement reads _all_ of A, but discards everything it reads
after the first column. The backspace statement then repositions back to
the beginning of the record containing A. The second read statement again
reads all of A, putting the first column into A(:,2) [strictly as a means
of positioning within the record containing A] and then immediately
replacing that data with the values from the second column. An alternative
form of the second READ would be
read(11) (dummy,i=1,size(A,1)),A(:,2)
In this case the "positioning" is done by repeated reading data into the
scalar variable DUMMY instead of using A(:,2) for this purpose.
This approach is entirely standard conforming, but since it read the entire
array more than once, it is likely to be less efficient than the approaches
(standard and nonstandard) that Richard was suggesting.
-Kurt
--
Kurt W Hirchert [log in to unmask]
UIUC Department of Atmospheric Sciences +1-217-265-0327
|