I have no ideas what can it be!



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?

.


Quantcast