thank you very much, Aldo.<br><br><div><span class="gmail_quote">On 1/23/08, <b class="gmail_sendername">Aldo Bonfiglioli</b> <<a href="mailto:aldo.bonfiglioli@unibas.it">aldo.bonfiglioli@unibas.it</a>> wrote:</span>
<blockquote class="gmail_quote" style="margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; margin-left: 0.80ex; border-left-color: #cccccc; border-left-width: 1px; border-left-style: solid; padding-left: 1ex">
> thank you for your reply. Do you have any method to generate an ascii<br>> file of the huge sparse matrix? thanks<br><br><br>I have been using HYPRE calls (from PETSc) to accomplish this.<br>Each processor will write his own portion of the global matrix
<br>in his own file.<br>The enclosed file should explain how.<br><br>Regards,<br>Aldo<br><br>--<br>Dr. Aldo Bonfiglioli<br><a href="http://Dip.to">Dip.to</a> di Ingegneria e Fisica dell'Ambiente (DIFA)<br>Universita' della Basilicata
<br>V.le dell'Ateneo lucano, 10 85100 Potenza ITALY<br>tel:+39.0971.205203 fax:+39.0971.205160<br><br><br> SUBROUTINE PrintMat(A,RHS,X,cols,values,maxcols,ITER,JOB)<br>C<br> IMPLICIT NONE<br>C<br>CC#define HYPER_PARCSR 5555
<br>C<br>C<br>C<br>C<br>C $Id: printmat.F,v 1.3 2006/11/10 08:31:31 abonfi Exp abonfi $<br>C<br>#include "include/finclude/petsc.h"<br>#include "include/finclude/petscvec.h"<br>#include "include/finclude/petscmat.h"
<br>#include "include/finclude/petscksp.h"<br>#include "include/finclude/petscpc.h"<br>#include "include/finclude/petscis.h"<br>#include "include/finclude/petscviewer.h"<br>C#include "
HYPRE.h"<br>C#include "IJ_mv.h"<br><br>C<br> Mat A<br> Vec RHS,X<br> INTEGER ITER,JOB<br> INTEGER rstart,rend,ncols,i,k<br> INTEGER HYPRE_PARCSR<br> parameter(HYPRE_PARCSR=5555)
<br> INTEGER maxcols<br> integer cols(maxcols)<br> double precision values(maxcols)<br> double precision info(MAT_INFO_SIZE)<br> INTEGER nz_a<br>C<br>C<br>C<br>C<br>C .. Parameters ..<br>C ..
<br>C .. Scalar Arguments ..<br>C ..<br>C .. Arrays in Common ..<br>C ..<br>C .. Local Scalars ..<br> INTEGER IFAIL,MY_PE<br>C ..<br>C .. Local Arrays ..<br> PetscViewer MyOpenMindedViewer
<br> INTEGER*8 ij<br> CHARACTER* 6 matfile,rhsfile,solfile<br> PetscScalar x_array(1)<br> PetscOffset i_x<br> PetscInt n<br>! PetscErrorCode IFAIL<br><br>C ..<br>C .. External Functions ..
<br>C ..<br>C .. External Subroutines ..<br>C ..<br>C<br>C .. Intrinsic Functions ..<br>C ..<br>C .. Common blocks ..<br> COMMON /MPICOM/MY_PE<br>C ..<br>C .. Equivalences ..<br>C ..
<br>C .. Data statements ..<br> DATA matfile,rhsfile,solfile/"matXXX","rhsXXX","solXXX"/<br>C ..<br>C Executable statements<br>C<br> IF(JOB.EQ.0)THEN<br> call MatGetInfo(A,MAT_LOCAL,info,IFAIL)
<br> nz_a = info(MAT_INFO_NZ_ALLOCATED)<br> maxcols = info(MAT_INFO_COLUMNS_LOCAL)<br> CALL VecGetLocalSize(rhs,n,IFAIL)<br> maxcols = max(maxcols,n)<br> write(6,*)'PE # ',MY_PE,nz_a,maxcols,n
<br> RETURN<br> ENDIF<br>C<br> IF( ITER. NE. 3 )RETURN<br>C<br> WRITE(matfile(4:6),FMT="(I3.3)")0<br> WRITE(rhsfile(4:6),FMT="(I3.3)")0<br> WRITE(solfile(4:6),FMT="(
I3.3)")0<br> CALL MatGetOwnershipRange(A,rstart,rend,IFAIL)<br> CALL HYPRE_IJMatrixCreate(PETSC_COMM_WORLD,rstart,rend-1,rstart,<br> &rend-1,ij,IFAIL)<br>! write(6,*)'HYPRE_IJMatrixCreate has returned ifail = ',ifail
<br> CALL HYPRE_IJMatrixSetObjectType(ij,HYPRE_PARCSR,IFAIL)<br>! write(6,*)'HYPRE_IJMatrixSetObjectType has returned ifail = ',<br>! &ifail<br> CALL HYPRE_IJMatrixInitialize(ij,IFAIL)<br>! write(6,*)'HYPRE_IJMatrixInitialize has returned ifail = ',
<br>! &ifail<br> do i= rstart, rend-1<br> CALL MatGetRow(A,i,ncols,cols,values,IFAIL)<br> if(ncols.GT.maxcols)STOP 'Must increase maxcols'<br> CALL HYPRE_IJMatrixSetValues(ij,1,ncols,i,cols,values,IFAIL)
<br> CALL MatRestoreRow(A,i,ncols,cols,values,IFAIL)<br> enddo<br> CALL HYPRE_IJMatrixAssemble(ij,IFAIL)<br> CALL HYPRE_IJMatrixPrint(ij,matfile,IFAIL)<br>! write(6,*)'HYPRE_IJMatrixPrint has returned ifail = ',
<br>! &ifail<br> CALL HYPRE_IJMatrixDestroy(ij,IFAIL)<br>! write(6,*)'HYPRE_IJMatrixDestroy has returned ifail = ',<br>! &ifail<br>C<br>C now dump rhs<br>C<br> CALL VecGetOwnerShipRange(rhs,rstart,rend,IFAIL)
<br> CALL HYPRE_IJVectorCreate(PETSC_COMM_WORLD,rstart,rend-1,<br> &ij,IFAIL)<br>! write(6,*)'HYPRE_IJVectorCreate has returned ifail = ',<br>! &ifail<br> CALL HYPRE_IJVectorSetObjectType(ij,HYPRE_PARCSR,IFAIL)
<br>! write(6,*)'HYPRE_IJSetObjectType has returned ifail = ',<br>! &ifail<br> CALL HYPRE_IJVectorInitialize(ij,IFAIL)<br>! write(6,*)'HYPRE_IJVectorInitialize has returned ifail = ',<br>
! &ifail<br> CALL VecGetLocalSize(rhs,n,IFAIL)<br> if(n.GT.maxcols)STOP 'Must increase maxcols'<br> CALL VecGetArray(rhs,x_array,i_x,IFAIL)<br> k = 0<br> do i = rstart,rend-1<br> k = k + 1
<br> cols(k) = i<br> enddo<br>! write(6,*)rend-rstart,n<br> CALL HYPRE_IJVectorSetValues(ij,n,cols,x_array(i_x + 1),IFAIL)<br>! write(6,*)'HYPRE_IJVectorSetValues has returned ifail = ',<br>
! &ifail<br> CALL HYPRE_IJVectorAssemble(ij,IFAIL)<br> CALL VecRestoreArray(rhs,x_array,i_x,IFAIL)<br> CALL HYPRE_IJVectorPrint(ij,rhsfile,IFAIL)<br>! write(6,*)'HYPRE_IJVectorPrint has returned ifail = ',
<br>! &ifail<br> CALL HYPRE_IJVectorDestroy(ij,IFAIL)<br>c<br>c dump solution<br>c<br> CALL VecGetOwnerShipRange(x,rstart,rend,IFAIL)<br> CALL HYPRE_IJVectorCreate(PETSC_COMM_WORLD,rstart,rend-1,
<br> &ij,IFAIL)<br>! write(6,*)'HYPRE_IJVectorCreate has returned ifail = ',<br>! &ifail<br> CALL HYPRE_IJVectorSetObjectType(ij,HYPRE_PARCSR,IFAIL)<br>! write(6,*)'HYPRE_IJSetObjectType has returned ifail = ',
<br>! &ifail<br> CALL HYPRE_IJVectorInitialize(ij,IFAIL)<br>! write(6,*)'HYPRE_IJVectorInitialize has returned ifail = ',<br>! &ifail<br> CALL VecGetLocalSize(x,n,IFAIL)<br> if(n.GT.maxcols
)STOP 'Must increase maxcols'<br> CALL VecGetArray(x,x_array,i_x,IFAIL)<br> k = 0<br> do i = rstart,rend-1<br> k = k + 1<br> cols(k) = i<br> enddo<br> CALL HYPRE_IJVectorSetValues(ij,n,cols,x_array(i_x + 1),IFAIL)
<br>! write(6,*)'HYPRE_IJVectorSetValues has returned ifail = ',<br>! &ifail<br> CALL VecRestoreArray(x,x_array,i_x,IFAIL)<br> CALL HYPRE_IJVectorAssemble(ij,IFAIL)<br> CALL HYPRE_IJVectorPrint(ij,solfile,IFAIL)
<br>! write(6,*)'HYPRE_IJVectorPrint has returned ifail = ',<br>! &ifail<br> CALL HYPRE_IJVectorDestroy(ij,IFAIL)<br> RETURN<br> END<br><br></blockquote></div><br>