I have a large 3-dimensional array and I'm trying to do an element-by-element maximum on the first 2 dimensions using the MAXVAL function. When I do, I get a stack overflow error. Is there a size limit to the MAXVAL intrinsic function? The code is abbreviated below with constants in the array declarations and allocations instead of variables just to show the size:
program main
real, allocatable :: arr2(:,:), arr3(:,:,:)
allocate( arr3( 0:1000, 1:440, 1:6 ), source = 0.0 )
allocate( arr2( 0:1000, 1:440 ), source = 0.0 )
...! assign values to arr3
!---This gives me the stack overflow error---
arr2 = maxval( arr3,dim=3)
!------------
!-----This code works of course when broken out----
do concurrent( i = 0:1000, j = 1:440 ) arr2(i,j) = max( arr3(i,j,1), arr3(i,j,2), arr3(i,j,3), & arr3(i,j,4), arr3(i,j,5), arr3(i,j,6) ) end do
!-----------------------
But I would think is much less efficient. Is this a compiler bug?
Amalia