- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
the following program produces a runtime error (apparently in the first line
- stack overflow) with CVF 6.6C on Windows XP:
program aha
implicit none
!
! No problem with allocatable arrays
! With pointers we do have a problem
!
integer, dimension(:,:), pointer :: a, b
integer :: ierr, ierr2
implicit none
!
! No problem with allocatable arrays
! With pointers we do have a problem
!
integer, dimension(:,:), pointer :: a, b
integer :: ierr, ierr2
write(*,*) 'Started ...'
allocate(a(1000,1000),stat=ierr)
allocate(b(2000,1000),stat=ierr2)
write(*,*) ierr, ierr2
a = 1
allocate(a(1000,1000),stat=ierr)
allocate(b(2000,1000),stat=ierr2)
write(*,*) ierr, ierr2
a = 1
!
! Remove this statement and all will work
!
b(1:1000,1:1000) = a(1:1000,1:1000)
write(*,*) a(3,3), b(3,3)
end program
! Remove this statement and all will work
!
b(1:1000,1:1000) = a(1:1000,1:1000)
write(*,*) a(3,3), b(3,3)
end program
Removing the assignment b(...) = a(...) causes the program to function
correctly.
If you change the pointer attribute to "allocatable", it also works
correctly.
However, as this is an excerpt of programs where allocatable
is not an option (typically thingsallocated in subroutines), I would
like to know how we can solve this problem.
Kind regards,
Arjen Markus
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I suggest you write:
b(1:1000,:) = a
instead. It may help. Or add /link /stack:10000000 to the command switches (or set the linker stack reserve setting to 10000000).
b(1:1000,:) = a
instead. It may help. Or add /link /stack:10000000 to the command switches (or set the linker stack reserve setting to 10000000).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The first option (change the line to b(1:1000,:) = a) did not work.
Changing the stack reserve did solve it.
Thanks,
Arjen
Changing the stack reserve did solve it.
Thanks,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should also keep in mind memory layout of arrays and try to arrange things so that you're doing contiguous moves. Your assignment skips blocks of 1000 elements so the compiler creates a temporary copy. If you reversed the order of the indexes, then the assignment would be contiguous.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hm, you are right - that could be the reason for this failure ...
However, when I tried with a one-dimensional version I had the same
problem:
exhibits the same problem
Regards,
Arjen
However, when I tried with a one-dimensional version I had the same
problem:
program aha
implicit none
!
! No problem with allocatable arrays
! With pointers we do have a problem
!
integer, dimension(:), pointer :: a, b
integer :: ierr, ierr2
write(*,*) 'Started ...'
allocate(a(1000000),stat=ierr)
allocate(b(2000000),stat=ierr2)
write(*,*) ierr, ierr2
a = 1
b(1:1000000) = a(1:1000000)
write(*,*) a(33), b(33)
end program
exhibits the same problem
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Don't use array section notation unless you need to (write A and not A(1:10000)). But I can see in this case it doesn't matter. Hmm.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Increasing the stack is not what I would call a practical solution as you realy do (may) not want to create a temporary array for a simple assignment.
What happens if you replace
b(1:1000,1:1000) = a(1:1000,1:1000)
with
FORALL(I=1:1000) b(1:1000,I) = a(1:1000,I)
The compiler/runtime used to have a diagnosticwarning when array temporaries were created/used. This option appears to have been removed in the latest release. The option was used to identify potential performance problem areas. Loss of this option must have been deemed as progress....
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The warning you're referring to is only for arguments in calls - it was never supported for temps created in statements.
I agree that raising the stack is not an ideal fix. In the Intel compiler, work is in progress to optionally allocate these temps on the heap. This example points out where the compiler's detection of where temps can be avoided could still be improved.
I agree that raising the stack is not an ideal fix. In the Intel compiler, work is in progress to optionally allocate these temps on the heap. This example points out where the compiler's detection of where temps can be avoided could still be improved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just a small update:
I downloaded Intel Visual Fortran 9.1 for Windows yesterday for evaluation purposes and tried it on this very same program. The crash was completely
similar.
Interestingly enough, it happens at _start up_ - not when the statement is to
executed.
Regards,
Arjen
I downloaded Intel Visual Fortran 9.1 for Windows yesterday for evaluation purposes and tried it on this very same program. The crash was completely
similar.
Interestingly enough, it happens at _start up_ - not when the statement is to
executed.
Regards,
Arjen
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page