- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I found out this unexpected behavior of temporary array when tracing down the root cause of a stack overflow.
In a subroutine, when multi-dimensional dummy arrays with explicit size are declared with the exponentiation operator ** (except in the last dimension), almost any operation in this subroutine that involves section of this array would create a temporary array, even if the section is obviously contiguous ( extreme case being x(:,:) ). Such temporary arrays are not created if the array size is declared using multiplication (n*n instead of n^2, or of higher power)
The following is an example:
program main implicit none real(8) x(4,2) call sub(x,2) end program main subroutine sub(x,n) implicit none integer,intent(in) :: n real(8),intent(in) :: x(n**2,2) ! change to x(n*n,2) and everything's fine print*, x(:,:) ! obviously contiguous, but a temporary array is created nonetheless. end subroutine sub
Is this behavior a compiler bug or is there some deeper reason to this that I'm not aware of? Help appreciated.
I checked temporary array creation using the -check arg_temp_created compiler option. I am using ifort version 16.0.0, on a UNIX system computing cluster at my institution.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for reporting this. It does seem to be a bug. I reported it to the Developers for further analysis. I will share what I hear back.
(Internal tracking id: DPD200376216)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page