* F11DSF Example Program Text * Mark 19 Release. NAG Copyright 1999. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER NMAX, LA, LWORK PARAMETER (NMAX=1000,LA=10000,LWORK=10000) * .. Local Scalars .. DOUBLE PRECISION OMEGA, RNORM, TOL INTEGER I, IFAIL, ITN, L, LWREQ, M, MAXITN, N, NNZ CHARACTER PRECON CHARACTER*8 METHOD * .. Local Arrays .. COMPLEX *16 A(LA), B(NMAX), WORK(LWORK), X(NMAX) INTEGER ICOL(LA), IROW(LA), IWORK(2*NMAX+1) * .. External Subroutines .. EXTERNAL F11DSF * .. Intrinsic Functions .. INTRINSIC MAX * .. Executable Statements .. WRITE (NOUT,*) 'F11DSF Example Program Results' WRITE (NOUT,*) * Skip heading in data file READ (NIN,*) * * Read algorithmic parameters * READ (NIN,*) N IF (N.LE.NMAX) THEN READ (NIN,*) NNZ READ (NIN,*) METHOD, PRECON READ (NIN,*) OMEGA READ (NIN,*) M, TOL, MAXITN * * Check size of workspace * L = N IF (PRECON.EQ.'N' .OR. PRECON.EQ.'n') L = 0 LWREQ = MAX(4*N+M*(M+N+5)+L+121,8*N+L+120,2*N*(M+3)+M*(M+2) + +L+120,11*N+L+120) IF (LWORK.LT.LWREQ) THEN WRITE (NOUT,*) 'LWORK must be at least', LWREQ GO TO 60 END IF * * Read the matrix A * DO 20 I = 1, NNZ READ (NIN,*) A(I), IROW(I), ICOL(I) 20 CONTINUE * * Read rhs vector b and initial approximate solution x * READ (NIN,*) (B(I),I=1,N) READ (NIN,*) (X(I),I=1,N) * * Solve Ax = b using F11DSF * IFAIL = 1 CALL F11DSF(METHOD,PRECON,N,NNZ,A,IROW,ICOL,OMEGA,B,M,TOL, + MAXITN,X,RNORM,ITN,WORK,LWORK,IWORK,IFAIL) * IF (IFAIL.EQ.0) THEN WRITE (NOUT,99999) ITN WRITE (NOUT,99998) RNORM WRITE (NOUT,*) * * Output x * WRITE (NOUT,*) ' X' DO 40 I = 1, N WRITE (NOUT,99997) X(I) 40 CONTINUE ELSE WRITE (NOUT,99996) IFAIL END IF * END IF 60 CONTINUE * 99999 FORMAT (1X,'Converged in',I10,' iterations') 99998 FORMAT (1X,'Final residual norm =',1P,E16.3) 99997 FORMAT (1X,'(',1P,E16.4,',',1P,E16.4,')') 99996 FORMAT (1X,/1X,' ** F11DSF returned with IFAIL = ',I5) END