# Defined Assignment Statements

Defined assignment specifies an assignment operation. It is defined by a subroutine subprogram containing a generic interface block that specifies ASSIGNMENT(=). The subroutine is specified in a SUBROUTINE or ENTRY statement that has two nonoptional dummy arguments.

Defined elemental assignment is indicated by specifying ELEMENTAL in the SUBROUTINE statement.

The dummy arguments represent the variable and expression, in that order. The rank (and shape, if either or both are arrays), type, and kind parameters of the variable and expression in the assignment statement must match those of the corresponding dummy arguments. If the second dummy argument has the POINTER or ALLOCATABLE attribute, the subroutine cannot be invoked directly by a defined assignment operator. This is because the right-hand side of the assignment is an expression, and as such, cannot have the TARGET, POINTER, or ALLOCATABLE attribute.

The dummy arguments must not both be numeric, or of type logical or character with the same kind parameter.

If the variable in an elemental assignment is an array, the defined assignment is performed element-by-element, in any order, on corresponding elements of the variable and expression. If the expression is scalar, it is treated as if it were an array of the same shape as the variable with every element of the array equal to the scalar value of the expression.

Parent topic: Assignments

## See Also

Subroutines
Derived data types
Defining Generic Assignment for details on subroutine subprograms that define assignment
Numeric Expressions for details on intrinsic operations
Character Expressions for details on intrinsic operations