next_line Subroutine

public subroutine next_line(unit, line, pos, lnum, iostat, iomsg)

Convenience function to read a line and update associated descriptors

Arguments

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

Formatted IO unit

character(len=:), intent(out), allocatable :: line

Line to read

integer, intent(out) :: pos

Current position in line

integer, intent(inout) :: lnum

Current line number

integer, intent(out) :: iostat

Status of operation

character(len=:), optional, allocatable :: iomsg

Error message


Source Code

subroutine next_line(unit, line, pos, lnum, iostat, iomsg)

   !> Formatted IO unit
   integer, intent(in) :: unit

   !> Line to read
   character(len=:), allocatable, intent(out) :: line

   !> Current position in line
   integer, intent(out) :: pos

   !> Current line number
   integer, intent(inout) :: lnum

   !> Status of operation
   integer, intent(out) :: iostat

   !> Error message
   character(len=:), allocatable, optional :: iomsg

   pos = 0
   call getline(unit, line, iostat, iomsg)
   if (iostat == 0) lnum = lnum + 1
end subroutine next_line