NAG Library Manual, Mark 27.2
```    Program g02ab_p0w_fe

!     G02AB_P0W_F Example Program Text
!     Mark 27.2 Release. NAG Copyright 2021.

!     .. Use Statements ..
Use iso_c_binding, Only: c_ptr
Use nag_library, Only: nag_wp, x04caf
!     .. Implicit None Statement ..
Implicit None
!     .. Parameters ..
Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
Real (Kind=nag_wp)               :: alpha, errtol, nrmgrd
Integer                          :: feval, i, ifail, iter, ldg, ldx,     &
lwork, maxit, maxits, n
Character (1)                    :: opt
!     .. Local Arrays ..
Real (Kind=nag_wp), Allocatable  :: eig(:), g(:,:), w(:), work(:),       &
x(:,:)
!     .. Executable Statements ..
Write (nout,*) 'G02AB_P0W_F Example Program Results'
Write (nout,*)
Flush (nout)

!     Skip heading in data file
alpha = 0.0_nag_wp
!     Read in the problem size, opt and alpha

ldg = n
ldx = n
lwork = 66*n
Allocate (g(n,n),w(n),x(n,n),eig(n),work(lwork))
x = 0.0_nag_wp

!     Read in the matrix G

!     Read in the vector W

!     Use the defaults for ERRTOL, MAXITS and MAXIT
errtol = 0.0E0_nag_wp
maxits = 0
maxit = 0

!     Calculate nearest correlation matrix
ifail = 0
ldx,iter,feval,nrmgrd,ifail)

!     Display results
ifail = 0
Call x04caf('General',' ',n,n,x,n,'Nearest Correlation Matrix X',ifail)
Write (nout,*)
Write (nout,99999) 'Number of Newton steps taken:', iter
Write (nout,99998) 'Number of function evaluations:', feval

Write (nout,*)
Write (nout,99997) 'alpha: ', alpha

99999 Format (1X,A,I11)
99998 Format (1X,A,I9)
99997 Format (1X,A,F37.3)

End Program g02ab_p0w_fe
```