# GMRES iteration options

**URL:** https://community.freefem.org/t/gmres-iteration-options/3202
**Category:** General Discussion
**Created:** [May 2, 2024, 11:37am UTC](https://community.freefem.org/t/gmres-iteration-options/3202 "2024-05-02T11:37:34Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Alexei](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@Alexei](https://community.freefem.org/u/Alexei)
#### Post date: [May 2, 2024, 11:37am UTC](https://community.freefem.org/t/gmres-iteration-options/3202/1 "2024-05-02T11:37:34Z")

</div>

Dear All,  
I would like to control the maximal number of iteration steps/absolute tolerance for the GMRES algorithm, but I couldn’t find the correct options.  
Thanks a lot for information,  
Alexei

---

<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: [May 2, 2024, 2:40pm UTC](https://community.freefem.org/t/gmres-iteration-options/3202/2 "2024-05-02T14:40:53Z")

</div>

Are you using PETSc?

---

<div class="post-metadata">

### Author: ![Alexei](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@Alexei](https://community.freefem.org/u/Alexei)
#### Post date: [May 2, 2024, 4:28pm UTC](https://community.freefem.org/t/gmres-iteration-options/3202/3 "2024-05-02T16:28:53Z")

</div>

It seems that on this particular machine load “PETSc” fails so this is the builtin (?) fgmres implementation,  
set(A, solver=GMRES)

---

<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: [May 2, 2024, 4:31pm UTC](https://community.freefem.org/t/gmres-iteration-options/3202/4 "2024-05-02T16:31:29Z")

</div>

Then, I do not know.

---

<div class="post-metadata">

### Author: ![mbukac](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/mbukac/32/1612_2.png) [@mbukac](https://community.freefem.org/u/mbukac)
#### Post date: [May 21, 2024, 5:51pm UTC](https://community.freefem.org/t/gmres-iteration-options/3202/5 "2024-05-21T17:51:45Z")

</div>

How to do it with PETSc?

---

<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: [May 21, 2024, 6:02pm UTC](https://community.freefem.org/t/gmres-iteration-options/3202/6 "2024-05-21T18:02:30Z")

</div>

`-ksp_max_it XY -ksp_rtol alpha -ksp_atol beta`. See also [KSPSetTolerances — PETSc 3.21.1 documentation](https://petsc.org/release/manualpages/KSP/KSPSetTolerances/) and [KSPSetFromOptions — PETSc 3.21.1 documentation](https://petsc.org/release/manualpages/KSP/KSPSetFromOptions/).

---

<div class="post-metadata">

### Author: ![mbukac](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/mbukac/32/1612_2.png) [@mbukac](https://community.freefem.org/u/mbukac)
#### Post date: [May 21, 2024, 11:17pm UTC](https://community.freefem.org/t/gmres-iteration-options/3202/7 "2024-05-21T23:17:21Z")

</div>

Thanks! Is there a way to display/output the number of iterations GMRES actually needed to converge?

---

<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: [May 22, 2024, 5:31am UTC](https://community.freefem.org/t/gmres-iteration-options/3202/8 "2024-05-22T05:31:30Z")

</div>

`-ksp_converged_reason`, it’s in the documentation I sent, so I suggest you read those links…
