[UP]


Manual Reference Pages  - read_line (3)

NAME

read_line(3f) - [M_io] read a line from specified LUN into allocatable string up to line length limit cleaning up input line (LICENSE:MIT)

CONTENTS

Syntax
Description
Example
Author
License

SYNTAX

function read_line(line,lun) result(ier)

   character(len=:),allocatable,intent(out) :: line
   integer,intent(in)                       :: lun
   integer,intent(out)                      :: ier

DESCRIPTION

Read a line of any length up to programming environment’s maximum line length. Requires Fortran 2003+.

It is primarily expected to be used when reading input which will then be parsed.
o Append lines that end in a backslash with next line
o Expand tabs
o Replace unprintable characters with spaces
o Remove trailing carriage return characters and white space
The simple use of a loop that repeatedly re-allocates a character variable in addition to reading the input file one buffer at a time could (depending on the programming environment used) be inefficient, as it could reallocate and allocate memory used for the output string with each buffer read.

EXAMPLE

Sample program:

   program demo_read_line
   use M_io, only : read_line
   implicit none
   character(len=:),allocatable :: line
      INFINITE: do while (read_line(line)==0)
         write(*,’(a)’)’[’//line//’]’
      enddo INFINITE
   end program demo_read_line

AUTHOR

John S. Urban

LICENSE

MIT License


read_line (3) November 13, 2019
Generated by manServer 1.08 from 76acab50-2908-46ba-ab96-ef8c19129b15 using man macros.