E04 Chapter Contents
E04 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentE04NDF/E04NDA

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

To supply optional parameters to E04NCF/E04NCA from an external file. More precisely, E04NDF must be used to supply optional parameters to E04NCF and E04NDA must be used to supply optional parameters to E04NCA.
E04NDA is a version of E04NDF that has additional parameters in order to make it safe for use in multithreaded applications (see Section 5). The initialization routine E04WBF must have been called before calling E04NDA.

## 2  Specification

### 2.1  Specification for E04NDF

 SUBROUTINE E04NDF ( IOPTNS, INFORM)
 INTEGER IOPTNS, INFORM

### 2.2  Specification for E04NDA

 SUBROUTINE E04NDA ( IOPTNS, LWSAV, IWSAV, RWSAV, INFORM)
 INTEGER IOPTNS, IWSAV(610), INFORM REAL (KIND=nag_wp) RWSAV(475) LOGICAL LWSAV(120)

## 3  Description

E04NDF/E04NDA may be used to supply values for optional parameters to E04NCF/E04NCA. E04NDF/E04NDA reads an external file and each line of the file defines a single optional parameter. It is only necessary to supply values for those parameters whose values are to be different from their default values.
Each optional parameter is defined by a single character string, of up to $72$ characters, consisting of one or more items. The items associated with a given option must be separated by spaces, or equals signs $\left[=\right]$. Alphabetic characters may be upper or lower case. The string
`Print Level = 1`
is an example of a string used to set an optional parameter. For each option the string contains one or more of the following items:
 – a mandatory keyword; – a phrase that qualifies the keyword; – a number that specifies an integer or real value. Such numbers may be up to $16$ contiguous characters in Fortran's I, F, E or D formats, terminated by a space if this is not the last item on the line.
Blank strings and comments are ignored. A comment begins with an asterisk (*) and all subsequent characters in the string are regarded as part of the comment.
The file containing the options must start with Begin and must finish with End. An example of a valid options file is:
```Begin * Example options file
Print level = 5
End
```
For E04NDF each line of the file is normally printed as it is read, on the current advisory message unit (see X04ABF), but printing may be suppressed using the keyword Nolist. To suppress printing of Begin, Nolist must be the first option supplied as in the file:
```Begin
Nolist
Print level = 5
End
```
Printing will automatically be turned on again after a call to E04NCF or E04NDF and may be turned on again at any time using the keyword List.
For E04NDA printing is turned off by default, but may be turned on at any time using the keyword List.
Optional parameter settings are preserved following a call to E04NCF/E04NCA and so the keyword Defaults is provided to allow you to reset all the optional parameters to their default values before a subsequent call to E04NCF/E04NCA.
A complete list of optional parameters, their abbreviations, synonyms and default values is given in Section 11 in E04NCF/E04NCA.

None.

## 5  Parameters

1:     IOPTNS – INTEGERInput
On entry: the unit number of the options file to be read.
Constraint: $0\le {\mathbf{IOPTNS}}\le 99$.
2:     INFORM – INTEGEROutput
Note: for E04NDA, INFORM does not occur in this position in the parameter list. See the additional parameters described below.
On exit: contains zero if the options file has been successfully read and a $\text{value}>0$ otherwise (see Section 6).
Note: the following are additional parameters for specific use with E04NDA. Users of E04NDF therefore need not read the remainder of this description.
2:     LWSAV($120$) – LOGICAL arrayCommunication Array
3:     IWSAV($610$) – INTEGER arrayCommunication Array
4:     RWSAV($475$) – REAL (KIND=nag_wp) arrayCommunication Array
The arrays LWSAV, IWSAV and RWSAV must not be altered between calls to any of the routines E04NDA, E04NCA, E04NEA or E04WBF.
5:     INFORM – INTEGEROutput
Note: see the parameter description for INFORM above.

## 6  Error Indicators and Warnings

Errors or warnings detected by the routine:
${\mathbf{INFORM}}=1$
IOPTNS is not in the range $\left[0,99\right]$.
${\mathbf{INFORM}}=2$
Begin was found, but end-of-file was found before End was found.
${\mathbf{INFORM}}=3$
end-of-file was found before Begin was found.
${\mathbf{INFORM}}=4$
Not used.
${\mathbf{INFORM}}=5$
One or more lines of the options file is invalid. Check that all keywords are neither ambiguous nor misspelt.

## 7  Accuracy

Not applicable.

E04NEF/E04NEA may also be used to supply optional parameters to E04NCF/E04NCA.

## 9  Example

This example minimizes the quadratic function ${c}^{\mathrm{T}}x+\frac{1}{2}{x}^{\mathrm{T}}Ax$, where
 $c=-4.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-0.1,-0.3T,$
 $A= 2 1 1 1 1 0 0 0 0 1 2 1 1 1 0 0 0 0 1 1 2 1 1 0 0 0 0 1 1 1 2 1 0 0 0 0 1 1 1 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0$
subject to the bounds
 $-2≤x1≤2 -2≤x2≤2 -2≤x3≤2 -2≤x4≤2 -2≤x5≤2 -2≤x6≤2 -2≤x7≤2 -2≤x8≤2 -2≤x9≤2$
and to the general constraints
 $-2.0≤x1+0x2+0x3+0x4+0x5+x6+x7+x8+ 4x9≤ 1.5 -2.0≤x1+ 2x2+ 3x3+ 4x4- 2x5+x6+x7+x8+0x9≤ 1.5 -2.0≤x1-0x2+0x3-0x4+0x5+x6+x7+x8+0x9≤ 4.0$
The initial point, which is feasible, is
 $x0=0,0,0,0,0,0,0,0,0T,$
and $F\left({x}_{0}\right)=0$.
The optimal solution (to five figures) is
 $x*=2.0,-0.23333,-0.26667,-0.3,-0.1,2.0,2.0,-1.7777,-0.45555T,$
and $F\left({x}^{*}\right)=-8.0678$. Three bound constraints and two general constraints are active at the solution. Note that, although the Hessian matrix is positive semidefinite, the point ${x}^{*}$ is unique.
In this example the options file read by E04NDF/E04NDA is appended to the data file for the program (see Section 9.2). It would usually be more convenient in practice to keep the data file and the options file separate.

### 9.1  Program Text

Note: the following programs illustrate the use of E04NDF and E04NDA.

Program Text (e04ndfe.f90)

Program Text (e04ndae.f90)

### 9.2  Program Data

Program Options (e04ndfe.opt)

Program Data (e04ndae.opt)

Program Data (e04ndfe.d)

Program Data (e04ndae.d)

### 9.3  Program Results

Program Results (e04ndfe.r)

Program Results (e04ndae.r)