Program f11zafe ! F11ZAF Example Program Text ! Mark 24 Release. NAG Copyright 2012. ! .. Use Statements .. Use nag_library, Only: f11zaf, nag_wp ! .. Implicit None Statement .. Implicit None ! .. Parameters .. Integer, Parameter :: nin = 5, nout = 6 ! .. Local Scalars .. Integer :: i, ifail, n, nnz Character (1) :: dup, zer ! .. Local Arrays .. Real (Kind=nag_wp), Allocatable :: a(:) Integer, Allocatable :: icol(:), irow(:), istr(:), iwork(:) ! .. Executable Statements .. Write (nout,*) 'F11ZAF Example Program Results' Write (nout,*) ! Skip heading in data file Read (nin,*) ! Read order of matrix and number of non-zero entries Read (nin,*) n Read (nin,*) nnz Allocate (a(nnz),icol(nnz),irow(nnz),istr(n+1),iwork(n)) ! Read and output the original non-zero elements Do i = 1, nnz Read (nin,*) a(i), irow(i), icol(i) End Do Write (nout,*) 'Original elements' Write (nout,'(A,I4)') ' NNZ = ', nnz Do i = 1, nnz Write (nout,'(I8,E16.4,2I8)') i, a(i), irow(i), icol(i) End Do ! Reorder, sum duplicates and remove zeros dup = 'S' zer = 'R' ! ifail: behaviour on error exit ! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ifail = 0 Call f11zaf(n,nnz,a,irow,icol,dup,zer,istr,iwork,ifail) ! Output results Write (nout,*) 'Reordered elements' Write (nout,'(A,I4)') ' NNZ = ', nnz Do i = 1, nnz Write (nout,'(I8,E16.4,2I8)') i, a(i), irow(i), icol(i) End Do End Program f11zafe