-mc=model or -Mlarge_arrays with array extent

Hi,
I got this weird behavior of PGI Fortran 9.0-4.
program main
REAL, DIMENSION(:, :), ALLOCATABLE : A

allocate(A(10,10))
call func(A)
end program main

subroutine func(A)
REAL, DIMENSION(:, :) :: A
INTEGER :: x
x = size(A,1)
print *, x
end subroutine

If I compile the program without -mc=model or -Mlarge_arrays, the extent of the matrix A is retrieved correctly, as I print x out. However, when I use either of these two options, I only get zeros for any extents of the array A. Could any suggest me how to resolve this as I want to know the array extent without passing it via dummy arguments. I tested with intrinsic matmul, there is no problem with this function.

Hi Tuan,

Can you please post an example of the behavior your seeing? The code you posted works fine for me (after adding an interface block).

% cat test.f90
program main

REAL, DIMENSION(:, :), ALLOCATABLE :: A

interface
   subroutine func(A)
     REAL, DIMENSION(:, :) :: A
   end subroutine func
end interface

allocate(A(10,10))
call func(A)

end program main

subroutine func(A)
REAL, DIMENSION(:, :) :: A
INTEGER :: x
x = size(A,1)
print *, x
end subroutine

% pgf90 test.f90 -fast -V9.0-4 -o test904.out
% test904.out
           10
% pgf90 test.f90 -fast -V9.0-4 -Mlarge_arrays -o test904_large.out
% test904_large.out
           10

Thanks,
Mat

Thanks mkcolg, I’ve just realized the issue also.

This happens as Fortran does not automatically generate the dimension information for the array if it is in the same file of the caller.