INTENT
Purpose
The INTENT attribute specifies the intended use of dummy arguments.
Syntax
Rules
- INTENT(IN) specifies that the dummy argument must not be redefined or become undefined during the execution of the subprogram.
- INTENT(OUT) specifies that the dummy argument must be defined before it is referenced within the subprogram. Such a dummy argument might not become undefined on invocation of the subprogram.
- INTENT(INOUT) specifies that the dummy argument can both receive and return data to the invoking subprogram.
- INTENT(IN) specifies that during the execution of the procedure, the
association status of the pointer dummy argument cannot be changed, except if the target of the
pointer is deallocated. If the target of the pointer is deallocated, the association status of the
pointer dummy argument becomes undefined.
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.
- INTENT(OUT) specifies that at the execution of the procedure, the association status of the pointer dummy argument is undefined
- INTENT(INOUT) specifies that the dummy argument can both receive and return data to the invoking subprogram.
- INTENT(IN) specifies that during the execution of the procedure, the allocation status of the dummy argument cannot be changed, and it must not be redefined or become undefined.
- INTENT(OUT) specifies that at the execution of the procedure, if the associated actual argument is allocated it will be deallocated.
- INTENT(INOUT) specifies that the dummy argument can both receive and return data to the invoking subprogram.
If a dummy argument with INTENT(OUT) is a derived type with default initialization, the dummy argument cannot be an assumed-size array.
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).
| ALLOCATABLE 1 | CONTIGUOUS 2 | TARGET |
| ASYNCHRONOUS | OPTIONAL | VALUE 1 |
| DIMENSION | POINTER | VOLATILE |
|
Note:
|
||
You must not specify the VALUE attribute for a dummy argument with an intent of OUT or INOUT
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 has no intent specified. This constraint does not apply to the
%REF built-in function.
Examples
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
- Intent of dummy arguments
- Argument association
- %VAL and %REF (IBM extension), for details on interlanguage calls
- Dummy arguments
