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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1028 by gross, Wed Mar 14 00:15:24 2007 UTC revision 1312 by ksteube, Mon Sep 24 06:18:44 2007 UTC
# Line 1  Line 1 
1    
2  /* $Id$ */  /* $Id$ */
3    
4  /*  /*******************************************************
5  ********************************************************************************   *
6  *               Copyright   2006 by ACcESS MNRF                                *   *           Copyright 2003-2007 by ACceSS MNRF
7  *                                                                              *   *       Copyright 2007 by University of Queensland
8  *                 http://www.access.edu.au                                     *   *
9  *           Primary Business: Queensland, Australia                            *   *                http://esscc.uq.edu.au
10  *     Licensed under the Open Software License version 3.0             *   *        Primary Business: Queensland, Australia
11  *        http://www.opensource.org/licenses/osl-3.0.php                        *   *  Licensed under the Open Software License version 3.0
12  ********************************************************************************   *     http://www.opensource.org/licenses/osl-3.0.php
13  */   *
14     *******************************************************/
15    
16  /**************************************************************/  /**************************************************************/
17    
# Line 22  Line 24 
24    
25  /**************************************************************/  /**************************************************************/
26    
 #include "Paso.h"  
 #include "mmio.h"  
27  #include "SystemMatrix.h"  #include "SystemMatrix.h"
28    
29  void Paso_SystemMatrix_saveMM(Paso_SystemMatrix * A_p, char * fileName_p) {  void Paso_SystemMatrix_saveMM(Paso_SystemMatrix * A_p, char * fileName_p) {
   
   int iRow, iCol, iPtr,ir,ic;  
   index_t index_offset=(A_p->type & MATRIX_FORMAT_OFFSET1 ? 1:0);  
30    FILE * fileHandle_p = NULL;    FILE * fileHandle_p = NULL;
   MM_typecode matrixCode;  
31    
32      if (A_p->mpi_info->size > 1) {
33           Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_saveHB: currently single processor runs are supported.\n");
34           return;
35      }
36    if (A_p->type & MATRIX_FORMAT_SYM) {    if (A_p->type & MATRIX_FORMAT_SYM) {
37      Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_saveMM does not support symmetric storage scheme");      Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_saveMM does not support symmetric storage scheme");
38      return;      return;
# Line 44  void Paso_SystemMatrix_saveMM(Paso_Syste Line 44  void Paso_SystemMatrix_saveMM(Paso_Syste
44      return;      return;
45    }    }
46    
   /* set the matrix code */  
   mm_initialize_typecode(&matrixCode);  
   mm_set_matrix(&matrixCode);  
   mm_set_coordinate(&matrixCode);  
   mm_set_real(&matrixCode);  
     
   mm_write_banner(fileHandle_p, matrixCode);  
   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);  
   
47    if (A_p->type & MATRIX_FORMAT_CSC) {    if (A_p->type & MATRIX_FORMAT_CSC) {
48        for (iCol = 0; iCol< A_p->pattern->n_ptr; iCol++) {      Paso_SparseMatrix_saveHB_CSC( A_p->mainBlock,fileHandle_p);
          for (ic = 0; ic< A_p->col_block_size; ic++) {  
         for (iPtr = A_p->pattern->ptr[iCol] - index_offset;iPtr < A_p->pattern->ptr[iCol+1] - index_offset; iPtr++) {  
                for (ir = 0; ir< A_p->row_block_size; ir++) {  
               fprintf(fileHandle_p, "%12d %12d %e\n",  
                   (A_p->pattern->index[iPtr]-index_offset)*A_p->row_block_size+ir+1,  
                   iCol*A_p->col_block_size+ic+ 1,  
                   A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);  
                }  
             }  
          }  
       }  
49    } else {    } else {
50        for (iRow = 0; iRow< A_p->pattern->n_ptr; iRow++) {      /* Paso_SparseMatrix_saveHB_CSR( A_p->mainBlock,fileHandle_p); */
51           for (ir = 0; ir< A_p->row_block_size; ir++) {      Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_saveMM does not support CSR yet.");
52          for (iPtr = A_p->pattern->ptr[iRow] - index_offset;iPtr < A_p->pattern->ptr[iRow+1] - index_offset; iPtr++) {      return;
                for (ic = 0; ic< A_p->col_block_size; ic++) {  
               fprintf(fileHandle_p, "%12d %12d %e\n",  
                   iRow*A_p->row_block_size+ir+ 1,  
                   (A_p->pattern->index[iPtr]-index_offset)*A_p->col_block_size+ic+1,  
                   A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);  
                }  
             }  
          }  
       }  
53    }    }
54    
55    /* close the file */    /* close the file */
# Line 86  void Paso_SystemMatrix_saveMM(Paso_Syste Line 57  void Paso_SystemMatrix_saveMM(Paso_Syste
57        
58    return;    return;
59  }  }
   
 /*  
  * $Log$  
  * Revision 1.2  2005/09/15 03:44:39  jgs  
  * Merge of development branch dev-02 back to main trunk on 2005-09-15  
  *  
  * Revision 1.1.2.1  2005/09/05 06:29:48  gross  
  * These files have been extracted from finley to define a stand alone libray for iterative  
  * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but  
  * has not been tested yet.  
  *  
  *  
  */  

Legend:
Removed from v.1028  
changed lines
  Added in v.1312

  ViewVC Help
Powered by ViewVC 1.1.26