Lahey/Fujitsu Fortran

VALUE Statement and Attribute

Description

The VALUE attribute specifies that the dummy argument is passed by value, rather than by reference.

				

Syntax

[type-decl,] VALUE [::] var WHERE: type-decl is an intrinsic or derived type data declaration var is a variable name

Remarks

The VALUE attribute may only be specified for a dummy argument.

If the VALUE attribute is specified, the PARAMETER, EXTERNAL, POINTER, ALLOCATABLE, DIMENSION, INTENT(INOUT), or INTENT(OUT) attributes cannot be specified.

If the VALUE attribute is specified for a dummy argument of type CHARACTER, the length parameter shall be omitted, or be specified by an initialization expression having a value of one.

If a dummy argument has the VALUE attribute, a temporary copy of the actual argument is made, and the copy is associated with the dummy argument. Subsequent changes to the dummy argument do not affect the value or status of the actual argument.

If the dummy argument has both the VALUE and TARGET attributes, any pointers associated with the dummy argument become undefined when execution of the procedure is complete.

By default, Fortran passes arguments by reference.

				

Example

subroutine method1(valuearg1,valuearg2) real,value :: valuearg1 ! value attribute integer :: valuearg2 value :: valuearg2 ! value statement ! do something end subroutine method1