I have no ideas what can it be!
- From: kurdayon@xxxxxxxxx
- Date: 29 Jun 2005 09:03:39 -0700
Hello,
Can anybody explain what is happening with the following code?
program p1
implicit none
real a, b
real, dimension(5) :: y, x, d
real, dimension(:,:) :: f
allocate(f(2,5))
x = (/1.0, 2.0, 3.0, 4.0, 5.0/)
y = (/1.0, 2.0, 3.0, 4.0, 5.0/)
call spectrum(a, b, y, d, f)
end program p1
subroutine spectrum(a, b, y, d, f)
implicit none
real a, b
real, dimension(:) :: y, d
real, dimension(:,:) :: f
write(6,*) 'Hello !!!'
end subroutine spectrum
It gives "Segmentation fault".
Why does it work if I comment assignment to x?
program p1
implicit none
real a, b
real, dimension(5) :: y, x, d
real, dimension(:,:) :: f
allocate(f(2,5))
! x = (/1.0, 2.0, 3.0, 4.0, 5.0/) <-- take a look here!
y = (/1.0, 2.0, 3.0, 4.0, 5.0/)
call spectrum(a, b, y, d, f)
end program p1
subroutine spectrum(a, b, y, d, f)
implicit none
real a, b
real, dimension(:) :: y, d
real, dimension(:,:) :: f
write(6,*) 'Hello !!!'
end subroutine spectrum
Why does it work if I remove one of the arguments argument from
subroutine?
program p1
implicit none
real a, b
real, dimension(5) :: y, x, d
real, dimension(:,:) :: f
allocate(f(2,5))
x = (/1.0, 2.0, 3.0, 4.0, 5.0/)
y = (/1.0, 2.0, 3.0, 4.0, 5.0/)
call spectrum(b, y, d, f)
end program p1
subroutine spectrum(b, y, d, f)
implicit none
real a, b
real, dimension(:) :: y, d
real, dimension(:,:) :: f
write(6,*) 'Hello !!!'
end subroutine spectrum
It also works if I remove instead of "a" "b" or "f". Why?
.
- Follow-Ups:
- Re: I have no ideas what can it be!
- From: *** Hendrickson
- Re: I have no ideas what can it be!
- Prev by Date: Re: MODULEand USE versus Argument Passing
- Next by Date: Re: MODULEand USE versus Argument Passing
- Previous by thread: MODULEand USE versus Argument Passing
- Next by thread: Re: I have no ideas what can it be!
- Index(es):