    PROGRAM nag_sort_ex06

      ! Example Program Text for nag_sort
      ! NAG fl90, Release 4. NAG Copyright 2000.

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_in, nag_std_out
      USE nag_sort, ONLY : nag_sort_vec
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      ! .. Local Scalars ..
      INTEGER :: n
      ! .. Local Arrays ..
      REAL (wp), ALLOCATABLE :: a(:)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_sort_ex06'
      WRITE (nag_std_out,*)

      READ (nag_std_in,*)          ! Skip heading in data file
      READ (nag_std_in,*) n

      ALLOCATE (a(n))              ! Allocate storage

      READ (nag_std_in,*) a

      CALL nag_sort_vec(a)

      WRITE (nag_std_out,*) 'Data sorted in ascending order'
      WRITE (nag_std_out,'(1X,F7.1)') a

      DEALLOCATE (a)               ! Deallocate storage

    END PROGRAM nag_sort_ex06
