*     F11JSF 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=7*NMAX+120)
*     .. Local Scalars ..
      DOUBLE PRECISION OMEGA, RNORM, TOL
      INTEGER          I, IFAIL, ITN, MAXITN, N, NNZ
      CHARACTER        PRECON
      CHARACTER*6      METHOD
*     .. Local Arrays ..
      COMPLEX *16      A(LA), B(NMAX), WORK(LWORK), X(NMAX)
      DOUBLE PRECISION RDIAG(NMAX)
      INTEGER          ICOL(LA), IROW(LA), IWORK(NMAX+1)
*     .. External Subroutines ..
      EXTERNAL         F11JSF
*     .. Executable Statements ..
      WRITE (NOUT,*) 'F11JSF Example Program Results'
*     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,*) TOL, MAXITN
*
*        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 F11JSF
*
         IFAIL = 0
         CALL F11JSF(METHOD,PRECON,N,NNZ,A,IROW,ICOL,OMEGA,B,TOL,MAXITN,
     +               X,RNORM,ITN,RDIAG,WORK,LWORK,IWORK,IFAIL)
*
         WRITE (NOUT,99999) 'Converged in', ITN, ' iterations'
         WRITE (NOUT,99998) 'Final residual norm =', RNORM
*
*        Output x
*
         DO 40 I = 1, N
            WRITE (NOUT,99997) X(I)
   40    CONTINUE
      END IF
      STOP
*
99999 FORMAT (1X,A,I10,A)
99998 FORMAT (1X,A,1P,D16.3)
99997 FORMAT (1X,'(',D16.4,',',D16.4,')')
      END
