HP Fortran Programmer's Reference (September 2007)

Expressions and assignment
Assignment
Chapter 4 97
Assignment
An assignment operation defines a variable by giving it a value. In HP Fortran, there are four
types of assignment:
Intrinsic assignment (also known as the assignment statement)
Pointer assignment
Masked-array assignment (also known as the WHERE construct)
Defined assignment
The following sections describe the first three assignment types. The last—defined
assignment—is defined by the programmer, using the INTERFACE statement. For information
about defined assignment, see “Defined assignment” on page 187.
Assignment statement
An assignment statement gives the value of an expression to a variable. It has the following
syntax:
variable
=
expression
variable
may be any nonpointer variable or a pointer variable that is associated with a
target. (If
variable
is a pointer,
expression
is assigned to the target.) The valid
combinations of types for
variable
and
expression
are given in Table 4-5. The intrinsic
functions that document the conversions are described in Chapter 11.
Table 4-5 Conversion of
variable
=
expression
Variable
type
Expression type Conversion
Integer Integer, real, or complex
INT(
expression
, KIND(
variable
))
Real Integer, real, or complex
REAL(
expression
, KIND(
variable
))
Character Character (same kind
parameters)
CMPLX(
expression
, KIND(
variable
))
Logical Logical Truncate
expression
if its length is greater
than that of
variable
; otherwise, pad value
assigned to
variable
, with blanks.