NAG Library Manual, Mark 27.2
Interfaces:  FL   CL   CPP   AD
```    Program f16ehfe

!     F16EHF Example Program Text

!     Mark 27.2 Release. NAG Copyright 2021.

!     .. Use Statements ..
Use nag_library, Only: blas_dwaxpby, nag_wp
!     .. Implicit None Statement ..
Implicit None
!     .. Parameters ..
Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
Real (Kind=nag_wp)               :: alpha, beta
Integer                          :: i, incw, incx, incy, ix, iy, n
!     .. Local Arrays ..
Real (Kind=nag_wp), Allocatable  :: w(:), x(:), y(:)
!     .. Intrinsic Procedures ..
Intrinsic                        :: abs
!     .. Executable Statements ..
Write (nout,*) 'F16EHF Example Program Results'

!     Skip heading in data file
Read (nin,*)

Read (nin,*) n
Read (nin,*) incx, incy, incw
Allocate (w(1+(n-1)*abs(incw)),x(1+(n-1)*abs(incx)),y(1+(n-              &
1)*abs(incy)))

Read (nin,*) alpha, beta

!     Read the vectors x and y and store forwards or backwards
!     as determined by incx (resp. incy).
If (incx>0) Then
ix = 1
Else
ix = 1 - (n-1)*incx
End If

Do i = 1, n
Read (nin,*) x(ix)
ix = ix + incx
End Do

If (incy>0) Then
iy = 1
Else
iy = 1 - (n-1)*incy
End If

Do i = 1, n
Read (nin,*) y(iy)
iy = iy + incy
End Do

!     Compute w = alpha*x + beta*y

Call blas_dwaxpby(n,alpha,x,incx,beta,y,incy,w,incw)

!     Display the vector w forwards or backwards
!     as determined by incw.
Write (nout,*)
Write (nout,99999)
If (incw>0) Then
Write (nout,99998) w(1:1+(n-1)*incw:incw)
Else
Write (nout,99998) w(1-(n-1)*incw:1:incw)
End If

99999 Format (1X,'Result of scaled vector addition is')
99998 Format (1X,'w =',5F9.4)
End Program f16ehfe
```