From: Dick Hendrickson <[log in to unmask]>
To: [log in to unmask] <[log in to unmask]>
Date: Tuesday, 5 July 2011 5:59
>I don't see anything obvious. Here's a few suggestions.
>Pointing to an allocatable object is unusual (at least to me), you
>might have hit a compiler bug. I think most people allocate the
>pointer directly.
>What compiler are you using? If it's reasonably old, you should get
>an update.
>FORALL is rarely used and likely to be buggy.
FORALL has been around for nearly 20 years, and is not likely
to be buggy.
> If you are using a
>FORALL, ask yourself why a DO isn't a better choice. It usually is.
>Do you know where the seg fault comes from? Try putting in a few
>PRINT *, "we are here" statements.
And turning on all checks.
___________
On Mon, Jul 4, 2011 at 1:46 PM, Sondak, Douglas L <[log in to unmask]> wrote:
> I wrote a short code to test a construct involving a pointer to an
> allocatable array, and it results in a seg fault when I run. I'm not sure
> what I'm doing wrong; could someone please take a look at it? Thanks.
>
> Doug Sondak
>
> module alloc_mod
> implicit none
> contains
> subroutine alloc_1d(x,n)
> implicit none
> integer, intent(in) :: n
> real, allocatable, intent(inout), target :: x(:)
> allocate(x(n))
> end subroutine alloc_1d
> end module alloc_mod
> program alloc_test
> use alloc_mod
> implicit none
> integer :: i, nwords = 5
> real, allocatable, dimension(:), target :: x
> real, pointer, dimension(:) :: s => null()
> call alloc_1d(x,nwords)
> s => x
> forall(i=1:nwords) s(i) = i
> print*,'s = ', s
> end program alloc_test
|