# NAG FL InterfaceReplacement Calls Advice

The following list gives the names of routines that are suitable replacements for routines that have either been withdrawn or deprecated since Mark 20.
The list indicates the minimum change necessary, but many of the replacement routines have additional flexibility and you may wish to take advantage of new features. It is strongly recommended that you consult the routine documents.
Settings help

FL Name Style:

FL Specification Language:

## C02 – Zeros of Polynomials

### c02aff

Deprecated.
Replaced by c02aaf.

#### Old Code

```Real (Kind=nag_wp) :: a(2,0:n)
Real (Kind=nag_wp) :: z(2,n)
Real (Kind=nag_wp) :: w(4*(n+1))
Logical :: scal
...
scal = .True.
Call c02aff(a, n, scal, z, w, ifail)```

#### New Code

```Real (Kind=nag_wp) :: a(2,0:n)
Real (Kind=nag_wp) :: z(2,n)
Complex (Kind=nag_wp) :: aa(0:n)
Complex (Kind=nag_wp) :: zz(n)
Integer :: itmax, polish
Real (Kind=nag_wp) :: berr(n), cond(n)
Integer :: conv(n)
...
itmax = 30
polish=1
! Convert array a from real to complex
aa(0:n) = Cmplx(a(1,0:n),a(2,0:n),kind=nag_wp)
Call c02aaf(aa, n, itmax, polish, zz, berr, cond, conv, ifail)
! Convert array z from Complex to Real
z(1,1:n) = Real(zz(1:n))
z(2,1:n) = Aimag(zz(1:n))```
Note: that arguments a and z are two-dimensional arrays of type real(kind=nag_wp) for c02aff, but are one-dimensional arrays of type complex(kind=nag_wp) for c02aaf. Note also that the roots may be returned in a different order in array z.

### c02agf

Deprecated.
Replaced by c02abf.

#### Old Code

```Real (Kind=nag_wp) :: a(0:n)
Real (Kind=nag_wp) :: z(2,n)
Real (Kind=nag_wp) :: w(2*(n+1))
Logical :: scal
...
scal = .True.
Call c02agf(a, n, scal, z, w, ifail)```

#### New Code

```Real (Kind=nag_wp) :: a(0:n)
Real (Kind=nag_wp) :: z(2,n)
Complex (Kind=nag_wp) :: zz(n)
Integer :: itmax, polish
Real (Kind=nag_wp) :: berr(n), cond(n)
Integer :: conv(n)
...
itmax = 30
polish=1
Call c02abf(a, n, itmax, polish, zz, berr, cond, conv, ifail)
! Convert array z from Complex to Real
z(1,1:n) = Real(zz(1:n))
z(2,1:n) = Aimag(zz(1:n))```
Note: that argument z is a two-dimensional array of type real(kind=nag_wp) for c02agf, but is a one-dimensional array of type complex(kind=nag_wp) for c02abf. Note also that the roots may be returned in a different order in array z.

## C05 – Roots of One or More Transcendental Equations

### c05adf

Withdrawn at Mark 25.
Replaced by c05ayf.

#### Old Code

```Function f(xx)
...
End Function f
...
Call c05adf(a,b,eps,eta,f,x,ifail)```

#### New Code

```Function f(xx,iuser,ruser)
...
Integer,            Intent (Inout) :: iuser(*)
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
...
End Function f
...
Integer            :: iuser(1)
Real (Kind=nag_wp) :: ruser(1)
...
Call c05ayf(a,b,eps,eta,f,x,iuser,ruser,ifail)```

### c05agf

Withdrawn at Mark 25.
Replaced by c05auf.

#### Old Code

```Function f(xx)
...
End Function f
...
Call c05agf(x,h,eps,eta,f,a,b,ifail)```

#### New Code

```Function f(xx,iuser,ruser)
...
Integer,            Intent (Inout) :: iuser(*)
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
...
End Function f
...
Integer            :: iuser(1)
Real (Kind=nag_wp) :: ruser(1)
...
Call c05auf(x,h,eps,eta,f,a,b,iuser,ruser,ifail)```

### c05ajf

Withdrawn at Mark 25.
Replaced by c05awf.

#### Old Code

```Function f(xx)
...
End Function f
...
Call c05ajf(x,eps,eta,f,nfmax,ifail)```

#### New Code

```Function f(xx,iuser,ruser)
...
Integer,            Intent (Inout) :: iuser(*)
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
...
End Function f
...
Integer            :: iuser(1)
Real (Kind=nag_wp) :: ruser(1)
...
Call c05awf(x,eps,eta,f,nfmax,iuser,ruser,ifail)```

### c05nbf

Withdrawn at Mark 25.
Replaced by c05qbf.

#### Old Code

```Subroutine fcn(n,x,fvec,iflag)
...
End Subroutine fcn
...
Call c05nbf(fcn,n,x,fvec,xtol,wa,lwa,ifail)```

#### New Code

```Subroutine fcn(n,x,fvec,iuser,ruser,iflag)
...
Integer,            Intent (Inout) :: iuser(*)
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
...
End Subroutine fcn
...
Integer            :: iuser(1)
Real (Kind=nag_wp) :: ruser(1)
...
Call c05qbf(fcn,n,x,fvec,xtol,iuser,ruser,ifail)```

### c05ncf

Withdrawn at Mark 25.
Replaced by c05qcf.

#### Old Code

```Subroutine fcn(n,x,fvec,iflag)
...
End Subroutine fcn
...
Real (Kind=nag_wp) :: fjac(ldfjac,n)
...
Call c05ncf(fcn,n,x,fvec,xtol,maxfev,ml,mu,epsfcn,diag,mode,factor, &
nprint,nfev,fjac,ldfjac,r,lr,qtf,w,ifail)```

#### New Code

```Subroutine fcn(n,x,fvec,iuser,ruser,iflag)
...
Integer,            Intent (Inout) :: iuser(*)
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
...
End Subroutine fcn
...
Integer            :: iuser(1)
Real (Kind=nag_wp) :: fjac(n,n), ruser(1)
...
Call c05qcf(fcn,n,x,fvec,xtol,maxfev,ml,mu,epsfcn,mode,diag,factor, &
nprint,nfev,fjac,r,qtf,iuser,ruser,ifail)```

### c05ndf

Withdrawn at Mark 25.
Replaced by c05qdf.

#### Old Code

```Real (Kind=nag_wp) :: fjac(ldfjac,n)
...
Call c05ndf(irevcm,n,x,fvec,xtol,ml,mu,epsfcn,diag,mode,factor, &
fjac,ldfjac,r,lr,qtf,w,ifail)```

#### New Code

```Real (Kind=nag_wp) :: fjac(n,n), rwsav(4*n+20)
Integer            :: iwsav(17)
...
Call c05qdf(irevcm,n,x,fvec,xtol,ml,mu,epsfcn,mode,diag,factor, &
fjac,r,qtf,iwsav,rwsav,ifail)```

### c05pbf/​c05pba

Withdrawn at Mark 25.
Replaced by c05rbf.

#### Old Code

```Subroutine fcn_c05pbf(n,x,fvec,fjac,ldfjac,iflag)
...
End Subroutine fcn_c05pbf
...
Real (Kind=nag_wp) :: fjac(ldfjac,n)
...
Call c05pbf(fcn_c05pbf,n,x,fvec,fjac,ldfjac,xtol,wa,lwa,ifail)
or
Subroutine fcn_c05pba(n,x,fvec,fjac,ldfjac,iflag,iuser,ruser)
...
End Subroutine fcn_c05pba
...
Real (Kind=nag_wp) :: fjac(ldfjac,n)
...
Call c05pba(fcn_c05pba,n,x,fvec,fjac,ldfjac,xtol,wa,lwa,iuser,ruser,ifail)```

#### New Code

```Subroutine fcn(n,x,fvec,fjac,iuser,ruser,iflag)
...
End Subroutine fcn
...
Real (Kind=nag_wp) :: fjac(n,n)
...
Call c05rbf(fcn,n,x,fvec,fjac,xtol,iuser,ruser,ifail)```

### c05pcf/​c05pca

Withdrawn at Mark 25.
Replaced by c05rcf.

#### Old Code

```Subroutine fcn_c05pcf(n,x,fvec,fjac,ldfjac,iflag)
...
End Subroutine fcn_c05pcf
...
Real (Kind=nag_wp) :: fjac(ldfjac,n)
...
Call c05pcf(fcn_c05pcf,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag,mode,factor, &
nprint,nfev,njev,r,lr,qtf,w,ifail)
or
Subroutine fcn_c05pca(n,x,fvec,fjac,ldfjac,iflag,iuser,ruser)
...
End Subroutine fcn_c05pca
...
Real (Kind=nag_wp) :: fjac(ldfjac,n)
...
Call c05pca(fcn_c05pca,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag,mode,factor, &
nprint,nfev,njev,r,lr,qtf,w,iuser,ruser,ifail)```

#### New Code

```Subroutine fcn(n,x,fvec,fjac,iuser,ruser,iflag)
...
Integer,            Intent (Inout) :: iuser(*)
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
...
End Subroutine fcn
...
Real (Kind=nag_wp) :: fjac(n,n)
...
Call c05rcf(fcn,n,x,fvec,fjac,xtol,maxfev,mode,diag,factor, &
nprint,nfev,njev,r,qtf,iuser,ruser,ifail)```

### c05pdf/​c05pda

Withdrawn at Mark 25.
Replaced by c05rdf.

#### Old Code

```Real (Kind=nag_wp) :: fjac(ldfjac,n), rwsav(10)
Integer            :: iwsav(15)
...
Call c05pdf(irevcm,n,x,fvec,fjac,ldfjac,xtol,diag,mode,factor, &
r,lr,qtf,w,ifail)
or
Call c05pda(irevcm,n,x,fvec,fjac,ldfjac,xtol,diag,mode,factor, &
r,lr,qtf,w,lwsav,iwsav,rwsav,ifail)```

#### New Code

```Real (Kind=nag_wp) :: fjac(n,n), rwsav(4*n+10)
Integer            :: iwsav(17)
...
Call c05rdf(irevcm,n,x,fvec,fjac,xtol,mode,diag,factor,        &
r,qtf,iwsav,rwsav,ifail)```

### c05zaf

Withdrawn at Mark 25.
Replaced by c05zdf.

#### Old Code

`Call c05zaf(m,n,x,fvec,fjac,ldfjac,xp,fvecp,mode,err)`

#### New Code

```ifail = 0
Call c05zdf(mode,m,n,x,fvec,fjac,ldfjac,xp,fvecp,err,ifail)```
The array xp must now have dimension n regardless of the value of mode, and likewise err must now have dimension m regardless. The argument ifail is the standard NAG argument for error trapping. If you are unfamiliar with this argument you should refer to Section 4 in the Introduction to the NAG Library FL Interface for details.

## C06 – Summation of Series

### c06dbf

Withdrawn at Mark 25.
Replaced by c06dcf.

#### Old Code

```Do i = 1, lx
res(i) = c06dbf(x(i),c,n,s)
End Do```

#### New Code

```xmin = -1.0D0
xmax = 1.0D0

Select Case (s)
Case (1,2,3)
S_USE = s
Case Default
S_USE = 2
End Select

ifail = 0
Call c06dcf(x,lx,xmin,xmax,c,n,s_use,res,ifail)```
The old routine c06dbf returns a single sum at a time, whereas the new routine c06dcf returns a vector of lx values at once. The values supplied in x to c06dcf are un-normalized original variable values in the range $\left[{\mathbf{xmin}},{\mathbf{xmax}}\right]$. The argument ifail is the standard NAG argument for error trapping. If you are unfamiliar with this argument you should refer to Section 4 in the Introduction to the NAG Library FL Interface for details.

### c06eaf

Withdrawn at Mark 26.
Replaced by c06paf.
c06paf removes restrictions on sequence length and combines transform directions.

#### Old Code

`Call c06eaf(x,n,ifail)`

#### New Code

`Call c06paf('F',x,n,work,ifail)`
where work is a real array of length $3×{\mathbf{n}}+100$ and the dimension of the array x has been extended from the original n to ${\mathbf{n}}+2$. The output values x are stored in a different order with real and imaginary parts stored contiguously. The mapping of output elements is as follows:
• ${\mathbf{x}}\left(2×\mathit{i}\right)←{\mathbf{x}}\left(\mathit{i}\right)$, for $\mathit{i}=0,1,\dots ,{\mathbf{n}}/2$ and
${\mathbf{x}}\left(2×\mathit{i}+1\right)←{\mathbf{x}}\left({\mathbf{n}}-\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,\left({\mathbf{n}}+1\right)/2$.

### c06ebf

Withdrawn at Mark 26.
Replaced by c06paf.
c06paf removes restrictions on sequence length and combines transform directions.

#### Old Code

`Call c06ebf(x,n,ifail)`

#### New Code

`Call c06paf('B',x,n,work,ifail)`
where work is a real array of length $3×{\mathbf{n}}+100$ and the dimension of the array x has been extended from the original n to ${\mathbf{n}}+2$. The input values of x are stored in a different order with real and imaginary parts stored contiguously. Also c06paf performs the inverse transform without the need to first conjugate. If prior conjugation of original array x is assumed then the mapping of input elements is:
• ${\mathbf{x}}\left(2×\mathit{i}\right)←{\mathbf{x}}\left(\mathit{i}\right)$, for $\mathit{i}=0,1,\dots ,{\mathbf{n}}/2$ and
${\mathbf{x}}\left(2×\mathit{i}+1\right)←{\mathbf{x}}\left({\mathbf{n}}-\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,\left({\mathbf{n}}-1\right)/2$.

### c06ecf

Withdrawn at Mark 26.
Replaced by c06pcf.
c06pcf removes restrictions on sequence length, combines transform directions and uses complex types.

#### Old Code

`Call c06ecf(x,y,n,ifail)`

#### New Code

`Call c06pcf('F',z,n,work,ifail)`
where work is a complex array of length $2×{\mathbf{n}}+15$ and Z is a complex array of length n such that $\text{Z}\left(\mathit{i}\right)=\mathrm{Cmplx}\left(\text{X}\left(\mathit{i}\right),\text{Y}\left(\mathit{i}\right)\right)$, for $\mathit{i}=0,1,\dots ,{\mathbf{n}}-1$ on input and output.

### c06ekf

Withdrawn at Mark 26.
Replaced by c06fkf.
c06fkf removes restrictions on sequence length.

#### Old Code

`Call c06ekf(ijob,x,y,n,ifail)`

#### New Code

`Call c06fkf(ijob,x,y,n,work,ifail)`
where work is a real array of length n.

### c06fpf

Scheduled for withdrawal at Mark 28.
Replaced by c06ppf or c06pqf.
c06pqf provides a simpler interface for both forward and backward transforms. c06ppf retains original input ordering at the expense of efficiency.

#### Old Code

`Call c06fpf(m,n,x,init,trig,work,ifail)`

#### New Code

`Call c06pqf('F',n,m,x,work,ifail)`
where the dimension of work has been extended from ${\mathbf{m}}×{\mathbf{n}}$ to ${\mathbf{m}}×{\mathbf{n}}+2×{\mathbf{n}}$ (to include trig) and the dimension of the array x has been extended from the original ${\mathbf{n}}×{\mathbf{m}}$ to $\left({\mathbf{n}}+2\right)×{\mathbf{m}}$.
The input values are stored slightly differently to allow for two extra storage spaces at the end of each sequence.
The mapping of input elements is as follows:
• (Here x begins at element zero ${\mathbf{x}}\left(0\right)$.)
for $\mathit{j}=0,1,\dots ,{\mathbf{m}}-1$
• $J=j×\left({\mathbf{n}}+2\right)$;
• ${\mathbf{x}}\left(J+\mathit{i}\right)←{\mathbf{x}}\left(\mathit{i}×{\mathbf{m}}+j\right)$, for $\mathit{i}=0,1,\dots ,{\mathbf{n}}-1$;
• ${\mathbf{x}}\left(J+{\mathbf{n}}\right)$ and ${\mathbf{x}}\left(J+{\mathbf{n}}+1\right)$ need not be set.
The output values x are stored in a different order with real and imaginary parts of each Hermitian sequence stored contiguously.
The mapping of output elements is as follows:
• (Here x begins at element zero ${\mathbf{x}}\left(0\right)$.)
for $\mathit{j}=0,1,\dots ,{\mathbf{m}}-1$
• $J=j×\left({\mathbf{n}}+2\right)$;
• ${\mathbf{x}}\left(J+2×\mathit{i}\right)←{\mathbf{x}}\left(\mathit{i}×{\mathbf{m}}+j\right)$, for $\mathit{i}=0,1,\dots ,{\mathbf{n}}/2$ [real parts];
• ${\mathbf{x}}\left(J+2×\mathit{i}+1\right)←{\mathbf{x}}\left(\left({\mathbf{n}}-\mathit{i}\right)×{\mathbf{m}}+j\right)$, for $\mathit{i}=1,2,\dots ,\left({\mathbf{n}}-1\right)/2$ [imaginary parts];
• ${\mathbf{x}}\left(J+1\right)$ is set to zero;
• ${\mathbf{x}}\left(J+{\mathbf{n}}+1\right)$ is set to zero when n is even.

### c06fqf

Scheduled for withdrawal at Mark 28.
Replaced by c06ppf or c06pqf.
c06pqf provides a simpler interface for both forward and backward transforms. c06ppf returns real sequences in row order at the expense of efficiency.

#### Old Code

`Call c06fqf(m,n,x,init,trig,work,ifail)`

#### New Code

`Call c06pqf('B',n,m,x,work,ifail)`
where the dimension of work has been extended from ${\mathbf{m}}×{\mathbf{n}}$ to ${\mathbf{m}}×{\mathbf{n}}+2×{\mathbf{n}}$ (to include trig) and the dimension of the array x has been extended from the original ${\mathbf{n}}×{\mathbf{m}}$ to $\left({\mathbf{n}}+2\right)×{\mathbf{m}}$.
The input values x are stored in a different order with real and imaginary parts of each Hermitian sequence stored contiguously.
The mapping of input elements is as follows:
• (Here x begins at element zero ${\mathbf{x}}\left(0\right)$.)
for $\mathit{j}=0,1,\dots ,{\mathbf{m}}-1$
• $J=j×\left({\mathbf{n}}+2\right)$;
• ${\mathbf{x}}\left(J+2×\mathit{i}\right)←{\mathbf{x}}\left(\mathit{i}×{\mathbf{m}}+j\right)$, for $\mathit{i}=0,1,\dots ,{\mathbf{n}}/2$ [real parts];
• ${\mathbf{x}}\left(J+2×\mathit{i}+1\right)←{\mathbf{x}}\left(\left({\mathbf{n}}-\mathit{i}\right)×{\mathbf{m}}+j\right)$, for $\mathit{i}=1,2,\dots ,\left({\mathbf{n}}-1\right)/2$ [imaginary parts];
• ${\mathbf{x}}\left(J+1\right)$ must be zero;
• ${\mathbf{x}}\left(J+{\mathbf{n}}+1\right)$ must zero when n is even.
The output values are stored slightly differently to allow for two extra storage spaces at the end of each sequence.
The mapping of output elements is as follows:
• (Here x begins at element zero ${\mathbf{x}}\left(0\right)$.)
for $\mathit{j}=0,1,\dots ,{\mathbf{m}}-1$
• $J=j×\left({\mathbf{n}}+2\right)$;
• ${\mathbf{x}}\left(J+\mathit{i}\right)←{\mathbf{x}}\left(\mathit{i}×{\mathbf{m}}+j\right)$, for $\mathit{i}=0,1,\dots ,{\mathbf{n}}-1$;
• ${\mathbf{x}}\left(J+{\mathbf{n}}\right)$ and ${\mathbf{x}}\left(J+{\mathbf{n}}+1\right)$ will be set to zero.

### c06frf

Withdrawn at Mark 26.
Replaced by c06psf.
c06psf provides a simpler interface for both forward and backward transforms.

#### Old Code

`Call c06frf(m,n,x,y,init,trig,work,ifail)`

#### New Code

```Do j = 1, m*n
cx(j) = Cmplx(x(j),y(j),Kind=nag_wp)
End Do
Call c06psf('F',m,n,cx,cwork,ifail)
x(1:m*n) = Real(cx(1:m*n))
y(1:m*n) = Aimag(cx(1:m*n))```
where $\mathrm{cx}$ and $\mathrm{cwork}$ are complex array of length ${\mathbf{m}}×{\mathbf{n}}$ and ${\mathbf{n}}×{\mathbf{m}}+2×{\mathbf{n}}+15$ respectively.

### c06fuf

Withdrawn at Mark 26.
Replaced by c06puf.
c06puf provides a simpler interface for both forward and backward transforms.

#### Old Code

`Call c06fuf(m,n,x,y,init,trigm,trign,work,ifail)`

#### New Code

```Do j = 1, m*n
cx(j) = Cmplx(x(j),y(j),Kind=nag_wp)
End Do
Call c06puf('F',m,n,cx,cwork,ifail)
x(1:m*n) = Real(cx(1:m*n))
y(1:m*n) = Aimag(cx(1:m*n))```
where $\mathrm{cx}$ and $\mathrm{cwork}$ are complex arrays of lengths $\mathrm{m}×\mathrm{n}$ and $\mathrm{n}×\mathrm{m}+2×\mathrm{n}+2×\mathrm{m}+30$ respectively.

### c06gbf

Withdrawn at Mark 26.
There is no replacement for this routine.

### c06gcf

Withdrawn at Mark 26.
There is no replacement for this routine.

### c06gqf

Withdrawn at Mark 26.
There is no replacement for this routine.

### c06gsf

Withdrawn at Mark 26.
There is no replacement for this routine.

### c06haf

Withdrawn at Mark 26.
Replaced by c06ref.
c06ref has a simpler interface, storing sequences by column.

#### Old Code

`Call c06haf(m,n,x,init,trig,work,ifail)`

#### New Code

`Call c06ref(m,n,y,ifail)`
where $\mathit{y}\left(1:n-1,m\right)$ is a two-dimensional real array such that $\mathit{y}\left(1:n-1,j\right)=\mathit{x}\left(j:m×\left(n-1\right),m\right)$.

### c06hbf

Withdrawn at Mark 26.
Replaced by c06rff.
c06rff has a simpler interface, storing sequences by column.

#### Old Code

`Call c06hbf(m,n,x,init,trig,work,ifail)`

#### New Code

`Call c06rff(m,n,y,ifail)`
where $\mathit{y}\left(0:n,m\right)$ is a two-dimensional real array such that $\mathit{y}\left(0:n,j\right)=\mathit{x}\left(j:m×\left(n+1\right),m\right)$.

### c06hcf

Withdrawn at Mark 26.
Replaced by c06rgf.
c06rgf has a simpler interface, storing sequences by column.

#### Old Code

`Call c06hcf(direct,m,n,x,init,trig,work,ifail)`

#### New Code

`Call c06rgf(idir,m,n,y,ifail)`
where $\mathit{y}\left(1:n,m\right)$ is a two-dimensional real array such that $\mathit{y}\left(1:n,j\right)=\mathit{x}\left(j:m×n,m\right)$; ${\mathbf{idir}}=1$ or $-1$ for forward and inverse transforms respectively.

### c06hdf

Withdrawn at Mark 26.
Replaced by c06rhf.
c06rhf has a simpler interface, storing sequences by column.

#### Old Code

`Call c06hdf(direct,m,n,x,init,trig,work,ifail)`

#### New Code

`Call c06rhf(idir,m,n,y,ifail)`
where $\mathit{y}\left(0:n-1,m\right)$ is a two-dimensional real array such that $\mathit{y}\left(0:n-1,j\right)=\mathit{x}\left(j:m×n,m\right)$; ${\mathbf{idir}}=1$ or $-1$ for forward and inverse transforms respectively.

## D01 – Quadrature

### d01ajf

Deprecated.
Replaced by d01rjf.
d01rjf provides thread safety in passing of data to user-supplied function. d01rjf also requires the user-supplied subroutine f to calculate a vector of abscissae at once for greater efficiency, has an improved interface for setting the maximum number of subdivisions allowed (maxsub), and returns additional information on the computation (in the arrays rinfo and iinfo rather than w and iw previously).
Callbacks

#### Old Code

```Function f(x)
Real (Kind=nag_wp)                 :: f
Real (Kind=nag_wp), Intent (In)    :: x```

#### New Code

```Subroutine f(x,nx,fv,iflag,iuser,ruser,cpuser)
Integer, Intent (In)               :: nx
Integer, Intent (Inout)            :: iflag, iuser(*)
Real (Kind=nag_wp), Intent (In)    :: x(nx)
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
Real (Kind=nag_wp), Intent (Out)   :: fv(nx)
Type (c_ptr), Intent (In)          :: cpuser```
Main Call

#### Old Code

`Call d01ajf(f,a,b,epsabs,epsrel,result,abserr,w,lw,iw,liw,ifail)`

#### New Code

`Call d01rjf(f,a,b,epsabs,epsrel,maxsub,result,abserr,rinfo,iinfo,iuser,ruser,cpuser,ifail)`
The arrays iuser and ruser and C pointer cpuser allow you to pass information to the user-supplied subroutine f.

### d01akf

Deprecated.
Replaced by d01rkf.
d01rkf provides thread safety in passing of data to user-supplied function. d01rkf also requires the user-supplied subroutine f to calculate a vector of abscissae at once for greater efficiency, has an improved interface for setting the maximum number of subdivisions allowed (maxsub), and returns additional information on the computation (in the arrays rinfo and iinfo rather than w and iw previously).
Callbacks

#### Old Code

```Function f(x)
Real (Kind=nag_wp)                 :: f
Real (Kind=nag_wp), Intent (In)    :: x```

#### New Code

```Subroutine f(x,nx,fv,iflag,iuser,ruser,cpuser)
Integer, Intent (In)               :: nx
Integer, Intent (Inout)            :: iflag, iuser(*)
Real (Kind=nag_wp), Intent (In)    :: x(nx)
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
Real (Kind=nag_wp), Intent (Out)   :: fv(nx)
Type (c_ptr), Intent (In)          :: cpuser```
Main Call

#### Old Code

`Call d01akf(f,a,b,epsabs,epsrel,result,abserr,w,lw,iw,liw,ifail)`

#### New Code

```key = 6
Call d01rkf(f,a,b,key,epsabs,epsrel,maxsub,result,abserr,rinfo,iinfo,iuser,ruser,cpuser,ifail)```
The arrays iuser and ruser and C pointer cpuser allow you to pass information to the user-supplied subroutine f.

### d01alf

Deprecated.
Replaced by d01rlf.
d01rlf provides thread safety in passing of data to user-supplied function. d01rlf also requires the user-supplied subroutine f to calculate a vector of abscissae at once for greater efficiency, has an improved interface for setting the maximum number of subdivisions allowed (maxsub), and returns additional information on the computation (in the arrays rinfo and iinfo rather than w and iw previously).
Callbacks

#### Old Code

```Function f(x)
Real (Kind=nag_wp)                 :: f
Real (Kind=nag_wp), Intent (In)    :: x```

#### New Code

```Subroutine f(x,nx,fv,iflag,iuser,ruser,cpuser)
Integer, Intent (In)               :: nx
Integer, Intent (Inout)            :: iflag, iuser(*)
Real (Kind=nag_wp), Intent (In)    :: x(nx)
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
Real (Kind=nag_wp), Intent (Out)   :: fv(nx)
Type (c_ptr), Intent (In)          :: cpuser```
Main Call

#### Old Code

`Call d01alf(f,a,b,npts,points,epsabs,epsrel,result,abserr,w,lw,iw,liw,ifail)`

#### New Code

```Call d01rlf(f,a,b,npts,points,epsabs,epsrel,maxsub,result,abserr,rinfo,iinfo,&
iuser,ruser,cpuser,ifail)```
The arrays iuser and ruser and C pointer cpuser allow you to pass information to the user-supplied subroutine f.

### d01amf

Deprecated.
Replaced by d01rmf.
d01rmf provides thread safety in passing of data to user-supplied function. d01rmf also requires the user-supplied subroutine f to calculate a vector of abscissae at once for greater efficiency, has an improved interface for setting the maximum number of subdivisions allowed (maxsub), and returns additional information on the computation (in the arrays rinfo and iinfo rather than w and iw previously).
Callbacks

#### Old Code

```Function f(x)
Real (Kind=nag_wp)                 :: f
Real (Kind=nag_wp), Intent (In)    :: x```

#### New Code

```Subroutine f(x,nx,fv,iflag,iuser,ruser,cpuser)
Integer, Intent (In)               :: nx
Integer, Intent (Inout)            :: iflag, iuser(*)
Real (Kind=nag_wp), Intent (In)    :: x(nx)
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
Real (Kind=nag_wp), Intent (Out)   :: fv(nx)
Type (c_ptr), Intent (In)          :: cpuser```
Main Call

#### Old Code

`Call d01amf(f,bound,inf,epsabs,epsrel,result,abserr,w,lw,iw,liw,ifail)`

#### New Code

```Call d01rmf(f,bound,inf,epsabs,epsrel,maxsub,result,abserr,rinfo,iinfo,&
iuser,ruser,cpuser,ifail)```
The arrays iuser and ruser and C pointer cpuser allow you to pass information to the user-supplied subroutine f.

### d01atf

Deprecated.
Replaced by d01rjf.
d01rjf provides thread safety in passing of data to user-supplied function. d01rjf also has an improved interface for setting the maximum number of subdivisions allowed (maxsub) and returns additional information on the computation (in the arrays rinfo and iinfo rather than w and iw previously).
Callbacks

#### Old Code

```Subroutine f(x,fv,nx)
Integer, Intent (In)         :: nx
Real (Kind=nag_wp), Intent (In)  :: x(nx)
Real (Kind=nag_wp), Intent (Out) :: fv(nx)```

#### New Code

```Subroutine f(x,nx,fv,iflag,iuser,ruser,cpuser)
Integer, Intent (In)               :: nx
Integer, Intent (Inout)            :: iflag, iuser(*)
Real (Kind=nag_wp), Intent (In)    :: x(nx)
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
Real (Kind=nag_wp), Intent (Out)   :: fv(nx)
Type (c_ptr), Intent (In)          :: cpuser```
Main Call

#### Old Code

`Call d01atf(f,a,b,epsabs,epsrel,result,abserr,w,lw,iw,liw,ifail)`

#### New Code

`Call d01rjf(f,a,b,epsabs,epsrel,maxsub,result,abserr,rinfo,iinfo,iuser,ruser,cpuser,ifail)`
The arrays iuser and ruser and C pointer cpuser allow you to pass information to the user-supplied subroutine f.

### d01auf

Deprecated.
Replaced by d01rkf.
d01rkf provides thread safety in passing of data to user-supplied function. d01rkf also has an improved interface for setting the maximum number of subdivisions allowed (maxsub) and returns additional information on the computation (in the arrays rinfo and iinfo rather than w and iw previously).
Callbacks

#### Old Code

```Subroutine f(x,fv,nx)
Integer, Intent (In)         :: nx
Real (Kind=nag_wp), Intent (Out) :: fv(nx)
Real (Kind=nag_wp), Intent (In)  :: x(nx)```

#### New Code

```Subroutine f(x,nx,fv,iflag,iuser,ruser,cpuser)
Integer, Intent (In)               :: nx
Integer, Intent (Inout)            :: iflag, iuser(*)
Real (Kind=nag_wp), Intent (In)    :: x(nx)
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
Real (Kind=nag_wp), Intent (Out)   :: fv(nx)
Type (c_ptr), Intent (In)          :: cpuser```
Main Call

#### Old Code

`Call d01auf(f,a,b,key,epsabs,epsrel,result,abserr,w,lw,iw,liw,ifail)`

#### New Code

```Call d01rkf(f,a,b,key,epsabs,epsrel,maxsub,result,abserr,rinfo,iinfo,iuser,ruser,cpuser,&
ifail)```
The arrays iuser and ruser and C pointer cpuser allow you to pass information to the user-supplied subroutine f.

### d01baf

Withdrawn at Mark 26.
Replaced by d01uaf.
d01uaf provides thread safety in passing of data to user-supplied function and a simpler interface to select the quadrature rule.

#### Old Code

```Function fun(x)

...
Real (Kind=nag_wp) :: fun
Real (Kind=nag_wp), Intent (In) :: x
fun = ...
End Function

dinest = d01baf(d01xxx,a,b,n,fun,ifail)```

#### New Code

```Subroutine f(x,nx,fv,iflag,iuser,ruser)
...
! see example below
...
End Subroutine f
...
Integer :: key
Integer, Allocatable :: iuser(:)
Real (Kind=nag_wp), Allocatable :: ruser(:)

! set KEY according to quadrature formula
! KEY =  0 : (D01XXX=D01BAZ)
! KEY = -3 : (D01XXX=D01BAY)
! KEY = -4 : (D01XXX=D01BAW)
! KEY = -5 : (D01XXX=D01BAX)
! KEY = ABS(KEY) for normal weights
key = 0

Allocate(iuser(liuser), ruser(lruser))

Call d01uaf(key,a,b,n,f,dinest,iuser,ruser,ifail)```
iuser and ruser are arrays available to allow you to pass information to the user-supplied subroutine f.
iflag is an Integer which you may use to force an immediate exit from d01uaf in case of an error in the user-supplied subroutine f.
f may be used to call the original fun as follows, although it may be more efficient to recode the integrand.
```Subroutine f(x,nx,fv,iflag,iuser,ruser)
...
Integer, Intent (In) :: nx
Integer, Intent (Inout) :: iflag
Real (Kind=nag_wp), Intent (In) :: x(nx)
Real (Kind=nag_wp), Intent (Out) :: fv(nx)
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
Integer, Intent (Inout) :: iuser(*)
Integer :: j
External fun

Do j=1,nx
fv(j)  = fun(x(j))
End Do

End Subroutine f```

### d01bbf

Withdrawn at Mark 26.
Replaced by d01tbf.
d01tbf provides thread safety in passing of data to the user-supplied routine and a simpler interface to select the quadrature rule.

#### Old Code

`Call d01bbf(d01xxx,a,b,itype,n,weight,abscis,ifail)`

#### New Code

```Integer :: key
Call d01tbf(key,a,b,n,weight,absics,ifail)```
The supplied subroutines D01XXX and the argument itype have been combined into a single argument key. ${\mathbf{key}}<0$ is equivalent to $\mathbf{itype}=1$ (adjusted weights). ${\mathbf{key}}>0$ is equivalent to $\mathbf{itype}=0$ (normal weights). $|{\mathbf{key}}|$ indicates the quadrature rule.
• $|{\mathbf{key}}|=0$ : Gauss–Legendre ($\mathbf{D01XXX}=\mathbf{D01BAZ}$)
• $|{\mathbf{key}}|=3$ : Gauss–Laguerre ($\mathbf{D01XXX}=\mathbf{D01BAX}$)
• $|{\mathbf{key}}|=4$ : Gauss–Hermite ($\mathbf{D01XXX}=\mathbf{D01BAW}$)
• $|{\mathbf{key}}|=5$ : Rational Gauss ($\mathbf{D01XXX}=\mathbf{D01BAY}$)

### d01bcf

Deprecated.
Replaced by d01tcf.
d01tcf provides a clearer chapter structure to match the name in the CL interfaces. d01tcf has an identical argument list to d01bcf.

### d01rbf

Scheduled for withdrawal at Mark 28.
There is no replacement for this routine.
This routine has been withdrawn as a separate diagnostic routine is not required. The details of the computation, as stored in the parameters icom and com, are specified in Section 9.1 in d01raf.
See Section 9 in d01raf for further details.

## D02 – Ordinary Differential Equations

### d02pcf

Withdrawn at Mark 26.
Replaced by d02pef and associated D02P routines.
these replacements were made primarily for reasons of threadsafety.

#### Old Code

```Call d02pvf(n,tstart,yinit,tend,tol,thresh,method,'u',errass, &
hstart,w,lw,ifail)
...
Call d02pcf(f,twant,t,y,yp,ymax,w,ifail)```

#### New Code

```If (.Not. errass) method = -method
Call d02pqf(n,tstart,tend,yinit,tol,thresh,method,hstart,iwsav, &
rwsav,ifail)
...
Call d02pef(f2,n,twant,t,y,yp,ymax,iuser,ruser,iwsav,rwsav,ifail)```
iwsav is an integer array of length $130$ and rwsav is a real array of length $350+32×{\mathbf{n}}$.
iuser and ruser are arrays available to allow you to pass information to the user defined routine f2 (see f in d02pef).
the definition of f2 (see f in d02pef) can use the original routine f as follows:
```   Subroutine f2(t,n,y,yp,iuser,ruser)
!     .. Scalar Arguments ..
Real (Kind=nag_wp), Intent (In)      :: t
Integer, Intent (In)             :: n
!     .. Array Arguments ..
Real (Kind=nag_wp), Intent (Inout)   :: ruser(1)
Real (Kind=nag_wp), Intent (In)      :: y(n)
Real (Kind=nag_wp), Intent (Out)     :: yp(n)
Integer, Intent (Inout)          :: iuser(1)
!     .. Procedure Arguments ..
External                         :: f
!     .. Executable Statements ..
Continue

Call f(t,y,yp)

Return
End Subroutine f2```

### d02pdf

Withdrawn at Mark 26.
Replaced by d02pff or d02pgf and associated D02P routines.
These replacements were made primarily for reasons of threadsafety. d02pgf also offers a reverse communication approach.

#### Old Code

```Call d02pvf(n,tstart,yinit,tend,tol,thresh,method,'U',errass, &
hstart,w,lw,ifail)
...
Call d02pdf(f,t,y,yp,work,ifail)```

#### New Code

```If (.Not. errass) method = -method
Call d02pqf(n,tstart,tend,yinit,tol,thresh,method,hstart,iwsav, &
rwsav,ifail)
...
Call d02pff(f2,n,t,y,yp,iuser,ruser,iwsav,rwsav,ifail)```
iwsav is an integer array of length $130$ and rwsav is a real array of length $350+32×{\mathbf{n}}$.
iuser and ruser are arrays available to allow you to pass information to the user defined routine f2 (see f in d02pef).
The definition of f2 (see f in d02pef) can use the original routine f as follows:
```   Subroutine f2(t,n,y,yp,iuser,ruser)
!     .. Scalar Arguments ..
Real (Kind=nag_wp), Intent (In)      :: t
Integer, Intent (In)             :: n
!     .. Array Arguments ..
Real (Kind=nag_wp), Intent (Inout)   :: ruser(1)
Real (Kind=nag_wp), Intent (In)      :: y(n)
Real (Kind=nag_wp), Intent (Out)     :: yp(n)
Integer, Intent (Inout)          :: iuser(1)
!     .. Procedure Arguments ..
External                         :: f
!     .. Executable Statements ..
Continue

Call f(t,y,yp)

Return
End Subroutine f2```

### d02pvf

Withdrawn at Mark 26.
Replaced by d02pqf.
This replacement was made primarily for reasons of threadsafety.
See d02pcf and d02pdf for further information.

### d02pwf

Withdrawn at Mark 26.
Replaced by d02prf.
This replacement was made primarily for reasons of threadsafety.

#### Old Code

`Call d02pwf(tendnu,ifail)`

#### New Code

`Call d02prf(tendnu,iwsav,rwsav,ifail)`
iwsav is an integer array of length $130$ and rwsav is a real array of length $350$.

### d02pxf

Withdrawn at Mark 26.
Replaced by d02psf.
This replacement was made primarily for reasons of threadsafety.

#### Old Code

```Call d02pxf(twant,reqest,nwant,ywant,ypwant,f,work,wrkint, &
lenint,ifail)```

#### New Code

```If (reqest == 'S' .Or. reqest == 's') Then
ideriv = 0
Else if (reqest == 'D' .Or. reqest == 'd') Then
ideriv = 1
Else
ideriv = 2
End If
Call d02psf(twant,ideriv,nwant,ywant,ypwant,f2,workint, &
lenint,iuser,ruser,iwsav,rwsav,ifail)```
iwsav is an integer array of length $130$ and rwsav is a real array of length $350+32×{\mathbf{n}}$.
iuser and ruser are arrays available to allow you to pass information to the user defined routine f2 (see f in d02psf).
wcomm is a real array of length lwcomm. See the routine document for d02psf for further information.
The definition of f2 (see f in d02psf) can use the original routine f as follows:
```Subroutine f2(t,n,y,yp,iuser,ruser)
!     .. Scalar Arguments ..
Real (Kind=nag_wp), Intent (In)      :: t
Integer, Intent (In)             :: n
!     .. Array Arguments ..
Real (Kind=nag_wp), Intent (Inout)   :: ruser(1)
Real (Kind=nag_wp), Intent (In)      :: y(n)
Real (Kind=nag_wp), Intent (Out)     :: yp(n)
Integer, Intent (Inout)          :: iuser(1)
!     .. Procedure Arguments ..
External                         :: f
!     .. Executable Statements ..
Continue

Call f(t,y,yp)

Return
End Subroutine f2```

### d02pyf

Withdrawn at Mark 26.
Replaced by d02ptf.
This replacement was made primarily for reasons of threadsafety.

#### Old Code

`Call d02pyf(totfcn,stpcst,waste,stpsok,hnext,ifail)`

#### New Code

```Call d02ptf(totfcn,stpcst,waste,stpsok,hnext,iwsav, &
rwsav,ifail)```

### d02pzf

Withdrawn at Mark 26.
Replaced by d02puf.
This replacement was made primarily for reasons of threadsafety.

#### Old Code

`Call d02pzf(rmserr,errmax,terrmx,work,ifail)`

#### New Code

`Call d02puf(n,rmserr,errmax,terrmx,iwsav,rwsav,ifail)`
n must be unchanged from that passed to d02pqf.
iwsav is an integer array of length $130$ and rwsav is a real array of length $350+32×{\mathbf{n}}$.

### d02tkf

Withdrawn at Mark 27.
Replaced by d02tlf.
This replacement was made primarily for reasons of threadsafety.

#### Old Code

`Call d02tkf(ffun,fjac,gafun,gbfun,gajac,gbjac,guess,rcomm,icomm,ifail)`

#### New Code

```Call d02tlf(ffun,fjac,gafun,gbfun,gajac,gbjac,guess,rcomm,icomm,iuser, &
ruser,ifail)```
The arrays iuser and ruser are also supplied as an additional two arguments to the seven user-supplied routines. These arrays are free to use to supply information to the seven routine arguments.

## D03 – Partial Differential Equations

### d03ryf

Withdrawn at Mark 27.
There is no replacement for this routine.

## E01 – Interpolation

### e01sef

Withdrawn at Mark 20.
Replaced by e01sgf.

#### Old Code

`Call e01sef(m,x,y,f,rnw,rnq,nw,nq,fnodes,minnq,wrk,ifail)`

#### New Code

`Call e01sgf(m,x,y,f,nw,nq,iq,liq,rq,lrq,ifail)`
e01sef has been superseded by e01sgf which gives improved accuracy, facilities for obtaining gradient values and a consistent interface with e01tgf for interpolation of scattered data in three dimensions.
The interpolant generated by the two routines will not be identical, but similar results may be obtained by using the same values of nw and nq. Details of the interpolant are passed to the evaluator through the arrays iq and rq rather than fnodes and rnw.

### e01sff

Withdrawn at Mark 20.
Replaced by e01shf.

#### Old Code

`Call e01sff(m,x,y,f,rnw,fnodes,px,py,pf,ifail)`

#### New Code

`Call e01shf(m,x,y,f,iq,liq,rq,lrq,1,px,py,pf,qx,qy,ifail)`
The two calls will not produce identical results due to differences in the generation routines e01sef and e01sgf. Details of the interpolant are passed from e01sgf through the arrays iq and rq rather than fnodes and rnw.
e01shf also returns gradient values in qx and qy and allows evaluation at arrays of points rather than just single points.

## E02 – Curve and Surface Fitting

### e02acf

Withdrawn at Mark 27.
Replaced by e02alf.

#### Old Code

`Call e02acf(x,y,n,a,m1,ref)`

#### New Code

`Call e02alf(n,x,y,m1-1,a,ref,ifail)`

## E04 – Minimizing or Maximizing a Function

### e04ccf/​e04cca

Withdrawn at Mark 24.
Replaced by e04cbf.

#### Old Code

```Call e04ccf(n,x,f,tol,iw,w1,w2,w3,w4,w5,w6,funct,monit,maxcal,   &
ifail)
or
Call e04cca(n,x,f,tol,iw,w1,w2,w3,w4,w5,w6,funct2,monit2,maxcal, &
iuser,ruser,ifail)```

#### New Code

```Call e04cbf(n,x,f,tolf,tolx,funct2,monit3,maxcal,iuser,ruser,    &
ifail)```
``` Subroutine         monit3(fmin,fmax,sim,n,ncall,serror,vratio,iuser,
ruser)
Integer            n, ncall, iuser(*)
Real (Kind=nag_wp) fmin, fmax, sim(n+1,n), serror, vratio, ruser(*)

Call monit2(fmin,fmax,sim,n,n+1,ncall,iuser,ruser)
!      Add code here to monitor the values of SERROR and VRATIO, if necessary
Return
End```

### e04dgf/​e04dga

Deprecated.
Replaced by e04kff.
The new solver e04kff is part of the NAG optimization modelling suite (see Section 3.1 in the E04 Chapter Introduction), therefore the definition of the objective function values and gradients need to be split into two separate subroutines. e04kff offers a significant improvement in performance over e04dgf/​e04dga as well as additional functionality, such as the addition of variable bounds and monitoring.
Callbacks

#### Old Code

```   Subroutine objfun(mode,n,x,objf,objgrd,nstate,iuser,ruser)

!     .. Implicit None Statement ..
Implicit None
!     .. Scalar Arguments ..
Real (Kind=nag_wp), Intent (Out) :: objf
Integer, Intent (Inout)        :: mode
Integer, Intent (In)           :: n, nstate
!     .. Array Arguments ..
Real (Kind=nag_wp), Intent (Out) :: objgrd(n)
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
Real (Kind=nag_wp), Intent (In) :: x(n)
Integer, Intent (Inout)        :: iuser(*)
!     .. Executable Statements ..

!     Compute objective at point x
objf = ...

If (mode == 2) Then
!     Compute objective gradient at point x
objgrd(1:n) = (/.../)
End If

Return
End Subroutine objfun```

#### New Code

```   Subroutine objfun(nvar,x,fx,inform,iuser,ruser,cpuser)

!     .. Use Statements ..
Use, Intrinsic                 :: iso_c_binding, Only: c_ptr
!     .. Implicit None Statement ..
Implicit None
!     .. Scalar Arguments ..
Type (c_ptr), Intent (In)      :: cpuser
Real (Kind=nag_wp), Intent (Out) :: fx
Integer, Intent (Inout)        :: inform
Integer, Intent (In)           :: nvar
!     .. Array Arguments ..
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
Real (Kind=nag_wp), Intent (In) :: x(nvar)
Integer, Intent (Inout)        :: iuser(*)
!     .. Executable Statements ..

!     Compute objective at point x
fx = ...

Return
End Subroutine objfun

Subroutine objgrd(nvar,x,nnzfd,fdx,inform,iuser,ruser,cpuser)

!     .. Use Statements ..
Use, Intrinsic                 :: iso_c_binding, Only: c_ptr
!     .. Implicit None Statement ..
Implicit None
!     .. Scalar Arguments ..
Type (c_ptr), Intent (In)      :: cpuser
Integer, Intent (Inout)        :: inform
Integer, Intent (In)           :: nnzfd, nvar
!     .. Array Arguments ..
Real (Kind=nag_wp), Intent (Inout) :: fdx(nvar), ruser(*)
Real (Kind=nag_wp), Intent (In) :: x(nvar)
Integer, Intent (Inout)        :: iuser(*)
!     .. Executable Statements ..

!     Compute objective gradient at point x
fdx(1:nnzfd) = (/.../)

Return
End Subroutine objgrd```
Main Call

#### Old Code

```ifail = -1
Call e04dgf/​e04dga(n,objfun,iter,objf,objgrd,x,iwork,work,iuser,ruser,ifail)```

#### New Code

```!     .. Use Statements ..
Use, Intrinsic                   :: iso_c_binding, Only: c_null_ptr, c_ptr

!     ...

!     Initialize problem with n variables
ifail = 0
Call e04raf(handle,n,ifail)

!     Add nonlinear objective function with dense gradient
!     (dependent on all variables)
ifail = 0
Call e04rgf(handle,n,(/(j,j=1,n)/),ifail)

!     Solve the problem
cpuser = c_null_ptr
ifail = -1
Call e04kff(handle,objfun,objgrd,e04kfu,n,x,rinfo,stats,iuser,ruser,     &
cpuser,ifail)

iter = stats(8)
objf = rinfo(1)

!     Free the handle memory
ifail = 0
Call e04rzf(handle,ifail)```

### e04djf/​e04dja

Deprecated.
There is no replacement for this routine.

### e04dkf/​e04dka

Deprecated.
There is no replacement for this routine.

### e04jcf

Deprecated.
Replaced by e04jdf and e04jef.
e04jdf and e04jef are a part of the new NAG optimization modelling suite (see Section 3.1 in the E04 Chapter Introduction) which allows you to define and solve various problems in a uniform manner. They also offer various algorithmic additions, such as a performance improvement on noisy problems, a possibility to progress towards the solution earlier than after $n$ initial function evaluations, heuristic stopping criteria, recovery from unavailable function evaluations, and various other algorithmic updates and tuning. In addition, e04jef offers a reverse communication interface (see Section 3.2 in the E04 Chapter Introduction) which might be useful in some environments or if you can parallelize your function evaluations.
Callbacks
The callback functions are almost identical but the new one has added cpuser argument and the order of arguments is slightly different.

#### Old Code

`Subroutine objfun(n,x,f,iuser,ruser,inform)`

#### New Code

`Subroutine objfun(n,x,f,inform,iuser,ruser,cpuser)`
Main Call

#### Old Code

```ifail = -1
Call e04jcf(objfun,n,npt,x,bl,bu,rhobeg,rhoend,e04jcp,maxcal,f,nf,iuser, &
ruser,ifail)```

#### New Code

```!     .. Use Statements ..
Use, Intrinsic                   :: iso_c_binding, Only: c_null_ptr, c_ptr

!     ...

!     Initialize problem with n variables
ifail = 0
Call e04raf(handle,n,ifail)

!     Add nonlinear objective function which depends on all variables
ifail = 0
Call e04rgf(handle,n,(/(j,j=1,n)/),ifail)

!     Add bounds for the variables
Call e04rhf(handle,n,bl,bu,ifail)

!     Pass npt, rhobeg, rhoend, maxcal as options if different from defaults
ifail = 0
Call e04zmf(handle,'DFO Number Interp Points = <your npt>',ifail)
Call e04zmf(handle,'DFO Starting Trust Region = <your rhobeg>',ifail)
Call e04zmf(handle,'DFO Trust Region Tolerance = <your rhoend>',ifail)
Call e04zmf(handle,'DFO Max Objective Calls = <your maxcal>',ifail)

!     Solve the problem
cpuser = c_null_ptr
ifail = -1
Call e04jdf(handle,objfun,e04jdu,n,x,rinfo,stats,iuser,ruser,cpuser,ifail)

!     retrieve the objective value and the total number of calls made to the
!     objective function
f = rinfo(1)
nf = stats(1)

!     Free the handle memory
ifail = 0
Call e04rzf(handle,ifail)```

### e04mzf

Deprecated.
Replaced by e04mxf.

#### Old Code

```mpslst = .False.    ! Or = .True.
Call e04mzf(infile,maxn,maxm,maxnnz,xbldef,xbudef,mpslst,n,m,nnz,iobj,   &
ncolh,a,irowa,iccola,bl,bu,start,pnames,nname,crname,xs,     &
istate,ifail)

if (ifail == 1 .Or. ifail == 2 .Or. ifail == 3) then
! not enough memory, allocate bigger arrays as given in m, n, nnz
! and call e04mzf again
else if (ifail >= 4 .And. ifail <= 16) then
! mps input file formating error
! stop
else if (ifail == 17) then
! wrong arguments to e04mzf
! stop
else if (ifail == 0) then
! data successfully read, call solver
end if```

#### New Code

```mpslst = 0      ! or = 1
Call e04mxf(infile,maxn,maxm,maxnnz,maxncolh,maxnnzh,maxlintvar,mpslst,  &
n,m,nnz,ncolh,nnzh,lintvar,iobj,a,irowa,iccola,bl,bu,pnames, &
nname,crname,h,irowh,iccolh,minmax,intvar,ifail)

if (ifail == 2) then
! not enough memory, allocate bigger arrays as given in m, n, nnz, ncolh,
! nnzh, lintvar and call e04mxf again
else if (ifail >= 3 .And. ifail <= 35) then
! MPS input file formatting error
! stop
else if (ifail == 36) then
! wrong input argument
! stop
else if (ifail=-999) then
! internal memory allocation error
! stop
else if (ifail == 0 .Or. ifail == 1) then
! data successfully read (with possible warning)
start = 'C'
do j=1,n
xs(j) = min(max(0.0_nag_wp,bl(j)),bu(j))
istate(j) = 0.0_nag_wp
end do
! call solver
end if```
e04mxf has extended the functionality of e04mzf and the interface has changed substantially. If there are Integer variables, a quadratic part of the objective function or OBJSENSE section (see Section 3.1 in e04mxf), e04mxf will read them and return them in the new arguments (lintvar, intvar, ncolh, nnzh, h, irowh, iccolh and minmax), with e04mzf these caused a file formatting error. The new routine e04mxf might also accept a slightly misformatted input file and return a warning ${\mathbf{ifail}}={\mathbf{1}}$.
The type of the argument mpslst has changed from logical to integer.
The parameters xbldef and xbudef of e04mzf were removed and fixed in e04mxf to their default values $0$ and ${10}^{20}$, respectively. Note that value ${10}^{20}$ within bounds is interpreted in our solvers as $+\infty$ (unconstrained).
Parameters start, xs and istate were present in e04mzf only for the convenience of calling the solver routine e04nkf/​e04nka and have been removed from e04mxf.
Should you need any assistance, please do not hesitate to contact the NAG Technical Support Service .

### e04unf

Withdrawn at Mark 22.
Replaced by e04usf/​e04usa.

#### Old Code

```Call e04unf(m,n,nclin,ncnln,lda,ldcj,ldfj,     &
ldr,a,bl,bu,y,confun,objfun,iter,  &
istate,c,cjac,f,fjac,clamda,objf,  &
r,x,iwork,liwork,work,lwork,iuser, &
ruser,ifail)```

#### New Code

```Call e04usf/​e04usa(m,n,nclin,ncnln,lda,ldcj,ldfj,     &
ldr,a,bl,bu,y,confun,objfun,iter,  &
istate,c,cjac,f,fjac,clamda,objf,  &
r,x,iwork,liwork,work,lwork,iuser, &
ruser,ifail)```
The specification of the subroutine objfun must also be changed as follows:

#### Old Code

```Subroutine         objfun(mode,m,n,ldfj,x,f,fjac,nstate,iuser,ruser)
Integer            mode,m,n,ldfj,nstate,iuser(*)
Real (Kind=nag_wp) x(n),f(*),fjac(ldfj,*),ruser(*)```

#### New Code

```Subroutine         objfun(mode,m,n,ldfj,needfi,x,f,fjac,nstate,      &
iuser,ruser)
Integer            mode,m,n,ldfj,needfi,nstate,iuser(*)
Real (Kind=nag_wp) x(n),f(*),fjac(ldfj,*),ruser(*)```
See the routine documents for further information.

### e04zcf/​e04zca

Withdrawn at Mark 24.
There is no replacement for this routine.

## F02 – Eigenvalues and Eigenvectors

### f02bjf

Withdrawn at Mark 23.
Replaced by f08wcf.

#### Old Code

`Call f02bjf(n,a,lda,b,ldb,eps1,alfr,alfi,beta,matv,v,ldv,iter,ifail)`

#### New Code

```If (matv) Then
jobvr = 'V'
Else
jobvr = 'N'
EndIF
Call dggev('N',jobvr,n,a,lda,b,ldb,alfr,alfi,beta,vl,ldvl,           &
vr,ldvl,work,lwork,info)
If (info == 0) Then
...```

### f02eaf

Withdrawn at Mark 23.
Replaced by f08paf.

#### Old Code

`Call f02eaf(job,n,a,lda,wr,wi,z,ldz,work,lwork,ifail)`

#### New Code

```Logical select
External select
...
If (job == 'N') Then
jobvs = 'N'
Else
jobvs = 'V'
End If
Call dgees(jobvs,'N',select,n,a,lda,0,wr,wi,z,ldz,work, &
lwork,bwork,info)
If (info == 0) Then
....
Logical Function select(ar,ai)
Real (Kind=nag_wp) :: ar, ai
select = .True.
Return
End```

### f02ebf

Withdrawn at Mark 23.
Replaced by f08naf.

#### Old Code

```Call f02ebf(job,n,a,lda,wr,wi,vr,ldvr,vi,ldvi,work,lwork, &
ifail)```

#### New Code

```If (job == 'N') Then
jobvr = 'N'
Else
jobvr = 'V'
End If
Call dgeev('N',jobvr,n,a,lda,wr,wi,vl,ldvl,vr1,ldvr1,     &
work,lwork,info)
If (info == 0) Then
!       Eigenvector information is stored differently.
!       For complex conjugate pairs (that is, corresponding
!       to the j-th eigenvector such that wi(j) is nonzero,
!       and wi(j) = -wi(j+1)), the real and imaginary parts
!       of the first of the pair of eigenvectors are stored
!       as consecutive columns of vr1: vr1(:,j), vr1(:,j+1).
!       The second in the pair is just the conjugate of the
!       first, so can be constructed by negating the
!       elements in vr1(:,j+1).
!       If the j-th eigenvector is real (wi(j)=0), the
!       corresponding real eigenvector is stored in the
!       j-th column of vr1, vr1(1:n,j).```

### f02faf

Withdrawn at Mark 23.
Replaced by f08faf.

#### Old Code

`Call f02faf(job,uplo,n,a,lda,w,work,lwork,ifail)`

#### New Code

```Call dsyev(job,uplo,n,a,lda,w,work,lwork,info)
If (info == 0) Then
...```
The minimum workspace requirement has not increased but the requirement for optimal performance might be different. The workspace query mechanism (${\mathbf{lwork}}=-1$) should be used to determine the requirement for optimal performance.

### f02fcf

Withdrawn at Mark 23.
Replaced by f08fbf.

#### Old Code

```Call f02fcf(job,range,uplo,n,a,lda,wl,wu,il,iu,mest,m,   &
w,z,ldz,work,lwork,iwork,ifail)```

#### New Code

```Call dsyevx(job,range,uplo,n,a,lda,wl,wu,il,iu,abstol,m, &
w,z,ldz,work,lwork,iwork,jfail,info)
If (info == 0) Then
...```
The minimum workspace requirement has not increased but the requirement for optimal performance might be different. The workspace query mechanism (${\mathbf{lwork}}=-1$) should be used to determine the requirement for optimal performance.

### f02fdf

Withdrawn at Mark 23.
Replaced by f08saf.

#### Old Code

`Call f02fdf(itype,job,uplo,n,a,lda,b,ldb,w,work,lwork,ifail)`

#### New Code

```Call dsygv(itype,job,uplo,n,a,lda,b,ldb,w,work,lwork,info)
If (info == 0) Then
...```
The minimum workspace requirement has not increased but the requirement for optimal performance might be different. The workspace query mechanism (${\mathbf{lwork}}=-1$) should be used to determine the requirement for optimal performance.

### f02fhf

Withdrawn at Mark 23.
Replaced by f08uaf.

#### Old Code

` Call f02fhf(n,ma,a,lda,mb,b,ldb,d,work,lwork,ifail)`

#### New Code

``` Call dsbgv('N','U',n,ma,mb,a,lda,b,ldb,d,z,ldz,work,info)
If (info == 0) Then
...```
The order of eigenvalues in D changes from descending to ascending.
The minimum workspace requirement has changed to become $\mathtt{LWORK}=3×{\mathbf{n}}$

### f02gaf

Withdrawn at Mark 23.
Replaced by f08pnf.

#### Old Code

`Call f02gaf(job,n,a,lda,w,z,ldz,rwork,work,lwork,ifail)`

#### New Code

```Logical bwork(1)
Logical select
External select
...
If (job == 'N') Then
jobvs = 'N'
Else
jobvs = 'V'
End If
Call zgees(jobvs,'N',select,n,a,lda,0,w,z,ldz,          &
work,lwork,rwork,bwork,info)
if (info /= 0) Then
...
Logical Function select(c)
Complex*16 c
select = .True.
Return
End```
The minimum workspace requirement has not increased but the requirement for optimal performance might be different. The workspace query mechanism (${\mathbf{lwork}}=-1$) should be used to determine the requirement for optimal performance.

### f02gbf

Withdrawn at Mark 23.
Replaced by f08nnf.

#### Old Code

`Call f02gbf(job,n,a,lda,w,v,ldv,rwork,work,lwork,ifail)`

#### New Code

```Call zgeev('N',job,n,a,lda,w,vl,ldvl,v,ldv,             &
work,lwork,rwork,info)
If (info == 0) Then
...```

### f02gjf

Withdrawn at Mark 23.
Replaced by f08wqf.

#### Old Code

```Call f02gjf(n,ar,ldar,ai,ldai,br,ldbr,bi,ldbi,eps1,alfr,  &
alfi,beta,matv,vr,ldvr,vi,ldvi,iter,ifail)```

#### New Code

```If (matv) Then
jobvr = 'V'
Else
jobvr = 'N'
End If

!     Set A=AR + iAI and B = BR+iBI

Call zggev('N',jobvr,n,a,lda,b,ldb,alpha,beta1,vl,ldvl,   &
v,ldv,work,lwork,rwork,info)
If (info == 0) Then
...```
Note that the separated real and imaginary parts of input and output data in f02gjf has been replaced by combined complex types in f08wnf.

### f02haf

Withdrawn at Mark 23.
Replaced by f08fnf.

#### Old Code

`Call f02haf(job,uplo,n,a,lda,w,rwork,work,lwork,ifail)`

#### New Code

```Call zheev(job,uplo,n,a,lda,w,work,lwork,rwork,info)
If (info == 0) Then
...```
The minimum workspace requirement has not increased but the requirement for optimal performance might be different. The workspace query mechanism (${\mathbf{lwork}}=-1$) should be used to determine the requirement for optimal performance.

### f02hcf

Withdrawn at Mark 23.
Replaced by f08fpf.

#### Old Code

```Call f02hcf(job,range,uplo,n,a,lda,wl,wu,il,iu,mest,m,   &
w,z,ldz,work,lwork,rwork,iwork,ifail)```

#### New Code

```Call zheevx(job,range,uplo,n,a,lda,wl,wu,il,iu,abstol,m, &
w,z,ldz,work,lwork,rwork,iwork,jfail,info)
If (info == 0) Then
...```
The minimum workspace requirement has not increased but the requirement for optimal performance might be different. The workspace query mechanism (${\mathbf{lwork}}=-1$) should be used to determine the requirement for optimal performance.

### f02hdf

Withdrawn at Mark 23.
Replaced by f08snf.

#### Old Code

```Call f02hdf(itype,job,uplo,n,a,lda,b,ldb,w,rwork,work, &
lwork,ifail)```

#### New Code

```Call zhegv(itype,job,uplo,n,a,lda,b,ldb,w,work,lwork,  &
rwork,info)
If (info == 0) Then
...```
The minimum workspace requirement has not increased but the requirement for optimal performance might be different. The workspace query mechanism (${\mathbf{lwork}}=-1$) should be used to determine the requirement for optimal performance.

### f02sdf

Withdrawn at Mark 27.
Replaced by f12agf and f12fgf.
The replacement routines f12fgf (symmetric case) and f12agf (nonsymmetric case) are threaded for parallel execution in multithreaded implementations. These routines are based on the ARPACK package and make calls to BLAS/LAPACK routines. These may be threaded within the vendor library used by the implementation, which provides an additional opportunity for multithreaded performance.

#### Old Code

```Call f02sdf(n,ma+1,mb+1,a,lda,b,ldb,sym,relep,rmu,vec,d,iwork,work, &
lwork,ifail)```

#### New Code

```licomm = 140
lcomm = 3*n + 3*ncv*ncv + 6*ncv + 60
Allocate (comm(lcomm),dr(ncv),di(ncv),resid(n),v(n,ncv), &
icomm(licomm))
!   B is symmetric definite:
If (B_symm_def) Then
Call f12aff(n,1,ncv,icomm,licomm,comm,lcomm,ifail)
Call f12adf('Generalized',icomm,comm,ifail)
Call f12adf('Shifted Inverse',icomm,comm,ifail)
Call f12agf(kl,ku,a,lda,b,ldb,rmu,0.0,nconv,dr,di,v,n,resid, &
v,ldv,comm,icomm,ifail)
vec(1:n) = v(1:n,1)
Else
Call f12aaf(n,nev,ncv,icomm,licomm,comm,lcomm,ifail)
Allocate(c(lda,n),ipiv(n),x(n),mx(n))
c = a - rmu*b
Call dgbtrf(n,n,kl,ku,c,lda,ipiv,info)
irevcm = 0
Do While (irevcm/=5)
Call f12abf(irevcm,resid,v,ldv,x,mx,nshift,comm,icomm,ifail)
If (irevcm == -1 .Or. irevcm == 1) Then
!     Perform  x <--- OP*x = inv[a-sigma*b]*bx.
Call dgbmv('N',n,n,kl,ku,one,b,ldb,x,1,zero,mx,1)
x(1:n) = mx(1:n)
Call dgbtrs('N',n,kl,ku,1,c,lda,ipiv,x,n,info)
End If
End Do
! Post-process using f12acf to compute eigenvalue.
Call f12acf(nconv,dr,di,v,ldv,rmu,0.0,resid,v,n,comm,icomm,ifail)
lr = dr(1)/(dr(1)**2+di(1)**2) + rmu
End If```

### f02wdf

Withdrawn at Mark 27.
Replaced by f02wuf and f08aef.
This routine is replaced for multithreaded performance and the ability to benefit from vendor library performance (BLAS/LAPACK).
Note: only the multithreaded implementations of f02wdf were able to benefit from parallelism or vendor BLAS/LAPACK performance.
The Householder $QU$ factorization part of the functionality can be achieved with f08aef. The action ${Q}^{\mathrm{T}}b$ can be computed by a call to f08agf. The orthogonal matrix $Q$ can be explicitly constructed, in-place, by a subsequent call to f08aff.
If the singular value decomposition (SVD) of $U$ is required, the result of f08aef must be fed to f02wuf, remembering that the first orthogonal matrix of the SVD is called $Q$ in f02wuf and $R$ in f02wdf

#### Old Code

```ifail = 0
Call f02wdf(m,n,a,lda,wantb,b,tol,svd,irank,z,sv,wantr,r, &
ldr,wantpt,pt,ldpt,work,lwork,ifail)```

#### New Code

```lwork = -1
Call dgeqrf(m,n,a,lda,z,work,lwork,info)
lwork = anint(work(1))
Deallocate (work)
Allocate (work(lwork))
Call dgeqrf(m,n,a,lda,z,work,lwork,info)
ncolb = 1
If (wantb) Then
Call dormqr('L','T',m,ncolb,n,a,lda,z,b,m,work,lwork,info)
End If
If (.Not. svd) Then
! construct Q explicitly, overwrites A
Call dorgqr(m,m,a,lda,z,work,lwork,info)
Else
! SVD factorization, PT overwrites A
Deallocate (work)
Allocate (work(5*n))
Call f02wuf(n,a,lda,ncolb,b,m,wantr,r,ldr,sv,wantpt,work,ifail)
! compute rank
irank = f06klf(n,sv,1,tol)
End If```

### f02wef

Withdrawn at Mark 23.
Replaced by f08kbf.

#### Old Code

```Call f02wef(m,n,a,lda,ncolb,b,ldb,wantq,q,ldq,sv,wantp,       &
pt,ldpt,work,ifail)```

#### New Code

```If (wantq) Then
jobu = 'A'
Else
jobu = 'N'
End If
If (wantp) Then
jobvt = 'A'
Else
jobvt = 'N'
End If
lwork = -1
Call dgesvd(jobu,jobvt,m,n,a,lda,sv,q,ldq,pt,ldpt,work,lwork,info)
lwork = anint(work(1))
Allocate (w(lwork))

Call dgesvd(jobu,jobvt,m,n,a,lda,sv,q,ldq,pt,ldpt,w,lwork,info)

Deallocate (w)```
work must be a one-dimensional real array of length at least lwork given by: $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,3×\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right)+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right),5×\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right)\right)$
Larger values of lwork, up to some optimal value, may improve performance.
Please note that the facility to return ${Q}^{\mathrm{T}}B$ is not provided so arguments $\mathbf{wantb}$ and $\mathbf{b}$ are not required. Instead, f08kbf has an option to return the entire ${\mathbf{m}}×{\mathbf{m}}$ orthogonal matrix $Q$, referred to as ${\mathbf{u}}$ in its documentation, through its 8th argument.

### f02xef

Withdrawn at Mark 23.
Replaced by f08kpf.

#### Old Code

```Call f02xef(m,n,a,lda,ncolb,b,ldb,wantq,q,ldq,sv,wantp,        &
ph,ldph,rwork,cwork,ifail)```

#### New Code

```If (wantq) Then
jobu = 'A'
Else
jobu = 'N'
End If
If (wantp) Then
jobvt = 'A'
Else
jobvt = 'N'
End If
lwork = -1
Call zgesvd(jobu,jobvt,m,n,a,lda,sv,q,ldq,pt,ldpt,work,        &
lwork,rwork,info)
lwork = anint(work(1))
Allocate (w(lwork))

Call zgesvd(jobu,jobvt,m,n,a,lda,sv,q,ldq,pt,ldpt,w,           &
lwork,rwork,info)

Deallocate (w)```
work must be a one-dimensional complex array of length at least lwork given by $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,2×\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right)+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right)\right)$
work must be a one-dimensional real array of length $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,5×\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right)\right)$.
Larger values of lwork, up to some optimal value, may improve performance.
Please note that the facility to return ${Q}^{\mathrm{H}}B$ is not provided so arguments wantb and $\mathbf{b}$ are not required. Instead, f08kpf has an option to return the entire ${\mathbf{m}}*{\mathbf{m}}$ unitary matrix $Q$, referred to as ${\mathbf{u}}$ in its documentation, through its 8th argument.

## F03 – Determinants

### f03aaf

Withdrawn at Mark 25.
Replaced by f07adf and f03baf.

#### Old Code

```ifail = 0
Call f03aaf(a,lda,n,det,wkspce,ifail)```

#### New Code

```Integer ipiv(n)
...

Call dgetrf(n,n,a,lda,ipiv,info)
ifail = 0
Call f03baf(n,a,lda,ipiv,d,id,ifail)
det = d*2**id```
Note: the real array wkspce has been replaced by the integer array ipiv for holding the pivots of the factorization.

### f03abf

Withdrawn at Mark 25.
Replaced by f07fdf and f03bff.

#### Old Code

```ifail = 0
Call f03abf(a,lda,n,det,wkspce,ifail)```

#### New Code

```Call dpotrf('U',n,a,lda,info)
ifail = 0
Call f03bff(n,a,lda,d,id,ifail)
det = d*2**id```
Note: the real array wkspce is no longer required. Also the upper triangular part of $A$, stored in a, has been replaced here by its Cholesky factorization; the lower triangular part of $A$ can be used and overwritten by replacing 'U' by 'L' in the call to dpotrf above.

### f03acf

Withdrawn at Mark 25.
Replaced by f07hdf and f03bhf.

#### Old Code

```ifail = 0
Call f03acf(a,lda,n,m,det,rl,ldrl,m1,ifail)```

#### New Code

```Call dpbtrf('L',n,m,ab,ldab,info)
ifail = 0
Call f03bhf('L',n,kd,ab,ldab,d,id,ifail)
det = d*2**id```
Note: the storage of $A$ in arrays a and ab is different. In fact ${\mathbf{ab}}\left(\mathit{i},\mathit{j}\right)=\mathbf{a}\left(\mathit{j},\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,m$ and $\mathit{j}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,i-m\right),\dots ,i$ which conforms to the LAPACK banded storage scheme. The factorization is returned in ab rather than in a separate array (rl). The upper part of matrix $A$ can also be stored in ab on input to dpbtrf.

### f03adf

Withdrawn at Mark 25.
Replaced by f07arf and f03bnf.

#### Old Code

```ifail = 0
Call f03adf(a,lda,n,detr,deti,wkspce,ifail)```

#### New Code

```Integer ipiv(n)
...
Call zgetrf(n,n,a,lda,ipiv,info)
ifail = 0
Call f03bnf(n,a,lda,ipiv,d,id,ifail)
detr = Real(d)*2**id(1)
deti = Aimag(d)*2**id(2)```
Note: the real array wkspce has been replaced by the integer array ipiv for holding the pivots of the factorization. The real and imaginary parts of the determinant are independently scaled.

### f03aef

Withdrawn at Mark 25.
Replaced by f07fdf and f03bff.

#### Old Code

```ifail = 0
Call f03aef(n,a,lda,p,d1,id,ifail)```

#### New Code

```Call dpotrf('U',n,a,lda,info)
ifail = 0
Call f03bff(n,a,lda,d1,id,ifail)```
Note: the upper triangular part of $A$, stored in a, has been replaced here by its Cholesky factorization; the lower triangular part of $A$ can be used and overwritten by replacing ${\mathbf{uplo}}=\text{'U'}$ by ${\mathbf{uplo}}=\text{'L'}$ in the call to f07fdf above.

### f03aff

Withdrawn at Mark 25.
Replaced by f07adf and f03baf.

#### Old Code

```ifail = 0
Call f03aff(n,eps,a,lda,d1,id,p,ifail)```

#### New Code

```Integer ipiv(n)
...
Call dgetrf(n,n,a,lda,ipiv,info)
ifail = 0
Call f03baf(n,a,lda,ipiv,d1,id,ifail)```
Note: real array p has been replaced by the integer array ipiv for holding the pivots of the factorization.

## F04 – Simultaneous Linear Equations

### f04aaf

Withdrawn at Mark 23.
Replaced by f07aaf.

#### Old Code

`Call f04aaf(a,lda,b,ldb,n,m,c,ldc,wkspce,ifail)`

#### New Code

```Call dgesv(n,m,a,lda,ipiv,b,ldb,info)
If (info == 0) Then
!       Answer now in b
...```

### f04abf

Scheduled for withdrawal at Mark 28.
Replaced by f07fbf.
This routine has been replaced by f07fbf for performance. The replacement routine is threaded by NAG and may also be threaded in the vendor library (BLAS/LAPACK).

#### Old Code

`Call f04abf(a,lda,b,ldb,n,m,c,ldc,wkspce,bb,ldbb,ifail)`

#### New Code

```Call f04abf_wrap(a,lda,b,ldb,n,m,c,ldc,wkspce,bb,ldbb,ifail)

Subroutine f04abf_wrap(a,lda,b,ldb,n,m,c,ldc,wkspce,bb,ldbb,ifail)
!     .. Use Statements ..
Use nag_library, Only: dposvx, dsymm, nag_wp
!     .. Scalar Arguments ..
Integer, Intent (In)             :: lda, ldb, ldbb, ldc, m, n
Integer, Intent (Inout)          :: ifail
!     .. Array Arguments ..
Real (Kind=nag_wp), Intent (Inout) :: a(lda,*), b(ldb,*)
Real (Kind=nag_wp), Intent (Out)   :: bb(ldbb,m), c(ldc,m), wkspce(1)
!     .. Local Scalars ..
Real (Kind=nag_wp)               :: rcond, alpha, beta
Integer                          :: info, ldaf
Character (1)                    :: equed
!     .. Local Arrays ..
Real (Kind=nag_wp)               :: s(1)
Real (Kind=nag_wp), Allocatable  :: af(:,:), work(:), ferr(:), berr(:)
Integer, Allocatable             :: iwork(:)

ldaf = n
Allocate (af(ldaf,n),ferr(m),berr(m),work(3*n),iwork(n))
!     The NAG name equivalent of dposvx is f07fbf
Call dposvx('N','Upper',n,m,a,lda,af,ldaf,equed,s,b,ldb,  &
c,ldc,rcond,ferr,berr,work,iwork,info)

ifail = info
bb(1:n,1:m) = b(1:n,1:m)
alpha = -1.0_nag_wp
beta = 1.0_nag_wp
!     The NAG name equivalent of dsymm is f06ycf
Call dsymm('L','U',n,m,alpha,a,lda,c,ldc,beta,bb,ldbb)

End Subroutine f04abf_wrap```

### f04acf

Withdrawn at Mark 23.
Replaced by f07haf.

#### Old Code

`Call f04acf(a,lda,b,ldb,n,m,ir,c,ldc,rl,ldrl,m1,ifail)`

#### New Code

```Call dpbsv('U',n,m,ir,ab,ldab,b,ldb,info)
If (info == 0) Then
!        a and ab are stored differently.
!        ab may be regarded as the transpose of a, with the 'U' option.
!        Thus ldab might be m+1
!        Answer now in b
...```

### f04adf

Withdrawn at Mark 23.
Replaced by f07anf.

#### Old Code

`Call f04adf(a,lda,b,ldb,n,m,c,ldc,wkspce,ifail)`

#### New Code

```Call zgesv(n,m,a,lda,ipiv,b,ldb,info)
If (info == 0) Then
!        Answer now in b
...```

### f04aef

Scheduled for withdrawal at Mark 28.
Replaced by f07abf.
This routine has been replaced by f07abf for performance. The replacement routine is threaded by NAG and may also be threaded in the vendor library (BLAS/LAPACK).

#### Old Code

`Call f04aef(a,lda,b,ldb,n,m,c,ldc,wkspce,aa,ldaa,bb,ldbb,ifail)`

#### New Code

```Call f04aef_wrap(a,lda,b,ldb,n,m,c,ldc,wkspce,aa,ldaa,bb,ldbb,ifail)

Subroutine f04aef_wrap(a,lda,b,ldb,n,m,c,ldc,wkspce,aa,ldaa,bb,ldbb,ifail)
!     .. Use Statements ..
Use nag_library, Only: dgesvx, dgemm, nag_wp
!     .. Scalar Arguments ..
Integer, Intent (In)             :: lda, ldaa, ldb, ldbb, ldc, m, n
Integer, Intent (Inout)          :: ifail
!     .. Array Arguments ..
Real (Kind=nag_wp), Intent (Inout) :: a(lda,*), b(ldb,*)
Real (Kind=nag_wp), Intent (Out)   :: bb(ldbb,m), c(ldc,m), aa(ldaa,n), &
wkspce(1)
!     .. Local Scalars ..
Real (Kind=nag_wp)               :: rcond, alpha, beta
Integer                          :: info
Character (1)                    :: equed
!     .. Local Arrays ..
Real (Kind=nag_wp)               :: cscl(1), rscl(1)
Real (Kind=nag_wp), Allocatable  :: work(:), ferr(:), berr(:)
Integer, Allocatable             :: ipiv(:), iwork(:)

Allocate (berr(m),ferr(m),work(4*n),ipiv(n),iwork(n))
!     The NAG name equivalent of dgesvx is f07abf
Call dgesvx('N','N',n,m,a,lda,aa,ldaa,ipiv,equed,rscl,cscl,b,ldb, &
c,ldc,rcond,ferr,berr,work,iwork,info)

ifail = info
bb(1:n,1:m) = b(1:n,1:m)
alpha = -1.0_nag_wp
beta = 1.0_nag_wp
!     The NAG name equivalent of dgemm is f06yaf
Call dgemm('N','N',n,m,n,alpha,a,lda,c,ldc,beta,bb,ldbb)

End Subroutine f04aef_wrap```

### f04aff

Withdrawn at Mark 25.
There is no replacement for this routine.
The factorization and solution of a positive definite linear system can be handled by calls to routines from Chapter F07, e.g., f07fbf.
For example:

#### Old Code

```ifail = 0
Call f03aef(n,a,lda,p,d1,id,ifail)
Call f04aff(n,nrhs,a,lda,p,b,ldb,eps,x,ldx,bb,ldbb,k,ifail)```

#### New Code

```Call dposvx('equil','upper',n,nrhs,a,lda,af,ldaf,'Yes',p,b, &
ldb,x,ldx,rcond,ferr,berr,work,iwork,info)
ifail = 0
Call f03bff(n,a,lda,d1,id,ifail)```

### f04agf

Withdrawn at Mark 25.
There is no replacement for this routine.
The factorization and solution of a positive definite linear system can be handled by calls to routines from Chapter F07, e.g., f07faf.
For example:

#### Old Code

```ifail = 0
Call f03aef(n,a,lda,p,d1,id,ifail)
Call f04agf(n,nrhs,a,lda,p,b,ldb,x,ldx)```

#### New Code

```Call dposv('upper',n,nrhs,a,lda,b,ldb,info)
ifail = 0
Call f03bff(n,a,lda,d1,id,ifail)```

### f04ahf

Withdrawn at Mark 25.
There is no replacement for this routine.
The factorization and solution of a real general linear system can be handled by calls to routines from the Chapter F07, e.g., f07abf.
For example:

#### Old Code

```ifail = 0
Call f03aff(n,eps,a,lda,d1,id,p,ifail)
Call f04ahf(n,nrhs,a,lda,aa,ldaa,p,b,ldb,eps,x,ldx,bb,    &
ldbb,k,ifail)```

#### New Code

```Call dgesvx('Equil','No trans',n,nrhs,a,lda,aa,ldaa,ipiv, &
'Yes',r,c,b,ldb,x,ldx,rcond,ferr,berr,work,   &
iwork,info)
ifail = 0
Call f03baf(n,a,lda,ipiv,d1,id,ifail)```

### f04ajf

Withdrawn at Mark 25.
There is no replacement for this routine.
The factorization and solution of a real general linear system can be handled by calls to routines from Chapter F07, e.g., f07aaf.
For example:

#### Old Code

```ifail = 0
Call f03aff(n,eps,a,lda,d1,id,p,ifail)
Call f04ajf(n,nrhs,a,lda,p,b,ldb)```

#### New Code

```Call dgesv(n,nrhs,a,lda,ipiv,b,ldb,info)
ifail = 0
Call f03baf(n,a,lda,ipiv,d1,id,ifail)```

### f04arf

Withdrawn at Mark 23.
Replaced by f07aaf.

#### Old Code

`Call f04arf(a,lda,b,n,c,wkspce,ifail)`

#### New Code

```Call dgesv(n,1,a,lda,ipiv,b,n,info)
If (info == 0) Then
!        Answer now in b
...```

### f04asf

Scheduled for withdrawal at Mark 28.
Replaced by f07fbf.
This routine has been replaced by f07fbf for performance. The replacement routine is threaded by NAG and may also be threaded in the vendor library (BLAS/LAPACK).

#### Old Code

`Call f04asf(a,lda,b,n,c,wk1,wk2,ifail)`

#### New Code

```Call f04asf_wrap(a,lda,b,n,c,wk1,wk2,ifail)

Subroutine f04asf_wrap(a,lda,b,n,c,wk1,wk2,ifail)
!     .. Use Statements ..
Use nag_library, Only: dposvx, nag_wp
!     .. Scalar Arguments ..
Integer, Intent (In)             :: lda, n
Integer, Intent (Inout)          :: ifail
!     .. Array Arguments ..
Real (Kind=nag_wp), Intent (Inout) :: a(lda,n), b(n)
Real (Kind=nag_wp), Intent (Out) :: c(n), wk1(1), wk2(1)
!     .. Local Scalars ..
Real (Kind=nag_wp)               :: rcond
Integer                          :: info, ldaf, m
Character (1)                    :: equed
!     .. Local Arrays ..
Real (Kind=nag_wp)               :: s(1), ferr(1), berr(1)
Real (Kind=nag_wp), Allocatable  :: af(:,:), work(:)
Integer, Allocatable             :: iwork(:)

ldaf = n
m = 1
Allocate (af(ldaf,n),work(3*n),iwork(n))
!     The NAG name equivalent of dposvx is f07fbf
Call dposvx('N','Upper',n,m,a,lda,af,ldaf,equed,s,b,n,  &
c,n,rcond,ferr,berr,work,iwork,info)
wk1(1) = rcond
wk2(1) = berr(1)

ifail = info
End Subroutine f04asf_wrap```

### f04atf

Scheduled for withdrawal at Mark 28.
Replaced by f07abf.
This routine has been replaced by f07abf for performance. The replacement routine is threaded by NAG and may also be threaded in the vendor library (BLAS/LAPACK).

#### Old Code

`Call f04atf(a,lda,b,n,c,aa,ldaa,wks1,wks2,ifail)`

#### New Code

```Call f04atf_wrap(a,lda,b,n,c,aa,ldaa,wks1,wks2,ifail)

Subroutine f04atf_wrap(a,lda,b,n,c,aa,ldaa,wks1,wks2,ifail)
!     .. Use Statements ..
Use nag_library, Only: dgesvx, nag_wp
!     .. Scalar Arguments ..
Integer, Intent (In)             :: lda, ldaa, n
Integer, Intent (Inout)          :: ifail
!     .. Array Arguments ..
Real (Kind=nag_wp), Intent (Inout) :: a(lda,*), b(n)
Real (Kind=nag_wp), Intent (Out)   :: c(n), aa(ldaa,n), wks1(1), wks2(1)
!     .. Local Scalars ..
Real (Kind=nag_wp)               :: rcond
Integer                          :: info, m
Character (1)                    :: equed
!     .. Local Arrays ..
Real (Kind=nag_wp)               :: cscl(1), rscl(1), ferr(1), berr(1)
Real (Kind=nag_wp), Allocatable  :: work(:)
Integer, Allocatable             :: ipiv(:), iwork(:)

m = 1
Allocate (work(4*n),ipiv(n),iwork(n))
!     The NAG name equivalent of dgesvx is f07abf
Call dgesvx('N','N',n,m,a,lda,aa,ldaa,ipiv,equed,rscl,cscl,b,n, &
c,n,rcond,ferr,berr,work,iwork,info)

ifail = info
wks1(1) = rcond
wks2(1) = berr(1)

End Subroutine f04atf_wrap```

### f04eaf

Withdrawn at Mark 23.
Replaced by f07caf.

#### Old Code

`Call f04eaf(n,d,du,dl,b,ifail)`

#### New Code

```Call dgtsv(n,1,dl(2),d,du(2),b,n,info)
If (info == 0) Then
!        Answer now in b
...```

### f04faf

Withdrawn at Mark 23.
Replaced by f07jaf, or f07jdf and f07jef.

#### Old Code

`Call f04faf(job,n,d,e,b,ifail)`

#### New Code

```Call dptsv
...```

### f04jaf

Withdrawn at Mark 23.
Replaced by f08kaf.

#### Old Code

`Call f04jaf(m,n,a,lda,b,tol,sigma,irank,work,lwork,ifail)`

#### New Code

```Call dgelss(m,n,1,a,lda,b,1,s,rcond,irank,work,lwork,info)
If (info == 0) Then
!        Answer now in b
!        Singular values now in s, not work.
!        The standard error is not computed
...```
The minimum workspace requirement has changed from $4×{\mathbf{n}}$ to $3×\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{n}},{\mathbf{m}}\right)+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(2×\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{n}},{\mathbf{m}}\right),\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right),1\right)$.

### f04jdf

Withdrawn at Mark 23.
Replaced by f08kaf.

#### Old Code

`Call f04jdf(m,n,a,lda,b,tol,sigma,irank,work,lwork,ifail)`

#### New Code

```Call dgelss(m,n,1,a,lda,b,1,s,rcond,irank,work,lwork,info)
!     Note workspace requirements are different.
If (info == 0) Then
!        Answer now in b
!        Singular values now in s, not work.
!        The standard error is not computed
...```
The minimum workspace requirement has changed from $\mathbf{n}×\left(\mathbf{m}+4\right)$ to $3×\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{n}},{\mathbf{m}}\right)+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(2×\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{n}},{\mathbf{m}}\right),\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right),1\right)$.

### f04jlf

Withdrawn at Mark 23.
Replaced by f08zbf.

#### Old Code

`Call f04jlf(m,n,p,a,lda,b,ldb,d,x,y,work,lwork,ifail)`

#### New Code

```Call dggglm(m,n,p,a,lda,b,ldb,d,x,y,work,lwork,info)
If (info == 0) Then
...```
The minimum workspace requirement has not increased but the requirement for optimal performance might be different. The workspace query mechanism (${\mathbf{lwork}}=-1$) should be used to determine the requirement for optimal performance.

### f04jmf

Withdrawn at Mark 23.
Replaced by f08zaf.

#### Old Code

` Call f04jmf(m,n,p,a,lda,b,ldb,c,d,x,work,lwork,ifail)`

#### New Code

``` Call dgglse(m,n,p,a,lda,b,ldb,c,d,x,work,lwork,info)
If (info == 0) Then
...```
The minimum workspace requirement has not increased but the requirement for optimal performance might be different. The workspace query mechanism (${\mathbf{lwork}}=-1$) should be used to determine the requirement for optimal performance.

### f04klf

Withdrawn at Mark 23.
Replaced by f08zpf.

#### Old Code

`Call f04klf(m,n,p,a,lda,b,ldb,d,x,y,work,lwork,ifail)`

#### New Code

```Call zggglm(m,n,p,a,lda,b,ldb,d,x,y,work,lwork,info)
If (info == 0) Then
...```

### f04kmf

Withdrawn at Mark 23.
Replaced by f08znf.

#### Old Code

`Call f04kmf(m,n,p,a,lda,b,ldb,c,d,x,work,lwork,ifail)`

#### New Code

```Call zgglse(m,n,p,a,lda,b,ldb,c,d,x,work,lwork,info)
If (info == 0) Then
...```

### f04ycf

Withdrawn at Mark 26.
Replaced by f04ydf.
f04ydf employs a better algorithm (see Higham and Tisseur (2000)).

#### Old Code

`Call f04ycf(icase,n,x,estnrm,work,iwork,ifail)`

#### New Code

`Call f04ydf(irevcm,m,n,x,ldx,y,ldy,estnrm,t,seed,work,iwork,ifail)`
f04ydf returns an estimate of the $1$-norm of a rectangular $m×n$ matrix, whereas f04ycf only works with square matrices. The real array x, which was previously used to return matrix–vector products to f04ycf, has been replaced with two real arrays ${\mathbf{x}}\left({\mathbf{ldx}},*\right)$ and ${\mathbf{y}}\left({\mathbf{ldy}},*\right)$ which are used to return matrix-matrix products to f04ydf. Here, ${\mathbf{ldx}}\ge {\mathbf{n}}$, ${\mathbf{ldy}}\ge {\mathbf{m}}$ and the second dimensions of x and y are at least of size t, where you can choose argument t. The sizes of the workspace arrays work and iwork have been increased to ${\mathbf{m}}×{\mathbf{t}}$ and $2×{\mathbf{n}}+5×{\mathbf{t}}+20$ respectively. The integer seed provides a seed for the random number generator used by f04ydf. The integer icase has been replaced by irevcm, which can take the values $0$, $1$ or $2$. See the routine documentation for f04ydf further details about the reverse communication interface.

### f04zcf

Withdrawn at Mark 26.
Replaced by f04zdf.
f04zdf employs a better algorithm (see Higham and Tisseur (2000).

#### Old Code

`Call f04zcf(icase,n,x,estnrm,work,ifail)`

#### New Code

`Call f04zdf(irevcm,m,n,x,ldx,y,ldy,estnrm,t,seed,work,rwork,iwork,ifail)`
f04zdf returns an estimate of the $1$-norm of a rectangular $m×n$ matrix, whereas f04zcf only works with square matrices. The complex array x, which was previously used to return matrix–vector products to f04zcf, has been replaced with two complex arrays ${\mathbf{x}}\left({\mathbf{ldx}},*\right)$ and ${\mathbf{y}}\left({\mathbf{ldy}},*\right)$ which are used to return matrix-matrix products to f04zdf. Here, ${\mathbf{ldx}}\ge {\mathbf{n}}$, ${\mathbf{ldy}}\ge {\mathbf{m}}$ and the second dimensions of x and y are at least of size t, where you can choose the argument t. The sizes of the workspace arrays work and iwork have been increased to ${\mathbf{m}}×{\mathbf{t}}$ and $2×{\mathbf{n}}+5×{\mathbf{t}}+20$ respectively and there is an additional real workspace array rwork of size $2×{\mathbf{n}}$. The integer seed provides a seed for the random number generator used by f04zdf. The integer icase has been replaced by irevcm, which can take the values $0$, $1$ or $2$. See the routine documentation for f04zdf for further details about the reverse communication interface.

## F08 – Least Squares and Eigenvalue Problems (LAPACK)

For each of the deprecated routines listed below, e.g., f08bef, the replacement routine has one additional argument lwork, used to supply the length of the array argument work or to perform a workspace query by setting ${\mathbf{lwork}}=-1$. It is safest to perform a workspace query first using a dummy workspace array of length $1$ and then to allocate the array of length equal to the optimal value returned in the dummy workspace, e.g.:
```lwork = -1
Call dgeqp3(...,dumwrk,lwork,...)
lwork = nint(dumwrk(1))
Allocate (work(lwork))
Call dgeqp3(...,work,lwork,...)```

### f08bef

Deprecated.
Replaced by f08bff.

### f08bsf

Deprecated.
Replaced by f08btf.

### f08vaf

Deprecated.
Replaced by f08vcf.

### f08vef

Deprecated.
Replaced by f08vgf.

### f08vnf

Deprecated.
Replaced by f08vqf.

### f08vsf

Deprecated.
Replaced by f08vuf.

### f08waf

Deprecated.
Replaced by f08wcf.

### f08wef

Deprecated.
Replaced by f08wff.

### f08wnf

Deprecated.
Replaced by f08wqf.

### f08wsf

Deprecated.
Replaced by f08wtf.

### f08xaf

Deprecated.
Replaced by f08xcf.

### f08xnf

Deprecated.
Replaced by f08xqf.

## F11 – Large Scale Linear Systems

### f11baf

Withdrawn at Mark 21.
Replaced by f11bdf.

#### Old Code

```Call f11baf(method,precon,norm,weight,iterm,n,m,tol,maxitn, &
anorm,sigmax,monit,lwreq,ifail)```

#### New Code

```Call f11bdf(method,precon,norm,weight,iterm,n,m,tol,maxitn, &
anorm,sigmax,monit,work,lwork,lwreq,ifail)```
f11bdf contains two additional arguments as follows:
See the routine document for further information.

### f11bbf

Withdrawn at Mark 21.
Replaced by f11bef.

#### Old Code

`Call f11bbf(irevcm,u,v,work,lwork,ifail)`

#### New Code

`Call f11bef(irevcm,u,v,wgt,work,lwork,ifail)`
wgt must be a one-dimensional real array of length at least $n$ (the order of the matrix) if weights are to be used in the termination criterion, and $1$ otherwise. Note that the call to f11bef requires the weights to be supplied in ${\mathbf{wgt}}\left(1:n\right)$ rather than ${\mathbf{work}}\left(1:n\right)$. The minimum value of the argument lwork may also need to be changed.

### f11bcf

Withdrawn at Mark 21.
Replaced by f11bff.

#### Old Code

`Call f11bcf(itn,stplhs,stprhs,anorm,sigmax,ifail)`

#### New Code

`Call f11bff(itn,stplhs,stprhs,anorm,sigmax,work,lwork,ifail)`
f11bff contains two additional arguments as follows:
• ${\mathbf{work}}\left({\mathbf{lwork}}\right)$ – real array.
• lwork – integer.
See the routine document for further information.

### f11gaf

Withdrawn at Mark 22.
Replaced by f11gdf.

#### Old Code

```Call f11gaf(method,precon,sigcmp,norm,weight,iterm,n,tol,maxitn,    &
anorm,sigmax,sigtol,maxits,monit,lwreq,ifail)```

#### New Code

```Call f11gdf(method,precon,sigcmp,norm,weight,iterm,n,tol,maxitn,    &
anorm,sigmax,sigtol,maxits,monit,lwreq,work,lwork,ifail)```
f11gdf contains two additional arguments as follows:
• ${\mathbf{work}}\left({\mathbf{lwork}}\right)$ – real array.
• lwork – integer.
See the routine document for further information.

### f11gbf

Withdrawn at Mark 22.
Replaced by f11gef.

#### Old Code

`Call f11gbf(irevcm,u,v,work,lwork,ifail)`

#### New Code

`Call f11gef(irevcm,u,v,wgt,work,lwork,ifail)`
wgt must be a one-dimensional real array of length at least $n$ (the order of the matrix) if weights are to be used in the termination criterion, and $1$ otherwise. Note that the call to f11gef requires the weights to be supplied in ${\mathbf{wgt}}\left(1:n\right)$ rather than ${\mathbf{work}}\left(1:n\right)$. The minimum value of the argument lwork may also need to be changed.

### f11gcf

Withdrawn at Mark 22.
Replaced by f11gff.

#### Old Code

`Call f11gcf(itn,stplhs,stprhs,anorm,sigmax,its,sigerr,ifail)`

#### New Code

```Call f11gff(itn,stplhs,stprhs,anorm,sigmax,its,sigerr,       &
work,lwork,ifail)```
f11gff contains two additional arguments as follows:
• ${\mathbf{work}}\left({\mathbf{lwork}}\right)$ – real array.
• lwork – integer.
See the routine document for further information.

## G01 – Simple Calculations on Statistical Data

### g01aaf

Withdrawn at Mark 26.
Replaced by g01atf.
Withdrawn because on output, additional information was needed to allow large datasets to be processed in blocks and the results combined through a call to g01auf. This information is returned in rcomm.

#### Old Code

`Call g01aaf(n,x,iwt,wt,xmean,s2,s3,s4,xmin,xmax,wtsum,ifail)`

#### New Code

```pn = 0
Call g01atf(n,x,iwt,wt,pn,xmean,s2,s3,s4,xmin,xmax,rcomm,ifail)
iwt = pn
wtsum = rcomm(1)```

### g01agf

Withdrawn at Mark 27.
There is no replacement for this routine.

### g01ahf

Withdrawn at Mark 27.
There is no replacement for this routine.

### g01ajf

Withdrawn at Mark 27.
There is no replacement for this routine.
Frequency tables generated by g01aef provide equivalent information.

## G02 – Correlation and Regression Analysis

### g02jafg02jbfg02jcfg02jdfg02jef

Deprecated.
For each of the routines g02jaf, g02jbf, g02jcf, g02jdf and g02jef there is not a direct one-to-one replacement, rather they have been replaced with a new suite of routines. This new suite allows a linear mixed effects model to be specified using a modelling language; giving a more natural way of specifying the model, allowing interaction terms to be specified and means that it is no longer necessary to create dummy variables when the model contains categorical variables.
The new suite of routines consists of:
• g22ybf used to describe the dataset of interest. Calling this routine allows labels to be assign to variables, which can then be used when specifying the model.
• g22yaf multiple calls to this routine are used to specify the fixed and random part of the model. The model is specified using strings and a modelling language, for example the string: ${V}_{1}+{V}_{2}+{V}_{1}\dots {V}_{1}$ would specify a model with the main effects of variables ${V}_{1}$ and ${V}_{2}$ and the interaction term between them. The modelling language is explained in detail in Section 3 in g22yaf.
• g02jff pre-processes the dataset prior to calling the model fitting routine.
• g02jhf fits the model and returns the parameter estimates etc.
In addition to the routines listed above, the following can also be used:
• g02jgf combines information returned by multiple calls to g02jff. This is useful for large problems as it allows the dataset to be split up into smaller subsets of data, pre-processing each one separately before combining them into a single set of information as if g02jff had been called on the full dataset.
• g22ydf can be used to obtain labels for the parameter estimates returned by g02jhf.
• g22zmf can be used to set any optional arguments.
• g22znf can be used to return the value of any optional arguments.
By default, the model fitting routine, g02jhf, fits the linear mixed effects model using restricted maximum likelihood (REML). In order to fit the model using maximum likelihood (ML) you need to call the optional argument setting routine, g22zmf with optstr set to ${\mathbf{Likelihood}}=\mathrm{ML}$, between the call to g02jff and the call to g02jhf.

## G05 – Random Number Generators

### g05caf

Withdrawn at Mark 22.
Replaced by g05saf.

#### Old Code

```Do i = 1, n
x(i) = g05caf(x(i))
End Do```

#### New Code

`Call g05saf(n,state,x,ifail)`
The integer array state in the call to g05saf contains information on the base generator being used. This array must have been initialized prior to calling g05saf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05saf is likely to be different from those produced by g05caf.

### g05cbf

Withdrawn at Mark 22.
Replaced by g05kff.

#### Old Code

`Call g05cbf(i)`

#### New Code

```lseed = 1
seed(1) = i
genid = 1
subid = 1
Call g05kff(genid,subid,seed,lseed,state,lstate,ifail)```
The integer array state in the call to g05kff contains information on the base generator being used. The base generator is chosen via the integer arguments genid and subid. The required length of the array state depends on the base generator chosen. Due to changes in the underlying code a sequence of values produced by using a random number generator initialized via a call to g05kff is likely to be different from a sequence produced by a generator initialized by g05cbf, even if the same value for I is used.

### g05ccf

Withdrawn at Mark 22.
Replaced by g05kgf.

#### Old Code

`Call g05ccf`

#### New Code

```genid = 1
subid = 1
Call g05kgf(genid,subid,state,lstate,ifail)```
The integer array state in the call to g05kgf contains information on the base generator being used. The base generator is chosen via the integer arguments genid and subid. The required length of the array state depends on the base generator chosen.

### g05cff

Withdrawn at Mark 22.
Replaced by f06dff.

#### Old Code

`Call g05cff(ia,ni,xa,nx,ifail)`

#### New Code

```lstate = state(1)
Call f06dff(lstate,state,1,cstate,1)```
The state of the base generator for the group of routines g05kff, g05kgf, g05khf, g05kjf, g05ncf, g05ndf, g05pdfg05pzf, g05rcfg05rzf, g05s and g05t can be saved by simply creating a local copy of the array state. The first element of the state array contains the number of elements that are used by the random number generating routines, therefore either this number of elements can be copied, or the whole array (as defined in the calling program).

### g05cgf

Withdrawn at Mark 22.
Replaced by f06dff.

#### Old Code

`Call g05cgf(ia,ni,xa,nx,ifail)`

#### New Code

```lstate = cstate(1)
Call f06dff(lstate,cstate,1,state,1)```
The state of the base generator for the group of routines g05kff, g05kgf, g05khf, g05kjf, g05ncf, g05ndf, g05pdfg05pzf, g05rcfg05rzf, g05s and g05t can be restored by simply copying back the previously saved copy of the state array. The first element of the state array contains the number of elements that are used by the random number generating routines, therefore either this number of elements can be copied, or the whole array (as defined in the calling program).

### g05daf

Withdrawn at Mark 22.
Replaced by g05sqf.

#### Old Code

```Do i = 1, n
x(i) = g05daf(aa,bb)
End Do```

#### New Code

```a = min(aa,bb)
b = max(aa,bb)
ifail = 0
Call g05sqf(n,a,b,state,x,ifail)```
The old routine g05daf returns a single variate at a time, whereas the new routine g05sqf returns a vector of n values in one go. In g05sqf the minimum value must be held in the argument a and the maximum in argument b, therefore ${\mathbf{a}}<{\mathbf{b}}$. This was not the case for the equivalent arguments in g05daf.
The integer array state in the call to g05sqf contains information on the base generator being used. This array must have been initialized prior to calling g05sqf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05sqf is likely to be different from those produced by g05daf.

### g05dbf

Withdrawn at Mark 22.
Replaced by g05sff.

#### Old Code

```Do i = 1, n
x(i) = g05dbf(aa)
End Do```

#### New Code

```a = abs(aa)
ifail = 0
Call g05sff(n,a,state,x,ifail)```
The old routine g05dbf returns a single variate at a time, whereas the new routine g05sff returns a vector of n values in one go. In g05sff argument a must be non-negative, this was not the case for the equivalent argument in g05dbf.
The integer array state in the call to g05sff contains information on the base generator being used. This array must have been initialized prior to calling g05sff with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05sff is likely to be different from those produced by g05dbf.

### g05dcf

Withdrawn at Mark 22.
Replaced by g05slf.

#### Old Code

```Do i = 1, n
x(i) = g05dcf(a,bb)
End Do```

#### New Code

```b = abs(bb)
ifail = 0
Call g05slf(n,a,b,state,x,ifail)```
The old routine g05dcf returns a single variate at a time, whereas the new routine g05slf returns a vector of n values in one go. In g05slf the spread (argument a) must be positive, this was not the case for the equivalent arguments in g05dcf.
The integer array state in the call to g05slf contains information on the base generator being used. This array must have been initialized prior to calling g05slf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05slf is likely to be different from those produced by g05dcf.

### g05ddf

Withdrawn at Mark 22.
Replaced by g05skf.

#### Old Code

```Do i = 1, n
x(i) = g05ddf(xmu,sd)
End Do```

#### New Code

```var = sd**2
ifail = 0
Call g05skf(n,xmu,var,state,x,ifail)```
The old routine g05ddf returns a single variate at a time, whereas the new routine g05skf returns a vector of n values in one go. g05skf expects the variance of the Normal distribution (argument var), compared to g05ddf which expected the standard deviation.
The integer array state in the call to g05skf contains information on the base generator being used. This array must have been initialized prior to calling g05skf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05skf is likely to be different from those produced by g05ddf.

### g05def

Withdrawn at Mark 22.
Replaced by g05smf.

#### Old Code

```Do i = 1, n
x(i) = g05def(xmu,sd)
End Do```

#### New Code

```var = sd**2
ifail = 0
Call g05smf(n,xmu,var,state,x,ifail)```
The old routine g05def returns a single variate at a time, whereas the new routine g05smf returns a vector of n values in one go. g05smf expects the variance of the corresponding Normal distribution (argument var), compared to g05def which expected the standard deviation.
The integer array state in the call to g05smf contains information on the base generator being used. This array must have been initialized prior to calling g05smf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05smf is likely to be different from those produced by g05def.

### g05dff

Withdrawn at Mark 22.
Replaced by g05scf.

#### Old Code

```Do i = 1, n
x(i) = g05dff(xmed,b)
End Do```

#### New Code

```semiqr = abs(b)
ifail = 0
Call g05scf(n,xmed,semiqr,state,x,ifail)```
The old routine g05dff returns a single variate at a time, whereas the new routine g05scf returns a vector of n values in one go. g05scf expects the semi-interquartile range (argument semiqr) to be non-negative, this was not the case for the equivalent argument in g05dff.
The integer array state in the call to g05scf contains information on the base generator being used. This array must have been initialized prior to calling g05scf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05scf is likely to be different from those produced by g05dff.

### g05dhf

Withdrawn at Mark 22.
Replaced by g05sdf.

#### Old Code

```Do i = 1, n
x(i) = g05dhf(df,ifail)
End Do```

#### New Code

`Call g05sdf(n,df,state,x,ifail)`
The old routine g05dhf returns a single variate at a time, whereas the new routine g05sdf returns a vector of n values in one go.
The integer array state in the call to g05sdf contains information on the base generator being used. This array must have been initialized prior to calling g05sdf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05sdf is likely to be different from those produced by g05dhf.

### g05djf

Withdrawn at Mark 22.
Replaced by g05snf.

#### Old Code

```Do i = 1, n
x(i) = g05djf(df,ifail)
End Do```

#### New Code

`Call g05snf(n,df,state,x,ifail)`
The old routine g05djf returns a single variate at a time, whereas the new routine g05snf returns a vector of n values in one go.
The integer array state in the call to g05snf contains information on the base generator being used. This array must have been initialized prior to calling g05snf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05snf is likely to be different from those produced by g05djf.

### g05dkf

Withdrawn at Mark 22.
Replaced by g05shf.

#### Old Code

```Do i = 1, n
x(i) = g05dkf(df1,df2,ifail)
End Do```

#### New Code

`Call g05shf(n,df1,df2,state,x,ifail)`
The old routine g05dkf returns a single variate at a time, whereas the new routine g05shf returns a vector of n values in one go.
The integer array state in the call to g05shf contains information on the base generator being used. This array must have been initialized prior to calling g05shf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05shf is likely to be different from those produced by g05dkf.

### g05dpf

Withdrawn at Mark 22.
Replaced by g05ssf.

#### Old Code

```Do i = 1, n
x(i) = g05dpf(a,b,ifail)
End Do```

#### New Code

`Call g05ssf(n,a,b,state,x,ifail)`
The old routine g05dpf returns a single variate at a time, whereas the new routine g05ssf returns a vector of n values in one go.
The integer array state in the call to g05ssf contains information on the base generator being used. This array must have been initialized prior to calling g05ssf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05ssf is likely to be different from those produced by g05dpf.

### g05drf

Withdrawn at Mark 22.
Replaced by g05tkf.

#### Old Code

```Do i = 1, n
x(i) = g05drf(lamda,ifail)
End Do```

#### New Code

```mode = 3
Call g05tjf(mode,n,lambda,r,lr,state,x,ifail)```
The old routine g05drf returns a single variate at a time, whereas the new routine g05tjf returns a vector of n values in one go. For efficiency, the new routine can make use of a reference vector, r. If, as in this case, the integer argument mode is set to 3, the real reference vector r is not referenced, and its length, lr, need only be at least one.
The integer array state in the call to g05tjf contains information on the base generator being used. This array must have been initialized prior to calling g05tjf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05tjf is likely to be different from those produced by g05drf.

### g05dyf

Withdrawn at Mark 22.
Replaced by g05tlf.

#### Old Code

```Do i = 1, n
x(i) = g05dyf(aa,bb)
End Do```

#### New Code

```ifail = 0
a = min(aa,bb)
b = max(aa,bb)
Call g05tlf(n,a,b,state,x,ifail)```
The old routine g05dyf returns a single variate at a time, whereas the new routine g05tlf returns a vector of n values in one go. In g05tlf the minimum value must be held in the argument a and the maximum in argument b, therefore ${\mathbf{a}}\le {\mathbf{b}}$. This was not the case for the equivalent arguments in g05dyf.
The integer array state in the call to g05tlf contains information on the base generator being used. This array must have been initialized prior to calling g05tlf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05tlf is likely to be different from those produced by g05dyf.

### g05dzf

Withdrawn at Mark 22.
Replaced by g05tbf.

#### Old Code

```Do i = 1, n
x(i) = g05dzf(pp)
End Do```

#### New Code

```p = max(0.0D0,min(pp,1.0D0))
ifail = 0
Call g05tbf(n,p,state,x,ifail)```
The old routine g05dzf returns a single variate at a time, whereas the new routine g05tbf returns a vector of n values in one go. The real argument p in g05tbf must not be less than zero or greater than one, this was not the case for the equivalent argument in g05dzf.
The integer array state in the call to g05tbf contains information on the base generator being used. This array must have been initialized prior to calling g05tbf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05tbf is likely to be different from those produced by g05dzf.

### g05eaf

Withdrawn at Mark 22.
Replaced by g05rzf.

#### Old Code

`Call g05eaf(xmu,m,c,ldc,eps,r1,lr1,ifail)`

#### New Code

```mode = 0
Call g05rzf(mode,n,m,xmu,c,ldc,r,lr,state,x,ldx,ifail)```
The old routine g05eaf sets up a reference vector for use by g05ezf. The functionality of both these routines has been combined into the single new routine g05rzf. Setting ${\mathbf{mode}}=0$ in the call to g05rzf only sets up the real reference vector r and hence mimics the functionality of g05eaf.
The length of the real reference vector, r, in g05rzf must be at least ${\mathbf{m}}×\left({\mathbf{m}}+1\right)+1$. In contrast to the equivalent argument in g05eaf, this array must be allocated in the calling program.

### g05ebf

Withdrawn at Mark 22.
Replaced by g05tlf.
There is no direct replacement for routine g05ebf. g05ebf sets up a reference vector for use by g05eyf, this reference vector is no longer required. The replacement routine for g05eyf is g05tlf.

### g05ecf

Withdrawn at Mark 22.
Replaced by g05tjf.

#### Old Code

```Call g05ecf(lambda,r1,lr1,ifail)
Do i = 1, n
x(i) = g05eyf(r1,lr1)
End Do```

#### New Code

```mode = 2
Call g05tjf(mode,n,lambda,r,lr,state,x,ifail)```
The old routine g05ecf sets up a reference vector for use by g05eyf. The replacement routine g05tjf is now used to both set up a reference vector and generate the required variates. Setting ${\mathbf{mode}}=0$ in the call to g05tjf sets up the real reference vector r and hence mimics the functionality of g05ecf. Setting ${\mathbf{mode}}=1$ generates a series of variates from a reference vector mimicking the functionality of g05eyf for this particular distribution. Setting ${\mathbf{mode}}=2$ initializes the reference vector and generates the variates in one go.
The routine g05eyf returns a single variate at a time, whereas the new routine g05tjf returns a vector of n values in one go.
The length of the real reference vector, r, in g05tjf, must be allocated in the calling program in contrast to the equivalent argument in g05ecf, see the documentation for more details.
The integer array state in the call to g05tjf contains information on the base generator being used. This array must have been initialized prior to calling g05tjf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05tjf is likely to be different from those produced by a combination of g05ecf and g05eyf.

### g05edf

Withdrawn at Mark 22.
Replaced by g05taf.

#### Old Code

```Call g05edf(m,p,r1,lr1,ifail)
Do i = 1, n
x(i) = g05eyf(r1,lr1)
End Do```

#### New Code

```mode = 2
Call g05taf(mode,n,m,p,r,lr,state,x,ifail)```
The old routine g05edf sets up a reference vector for use by g05eyf. The replacement routine g05taf is now used to both set up a reference vector and generate the required variates. Setting ${\mathbf{mode}}=0$ in the call to g05taf sets up the real reference vector r and hence mimics the functionality of g05edf. Setting ${\mathbf{mode}}=1$ generates a series of variates from a reference vector mimicking the functionality of g05eyf for this particular distribution. Setting ${\mathbf{mode}}=2$ initializes the reference vector and generates the variates in one go.
The routine g05eyf returns a single variate at a time, whereas the new routine g05taf returns a vector of n values in one go.
The length of the real reference vector, r, in g05taf, needs to be a different length from the equivalent argument in g05edf, see the documentation for more details.
The integer array state in the call to g05taf contains information on the base generator being used. This array must have been initialized prior to calling g05taf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05taf is likely to be different from those produced by a combination of g05edf and g05eyf.

### g05eef

Withdrawn at Mark 22.
Replaced by g05thf.

#### Old Code

```Call g05eef(m,p,r1,lr1,ifail)
Do i = 1, n
x(i) = g05eyf(r1,lr1)
End Do```

#### New Code

```mode = 2
Call g05thf(mode,n,m,p,r,lr,state,x,ifail)```
The old routine g05eef sets up a reference vector for use by g05eyf. The replacement routine g05thf is now used to both set up a reference vector and generate the required variates. Setting ${\mathbf{mode}}=0$ in the call to g05thf sets up the real reference vector r and hence mimics the functionality of g05eef. Setting ${\mathbf{mode}}=1$ generates a series of variates from a reference vector mimicking the functionality of g05eyf for this particular distribution. Setting ${\mathbf{mode}}=2$ initializes the reference vector and generates the variates in one go.
The routine g05eyf returns a single variate at a time, whereas the new routine g05thf returns a vector of n values in one go.
The length of the real reference vector, r, in g05thf, needs to be a different length from the equivalent argument in g05eef, see the documentation for g05thf for more details.
The integer array state in the call to g05thf contains information on the base generator being used. This array must have been initialized prior to calling g05thf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05thf is likely to be different from those produced by a combination of g05eef and g05eyf.

### g05eff

Withdrawn at Mark 22.
Replaced by g05tef.

#### Old Code

```Call g05eff(ns,m,np,r1,lr1,ifail)
Do i = 1, n
x(i) = g05eyf(r1,lr1)
End Do```

#### New Code

```mode = 2
Call g05tef(mode,n,ns,np,m,r,lr,state,x,ifail)```
The old routine g05eff sets up a reference vector for use by g05eyf. The replacement routine g05tef is now used to both set up a reference vector and generate the required variates. Setting ${\mathbf{mode}}=0$ in the call to g05tef sets up the real reference vector r and hence mimics the functionality of g05eff. Setting ${\mathbf{mode}}=1$ generates a series of variates from a reference vector mimicking the functionality of g05eyf for this particular distribution. Setting ${\mathbf{mode}}=2$ initializes the reference vector and generates the variates in one go.
The routine g05eyf returns a single variate at a time, whereas the new routine g05tef returns a vector of n values in one go.
The length of the real reference vector, r, in g05tef, needs to be a different length from the equivalent argument in g05eff, see the documentation for more details.
The integer array state in the call to g05tef contains information on the base generator being used. This array must have been initialized prior to calling g05tef with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05tef is likely to be different from those produced by a combination of g05eff and g05eyf.

### g05egf

Withdrawn at Mark 22.
Replaced by g05phf.

#### Old Code

`Call g05egf(e,a,na,b,nb,r,nr,var,ifail)`

#### New Code

```avar = b(1)**2
iq = nb - 1
If (avar > 0.0D0) Then
Do i = 1, iq
theta(i) = -b(i+1)/b(1)
End Do
Else
Do i = 1, iq
theta(i) = 0.0D0
End Do
End If
mode = 0
Call g05phf(mode,n,e,na,a,iq,theta,avar,r,lr,state,var,x,ifail)```
The real vector theta must be of length at least ${\mathbf{iq}}=\mathit{NB}-1$.
The old routine g05egf sets up a reference vector for use by g05ewf. The replacement routine g05phf is now used to both set up a reference vector and generate the required variates. Setting ${\mathbf{mode}}=0$ in the call to g05phf sets up the real reference vector r and hence mimics the functionality of g05egf. When ${\mathbf{mode}}=0$, the integer array state in the call to g05phf need not be set.

### g05ehf

Withdrawn at Mark 22.
Replaced by g05ncf.

#### Old Code

`Call g05ehf(index,n,ifail)`

#### New Code

`Call g05ncf(index,n,state,ifail)`
The integer array state in the call to g05ncf contains information on the base generator being used. This array must have been initialized prior to calling g05ncf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05ncf is likely to be different from those produced by g05ehf.

### g05ejf

Withdrawn at Mark 22.
Replaced by g05ndf.

#### Old Code

`Call g05ejf(ia,n,iz,m,ifail)`

#### New Code

`Call g05ndf(ia,n,iz,m,state,ifail)`
The integer array state in the call to g05ndf contains information on the base generator being used. This array must have been initialized prior to calling g05ndf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05ndf is likely to be different from those produced by g05ejf.

### g05ewf

Withdrawn at Mark 22.
Replaced by g05phf.

#### Old Code

```Call g05egf(e,a,na,b,nb,r,nr,var,ifail)
Do i = 1, n
x(i) = g05ewf(r,nr,ifail)
End Do```

#### New Code

```avar = b(1)**2
iq = nb - 1
If (avar > 0.0D0) Then
Do i = 1, iq
theta(i) = -b(i+1)/b(1)
End Do
Else
Do i = 1, iq
theta(i) = 0.0D0
End Do
End If
mode = 2
Call g05phf(mode,n,e,na,a,nb-1,theta,avar,var,r,lr,state,x,ifail)```
The real vector theta must be of length at least ${\mathbf{iq}}=\mathbf{nb}-1$.
The old routine g05egf sets up a reference vector for use by g05ewf. The replacement routine g05phf is now used to both set up a reference vector and generate the required variates. Setting the integer argument mode to 0 in the call to g05phf sets up the real reference vector r and hence mimics the functionality of g05egf. Setting mode to 1 generates a series of variates from a reference vector mimicking the functionality of g05ewf. Setting mode to 2 initializes the reference vector and generates the variates in one go.
The integer array state in the call to g05phf contains information on the base generator being used. This array must have been initialized prior to calling g05phf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05phf is likely to be different from those produced by g05egf.

### g05exf

Withdrawn at Mark 22.
Replaced by g05tdf.

#### Old Code

```Call g05exf(p,np,ip1,itype,r1,lr1,ifail)
Do i = 1, n
x(i) = g05eyf(r1,lr1)
End Do```

#### New Code

```mode = 2
Call g05tdf(mode,n,p,np,ip1,itype,r,lr,state,x,ifail)```
The old routine g05exf sets up a reference vector for use by g05eyf. The replacement routine g05tdf is now used to both set up a reference vector and generate the required variates. Setting ${\mathbf{mode}}=0$ in the call to g05tdf sets up the real reference vector r and hence mimics the functionality of g05exf. Setting ${\mathbf{mode}}=1$ generates a series of variates from a reference vector mimicking the functionality of g05eyf for this particular distribution. Setting ${\mathbf{mode}}=2$ initializes the reference vector and generates the variates in one go.
The routine g05eyf returns a single variate at a time, whereas the new routine g05tdf returns a vector of n values in one go.
The length of the real reference vector, r, in g05tdf must be allocated in the calling program in contrast to the equivalent argument in g05exf, see the documentation for more details.
The integer array state in the call to g05tdf contains information on the base generator being used. This array must have been initialized prior to calling g05tdf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05tdf is likely to be different from those produced by a combination of g05exf and g05eyf.

### g05eyf

Withdrawn at Mark 22.
Replaced by g05tdf.
There is no direct replacement routine for g05eyf.
g05eyf is designed to generate random draws from a distribution defined by a reference vector. These reference vectors are created by other routines in Chapter G05, for example g05ebf, which have themselves been superseded. In order to replace a call to g05eyf you must identify which NAG routine generated the reference vector being used and look up its replacement. For example, to replace a call to g05eyf preceded by a call to g05ebf, as in:
```    Call g05ebf(m,ib,r,nr,ifail)
x = g05eyf(r,nr)```
you would need to look at the replacement routine for g05ebf.

### g05ezf

Withdrawn at Mark 22.
Replaced by g05rzf.

#### Old Code

```Call g05eaf(xmu,n,c,ldc,eps,r1,lr1,ifail)
Do i = 1, n
Call g05ezf(cx,m,r,nr,ifail)
Do j = 1, m
x(i,j) = cx(j)
End Do
End Do```

#### New Code

```mode = 2
Call g05rzf(mode,n,m,xmu,c,ldc,r,lr,state,x,ldx,ifail)```
The old routine g05eaf sets up a reference vector for use by g05ezf. The functionality of both these routines has been combined into the single new routine g05rzf. Setting ${\mathbf{mode}}=2$ in the call to g05rzf sets up the real reference vector r and generates the draws from the multivariate Normal distribution in one go.
The old routine g05ezf returns a single (m-dimensional vector) draw from the multivariate Normal distribution at a time, whereas the new routine g05rzf returns an n by m matrix of n draws in one go.
The integer array state in the call to g05rzf contains information on the base generator being used. This array must have been initialized prior to calling g05rzf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05rzf is likely to be different from those produced by g05ezf.

### g05faf

Withdrawn at Mark 22.
Replaced by g05sqf.

#### Old Code

`Call g05faf(aa,bb,n,x)`

#### New Code

```a = min(aa,bb)
b = max(aa,bb)
ifail = 0
Call g05sqf(n,a,b,state,x,ifail)```
In g05sqf the minimum value must be held in the argument a and the maximum in argument b, therefore ${\mathbf{a}}\le {\mathbf{b}}$. This was not the case for the equivalent arguments in g05faf.
The integer array state in the call to g05sqf contains information on the base generator being used. This array must have been initialized prior to calling g05sqf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05sqf is likely to be different from those produced by g05faf.

### g05fbf

Withdrawn at Mark 22.
Replaced by g05sff.

#### Old Code

`Call g05fbf(aa,n,x)`

#### New Code

```a = abs(aa)
ifail = 0
Call g05sff(n,a,state,x,ifail)```
In g05sff argument a must be non-negative, this was not the case for the equivalent argument in g05fbf.
The integer array state in the call to g05sff contains information on the base generator being used. This array must have been initialized prior to calling g05sff with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05sff is likely to be different from those produced by g05fbf.

### g05fdf

Withdrawn at Mark 22.
Replaced by g05skf.

#### Old Code

`Call g05fdf(xmu,sd,n,x)`

#### New Code

```var = sd**2
ifail = 0
Call g05skf(n,xmu,var,state,x,ifail)```
g05skf expects the variance of the Normal distribution (argument var), compared to g05fdf which expected the standard deviation.
The integer array state in the call to g05skf contains information on the base generator being used. This array must have been initialized prior to calling g05skf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05skf is likely to be different from those produced by g05fdf.

### g05fef

Withdrawn at Mark 22.
Replaced by g05sbf.

#### Old Code

`Call g05fef(a,b,n,x,ifail)`

#### New Code

`Call g05sbf(n,a,b,state,x,ifail)`
The integer array state in the call to g05sbf contains information on the base generator being used. This array must have been initialized prior to calling g05sbf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05sbf is likely to be different from those produced by g05fef.

### g05fff

Withdrawn at Mark 22.
Replaced by g05sjf.

#### Old Code

`Call g05fff(a,b,n,x,ifail)`

#### New Code

`Call g05sjf(n,a,b,state,x,ifail)`
The integer array state in the call to g05sjf contains information on the base generator being used. This array must have been initialized prior to calling g05sjf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05sjf is likely to be different from those produced by g05fff.

### g05fsf

Withdrawn at Mark 22.
Replaced by g05srf.

#### Old Code

`Call g05fsf(vk,n,x,ifail)`

#### New Code

`Call g05srf(n,vk,state,x,ifail)`
The integer array state in the call to g05srf contains information on the base generator being used. This array must have been initialized prior to calling g05srf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05srf is likely to be different from those produced by g05fsf.

### g05gaf

Withdrawn at Mark 22.
Replaced by g05pxf.

#### Old Code

`Call g05gaf(side,init,m,n,a,lda,wk,ifail)`

#### New Code

`Call g05pxf(side,init,m,n,state,a,lda,ifail)`
The integer array state in the call to g05pxf contains information on the base generator being used. This array must have been initialized prior to calling g05pxf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05pxf is likely to be different from those produced by g05gaf.

### g05gbf

Withdrawn at Mark 22.
Replaced by g05pyf.

#### Old Code

`Call g05gbf(n,d,c,ldc,eps,wk,ifail)`

#### New Code

`Call g05pyf(n,d,eps,state,c,ldc,ifail)`
The integer array state in the call to g05pyf contains information on the base generator being used. This array must have been initialized prior to calling g05pyf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05pyf is likely to be different from those produced by g05gbf.

### g05hdf

Withdrawn at Mark 22.
Replaced by g05pjf.

#### Old Code

```Call g05hdf(mode,k,ip,iq,mean,par,lpar,qq,ldqq,n,w,ref,lref,  &
iwork,liwork,ifail)```

#### New Code

```If (mode == 'S') Then
imode = 0
Else if (mode == 'C') Then
imode = 1
Else if (mode == 'R') Then
imode = 3
End If
ll = 0
Do l = 1, ip
Do i = 1, k
Do j = 1, k
ll = ll + 1
phi(i,j,l) = par(ll)
End Do
End Do
End Do
Do l = 1, iq-1
Do i = 1, k
Do j = 1, k
ll = ll + 1
theta(i,j,l) = par(ll)
End Do
End Do
End Do
If (mean == 'M') Then
Do i = 1, k
ll = ll + 1
xmean(i) = par(ll)
End Do
Else
Do i = 1, k
xmean(i) = 0.0D0
End Do
End If
ldw = n
Call g05pjf(imode,n,k,xmean,ip,phi,iq,theta,qq,ldqq,ref,lref, &
state,w,ldw,iwork,liwork,ifail)```
The integer argument IMODE should be set to 0, 1 or 3 in place of the argument mode having settings of 'S', 'C' or 'R' respectively. The real array phi should have length at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{ip}}×\left({\mathbf{k}}×{\mathbf{k}}\right)\right)$; if dimensioned as ${\mathbf{phi}}\left({\mathbf{k}},{\mathbf{k}},{\mathbf{ip}}\right)$ (as in the above example) then ${\mathbf{phi}}\left(i,j,l\right)$ will contain the element $\mathtt{par}\left(\left(l-1\right)×k×k+\left(i-1\right)×k+j\right)$. The real array theta should have length at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{iq}}×\left({\mathbf{k}}×{\mathbf{k}}\right)\right)$; if dimensioned as ${\mathbf{theta}}\left({\mathbf{k}},{\mathbf{k}},{\mathbf{iq}}\right)$ (as in the above example) then ${\mathbf{theta}}\left(i,j,l\right)$ will contain the element $\mathtt{par}\left({\mathbf{ip}}×k×k+\left(l-1\right)×k×k+\left(i-1\right)×k+j\right)$. The real array xmean should have length at least k; if $\mathbf{mean}=\text{'M'}$ then ${\mathbf{xmean}}\left(i\right)$ will contain the element $\mathtt{par}\left({\mathbf{ip}}+{\mathbf{iq}}×k×k+i\right)$, otherwise xmean should contain an array of zero values.
The integer array state in the call to g05pjf contains information on the base generator being used. This array must have been initialized prior to calling g05pjf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05pjf is likely to be different from those produced by g05hdf.

### g05hkf

Withdrawn at Mark 24.
Replaced by g05pdf.

#### Old Code

```Call g05hkf(dist,num,ip,iq,theta,gamma,df,ht,et,fcall,rvec,igen,  &
iseed,rwsav,ifail)```

#### New Code

```Call g05pdf(dist,num,ip,iq,theta,gamma,df,ht,et,fcall,r,lr,state, &
ifail)```
The integer array state in the call to g05pdf contains information on the base generator being used. This array must have been initialized prior to calling g05pdf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05pdf is likely to be different from those produced by g05hkf.

### g05hlf

Withdrawn at Mark 24.
Replaced by g05pef.

#### Old Code

```Call g05hlf(dist,num,ip,iq,theta,gamma,df,ht,et,fcall,rvec,igen,  &
iseed,rwsav,ifail)```

#### New Code

```Call g05pef(dist,num,ip,iq,theta,gamma,df,ht,et,fcall,r,lr,state, &
ifail)```
The integer array state in the call to g05pef contains information on the base generator being used. This array must have been initialized prior to calling g05pef with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05pef is likely to be different from those produced by g05hlf.

### g05hmf

Withdrawn at Mark 24.
Replaced by g05pff.

#### Old Code

```Call g05hmf(dist,num,ip,iq,theta,gamma,df,ht,et,fcall,rvec,igen,  &
iseed,rwsav,ifail)```

#### New Code

```Call g05pff(dist,num,ip,iq,theta,gamma,df,ht,et,fcall,r,lr,state, &
ifail)```
The integer array state in the call to g05pff contains information on the base generator being used. This array must have been initialized prior to calling g05pff with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization. Due to changes in the underlying code the sequence of values produced by g05pff is likely to be different from those produced by g05hmf.

### g05hnf

Withdrawn at Mark 24.
Replaced by g05pgf.

#### Old Code

```Call g05hnf(dist,num,ip,iq,theta,df,ht,et,fcall,rvec,igen,iseed, &
rwsav,ifail)```

#### New Code

```Call g05pgf(dist,num,ip,iq,theta,df,ht,et,fcall,rvec,state,      &
ifail)```
The integer array state in the call to g05pgf contains information on the base generator being used. This array must have been initialized prior to calling g05pgf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05kaf

Withdrawn at Mark 24.
Replaced by g05saf.

#### Old Code

```Do i = 1, n
x(i) = g05kaf(igen,iseed)
End Do```

#### New Code

`Call g05saf(n,state,x,ifail)`
The old routine g05kaf returns a single variate at a time, whereas the new routine g05saf returns a vector of n values in one go.
The integer array state in the call to g05saf contains information on the base generator being used. This array must have been initialized prior to calling g05saf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05kbf

Withdrawn at Mark 24.
Replaced by g05kff.

#### Old Code

`g05kbf(igen,iseed)`

#### New Code

```If (igen == 0) Then
Call g05kff(1,1,iseed,lseed,state,lstate,ifail)
Else
Call g05kff(2,igen,iseed,lseed,state,lstate,ifail)
End If```

### g05kcf

Withdrawn at Mark 24.
Replaced by g05kgf.

#### Old Code

`Call g05kcf(igen,iseed)`

#### New Code

```If (igen == 0) Then
Call g05kgf(1,1,state,lstate,ifail)
Else
Call g05kgf(2,igen,state,lstate,ifail)
End If```

### g05kef

Withdrawn at Mark 24.
Replaced by g05tbf.

#### Old Code

```Do i = 1, n
x(i) = g05kef(p,igen,iseed,ifail)
End Do```

#### New Code

`Call g05tbf(n,p,state,x,ifail)`
The old routine g05kef returns a single variate at a time, whereas the new routine g05tbf returns a vector of n values in one go.
The integer array state in the call to g05tbf contains information on the base generator being used. This array must have been initialized prior to calling g05tbf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05laf

Withdrawn at Mark 24.
Replaced by g05skf.

#### Old Code

`Call g05laf(xmu,var,n,x,igen,iseed,ifail)`

#### New Code

`Call g05skf(n,xmu,var,state,x,ifail)`
The integer array state in the call to g05skf contains information on the base generator being used. This array must have been initialized prior to calling g05skf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05lbf

Withdrawn at Mark 24.
Replaced by g05snf.

#### Old Code

`Call g05lbf(df,n,x,igen,iseed,ifail)`

#### New Code

`Call g05snf(n,df,state,x,ifail)`
The integer array state in the call to g05snf contains information on the base generator being used. This array must have been initialized prior to calling g05snf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05lcf

Withdrawn at Mark 24.
Replaced by g05sdf.

#### Old Code

`Call g05lcf(df,n,x,igen,iseed,ifail)`

#### New Code

`Call g05sdf(n,df,state,x,ifail)`
The integer array state in the call to g05sdf contains information on the base generator being used. This array must have been initialized prior to calling g05sdf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05ldf

Withdrawn at Mark 24.
Replaced by g05shf.

#### Old Code

`Call g05ldf(df1,df2,n,x,igen,iseed,ifail)`

#### New Code

`Call g05shf(n,df1,df2,state,x,ifail)`
The integer array state in the call to g05shf contains information on the base generator being used. This array must have been initialized prior to calling g05shf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05lef

Withdrawn at Mark 24.
Replaced by g05sbf.

#### Old Code

`Call g05lef(a,b,n,x,igen,iseed,ifail)`

#### New Code

`Call g05sbf(n,a,b,state,x,ifail)`
The integer array state in the call to g05sbf contains information on the base generator being used. This array must have been initialized prior to calling g05sbf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05lff

Withdrawn at Mark 24.
Replaced by g05sjf.

#### Old Code

`Call g05lff(a,b,n,x,igen,iseed,ifail)`

#### New Code

`Call g05sjf(n,a,b,state,x,ifail)`
The integer array state in the call to g05sjf contains information on the base generator being used. This array must have been initialized prior to calling g05sjf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05lgf

Withdrawn at Mark 24.
Replaced by g05sqf.

#### Old Code

`Call g05lgf(a,b,n,x,igen,iseed,ifail)`

#### New Code

`Call g05sqf(n,a,b,state,x,ifail)`
The integer array state in the call to g05sqf contains information on the base generator being used. This array must have been initialized prior to calling g05sqf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05lhf

Withdrawn at Mark 24.
Replaced by g05spf.

#### Old Code

`Call g05lhf(xmin,xmax,xmed,n,x,igen,iseed,ifail)`

#### New Code

`Call g05spf(n,xmin,xmed,xmax,state,x,ifail)`
The integer array state in the call to g05spf contains information on the base generator being used. This array must have been initialized prior to calling g05spf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05ljf

Withdrawn at Mark 24.
Replaced by g05sff.

#### Old Code

`Call g05ljf(a,n,x,igen,iseed,ifail)`

#### New Code

`Call g05sff(n,a,state,x,ifail)`
The integer array state in the call to g05sff contains information on the base generator being used. This array must have been initialized prior to calling g05sff with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05lkf

Withdrawn at Mark 24.
Replaced by g05smf.

#### Old Code

`Call g05lkf(xmu,var,n,x,igen,iseed,ifail)`

#### New Code

`Call g05smf(n,xmu,var,state,x,ifail)`
The integer array state in the call to g05smf contains information on the base generator being used. This array must have been initialized prior to calling g05smf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05llf

Withdrawn at Mark 24.
Replaced by g05sjf.

#### Old Code

`Call g05llf(xmed,semiqr,n,x,igen,iseed,ifail)`

#### New Code

`Call g05scf(n,xmed,semiqr,state,x,ifail)`
The integer array state in the call to g05scf contains information on the base generator being used. This array must have been initialized prior to calling g05scf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05lmf

Withdrawn at Mark 24.
Replaced by g05ssf.

#### Old Code

`Call g05lmf(a,b,n,x,igen,iseed,ifail)`

#### New Code

`Call g05ssf(n,a,b,state,x,ifail)`
The integer array state in the call to g05ssf contains information on the base generator being used. This array must have been initialized prior to calling g05ssf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05lnf

Withdrawn at Mark 24.
Replaced by g05slf.

#### Old Code

`Call g05lnf(a,b,n,x,igen,iseed,ifail)`

#### New Code

`Call g05slf(n,a,b,state,x,ifail)`
The integer array state in the call to g05slf contains information on the base generator being used. This array must have been initialized prior to calling g05slf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05lpf

Withdrawn at Mark 24.
Replaced by g05srf.

#### Old Code

`Call g05lpf(vk,n,x,igen,iseed,ifail)`

#### New Code

`Call g05srf(n,vk,state,x,ifail)`
The integer array state in the call to g05srf contains information on the base generator being used. This array must have been initialized prior to calling g05srf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05lqf

Withdrawn at Mark 24.
Replaced by g05sgf.

#### Old Code

`Call g05lqf(nmix,a,wgt,n,x,igen,iseed,ifail)`

#### New Code

`Call g05sgf(n,nmix,a,wgt,state,x,ifail)`
The integer array state in the call to g05sgf contains information on the base generator being used. This array must have been initialized prior to calling g05sgf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05lxf

Withdrawn at Mark 24.
Replaced by g05ryf.

#### Old Code

`Call g05lxf(mode,df,m,xmu,c,ldc,n,x,ldx,igen,iseed,r,lr,ifail)`

#### New Code

```If (mode == 0) Then
nmode = 1
Else if (mode == 1) Then
nmode = 0
Else
nmode = mode
End If
Call g05ryf(nmode,n,df,m,xmu,c,ldc,r,lr,state,x,ldx,ifail)```
The integer array state in the call to g05ryf contains information on the base generator being used. This array must have been initialized prior to calling g05ryf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05lyf

Withdrawn at Mark 24.
Replaced by g05rzf.

#### Old Code

`Call g05lyf(mode,m,xmu,c,ldc,n,x,ldx,igen,iseed,r,lr,ifail)`

#### New Code

```If (mode == 0) Then
nmode = 1
Else if (mode == 1) Then
nmode = 0
Else
nmode = mode
End If
Call g05rzf(nmode,n,m,xmu,c,ldc,r,lr,state,x,ldx,ifail)```
The integer array state in the call to g05rzf contains information on the base generator being used. This array must have been initialized prior to calling g05rzf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05lzf

Withdrawn at Mark 24.
Replaced by g05rzf.

#### Old Code

`Call g05lzf(mode,m,xmu,c,ldc,x,igen,iseed,r,lr,ifail)`

#### New Code

```If (mode == 0) Then
nmode = 1
Else if (mode == 1) Then
nmode = 0
Else
nmode = mode
End If
Call g05rzf(nmode,n,m,xmu,c,ldc,r,lr,state,x,ldx,ifail)```
The integer array state in the call to g05rzf contains information on the base generator being used. This array must have been initialized prior to calling g05rzf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05maf

Withdrawn at Mark 24.
Replaced by g05tlf.

#### Old Code

`Call g05maf(a,b,n,x,igen,iseed,ifail)`

#### New Code

`Call g05tlf(n,a,b,state,x,ifail)`
The integer array state in the call to g05tlf contains information on the base generator being used. This array must have been initialized prior to calling g05tlf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05mbf

Withdrawn at Mark 24.
Replaced by g05tcf.

#### Old Code

`Call g05mbf(mode,p,n,x,igen,iseed,r,nr,ifail)`

#### New Code

```Call g05tcf(mode,n,p,r,lr,state,x,ifail)
Do i = 1, n
x(i) = x(i) + 1
End Do```
g05mbf returned the number of trials required to get the first success, whereas g05tcf returns the number of failures before the first success, therefore the value returned by g05tcf is one less than the equivalent value returned from g05mbf.
The integer array state in the call to g05tcf contains information on the base generator being used. This array must have been initialized prior to calling g05tcf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05mcf

Withdrawn at Mark 24.
Replaced by g05thf.

#### Old Code

`Call g05mcf(mode,m,p,n,x,igen,iseed,r,nr,ifail)`

#### New Code

`Call g05thf(mode,n,m,p,r,lr,state,x,ifail)`
The integer array state in the call to g05thf contains information on the base generator being used. This array must have been initialized prior to calling g05thf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05mdf

Withdrawn at Mark 24.
Replaced by g05tff.

#### Old Code

`Call g05mdf(mode,a,n,x,igen,iseed,r,nr,ifail)`

#### New Code

`Call g05tff(mode,n,a,r,lr,state,x,ifail)`
The integer array state in the call to g05tff contains information on the base generator being used. This array must have been initialized prior to calling g05tff with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05mef

Withdrawn at Mark 24.
Replaced by g05tkf.

#### Old Code

`Call g05mef(m,vlamda,x,igen,iseed,ifail)`

#### New Code

`Call g05tkf(m,vlamda,state,x,ifail)`
The integer array state in the call to g05tkf contains information on the base generator being used. This array must have been initialized prior to calling g05tkf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05mjf

Withdrawn at Mark 24.
Replaced by g05taf.

#### Old Code

`Call g05mjf(mode,m,p,n,x,igen,iseed,r,nr,ifail)`

#### New Code

`Call g05taf(mode,n,m,p,r,lr,state,x,ifail)`
The integer array state in the call to g05taf contains information on the base generator being used. This array must have been initialized prior to calling g05taf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05mkf

Withdrawn at Mark 24.
Replaced by g05tjf.

#### Old Code

`Call g05mkf(mode,lambda,n,x,igen,iseed,r,nr,ifail)`

#### New Code

`Call g05tjf(mode,n,lambda,r,lr,state,x,ifail)`
The integer array state in the call to g05tjf contains information on the base generator being used. This array must have been initialized prior to calling g05tjf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05mlf

Withdrawn at Mark 24.
Replaced by g05tef.

#### Old Code

`Call g05mlf(mode,ns,np,m,n,x,igen,iseed,r,nr,ifail)`

#### New Code

`Call g05tef(mode,n,ns,np,m,r,lr,state,x,ifail)`
The integer array state in the call to g05tef contains information on the base generator being used. This array must have been initialized prior to calling g05tef with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05mrf

Withdrawn at Mark 24.
Replaced by g05tgf.

#### Old Code

`Call g05mrf(mode,m,k,p,n,x,ldx,igen,iseed,r,nr,ifail)`

#### New Code

`Call g05tgf(mode,n,m,k,p,r,lr,state,x,ldx,ifail)`
The integer array state in the call to g05tgf contains information on the base generator being used. This array must have been initialized prior to calling g05tgf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05mzf

Withdrawn at Mark 24.
Replaced by g05tdf.

#### Old Code

`Call g05mzf(mode,p,np,ip1,itype,n,x,igen,iseed,r,nr,ifail)`

#### New Code

`Call g05tdf(mode,n,p,np,ip1,itype,r,lr,state,x,ifail)`
The integer array state in the call to g05tdf contains information on the base generator being used. This array must have been initialized prior to calling g05tdf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05naf

Withdrawn at Mark 24.
Replaced by g05ncf.

#### Old Code

`Call g05naf(index,n,igen,iseed,ifail)`

#### New Code

`Call g05ncf(index,n,state,ifail)`
The integer array state in the call to g05ncf contains information on the base generator being used. This array must have been initialized prior to calling g05ncf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05nbf

Withdrawn at Mark 24.
Replaced by g05ndf.

#### Old Code

`Call g05nbf(ipop,n,isampl,m,igen,iseed,ifail)`

#### New Code

`Call g05ndf(ipop,n,isampl,m,state,ifail)`
The integer array state in the call to g05ndf contains information on the base generator being used. This array must have been initialized prior to calling g05ndf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05paf

Withdrawn at Mark 24.
Replaced by g05phf.

#### Old Code

```Call g05paf(mode,xmean,ip,phi,iq,theta,avar,var,n,x,igen,iseed,r, &
nr,ifail)```

#### New Code

```Call g05phf(mode,n,xmean,ip,phi,iq,theta,avar,r,lr,state,var,x,   &
ifail)```
The integer array state in the call to g05phf contains information on the base generator being used. This array must have been initialized prior to calling g05phf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05pcf

Withdrawn at Mark 24.
Replaced by g05pjf.

#### Old Code

```Call g05pcf(mode,k,xmean,ip,phi,iq,theta,var,ldv,n,x,igen,iseed,r,   &
nr,iwork,liwork,ifail)```

#### New Code

```Call g05pjf(mode,n,k,xmean,ip,phi,iq,theta,var,ldv,r,lr,state,x,ldx, &
ifail)```
The integer array state in the call to g05pjf contains information on the base generator being used. This array must have been initialized prior to calling g05pjf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05qaf

Withdrawn at Mark 24.
Replaced by g05pxf.

#### Old Code

`Call g05qaf(side,init,m,n,a,lda,igen,iseed,wk,ifail)`

#### New Code

`Call g05pxf(side,init,m,n,state,a,lda,ifail)`
The integer array state in the call to g05pxf contains information on the base generator being used. This array must have been initialized prior to calling g05pxf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05qbf

Withdrawn at Mark 24.
Replaced by g05pyf.

#### Old Code

`Call g05qbf(n,d,c,ldc,eps,igen,iseed,wk,ifail)`

#### New Code

`Call g05pyf(n,d,eps,state,c,ldc,ifail)`
The integer array state in the call to g05pyf contains information on the base generator being used. This array must have been initialized prior to calling g05pyf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05qdf

Withdrawn at Mark 24.
Replaced by g05pzf.

#### Old Code

```Call g05qdf(mode,nrow,ncol,totr,totc,x,ldx,igen,iseed,r,nr,iw,liw, &
ifail)```

#### New Code

`Call g05pzf(mode,nrow,ncol,totr,totc,r,lr,state,x,ldx,ifail)`
The integer array state in the call to g05pzf contains information on the base generator being used. This array must have been initialized prior to calling g05pzf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05raf

Withdrawn at Mark 24.
Replaced by g05rdf.

#### Old Code

`Call g05raf(mode,m,c,ldc,n,x,ldx,igen,iseed,r,lr,ifail)`

#### New Code

```If (mode == 0) Then
nmode = 1
Else if (mode == 1) Then
nmode = 0
Else
nmode = mode
End If
Call g05rdf(nmode,n,m,c,ldc,r,lr,state,x,ldx,ifail)```
The integer array state in the call to g05rdf contains information on the base generator being used. This array must have been initialized prior to calling g05rdf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05rbf

Withdrawn at Mark 24.
Replaced by g05rcf.

#### Old Code

`Call g05rbf(mode,df,m,c,ldc,n,x,ldx,igen,iseed,r,lr,ifail)`

#### New Code

```If (mode == 0) Then
nmode = 1
Else if (mode == 1) Then
nmode = 0
Else
nmode = mode
End If
Call g05rcf(nmode,n,df,m,c,ldc,r,lr,state,x,ldx,ifail)```
The integer array state in the call to g05rcf contains information on the base generator being used. This array must have been initialized prior to calling g05rcf with a call to either g05kff or g05kgf. The required length of the array state will depend on the base generator chosen during initialization.

### g05yaf

Withdrawn at Mark 23.
Replaced by g05ylf and g05ymf.
Faure quasi-random numbers:

#### Old Code

`Call g05yaf(.True.,'F',iskip,idim,quas,iref,ifail)`

#### New Code

`Call g05ylf(4,idim,iref,liref,iskip,ifail)`

#### Old Code

`Call g05yaf(.False.,'F',iskip,idim,quas,iref,ifail)`

#### New Code

`Call g05ymf(1,2,quas,ldquas,iref,ifail)`
Sobol quasi-random numbers:

#### Old Code

`Call g05yaf(.True.,'S',iskip,idim,quas,iref,ifail)`

#### New Code

`Call g05ylf(2,idim,iref,liref,iskip,ifail)`

#### Old Code

`Call g05yaf(.False.,'S',iskip,idim,quas,iref,ifail)`

#### New Code

`Call g05ymf(1,2,quas,ldquas,iref,ifail)`
Neiderreiter quasi-random numbers:

#### Old Code

`Call g05yaf(.True.,'N',iskip,idim,quas,iref,ifail)`

#### New Code

`Call g05ylf(3,idim,iref,liref,iskip,ifail)`

#### Old Code

`Call g05yaf(.False.,'N',iskip,idim,quas,iref,ifail)`

#### New Code

`Call g05ymf(1,2,quas,ldquas,iref,ifail)`

### g05ybf

Withdrawn at Mark 23.
Replaced by g05ylf and either g05yjf or g05ykf.
This routine has been replaced by a suite of routines consisting of the relevant initialization routine followed by one of two possible generator routines.
Faure quasi-random numbers with Gaussian probability:

#### Old Code

`Call g05ybf(.True.,'F',.False.,mean,std,iskip,idim,quasi,iref,ifail)`

#### New Code

`Call g05ylf(4,idim,iref,liref,iskip,ifail)`

#### Old Code

`Call g05ybf(.False.,'F',.False.,mean,std,iskip,idim,quasi,iref,ifail)`

#### New Code

`Call g05yjf(mean,std,n,quasi,iref,ifail)`
Sobol quasi-random numbers with Gaussian probability:

#### Old Code

`Call g05ybf(.True.,'S',.False.,mean,std,iskip,idim,quasi,iref,ifail)`

#### New Code

`Call g05ylf(2,idim,iref,liref,iskip,ifail)`

#### Old Code

`Call g05ybf(.False.,'S',.False.,mean,std,iskip,idim,quasi,iref,ifail)`

#### New Code

`Call g05yjf(mean,std,n,quasi,iref,ifail)`
Neiderreiter quasi-random numbers with Gaussian probability:

#### Old Code

`Call g05ybf(.True.,'N',.False.,mean,std,iskip,idim,quasi,iref,ifail)`

#### New Code

`Call g05ylf(3,idim,iref,liref,iskip,ifail)`

#### Old Code

`Call g05ybf(.False.,'N',.False.,mean,std,iskip,idim,quasi,iref,ifail)`

#### New Code

`Call g05yjf(mean,std,n,quasi,iref,ifail)`
Faure quasi-random numbers with log Normal probability:

#### Old Code

`Call g05ybf(.True.,'F',.True.,mean,std,iskip,idim,quasi,iref,ifail)`

#### New Code

`Call g05ylf(4,idim,iref,liref,iskip,ifail)`

#### Old Code

`Call g05ybf(.False.,'F',.True.,mean,std,iskip,idim,quasi,iref,ifail)`

#### New Code

`Call g05ykf(mean,std,n,quasi,iref,ifail)`
Sobol quasi-random numbers with log Normal probability:

#### Old Code

`Call g05ybf(.True.,'S',.True.,mean,std,iskip,idim,quasi,iref,ifail)`

#### New Code

`Call g05ylf(2,idim,iref,liref,iskip,ifail)`

#### Old Code

`Call g05ybf(.False.,'S',.True.,mean,std,iskip,idim,quasi,iref,ifail)`

#### New Code

`Call g05ykf(mean,std,n,quasi,iref,ifail)`
Neiderreiter quasi-random numbers with log Normal probability:

#### Old Code

`Call g05ybf(.True.,'N',.True.,mean,std,iskip,idim,quasi,iref,ifail)`

#### New Code

`Call g05ylf(3,idim,iref,liref,iskip,ifail)`

#### Old Code

`Call g05ybf(.False.,'N',.True.,mean,std,iskip,idim,quasi,iref,ifail)`

#### New Code

`Call g05ykf(mean,std,n,quasi,iref,ifail)`

### g05ycf

Withdrawn at Mark 24.
Replaced by g05ylf.

#### Old Code

`Call g05ycf(idim,iref,ifail)`

#### New Code

```genid = 4
Call g05ylf(genid,idim,iref,liref,iskip,ifail)```

### g05ydf

Withdrawn at Mark 24.
Replaced by g05ymf.

#### Old Code

`Call g05ydf(n,quasi,iref,ifail)`

#### New Code

`Call g05ymf(n,quas,ldquas,iref,ifail)`

### g05yef

Withdrawn at Mark 24.
Replaced by g05ylf.

#### Old Code

`Call g05yef(idim,iref,iskip,ifail)`

#### New Code

```genid = 2
Call g05ylf(genid,idim,iref,liref,iskip,ifail)```

### g05yff

Withdrawn at Mark 24.
Replaced by g05ymf.

#### Old Code

`Call g05yff(n,quasi,iref,ifail)`

#### New Code

`Call g05ymf(n,quas,ldquas,iref,ifail)`

### g05ygf

Withdrawn at Mark 24.
Replaced by g05ylf.

#### Old Code

`Call g05ygf(idim,iref,iskip,ifail)`

#### New Code

```genid = 3
Call g05ylf(genid,idim,iref,liref,iskip,ifail)```

### g05yhf

Withdrawn at Mark 24.
Replaced by g05ymf.

#### Old Code

`Call g05yhf(n,quasi,iref,ifail)`

#### New Code

`Call g05ymf(n,rcord,quas,ldquas,iref,ifail)`

### g05zaf

Withdrawn at Mark 22.
There is no replacement for this routine.
g05zaf was used to select the underlying generator for the old style random number generation routines. These routines are no longer available and hence no direct replacement routine for g05zaf is required. See g05kff and g05kgf for details on how to select the underlying generator for the newer style routines.

## G10 – Smoothing in Statistics

### g10baf

Withdrawn at Mark 27.
Replaced by g10bbf.
Withdrawn primarily due to threadsafety. The replacement routine also introduces new functionality with respect to the automatic selection of a suitable window width.

#### Old Code

`Call g10baf(n,x,window,slo,shi,ns,smooth,t,usefft,fft,ifail)`

#### New Code

```Allocate(rcomm,ns+20)
Call g10bbf(n,x,1,window,slo,shi,ns,smooth,t,usefft,rcomm,ifail)
! the next step is only required if the information in FFT
! was being used outside another call to G10BAF
fft(1:ns) = rcomm(21:ns+20)```

## G13 – Time Series Analysis

### g13dcf

Withdrawn at Mark 24.
Replaced by g13ddf.

#### Old Code

```Call g13dcf(k,n,ip,iq,mean,par,npar,qq,kmax,w,parhld,exact,iprint,  &
cgetol,maxcal,ishow,niter,rlogl,v,g,cm,ldcm,work,lwork, &
iw,liw,ifail)```

#### New Code

```Call g13ddf(k,n,ip,iq,mean,par,npar,qq,kmax,w,parhld,exact,iprint,  &
cgetol,maxcal,ishow,niter,rlogl,v,g,cm,ldcm,ifail)```
The workspace arguments work, lwork, iw and liw are no longer required in the call to g13ddf.

## P01 – Error Trapping

### p01abf

Withdrawn at Mark 24.
There is no replacement for this routine.

## X02 – Machine Constants

### x02daf

Withdrawn at Mark 24.
There is no replacement for this routine.

### x02djf

Withdrawn at Mark 24.
There is no replacement for this routine.