    Program f16elfe

!     F16ELF Example Program Text

!     Mark 24 Release. NAG Copyright 2012.

!     .. Use Statements ..
      Use nag_library, Only: blas_dsum, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: sumval
      Integer                          :: i, incx, n
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: x(:)
!     .. Intrinsic Procedures ..
      Intrinsic                        :: abs
!     .. Executable Statements ..
      Write (nout,*) 'F16ELF 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_dsum(n,x,incx)

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

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