    PROGRAM f16dnfe

!      F16DNF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : f16dnf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       INTEGER                         :: i, incx, j, k, n
!      .. Local Arrays ..
       INTEGER, ALLOCATABLE            :: x(:)
!      .. Intrinsic Functions ..
       INTRINSIC                          abs
!      .. Executable Statements ..
       WRITE (nout,*) 'F16DNF Example Program Results'

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

       READ (nin,*) n, incx
       ALLOCATE (x(1+(n-1)*abs(incx)))

       READ (nin,*) (x(j),j=1,1+(n-1)*abs(incx),incx)

!      Find K = ARGMAX(X) and I = MAX(X).

       CALL f16dnf(n,x,incx,k,i)

       WRITE (nout,*)
       WRITE (nout,99999) k
       WRITE (nout,99998) i

99999  FORMAT (1X,'Index of largest component of X is',I3)
99998  FORMAT (1X,'Largest component of X is',I12)
    END PROGRAM f16dnfe
