Re: [問題] module裡面不同的function可以互相支援嗎

作者: terryys (terry)   2012-11-30 10:30:23
module testmod
implicit none
contains
function a(x)
real :: a
real, intent(in) :: x
a=x**2.
end function
function b(x)
real :: b
real, intent(in) :: x
b=(x+6.)/a(x)
end function
end module
program testpro
use testmod
implicit none
print *, b(12.)
end
可以正常執行,輸出0.125也是正確的答案
你的B裡面宣告了另一個a,ifort和gfortran都不能編譯
試試把那個a刪掉?
作者: ted40905 (天兵)   2011-01-30 18:03:00
好的我試試看試過,可以了! 感謝~
作者: jubilee2 (3321)   2011-01-30 22:06:00
同MODULE內的FUNCTION不用特別宣告
作者: ted40905 (天兵)   2012-02-01 03:11:00
OK

Links booklink

Contact Us: admin [ a t ] ucptt.com