Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EOF() intrinsic function ? 1

Status
Not open for further replies.

Renardp

Technical User
May 26, 2007
8
CA
Hi all, I have a problem with reading a file in wich i don't know in advance how much lines i need to read.
In the past I could solve the problem with the next lines:

....
open(10,file='data.txt')
do while(.not.eof(10))
read(10,*)x
enddo
....

this solution works well with Compaq Fortran and Intel Fortran.
When I try to use same code with gfortran or g95 it seems that they don't have implemented the EOF intrinsic function, maybe this is not a standard function ...

Do you have any sugestion how to avoid the use of EOF ?

Thanks.

 
The standard Fortran way is to do it in the read statement. It works like a goto.
Code:
open (10, file='data.txt')
do while (.true.)
   read (10, *, end=999) x
enddo
999 continue
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top