- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
program arrayreshape
implicit none
integer, parameter:: N=1000
integer :: i,j
real(8), allocatable, dimension(:,:):: a, b
allocate(a(N,N))
allocate(b(N,N))
a=reshape([(1._16,i=1,N**2)],[N,N])
b=reshape([(100._16,i=1,N**2)],[N,N])
end program
Using ifort (IFORT) 2021.6.0 20220226, it can be built without error, but there will be segmentation fault:
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
reshapeLargeMatri 0000000000404C7A Unknown Unknown Unknown
libc.so.6 00007F71C1EE48E0 Unknown Unknown Unknown
reshapeLargeMatri 000000000040387F Unknown Unknown Unknown
reshapeLargeMatri 0000000000403842 Unknown Unknown Unknown
libc.so.6 00007F71C1ECF290 Unknown Unknown Unknown
libc.so.6 00007F71C1ECF34A __libc_start_main Unknown Unknown
reshapeLargeMatri 0000000000403725 Unknown Unknown Unknown
Is this a bug? Changing to N=500, it runs without problem.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are likely having stack overflow. Possible solutions:
a) Increase stack size
b) use option heap arrays
c) replace reshape with DO loop
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What Jim Said, additionally did you really intend kind=16 for for 1D arrays assigned to a kind=8 array? You can guess all manner of temp arrays need to be created on the stack for these lines.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page