NAG Library Manual, Mark 27.2
```    Program f08kb_p0w_fe

!     F08KB_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               :: nb = 64, nin = 5, nout = 6
!     .. Local Scalars ..
Integer                          :: i, ifail, lda, ldu, ldvt, lwork, m,  &
n
!     .. Local Arrays ..
Real (Kind=nag_wp), Allocatable  :: a(:,:), s(:), u(:,:), vt(:,:),       &
work(:)
Real (Kind=nag_wp)               :: dummy(1,1)
!     .. Intrinsic Procedures ..
Intrinsic                        :: max, min, nint
!     .. Executable Statements ..
Write (nout,*) 'F08KB_P0W_F Example Program Results'
!     Skip heading in data file
lda = m
ldu = m
ldvt = n
Allocate (a(lda,n),s(m),u(ldu,m),vt(ldvt,n))

!     Use routine workspace query to get optimal workspace.
lwork = -1
ifail = 0
lwork,ifail)

!     Make sure that there is enough workspace for block size nb.
lwork = max((5*m+9)*m+n+nb*(m+n),nint(dummy(1,1)))
Allocate (work(lwork))

!     Read the m by n matrix A from data file

!     Compute the singular values and left and right singular vectors
!     of A (A = U*S*(V**T), m.le.n)
ifail = 0
ifail)

!     Print solution
Write (nout,*)
Write (nout,*) 'Singular values'
Write (nout,99999) s(1:m)
99999 Format (3X,(8F8.4))
Flush (nout)

!     Normalize so that u(1,j)>=0
Do i = 1, min(m,n)
If (u(1,i)<0.0_nag_wp) Then
u(1:m,i) = -u(1:m,i)
vt(i,1:n) = -vt(i,1:n)
End If
End Do
!     ifail: behaviour on error exit
!            =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
ifail = 0
Call x04caf('General',' ',m,m,u,ldu,'Left singular vectors',ifail)

Write (nout,*)
Flush (nout)

Call x04caf('General',' ',m,n,vt,ldvt,'Right singular vectors by row '// &
'(first m rows of V**T)',ifail)

End Program f08kb_p0w_fe
```