NAG Library Manual, Mark 27.3
Interfaces:  FL   CL   CPP   AD 

NAG FL Interface Introduction
Example description
    Program f16dqfe

!     F16DQF Example Program Text

!     Mark 27.3 Release. NAG Copyright 2021.

!     .. Use Statements ..
      Use nag_library, Only: f16dqf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Integer                          :: i, incx, j, jx, k, n
!     .. Local Arrays ..
      Integer, Allocatable             :: x(:)
!     .. Intrinsic Procedures ..
      Intrinsic                        :: abs
!     .. Executable Statements ..
      Write (nout,*) 'F16DQF Example Program Results'

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

      Read (nin,*) n, incx
      Allocate (x(1+(n-1)*abs(incx)))

!     Read the vector x and store forwards or backwards
!     as determined by incx.
      If (incx>0) Then
        jx = 1
      Else
        jx = 1 - (n-1)*incx
      End If

      Do j = 1, n
        Read (nin,*) x(jx)
        jx = jx + incx
      End Do

!     Find k = argmax(abs(x)) and i = max(abs(x)).

      Call f16dqf(n,x,incx,k,i)

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

99999 Format (1X,'Index of absolutely largest component of x is',I3)
99998 Format (1X,'Absolutely largest component of x is',I12)
    End Program f16dqfe