number_of_rows Function

public function number_of_rows(s) result(nrows)

Determine number or rows in a file given a LUN

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: s

Return Value integer


Source Code

integer function number_of_rows(s) result(nrows)
    integer,intent(in)::s
    integer :: ios
    rewind(s)
    nrows = 0
    do
        read(s, *, iostat=ios)
        if (ios /= 0) exit
        nrows = nrows + 1
    end do
    rewind(s)
end function number_of_rows