Next: , Previous: Implicitly interconvert LOGICAL and INTEGER, Up: Extensions

7.11 Hollerith constants support

A Hollerith constant is a string of characters preceded by the letter `H' or `h', and there must be an literal, unsigned, nonzero default integer constant indicating the number of characters in the string. Hollerith constants are stored as byte strings, one character per byte.

gfortran supports Hollerith constants. They can be used as the right hands in the DATA statement and ASSIGN statement, also as the arguments. The left hands can be of Integer, Real, Complex and Logical type. The constant will be padded or truncated to fit the size of left hand.

Valid Hollerith constants examples:

     complex*16 x(2)
     data x /16Habcdefghijklmnop, 16Hqrstuvwxyz012345/
     call foo (4H abc)
     x(1) = 16Habcdefghijklmnop

Invalid Hollerith constants examples:

     integer*4 a
     a = 8H12345678 ! The Hollerith constant is too long. It will be truncated.
     a = 0H         ! At least one character needed.