Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

heap error with OpenMP

hadesmajesty
Beginner
415 Views
I meet a problem.Thesettings in myIVF complier are asbelow:

(1) Optimization:Speed plus higher level Optimizations(/03).
(2)Global Optimizations:Yes(/Og)
(3) Heap Arrays:30
(4) Process OpenMP Directives: Generate Parallel Code(/Qopenmp)

If I run my code with above settings, I find there is a heap error, pointed to the file dgbheap.c, when I run in the debug mode and code just stops in non-debug mode.

However, I note that when I set off (1) or (4), the code can run well.

I wonder why I cannot run the code with (1) and (4) on?

Thanks you in advance.
0 Kudos
7 Replies
Steven_L_Intel1
Employee
415 Views
Please provide a test case we can build and run here. We'll be glad to investigate.
0 Kudos
hadesmajesty
Beginner
415 Views
Thanks, Steve. But I am afraid I can not provide thecode.

I find the problem occurs in thebelow subroutine:

subroutine name(m)

integer m
real(8) array(m,m)

end subroutine


I temporally resolve the problem by removing thefixed size array(m,m) in my subroutine and setting the heap arrays as default.

However, in the case I really need such a large array, what should I do? Can I increase the stack size of IVF and how?

Thanks a lot.

0 Kudos
Steven_L_Intel1
Employee
415 Views
I suggest this instead:

subroutine name(m)
integer m
real(8), allocatable :: array(:)
allocate (array(m))
...

The array will be automatically deallocated when the subroutine exits.
0 Kudos
jimdempseyatthecove
Honored Contributor III
415 Views
Try adding "recursive" to the subroutine declaration:

recursive subroutine name(m)

integer m
real(8) array(m,m)

end subroutine


or

recursive subroutine name(m)

integer m
real(8), allocatable ::array(:,:)
allocate(array(m,m))

end subroutine

Jim Dempsey
0 Kudos
Steven_L_Intel1
Employee
415 Views
The issue here is running out of thread stack - adding recursive won't change that - as an "automatic array", ARRAY is already stack-allocated. Using ALLOCATABLE will as the allocation will come from the heap.
0 Kudos
hadesmajesty
Beginner
415 Views
Thank you so much.

But I still want to ask one more question. What should I do if I need to transfer the large array as parameter? For example:

subroutine name(m,arrary)

integer m
real(8) array(m,m)

end subroutine

In this case, it seems that the allocatable/allocate method cannot be applied in above situation.

Thanks.
0 Kudos
Steven_L_Intel1
Employee
415 Views
In that case you don't need ALLOCATABLE - that's only when the array is locat to the procedure. If you pass the array as an argument, it is already allocated by the caller.
0 Kudos
Reply