[UP]


Manual Reference Pages  - read_all (3)

NAME

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

CONTENTS

Syntax
Description
Options
Returns
Example
Author
License

SYNTAX

function read_all(line,lun) result(ier)

   character(len=:),allocatable,intent(out) :: line
   integer,intent(in),optional              :: 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.

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.

OPTIONS

LINE line read
LUN optional LUN (Fortran logical I/O unit) number. Defaults to stdin.

RETURNS

IER zero unless an error occurred. If not zero, LINE returns the I/O error message.

EXAMPLE

Sample program:

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

AUTHOR

John S. Urban

LICENSE

MIT License


read_all (3) November 13, 2019
Generated by manServer 1.08 from 5eb5018e-c371-40f0-b570-c1b7164545ea using man macros.