FORTRAN Reference Manual

Hollerith Constants and Punch Card Codes
FORTRAN Reference Manual528615-001
H-2
Editing Hollerith Data
dummy argument. Table H-1 shows the relationship between the data type of a dummy
argument and the maximum number of characters in a Hollerith string.
The following example uses a DATA statement to initialize the quadrupleword integer K
to the string “JANUARY ”. Because January has only seven letters in it, a single blank
after the Y in January is included in the Hollerith constant:
INTEGER*8 k
DATA k/8HJANUARY /
The following example shows a CALL statement that specifies a Hollerith constant:
CALL sub(2HNO)
The following example uses a Hollerith constant in a FORMAT statement:
WRITE (10, 100) balance
100 FORMAT(1x, 11HBalance is , F8.2)
If the length of string is less than the number of characters the entity can contain, the
characters are left justified in the entity and the remaining character positions are filled
with blanks.
Editing Hollerith Data
Use the A w edit descriptor with Hollerith data when an I/O list item is of type integer,
real, or logical; for example:
DATA j,a/54321,4H$$$$/
WRITE (*,33) j,a
33 FORMAT (I5,A4)
Table H-1. Hollerith Constant String Lengths
Entity Maximum Characters Example
INTEGER*2 2 DATA j /2H++/
LOGICAL 2 DATA c /2Hno/
INTEGER*4 4 DATA k /4Hplus/
REAL 4 DATA c /4Hwork/
LOGICAL*4 4 DATA a /4Htrue/
INTEGER*8 8 DATA m /8HPersonal/