Program e04mgfe ! E04MGF Example Program Text ! Mark 24 Release. NAG Copyright 2012. ! .. Use Statements .. Use nag_library, Only: e04mff, e04mgf, e04mhf, nag_wp, x04abf, x04acf, & x04baf ! .. Implicit None Statement .. Implicit None ! .. Parameters .. Integer, Parameter :: iset = 1, nin = 5, ninopt = 7, & nout = 6 Character (*), Parameter :: fname = 'e04mgfe.opt' ! .. Local Scalars .. Real (Kind=nag_wp) :: obj Integer :: i, ifail, inform, iter, lda, liwork, & lwork, mode, n, nclin, outchn, sda Character (80) :: rec ! .. Local Arrays .. Real (Kind=nag_wp), Allocatable :: a(:,:), ax(:), bl(:), bu(:), & clamda(:), cvec(:), work(:), x(:) Integer, Allocatable :: istate(:), iwork(:) ! .. Intrinsic Procedures .. Intrinsic :: max ! .. Executable Statements .. Write (rec,*) 'E04MGF Example Program Results' Call x04baf(nout,rec) ! Skip heading in data file Read (nin,*) Read (nin,*) n, nclin liwork = 2*n + 3 ! The minimum LWORK for an LP problem: If (0=n) Then lwork = 2*n**2 + 7*n + 5*nclin Else lwork = 7*n + 1 End If lda = max(1,nclin) If (nclin>0) Then sda = n Else sda = 1 End If Allocate (istate(n+nclin),iwork(liwork),a(lda,sda),bl(n+nclin), & bu(n+nclin),cvec(n),x(n),ax(max(1,nclin)),clamda(n+nclin),work(lwork)) Read (nin,*) cvec(1:n) Read (nin,*)(a(i,1:sda),i=1,nclin) Read (nin,*) bl(1:(n+nclin)) Read (nin,*) bu(1:(n+nclin)) Read (nin,*) x(1:n) ! Set the unit number for advisory messages to OUTCHN outchn = nout Call x04abf(iset,outchn) ! Set three options using E04MHF Call e04mhf(' Print Level = 1 ') Call e04mhf(' Check Frequency = 10 ') Call e04mhf(' Infinite Bound Size = 1.0D+25 ') ! Open the options file for reading mode = 0 ifail = 0 Call x04acf(ninopt,fname,mode,ifail) ! Read the options file for the remaining options Call e04mgf(ninopt,inform) If (inform/=0) Then Write (rec,99999) 'E04MGF terminated with INFORM = ', inform Call x04baf(nout,rec) Go To 100 End If ! Solve the problem ifail = 0 Call e04mff(n,nclin,a,lda,bl,bu,cvec,istate,x,iter,obj,ax,clamda,iwork, & liwork,work,lwork,ifail) 100 Continue 99999 Format (1X,A,I5) End Program e04mgfe