Re: Need clarification on unformatted IO



Jason C <nightcom26@xxxxxxxxx> wrote:

> When I try to read in the content of the file with the following code,
> it crashes (segmentation fault):
>
> do i = 1, total
> read(12) differ_buffer(1:total2)
> end do
>
> However, if I use the following code, I can complete the read call:
>
> do i = 1, total
> read(12) (differ_buffer(j), j = 1, total2)
> end do

Those should be equivalent in terms of the standard if you have
accurately reported the circumstances and not left out some other
factor. It is vaguely possible, if total2 is large, that one form might
use more temporary space than the other, triggering a crash if you ran
out of resources. I'm not sure how likely I'd guess that to be, but it
is at least a possibility.

However, the "fragments" you quote below just confuse the matter and
make me wonder whether the report is entirely accurate. These are not
meaningful code fragments as you have written them. An I/o list makes no
sense standing on its own; it *MUST* be part of an I/O statement. And if
I'm reading what you are trying to say, then it is wrong. No, an implied
DO is not the same as a real DO loop. The above two
code fragments do mean the same thing, but the ones in your elaboration
below, once completed, would not.

> From what I've read from Fortran 90, don't the following code
> fragements the same thing?
>
>
> differ_buffer(A:B)
>
> and
>
> do i = A,B
> differ_buffer(i)
> enddo
>
> and
>
> differ_buffer(i), i = A,B


--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.