# Start from last step

**URL:** https://community.freefem.org/t/start-from-last-step/2208
**Category:** General Discussion
**Created:** [January 6, 2023, 3:59am UTC](https://community.freefem.org/t/start-from-last-step/2208 "2023-01-06T03:59:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mahdi](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@mahdi](https://community.freefem.org/u/mahdi)
#### Post date: [January 6, 2023, 3:59am UTC](https://community.freefem.org/t/start-from-last-step/2208/1 "2023-01-06T03:59:42Z")

</div>

Hi;

I am wondering if is there any way to Run FreeFem from a saved checkpoint?

Thanks

---

<div class="post-metadata">

### Author: ![julienG](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/julieng/32/222_2.png) [@julienG](https://community.freefem.org/u/julienG)
#### Post date: [January 6, 2023, 9:30am UTC](https://community.freefem.org/t/start-from-last-step/2208/2 "2023-01-06T09:30:09Z")

</div>

You can write a script like this

```auto
include "getARGV.idp" ;

int Index = getARGV("-index" , 0);

mesh Th; // define the mesh (empty)
fespace Vh(Th, P1); // define the finite element space

// Build or load mesh
if( !Index ){ // Build mesh for the first time
  Th = square(20,20);
  savemesh(Th,"Mesh.msh");
 }
 else{ // Otherwise read the mesh 
   Th=readmesh("Mesh.msh"); 
 }

Vh X1; // The FE-function

// Guess or load the functions
if( !Index ){ // Initial guess
  X1 = cos(x*2.0*pi)*sin(y*2.0*pi);
 }
 else{ // Otherwise read the data 
   ifstream input("iter="+(Index-1)+".fem");  
   input >> X1[] ;    
 }

// Do something her, I shift
real shift = 0.1*Index;
X1 = X1( (x+shift) - ((x+shift)<1. ? 0. : 1.) ,y);

// View and save
plot(X1,cmm="iter = "+Index,wait=1,fill=1,value=1);

{ ofstream output("iter="+Index+".fem");  
  output << X1[] ; };

```

Then you run your first iteration  
`> FreeFem++ your_script.edp -index 0`  
then your second iteration  
`> FreeFem++ your_script.edp -index 1`  
etc…

hope this helps
