[petsc-users] Error in VecAssemeblyBegin after VecView

Barry Smith bsmith at mcs.anl.gov
Wed Jan 4 16:18:24 CST 2012


   Hannes,

      Thanks for reporting the problem. It is a bug in our handling of PETSC_VIEWER_ASCII_MATLAB in parallel. I have fixed the repository copy in both petsc-3.2 and petsc-dev   It will be fixed in the next patch release of 3.2 or Satish can send you the patch file; just ask for it at petsc-maint at mcs.anl.gov

    Barry


> Hannes

On Jan 4, 2012, at 11:59 AM, Johannes.Huber at unibas.ch wrote:

> Hi all,
> thanks a lot for you help.
> I tracked the problem down to a minimal program and found, that it looks like I'm doing something wrong when using the matlab format. Here is the minimal program:
> #include <petscvec.h>
> static char help[] = "Matlab output.\n\n";
> int main (int argc, char** argv)
> {
>  PetscInitialize(&argc,&argv,(char*)0,help);
>  Vec b;
>  PetscInt ierr;
>  int r;
>  MPI_Comm_rank(PETSC_COMM_WORLD,&r);
>  ierr=VecCreate(PETSC_COMM_WORLD,&b); CHKERRQ(ierr);
>  ierr=VecSetSizes(b,10,PETSC_DECIDE); CHKERRQ(ierr);
>  ierr=VecSetFromOptions(b); CHKERRQ(ierr);
>  ierr=VecZeroEntries(b); CHKERRQ(ierr);
>  ierr=VecAssemblyBegin(b); CHKERRQ(ierr);
>  ierr=VecAssemblyEnd(b); CHKERRQ(ierr);
> 
>  PetscViewer File;
>  ierr=PetscViewerASCIIOpen(PETSC_COMM_WORLD,"Test.m",&File); CHKERRQ(ierr);
>  ierr=PetscViewerSetFormat(File,PETSC_VIEWER_ASCII_MATLAB); CHKERRQ(ierr);  // crash
>  //ierr=PetscViewerSetFormat(File,PETSC_VIEWER_ASCII_INDEX); CHKERRQ(ierr);  //works
>  //ierr=PetscViewerSetFormat(File,PETSC_VIEWER_ASCII_DENSE); CHKERRQ(ierr);  //works
>  ierr=VecView(b,File); CHKERRQ(ierr);
>  ierr=PetscViewerDestroy(&File); CHKERRQ(ierr);
> 
>  printf("[%d]: %d\n",r,__LINE__);
>  VecAssemblyBegin(b);
>  printf("[%d]: %d\n",r,__LINE__);
>  VecAssemblyEnd(b);
>  ierr=VecDestroy(&b); CHKERRQ(ierr);
>  MPI_Barrier(PETSC_COMM_WORLD);
>  PetscFinalize();
>  return 0;
> }
> Does anybody know, what's wrong with this?
> 
> Thanks a lot,
>    Hannes
> 
> Quoting Barry Smith <bsmith at mcs.anl.gov>:
> 
>> 
>> On Jan 3, 2012, at 6:59 AM, Jed Brown wrote:
>> 
>>> On Tue, Jan 3, 2012 at 06:41, <Johannes.Huber at unibas.ch> wrote:
>>> The first assembly works well, and I would agree, if the first assmebly crashed. However, it's the second assembly call and in between those two calls, all I'm doing is viewing the vector.
>>> 
>>> Use a debugger to set a breakpoint in VecSetValues(); maybe starting after your first assemble. Also try Valgrind, it could be memory corruption.
>> 
>> http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind
>> 
>> 
>>> 
>>> You can also break in the first VecAssemblyBegin and do
>>> 
>>> (gdb) p &vec->stash.insertmode
>>> $1 = (InsertMode *) 0xADDRESS
>>> (gdb) wat *$1
>>> Hardware watchpoint 3: *$1
>>> (gdb) c
>>> ... breaks when insertmode is modified for any reason.
>> 
>> 
> 
> 
> 
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
> 
> 



More information about the petsc-users mailing list