Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Fortran 90 Programmer's Reference: HP Series 700/800 Computers > Chapter 3 Data types and data objects

Dynamic data objects

» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

Allocatable arrays, pointers and automatic objects are allocated dynamically.

Allocatable arrays

The definition and description of use of allocatable arrays is in Chapter 4.

Pointers

A variable with the POINTER attribute is referred to as a pointer. It can be in one of three states: undefined, disassociated, or associated. On entry to a program, all pointers are undefined.

If variable p is a pointer:

  • ALLOCATE(p) acquires storage and associates p with this storage, which becomes its target.

  • DEALLOCATE(p) disassociates p from its target (which must have been previously ALLOCATEd) and frees the storage occupied by the target.

  • NULLIFY(p) disassociates p from any target but does not alter the status of the target.

The ASSOCIATED intrinsic function inquires if a pointer is associated with:

  • Any target

  • A specific target

  • The same target as another pointer

A pointer can also be associated with an existing target using pointer assignment (see Chapter 5 for details). Briefly, p => t associates pointer p with target t. If t is a pointer then p becomes associated with the target with which t is associated.

Cray-style pointers

For compatibility with earlier versions of Fortran, HP Fortran 90 supports Cray-style pointer variables ; see Chapter 10 for the syntax and examples. The use of Cray-style pointers is not recommended.

Automatic objects

An automatic object is an explicit-shape array or character string whose size is determined by values which are known only on entry to the procedure in which it is declared. It cannot be a dummy argument and cannot possess the SAVE attribute. Its storage space is dynamically allocated upon invocation of the subprogram and is released on return from the subprogram.

Consider the following example:

SUBROUTINE sub(n,...)
   ! a and c are not in the dummy argument list
   INTEGER, INTENT(IN) :: n
   ! n must have a value on entry
   REAL, DIMENSION(n) :: a
   CHARACTER(LEN=n) :: c
   ...
END SUBROUTINE sub

Array a is dynamically allocated on entry to the subroutine sub, by which time the value of n has been defined. Similarly, character variable c will be dynamically allocated, with length n. The storage for both of these automatic objects will be released on return from the subroutine.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1996 Hewlett-Packard Development Company, L.P.