    PROGRAM f16jnfe

!      F16JNF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : blas_dmax_val, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: r
       INTEGER                         :: i, incx, k, n
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: x(:)
!      .. Intrinsic Functions ..
       INTRINSIC                          abs
!      .. Executable Statements ..
       WRITE (nout,*) 'F16JNF 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)

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

       CALL blas_dmax_val(n,x,incx,k,r)

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

99999  FORMAT (1X,'Index of largest component of X is',I3)
99998  FORMAT (1X,'Largest component of X is',F12.5)
    END PROGRAM f16jnfe
