Allocatable array

Applies to: fortran

An allocatable array has its size chosen at run time with allocate (and freed with deallocate, or automatically at scope exit). It is Fortran's safe dynamic array, the analog of std::vector's sizing.

real, allocatable :: a(:)
allocate(a(n))      ! size known only at run time
a = 0.0

See also: array-slicing-fortran, do-loop