9. Expressions
9.1. Character Constants
-
Character string constants are marked by strings surrounded by apostrophes.
If an apostrophe is to be included in a constant, it is repeated:
-
'abc'
'ain''t'
There are no null (zero-length) character strings in Fortran 77.
Our compiler has two different quotation marks, `` ' ''' and `` " ''.
(See Section 2.9 in the main text.)
9.2. Concatenation
-
One new operator has been added, character string concatenation, marked by a double slash
(``//'').
The result of a concatenation is the string containing the characters of the left operand followed by the characters of
the right operand.
The strings
-
'ab' // 'cd'
'abcd'
are equal.
The strings being concatenated must be of constant length in all concatenations
that are not the right sides of assignments.
(The only concatenation expressions in which a
character string declared adjustable with a ``*(*)'' modifier
or a substring denotation with nonconstant position values may appear
are the right sides of assignments).
9.3. Character String Assignment
-
The left and right sides of a character assignment may not share storage.
(The assumed implementation of character assignment is to copy characters from the right to the left side.)
If the left side is longer than the right, it is padded with blanks.
If the left side is shorter than the right, trailing characters are discarded.
9.4. Substrings
-
It is possible to extract a substring of a character variable or character array element, using the colon notation:
-
a(i,j) (m:n)
is the string of characters beginning at the
character of the character array element .
Results are undefined unless .
Substrings may be used on the left sides of assignments and as procedure actual arguments.
9.5. Exponentiation
-
It is now permissible to raise real quantities to complex powers,
or complex quantities to real or complex powers.
(The principal part of the logarithm is used).
Also, multiple exponentiation is now defined:
-
a**b**c = a ** (b**c)
9.6. Relaxation of Restrictions
-
Mixed mode expressions are now permitted.
(For instance,
it is permissible to combine integer and complex quantities in an expression.)
-
Constant expressions are permitted where a constant is allowed,
except in
data
statements.
(A constant expression is made up of explicit constants and
parameters
and the Fortran operators,
except for exponentiation to a floating-point power).
An adjustable dimension may now be an integer expression involving constants,
arguments, and variables in
B common..
-
Subscripts may now be general integer expressions;
the old
rules have been removed.
do
loop bounds may be general integer, real, or double precision expressions.
Computed
goto
expressions and I/O unit numbers may be general integer expressions.