Re: [petsc-users] error related to 'valgrind' when using MatView

2023-08-11 Thread Barry Smith

  New error checking to prevent this confusion in the future: 
https://gitlab.com/petsc/petsc/-/merge_requests/6804


> On Aug 10, 2023, at 6:54 AM, Matthew Knepley  wrote:
> 
> On Thu, Aug 10, 2023 at 2:30 AM maitri ksh  > wrote:
>> I am unable to understand what possibly went wrong with my code, I could 
>> load a matrix (large sparse matrix) into petsc, write it out and read it 
>> back into Matlab but when I tried to use MatView to see the matrix-info, it 
>> produces error of some 'corrupt argument, #valgrind'. Can anyone please help?
> 
> You use
> 
>   viewer = PETSC_VIEWER_STDOUT_WORLD
> 
> but then you Destroy() that viewer. You should not since you did not create 
> it.
> 
>   THanks,
> 
>  Matt
>  
>> Maitri
> 
> 
> -- 
> What most experimenters take for granted before they begin their experiments 
> is infinitely more interesting than any results to which their experiments 
> lead.
> -- Norbert Wiener
> 
> https://www.cse.buffalo.edu/~knepley/ 



Re: [petsc-users] error related to 'valgrind' when using MatView

2023-08-10 Thread Matthew Knepley
On Thu, Aug 10, 2023 at 2:30 AM maitri ksh  wrote:

> I am unable to understand what possibly went wrong with my code, I could
> load a matrix (large sparse matrix) into petsc, write it out and read it
> back into Matlab but when I tried to use MatView to see the matrix-info, it
> produces error of some 'corrupt argument, #valgrind'. Can anyone please
> help?
>

You use

  viewer = PETSC_VIEWER_STDOUT_WORLD

but then you Destroy() that viewer. You should not since you did not create
it.

  THanks,

 Matt


> Maitri
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ 


[petsc-users] error related to 'valgrind' when using MatView

2023-08-10 Thread maitri ksh
I am unable to understand what possibly went wrong with my code, I could
load a matrix (large sparse matrix) into petsc, write it out and read it
back into Matlab but when I tried to use MatView to see the matrix-info, it
produces error of some 'corrupt argument, #valgrind'. Can anyone please
help?
Maitri
Mat Object: 1 MPI process
  type: mpiaij
  rows=48, cols=48
  total: nonzeros=17795897, allocated nonzeros=17795897
  total number of mallocs used during MatSetValues calls=0
not using I-node (on process 0) routines
after Loading A matrix... Memory: Total: 0.483803 Max: 0.483803 [0]
after MatDestroy... Memory: Total: 0.483803 Max: 0.483803 [0]
Done
[0]PETSC ERROR: - Error Message 
--
[0]PETSC ERROR: Corrupt argument: https://petsc.org/release/faq/#valgrind
[0]PETSC ERROR: Object already free: Parameter # 1
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Development GIT revision: v3.19.4-889-g617fea4  GIT Date: 
2023-08-01 05:10:03 +
[0]PETSC ERROR: ./loadMat on a linux-gnu-c-debug named zeus.technion.ac.il by 
maitri.ksh Thu Aug 10 09:20:43 2023
[0]PETSC ERROR: Configure options --with-cc=/usr/local/gcc11/bin/gcc 
--with-cxx=/usr/local/gcc11/bin/g++ --with-fc=gfortran --download-mpich 
--download-fblaslapack --with-matlab --with-matlab-dir=/usr/local/matlab 
--download-superlu --with-superlu --download-superlu_dist --with-superlu_dist 
--download-hdf5 --with-hdf5=1 --download-mumps --with-mumps 
--download-scalapack --with-scalapack --download-parmetis --download-metis 
--download-ptscotch --download-bison --download-cmake
[0]PETSC ERROR: #1 PetscObjectDestroy() at 
/home/maitri.ksh/Maitri/petsc/src/sys/objects/destroy.c:50
[0]PETSC ERROR: #2 PetscObjectRegisterDestroyAll() at 
/home/maitri.ksh/Maitri/petsc/src/sys/objects/destroy.c:355
[0]PETSC ERROR: #3 PetscFinalize() at 
/home/maitri.ksh/Maitri/petsc/src/sys/objects/pinit.c:1452
/* Load unfactored matrix (A) */
PetscViewer viewerA;
ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD, "Jmat.dat", FILE_MODE_READ, 
); CHKERRQ(ierr);
ierr = MatCreate(PETSC_COMM_WORLD, ); CHKERRQ(ierr);
ierr = MatSetSizes(A, PETSC_DECIDE, PETSC_DECIDE, N, N);
ierr = MatSetType(A, type);
ierr = MatSetFromOptions(A);
PetscPrintf(PETSC_COMM_WORLD, "Loading unfactored matrix\n");
ierr = MatLoad(A, viewerA); CHKERRQ(ierr);
PetscViewerDestroy();

PetscViewer viewer;
viewer = PETSC_VIEWER_STDOUT_WORLD;
ierr = PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_INFO);
ierr = MatView(A, viewer);
PetscViewerPopFormat(viewer);
PetscViewerDestroy();