<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.17080" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=483223209-29092010><FONT face=Arial size=2>Dear
Developers,</FONT></SPAN></DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial size=2>I have a Matrix and
a Right Hand Side (RHS) </FONT><FONT face=Arial><FONT size=2>in an ASCII format
stored in 2 different files. I have written the code that reads the data
and solve the system in sequential. I would like to solve the same problem in
parallel. I read the FAQ section that says:</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial><FONT
size=2></FONT></FONT></SPAN> </DIV>
<DIV><SPAN class=483223209-29092010>Never read or write in parallel an ASCII
matrix file, instead for reading: read in sequentially then save the matrix with
the binary viewer PetscBinaryViewerOpen() and load the matrix in parallel with
MatLoad().</SPAN></DIV>
<DIV><SPAN class=483223209-29092010></SPAN> </DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial size=2>So far, I did not
manage to implement this. Could any one help me?</FONT></SPAN></DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial size=2>My matrix is in the
Matrix Market format. I have put below my current
implementation.</FONT></SPAN></DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial size=2>Kind
regards,</FONT></SPAN></DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=483223209-29092010> <FONT face=Arial
size=2>-Pierre.</FONT></SPAN></DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial size=2>
PetscInitialize(&argc,&argv,(char *)0,help);<BR> ierr =
MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr);<BR> if (size !=
1) SETERRQ(1,"This is a uniprocessor example only!");</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial size=2> /* Read in
matrix */<BR> ierr =
PetscOptionsGetString(PETSC_NULL,"-fin",filein,127,PETSC_NULL);CHKERRQ(ierr);<BR>
ierr = PetscFOpen(PETSC_COMM_SELF,filein,"r",&file);CHKERRQ(ierr);<BR>
</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial size=2> /* find out
size of sparse matrix .... */<BR>
fgets(buf,PETSC_MAX_PATH_LEN-1,file);<BR> printf("%s",buf);<BR>
fscanf(file,"%d %d %d\n",&M,&N,&nz);</FONT></SPAN></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial size=2> ierr =
PetscPrintf(PETSC_COMM_SELF,"M: %d, N: %d, nz:
%d\n",M,N,nz);CHKERRQ(ierr);</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial size=2>
MatCreate(PETSC_COMM_WORLD,&A);<BR>
MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,M,N);<BR>
MatSetType(A,MATAIJ);<BR> MatSetUp(A);</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial size=2> for (i=0;
i<nz; i++){<BR> fscanf(file,"%d %d
%le\n",&I,&J,(double*)&val);<BR> I = I-1; J =
J-1;<BR> ierr =
MatSetValues(A,1,&I,1,&J,&val,INSERT_VALUES);CHKERRQ(ierr);<BR>
}</FONT></SPAN></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial size=2> ierr =
MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);<BR> ierr =
MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=483223209-29092010><FONT face=Arial size=2> if (file
!=stdin) fclose(file);<BR> ierr = PetscPrintf(PETSC_COMM_SELF,"Reading
matrix completes.\n");CHKERRQ(ierr);<BR></FONT></SPAN></DIV> <br>
********************************************************************<br>
This email and any attachments are confidential to the intended<br>
recipient and may also be privileged. If you are not the intended<br>
recipient please delete it from your system and notify the sender.<br>
You should not copy it or use it for any purpose nor disclose or<br>
distribute its contents to any other person.<br>
********************************************************************<br>
<br>
</body></HTML>