FORTRAN

Getting the number of lines in a file

This program reads a file and gives you the number of lines in it. Using the keyword 'END' does the trick.

open(unit=12,file='YOURFILE',action=read)

nlines=0

do

read(12,*, end=100)

nlines = nlines + 1

end do

100 close(12)