! E04JYF Example Program Text ! Mark 23 Release. NAG Copyright 2011. MODULE e04jyfe_mod ! E04JYF Example Program Module: ! Parameters and User-defined Routines ! .. Use Statements .. USE nag_library, ONLY : nag_wp ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: n = 4, nout = 6 INTEGER, PARAMETER :: liw = n + 2 INTEGER, PARAMETER :: lw = n*(n-1)/2 + 12*n CONTAINS SUBROUTINE funct1(n,xc,fc,iuser,ruser) ! Routine to evaluate objective function. ! .. Implicit None Statement .. IMPLICIT NONE ! .. Scalar Arguments .. REAL (KIND=nag_wp), INTENT (OUT) :: fc INTEGER, INTENT (IN) :: n ! .. Array Arguments .. REAL (KIND=nag_wp), INTENT (INOUT) :: ruser(*) REAL (KIND=nag_wp), INTENT (IN) :: xc(n) INTEGER, INTENT (INOUT) :: iuser(*) ! .. Local Scalars .. REAL (KIND=nag_wp) :: x1, x2, x3, x4 ! .. Executable Statements .. x1 = xc(1) x2 = xc(2) x3 = xc(3) x4 = xc(4) fc = (x1+10.0_nag_wp*x2)**2 + 5.0_nag_wp*(x3-x4)**2 + & (x2-2.0_nag_wp*x3)**4 + 10.0_nag_wp*(x1-x4)**4 RETURN END SUBROUTINE funct1 END MODULE e04jyfe_mod PROGRAM e04jyfe ! E04JYF Example Main Program ! .. Use Statements .. USE nag_library, ONLY : e04jyf USE e04jyfe_mod, ONLY : funct1, liw, lw, n, nag_wp, nout ! .. Implicit None Statement .. IMPLICIT NONE ! .. Local Scalars .. REAL (KIND=nag_wp) :: f INTEGER :: ibound, ifail ! .. Local Arrays .. REAL (KIND=nag_wp) :: bl(n), bu(n), ruser(n), w(lw), & x(n) INTEGER :: iuser(n), iw(6) ! .. Executable Statements .. WRITE (nout,*) 'E04JYF Example Program Results' FLUSH (nout) x(1:n) = (/ 3.0_nag_wp, -1.0_nag_wp, 0.0_nag_wp, 1.0_nag_wp/) ibound = 0 ! X(3) is unconstrained, so we set BL(3) to a large negative ! number and BU(3) to a large positive number. bl(1:n) = (/ 1.0_nag_wp, -2.0_nag_wp, -1.0E6_nag_wp, 1.0_nag_wp/) bu(1:n) = (/ 3.0_nag_wp, 0.0_nag_wp, 1.0E6_nag_wp, 3.0_nag_wp/) ifail = -1 CALL e04jyf(n,ibound,funct1,bl,bu,x,f,iw,liw,w,lw,iuser,ruser,ifail) SELECT CASE (ifail) CASE (0,2:) WRITE (nout,*) WRITE (nout,99999) 'Function value on exit is ', f WRITE (nout,99998) 'at the point', x(1:n) END SELECT 99999 FORMAT (1X,A,F8.4) 99998 FORMAT (1X,A,4F9.4) END PROGRAM e04jyfe