* F07ACF Example Program Text * Mark 22 Release. NAG Copyright 2007. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER NMAX, RMAX PARAMETER (NMAX=8,RMAX=1) INTEGER LDA, LDB, LDX PARAMETER (LDA=NMAX,LDB=NMAX,LDX=NMAX) * .. Local Scalars .. INTEGER I, INFO, ITER, J, N, R * .. Local Arrays .. DOUBLE PRECISION A(LDA,NMAX), B(NMAX,RMAX), WORK(NMAX*RMAX), + X(LDX,RMAX) REAL SWORK(NMAX*(NMAX+RMAX)) INTEGER IPIV(NMAX) * .. External Subroutines .. EXTERNAL DSGESV * .. Executable Statements .. WRITE (NOUT,*) 'F07ACF Example Program Results' WRITE (NOUT,*) * Skip heading in data file READ (NIN,*) READ (NIN,*) N, R IF (N.LE.NMAX .AND. R.LE.RMAX) THEN * * Read A and B from data file * READ (NIN,*) ((A(I,J),J=1,N),I=1,N) READ (NIN,*) ((B(I,J),J=1,R),I=1,N) * * Solve the equations Ax = b for x * CALL DSGESV(N,R,A,LDA,IPIV,B,LDB,X,LDX,WORK,SWORK,ITER,INFO) * IF (INFO.EQ.0) THEN * * Print solution * WRITE (NOUT,*) 'Solution' WRITE (NOUT,99999) ((X(I,J),J=1,R),I=1,N) * * Print pivot indices * WRITE (NOUT,*) WRITE (NOUT,*) 'Pivot indices' WRITE (NOUT,99998) (IPIV(I),I=1,N) * ELSE WRITE (NOUT,99997) 'The (', INFO, ',', INFO, ')', + ' element of the factor U is zero' END IF ELSE WRITE (NOUT,*) 'NMAX too small' END IF * 99999 FORMAT ((3X,7F11.4)) 99998 FORMAT ((3X,7I11)) 99997 FORMAT (1X,A,I3,A,I3,A,A) END