# Saving data inside a loop

**URL:** <https://community.freefem.org/t/saving-data-inside-a-loop/561>\
**Category:** General Discussion\
**Created:** [September 1, 2020, 8:15pm UTC](https://community.freefem.org/t/saving-data-inside-a-loop/561 "2020-09-01T20:15:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mordechaiy](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@mordechaiy](https://community.freefem.org/u/mordechaiy)\
**Post date:** [September 1, 2020, 8:15pm UTC](https://community.freefem.org/t/saving-data-inside-a-loop/561/1 "2020-09-01T20:15:19Z")

</div>

Hello,

I have written in FreeFem++ a central differences scheme to the weak formulation of the 2D wave equation in a square. and initialized it with two initial conditions, then I have a loop for the time of the simulation, hence in each time of the simulation t is known and u^n-1 and u^n are given to scheme and u^n+1 is calculated, I wanted to ask, please how can I save the data of u^n and u^n+1 for each time of the simulation in an array or in a file.

Thanks,  
Mordechai.

---

<div class="post-metadata">

**Author:** ![Daoudi](https://avatars.discourse-cdn.com/v4/letter/d/3ec8ea/32.png) [@Daoudi](https://community.freefem.org/u/Daoudi)\
**Post date:** [March 31, 2021, 2:44pm UTC](https://community.freefem.org/t/saving-data-inside-a-loop/561/2 "2021-03-31T14:44:23Z")

</div>

Real [int,int] data(nt,m):// nt: mesh of Time , m: degree of freedom (numbers of nodes in the mesh)  
// m=Vh.ndof;  
for(t=0;I\<t;t++) //t : times  
Data(t,:)=u^n+1[];
