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

NAG FL Interface Introduction
Example description
    Program f16gcfe

!     F16GCF Example Program Text

!     Mark 27.2 Release. NAG Copyright 2021.

!     .. Use Statements ..
      Use nag_library, Only: blas_zaxpby, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Complex (Kind=nag_wp)            :: alpha, beta
      Integer                          :: i, incx, incy, ix, iy, n
!     .. Local Arrays ..
      Complex (Kind=nag_wp), Allocatable :: x(:), y(:)
!     .. Intrinsic Procedures ..
      Intrinsic                        :: abs
!     .. Executable Statements ..
      Write (nout,*) 'F16GCF 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_zaxpby(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 = ( ',2('(',F9.4,',',F9.4,'), '),'(',F9.4,',',F9.4,') )')
    End Program f16gcfe