Fortran 95
NULL(MOLD)
Purpose
This function returns a pointer or designates an unallocated 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)
- must be a pointer and can be of any type. The association status of
the pointer can be undefined, disassociated, or associated. If the MOLD argument has an association status of associated, the target may be
undefined.
Result type and attributes
If MOLD is present, the pointer's type, type parameter, and rank
are the same as MOLD. 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())
End of Fortran 95