program newt5 c logical error integer out real x external func common /inout/ out c out = 6 write(out,*) ' newton-s method' 10 write(out, 103) read(*, 104) x if (x .lt. -19.0) goto 99 call newton(x, func, error) if (.not. error) write(out, 102) x goto 10 99 stop 102 format(/' the answer is ', f12.5) 103 format(' first guess? ' ) 104 format(e10.0) end subroutine func(x, fx, dfx) c c -- the solution for f(x) = exp(x) - 4x c real x, fx, dfx, e c e = exp(x) fx = e - 4.0 * x dfx = e - 4.0 return end