    PROGRAM m01cbfe

!      M01CBF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : m01cbf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       INTEGER                         :: i, ifail, m1, m2
!      .. Local Arrays ..
       INTEGER, ALLOCATABLE            :: iv(:)
!      .. Executable Statements ..
       WRITE (nout,*) 'M01CBF Example Program Results'

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

       READ (nin,*) m2
       ALLOCATE (iv(m2))

       m1 = 1

       READ (nin,*) (iv(i),i=m1,m2)

       ifail = 0
       CALL m01cbf(iv,m1,m2,'Descending',ifail)

       WRITE (nout,*)
       WRITE (nout,*) 'Sorted numbers'
       WRITE (nout,*)
       WRITE (nout,99999) (iv(i),i=m1,m2)

99999  FORMAT (1X,10I7)
    END PROGRAM m01cbfe
