081. Syntax for character array without manual padding#

topic: Character variables

Note

This tip is a draft1.

Fortran 2003 lets you write an array of character variables as

s = [character (len=4) :: “one”,”two”,”five”]

instead of

s = [“one “,”two “,”five”] ! “one” and “two” padded

Manually padding large arrays of strings is a pain.



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.