    PROGRAM f16jtfe

!      F16JTF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : blas_zamin_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 ..
       COMPLEX (KIND=nag_wp), ALLOCATABLE :: x(:)
!      .. Intrinsic Functions ..
       INTRINSIC                          abs
!      .. Executable Statements ..
       WRITE (nout,*) 'F16JTF 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 = ARGMIN(ABS(Re(X))+ABS(Im(X))) and
!            R = MIN(ABS(Re(X))+ABS(Im(X))).

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

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

99999  FORMAT (1X,'Index of absolutely smallest component of X is',I3)
99998  FORMAT (1X,'Absolutely smallest value is',F12.5)
    END PROGRAM f16jtfe
