An expression is a data reference or a computation, and is formed from operands, operators, and parentheses. An expression, when evaluated, produces a value, which has a type, a shape, and possibly type parameters.
An operand is either a scalar or an array. An operator is either intrinsic or defined. A unary operation has the form:
A binary operation has the form:
where the two operands are shape-conforming. If one operand is an array and the other is a scalar, the scalar is treated as an array of the same shape as the array, and every element of the array has the value of the scalar.
Any expression contained in parentheses is treated as a data entity. Parentheses can be used to specify an explicit interpretation of an expression. They can also be used to restrict the alternative forms of the expression, which can help control the magnitude and accuracy of intermediate values during evaluation of the expression. For example, the two expressions
are mathematically equivalent, but may produce different computational values as a result of evaluation.
A primary is the simplest form of an expression. It can be one of the following:
A primary that is a data object must not be an assumed-size array.
12.3 ! Constant 'ABCDEFG'(2:3) ! Subobject of a constant VAR ! Variable name (/7.0,8.0/) ! Array constructor EMP(6,'SMITH') ! Structure constructor SIN(X) ! Function reference (T-1) ! Expression in parentheses
The type, type parameters, and shape of a primary are determined as follows:
If a pointer appears as a primary in an operation in which it is associated with a nonpointer dummy argument, the target is referenced. The type, parameters, and shape of the primary are those of the target. If the pointer is not associated with a target, it can appear only as an actual argument in a procedure reference whose corresponding dummy argument is a pointer, or as the target in a pointer assignment statement.
Given the operation [ expr1] op expr2, the shape of the operation is the shape of expr2 if op is unary or if expr1 is a scalar. Otherwise, its shape is that of expr1.
The type and shape of an expression are determined by the operators and by the types and shapes of the expression's primaries. The type of the expression can be intrinsic or derived. An expression of intrinsic type has a kind parameter and, if it is of type character, it also has a length parameter.