<div dir="auto">MatSetType + MatSetLocalToGlobalMapping<div dir="auto">is equivalent to MatCreateIS. Look at the code for MatCreateIS.</div></div><div class="gmail_extra"><br><div class="gmail_quote">Il 13 Dic 2017 7:32 PM, "Franck Houssen" <<a href="mailto:franck.houssen@inria.fr">franck.houssen@inria.fr</a>> ha scritto:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:times new roman,new york,times,serif;font-size:12pt;color:#000000"><div>Thanks. Working now. I missed that. I believed "MatSetType +  MatSetLocalToGlobalMapping" <=> "MatCreateIS(..., rmap, cmap, ...)" : I got that wrong.<br></div><div><br></div><div>Franck<br></div><div><br></div><hr id="m_-1129223978753723038zwchr"><blockquote style="border-left:2px solid #1010ff;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><b>De: </b>"Pierre Jolivet" <<a href="mailto:pierre.jolivet@enseeiht.fr" target="_blank">pierre.jolivet@enseeiht.fr</a>><br><b>À: </b>"Franck Houssen" <<a href="mailto:franck.houssen@inria.fr" target="_blank">franck.houssen@inria.fr</a>><br><b>Cc: </b><a href="mailto:petsc-dev@mcs.anl.gov" target="_blank">petsc-dev@mcs.anl.gov</a><br><b>Envoyé: </b>Mardi 12 Décembre 2017 20:43:50<br><b>Objet: </b>Re: [petsc-dev] MatIS export<br><div><br></div>Hello Franck,<div>From the documentation: "You must call MatSetLocalToGlobalMapping() before using this matrix type.” (<a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MATIS.html" target="_blank">http://www.mcs.anl.gov/petsc/<wbr>petsc-current/docs/<wbr>manualpages/Mat/MATIS.html</a>)</div><div>You are missing this call when your Mat is of type MATIS, thus the runtime error.</div><div><br></div><div>Thanks,</div><div>Pierre<br><div><br><blockquote><div>On 11 Dec 2017, at 5:42 PM, Franck Houssen <<a href="mailto:franck.houssen@inria.fr" target="_blank">franck.houssen@inria.fr</a>> wrote:</div><br class="m_-1129223978753723038Apple-interchange-newline"><div><div><div style="font-family:"times new roman","new york",times,serif;font-size:12pt"><div>Seems there is a problem with the attachment. Here is the file :<br></div><div><br></div><div>>> more matExport.cpp <br>#include <petscmat.h><br>#include <petscsys.h><br><br>int main(int argc, char *argv[])<br>{<br>  PetscInitialize(&argc, &argv, "", NULL);<br><br>  Mat matrix;<br>  MatCreate(PETSC_COMM_WORLD, &matrix);<br>  const char* matType = (argc >= 2) ? argv[1] : MATMPIAIJ;<br>  PetscPrintf(PETSC_COMM_WORLD, "mat type is %s \n", matType);<br>  MatSetType(matrix, matType);<br>  MatSetSizes(matrix, PETSC_DECIDE, PETSC_DECIDE, 10, 10);<br>  MatSetUp(matrix);<br>  for (int i = 0; i < 10; i++) MatSetValue(matrix, i, i, (double)(i+1.), ADD_VALUES);<br>  MatAssemblyBegin(matrix, MAT_FINAL_ASSEMBLY);<br>  MatAssemblyEnd(matrix, MAT_FINAL_ASSEMBLY);<br><br>  PetscViewer viewer;<br>  PetscViewerBinaryOpen(PETSC_<wbr>COMM_WORLD, "matExport.bin", FILE_MODE_WRITE, &viewer);<br>  MatView(matrix, viewer);<br>  PetscViewerDestroy(&viewer);<br><br>  PetscViewerASCIIOpen(PETSC_<wbr>COMM_WORLD, "matExport.log", &viewer);<br>  MatView(matrix, viewer);<br>  PetscViewerDestroy(&viewer);<br><br>  PetscViewerASCIIOpen(PETSC_<wbr>COMM_WORLD, "matExport.mat", &viewer);<br>  PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_MATLAB);<br>  MatView(matrix, viewer);<br>  PetscViewerDestroy(&viewer);<br><br>  MatDestroy(&matrix);<br>  PetscFinalize();<br>}<br><br><br></div><div><br></div><hr id="m_-1129223978753723038zwchr"><blockquote style="border-left-width:2px;border-left-style:solid;border-left-color:rgb(16,16,255);margin-left:5px;padding-left:5px;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><b>De: </b>"Franck Houssen" <<a href="mailto:franck.houssen@inria.fr" target="_blank">franck.houssen@inria.fr</a>><br><b>À: </b><a href="mailto:petsc-dev@mcs.anl.gov" target="_blank">petsc-dev@mcs.anl.gov</a><br><b>Envoyé: </b>Lundi 11 Décembre 2017 17:39:40<br><b>Objet: </b>[petsc-dev] MatIS export<br><div><br></div><div style="font-family:"times new roman","new york",times,serif;font-size:12pt"><div>Reporting a small bug related to MatIS export (or is this not meant to be supported ?).<br></div><div><br></div><div>Franck<br></div><div><br></div><div>>> rm -f matExport.log matExport.mat matExport.bin; mpirun -n 2 ./matExport.exe <strong>is</strong>; more matExport.log matExport.mat matExport.bin<br>mat type is is <br>[0]PETSC ERROR: ------------------------------<wbr>------------------------------<wbr>------------<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/documentation/faq.html#valgrind" target="_blank">http://www.mcs.anl.gov/petsc/<wbr>documentation/faq.html#<wbr>valgrind</a><br>[0]PETSC ERROR: or try <a href="http://valgrind.org" target="_blank">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>[1]PETSC ERROR: ------------------------------<wbr>------------------------------<wbr>------------<br>[1]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range<br>[1]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger<br>[1]PETSC ERROR: or see <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind" target="_blank">http://www.mcs.anl.gov/petsc/<wbr>documentation/faq.html#<wbr>valgrind</a><br>[1]PETSC ERROR: or try <a href="http://valgrind.org" target="_blank">http://valgrind.org</a> on GNU/linux and Apple Mac OS X to find memory corruption errors<br>[1]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run <br>[1]PETSC ERROR: to get more information on the crash.<br>[0]PETSC ERROR: --------------------- Error Message ------------------------------<wbr>------------------------------<wbr>--<br><div><br></div></div><div><br></div><div>>> rm -f matExport.log matExport.mat matExport.bin; mpirun -n 2 ./matExport.exe <strong>mpiaij</strong>; more matExport.log matExport.mat matExport.bin<br>mat type is mpiaij <br>::::::::::::::<br>matExport.log<br>::::::::::::::<br>Mat Object: 2 MPI processes<br>  type: mpiaij<br>row 0: (0, 2.) <br>row 1: (1, 4.) <br>row 2: (2, 6.) <br>row 3: (3, 8.) <br>row 4: (4, 10.) <br>row 5: (5, 12.) <br>row 6: (6, 14.) <br>row 7: (7, 16.) <br>row 8: (8, 18.) <br>row 9: (9, 20.) <br>::::::::::::::<br>matExport.mat<br>::::::::::::::<br>%Mat Object: 2 MPI processes<br>%  type: mpiaij<br>% Size = 10 10 <br>% Nonzeros = 10 <br>zzz = zeros(10,3);<br>zzz = [<br>1 1  2.0000000000000000e+00<br>2 2  4.0000000000000000e+00<br>3 3  6.0000000000000000e+00<br>4 4  8.0000000000000000e+00<br>5 5  1.0000000000000000e+01<br>6 6  1.2000000000000000e+01<br>7 7  1.4000000000000000e+01<br>8 8  1.6000000000000000e+01<br>9 9  1.8000000000000000e+01<br>10 10  2.0000000000000000e+01<br>];<br> Mat_0x557ffe276ba0_0 = spconvert(zzz);<br>::::::::::::::<br>matExport.bin<br>::::::::::::::<br><div><br></div><br><div><br></div><br><div><br></div></div><div><br></div><div><br></div></div></blockquote><div><br></div></div></div></div></blockquote></div><br></div></blockquote><div><br></div></div></div></blockquote></div></div>