9.5 mm_mat_write — Write a sparse matrix to a file in the MatrixMarket format

call mm_mat_write(a, mtitle, iret, iunit, filename)

Type:
Asynchronous.
On Entry
a
the sparse matrix to be written.
Type:required.
Specified as: a structured data of type psb_Tspmat_type.
mtitle
Matrix title.
Type: required
A charachter variable holding a descriptive title for the matrix to be written to file.
filename
The name of the file to be written to.
Type:optional.
Specified as: a character variable containing a valid file name, or -, in which case the default output unit 6 (i.e. standard output in Unix jargon) is used. Default: -.
iunit
The Fortran file unit number.
Type:optional.
Specified as: an integer value. Only meaningful if filename is not -.

On Return
iret
Error code.
Type: required
An integer value; 0 means no error has been detected.

Notes

If this function is called on a matrix a on a distributed communicator only the local part is written in output. To get a single MatrixMarket file with the whole matrix when appropriate, e.g. for debugging purposes, one could gather the whole matrix on a single rank and then write it. Consider the following example for a double precision matrix

type(psb_ldspmat_type) :: aglobal
call psb_gather(aglobal,a,desc_a,info)
if (iam == psb_root_) then
call mm_mat_write(aglobal,mtitle,info,filename)
end if
call psb_spfree(aglobal, desc_a, info)

To simplify this procedure in C, there is a utility function

psb_i_t psb_c_<s,d,c,z>global_mat_write(ah,cdh);

that produces exactly this result.