Error: Unclassifiable statement at (1) using log() logarithm

Error: Unclassifiable statement at (1) using log() logarithm

因此,当我在我的 fortran90 代码中使用 log 函数时,它会抛出以下编译时错误:

newtonf90.f90:21:

f = ((x - 2.d0)**2) \xE2\x88\x92 log(x)
1
Error: Unclassifiable statement at (1)

注意:使用gfortran

那么,我犯的错误是什么?

完整代码:

implicit none
double precision p0,p,df,f,tol
integer imax,i

p0=1.d0
imax=70
tol=0.0001
do i=1, imax
   p = p0 - f(p0) / df(p0)
   write(2,*) i , p , dabs(p0-p)
   if (dabs(p0-p) .lt. tol) stop
   p0=p
enddo
stop
end program newton

function f(x)
implicit none
double precision x,f
f = ((x - 2.d0)**2) − log(x)
return
end function f

function df(x)
implicit none
double precision x,df
df=2*(x - 2.d0) - 1/x
return
end function df

"log"前的字符不是减号。删除它并在其位置写一个适当的“-”。