Fortran 2003 Standard

VALUE

Purpose

The VALUE attribute specifies an argument association between a dummy and an actual argument. This association allows you to pass the dummy argument with the value of the actual argument. This pass by value implementation from the Fortran 2003 Standard provides a standard conforming option to the %VAL built-in function.

An actual argument and the associated dummy argument can change independently. Changes to the value or definition status of the dummy argument do not affect the actual argument. A dummy argument with the VALUE attribute becomes associated with a temporary variable with an initial value identical to the value of the actual argument.

Syntax

Read syntax diagramSkip visual syntax diagram>>-VALUE--+----+--dummy_argument_name_list---------------------><
          '-::-'
 

Rules

You must specify the VALUE attribute for dummy arguments only.

You must not use the %VAL or %REF built-in functions to reference a dummy argument with the VALUE attribute, or the associated actual argument.

A referenced procedure that has a dummy argument with the VALUE attribute must have an explicit interface.

A dummy argument with the VALUE attribute can be of character type if you omit the length parameter or specify it using an intitalization expression with a value of 1.

You must not specify the VALUE attribute with the following:

Attributes compatible with the VALUE attribute

If a dummy argument has both the VALUE and TARGET attributes, any pointers associated with that dummy argument become undefined after the execution of the procedure.

Examples

Program validexm1
  integer :: x = 10, y = 20
  print *, 'before calling: ', x, y
  call intersub(x, y)
  print *, 'after calling: ', x, y

  contains
  subroutine intersub(x,y)
    integer, value ::  x
    integer y
    x = x + y
    y = x*y
    print *, 'in subroutine after changing: ', x, y
  end subroutine
end program validexm1

Expected output:

before calling: 10 20
in subroutine after changing: 30 600
after calling: 10 600

Related information

For more information, see the %VAL built-in function.

End of Fortran 2003 Standard