The following change reports the memory address of test(k)%arr, indicating that a duplicate is being provided. gFortran reports the same address, indicating that this stack copy is not required.
module test_mod
type dan_array
real*4, allocatable, dimension(:,:,:) :: arr
end type dan_array
!
type (dan_array) test(7)
!
contains
subroutine report_size ( k, arr)
integer*4 k
real*4, dimension(:,:,:) :: arr
write (*,10) ' Element ',k,' size=', size (arr), ' b1=',ubound(arr,1), ' b2=',ubound(arr,2), ' b3=',ubound(arr,3)
write (*,12) ' Start address= ',loc(arr(1,1,1)), loc(arr)
10 format (a,i0,a,b'z,zzz,zzz,zz#',3(a,b'zzz,zz#') )
12 format (a,2(b'z,zzz,zzz,zz#'))
end subroutine report_size
end module test_mod
use test_mod
!
integer k, sum_size
!
allocate ( test(1)%arr(1000,1000,1) )
allocate ( test(2)%arr(1000,1000,2) )
allocate ( test(3)%arr(100,100,3) )
allocate ( test(4)%arr(10,10,4) )
allocate ( test(5)%arr(1,1,5) )
allocate ( test(6)%arr(10000,1000,6) )
allocate ( test(7)%arr(1000,1000,7) )
!
sum_size = 0
do k = 1,7
if ( k/=6) &
call report_size ( k, test(k)%arr ) ! call fails as test(k)%arr is copied to stack
write (*,12) ' Start address= ',loc(test(k)%arr(1,1,1))
write (*,10) ' Element ',k,' size=', size (test(k)%arr), ' b1=',ubound(test(k)%arr,1), ' b2=',ubound(test(k)%arr,2)
sum_size = sum_size + size (test(k)%arr)
end do
write (*,11) sum_size
10 format (a,i0,a,b'z,zzz,zzz,zz#',3(a,b'zzz,zz#') )
11 format ('Total size = ',b'z,zzz,zzz,zz#')
12 format (a,2(b'z,zzz,zzz,zz#'))
!
end
After all these years of using FTN95, I still don't know how to change the stack size. can someone give an example of changing the stack. I compiled and linked with : ftn95 dan_array /link