! C05QSF Example Program Text ! Mark 23 Release. NAG Copyright 2011. MODULE c05qsfe_mod ! C05QSF 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 = 9, nout = 6 CONTAINS SUBROUTINE fcn(n,lindf,indf,x,fvec,iuser,ruser,iflag) ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. REAL (KIND=nag_wp), PARAMETER :: one = 1.0E0_nag_wp REAL (KIND=nag_wp), PARAMETER :: three = 3.0E0_nag_wp REAL (KIND=nag_wp), PARAMETER :: two = 2.0E0_nag_wp REAL (KIND=nag_wp), PARAMETER :: alpha = (one/two)**7 ! .. Scalar Arguments .. INTEGER, INTENT (INOUT) :: iflag INTEGER, INTENT (IN) :: lindf, n ! .. Array Arguments .. REAL (KIND=nag_wp), INTENT (OUT) :: fvec(n) REAL (KIND=nag_wp), INTENT (INOUT) :: ruser(*) REAL (KIND=nag_wp), INTENT (IN) :: x(n) INTEGER, INTENT (IN) :: indf(lindf) INTEGER, INTENT (INOUT) :: iuser(*) ! .. Local Scalars .. REAL (KIND=nag_wp) :: theta INTEGER :: i, ind ! .. Intrinsic Functions .. INTRINSIC real ! .. Executable Statements .. iflag = 0 theta = real(iuser(1),kind=nag_wp)*alpha DO ind = 1, lindf i = indf(ind) fvec(i) = (three-(two+theta)*x(i))*x(i) + one IF (i>1) THEN fvec(i) = fvec(i) - x(i-1) END IF IF (i