I'm new to Fortran and inside a subroutine which is inside a module I'm trying to declare the following variable:
real(kind = 8), dimension(dim*nnds, dim*nnds) :: Kgel
And I get the following:
Unhandled exception at 0x009F4029 in Solver.exe: 0xC00000FD: Stack overflow (parameters: 0x00000000, 0x00602000).
dim and nnds are variables coming from another module, and I know they are being passed correctly as:
integer(kind = 8) :: nnds, dim
dim = 2
nnds = 937
If I declare the variable like:
real(kind = 8), dimension(2*937, 2*937) :: Kgel
Or even like:
real(kind = 8), dimension(:, :), allocatable :: Kgel
allocate(Kgel(dim*nnds, dim*nnds))
It works, so why can't I declare 'Kgel' like:
real(kind = 8), dimension(dim*nnds, dim*nnds) :: Kgel
Thanks very much for your time...
UPDATE
My code is something like this:
program MainTest
use FirstModule
use SecondModule
call FirstSubRoutine
call SecondSubRoutine
end program
.
module FirstModule
integer(kind = 8) :: nnds, dim
contains
subroutine FirstSubRoutine()
!does stuff and eventually
dim = 2
nnds = 937
end subroutine
end module
.
module SecondModule
use FirstModule
contains
subroutine SecondSubRoutine()
real(kind = 8), dimension(nnds*dim, nnds*dim) :: Kgel
!print *, dim -> dim = 2
!print *, nnds -> nnds = 937
!pause
!but this works:
!real(kind = 8), dimension(:, :), allocatable :: Kgel
!allocate(Kgel(dim*nnds, dim*nnds))
end subroutine
end module
This small test code will replicate my problem.
UPDATE
By changing the "Stack Reserve Size" it now seems to work fine:

dimandnndsdeclared? Is the code you show in the main program or in a subroutine? There is not enough information here for anyone to help.ALLOCATABLEattribute and doing your own memory allocation puts the array on the heap. A user process typically has much more heap than stack.