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