Program m01ebfe
! M01EBF Example Program Text
! Mark 26.2 Release. NAG Copyright 2017.
! .. Use Statements ..
Use nag_library, Only: m01dbf, m01ebf
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Integer :: i, ifail, j, k, m1, m2, n
! .. Local Arrays ..
Integer, Allocatable :: im(:,:), irank(:)
! .. Executable Statements ..
Write (nout,*) 'M01EBF Example Program Results'
! Skip heading in data file
Read (nin,*)
Read (nin,*) m2, n, k
If (k<1 .Or. k>n) Then
Go To 100
End If
Allocate (im(m2,n),irank(m2))
m1 = 1
Do i = m1, m2
Read (nin,*)(im(i,j),j=1,n)
End Do
ifail = 0
Call m01dbf(im(m1,k),m1,m2,'Ascending',irank,ifail)
Do j = 1, n
ifail = 0
Call m01ebf(im(m1,j),m1,m2,irank,ifail)
End Do
Write (nout,*)
Write (nout,99999) 'Matrix sorted on column', k
Write (nout,*)
Do i = m1, m2
Write (nout,99998)(im(i,j),j=1,n)
End Do
100 Continue
99999 Format (1X,A,I3)
99998 Format (1X,3I7)
End Program m01ebfe