The A specifier is used for character type data items. The general form is:
A [ w ]
On input, character data is stored in the corresponding list item.
On output, the corresponding list item is displayed as character data.
If w is omitted, then:
For character data type variables, it assumes the size of the variable.
For noncharacter data type variables, it assumes the maximum number of characters that fit in a variable of that data type. This is nonstandard behavior. @
Each of the following examples read into a size n variable (CHARACTER*n), for various values of n, for instance, for n = 9.
CHARACTER C*9 READ '( A7 )', C
The various values of n, in CHARACTER C*n are:
Size n |
9 |
7 |
4 |
1 |
---|---|---|---|---|
Data |
Node¤Id |
Node¤Id |
Node¤Id |
Node¤Id |
Format |
A7 |
A7 |
A7 |
A7 |
Memory |
Node¤Id¤¤ |
Node¤Id |
e¤Id |
d |
¤ indicates a blank space.
Example: Output strings of 3, 5, and 7 characters, each in a 5 character field:
PRINT 1, 'The', 'whole', 'shebang' 1 FORMAT( A5 / A5 / A5 ) END
¤¤The whole sheba
The maximum characters in noncharacter types are summarized in the following table.
Table 5-5 Maximum Characters in Noncharacter Type Hollerith (nHaaa)
Type of List Item |
Maximum Number of Characters |
---|---|
BYTE LOGICAL*1 LOGICAL*2 LOGICAL*4 LOGICAL*8 INTEGER*2 INTEGER*4 INTEGER*8 REAL REAL*4 REAL*8 REAL*16 (SPARC only) DOUBLE PRECISION COMPLEX COMPLEX*8 COMPLEX*16 COMPLEX*32 (SPARC only) DOUBLE COMPLEX |
1 1 2 4 8 2 4 8 4 4 8 16 8 8 8 16 32 16 |
In f77, you can use Hollerith constants wherever a character constant can be used in FORMAT statements, assignment statements, and DATA statements.© These constants are not recommended. FORTRAN does not have these old Hollerith (n H) notations, although the FORTRAN Standard recommends implementing the Hollerith feature to improve compatibility with old programs. But such constants cannot be used as input data elements in list-directed or NAMELIST input.
For example, these two formats are equivalent:
10 FORMAT( 8H Code = , A6 ) 20 FORMAT( ' Code = ', A6 )
In f77, commas between edit descriptors are generally optional:
10 FORMAT( 5H flex 4Hible )