当我用一个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)
ABOUTYOU
aluckdog
GCT1015
相关分类