请高手指教,程序和编译器出错提示如下:

当我用一个function,用contains包含另外一个function 时就出错了  
不用contains 结构,分开写,就又没问题了

function se(x) 
implicit none
integer n
real x,h,he,tx,se
n=1
tx=h(n)*x**(2*n)
he=tx
do while(abs(tx)>=1e-10)
n=n+1
tx=h(n)*x**(2*n)
he=he+tx
enddo
se=1+he
contains
function h(n) result(k)
implicit none
integer i,n
real pim,term1,term2,e,s,k
pim=(2/3.1415926)**(2*n+1)
term1=1
term2=1
e=term1/term2
s=1
i=1
do while(abs(e)>=1e-10)
i=i+1
term1=(-1.0)**(real(i)-1)
term2=(2*real(i)-1)**(2*n+1)
e=term1/term2
s=s+e
enddo
k=2*pim*s
end function h
end function se

program ex
implicit none
real se,x
read*,x
print*,se(x)
end

D:\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)

哈士奇WWW
浏览 306回答 3
3回答

ABOUTYOU

用contains包含之后不能再在函数se中声明h了,real x,h,he,tx,se去掉hreal x,he,tx,se

aluckdog

错误文件你可以从软件库中删除,也可以通过调用 Microsoft 产品支持服务请求

GCT1015

我也是书上看的哈,你试下行不行最前面加一个module blala第二行implicit none把cantains写到第三行最后加一个end module bala这个module bala就包括了两个子函数主程序里面调用写use bala
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java