Example description
    Program f16ecfe

!     F16ECF Example Program Text

!     Mark 27.1 Release. NAG Copyright 2020.

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

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

      Read (nin,*) n
      Read (nin,*) incx, incy
      Allocate (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 y = alpha*x + beta*y

      Call blas_daxpby(n,alpha,x,incx,beta,y,incy)

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

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