Purpose
The INTENT attribute specifies the intended use of dummy arguments.
Format
>>-INTENT--(--+-IN----+--)--+----+--dummy_arg_name_list-------->< +-OUT---+ '-::-' '-INOUT-' |
Rules
If you specify a nonpointer, nonallocatable dummy argument, the INTENT attribute will have the following characteristics:
If you specify a pointer dummy argument, the INTENT attribute will have the following characteristics:
You cannot use an INTENT(IN) pointer dummy argument as a pointer object in a pointer assignment statement. You cannot allocate, deallocate, or nullify an INTENT(IN) pointer dummy argument
You cannot specify an INTENT(IN) pointer dummy argument as an actual argument to a procedure if the associated dummy argument is a pointer with INTENT(OUT) or INTENT(INOUT) attribute.
If you specify an allocatable dummy argument, the INTENT attribute will have the following characteristics:
If you do not specify the INTENT attribute for a pointer or allocatable dummy argument, its use is subject to the limitations and restrictions of the associated actual argument.
An actual argument that becomes associated with a dummy argument with an intent of OUT or INOUT must be definable. Hence, a dummy argument with an intent of IN, or an actual argument that is a constant, a subobject of a constant, or an expression, cannot be passed as an actual argument to a subprogram expecting an argument with an intent of OUT or INOUT.
An actual argument that is an array section with a vector subscript cannot be associated with a dummy array that is defined or redefined (that is, with an intent of OUT or INOUT).
+-------------------------------IBM Extension--------------------------------+
The %VAL built-in function, used for interlanguage calls, can only be used for an actual argument that corresponds to a dummy argument with an intent of IN, or that has no intent specified. This constraint does not apply to the %REF built-in function.
+----------------------------End of IBM Extension----------------------------+
Attributes Compatible with the INTENT Attribute | |||
---|---|---|---|
|
PROGRAM MAIN DATA R,S /12.34,56.78/ CALL SUB(R+S,R,S) END PROGRAM SUBROUTINE SUB (A,B,C) INTENT(IN) A INTENT(OUT) B INTENT(INOUT) C C=C+A+ABS(A) ! Valid references to A and C ! Valid redefinition of C B=C**2 ! Valid redefinition of B END SUBROUTINE
Related Information