主题:[讨论]fortran编程总是报错
PROGRAM interpolation errors
IMPLICIT NONE
REAL :: x,F(x),q,P2,P6,P8
INTEGER :: i,j,k,m
F(x)=1/1+x**2
i=0
DO
i=i+1
IF(i=2 .OR. i=6 .OR. i=8)
REAL :: A(0:i,0:2)
REAL :: P(i)=0
q=10/i
A(0,0)=-5
A(0,1)=F(A(0,0))
A(i,2)=1
j=1
DO
j=j+1
IF(j>i) EXIT
A(j,0)=A(j-1,0)+q
A(j,1)=F(A(j,0))
k=0
DO
k=k+1
IF(k>i) EXIT
IF(k.NE.j)
A(k,2)=A(k,2)*(x-A(j,0))/(A(k,0)-A(j,0))
ELSE
A(k,2)=A(k,2)*(x-A(0,0))/(A(k,0)-A(0,0))
m=0
DO
m=m+1
IF(m>i) EXIT
P(i)=P(i)+A(m,1)*A(m,2)
P2=P(2)*F(x)
P6=P(6)*F(x)
P8=P(8)*F(x)
IF(i>8)
enddo
END PROGRAM interpolation errors
IMPLICIT NONE
REAL :: x,F(x),q,P2,P6,P8
INTEGER :: i,j,k,m
F(x)=1/1+x**2
i=0
DO
i=i+1
IF(i=2 .OR. i=6 .OR. i=8)
REAL :: A(0:i,0:2)
REAL :: P(i)=0
q=10/i
A(0,0)=-5
A(0,1)=F(A(0,0))
A(i,2)=1
j=1
DO
j=j+1
IF(j>i) EXIT
A(j,0)=A(j-1,0)+q
A(j,1)=F(A(j,0))
k=0
DO
k=k+1
IF(k>i) EXIT
IF(k.NE.j)
A(k,2)=A(k,2)*(x-A(j,0))/(A(k,0)-A(j,0))
ELSE
A(k,2)=A(k,2)*(x-A(0,0))/(A(k,0)-A(0,0))
m=0
DO
m=m+1
IF(m>i) EXIT
P(i)=P(i)+A(m,1)*A(m,2)
P2=P(2)*F(x)
P6=P(6)*F(x)
P8=P(8)*F(x)
IF(i>8)
enddo
END PROGRAM interpolation errors