NULL(MOLD)

Purpose

This function returns a pointer or designates a deallocated allocatable component of a structure constructor. The association status of the pointer is disassociated.

You must use the function without the MOLD argument in any of the following:
  • initialization of an object in a declaration
  • default initialization of a component
  • in a DATA statement
  • in a STATIC statement
You can use the function with or without the MOLD argument in any of the following:
  • in the PARAMETER attribute
  • on the right side of a pointer assignment
  • in a structure constructor
  • as an actual argument

Class

Transformational function.

Argument type and attributes

MOLD (optional)
An INTENT(IN) argument. The corresponding actual argument must be a pointer or allocatable. The actual argument can be of any type or can be a procedure pointer. The association status of the pointer can be undefined, disassociated, or associated. If the actual argument has an association status of associated, the target may be undefined. If the actual argument is allocatable, its allocation status can be allocated or deallocated.

Result type and attributes

If MOLD is present, the result's characteristics are the same as those of MOLD. If MOLD has deferred type parameters, those type parameters of the result are deferred. If MOLD is not present, the entity's type, type parameter and rank are determined as follows:
  • same as the pointer that appears on the left hand side, for a pointer assignment
  • same as the object, when initializing an object in a declaration
  • same as the component, in a default initialization for a component
  • same as the corresponding component, in a structure constructor
  • same as the corresponding dummy argument, as an actual argument
  • same as the corresponding pointer object, in a DATA statement
  • same as the corresponding pointer object, in a STATIC statement

Result value

The result is a pointer with disassociated association status or an unallocated allocatable entity.

Examples

! Using NULL() as an actual argument.
INTERFACE
   SUBROUTINE FOO(I, PR)
      INTEGER I
      REAL, POINTER:: PR
   END SUBROUTINE FOO
END INTERFACE

CALL FOO(5, NULL())