A testbased on Gary Scott's issue described here.
This test reproduction is devoted to Paul Rich & Co. for GNU gfortran users
program test
use iso_fortran_env
implicit none
type WPDataDef
real(real32), pointer :: selData(:,:)
real(real32), pointer :: selDataG(:,:)
real(real32), allocatable :: set1Data(:,:)
real(real32), allocatable :: set2Data(:,:)
real(real32), allocatable :: set3Data(:,:)
end type
type (WPDataDef), target :: svWPData
type (WPDataDef) :: wpDataSort
allocate(svWPData%set1Data(600,5000))
allocate(svWPData%set2Data(600,5000))
allocate(svWPData%set3Data(600,5000))
allocate(WPDataSort%set1Data(600,5000))
#ifdef STACK
svWPData%set1Data = wpDataSort%set1Data
#else
call safe_copy(to=svWPData%set1Data, from=wpDataSort%set1Data)
#endif
contains
subroutine safe_copy(from, to)
real(real32), intent(in) :: from(:,:)
real(real32), intent(out) :: to(:,:)
to = from
end subroutine safe_copy
end program
Lenovo MIIX 700, Intel(R) Core(TM) m5-6Y54 CPU @ 1.10GHz, 4GB Ram, 4.4.0-45-generic #66-Ubuntu SMP Wed Oct 19 14:12:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
stefano@thor(08:21 AM Sun Nov 06)
~/downloads/test_stack 2 files, 28Kb
→ gfortran -DSTACK -Warray-temporaries test_stack.F90
stefano@thor(08:28 AM Sun Nov 06)
~/downloads/test_stack 2 files, 28Kb
→ ./a.out
stefano@thor(08:28 AM Sun Nov 06)
~/downloads/test_stack 2 files, 28Kb
→ gfortran -Warray-temporaries test_stack.F90
stefano@thor(08:28 AM Sun Nov 06)
~/downloads/test_stack 2 files, 28Kb
→ ./a.out
GNU gfortran 6.2.0
ulimit -s 1024
Under GNU Linux, with GNU gfortran 6.2.0 the test shows that the stack memory is not used as expected, the stack memory being also reduced to 1MB.