/[escript]/trunk/esys2/finley/src/finleyC/System_saveMM.c
ViewVC logotype

Contents of /trunk/esys2/finley/src/finleyC/System_saveMM.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 97 - (show annotations)
Tue Dec 14 05:39:33 2004 UTC (14 years, 11 months ago) by jgs
File MIME type: text/plain
File size: 2940 byte(s)
*** empty log message ***

1 /* $Id$ */
2
3 /**************************************************************/
4
5 /* Finley: SystemMatrix is saved to Matrix Market format */
6
7 /**************************************************************/
8
9 /* Copyrights by ACcESS Australia 2003,2004 */
10 /* Author: davies@access.edu.au */
11
12 /**************************************************************/
13
14 #include "Finley.h"
15 #include "mmio.h"
16 #include "System.h"
17
18 void Finley_SystemMatrix_saveMM(Finley_SystemMatrix * A_p, char * fileName_p) {
19
20 int iRow, iCol, iPtr,ir,ic;
21
22 /* open the file */
23 FILE * fileHandle_p = fopen(fileName_p, "w");
24 if (fileHandle_p==NULL) {
25 Finley_ErrorCode =IO_ERROR;
26 sprintf(Finley_ErrorMsg, "file %s could not be opened for writing",fileName_p);
27 return;
28 }
29
30 /* set the matrix code */
31 MM_typecode matrixCode;
32 mm_initialize_typecode(&matrixCode);
33 mm_set_matrix(&matrixCode);
34 mm_set_coordinate(&matrixCode);
35 mm_set_real(&matrixCode);
36
37 mm_write_banner(fileHandle_p, matrixCode);
38 mm_write_mtx_crd_size(fileHandle_p, A_p->num_rows*A_p->row_block_size, A_p->num_cols*A_p->col_block_size,A_p->len);
39
40 switch(A_p->type) {
41 case CSR:
42 for (iRow = 0; iRow< A_p->pattern->n_ptr; iRow++) {
43 for (ir = 0; ir< A_p->row_block_size; ir++) {
44 for (iPtr = A_p->pattern->ptr[iRow] - PTR_OFFSET;iPtr < A_p->pattern->ptr[iRow+1] - PTR_OFFSET; iPtr++) {
45 for (ic = 0; ic< A_p->col_block_size; ic++) {
46 fprintf(fileHandle_p, "%12d %12d %22.15g\n",
47 iRow*A_p->row_block_size+ir+ 1,
48 (A_p->pattern->index[iPtr]-INDEX_OFFSET)*A_p->col_block_size+ic+1,
49 A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);
50 }
51 }
52 }
53 }
54 break;
55 case CSC:
56 for (iCol = 0; iCol< A_p->pattern->n_ptr; iCol++) {
57 for (ic = 0; ic< A_p->col_block_size; ic++) {
58 for (iPtr = A_p->pattern->ptr[iCol] - PTR_OFFSET;iPtr < A_p->pattern->ptr[iCol+1] - PTR_OFFSET; iPtr++) {
59 for (ir = 0; ir< A_p->row_block_size; ir++) {
60 fprintf(fileHandle_p, "%12d %12d %22.15g\n",
61 (A_p->pattern->index[iPtr]-INDEX_OFFSET)*A_p->row_block_size+ir+1,
62 iCol*A_p->col_block_size+ic+ 1,
63 A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);
64 }
65 }
66 }
67 }
68 }
69
70 /* close the file */
71 fclose(fileHandle_p);
72
73 return;
74 }
75 /*
76 * $Log$
77 * Revision 1.2 2004/12/14 05:39:31 jgs
78 * *** empty log message ***
79 *
80 * Revision 1.1.1.1.2.1 2004/11/12 06:58:19 gross
81 * a lot of changes to get the linearPDE class running: most important change is that there is no matrix format exposed to the user anymore. the format is chosen by the Domain according to the solver and symmetry
82 *
83 * Revision 1.1.1.1 2004/10/26 06:53:57 jgs
84 * initial import of project esys2
85 *
86 * Revision 1.1 2004/07/02 04:21:13 gross
87 * Finley C code has been included
88 *
89 *
90 */

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26