当我用一个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
提交
取消