    PROGRAM m01dcfe

!      M01DCF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. 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
