program main ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c Usage: testio < datafile.mtx c testio datafile.mtx c gunzip -c datafile.mtx.z | testio c c Note: make 'testio' executable with: f77 -o testio testio.f mmio.f c c This sample driver takes a matrix market file as standard input, c or opens a the specified file if a filename argument is present, c and calls two routines: c c call mminfo(iunit,rep,field,symm,nrows,ncols,nnz) c and c call mmread(iunit,rep,field,symm,nrows,ncols,nnz,nnzmax, c * indx,jndx,ival,rval,cval) c c Subroutine mminfo just parses header information, while mmread parses c the header and reads the numerical data into the appropriate arrays. c each of these requires a pre-opened read unit (iunit), and c rewinds the unit prior to return. (so mminfon doesn't interfere c with mmread and vice versa). c c 18-Oct-96 Karin A. Remington, NIST ACMD (karin@cam.nist.gov) c 30-Oct-96 Minor change to calling sequences to accommodate new c integer value parameter (ival) c + associated changes to check for integer value data ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc integer nnzmax integer iunit,ounit character rep*10 character field*7 character symm*19 character ifile*32,ofile*32 parameter (nnzmax=100000) integer ival(nnzmax) double precision rval(nnzmax) complex cval(nnzmax) integer indx(nnzmax) integer jndx(nnzmax) c if (iargc() .gt. 0) then call getarg(1,ifile) iunit = 8 open(unit=iunit,file=ifile) else iunit = 5 endif print *,'Reading header only...' call mminfo(iunit,rep,field,symm,nrows,ncols,nnz) print *,' Matrix is type: ',rep,' ',field,' ',symm print *,' Matrix size: ',nrows,' by ',ncols,' with ', * nnz,' nonzeros.' c print *,'Reading header and data...' call mmread(iunit,rep,field,symm,nrows,ncols,nnz,nnzmax, * indx,jndx,ival,rval,cval) print *,' Matrix is type: ',rep,' ',field,' ',symm print *,' Matrix size: ',nrows,' by ',ncols,' with ', * nnz,' nonzeros.' c if( rep .eq. 'array' ) then print *,' Dense array.' print *,' First two entries:' if ( field .eq. 'integer' ) then print *,(ival(i),i=1,2) elseif ( field .eq. 'real') then print *,(rval(i),i=1,2) elseif ( field .eq. 'complex' ) then print *,(cval(i),i=1,2) endif else print *,' Sparse (coordinate) array.' print *,' First two entries:' if ( field .eq. 'integer' ) then print *,indx(1),jndx(1),ival(1) print *,indx(2),jndx(2),ival(2) elseif ( field .eq. 'real') then print *,indx(1),jndx(1),rval(1) print *,indx(2),jndx(2),rval(2) elseif ( field .eq. 'complex' ) then print *,indx(1),jndx(1),cval(1) print *,indx(2),jndx(2),cval(2) elseif ( field .eq. 'pattern' ) then print *,indx(1),jndx(1) print *,indx(2),jndx(2) endif endif if (iargc() .gt. 1) then call getarg(2,ofile) ounit = 9 open(unit=ounit,file=ofile) print *,'Writing header and data...' call mmwrite(ounit,rep,field,symm,nrows,ncols,nnz, * indx,jndx,ival,rval,cval) close(9) print *,'Done writing to file: ',ofile endif stop end