PROGRAM main REAL tol, x, xd, tmp1, tmp1d INTEGER r, it INTEGER tmp2, tmp3 COMMON /validity_test_common/ gmin, gmax, infmin, infmax REAL gmin, gmax LOGICAL infmin, infmax tol = 1.0e-3 r = 0 x = 6 WRITE(*, '(/, A, F3.1)') ' Initial guess: ', x xd = 1 WRITE(*, '(A, F3.1)') ' Initial guess direction: ', xd it = 20 WRITE(*, '(A, I4)') ' Iteration times: ', it WRITE(*, '(/, A)') " x f(x) f'(x) gmin gmax + infmin infmax" gmin=.0 gmax=.0 infmin=.TRUE. infmax=.TRUE. DO CALL F_DVA(x, xd, tmp1, tmp1d) IF ( infmin .eqv. .TRUE. ) THEN tmp2 = 1 ELSE tmp2 = 0 END IF IF ( infmax .eqv. .TRUE. ) THEN tmp3 = 1 ELSE tmp3 = 0 END IF WRITE(*, '(5(F9.5, X), I5, X, I5)') x, tmp1, tmp1d, gmin, gmax + , tmp2, tmp3 C x = x - ( tmp1 / tmp1d ) IF ( abs( tmp1d ) < tol ) EXIT r = r + 1 IF ( r > it ) EXIT END DO END SUBROUTINE F( x, y ) REAL x, y IF ( x > 1 ) THEN y = x**2 ELSE y = 2-x**2 ENDIF END