The Matrix Market

MatrixMarket I/O Functions for Fortran (F77/F90)

Matrix Market provides Fortran subroutines for three basic Matrix Market file I/O functions: mminfo, mmread, and mmwrite. All subroutines are contained in the file mmio.f. A sample driver program is provided in testio.f.


30-Oct-96 Update Note:

These routines were updated to apply bug fixes and incorporate additional input validation. Please try the new verion of mmio.f and report any problems via email to Matrix Market.

(Thanks to G.P.Leendetse and H.Oudshoom for their review of the initial version and suggested fixes.)


mminfo

Calling sequence: subroutine mminfo(iunit,rep,field,symm,rows,cols,entries)
Description: Queries the contents of the Matrix Market file connected to the unit iunit to extract size and storage information.

In the case of coordinate matrices, entries refers to the number of coordinate entries stored in the file.

In the case of array matrices, entries is the product rows*cols for nonsymmetric matrices, and ((rows*cols - rows)/2 + rows if symmetry was used to store the matrix efficiently.

entries can be used to determine storage requirements in the calling program.

The unit iunit must be open, and the file will be rewound on return.

Arguments:
nametype in/outdescription
iunit integer in Unit identifier for the open file containing the data to be read.
rep character*10 out Matrix Market 'representation' indicator.
On return:

coordinate (for sparse data)
array (for dense data)
elemental (to be added)
field character*7 out Matrix Market 'field'.
On return:

real
complex
integer
pattern
symm character*19 out Matrix Market 'field'.
On return:

symmetric
hermitian
skew-symmetric
general
rows integer out Number of rows in matrix.
cols integer out Number of columns in matrix.
entries integer out Number of nonzero entries required to store matrix.


mmread

Calling sequence: subroutine mmread(iunit,rep,field,symm,rows,cols,entries,nnzmax,
indx, jndx, rval, cval)
Description: Reads the contents of the Matrix Market file connected to the unit iunit into the storage arrays provided.

In the case of coordinate matrices, entries refers to the number of coordinate entries stored in the file.

In the case of array matrices, entries is the product rows*cols for nonsymmetric matrices, and ((rows*cols - rows)/2 + rows if symmetry was used to store the matrix efficiently.

nnzmax is used ensure that the storage arrays are large enough to hold the required data. nnzmax should therefore reflect the actual dimension of the storage arrays as declared.

The unit iunit must be open, and the file will be rewound on return.

Arguments:
nametype in/outdescription
iunit integer in Unit identifier for the open file containing the data to be read.
rep character*10 out Matrix Market 'representation' indicator.
On return:

coordinate (for sparse data)
array (for dense data)
elemental (to be added)
field character*7 out Matrix Market 'field'.
On return:

real
complex
integer
pattern
symm character*19 out Matrix Market 'field'.
On return:

symmetric
hermitian
skew-symmetric
general
rows integer out Number of rows in matrix.
cols integer out Number of columns in matrix.
entries integer out Number of nonzero entries required to store matrix.
nnzmax integer in Dimension of the arrays indx, jndx, etc. as declared.
indx integer(nnz) out Array containing the row indices of the nonzero entries of a coordinate matrix.
Unchanged if the matrix is stored in array format.
jndx integer(nnz) out Array containing the column indices of the nonzero entries of a coordinate matrix.
Unchanged if the matrix is stored in array format.
rval double precision(nnz) out Array containing the values of the nonzero entries of a real or integer matrix.
Unchanged if the matrix is pattern or complex.
cval double precision(nnz) out Array containing the values of the nonzero entries of a complex matrix.
Unchanged if the matrix is real, integer, or pattern.


mmwrite

Calling sequence: subroutine mmwrite(ounit,rep,field,symm,rows,cols,entries,
indx, jndx, rval, cval)
Description: Writes matrix data to a Matrix Market formatted file connected to the unit ounit.

In the case of coordinate matrices, entries number of nonzero values to be stored.

In the case of array matrices, entries is the product rows*cols for nonsymmetric matrices, and ((rows*cols - rows)/2 + rows if symmetry was used to store the matrix efficiently.

The unit ounit must be open, and the file will be rewound on return.

Arguments:
nametype in/outdescription
ounit integer in Unit identifier for the open file to which the data will be written.
rep character*10 in Matrix Market 'representation' indicator.
On return:

coordinate (for sparse data)
array (for dense data)
elemental (to be added)
field character*7 in Matrix Market 'field'.
On return:

real
complex
integer
pattern
symm character*19 in Matrix Market 'field'.
On return:

symmetric
hermitian
skew-symmetric
general
rows integer in Number of rows in matrix.
cols integer in Number of columns in matrix.
entries integer in Number of nonzero entries required to store matrix.
indx integer(nnz) in Array containing the row indices of the nonzero entries of a coordinate matrix.
Ignored if the matrix to be stored is in array format.
jndx integer(nnz) in Array containing the column indices of the nonzero entries of a coordinate matrix.
Ignored if the matrix to be stored is in array format.
rval double precision(nnz) in Array containing the values of the nonzero entries of a real or integer matrix.
Ignored if the matrix is pattern or complex.
cval double precision(nnz) in Array containing the values of the nonzero entries of a complex matrix.
Ignored if the matrix is real, integer, or pattern.


Updates:

30-Oct-96Bug fixes in mmio.f:
  • changed looping structure for comment lines for better portability
  • fixed non-ansi zero stringlength
  • fixed size calculation for skew-symmetric arrays
Other changes in mmio.f:
  • added integer value parameter to calling sequences
  • enforced proper count in size info line
  • added routine to count words in string (countwd)