program newt1 c integer out real x common /inout/ out c out = 6 write(out,*) ' newton-s method' x = 2 call newton(x) write(out, 102) x stop 102 format(/' the square root of 2 is ', f8.5) end subroutine func(x, fx, dfx) c c -- the square root of 2 c real x, fx, dfx c fx = x * x - 2 dfx = 2 * x return end subroutine newton(x) c c -- the solution of f(x) = 0 by newton-s method c integer out real x, fx, dfx, x1, dx, tol common /inout/ out data tol/1.0e-6/ c write(out,*)' x fx dfx' 10 x1 = x call func(x, fx, dfx) dx = fx / dfx x = x1 - dx write(out, 102) x1, fx, dfx if (abs(dx) .gt. abs(x * tol)) goto 10 return 102 format(1x, 0pf8.5, 3x, 1p2e12.4) end