當我用一個function,用contains包含另外一個function 時就出錯了 不用contains 結構,分開寫,就又沒問題了function se(x) implicit noneinteger nreal x,h,he,tx,sen=1tx=h(n)*x**(2*n)he=txdo while(abs(tx)>=1e-10)n=n+1tx=h(n)*x**(2*n)he=he+txenddose=1+hecontainsfunction h(n) result(k)implicit noneinteger i,nreal pim,term1,term2,e,s,kpim=(2/3.1415926)**(2*n+1)term1=1term2=1e=term1/term2s=1i=1do while(abs(e)>=1e-10)i=i+1term1=(-1.0)**(real(i)-1)term2=(2*real(i)-1)**(2*n+1)e=term1/term2s=s+eenddok=2*pim*send function hend function seprogram eximplicit nonereal se,xread*,xprint*,se(x)endD:\My Documents\fortran save\Text1.f90(15) : Error: The name of the internal procedure conflicts with a name in the encompassing scoping unit. [H]function h(n) result(k)
3 回答

GCT1015
TA貢獻1827條經驗 獲得超4個贊
我也是書上看的哈,你試下行不行
最前面加一個module blala
第二行implicit none
把cantains寫到第三行
最后加一個end module bala
這個module bala就包括了兩個子函數
主程序里面調用寫use bala
添加回答
舉報
0/150
提交
取消