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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1388 - (hide annotations)
Fri Jan 11 07:45:58 2008 UTC (11 years, 9 months ago) by trankine
File MIME type: text/plain
File size: 2483 byte(s)
And get the *(&(*&(* name right
1 ksteube 1312
2 jgs 150 /* $Id$ */
3    
4 ksteube 1312 /*******************************************************
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 dhawcroft 631
16 jgs 150 /**************************************************************/
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 gross 1369 #include "mmio.h"
29 jgs 150
30     void Paso_SystemMatrix_saveMM(Paso_SystemMatrix * A_p, char * fileName_p) {
31 gross 1028 FILE * fileHandle_p = NULL;
32 gross 1369 dim_t N,M,i, iptr_ij;
33     MM_typecode matcode;
34 jgs 150
35 ksteube 1312 if (A_p->mpi_info->size > 1) {
36 gross 1369 Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_saveMM: currently single processor runs are supported.\n");
37 ksteube 1312 return;
38     }
39 gross 1369 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 gross 415 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 jgs 150 /* open the file */
49 gross 1028 fileHandle_p = fopen(fileName_p, "w");
50 jgs 150 if (fileHandle_p==NULL) {
51     Paso_setError(IO_ERROR,"file could not be opened for writing");
52     return;
53     }
54    
55 gross 415 if (A_p->type & MATRIX_FORMAT_CSC) {
56 gross 1369 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 jgs 150 }
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