INTEGER AGE, GRADE LOGICAL SUPER REAL RATE, HOURS, PAY, TAX, INSURE
In this example the first four items declared to be real would have had that type anyway had the default rules been left to operate. Confirmatory type specification does no harm.
There is no limit to the number of type statements that can be used
but a name must not have its type specified explicitly more than
once in a program unit. Type statements must precede all
executable statements in the unit; it is good practice, though not
essential, for them to precede other specification statements
referring to the same name. Type statements can be used in a
subprogram to specify the types of the dummy arguments and, in
an external function, the type of the function as well. Type
statements by themselves have no effect on intrinsic function
names but it is not a good idea to use them in this way.
The CHARACTER statement is slightly different from the others
because it also specifies the length of each character item, i.e. the
number of characters it holds. The length can be given separately
for each item, thus:
CHARACTER NAME*15, STREET*30, TOWN*20, PCODE*7
Alternatively, if several items are to have the same length, a default length for the statement can be given at the beginning:
CHARACTER*20 STAR, GALAXY, COMET*4, PLANET
This declares the name COMET to have a length of 4 characters, whereas STAR, GALAXY, and PLANET are all 20 characters long. If the length is not specified at all it defaults to one. The length can also be specified by means of a named integer constant or an integer constant expression enclosed in parentheses. For example:
PARAMETER (NEXT=15, LAST=80) CHARACTER TEXT*(NEXT+LAST)
Note that the length of a character item is fixed at compilation
time. The special form:
is permitted in two cases: for named constants the length of the literal constant in the PARAMETER statement is used (section 5.4); for dummy arguments of procedures the length of the associated actual argument is used (section 9.5). Type statements can also be used to declare the dimensions of arrays: this is described in section 5.6.