<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><DIV>Hello, Matt<BR> <BR> After my careful testing, I get some findings.</DIV>
<DIV> </DIV>
<DIV> Firstly, considering the approach of setting one row at a time. I change my codes<BR>from setting one data per time to one row per time (codes attached). I find that both<BR>of the times are almost equal and cannot be ignored . In my opinion, the latter should<BR>take less time than the former. the codes have been proved to have the right results<BR>and I think my testing datas are enough to show that they almost have the same time<BR>for setting the matrix. </DIV>
<DIV> </DIV>
<DIV> Secondly, as you said in a previous post('CSR Sparse Matrix Query', 2007), there<BR>is no Fortran interface for the function 'MatCreateMPIAIJWithArrays'. I am not sure<BR>if it is true now because the docs do not specify this and I connot compile with<BR>it atfer a simple test. In my opinion, you prefer to do the thing of setting values from<BR>CSR format using the way of setting values with MatSetValus for each row rather than<BR>using MatCreateMPIAIJWithArrays. am I right?</DIV>
<DIV> </DIV>
<DIV> Thanks again.</DIV>
<DIV> Jim</DIV>
<DIV>-----coding:per row(you can compare it with the first page int this post of one data per time )-----<BR> <BR> !NROWIN,NNZIJ,values:the CSR variables of the main function<BR> !NROWIN,NNZIJ:one-based,so get zero-based variables rowIndex,columns</DIV>
<DIV> do 10,II=Istart+1,Iend<BR> !no-zero numbers of this row<BR> rowNum=NROWIN(II+1)-NROWIN(II)<BR> <BR> allocate(nColPerRow(rowNum))<BR> allocate(valuePerRow(rowNum))<BR> <BR> kValStart=NROWIN(II)+1-1<BR> kValEnd=NROWIN(II)+rowNum-1<BR> <BR> !column index<BR> nColPerRow=NNZIJ(kValStart:kValEnd)-1<BR> valuePerRow=values(kValStart:kValEnd)<BR> nRow=II-1<BR> call MatSetValues(A,ione,nRow,rowNum,nColPerRow,valuePerRow,<BR> & INSERT_VALUES,ierr)<BR> deallocate(nColPerRow)<BR> deallocate(valuePerRow) <BR> 10 continue<BR>---------------------coding-----------------------------<BR><BR></DIV>
<DIV></DIV>
<DIV id="divNeteaseMailCard"></DIV>
<DIV><BR></DIV>>ÔÚ 2012-06-10 20:49:13£¬"Matthew Knepley" <knepley@gmail.com> дµÀ£º<BR>
<BLOCKQUOTE style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" id="isReplyContent">>On Sun, Jun 10, 2012 at 4:48 PM, w_ang_temp <SPAN dir="ltr"><<A href="mailto:w_ang_temp@163.com" target="_blank">w_ang_temp@163.com</A>></SPAN> wrote:<BR>
<DIV class="gmail_quote">
<BLOCKQUOTE style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<DIV style="LINE-HEIGHT: 1.7; FONT-FAMILY: arial; FONT-SIZE: 14px">
<DIV>>Hello, Barry<BR> <BR>> I try to use MatCreateSeqAIJWithArrays to deal with my problem. Since <BR>>there is no example in the doc, I find some examples in the web and use it.<BR>>And I get some errors.</DIV>
<DIV> </DIV>
<DIV>> When the processor is 1(mpiexec -n 1 ./ex4f), the results are ok. While<BR>>it is more than one, I get the errors. So I think I miss some piece of<BR>>information about MatCreateSeqAIJWithArrays.</DIV></DIV></BLOCKQUOTE>
<DIV><BR></DIV>
<DIV>>1) Check the error codes. Always!</DIV>
<DIV> </DIV>
<BLOCKQUOTE style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<DIV style="LINE-HEIGHT: 1.7; FONT-FAMILY: arial; FONT-SIZE: 14px">
<DIV>> Thanks. <BR>> Jim</DIV>
<DIV> </DIV>
<DIV>>----------------------------code-------------------------------------------<BR>> call MatCreate(PETSC_COMM_WORLD,A,ierr)<BR>> call MatSetType(A,MATAIJ,ierr)<BR>> call MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,m,n,ierr)<BR>> call MatSetFromOptions(A,ierr)<BR>> call MatGetOwnershipRange(A,Istart,Iend,ierr)</DIV></DIV></BLOCKQUOTE>
<DIV> </DIV>
<BLOCKQUOTE style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<DIV style="LINE-HEIGHT: 1.7; FONT-FAMILY: arial; FONT-SIZE: 14px">
<DIV>> !NROWIN,NNZIJ,values:the CSR variables of the main function<BR>> !NROWIN,NNZIJ:one-based,so get zero-based variables rowIndex,columns<BR>> allocate(rowIndex(JFLNG+1))<BR>> allocate(columns(MAXNNZ))<BR>> rowIndex=NROWIN-1<BR>> columns=NNZIJ-1<BR> <BR>> call MatCreateSeqAIJWithArrays(MPI_COMM_WORLD,m,n,rowIndex,columns,<BR>> & values,A, ierr)</DIV></DIV></BLOCKQUOTE>
<DIV><BR></DIV>
<DIV>>2) This can only be called in serial. In parallel, you need MatCreateMPIAIJWithArrays()</DIV>
<DIV><BR></DIV>
<DIV>>3) I still believe you are really doing the wrong thing. The right solution is to set one row at</DIV>
<DIV>> a time. I will bet dollars to doughnuts that the assembly time is not noticeable in your program.</DIV>
<DIV><BR></DIV>
<DIV>> Matt</DIV>
<DIV> </DIV>
<BLOCKQUOTE style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<DIV style="LINE-HEIGHT: 1.7; FONT-FAMILY: arial; FONT-SIZE: 14px">
<DIV><BR>> call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr)<BR>> call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr)<BR>>----------------------------code-------------------------------------------</DIV>
<DIV> </DIV>
<DIV>>----------------------------Error Message----------------------------------</DIV>
<DIV>>.........<BR></DIV></DIV></BLOCKQUOTE></DIV></BLOCKQUOTE></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>