/[escript]/trunk/paso/src/SystemMatrix_saveMM.c
ViewVC logotype

Contents of /trunk/paso/src/SystemMatrix_saveMM.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1369 - (show annotations)
Fri Dec 21 05:51:44 2007 UTC (11 years, 10 months ago) by gross
File MIME type: text/plain
File size: 2483 byte(s)
does something now!
1
2 /* $Id$ */
3
4 /*******************************************************
5 *
6 * Copyright 2003-2007 by ACceSS MNRF
7 * Copyright 2007 by University of Queensland
8 *
9 * http://esscc.uq.edu.au
10 * Primary Business: Queensland, Australia
11 * Licensed under the Open Software License version 3.0
12 * http://www.opensource.org/licenses/osl-3.0.php
13 *
14 *******************************************************/
15
16 /**************************************************************/
17
18 /* Paso: SystemMatrix is saved to Matrix Market format */
19
20 /**************************************************************/
21
22 /* Copyrights by ACcESS Australia 2003,2004 */
23 /* Author: davies@access.edu.au */
24
25 /**************************************************************/
26
27 #include "SystemMatrix.h"
28 #include "mmio.h"
29
30 void Paso_SystemMatrix_saveMM(Paso_SystemMatrix * A_p, char * fileName_p) {
31 FILE * fileHandle_p = NULL;
32 dim_t N,M,i, iptr_ij;
33 MM_typecode matcode;
34
35 if (A_p->mpi_info->size > 1) {
36 Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_saveMM: currently single processor runs are supported.\n");
37 return;
38 }
39 if (A_p->block_size>1) {
40 Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_saveMM: currently only block size 1 is supported.\n");
41 return;
42 }
43
44 if (A_p->type & MATRIX_FORMAT_SYM) {
45 Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_saveMM does not support symmetric storage scheme");
46 return;
47 }
48 /* open the file */
49 fileHandle_p = fopen(fileName_p, "w");
50 if (fileHandle_p==NULL) {
51 Paso_setError(IO_ERROR,"file could not be opened for writing");
52 return;
53 }
54
55 if (A_p->type & MATRIX_FORMAT_CSC) {
56 Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_saveMM does not support CSC yet.");
57 } else {
58 mm_initialize_typecode(&matcode);
59 mm_set_matrix(&matcode);
60 mm_set_coordinate(&matcode);
61 mm_set_real(&matcode);
62
63 N= Paso_SystemMatrix_getGlobalNumRows(A_p);
64 M=Paso_SystemMatrix_getGlobalNumCols(A_p);
65 mm_write_banner(fileHandle_p, matcode);
66 mm_write_mtx_crd_size(fileHandle_p, N, M, A_p->mainBlock->pattern->ptr[N]);
67
68 for (i=0; i<N; i++) {
69 for (iptr_ij=A_p->mainBlock->pattern->ptr[i];iptr_ij<A_p->mainBlock->pattern->ptr[i+1]; ++iptr_ij) {
70 fprintf(fileHandle_p, "%d %d %25.15e\n", i+1, A_p->mainBlock->pattern->index[iptr_ij]+1, A_p->mainBlock->val[iptr_ij]);
71 }
72 }
73 }
74
75 /* close the file */
76 fclose(fileHandle_p);
77
78 return;
79 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26