The OPTIONAL attribute permits dummy arguments to be omitted in a procedure reference.
The OPTIONAL attribute can be specified in a type declaration statement or an OPTIONAL statement, and takes one of the following forms:
type, [att-ls,] OPTIONAL [,att-ls] :: d-arg [,d-arg]...
OPTIONAL [::] d-arg [,d-arg]...
The OPTIONAL attribute can only appear in the scoping unit of a subprogram or an interface body, and can only be specified for dummy arguments.
A dummy argument is "present" if it associated with an actual argument. A dummy argument that is not optional must be present. You can use the PRESENT intrinsic function to determine whether an optional dummy argument is associated with an actual argument.
The following example shows a type declaration statement specifying the OPTIONAL attribute:
SUBROUTINE TEST(A) REAL, OPTIONAL, DIMENSION(-10:2) :: A END SUBROUTINE
The following is an example of the OPTIONAL statement:
SUBROUTINE TEST(A, B, L, X)
OPTIONAL :: B
...
IF (.NOT. PRESENT(B)) THEN
B = 1.0
END IF