A simple question about "allocatable"

I’m trying to allocate an array in the main program using a subroutine. But pgf90 compiler gave me that “PGF90-S-0084-Illegal use of symbol arr - must be an allocatable array (mainprogram.f90: 19)
Help!
My code (very simple):

program main
implicit none
interface
subroutine allocatearray(arr,leng)
real(8),allocatable :: arr(:)
integer:: leng
end subroutine allocatearray
end interface
real(8), allocatable:: a(:)
call allocatearray(a,10)
print*, a
end program main

subroutine allocatearray(arr,leng)
implicit none
real(8),target, allocatable :: arr(:) ! I have declared arr here.
integer:: leng
integer:: error
allocate(arr(leng),stat=error)
arr=3.1415926
print*, arr
end subroutine allocatearray

Hi Landau,


Unfortunately, using an allocatable as part of the dummy argument is illegal in Fortran 90/95. There is an extension that has been adopted in the F2003 standard that does allow this, but as of yet, pgf90 has not added this extension.

  • Mat