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

NAG FL Interface Introduction
Example description
    Program f16glfe

!     F16GLF Example Program Text

!     Mark 27.3 Release. NAG Copyright 2021.

!     .. Use Statements ..
      Use nag_library, Only: blas_zsum, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Complex (Kind=nag_wp)            :: sumval
      Integer                          :: i, incx, ix, n
!     .. Local Arrays ..
      Complex (Kind=nag_wp), Allocatable :: x(:)
!     .. Intrinsic Procedures ..
      Intrinsic                        :: abs
!     .. Executable Statements ..
      Write (nout,*) 'F16GLF Example Program Results'

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

      Read (nin,*) n, incx
      Allocate (x(1+(n-1)*abs(incx)))

!     Read the vector x and store forwards or backwards
!     as determined by incx.
      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

!     Sum the elements of x

      sumval = blas_zsum(n,x,incx)

      Write (nout,*)
      Write (nout,99999) sumval

99999 Format (1X,'Sum of elements of x is (',F9.5,',',F9.5,')')
    End Program f16glfe