FORTRAN Reference Manual

Statements
FORTRAN Reference Manual528615-001
7-8
Assignment Statement
contain the value, arithmetic overflow occurs. The type of name need not be the
same as the type of arithmetic-expression, but both must be arithmetic
types. If either name or arithmetic-expression is type character, both must
be type character. If either name or arithmetic-expression is type logical,
both must be type logical.
Character assignment statement
When your program executes a character assignment statement, FORTRAN
evaluates character-expression to produce a character string, and stores the
string in name. The type of name must be character, but it can have a different
length from character-expression.
If name is shorter than character-expression, FORTRAN truncates the
excess rightmost characters of character-expression. If name is longer than
character-expression, FORTRAN pads character-expression with
blanks (on the right) until its length is equal to that of name.
The character expression cannot refer to any character position included in name.
For example, the following statement is invalid:
name(3:9) = name(2:7)
because the string NAME(3:7) appears on both sides of the equals sign. The
following expression is valid because the two substrings are separate entities:
name(1:3) = name(4:6)
If name refers to a substring, only that substring is affected by the assignment
statement.
Note that in the case of character assignments, intermediate results are not stored
in temporary locations. The evaluation of a character expression progresses from
left to right, character by character to the receiving location. In the following
example, the value of A is “abcdeabcde” not “abcdefghij”:
CHARACTER*10 A
A = 'fghij'
A = 'abcde' // A
For additional information about character expressions, see Section 3,
Expressions.
Logical assignment statement
When a logical assignment statement executes, FORTRAN evaluates
logical-expression and assigns its value to name, which must be of logical
type.