Program m01zafe
! M01ZAF Example Program Text
! Mark 30.0 Release. NAG Copyright 2024.
! .. Use Statements ..
Use nag_library, Only: m01def, m01zaf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Integer :: i, ifail, j, ldm, m1, m2, n1, n2
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: rm(:,:)
Integer, Allocatable :: iperm(:)
! .. Executable Statements ..
Write (nout,*) 'M01ZAF Example Program Results'
! Skip heading in data file
Read (nin,*)
Read (nin,*) m2, n2
ldm = m2
Allocate (rm(ldm,n2),iperm(m2))
m1 = 1
n1 = 1
Do i = m1, m2
Read (nin,*)(rm(i,j),j=n1,n2)
End Do
ifail = 0
Call m01def(rm,ldm,m1,m2,n1,n2,'Ascending',iperm,ifail)
ifail = 0
Call m01zaf(iperm,m1,m2,ifail)
Write (nout,*)
Write (nout,*) 'Matrix sorted by rows'
Write (nout,*)
Do i = m1, m2
Write (nout,99999)(rm(iperm(i),j),j=n1,n2)
End Do
99999 Format (1X,3F7.1)
End Program m01zafe