PROGRAM f11zafe ! F11ZAF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. 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