Returns the number of lines in a file (assumed to be open)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | iunit |
the file unit number (assumed to be open) |
the number of lines in the file
function number_of_lines_in_file(iunit) result(n_lines) integer,intent(in) :: iunit !! the file unit number !! (assumed to be open) integer :: n_lines !! the number of lines in the file character(len=1) :: tmp integer :: istat rewind(iunit) n_lines = 0 do !print*, n_lines read(iunit,fmt='(A1)',iostat=istat) tmp !print*, tmp if (is_iostat_end(istat)) exit n_lines = n_lines + 1 end do rewind(iunit) end function number_of_lines_in_file