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!

File length

Status
Not open for further replies.

cjkogan111

Technical User
Jul 12, 2007
5
US
Hello,
Lets say that I have a file -

5 4 3
9 2 4
2 5 3
2 1 1

And I am reading in variables a,b,c.

Does anyone know how I determine the # of lines in the file before I read it in?

Thanks!
-cjkogan111
 
I think you can't, you either start with that number and read that number, so...

4
5 4 3
9 2 4
2 5 3
2 1 1

or you read till end of file DO WHILE(.NOT.EOF(1)) etc
you count the lines and you read again after allocating

Any other suggestions are welcome, I don't know anything better

Regards,

Gerrit
 
I think you can do this using the inquire function, but I'd have to admit that I can't get it to work..
Something along the lines of:

inquire (unit=21, recl=n)

then n should be the file length. Except that this doesn't work, but I'm pretty sure it's something like that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top