[問題] array 當argument 的問題
舉個簡單的例子,二個向量交換
program main
implicit none
real :: a(2), b(2)
a(1) = 1.0E0
a(2) = 2.0E0
b(1) = 3.0E0
b(2) = 4.0E0
call swap(a, b)
write(*, *) "a(1)=", a(1), "a(2)=", a(2)
write(*, *) "b(1)=", b(1), "b(2)=", b(2)
end program main
SUBROUTINE swap(a, b)
REAL, DIMENSION(:) :: a, b
REAL, DIMENSION(SIZE(a)) :: work
work = a
a = b
b = work
END SUBROUTINE swap
可以編譯成功,但執行時卻會發生segmentation fault,
把swap 裡的
work = a
a = b
b = work
註解掉,然後加了
write(*,*) size(a)
看size(a) 的值,
可以正常執行,但size(a) 的結果卻是0
我用的compiler 是ifort 11.1
請問有誰知道這是怎麼回事嗎?謝謝 :-)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.109.176.53
→
03/11 18:28, , 1F
03/11 18:28, 1F
→
03/11 18:30, , 2F
03/11 18:30, 2F
→
03/11 18:31, , 3F
03/11 18:31, 3F
→
03/11 19:17, , 4F
03/11 19:17, 4F
→
03/11 19:19, , 5F
03/11 19:19, 5F
→
03/11 22:49, , 6F
03/11 22:49, 6F
→
03/11 23:01, , 7F
03/11 23:01, 7F
→
03/11 23:02, , 8F
03/11 23:02, 8F
推
03/11 23:54, , 9F
03/11 23:54, 9F
推
03/12 09:43, , 10F
03/12 09:43, 10F
→
03/12 17:02, , 11F
03/12 17:02, 11F
Fortran 近期熱門文章
PTT數位生活區 即時熱門文章