* E04CBF Example Program Text * Mark 22 Release. NAG Copyright 2007. * .. Parameters .. INTEGER N, NOUT PARAMETER (N=2,NOUT=6) * .. Local Scalars .. DOUBLE PRECISION F, TOLF, TOLX INTEGER I, IFAIL, MAXCAL * .. Local Arrays .. DOUBLE PRECISION RUSER(1), X(N) INTEGER IUSER(1) * .. External Functions .. DOUBLE PRECISION X02AJF EXTERNAL X02AJF * .. External Subroutines .. EXTERNAL E04CBF, FUNCT, MONIT * .. Intrinsic Functions .. INTRINSIC SQRT * .. Executable Statements .. CONTINUE * WRITE (NOUT,*) 'E04CBF Example Program Results' * * Set IUSER(1) to 1 to obtain monitoring information * IUSER(1) = 0 * X(1) = -1.0D0 X(2) = 1.0D0 TOLF = SQRT(X02AJF()) TOLX = SQRT(TOLF) MAXCAL = 100 IFAIL = 1 * CALL E04CBF(N,X,F,TOLF,TOLX,FUNCT,MONIT,MAXCAL,IUSER,RUSER,IFAIL) * WRITE (NOUT,*) IF (IFAIL.GE.0) THEN WRITE (NOUT,99999) IFAIL * IF (IFAIL.EQ.0) THEN WRITE (NOUT,99998) F WRITE (NOUT,99997) (X(I),I=1,N) END IF ELSE WRITE (NOUT,99996) ' ** E04CBF returned with IFAIL = ', IFAIL END IF * 99999 FORMAT (1X,'On exit from E04CBF, IFAIL = ',I4) 99998 FORMAT (1X,'The final function value is',F12.4) 99997 FORMAT (1X,'at the point',2F12.4) 99996 FORMAT (1X,A,I5) END * SUBROUTINE FUNCT(N,XC,FC,IUSER,RUSER) * .. Scalar Arguments .. DOUBLE PRECISION FC INTEGER N * .. Array Arguments .. DOUBLE PRECISION RUSER(*), XC(N) INTEGER IUSER(*) * .. Intrinsic Functions .. INTRINSIC EXP * .. Executable Statements .. CONTINUE * FC = EXP(XC(1))*(4.0D0*XC(1)*(XC(1)+XC(2))+2.0D0*XC(2)*(XC(2) + +1.0D0)+1.0D0) * RETURN END * SUBROUTINE MONIT(FMIN,FMAX,SIM,N,NCALL,SERROR,VRATIO,IUSER,RUSER) * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. DOUBLE PRECISION FMAX, FMIN, SERROR, VRATIO INTEGER N, NCALL * .. Array Arguments .. DOUBLE PRECISION RUSER(*), SIM(N+1,N) INTEGER IUSER(*) * .. Local Scalars .. INTEGER I, J * .. Executable Statements .. CONTINUE * IF (IUSER(1).NE.0) THEN WRITE (NOUT,*) WRITE (NOUT,99999) NCALL WRITE (NOUT,99998) FMIN WRITE (NOUT,99997) WRITE (NOUT,99996) ((SIM(I,J),J=1,N),I=1,N+1) WRITE (NOUT,99995) SERROR WRITE (NOUT,99994) VRATIO END IF * RETURN * 99999 FORMAT (1X,'There have been',I5,' function calls') 99998 FORMAT (1X,'The smallest function value is',F10.4) 99997 FORMAT (1X,'The simplex is') 99996 FORMAT (1X,2F10.4) 99995 FORMAT (1X,'The standard deviation in function values at the ', + 'vertices of the simplex is',F10.4) 99994 FORMAT (1X,'The linearized volume ratio of the current simplex', + ' to the starting one is',F10.4) END