[petsc-users] extract data from vector in petsc into fortran array

Barry Smith bsmith at mcs.anl.gov
Thu May 3 22:46:21 CDT 2012


  You are creating or duplicating vectors and not destroying them so they will swallow up more and more memory. Make sure every create/duplicate has a corresponding destroy.

   Barry

On May 3, 2012, at 10:38 PM, Bo Sun wrote:

> Hi Barry,
> 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 "
>  
> [0]PETSC ERROR: --------------------- Error Message ------------------------------------
> [0]PETSC ERROR: Out of memory. This could be due to allocating
> [0]PETSC ERROR: too large an object or bleeding by not properly
> [0]PETSC ERROR: destroying unneeded objects.
> [0]PETSC ERROR: Memory allocated 0 Memory used by process 1882513408
> [0]PETSC ERROR: Try running with -malloc_dump or -malloc_log for info.
> [0]PETSC ERROR: Memory requested 2628072!
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Release Version 3.2.0, Patch 6, Wed Jan 11 09:28:45 CST 2012 
> [0]PETSC ERROR: See docs/changes/index.html for recent updates.
> [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
> [0]PETSC ERROR: See docs/index.html for manual pages.
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: ./main on a arch-linu named lightningsmp.its.iastate.edu by sciam Thu May  3 15:58:24 2012
> [0]PETSC ERROR: Libraries linked from /work/doe_ar1/sciam/petsc-3.2-p6/arch-linux2-c-opt/lib
> [0]PETSC ERROR: Configure run at Wed Apr  4 12:45:08 2012
> [0]PETSC ERROR: Configure options --with-cc=mpicc --with-fc=mpif90 --with-debugging=0 FOPTFLAGS="-O3 -qarch=p4 -qtune=p4"
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: PetscMallocAlign() line 49 in src/sys/memory/mal.c
> [0]PETSC ERROR: VecCreate_Seq() line 40 in src/vec/vec/impls/seq/bvec3.c
> [0]PETSC ERROR: VecSetType() line 53 in src/vec/vec/interface/vecreg.c
> [0]PETSC ERROR: VecDuplicate_Seq() line 800 in src/vec/vec/impls/seq/bvec2.c
> [0]PETSC ERROR: VecDuplicate() line 541 in src/vec/vec/interface/vector.c
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
> [0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
> [0]PETSC ERROR: or see http://www.mcs.anl.gov/petsc/petsc-as/documentation/faq.html#valgrind[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors
> [0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run 
> [0]PETSC ERROR: to get more information on the crash.
> [0]PETSC ERROR: --------------------- Error Message ------------------------------------
> [0]PETSC ERROR: Signal received!
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Release Version 3.2.0, Patch 6, Wed Jan 11 09:28:45 CST 2012 
> [0]PETSC ERROR: See docs/changes/index.html for recent updates.
> [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
> [0]PETSC ERROR: See docs/index.html for manual pages.
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: ./main on a arch-linu named lightningsmp.its.iastate.edu by sciam Thu May  3 15:58:24 2012
> [0]PETSC ERROR: Libraries linked from /work/doe_ar1/sciam/petsc-3.2-p6/arch-linux2-c-opt/lib
> [0]PETSC ERROR: Configure run at Wed Apr  4 12:45:08 2012
> [0]PETSC ERROR: Configure options --with-cc=mpicc --with-fc=mpif90 --with-debugging=0 FOPTFLAGS="-O3 -qarch=p4 -qtune=p4"
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: User provided function() line 0 in unknown directory unknown file
> ------------------------------------------------------------------------------------------------------------------------------
> 
> 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't do appropriate  destroy to the vector in petsc. 
> 
> Regards,
> Bo
> 
> On Wed, May 2, 2012 at 11:01 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> 
> On May 2, 2012, at 11:32 PM, Bo Sun wrote:
> 
> > Hi there,
> > I am coding using Fortran 90 with petsc. I extract the results from vector in petsc as follows,
> >
> >    PetscScalar, pointer :: xx_v(:)
> >    Vec pet_u
> >
> >    ..............
> >    call VecGetArrayF90(pet_u,xx_v,ierr)
> >     data_for_fortran = xx_v
> >     call VecRestoreArrayF90(pet_u,xx_v,ierr)
> >    ...................
> >
> >
> > For small size of vector, there is no problem. But when the size of vector is above million, some strange data appear.
> 
>   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 petsc-maint at mcs.anl.gov
> 
>   VecGetArrayF90() is generally the way to go, other things are more cumbersome.
> >
> 
> 
> > Could you recommend another way to output the data of vector in petsc into fortran array ?
> >
> >
> > Thanks,
> > Bo
> 
> 
> 
> 
> -- 
> --------------------------------------------------------------------
> CFD
> Mechanical Engineering
> Iowa State University
> 50011



More information about the petsc-users mailing list