172. Use the “(a)” format to read a line of a file into a string.#

topic: Input and Output

Note

This tip is a draft1.

character (len=100) :: s read (iunit,”(a)”) s

will read the first 100 characters of a line into s, padding with blanks if necessary.

read (iunit,*) s

will read the first “word” of the line, where words are separated by blanks or commas.



1

From the perspective of FortranTip Browser, “draft” means that it hasn’t been edited for formatting, hasn’t had corresponding Fortran programs added, the text content hasn’t been enhanced, etc. Draft texts are extracted from the corresponding Tweet using the Twitter API.