Absoft User Forum

Support => Windows => Topic started by: mecej4 on March 26, 2022, 08:48:05 PM

Title: Automatic allocate/reallocate on assignment not implemented?
Post by: mecej4 on March 26, 2022, 08:48:05 PM
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 and 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.

Code: [Select]
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

Code: [Select]
? FORTRAN Runtime Error:
? Reference to  an unallocated allocatable array  MULTIPLES
? File prmabs.f90; Line 9