* M01EDF Example Program Text * Mark 19 Release. NAG Copyright 1999. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER MMAX, NMAX PARAMETER (MMAX=20,NMAX=20) * .. Local Scalars .. INTEGER I, IFAIL, J, K, M, N CHARACTER*30 STRING * .. Local Arrays .. COMPLEX *16 CM(MMAX,NMAX) DOUBLE PRECISION CMOD(MMAX) INTEGER IRANK(MMAX) * .. External Subroutines .. EXTERNAL M01DAF, M01EDF, X04DAF * .. Intrinsic Functions .. INTRINSIC ABS * .. Executable Statements .. WRITE (NOUT,*) 'M01EDF Example Program Results' * Skip heading in data file READ (NIN,*) READ (NIN,*) M, N, K IF (M.GE.1 .AND. M.LE.MMAX .AND. N.GE.1 .AND. N.LE.NMAX .AND. + K.GE.1 .AND. K.LE.N) THEN * * Read matrix from data file. * DO 20 I = 1, M READ (NIN,*) (CM(I,J),J=1,N) 20 CONTINUE * * Calculate the moduli of the elements in the K-th column. * DO 40 I = 1, M CMOD(I) = ABS(CM(I,K)) 40 CONTINUE * * Rearrange the rows so that the elements in the K-th column * are in ascending order of modulus. * IFAIL = 0 * CALL M01DAF(CMOD,1,M,'Ascending',IRANK,IFAIL) * * Rearrange each column into the order specified by IRANK. * DO 60 J = 1, N IFAIL = 0 * CALL M01EDF(CM(1,J),1,M,IRANK,IFAIL) * 60 CONTINUE * * Print the results. * WRITE (NOUT,*) WRITE (STRING,99999) 'Matrix sorted on column', K IFAIL = 0 * CALL X04DAF('General',' ',M,N,CM,MMAX,STRING,IFAIL) * END IF * 99999 FORMAT (1X,A,I3) END