PROGRAM MAIN_ROOT
IMPLICIT NONE
REAL::ROOT,A,B,C,D,X0,X
write( *,* ) "PLEASE INPUT A,B,C,D,X0"
READ (*,*) A,B,C,D,X0
X=ROOT(A,B,C,D,X0)
write(*,*) X
return
END PROGRAM MAIN_ROOT
FUNCTION ROOT(A,B,C,D,X0) RESULT(ROOT_RESULT)
IMPLICIT NONE
REAL,INTENT(IN)::A,B,C,D,X0
REAL::ROOT_RESULT
reAL::X1,F,F1
X1 = X0
F=A*X1**3+B*X1**2+C*X1+D
write(*,*) F
DO WHILE(ABS(F).GT.1E-6)
F=A*X1**3+B*X1**2+C*X1+D
c |
F1=3*A*X1*X1+2*B*X1+C
X1 = X1-F/F1
write(*,*) X1
ROOT_RESULT = X1
END DO
END FUNCTION ROOT
因为INTENT(IN)就表明这个值是传入的,不可修改。
而你的函数中X0要修改。所以就出错了。
你可以把X0设为INTENT(INOUT)。或把X0赋值给另一个变量。
有问题可以再讨论。
China proposes emergency talks on Korea crisis
Both Beijing and Pyongyang have been pressing regional powers to return to talks, in some form or other, for the past few months, in a move analysts say is designed to extract concessions.
Seoul expects jitters in financial markets to settle in the short term unless North Korea carries out further provocations, Yonhap quoted a senior Finance Ministry official as saying.
The nuclear-powered carrier USS George Washington, which carries 75 warplanes and has a crew of over 6,newport cigarettes,000, has joined the exercises and will be accompanied by at least four other U.S. warships, an official from U.S. Forces Korea said.