      SUBROUTINE PardisoTestSub

      IMPLICIT NONE
       include 'mkl_pardiso.fi'

      TYPE(MKL_PARDISO_HANDLE) pt(64)
      INTEGER    i,j
      INTEGER    maxfct,mnum,mtype,phase,n,nrhs,msglvl,error
      INTEGER    iparm(64)
      CHARACTER  buf*256

      INTEGER    ia(66),ja(252),perm(65)
      REAL*8     a(252),b(65),x(65)

      maxfct=1
      mnum=1
      mtype=2
      phase=13
      n=65
      nrhs=1
      msglvl=0
      DO i=1,n
         perm(i)=0
      ENDDO

c     Initialize the output parameters
C      do j=1,nrhs
         do i=1,n
            x(i)=0.0d0
         enddo
C      enddo
      error=0

c     Read the data that gets passed to Pardiso for this test
C      open(98,FILE='C:\Work\PardisoData.TXT')
      open(98,FILE='PardisoData.TXT')
      read(98,*)
      read(98,*) a
      read(98,*)
      read(98,*) ia
      read(98,*)
      read(98,*) ja
      read(98,*)
      read(98,*) b
      close(98)

      CALL PardisoInit (pt, mtype, iparm)
c  iparm(2) == 0 works. 2 and 3 - fails.. 
      iparm(2)  = 2;   
      iparm(27) = 1;
      phase=11  ! Analyse, factorize and solve

      CALL Pardiso (pt, maxfct, mnum, mtype, phase, n, a, ia, ja
     c             ,perm, nrhs, iparm, msglvl, b, x, error)

      phase=-1  ! Release memory
      CALL Pardiso (pt, maxfct, mnum, mtype, phase, n, a, ia, ja
     c             ,perm, nrhs, iparm, msglvl, b, x, error)

      CALL mkl_get_version_string(buf)

c     Save the results
c_gf      open(98,FILE='C:\Work\PardisoResults.TXT')
c_gf      write(98,*) buf
c_gf      do j=1,nrhs
c_gf         write(98,*) 'x() for rhs ',j,':'
c_gf         write(98,*) 'x() for rhs ',j,':'
c_gf         write(98,*) 'x() for rhs ',j,':'
c_gf         write(98,*) (x(i,j),i=1,n)
c_gf      enddo
c_gf      close(98)

      RETURN
      END
