<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div>  You can use MatCreateVecs() to create vectors sized properly for both x and y in y = Ax when A is not square.<div><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Sep 5, 2024, at 5:20 PM, Karthikeyan Chockalingam - STFC UKRI via petsc-users <petsc-users@mcs.anl.gov> wrote:</div><br class="Apple-interchange-newline"><div><meta charset="UTF-8"><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">Hello,<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">I am unsure why the program crashes even while running the code serially<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">  petscErr = MatCreate(mesh.comm().get(), &par_G);<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">  petscErr = MatSetType(par_G, MATMPIAIJ);<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">  petscErr = MatSetSizes(par_G, local_num_rows, local_num_cols,    total_num_rows, total_num_cols);<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">  PetscInt d_nz = 2;<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">  PetscInt o_nz = 2;<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">  petscErr = MatMPIAIJSetPreallocation(par_G, d_nz, NULL, o_nz, NULL);<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">  petscErr = VecCreateMPI(mesh.comm().get(),local_num_cols,total_num_cols,&par_xcoord);<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">  petscErr = VecDuplicate(par_xcoord,&par_xvec);<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: white;"><span style="font-size: 9pt; font-family: Menlo;"></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(0, 16, 128);">petscErr</span><span style="font-size: 9pt; font-family: Menlo;"><span class="Apple-converted-space"> </span>=<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(121, 94, 38);">MatMult</span><span style="font-size: 9pt; font-family: Menlo;">(</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(0, 16, 128);">par_G</span><span style="font-size: 9pt; font-family: Menlo;">,<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(0, 16, 128);">par_xcoord</span><span style="font-size: 9pt; font-family: Menlo;">,<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(0, 16, 128);">par_xvec</span><span style="font-size: 9pt; font-family: Menlo;">);<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: white;"><span style="font-size: 9pt; font-family: Menlo;"><o:p> </o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: white;"><span style="font-size: 9pt; font-family: Menlo;"><o:p> </o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: white;"><span style="font-size: 9pt; font-family: Menlo;"><o:p> </o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: white;"><span style="font-size: 9pt; font-family: Menlo;"><o:p> </o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: white;"><span style="font-size: 9pt; font-family: Menlo;">[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: white;"><span style="font-size: 9pt; font-family: Menlo;">[0]PETSC ERROR: Nonconforming object sizes<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: white;"><span style="font-size: 9pt; font-family: Menlo;">[0]PETSC ERROR: Mat mat,Vec y: global dim 40 25<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: white;"><span style="font-size: 9pt; font-family: Menlo;">[0]PETSC ERROR: WARNING! There are unused option(s) set! Could be the program crashed before usage or a spelling mistake, etc!<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: white;"><span style="font-size: 9pt; font-family: Menlo;">[0]PETSC ERROR:   Option left: name:--keep-cout (no value) source: command line<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: white;"><span style="font-size: 9pt; font-family: Menlo;">[0]PETSC ERROR: See<span class="Apple-converted-space"> </span><a href="https://urldefense.us/v3/__https://petsc.org/release/faq/__;!!G_uCfscf7eWS!eNf_b1At1lAvdYeAlplIXxQN9WwVYKe1gkVUZRvNkdF0V6JCbVOG_mYTuCQrp2rs8FMod_waFjX0LLNuAvMcHmdf7Hrzm4s3JaQT$">https://petsc.org/release/faq/</a><span class="Apple-converted-space"> </span>for trouble shooting.<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: white;"><span style="font-size: 9pt; font-family: Menlo;">[0]PETSC ERROR: Petsc Release Version 3.20.3, unknown <o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: white;"><span style="font-size: 9pt; font-family: Menlo;">[0]PETSC ERROR: ./example-dbg on a arch-moose named HC20210312 by karthikeyan.chockalingam Thu Sep  5 22:16:54 2024<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: white;"><span style="font-size: 9pt; font-family: Menlo;">[0]PETSC ERROR: Configure options --with-64-bit-indices --with-cxx-dialect=C++17 --with-debugging=no --with-fortran-bindings=0 --with-mpi=1 --with-openmp=1 --with-shared-libraries=1 --with-sowing=0 --download-fblaslapack=1 --download-hypre=1 --download-metis=1 --download-mumps=1 --download-ptscotch=1 --download-parmetis=1 --download-scalapack=1 --download-slepc=1 --download-strumpack=1 --download-superlu_dist=1 --download-bison=1 --download-hdf5=1 --with-hdf5-fortran-bindings=0 --download-hdf5-configure-arguments="--with-zlib" --with-make-np=4 <o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: white;"><span style="font-size: 9pt; font-family: Menlo;">[0]PETSC ERROR: #1 MatMult() at /Users/karthikeyan.chockalingam/moose/petsc/src/mat/interface/matrix.c:2587<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: white;"><span style="font-size: 9pt; font-family: Menlo;">Vec Object: 1 MPI process<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: white;"><span style="font-size: 9pt; font-family: Menlo;"><o:p> </o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">Many thanks for the help!<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">Karthik.<o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div><div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif;">-- <o:p></o:p></span></div></div><div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><b><span style="font-size: 10.5pt; font-family: Arial, sans-serif; color: rgb(45, 45, 98);">Karthik Chockalingam, Ph.D.<o:p></o:p></span></b></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 10.5pt; font-family: Arial, sans-serif;">Senior Research Software Engineer</span><span style="font-size: 10.5pt; font-family: Calibri, sans-serif;"><o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 10.5pt; font-family: Arial, sans-serif;">High Performance Systems Engineering Group</span><span style="font-size: 10.5pt; font-family: Calibri, sans-serif;"><o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 10.5pt; font-family: Arial, sans-serif;">Hartree Centre | Science and Technology Facilities Council</span><span style="font-size: 10.5pt; font-family: Calibri, sans-serif;"><o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 10.5pt; font-family: Arial, sans-serif; color: rgb(33, 33, 33);"><a href="mailto:karthikeyan.chockalingam@stfc.ac.uk"><span style="color: rgb(5, 99, 193);">karthikeyan.chockalingam@stfc.ac.uk</span></a></span><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(33, 33, 33);"><o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-family: "Times New Roman", serif;"> </span><span style="font-size: 10.5pt; font-family: Arial, sans-serif; color: rgb(65, 65, 65);"> </span><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(33, 33, 33);"><o:p></o:p></span></div><div style="margin: 0cm; font-size: 12pt; font-family: Aptos, sans-serif;"><b><span style="font-size: 10.5pt; font-family: Arial, sans-serif; color: rgb(65, 65, 65);"> </span></b><span style="font-family: "Times New Roman", serif; color: rgb(31, 73, 125);"><span id="cid:image001.png@01DAFFE0.785F7550"><image001.png></span></span></div></div></div></div></div></blockquote></div><br></div></body></html>