02.07.2013 Views

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>HP</strong> <strong>Fortran</strong> statements<br />

ALLOCATABLE (statement and attribute)<br />

If (deferred-shape-spec-list) is omitted from the ALLOCATABLE statement, it must be<br />

specified in another declaration statement, such as a type or DIMENSION statement.<br />

The ALLOCATED intrinsic inquiry function is described in “ALLOCATED(ARRAY)” on<br />

page 486. It can be used to determine whether an allocatable array is currently allocated.<br />

Description<br />

The ALLOCATABLE attribute or statement is used to declare an array whose extents in all its<br />

dimensions will be specified when an ALLOCATE statement is executed at run-time; for this<br />

reason it is known as “deferred-shape”. When an allocatable array is declared, only its name<br />

and rank are given.<br />

Examples<br />

The following statements declare a rank-one deferred-shape array and illustrate its use with<br />

different extents.<br />

! mls is deferred shape.<br />

INTEGER, ALLOCATABLE :: mls(:)<br />

ALLOCATE (mls (3)) ! Allocate 3 elements.<br />

DEALLOCATE (mls) ! mls is no longer allocated<br />

ALLOCATE (mls (-n:n)) ! Allocate with different extent<br />

Related statements<br />

ALLOCATE and DEALLOCATE<br />

Related concepts<br />

See “Allocatable arrays” on page 62 for more information about allocatable arrays and the<br />

conditions applying to their use.<br />

Array pointers provide a more general mechanism for the manipulation of deferred-shape<br />

arrays; see “Array pointers” on page 61.<br />

Chapter 10 241

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!