bug with internal file I/O?
Magnus Hagdorn
Magnus.Hagdorn@glg.ed.ac.uk
Fri Jun 8 15:17:00 GMT 2007
On Fri, 2007-06-08 at 08:00 -0700, Steve Kargl wrote:
>
> Although the program is invalid, there is definitely some problem
> with the implied-do loop in the IO statement. Consider this valid
> Fortran program
>
> program test
> implicit none
> character(len=100) :: value
> integer, dimension(100) :: intvalues
> integer i
>
> i = 2
> intvalues = 42
> value = "2 5 69"
> write(*,*) len(trim(value))
> read(value,*,end=20,err=20) (intvalues(i),i=1,100)
> 20 i=i-1
> !
> ! This should print 1 2 5 69
> !
> write(*,*) i, intvalues(1:3)
> !
> ! This prints the expected output 1 1 100
> !
> i = 1
> intvalues = (/ (i,i=1,100) /)
> print *, i, intvalues(1), intvalues(100)
> end program test
>
> The problem is a scoping issue. The implied-do-index has the
> scope of the implied-do.
>
ok, I can see the problem. Unfortunately, it doesn't solve what I had
hoped for. I wanted a way to find the number of integers I just read
from the string. I guess I could initialise the integer array to some
unlikely value and check for its first occurrence.
> Magnus, can you file a bug report in bugzilla?
>
I just created a bugzilla account and will report the bug ASAP.
Cheers
magnus
More information about the Fortran
mailing list