[petsc-dev] MatIS export

Franck Houssen franck.houssen at inria.fr
Mon Dec 11 10:42:41 CST 2017


Seems there is a problem with the attachment. Here is the file : 

>> more matExport.cpp 
#include <petscmat.h> 
#include <petscsys.h> 

int main(int argc, char *argv[]) 
{ 
PetscInitialize(&argc, &argv, "", NULL); 

Mat matrix; 
MatCreate(PETSC_COMM_WORLD, &matrix); 
const char* matType = (argc >= 2) ? argv[1] : MATMPIAIJ; 
PetscPrintf(PETSC_COMM_WORLD, "mat type is %s \n", matType); 
MatSetType(matrix, matType); 
MatSetSizes(matrix, PETSC_DECIDE, PETSC_DECIDE, 10, 10); 
MatSetUp(matrix); 
for (int i = 0; i < 10; i++) MatSetValue(matrix, i, i, (double)(i+1.), ADD_VALUES); 
MatAssemblyBegin(matrix, MAT_FINAL_ASSEMBLY); 
MatAssemblyEnd(matrix, MAT_FINAL_ASSEMBLY); 

PetscViewer viewer; 
PetscViewerBinaryOpen(PETSC_COMM_WORLD, "matExport.bin", FILE_MODE_WRITE, &viewer); 
MatView(matrix, viewer); 
PetscViewerDestroy(&viewer); 

PetscViewerASCIIOpen(PETSC_COMM_WORLD, "matExport.log", &viewer); 
MatView(matrix, viewer); 
PetscViewerDestroy(&viewer); 

PetscViewerASCIIOpen(PETSC_COMM_WORLD, "matExport.mat", &viewer); 
PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_MATLAB); 
MatView(matrix, viewer); 
PetscViewerDestroy(&viewer); 

MatDestroy(&matrix); 
PetscFinalize(); 
} 

----- Mail original -----

> De: "Franck Houssen" <franck.houssen at inria.fr>
> À: petsc-dev at mcs.anl.gov
> Envoyé: Lundi 11 Décembre 2017 17:39:40
> Objet: [petsc-dev] MatIS export

> Reporting a small bug related to MatIS export (or is this not meant to be
> supported ?).

> Franck

> >> rm -f matExport.log matExport.mat matExport.bin; mpirun -n 2
> >> ./matExport.exe is ; more matExport.log matExport.mat matExport.bin
> mat type is is
> [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/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.
> [1]PETSC ERROR:
> ------------------------------------------------------------------------
> [1]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation,
> probably memory access out of range
> [1]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
> [1]PETSC ERROR: or see
> http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind
> [1]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to
> find memory corruption errors
> [1]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and
> run
> [1]PETSC ERROR: to get more information on the crash.
> [0]PETSC ERROR: --------------------- Error Message
> --------------------------------------------------------------

> >> rm -f matExport.log matExport.mat matExport.bin; mpirun -n 2
> >> ./matExport.exe mpiaij ; more matExport.log matExport.mat matExport.bin
> mat type is mpiaij
> ::::::::::::::
> matExport.log
> ::::::::::::::
> Mat Object: 2 MPI processes
> type: mpiaij
> row 0: (0, 2.)
> row 1: (1, 4.)
> row 2: (2, 6.)
> row 3: (3, 8.)
> row 4: (4, 10.)
> row 5: (5, 12.)
> row 6: (6, 14.)
> row 7: (7, 16.)
> row 8: (8, 18.)
> row 9: (9, 20.)
> ::::::::::::::
> matExport.mat
> ::::::::::::::
> %Mat Object: 2 MPI processes
> % type: mpiaij
> % Size = 10 10
> % Nonzeros = 10
> zzz = zeros(10,3);
> zzz = [
> 1 1 2.0000000000000000e+00
> 2 2 4.0000000000000000e+00
> 3 3 6.0000000000000000e+00
> 4 4 8.0000000000000000e+00
> 5 5 1.0000000000000000e+01
> 6 6 1.2000000000000000e+01
> 7 7 1.4000000000000000e+01
> 8 8 1.6000000000000000e+01
> 9 9 1.8000000000000000e+01
> 10 10 2.0000000000000000e+01
> ];
> Mat_0x557ffe276ba0_0 = spconvert(zzz);
> ::::::::::::::
> matExport.bin
> ::::::::::::::
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20171211/5fc28d0a/attachment.html>


More information about the petsc-dev mailing list