If V is declared to be an allocatable array of a certain type, in Fortran 2003 and later, execution of the assignment statement V = <expression> causes V to be allocated (if not previously allocated) and deallocation/reallocation (if previously allocated and the shapes do not match). The details are to be found in sections 7.4.1.2 and 7.4.1.3 of the Fortran 2003 standard.
In this context, the test program given below causes a run time error, as shown below after the program text.
Are there any plans to implement the "allocate on assignment" feature in Absoft Fortran? Thanks.
program prime_sieve
implicit none
integer, parameter :: N = 10000, rtN = 100
integer :: i, j
integer, allocatable :: multiples(:)
multiples = [(( i*j, i=j,N/j,2), j=3,rtN,2)] ! allocate on assignment
print '(A,I5,A,I7)','size(multiples) = ',size(multiples)
end program prime_sieve
? FORTRAN Runtime Error:
? Reference to an unallocated allocatable array MULTIPLES
? File prmabs.f90; Line 9