    Program m01dcfe

!     M01DCF Example Program Text

!     Mark 24 Release. NAG Copyright 2012.

!     .. Use Statements ..
      Use nag_library, Only: m01dcf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Integer                          :: i, ifail, l1, l2, m1, m2
!     .. Local Arrays ..
      Integer, Allocatable             :: irank(:)
      Character (12), Allocatable      :: ch(:)
!     .. Executable Statements ..
      Write (nout,*) 'M01DCF Example Program Results'

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

      Read (nin,*) m2
      Allocate (ch(m2),irank(m2))

      m1 = 1

      Do i = m1, m2
        Read (nin,'(A)') ch(i)
      End Do

      l1 = 7
      l2 = 12

      ifail = 0
      Call m01dcf(ch,m1,m2,l1,l2,'Reverse ASCII',irank,ifail)

      Write (nout,*)
      Write (nout,99999) 'Records ranked on columns ', l1, '  to ', l2
      Write (nout,*)
      Write (nout,*) 'Data            Ranks'
      Write (nout,*)
      Write (nout,99998)(ch(i),irank(i),i=m1,m2)

99999 Format (1X,A,I2,A,I2)
99998 Format (1X,A,I7)
    End Program m01dcfe
