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!

Reading last line of input file

Status
Not open for further replies.

206099

Programmer
Aug 31, 2009
1
US
Hi,

I'm posting this simple question here, because I haven't found a satisfactory solution online.
My problem is: I have a huge input unformatted file (say ~1GB) with data and I want to be able to read the last line of data without having to go through the whole file (reading line by line till I reach the end). Is there a way to jump to the last line? I'd like to do it using only F90 and not with some bash/F90 script.
Thanks.
 
Do you want to do it in standard Fortran 90 or are you using a specific compiler. Some compilers have additional stuff like position='append' and recordtype='stream_cr' which will cause the file cursor to be positioned at EOF. All you need to do is to open for appending, then is backspace and read.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top