# Save time step solution progress to continue next run

**URL:** https://community.freefem.org/t/save-time-step-solution-progress-to-continue-next-run/105
**Category:** General Discussion
**Created:** [August 7, 2019, 8:07pm UTC](https://community.freefem.org/t/save-time-step-solution-progress-to-continue-next-run/105 "2019-08-07T20:07:21Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![robin997](https://avatars.discourse-cdn.com/v4/letter/r/dfb087/32.png) [@robin997](https://community.freefem.org/u/robin997)
#### Post date: [August 7, 2019, 8:07pm UTC](https://community.freefem.org/t/save-time-step-solution-progress-to-continue-next-run/105/1 "2019-08-07T20:07:21Z")

</div>

Hi,

Just wondering if anyone has tried saving their time-step progress to continue in a different run. I found that I could export solution data with “ffmatlib” and “iovtk”. However, “ffmatlib” doesn’t have the function to import the data back. “iovtk” has the function “vtkload”, but I am only able to import the mesh details. The FreeFem++ documentation for “vtkload” function only shows “to-do”, so I don’t know how much this function could do.

Robin

---

<div class="post-metadata">

### Author: ![fotios.kasolis](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fotios.kasolis/32/18_2.png) [@fotios.kasolis](https://community.freefem.org/u/fotios.kasolis)
#### Post date: [August 8, 2019, 12:07pm UTC](https://community.freefem.org/t/save-time-step-solution-progress-to-continue-next-run/105/2 "2019-08-08T12:07:23Z")

</div>

Dear @robin997,

You can define your own function.

```auto
func int savesnaps(real[int] & u, int cnt) {
  ofstream file("results/snapshot." + cnt + ".txt", append);
  file.precision(16);
  for(int cnt = 0; cnt < u.n; cnt++){
    file << u[cnt] << endl;
  }
  return 0;
}

```

where you call it like `savesnaps(u[], tid)`, with `u` being a `fespace` function, and hence, `u[]` is the associated vector and `tid` is a unique time id. To reload the data

```auto
real[int] data(V.ndof);
ifstream file("results/snapshot.123.txt/"); // for snapshot at 123 time step
for (int cnt = 0; cnt < V.ndof; cnt++) {
  file >> data[cnt];
}
V ulast; ulast[] = data;

```

with `u[].n==V.ndof` and the same mesh.

Regards,  
/Fotios Kasolis

---

<div class="post-metadata">

### Author: ![robin997](https://avatars.discourse-cdn.com/v4/letter/r/dfb087/32.png) [@robin997](https://community.freefem.org/u/robin997)
#### Post date: [August 9, 2019, 12:09am UTC](https://community.freefem.org/t/save-time-step-solution-progress-to-continue-next-run/105/3 "2019-08-09T00:09:53Z")

</div>

@fotios.kasolis Thank you so much, it works great!
