Intel® Fortran Compiler

Developer Guide and Reference

ID 767251
Date 3/31/2025
Public
Document Table of Contents

NULL

Transformational Intrinsic Function (Generic): Returns a disassociated pointer or an unallocated entity with the allocatable attribute.

result = NULL ([mold])

mold

(Optional) Must be a pointer or have the allocatable attribute; it can be of any type or be a procedure pointer. If it is a pointer, its pointer association status can be associated, disassociated, or undefined. If it is allocatable, its allocation status can be either allocated or deallocated. It does not have to be defined with a value.

Results

The result type and kind are the same as mold, if present. The result has deferred type parameters if mold has deferred type parameters.

If mold is not present, the result characteristics are determined by the entity with which the function reference is associated, as specified in the table below.

If NULL ( ) Appears...

Type is Determined From...

On the right side of pointer assignment

The pointer on the left side

As initialization for an entity in a declaration

The entity

As default initialization for a component

The component

In a structure constructor

The corresponding component

As an actual argument

The corresponding dummy argument

In all other contexts, mold must be present. If the contextual entity has any deferred type parameters, those type parameters of the result are deferred. mold must be present if any of the contextual entity’s type parameters are assumed.

If NULL appears as an actual argument in a generic procedure reference, mold must be present if the type, type parameters, or rank are required to resolve the generic procedure reference. mold must be present if the reference to NULL is an actual argument corresponding to an assumed-rank array.

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

CAUTION:

If you use module IFWIN or IFWINTY, you will have a name conflict if you use the NULL intrinsic. To avoid this problem, rename the integer parameter constant NULL to something else; for example:

USE IFWIN, NULL0 => NULL

This example lets you use both NULL0 and NULL( ) in the same program unit with no conflict.

Examples

Consider the following:

INTEGER, POINTER :: POINT1 => NULL( )

This statement defines the initial association status of POINT1 to be disassociated.

mold is required in the following example:

SUBROUTINE SUB () REAL, ALLOCATABLE, DIMENSION (:, :) :: ARR(8) . . . CALL INNER_SUB (NULL (MOLD=ARR)) . . . CONTAINS SUBROUTINE INNER_SUB (A) REAL, ALLOCATABLE, DIMENSION (..) :: A . . . END SUBROUTINE INNER_SUB END SUBROUTINE SUB