Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
ALLOCATE
◄Up► ◄Contents► ◄Index► ◄Back►
─────ALLOCATE───────────────────────────────────────────────────────────────
Action
Dynamically sizes an array previously declared with the
ALLOCATABLE attribute.
Syntax
ALLOCATE (array([l:]u[,[l:]u ...]) [, STAT = ierr]) ...
Parameter Description
array Name of allocatable array
ierr Integer variable that returns error status
l Integer expression that sets the lower bound of
the array
u Integer expression that sets the upper bound of
the array
Remarks
Allocatable arrays are dynamically allocated and deallocated at
run time.
Allocatable arrays may not have the NEAR attribute. If the array
may be larger than 65,536 bytes, you must specify the HUGE
attribute so the array elements are correctly addressed.
Allocatable arrays may not appear in AUTOMATIC, COMMON, DATA,
EQUIVALENCE, or STRUCTURE statements.
The <ierr> variable returns a value of zero if the allocation was
successful, and the number of the run-time error if the
allocation failed. If the ISTAT= parameter is not specified and
an error occurs, the program is halted and a run-time error is
generated.
See Also: ◄DEALLOCATE►
Example
.
.
.
INTEGER dataset[ALLOCATABLE](:,:),
+ results[ALLOCATABLE, HUGE](:,:,:)
INTEGER reactor, level, calcs, error
DATA reactor, level, calcs / 10, 50, 100 /
ALLOCATE (dataset(reactor,level),
+ results(reactor,level,calcs), STAT = error)
IF (error .NE. 0)
+ STOP 'Not enough storage for data; aborting...'
.
.
.
-♦-