    PROGRAM f16glfe

!      F16GLF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. 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, n
!      .. Local Arrays ..
       COMPLEX (KIND=nag_wp), ALLOCATABLE :: x(:)
!      .. Intrinsic Functions ..
       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 (nin,*) (x(i),i=1,1+(n-1)*abs(incx),incx)

!      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
