Hi Barry,<br>Thank you for your reply.  Sorry to confuse you. The strange data means that when I run the case using only one cpu, after some steps, the case blows up or give wrong data. I think that is because the local memory is not enough. And some case gives the following error message &quot;<br>
 <br>[0]PETSC ERROR: --------------------- Error Message ------------------------------------<br>[0]PETSC ERROR: Out of memory. This could be due to allocating<br>[0]PETSC ERROR: too large an object or bleeding by not properly<br>
[0]PETSC ERROR: destroying unneeded objects.<br>[0]PETSC ERROR: Memory allocated 0 Memory used by process 1882513408<br>[0]PETSC ERROR: Try running with -malloc_dump or -malloc_log for info.<br>[0]PETSC ERROR: Memory requested 2628072!<br>
[0]PETSC ERROR: ------------------------------------------------------------------------<br>[0]PETSC ERROR: Petsc Release Version 3.2.0, Patch 6, Wed Jan 11 09:28:45 CST 2012 <br>[0]PETSC ERROR: See docs/changes/index.html for recent updates.<br>
[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.<br>[0]PETSC ERROR: See docs/index.html for manual pages.<br>[0]PETSC ERROR: ------------------------------------------------------------------------<br>[0]PETSC ERROR: ./main on a arch-linu named <a href="http://lightningsmp.its.iastate.edu">lightningsmp.its.iastate.edu</a> by sciam Thu May  3 15:58:24 2012<br>
[0]PETSC ERROR: Libraries linked from /work/doe_ar1/sciam/petsc-3.2-p6/arch-linux2-c-opt/lib<br>[0]PETSC ERROR: Configure run at Wed Apr  4 12:45:08 2012<br>[0]PETSC ERROR: Configure options --with-cc=mpicc --with-fc=mpif90 --with-debugging=0 FOPTFLAGS=&quot;-O3 -qarch=p4 -qtune=p4&quot;<br>
[0]PETSC ERROR: ------------------------------------------------------------------------<br>[0]PETSC ERROR: PetscMallocAlign() line 49 in src/sys/memory/mal.c<br>[0]PETSC ERROR: VecCreate_Seq() line 40 in src/vec/vec/impls/seq/bvec3.c<br>
[0]PETSC ERROR: VecSetType() line 53 in src/vec/vec/interface/vecreg.c<br>[0]PETSC ERROR: VecDuplicate_Seq() line 800 in src/vec/vec/impls/seq/bvec2.c<br>[0]PETSC ERROR: VecDuplicate() line 541 in src/vec/vec/interface/vector.c<br>
[0]PETSC ERROR: ------------------------------------------------------------------------<br>[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range<br>[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger<br>
[0]PETSC ERROR: or see <a href="http://www.mcs.anl.gov/petsc/petsc-as/documentation/faq.html#valgrind[0]PETSC">http://www.mcs.anl.gov/petsc/petsc-as/documentation/faq.html#valgrind[0]PETSC</a> ERROR: or try <a href="http://valgrind.org">http://valgrind.org</a> on GNU/linux and Apple Mac OS X to find memory corruption errors<br>
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run <br>[0]PETSC ERROR: to get more information on the crash.<br>[0]PETSC ERROR: --------------------- Error Message ------------------------------------<br>
[0]PETSC ERROR: Signal received!<br>[0]PETSC ERROR: ------------------------------------------------------------------------<br>[0]PETSC ERROR: Petsc Release Version 3.2.0, Patch 6, Wed Jan 11 09:28:45 CST 2012 <br>[0]PETSC ERROR: See docs/changes/index.html for recent updates.<br>
[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.<br>[0]PETSC ERROR: See docs/index.html for manual pages.<br>[0]PETSC ERROR: ------------------------------------------------------------------------<br>[0]PETSC ERROR: ./main on a arch-linu named <a href="http://lightningsmp.its.iastate.edu">lightningsmp.its.iastate.edu</a> by sciam Thu May  3 15:58:24 2012<br>
[0]PETSC ERROR: Libraries linked from /work/doe_ar1/sciam/petsc-3.2-p6/arch-linux2-c-opt/lib<br>[0]PETSC ERROR: Configure run at Wed Apr  4 12:45:08 2012<br>[0]PETSC ERROR: Configure options --with-cc=mpicc --with-fc=mpif90 --with-debugging=0 FOPTFLAGS=&quot;-O3 -qarch=p4 -qtune=p4&quot;<br>
[0]PETSC ERROR: ------------------------------------------------------------------------<br>[0]PETSC ERROR: User provided function() line 0 in unknown directory unknown file<br>------------------------------------------------------------------------------------------------------------------------------<br>
<br>The input from fortran array to petsc vector and output from petsc vector to fortran array happens in each loop. I guess that I didn&#39;t do appropriate  destroy to the vector in petsc. <br><br>Regards,<br>Bo<br><br>
<div class="gmail_quote">On Wed, May 2, 2012 at 11:01 PM, Barry Smith <span dir="ltr">&lt;<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im"><br>
On May 2, 2012, at 11:32 PM, Bo Sun wrote:<br>
<br>
&gt; Hi there,<br>
&gt; I am coding using Fortran 90 with petsc. I extract the results from vector in petsc as follows,<br>
&gt;<br>
&gt;    PetscScalar, pointer :: xx_v(:)<br>
&gt;    Vec pet_u<br>
&gt;<br>
&gt;    ..............<br>
&gt;    call VecGetArrayF90(pet_u,xx_v,ierr)<br>
&gt;     data_for_fortran = xx_v<br>
&gt;     call VecRestoreArrayF90(pet_u,xx_v,ierr)<br>
&gt;    ...................<br>
&gt;<br>
&gt;<br>
&gt; For small size of vector, there is no problem. But when the size of vector is above million, some strange data appear.<br>
<br>
</div>   What do you mean strange data? Is this reproducable? Do two different Fortran compilers give the same problem? I you can send us a simple Fortran code that demonstrates the problem we can try to reproduce it. Please send such a bug report to <a href="mailto:petsc-maint@mcs.anl.gov">petsc-maint@mcs.anl.gov</a><br>

<br>
   VecGetArrayF90() is generally the way to go, other things are more cumbersome.<br>
<div class="HOEnZb"><div class="h5">&gt;<br>
<br>
<br>
&gt; Could you recommend another way to output the data of vector in petsc into fortran array ?<br>
&gt;<br>
&gt;<br>
&gt; Thanks,<br>
&gt; Bo<br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>--------------------------------------------------------------------<br>CFD<br>Mechanical Engineering<br>Iowa State University<br>50011<br>