* F11DKF Example Program Text * Mark 20 Release. NAG Copyright 2001. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER NMAX, LA, LWORK PARAMETER (NMAX=1000,LA=10000,LWORK=10*NMAX) * .. Local Scalars .. DOUBLE PRECISION ANORM, SIGMAX, STPLHS, STPRHS, TOL INTEGER I, IFAIL, IFAIL1, IREVCM, ITERM, ITN, LWREQ, M, + MAXITN, MONIT, N, NITER, NNZ CHARACTER INIT, NORM, PRECON, WEIGHT CHARACTER*8 METHOD * .. Local Arrays .. DOUBLE PRECISION A(LA), B(NMAX), DIAG(NMAX), WGT(NMAX), + WORK(LWORK), X(NMAX) INTEGER ICOL(LA), IROW(LA) * .. External Subroutines .. EXTERNAL F11BDF, F11BEF, F11BFF, F11DKF, F11XAF * .. Executable Statements .. WRITE (NOUT,*) 'F11DKF Example Program Results' * * Skip heading in data file * READ (NIN,*) READ (NIN,*) N IF (N.GT.NMAX) THEN WRITE (NOUT,'(A,I5)') ' N is too large, N =', N WRITE (NOUT,'(A,I5)') ' N must be less than ', NMAX GO TO 60 END IF * * Read or initialize the parameters for the iterative solver * READ (NIN,*) METHOD READ (NIN,*) PRECON, NORM, WEIGHT, ITERM READ (NIN,*) M, TOL, MAXITN READ (NIN,*) MONIT ANORM = 0.0D0 SIGMAX = 0.0D0 * * Read the parameters for the preconditioner * READ (NIN,*) NITER * * Read the number of non-zero elements of the matrix A, then read * the non-zero elements * READ (NIN,*) NNZ DO 20 I = 1, NNZ READ (NIN,*) A(I), IROW(I), ICOL(I) 20 CONTINUE * * Read right-hand side vector b and initial approximate solution * READ (NIN,*) (B(I),I=1,N) READ (NIN,*) (X(I),I=1,N) * * Call F11BDF to initialize the solver * IFAIL = 1 CALL F11BDF(METHOD,PRECON,NORM,WEIGHT,ITERM,N,M,TOL,MAXITN,ANORM, + SIGMAX,MONIT,LWREQ,WORK,LWORK,IFAIL) IF (IFAIL.NE.0) THEN WRITE (NOUT,99993) IFAIL GO TO 60 END IF * * Call repeatedly F11BEF to solve the equations * Note that the arrays B and X are overwritten * * On final exit, X will contain the solution and B the residual * vector * IFAIL = 1 IREVCM = 0 INIT = 'I' * 40 CONTINUE CALL F11BEF(IREVCM,X,B,WGT,WORK,LWREQ,IFAIL) IF (IREVCM.NE.4) THEN IFAIL1 = -1 IF (IREVCM.EQ.-1) THEN CALL F11XAF('Transpose',N,NNZ,A,IROW,ICOL,'No checking',X,B, + IFAIL1) ELSE IF (IREVCM.EQ.1) THEN CALL F11XAF('No transpose',N,NNZ,A,IROW,ICOL,'No checking', + X,B,IFAIL1) ELSE IF (IREVCM.EQ.2) THEN CALL F11DKF('Non symmetric','N',INIT,NITER,N,NNZ,A,IROW, + ICOL,'Check',X,B,DIAG,WORK(LWREQ+1),IFAIL1) INIT = 'N' ELSE IF (IREVCM.EQ.3) THEN IFAIL1 = 0 CALL F11BFF(ITN,STPLHS,STPRHS,ANORM,SIGMAX,WORK,LWREQ, + IFAIL1) WRITE (NOUT,99999) ITN, STPLHS END IF IF (IFAIL1.NE.0) IREVCM = 6 GO TO 40 ELSE IF (IFAIL.NE.0) THEN WRITE (NOUT,99992) IFAIL GO TO 60 END IF * * Obtain information about the computation * IFAIL1 = 0 CALL F11BFF(ITN,STPLHS,STPRHS,ANORM,SIGMAX,WORK,LWREQ,IFAIL1) * * Print the output data * WRITE (NOUT,99996) WRITE (NOUT,99995) 'Number of iterations for convergence: ', + ITN WRITE (NOUT,99994) 'Residual norm: ', + STPLHS WRITE (NOUT,99994) 'Right-hand side of termination criterion:', + STPRHS WRITE (NOUT,99994) '1-norm of matrix A: ', + ANORM * * Output x * WRITE (NOUT,99998) WRITE (NOUT,99997) (X(I),B(I),I=1,N) 60 CONTINUE * 99999 FORMAT (/1X,'Monitoring at iteration no.',I4,/1X,1P,'residual no', + 'rm: ',E14.4) 99998 FORMAT (/2X,' Solution vector',2X,' Residual vector') 99997 FORMAT (1X,1P,E16.4,1X,E16.4) 99996 FORMAT (/1X,'Final Results') 99995 FORMAT (1X,A,I4) 99994 FORMAT (1X,A,1P,E14.4) 99993 FORMAT (1X,/1X,' ** F11BDF returned with IFAIL = ',I5) 99992 FORMAT (1X,/1X,' ** F11BEF returned with IFAIL = ',I5) END