# PETSc - createMat Issues

**URL:** https://community.freefem.org/t/petsc-createmat-issues/2868
**Category:** General Discussion
**Created:** [January 8, 2024, 4:52pm UTC](https://community.freefem.org/t/petsc-createmat-issues/2868 "2024-01-08T16:52:24Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![OTTAVIO.C.T.UNISA](https://avatars.discourse-cdn.com/v4/letter/o/2bfe46/32.png) [@OTTAVIO.C.T.UNISA](https://community.freefem.org/u/OTTAVIO.C.T.UNISA)
#### Post date: [January 8, 2024, 4:52pm UTC](https://community.freefem.org/t/petsc-createmat-issues/2868/1 "2024-01-08T16:52:24Z")

</div>

Good morning everyone. I have been practising with FreeFem++ (Windows 11) for a couple of months and now i’m catching up with expert tutorial 2022 made by Professor Pierre Joliviet in order to learn parallel computing. I am trying to launch a script on freefemMPI and using PETSc. It gives me no problems when using 3 or less MPI processes. But when i ask to use 4 or more processes, the script is compiled but execution gets stuck. It shows no error at all but it just keeps computing and never gives the output. I tried debugging and the problem seems to come from the createMat function. How can i solve this problem?  
The script is the following. It is a very simple problem from the tutorial.

```auto
border circle(t=0,2*pi){x=cos(t); y=sin(t);}
int n=200;
mesh Th=buildmesh(circle(n));
fespace Ph(Th,P0);
Ph partitioning;
include "macro_ddm.idp" // includo la idp con le macro
buildDmesh(Th); 
load "PETSc"
Ph outputForParaview = mpirank;
savevtk("C:/Users/Utente/Desktop/tirocinio e tesi portatile/free fem/esercizi freefem/decomposition/pierre8/rank.vtu",Th, outputForParaview);
fespace Vh(Th,P1);
tgv=-1.0;
varf vPb(u,v)=int2d(Th)(dx(u)*dy(v)+dy(u)*dy(v))+int2d(Th)(v)+on(1, u=1.0);
real[int] rhs=vPb(0,Vh);
Mat A; 
createMat(Th,A,P1); 
A=vPb(Vh,Vh);
set(A, sparams="-prefix_push myFirstSolve_ -ksp_converged_reason -ksp_type gmres -pc_type lu -prefix_pop", prefix = "myFirstSolve_");
real[int] sol=A^-1*rhs;
Vh solForOutput;  
solForOutput[]=sol;  
int[int] one(1);
one=1;
savevtk("C:/Users/Utente/Desktop/tirocinio e tesi portatile/free fem/esercizi freefem/decomposition/pierre7/rank.vtu",Th, solForOutput, order=one, append=true);

```

Thanks for the help.  
Best regards  
OCT

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [January 8, 2024, 4:54pm UTC](https://community.freefem.org/t/petsc-createmat-issues/2868/2 "2024-01-08T16:54:31Z")

</div>

Make sure we can copy/paste your code by surrounding it around back tick

```auto
like this

```

otherwise I won’t be able to help you.

---

<div class="post-metadata">

### Author: ![OTTAVIO.C.T.UNISA](https://avatars.discourse-cdn.com/v4/letter/o/2bfe46/32.png) [@OTTAVIO.C.T.UNISA](https://community.freefem.org/u/OTTAVIO.C.T.UNISA)
#### Post date: [January 8, 2024, 5:15pm UTC](https://community.freefem.org/t/petsc-createmat-issues/2868/3 "2024-01-08T17:15:27Z")

</div>

Ok, done. Sorry, first time using the forum.

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [January 8, 2024, 5:49pm UTC](https://community.freefem.org/t/petsc-createmat-issues/2868/4 "2024-01-08T17:49:11Z")

</div>

Thanks. You are not using the same path for both calls to `savevtk`, is that intended? Things look good otherwise, could you please run the code that hangs with the command-line parameter `-info dump` and send or copy/paste here the file `dump.0`?

---

<div class="post-metadata">

### Author: ![OTTAVIO.C.T.UNISA](https://avatars.discourse-cdn.com/v4/letter/o/2bfe46/32.png) [@OTTAVIO.C.T.UNISA](https://community.freefem.org/u/OTTAVIO.C.T.UNISA)
#### Post date: [January 9, 2024, 11:43am UTC](https://community.freefem.org/t/petsc-createmat-issues/2868/5 "2024-01-09T11:43:12Z")

</div>

I solved the problem just by updating my freefem version. Something was wrong in the installation. Anyway, now it works with any number of MPI processes. Thank you so much and sorry for taking your time.  
Best regards  
OCT
